  :root{
    --bg: #121212;
    --surface: #1a1a1a;
    --surface-2: #242424;
    --metal: #9a9a9a;
    --string: #d0d0d0;
    --inlay: #f0f0f0;

    /* Note colors on the neck. Each role differs from every other by hue AND
       lightness, so they stay distinct for red-green and blue-yellow color
       weakness, and from playing distance. Blue is used for nothing but the
       notes the player tapped (and the wordmark). */
    --yours: #4fb3f0;
    --yours-glow: rgba(79,179,240,0.5);
    --root-note: #ece3cf;          /* pearl — the lightest dot, finds home by brightness alone */

    /* Interface emphasis is neutral, so no UI chrome competes with the note colors. */
    --accent: #ececec;
    --accent-tint: rgba(255,255,255,0.08);
    --accent-tint-faint: rgba(255,255,255,0.04);
    --accent-border: rgba(255,255,255,0.28);
    --text: #f2f2f2;
    --text-muted: #999999;
    --mute: #4d4d4d;
    --border: #333333;
    --scale-note: #807b76;         /* warm gray — a background layer, clearly not yours */
    --scale-note-glow: rgba(236,227,207,0.55);
    --decide: #e69f00;             /* amber — reserved for decision notes */
    --decide-glow: rgba(230,159,0,0.55);
    --leaving: #d1573f;            /* warning text only, never a note color */
  }
  *{box-sizing:border-box;}
  /* No browser tap flash: blue is reserved for the player's notes. */
  html{ -webkit-tap-highlight-color: transparent; }
  button:focus-visible, select:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }
  html,body{margin:0;padding:0;}
  body{
    touch-action: manipulation; /* no double-tap zoom delay on fast taps */
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    /* Keep clear of notches and the home bar when installed full-screen. */
    padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
             max(40px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .wrap{ max-width: 1000px; margin: 0 auto; }

  header{ margin-bottom: 18px; }
  .brand{
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    letter-spacing: 0.04em;
    font-size: 22px;
    color: var(--text);
  }
  .brand span{ color: var(--yours); }
  .tagline{
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
  }

  .controls{
    display:flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 14px;
    align-items: center;
  }
  .control-group{
    display:flex;
    align-items:center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 8px;
  }
  .control-label{
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 4px;
    font-family: 'Inter', sans-serif; font-weight: 700;
  }
  select{
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 9px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    min-height: 44px;
  }
  .toggle{
    display:flex;
    background: var(--surface-2);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border);
  }
  .toggle button{
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 9px 14px;
    font-family: 'Inter', sans-serif; font-weight: 700;
    font-size: 12.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 44px;
  }
  .toggle button.active{
    background: var(--accent);
    color: #1c1712;
    font-weight: 600;
  }
  .clear-btn{
    background: var(--accent-tint);
    border: 1px solid var(--accent-border);
    color: var(--text);
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 12.5px;
    font-family: 'Inter', sans-serif; font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 44px;
    transition: background .15s ease, opacity .15s ease;
  }
  .clear-btn:hover:not(:disabled){ background: var(--accent); color: #1c1712; }
  .clear-btn:disabled{
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
    opacity: .5;
    cursor: default;
  }

  .neck-hint{
    font-size: 11.5px;
    color: var(--text-muted);
    margin: 0 0 8px 2px;
  }

  .neck-scroll{
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
  }
  .neck-scroll::-webkit-scrollbar{ height: 8px; }
  .neck-scroll::-webkit-scrollbar-thumb{ background: var(--border); border-radius: 4px; }

  svg{ display:block; }
  .fret-hit{ cursor: pointer; }
  .fret-hit .target{ fill: transparent; }
  .note-label{
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
  }
  .fret-num{
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    text-anchor: middle;
    fill: var(--text-muted);
    pointer-events: none;
  }
  .snum-label{
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    text-anchor: middle;
    fill: var(--text-muted);
    pointer-events: none;
    opacity: 0.75;
  }
  select.tuning-select{
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0 2px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--accent);
    font-weight: 700;
  }



  .viewer-controls{ margin-top:0; margin-bottom:12px; }
  .legend-box:not(:empty){
    margin-top: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
  }
  .legend-title{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:10px; letter-spacing:0.11em;
    text-transform:uppercase; color:var(--text-muted); margin-bottom:9px;
  }
  .legend-items{ display:flex; flex-wrap:wrap; gap:9px 18px; }
  .legend-item{
    display:flex; align-items:center; gap:9px;
    font-size:12.5px; color:var(--text); opacity:.9; line-height:1.35;
  }
  .swatch{
    width:19px; height:19px; border-radius:50%; flex-shrink:0;
    display:inline-block; box-sizing:border-box;
  }
  .sw-sel{ background:var(--yours); }
  .sw-root{ background:var(--root-note); }
  .sw-scale{ background:var(--scale-note); }
  .sw-arrive{ background:var(--scale-note); box-shadow:0 0 6px var(--scale-note-glow); }
  .sw-decide{ background:var(--decide); }
  .sw-view{ background:var(--scale-note); }
  .sw-viewroot{ background:var(--root-note); }
  .sw-yoursroot{ background:var(--yours); border:3px solid var(--root-note); }
  .results{
    margin-top: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
  }
  .results-label{
    font-family: 'Inter', sans-serif; font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
  }
  /* The answer — chord name or key — is the largest type on screen, sized to
     read from arm's length on a phone at band practice. */
  .answer-main{
    font-family: 'Inter', sans-serif; font-weight: 800;
    font-size: 44px; line-height: 1.05; letter-spacing: -0.01em;
  }
  .answer-alt{
    font-family: 'Inter', sans-serif; font-weight: 600;
    font-size: 20px; line-height: 1.3; color: var(--text-muted);
    margin-top: 6px; letter-spacing: normal;
  }
  .answer-sub{ margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
  .answer-sub b{ color: var(--text); font-weight: 600; }
  .notes-row{
    font-family: 'JetBrains Mono', monospace;
    font-size: 40px;
    font-weight: 700;
    letter-spacing: 0.04em;
    min-height: 34px;
    word-break: break-word;
  }
  .notes-row .empty{
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: normal;
  }
  .notes-detail{
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.6;
  }
  .next-hint{
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
  }


  .tone-line{
    display:flex; align-items:center; flex-wrap:wrap; gap:6px; margin-top:10px;
  }
  .tone-caption{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:10px; letter-spacing:0.1em;
    text-transform:uppercase; color:var(--text-muted); min-width:70px; white-space:nowrap; flex-shrink:0;
  }
  .tone{
    font-family:'JetBrains Mono',monospace; font-size:14px; font-weight:700;
    color:var(--text); background:var(--surface-2); border:1px solid var(--border);
    border-radius:6px; padding:4px 9px; min-width:34px; text-align:center;
  }
  .tone.deg{ color:var(--text-muted); font-size:13px; }
  .omitted{
    margin-top:10px; font-size:11.5px; color:var(--text-muted); font-style:italic;
  }



  .prog-chip{
    display:flex; align-items:center; gap:8px; cursor:pointer;
    background:var(--surface-2); border:1px solid var(--border); border-radius:8px;
    padding:4px 4px 4px 13px; min-height:44px; font-family:'JetBrains Mono',monospace; font-weight:700; font-size:14px;
    color:var(--text);
  }
  .prog-chip:hover{ border-color:var(--mute); }
  .prog-chip.active{ border-color:var(--accent); background:var(--accent-tint); }
  .key-callout{
    margin-bottom:16px; padding:13px 14px; background:var(--surface-2);
    border:1px solid var(--border); border-radius:10px;
  }
  .key-headline{ font-size:13px; color:var(--text); opacity:.92; margin-bottom:10px; line-height:1.5; }
  .key-headline b{ color:var(--accent); font-family:'JetBrains Mono',monospace; }
  .prog-suggest-title{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:10.5px; letter-spacing:0.11em;
    text-transform:uppercase; color:var(--text-muted); margin-bottom:12px;
  }
  .reshape-panel{
    margin-bottom:18px; padding:15px 15px 4px; border:1px solid var(--accent-border);
    background:var(--accent-tint-faint); border-radius:12px;
  }
  .reshape-title{ font-size:13px; color:var(--text); margin-bottom:13px; }
  .reshape-title b{ color:var(--accent); font-family:'JetBrains Mono',monospace; }
  .fingering-row{ margin-bottom:16px; }
  .fingering-label{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:10px; letter-spacing:0.1em;
    text-transform:uppercase; color:var(--text-muted); margin-bottom:8px;
  }
  .fingering-btns{ display:flex; flex-wrap:wrap; gap:8px; }
  .fingering-btn{
    display:flex; flex-direction:column; align-items:flex-start; gap:4px;
    background:var(--surface-2); border:1px solid var(--border); border-radius:9px;
    padding:9px 13px; cursor:pointer; min-height:52px;
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:11px; letter-spacing:0.03em;
    text-transform:uppercase; color:var(--text-muted);
  }
  .fingering-btn:hover{ border-color:var(--mute); }
  .fingering-btn.active{ border-color:var(--accent); color:var(--accent); background:var(--accent-tint); }
  .fingering-shape{
    font-family:'JetBrains Mono',monospace; font-size:12.5px; letter-spacing:0.08em;
    color:var(--text); text-transform:none;
  }
  .prog-panel:not(:empty){
    margin-top:14px; background:var(--surface); border:1px solid var(--border);
    border-radius:14px; padding:16px 18px;
  }
  .prog-header{ display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
  .prog-title{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:12px; letter-spacing:0.12em;
    text-transform:uppercase; color:var(--accent);
  }
  .prog-chips{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-bottom:14px; }
  .prog-chip{
    display:flex; align-items:center; gap:8px;
    background:var(--surface-2); border:1px solid var(--border); border-radius:8px;
    padding:8px 8px 8px 13px; font-family:'JetBrains Mono',monospace; font-weight:700; font-size:14px;
  }
  .chip-remove{
    background:transparent; border:none; color:var(--text-muted); cursor:pointer;
    font-size:17px; line-height:1; padding:10px 10px; margin:-6px -4px -6px 0; border-radius:6px;
  }
  .chip-remove:hover{ color:var(--leaving); background:rgba(199,123,107,0.12); }
  .prog-arrow{ color:var(--text-muted); font-size:14px; }
  .prog-slot{
    font-family:'JetBrains Mono',monospace; font-weight:700; font-size:14px;
    color:var(--text-muted); border:1px dashed var(--border); border-radius:8px; padding:8px 14px;
  }
  .key-row{
    display:flex; align-items:center; gap:8px; margin-bottom:16px; padding-bottom:16px;
    border-bottom:1px solid var(--border); flex-wrap:wrap;
  }
  .key-row select{ min-height:44px; padding:7px 9px; }
  .sugg-group{ margin-bottom:16px; }
  .sugg-group:last-child{ margin-bottom:0; }
  .sugg-title{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:11.5px; letter-spacing:0.08em;
    text-transform:uppercase; color:var(--text); margin-bottom:8px;
  }
  .sugg-blurb{
    display:block; font-family:'Inter',sans-serif; font-size:11.5px;
    letter-spacing:normal; text-transform:none; color:var(--text-muted); font-weight:400; margin-top:2px;
  }
  .sugg-list{ display:flex; flex-direction:column; gap:7px; }
  .sugg-item{
    text-align:left; cursor:pointer; width:100%;
    background:var(--surface-2); border:1px solid var(--border); border-radius:9px; padding:10px 13px;
  }
  .sugg-item:hover{ border-color:var(--mute); }
  .sugg-head{ display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
  .sugg-name{ font-family:'JetBrains Mono',monospace; font-weight:700; font-size:15px; color:var(--text); }
  .sugg-tag{
    font-size:10.5px; color:var(--accent); font-family:'Inter',sans-serif;
    background:var(--accent-tint); border-radius:5px; padding:2px 7px; white-space:nowrap;
  }
  .sugg-reason{
    display:block; font-size:12px; color:var(--text-muted); line-height:1.5; margin-top:5px;
    font-family:'Inter',sans-serif;
  }

  .already-added{
    font-size:12.5px; color:var(--text-muted); margin-bottom:2px;
    display:flex; align-items:center; gap:6px;
  }
  .add-prog-btn{ margin-top:14px; }
  .why-box{ margin-top:16px; }
  .why-title{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:10px; letter-spacing:0.11em;
    text-transform:uppercase; color:var(--text-muted); margin-bottom:8px;
  }
  .why-box p{
    margin:0 0 9px; font-size:13.5px; line-height:1.62; color:var(--text);
    opacity:.92;
  }
  .why-box p:last-child{ margin-bottom:0; }
  .why-box b{ color:var(--accent); font-weight:600; }
  .root-box:not(:empty){ margin-top:14px; }
  .root-title{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:10px; letter-spacing:0.11em;
    text-transform:uppercase; color:var(--text-muted); margin-bottom:9px;
  }
  .root-btns{ display:flex; flex-wrap:wrap; gap:7px; }
  .root-btn{
    background:var(--surface-2); border:1px solid var(--border); color:var(--text-muted);
    border-radius:8px; padding:9px 14px; min-height:44px; min-width:48px; cursor:pointer;
    font-family:'JetBrains Mono',monospace; font-size:13px; font-weight:700;
  }
  .root-btn:hover{ color:var(--text); border-color:var(--mute); }
  .root-btn.active{ background:var(--accent); color:#1c1712; border-color:var(--accent); }

  .riff-note{ font-size:12.5px; color:var(--text-muted); line-height:1.55; margin:0 0 12px; }
  .scale-list{ display:flex; flex-direction:column; gap:7px; }
  .scale-row{
    display:flex; justify-content:space-between; align-items:center; gap:10px;
    width:100%; text-align:left; cursor:pointer; min-height:46px;
    background:var(--surface-2); border:1px solid var(--border); border-radius:9px; padding:10px 13px;
  }
  .scale-row.scale-row-mood{ flex-direction:column; align-items:stretch; gap:5px; }
  .scale-row-head{ display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
  .scale-mood{
    font-size:12px; color:var(--text-muted); font-family:'Inter',sans-serif;
    line-height:1.45; opacity:.95;
  }
  .scale-row.active .scale-mood{ color:var(--text); opacity:.85; }
  .scale-row:hover{ border-color:var(--mute); }
  .scale-row.active{ border-color:var(--accent); background:var(--accent-tint); }
  .scale-name{ font-family:'JetBrains Mono',monospace; font-size:14px; font-weight:700; color:var(--text); }
  .scale-row.active .scale-name{ color:var(--accent); }
  .scale-fit{ font-size:11px; color:var(--text-muted); font-family:'Inter',sans-serif; white-space:nowrap; }
  .decide-list{ display:flex; flex-direction:column; gap:8px; }
  .decide-row{
    display:flex; align-items:flex-start; gap:12px; width:100%; text-align:left; cursor:pointer;
    background:var(--surface-2); border:1px solid var(--border); border-radius:9px; padding:11px 13px;
  }
  .decide-row:hover{ border-color:var(--mute); }
  .decide-row.active{ border-color:var(--decide); background:rgba(230,159,0,0.12); }
  .decide-note{
    font-family:'JetBrains Mono',monospace; font-size:16px; font-weight:700;
    color:var(--decide); min-width:34px; flex-shrink:0;
  }
  .decide-text{ font-size:12.5px; color:var(--text); line-height:1.5; opacity:.9; }
  .decide-text b{ color:var(--text-muted); font-weight:500; }
  .decide-out{ color:var(--text-muted); font-size:11.5px; }

  .compare-box:not(:empty){ margin-top:20px; padding-top:18px; border-top:1px solid var(--border); }
  .explorer-box:not(:empty){ margin-top:18px; }
  .move-row{ display:flex; flex-wrap:wrap; gap:8px; }
  .move-chip{
    display:flex; align-items:center; gap:7px;
    background:var(--surface-2); border:1px solid var(--border);
    border-radius:8px; padding:8px 12px;
    font-family:'JetBrains Mono',monospace; font-size:15px; font-weight:700;
  }
  /* The strike-through carries "leaving", so no color is needed for it. */
  .move-chip .from{ color:var(--text-muted); text-decoration:line-through; }
  .move-chip .to{ color:var(--text); }
  .move-chip .arrow{ color:var(--text-muted); font-size:13px; }


  .exp-filter{ margin:12px 0 4px; width:fit-content; }
  .exp-filter button{ padding:8px 13px; font-size:11.5px; min-height:44px; }
  .exp-row.conflicts{ opacity:.72; }
  .exp-conflict{
    font-size:11.5px; color:var(--leaving); line-height:1.45;
    font-family:'Inter',sans-serif; margin-top:2px;
  }
  .exp-row{ flex-direction:column; align-items:stretch; gap:6px; padding:12px 13px; }
  .exp-head{ display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
  .exp-plain{ font-size:12.5px; color:var(--text); opacity:.82; line-height:1.5; font-family:'Inter',sans-serif; }
  .exp-heard{ font-size:11.5px; color:var(--text-muted); line-height:1.45; font-family:'Inter',sans-serif; }
  .exp-heard b{ color:var(--accent); font-weight:600; opacity:.9; }

  .exp-group{ margin-top:16px; }
  .exp-group-name{
    font-family: 'Inter', sans-serif; font-weight: 700; font-size:12px; letter-spacing:0.07em;
    text-transform:uppercase; color:var(--accent); margin-bottom:8px;
  }
  .exp-group-blurb{
    display:block; font-family:'Inter',sans-serif; font-size:11.5px;
    letter-spacing:normal; text-transform:none; color:var(--text-muted);
    font-weight:400; margin-top:2px;
  }


  .switch-row{
    display:flex; align-items:center; gap:11px; margin-top:14px;
    cursor:pointer; user-select:none; min-height:40px;
  }
  .switch-row input{ position:absolute; opacity:0; width:0; height:0; }
  .switch-track{
    width:44px; height:25px; border-radius:13px; flex-shrink:0;
    background:var(--surface-2); border:1px solid var(--border);
    position:relative; transition:background .18s ease, border-color .18s ease;
  }
  .switch-knob{
    position:absolute; top:2px; left:2px; width:19px; height:19px; border-radius:50%;
    background:var(--text-muted); transition:transform .18s ease, background .18s ease;
  }
  .switch-row input:checked + .switch-track{
    background:rgba(199,123,107,0.22); border-color:var(--leaving);
  }
  .switch-row input:checked + .switch-track .switch-knob{
    transform:translateX(19px); background:var(--leaving);
  }
  .switch-row input:focus-visible + .switch-track{ outline:2px solid var(--accent); outline-offset:2px; }
  .switch-label{ font-size:12.5px; color:var(--text); opacity:.9; }
  .pinned{
    margin-top:12px; padding:11px 13px;
    background:var(--accent-tint-faint);
    border:1px solid var(--accent-border);
    border-radius:9px;
  }
  .pinned-head{ font-size:12.5px; color:var(--text); opacity:.92; }
  .pinned-head b{ color:var(--accent); font-family:'JetBrains Mono',monospace; }
  .alt-box{ margin-top:16px; }
  .alt-toggle{
    background:transparent; border:1px solid var(--border); color:var(--text-muted);
    border-radius:8px; padding:9px 13px; font-family: 'Inter', sans-serif; font-weight: 700;
    font-size:11.5px; letter-spacing:0.06em; text-transform:uppercase;
    cursor:pointer; min-height:44px; display:flex; align-items:center; gap:8px;
  }
  .alt-toggle:hover{ color:var(--text); border-color:var(--mute); }
  .alt-toggle .chev{ transition: transform .18s ease; display:inline-block; }
  .alt-toggle.open .chev{ transform: rotate(180deg); }
  .alt-list{ margin-top:10px; display:flex; flex-direction:column; gap:8px; }
  .alt-item{
    display:flex; flex-wrap:wrap; align-items:baseline; gap:10px;
    background:var(--surface-2); border:1px solid var(--border);
    border-radius:8px; padding:9px 12px;
  }
  .alt-name{ font-family:'JetBrains Mono',monospace; font-weight:700; font-size:15px; color:var(--text); }
  .alt-notes{ font-family:'JetBrains Mono',monospace; font-size:12px; color:var(--text-muted); }
  .alt-degs{ font-family:'JetBrains Mono',monospace; font-size:12px; color:var(--text-muted); }
  @media (max-width:480px){ .tone-caption{ width:100%; } }


  .header-row{ display:flex; justify-content:space-between; align-items:flex-start; gap:14px; }
  .help-link{
    background:transparent; border:1px solid var(--border); color:var(--text-muted);
    border-radius:8px; padding:8px 13px; font-family:'Inter',sans-serif; font-size:12.5px;
    font-weight:600; cursor:pointer; white-space:nowrap; min-height:44px; flex-shrink:0;
  }
  .help-link:hover{ border-color:var(--accent); color:var(--accent); }

  .help-overlay{
    position:fixed; inset:0; background:rgba(6,7,8,0.72);
    display:flex; align-items:flex-start; justify-content:center;
    padding:40px 16px; z-index:1000; overflow-y:auto;
  }
  .help-overlay[hidden]{ display:none; }
  .help-panel{
    background:var(--surface); border:1px solid var(--border); border-radius:16px;
    max-width:640px; width:100%; max-height:calc(100vh - 80px); display:flex; flex-direction:column;
  }
  .help-header{
    display:flex; justify-content:space-between; align-items:center;
    padding:18px 20px; border-bottom:1px solid var(--border); flex-shrink:0;
  }
  .help-title{ font-family:'Inter',sans-serif; font-weight:800; font-size:17px; color:var(--text); }
  .help-close{
    background:transparent; border:none; color:var(--text-muted); font-size:22px;
    line-height:1; cursor:pointer; padding:10px 14px; min-width:44px; min-height:44px; border-radius:6px;
  }
  .help-close:hover{ color:var(--text); background:var(--surface-2); }
  .help-body{ padding:20px 22px 24px; overflow-y:auto; }
  .help-section{ margin-bottom:20px; }
  .help-section:last-child{ margin-bottom:0; }
  .help-h{
    font-family:'Inter',sans-serif; font-weight:700; font-size:13.5px;
    color:var(--accent); margin-bottom:8px;
  }
  .help-body ul{ margin:0; padding-left:19px; }
  .help-body li{
    font-size:13px; color:var(--text); opacity:.9; line-height:1.55; margin-bottom:6px;
  }
  .help-body li:last-child{ margin-bottom:0; }
  .help-body b{ color:var(--text); opacity:1; }

  @media (max-width: 480px){
    .brand{ font-size: 19px; }
    .notes-row{ font-size: 34px; }
    .answer-main{ font-size: 38px; }
    .answer-alt{ font-size: 17px; }
  }


  /* ---- Top bar: the only controls touched mid-practice ---- */
  .topbar{
    display:flex; align-items:center; gap:8px; flex-wrap:nowrap;
    margin: 16px 0 12px;
  }
  .setup-chip{
    flex: 1 1 0; min-width: 0; max-width: 300px; min-height: 44px;
    display:flex; align-items:center; justify-content:space-between; gap:8px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    padding: 0 10px; cursor: pointer;
    font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 12.5px;
  }
  .setup-chip-text{ display:flex; flex-direction:column; align-items:flex-start; min-width:0; line-height:1.15; text-align:left; }
  .setup-inst{
    font-family:'Inter',sans-serif; font-weight:700; font-size:9.5px; letter-spacing:0.09em;
    text-transform:uppercase; color:var(--text-muted);
  }
  .setup-tuning{
    font-family:'Inter',sans-serif; font-weight:700; font-size:14px; color:var(--text);
    max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  }
  .setup-inst, .setup-tuning{ display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .setup-chip .chev{ color: var(--text-muted); transition: transform .18s ease; }
  .setup-chip[aria-expanded="true"]{ border-color: var(--accent-border); }
  .setup-chip[aria-expanded="true"] .chev{ transform: rotate(180deg); }
  .mode-toggle{ flex: 0 0 auto; margin-left: auto; } /* on wide screens, controls sit right */
  .mode-toggle button{ padding: 9px 12px; }
  .topbar .clear-btn{ flex: 0 0 auto; padding: 9px 12px; }

  /* ---- Setup panel: set once, then closed ---- */
  .setup-panel{
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px; margin: 0 0 14px;
  }
  .setup-panel[hidden]{ display:none; }
  .setup-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
  .setup-field{ display:flex; flex-direction:column; gap:6px; min-width:0; }
  .setup-field .control-label{ padding:0; }
  .setup-field select{ width:100%; }
  .setup-field .toggle{ width:fit-content; }
  .setup-wide{ grid-column: 1 / -1; }
  .viewer-row{ display:flex; gap:8px; flex-wrap:wrap; }
  .viewer-row #viewerRoot{ flex: 0 0 84px; }
  .viewer-row #viewerScale{ flex: 1 1 140px; min-width:0; }
  .setup-note{ margin: 12px 0 0; font-size: 12px; color: var(--text-muted); }
  .setup-done{ margin-top: 12px; width: 100%; }

  /* Narrow Android phones: give the setup chip a few more pixels. */
  @media (max-width: 380px){
    .topbar{ gap: 6px; }
    .mode-toggle button{ padding: 9px 9px; }
    .topbar .clear-btn{ padding: 9px 9px; }
    .setup-chip{ padding: 0 8px; }
  }

  /* ---- Install instructions in the help panel ---- */
  .install-help{ padding-bottom: 18px; border-bottom: 1px solid var(--border); }
  .install-text{ margin: 0 0 10px; font-size: 13px; line-height: 1.55; color: var(--text); opacity: .9; }
