/************************************************************
 * FretNerd
 * Copyright (c) 2026 Scott Farris / Tilted Iron
 * Proprietary and confidential. Unauthorized use prohibited.
 ************************************************************/

    /* ═══════════════════════════════════════════════
       RESET & TOKENS
    ═══════════════════════════════════════════════ */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      --bg:       #f2f2ee;
      --surface:  #ffffff;
      --border:   #e2e2de;
      --text:     #1a1a1a;
      --text2:    #666666;
      --text3:    #aaaaaa;
      --teal:     #1D9E75;
      --teal-dk:  #0F6E56;
      --teal-lt:  #E1F5EE;
      --teal-txt: #085041;
      --red:      #E24B4A;
      --red-lt:   #FCEBEB;
      --red-txt:  #791F1F;
      --amber-lt: #FAEEDA;
      --amber-txt:#633806;
      --purple-lt:#EEEDFE;
      --purple-txt:#3C3489;
      --blue-lt:  #E6F1FB;
      --blue-txt: #0C447C;
      --radius:   10px;
      --gap:      8px;
      --pad:      10px 14px;
      --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    }
    @media (prefers-color-scheme: dark) {
      :root {
        --bg:       #181818;
        --surface:  #232323;
        --border:   #333333;
        --text:     #f0f0f0;
        --text2:    #999999;
        --text3:    #555555;
        --teal-lt:  #0a2e22;
        --teal-txt: #9FE1CB;
        --red-lt:   #2e1111;
        --red-txt:  #F09595;
        --amber-lt: #271900;
        --amber-txt:#FAC775;
        --purple-lt:#1a1840;
        --purple-txt:#AFA9EC;
        --blue-lt:  #0c1e30;
        --blue-txt: #85B7EB;
      }
    }
    html, body { height: 100%; width: 100%; font-family: var(--font); background: var(--bg); color: var(--text); }

    /* ═══════════════════════════════════════════════
       APP SHELL
    ═══════════════════════════════════════════════ */
    #app { display: flex; flex-direction: column; width: 100%; height: 100%; padding: var(--pad); gap: var(--gap); position: relative; }

    /* ═══════════════════════════════════════════════
       COMMON COMPONENTS
    ═══════════════════════════════════════════════ */
    .pill {
      font-size: 12px; font-weight: 500; padding: 3px 9px;
      border-radius: 999px; background: var(--surface);
      border: 1px solid var(--border); color: var(--text2); white-space: nowrap;
    }
    .pill b { font-weight: 700; color: var(--text); }
    .txt-btn {
      font-size: 12px; background: none; border: none; cursor: pointer;
      color: var(--text3); text-decoration: underline; white-space: nowrap;
      -webkit-tap-highlight-color: transparent; font-family: var(--font);
    }
    .sec-lbl {
      font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
      color: var(--text3); font-weight: 600; margin-bottom: 8px;
    }
    /* toggle button */
    .tog-btn {
      padding: 9px 6px; font-size: 13px; font-weight: 600; border-radius: 8px;
      cursor: pointer; border: 1px solid var(--border); background: var(--surface);
      color: var(--text2); text-align: center; font-family: var(--font);
      -webkit-tap-highlight-color: transparent; -webkit-appearance: none; appearance: none;
    }
    .tog-btn.on { border-width: 2px; border-color: var(--teal-dk); background: var(--teal); color: #fff; }
    /* grid helpers */
    .grid2 { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--gap); }
    .grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--gap); }
    .grid4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--gap); }
    /* mode segment */
    .seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 1.25rem; }
    .seg-btn {
      flex: 1; padding: 10px 8px; font-size: 13px; font-weight: 600;
      background: var(--surface); border: none; cursor: pointer; color: var(--text2);
      font-family: var(--font); -webkit-tap-highlight-color: transparent; -webkit-appearance: none;
    }
    .seg-btn.study-sel   { background: var(--amber-lt);  color: var(--amber-txt); }
    .seg-btn.practice-sel{ background: var(--purple-lt); color: var(--purple-txt); }
    .seg-btn + .seg-btn  { border-left: 1px solid var(--border); }
    /* experience cards */
    .exp-card {
      border: 2px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
      cursor: pointer; margin-bottom: 8px; background: var(--surface);
      -webkit-tap-highlight-color: transparent;
    }
    .exp-card:last-of-type { margin-bottom: 0; }
    .exp-card.selected { border-color: var(--teal); background: var(--teal-lt); }
    .exp-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
    .exp-card-desc  { font-size: 11px; color: var(--text2); margin-top: 2px; }
    /* action buttons */
    .action-row { display: flex; gap: var(--gap); margin-top: 1.25rem; }
    .action-btn {
      flex: 1; padding: 11px; font-size: 13px; font-weight: 500;
      background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
      cursor: pointer; color: var(--text); font-family: var(--font);
      -webkit-tap-highlight-color: transparent; -webkit-appearance: none;
    }
    .action-btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); font-size: 14px; font-weight: 700; flex: 2; }
    .action-btn.danger  { color: var(--red); }
    /* stats grid */
    .sp-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--gap); margin-bottom: 1.25rem; }
    .sp-stat { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
    .sp-stat-val { font-size: 20px; font-weight: 600; color: var(--text); }
    .sp-stat-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text3); margin-top: 2px; }
    /* legend */
    .legend { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
    .ldot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: middle; }
    .legend span { font-size: 12px; color: var(--text2); }
    /* weak items */
    .weak-item { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
    .weak-item:last-child { border-bottom: none; }
    /* summary table */
    .sum-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 1rem; }
    .sum-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); font-weight: 600; padding: 3px 6px 6px 0; border-bottom: 1px solid var(--border); }
    .sum-table th:not(:first-child) { text-align: right; }
    .sum-table td { padding: 6px 6px 6px 0; border-bottom: 1px solid var(--border); color: var(--text); }
    .sum-table td:not(:first-child) { text-align: right; }
    .sum-table tr:last-child td { border-bottom: none; }

    /* ═══════════════════════════════════════════════
       TOPBAR
    ═══════════════════════════════════════════════ */
    #topbar {
      display: grid;
      grid-template-columns: auto 1fr auto;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
    }
    #topbar-home {
      font-size: 18px; background: none; border: none; cursor: pointer;
      color: var(--text2); padding: 4px 6px; flex-shrink: 0;
      -webkit-tap-highlight-color: transparent; line-height: 1;
    }
    #topbar-module-name {
      font-size: 13px; font-weight: 700; color: var(--text);
      text-align: center; white-space: nowrap; overflow: hidden;
      min-width: 0; text-overflow: ellipsis;
    }
    #topbar-right {
      display: flex; align-items: center; gap: 4px; justify-content: flex-end;
    }

    #topbar-overflow-btn,
    .topbar-menu { display: none; }

    #app.simple-module #topbar-overflow-btn,
    #app.simple-module .topbar-wide-only { display: none; }

    .topbar-menu {
      position: absolute;
      top: 44px;
      right: 8px;
      z-index: 50;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 4px;
      min-width: 140px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    }
    .topbar-menu.open { display: flex; flex-direction: column; }

    .topbar-menu-item {
      display: flex; align-items: center; gap: 8px;
      padding: 9px 10px; font-size: 13px; font-weight: 600;
      background: none; border: none; border-radius: 6px;
      color: var(--text2); text-align: left; cursor: pointer;
      font-family: var(--font); -webkit-tap-highlight-color: transparent;
    }
    .topbar-menu-item:hover, .topbar-menu-item:active {
      background: var(--border); color: var(--text);
    }

    @media (max-width: 500px) {
      #topbar-right .topbar-wide-only { display: none; }
      #topbar-overflow-btn { display: flex; }
    }
    /* ═══════════════════════════════════════════════
       SVG ICON BUTTONS
    ═══════════════════════════════════════════════ */
    .icon-btn {
      background: none; border: none; cursor: pointer; padding: 6px;
      color: var(--text2); display: flex; align-items: center; justify-content: center;
      border-radius: 6px; -webkit-tap-highlight-color: transparent;
      -webkit-appearance: none; flex-shrink: 0;
      transition: color 0.15s, background 0.15s;
    }
    .icon-btn:hover  { background: var(--border); color: var(--text); }
    .icon-btn:active { background: var(--border); color: var(--text); }
    .icon-btn svg { display: block; }
    #pause-btn {
      display: flex; align-items: center; gap: 5px;
      font-size: 12px; font-weight: 600; padding: 5px 10px;
      border-radius: 6px; border: 1px solid var(--border);
      background: var(--surface); cursor: pointer;
      color: var(--text2); font-family: var(--font);
      -webkit-tap-highlight-color: transparent; flex-shrink: 0;
    }
    #pause-btn svg { display: block; flex-shrink: 0; }

    /* stats pills row — shown below topbar on portrait phone, inline on wider screens */
    #stats-row {
      display: flex; align-items: center; gap: 6px;
      flex-shrink: 0; flex-wrap: nowrap; overflow: hidden;
    }
    #prog-bg { flex: 1; min-width: 40px; height: 5px; background: var(--border); border-radius: 3px; }
    #prog-fill { height: 5px; background: var(--teal); border-radius: 3px; width: 0%; transition: width 0.5s; }
    #mastered-pill { background: var(--teal-lt); border-color: var(--teal); color: var(--teal-txt); }
    #stats-practice-pills { display: none; align-items: center; gap: 6px; }
    #stats-practice-pills.show { display: flex; }
    .stats-divider { width: 1px; height: 14px; background: var(--border); flex-shrink: 0; }

    /* ═══════════════════════════════════════════════
       MODE TABS
    ═══════════════════════════════════════════════ */
    #mode-tabs {
      display: flex; flex-shrink: 0;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 8px; overflow: hidden;
    }
    .mode-tab {
      flex: 1; padding: 8px 12px; font-size: 13px; font-weight: 600;
      border: none; cursor: pointer; background: transparent;
      color: var(--text2); font-family: var(--font);
      -webkit-tap-highlight-color: transparent; -webkit-appearance: none;
      transition: background 0.15s, color 0.15s;
    }
    .mode-tab + .mode-tab { border-left: 1px solid var(--border); }
    .mode-tab.active-study    { background: var(--amber-lt);  color: var(--amber-txt); }
    .mode-tab.active-practice { background: var(--purple-lt); color: var(--purple-txt); }

    /* ═══════════════════════════════════════════════
       STAGE BAR (Music Fundamentals only)
    ═══════════════════════════════════════════════ */
    #stage-bar {
      display: flex; flex-shrink: 0;
      padding: 4px 0 2px;
    }
    .stage-dot-item {
      display: flex; flex-direction: column; align-items: center;
      flex: 1; cursor: pointer; position: relative;
      background: none; border: none; font-family: var(--font);
      -webkit-tap-highlight-color: transparent; -webkit-appearance: none;
    }
    .stage-dot-item::after {
      content: ''; position: absolute; top: 11px;
      left: calc(50% + 11px); right: calc(-50% + 11px);
      height: 1px; background: var(--border);
    }
    .stage-dot-item:last-child::after { display: none; }
    .stage-dot {
      width: 22px; height: 22px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 11px; font-weight: 700; margin-bottom: 3px;
      position: relative; z-index: 1; transition: all 0.15s;
    }
    .stage-dot.done   { background: var(--teal); color: #fff; }
    .stage-dot.active { background: var(--surface); border: 2px solid var(--teal); color: var(--teal); }
    .stage-dot.locked { background: var(--surface); color: var(--text3); border: 1px solid var(--border); }
    .stage-label {
      font-size: 9px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.04em; color: var(--text3); text-align: center;
    }
    .stage-dot-item.active .stage-label { color: var(--teal); }
    .stage-dot-item.done .stage-label   { color: var(--teal); opacity: 0.7; }

    /* ═══════════════════════════════════════════════
       MUSIC FUNDAMENTALS — STUDY CONTENT
    ═══════════════════════════════════════════════ */
    .fund-lesson-card {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 14px;
    }
    .fund-eyebrow {
      font-size: 11px; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.06em; color: var(--teal); margin-bottom: 4px;
      display: flex; align-items: center;
    }
    .fund-title {
      font-size: 19px; font-weight: 700; color: var(--text);
      margin-bottom: 6px; line-height: 1.2;
    }
    .fund-body { font-size: 14px; color: var(--text2); line-height: 1.55; }
    .fund-body strong { color: var(--text); }

    .fund-string-diagram {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 12px 10px;
    }
    .fund-string-label {
      font-size: 12px; font-weight: 600; text-transform: uppercase;
      letter-spacing: 0.05em; color: var(--text2); text-align: center; margin-bottom: 8px;
    }
    .fund-string-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .fund-string-wrap svg { min-width: 480px; }
    .fund-callout {
      background: var(--teal-lt); border: 1px solid var(--teal);
      border-radius: 8px; padding: 9px 11px; font-size: 13px; color: var(--text2);
    }
    .fund-callout strong { color: var(--teal-txt); }

    .fund-section-divider {
      display: flex; align-items: center; gap: 8px;
    }
    .fund-section-divider span {
      font-size: 12px; font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.08em; color: var(--text2); white-space: nowrap;
    }
    .fund-section-divider::before, .fund-section-divider::after {
      content: ''; flex: 1; height: 1px; background: var(--border);
    }

    .fund-alpha-note {
      width: 36px; height: 36px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px; font-weight: 700; background: var(--bg);
      border: 1px solid var(--border); color: var(--text); cursor: pointer;
      transition: all 0.15s; -webkit-tap-highlight-color: transparent;
    }
    .fund-alpha-note:hover { border-color: var(--teal); color: var(--teal); }
    .fund-alpha-note.active { background: var(--teal); color: #fff; border-color: var(--teal); }
    .fund-alpha-arrow { color: var(--text2); font-size: 14px; }
    .fund-alpha-repeat {
      font-size: 16px; font-weight: 600; color: var(--text);
      text-align: center; margin-top: 6px;
    }

    .fund-step-note {
      width: 38px; height: 38px; border-radius: 8px;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px; font-weight: 700; background: var(--bg);
      border: 1px solid var(--border); color: var(--text); cursor: pointer;
      transition: all 0.15s; -webkit-tap-highlight-color: transparent;
    }
    .fund-step-note:hover { border-color: var(--teal); }
    .fund-step-note.active { background: var(--teal); color: #fff; border-color: var(--teal); }

    .fund-chrom-note {
      border-radius: 8px; cursor: pointer; transition: all 0.15s;
      -webkit-tap-highlight-color: transparent; font-weight: 700;
    }
    .fund-chrom-note.natural {
      width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
      background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: 15px;
    }
    .fund-chrom-note.acc {
      padding: 0 8px; height: 38px; display: flex; align-items: center; justify-content: center;
      background: transparent; border: 1px dashed var(--text3); color: var(--text2); font-size: 11px;
    }
    .fund-chrom-note:hover { border-color: var(--teal); color: var(--teal-txt); }
    .fund-chrom-note.hl-nat, .fund-chrom-note.hl-acc { background: var(--teal-lt); border-color: var(--teal); color: var(--teal-txt); }

    .fund-enharm-pill {
      padding: 6px 16px; border-radius: 24px; font-size: 20px; font-weight: 800;
      background: var(--bg); border: 1px solid var(--border); color: var(--text);
    }

    .fund-key-btn {
      padding: 6px 12px; border-radius: 16px; font-size: 13px; font-weight: 700;
      cursor: pointer; border: 1px solid var(--border); background: var(--bg);
      color: var(--text2); -webkit-tap-highlight-color: transparent; font-family: var(--font);
    }
    .fund-key-btn:hover { border-color: var(--text3); color: var(--text); }
    .fund-key-btn.active { background: var(--teal-lt); border-color: var(--teal); color: var(--teal-txt); }

    /* ═══════════════════════════════════════════════
       STAGE 4 — KEYS & KEY SIGNATURES
    ═══════════════════════════════════════════════ */
    .fund-subnav { display: flex; gap: 10px; margin-top: 6px; }
    .fund-subnav-btn {
      padding: 0 18px; border-radius: var(--radius); background: var(--bg);
      border: 1px solid var(--border); color: var(--text2); font-size: 14px; font-weight: 700;
      cursor: pointer; font-family: var(--font); -webkit-appearance: none;
    }
    .fund-subnav-btn:disabled { opacity: 0.3; cursor: default; }
    .fund-subnav-btn:not(:disabled):hover { border-color: var(--text3); color: var(--text); }

    .fund-formula-row { display: flex; gap: 5px; justify-content: center; margin: 10px 0; flex-wrap: wrap; }
    .fund-formula-step {
      width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
      font-size: 14px; font-weight: 800; background: var(--bg); border: 1px solid var(--border);
    }
    .fund-formula-step.whole { color: var(--text2); }
    .fund-formula-step.half  { color: var(--teal-txt); border-color: var(--teal); background: var(--teal-lt); }

    .fund-scale-builder, .fq-construct-slots { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 12px 0; }
    .fund-scale-note {
      min-width: 36px; height: 36px; padding: 0 6px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
      font-size: 15px; font-weight: 800; background: var(--bg); border: 1px solid var(--border); color: var(--text);
    }
    .fund-scale-note.root { background: var(--teal); color: #fff; border-color: var(--teal); }
    .fq-formula-connector { font-size: 10px; font-weight: 800; width: 16px; text-align: center; flex-shrink: 0; }
    .fq-formula-connector.half { color: var(--teal-txt); }
    .fq-formula-connector.whole { color: var(--text3); }

    .fund-signature-summary {
      margin-top: 12px; padding: 12px; border-radius: var(--radius); background: var(--bg);
      border: 1px solid var(--border); text-align: center;
    }
    .fund-sig-count { font-size: 24px; font-weight: 800; color: var(--teal-txt); }
    .fund-sig-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); }
    .fund-sig-accidentals { margin-top: 4px; font-size: 14px; font-weight: 700; color: var(--text); }

    /* construction UI for "Build the scale" */
    .fq-construct-slot {
      width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
      font-size: 15px; font-weight: 800; background: var(--bg); border: 2px dashed var(--border); color: var(--text2);
      position: relative; cursor: default;
    }
    .fq-construct-slot.root-slot { border-color: var(--teal); }
    .fq-construct-slot.filled { border-style: solid; color: var(--text); cursor: pointer; }
    .fq-construct-slot.filled.root-slot { background: var(--teal); color: #fff; border-color: var(--teal); }
    .fq-construct-slot.right { background: var(--teal-lt); border-color: var(--teal); color: var(--teal-txt); }
    .fq-construct-slot.wrong { background: var(--red-lt); border-color: var(--red); color: var(--red-txt); }
    .fq-construct-correction {
      position: absolute; bottom: -18px; left: 0; right: 0; text-align: center;
      font-size: 10px; font-weight: 700; color: var(--teal-txt);
    }
    .fq-construct-hint { text-align: center; font-size: 10px; color: var(--text3); margin: -4px 0 2px; }
    .fq-construct-pool { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 12px 0 4px; padding-top: 10px; border-top: 1px solid var(--border); }
    .fq-construct-pool-note {
      min-width: 40px; height: 40px; padding: 0 8px; border-radius: 8px; font-size: 14px; font-weight: 700;
      background: var(--bg); border: 1px solid var(--border); color: var(--text); cursor: pointer;
      font-family: var(--font); -webkit-appearance: none;
    }
    .fq-construct-pool-note:disabled { opacity: 0.25; cursor: default; }
    .fq-construct-actions { display: flex; gap: 10px; align-items: stretch; }
    .fq-undo-btn {
      padding: 0 16px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border);
      color: var(--text2); font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--font);
      -webkit-appearance: none;
    }
    .fq-undo-btn:disabled { opacity: 0.3; cursor: default; }

    /* read-the-signature tap UI */
    .fund-readsig-note {
      min-width: 42px; height: 42px; padding: 0 8px; border-radius: 8px; font-size: 15px; font-weight: 800;
      background: var(--bg); border: 1px solid var(--border); color: var(--text); cursor: pointer;
      font-family: var(--font); -webkit-appearance: none;
    }
    .fund-readsig-note.selected { border-color: var(--teal); background: var(--teal-lt); color: var(--teal-txt); }
    .fund-readsig-note.correct-tap { border-color: var(--teal); background: var(--teal-lt); color: var(--teal-txt); }
    .fund-readsig-note.wrong-tap { border-color: var(--red); background: var(--red-lt); color: var(--red-txt); }

    /* list/circle signature tabs + table */
    .fund-sig-tab-row { display: flex; gap: 8px; margin: 4px 0 12px; }
    .fund-sig-tab-btn {
      flex: 1; padding: 9px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border);
      color: var(--text2); font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--font);
      -webkit-appearance: none;
    }
    .fund-sig-tab-btn.active { background: var(--teal); border-color: var(--teal); color: #fff; }

    .fund-sig-table-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
    .fund-sig-table-label.sharps { color: var(--text); }
    .fund-sig-table-label.flats { color: var(--teal-txt); }
    .fund-sig-table-row {
      display: grid; grid-template-columns: 18px 32px 18px 1fr; align-items: center; gap: 4px;
      padding: 5px 6px; border-radius: 7px; background: var(--bg); border: 1px solid var(--border); margin-bottom: 3px;
    }
    .fund-sig-table-pos { font-size: 11px; color: var(--text2); text-align: center; }
    .fund-sig-table-key { font-size: 13px; font-weight: 800; color: var(--text); }
    .fund-sig-table-count { font-size: 12px; font-weight: 700; color: var(--text2); text-align: center; }
    .fund-sig-table-accs { display: flex; gap: 3px; flex-wrap: wrap; }
    .fund-sig-table-acc { font-size: 11px; font-weight: 700; padding: 1px 3px; border-radius: 4px; }
    .fund-sig-table-acc.kept-acc-sharp, .fund-sig-table-acc.kept-acc-flat { color: var(--text2); }
    .fund-sig-table-acc.new-acc-sharp { color: var(--text); background: var(--border); }
    .fund-sig-table-acc.new-acc-flat { color: var(--teal-txt); background: var(--teal-lt); }
    .fund-sig-table-acc.none { color: var(--text2); }

    .fund-drill-progress { text-align: center; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text2); margin-bottom: 8px; }
    .fund-predict-question { text-align: center; font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
    .fund-predict-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
    .fund-predict-option {
      padding: 14px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border);
      color: var(--text); font-size: 15px; font-weight: 700; cursor: pointer; font-family: var(--font);
      -webkit-appearance: none;
    }
    .fund-predict-option.long-text { font-size: 12px; }
    .fund-predict-option:disabled { cursor: default; }
    .fund-predict-option.correct-tap { background: var(--teal-lt); border-color: var(--teal); color: var(--teal-txt); }
    .fund-predict-option.wrong-tap { background: var(--red-lt); border-color: var(--red); color: var(--red-txt); }
    .fund-predict-feedback { text-align: center; font-size: 12px; min-height: 18px; }

    .fund-formula-compare-label {
      font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); text-align: center;
    }
    .fund-minor-major-link {
      margin-top: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border);
    }

    .fund-cta-btn {
      width: 100%; padding: 14px; border-radius: var(--radius);
      background: var(--teal); color: #fff; font-size: 16px; font-weight: 700;
      border: none; cursor: pointer; font-family: var(--font);
      -webkit-appearance: none; -webkit-tap-highlight-color: transparent;
    }
    .fund-cta-btn:hover { background: var(--teal-dk); }
    .fund-cta-btn:disabled {
      background: var(--border); color: var(--text3); cursor: default;
    }
    .fund-cta-btn:disabled:hover { background: var(--border); }

    /* ═══════════════════════════════════════════════
       MUSIC FUNDAMENTALS — PRACTICE QUIZ
    ═══════════════════════════════════════════════ */
    .fq-shell {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 14px;
      display: flex; flex-direction: column; gap: 12px;
    }
    .fq-prompt-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
    .fq-question { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.25; }
    .fq-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }
    .fq-badge-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
    .fq-type-badge {
      font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
      color: var(--text3); background: var(--bg); border: 1px solid var(--border);
      padding: 3px 8px; border-radius: 20px; white-space: nowrap;
    }
    .fq-streak { font-size: 10px; font-weight: 700; color: var(--teal); white-space: nowrap; }

    .fq-progress-row { display: flex; align-items: center; gap: 8px; }
    .fq-progress-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text2); white-space: nowrap; }
    .fq-progress-track { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
    .fq-progress-fill { height: 100%; background: var(--teal); transition: width 0.3s; }
    .fq-progress-count { font-size: 12px; color: var(--text2); white-space: nowrap; }

    .fq-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .fq-answer-btn {
      padding: 16px 8px; border-radius: 8px; background: var(--bg);
      border: 1px solid var(--border); color: var(--text); font-size: 15px; font-weight: 700;
      cursor: pointer; font-family: var(--font); -webkit-appearance: none;
      -webkit-tap-highlight-color: transparent; transition: all 0.12s;
    }
    .fq-answer-btn:disabled { cursor: default; }
    .fq-answer-btn.correct { background: var(--teal-lt); border-color: var(--teal); color: var(--teal-txt); }
    .fq-answer-btn.wrong   { background: var(--red-lt); border-color: var(--red); color: var(--red-txt); }

    .fq-feedback { min-height: 18px; font-size: 13px; text-align: center; }
    .fq-fb-correct { color: var(--teal-txt); font-weight: 600; }
    .fq-fb-slow    { color: var(--amber-txt); font-weight: 600; }
    .fq-fb-wrong   { color: var(--red-txt); }
    .fq-fb-wrong strong { color: var(--text); }
    .fq-fb-unlock  { margin-top: 6px; font-size: 10px; font-weight: 700; color: var(--amber-txt); }

    .fq-continue-btn {
      display: block; margin: 10px auto 0; padding: 10px 24px;
      border-radius: 8px; background: var(--bg); border: 1px solid var(--text3);
      color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer;
      font-family: var(--font); -webkit-appearance: none;
    }
    .fq-continue-btn:hover { border-color: var(--teal); color: var(--teal-txt); }

    /* ═══════════════════════════════════════════════
       PROMPT ROW
    ═══════════════════════════════════════════════ */
    #prompt-row {
      display: flex; align-items: center; gap: 10px; flex-shrink: 0;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 9px 14px;
    }
    #prompt-left { flex: 1; }
    #prompt-text { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; color: var(--text); }
    #prompt-sub  { font-size: 14px; color: var(--text2); margin-top: 2px; }
    .badge { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
    #timer-display { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; min-width: 52px; }
    #timer-val { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; color: var(--text); }
    #timer-val.slow     { color: #BA7517; }
    #timer-val.hesitant { color: var(--red); }
    #timer-val.paused   { color: var(--text3); }
    #timer-lbl { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

    /* ═══════════════════════════════════════════════
       FRETBOARD
    ═══════════════════════════════════════════════ */
    #fb-outer {
      display: flex; align-items: center; justify-content: center;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 6px 4px;
      overflow: hidden; position: relative;
      flex: 1; min-height: 80px;
    }
    #fb-canvas { display: block; max-width: 100%; }
    #pause-cover {
      display: none; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
      background: var(--surface); border-radius: var(--radius);
      align-items: center; justify-content: center; flex-direction: column; gap: 8px;
    }
    #pause-cover.show { display: flex; }

    /* ═══════════════════════════════════════════════
       ANSWER BUTTONS
    ═══════════════════════════════════════════════ */
    #answer-row { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--gap); flex-shrink: 0; }
    .ans-btn {
      padding: 12px 4px; font-size: 18px; font-weight: 600;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); cursor: pointer; color: var(--text);
      text-align: center; font-family: var(--font);
      -webkit-tap-highlight-color: transparent; -webkit-appearance: none; appearance: none;
      width: 100%; display: block; line-height: 1.2; margin: 0;
      transition: background 0.08s, border-color 0.08s, transform 0.08s;
    }
    .ans-btn:active { background: var(--teal) !important; border-color: var(--teal-dk) !important; color: #fff !important; transform: scale(0.95); }
    .ans-btn.tapped { background: var(--teal) !important; border-color: var(--teal-dk) !important; color: #fff !important; transform: scale(0.95); }

    /* ═══════════════════════════════════════════════
       FEEDBACK & HEATMAP
    ═══════════════════════════════════════════════ */
    #bottom-row { display: flex; align-items: center; gap: 10px; flex-shrink: 0; min-height: 34px; }
    #feedback { font-size: 14px; font-weight: 600; flex: 1; }
    #hm-wrap { flex-shrink: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 12px; }
    #hm-canvas { display: block; width: 100%; }
    #speed-legend { display: flex; gap: 12px; margin-top: 5px; font-size: 13px; color: var(--text2); flex-wrap: wrap; }
    .sl-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 3px; vertical-align: middle; }

    /* ═══════════════════════════════════════════════
       OVERLAYS (settings, stats, summary, complete)
    ═══════════════════════════════════════════════ */
    .overlay {
      display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.45); z-index: 1000;
      align-items: flex-start; justify-content: center;
      padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    .overlay.open { display: flex; }
    .panel {
      background: var(--surface); border-radius: 14px; border: 1px solid var(--border);
      width: 100%; max-width: 480px; padding: 1.5rem; margin: auto; position: relative;
    }
    .panel-actions {
      position: sticky; bottom: 0; background: var(--surface);
      border-top: 1px solid var(--border); padding: 12px 0 0; margin-top: 1.25rem;
    }
    .panel-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
    .panel-title { font-size: 16px; font-weight: 600; color: var(--text); }
    .close-btn {
      background: none; border: none; cursor: pointer; font-size: 26px;
      color: var(--text3); line-height: 1; padding: 4px 8px;
      -webkit-tap-highlight-color: transparent;
    }
    /* completion */
    #complete-panel { max-width: 400px; text-align: center; }
    #complete-actions { display: flex; flex-direction: column; gap: 8px; }
    #complete-actions button {
      padding: 12px; font-size: 14px; font-weight: 600;
      border-radius: 8px; cursor: pointer; border: none; color: #fff;
      font-family: var(--font); -webkit-tap-highlight-color: transparent;
    }

    /* ═══════════════════════════════════════════════
       COUNTDOWN
    ═══════════════════════════════════════════════ */
    #countdown-overlay {
      display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      z-index: 2000; background: rgba(0,0,0,0.55);
      align-items: center; justify-content: center; flex-direction: column; gap: 12px;
    }
    #countdown-overlay.open { display: flex; }
    #countdown-num { font-size: 120px; font-weight: 700; color: #fff; line-height: 1; }
    #countdown-label { font-size: 16px; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 0.06em; }

    /* ═══════════════════════════════════════════════
       STUDY VIEW (full-screen)
    ═══════════════════════════════════════════════ */
    #study-view {
      display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: var(--bg); z-index: 500;
      flex-direction: column; padding: var(--pad); gap: var(--gap);
    }
    #study-fb-outer {
      display: flex; align-items: center; justify-content: center;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 6px 4px; overflow: hidden;
    }
    #study-canvas { display: block; max-width: 100%; }
    #study-legend {
      flex-shrink: 0; display: flex; gap: 16px; flex-wrap: wrap;
      font-size: 12px; color: var(--text2);
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 8px; padding: 8px 12px;
    }

    /* ═══════════════════════════════════════════════
       FLOATING START BUTTON
    ═══════════════════════════════════════════════ */
    /* start-bar removed — Start button now inside settings panel footer */
    /* light mode overrides */
    @media (max-width: 500px) and (orientation: portrait) {
      #answer-row { grid-template-columns: repeat(2,1fr); gap: 6px; }
      .ans-btn { padding: 16px 4px; font-size: 20px; }
      #bottom-row { min-height: 28px; }
      #feedback { font-size: 13px; }
      #hm-wrap { padding: 5px 8px; }
      #speed-legend { display: none; }
    }

    /* ═══════════════════════════════════════════════
       PHONE — LANDSCAPE  (≤900px wide, ≤500px tall)
    ═══════════════════════════════════════════════ */
    @media (max-height: 500px) and (max-width: 900px) and (orientation: landscape) {
      .ans-btn { padding: 8px 4px; font-size: 16px; }
      #hm-canvas { height: 36px; }
      #speed-legend { display: none; }
      #prompt-sub { display: none; }
    }

    /* ═══════════════════════════════════════════════
       TABLET / DESKTOP — settings panel wider
    ═══════════════════════════════════════════════ */
    @media (min-width: 700px) {
      .panel { max-width: 600px; }
      .tog-grid.cols3 { grid-template-columns: repeat(3,1fr); }
    }
    @media (min-width: 1000px) {
      .panel { max-width: 700px; }
    }

    /* ═══════════════════════════════════════════════
       HOME SCREEN — branded to match fretnerd.com
    ═══════════════════════════════════════════════ */

    /* Website color tokens (home screen only) */
    #home-screen {
      --hs-ebony:   #111110;
      --hs-ebony2:  #191917;
      --hs-ebony3:  #222220;
      --hs-inlay:   #EDE0C0;
      --hs-inlay2:  #C8BAA0;
      --hs-copper:  #C47838;
      --hs-silver:  #7A8E9A;
      --hs-signal:  #72C442;
      --hs-fret:    #302C28;
      --hs-border:  #302C28;
    }

    #home-screen {
      display: none; position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: var(--hs-ebony); z-index: 600;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 28px 20px;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      /* grain texture */
      isolation: isolate;
    }
    #home-screen.show { display: flex; }
    @media (max-height: 500px) and (orientation: landscape) {
      #home-screen { justify-content: flex-start; padding-top: 16px; }
    }

    /* dot grid background — diagonal pattern */
    #home-screen::before {
      content: '';
      position: fixed; top: -50%; left: -50%; right: -50%; bottom: -50%;
      pointer-events: none; z-index: 0;
      background-image:
        radial-gradient(circle, rgba(122,142,154,0.22) 1.5px, transparent 1.5px),
        radial-gradient(circle, rgba(122,142,154,0.22) 1.5px, transparent 1.5px);
      background-size: 42px 42px;
      background-position: 0 0, 21px 21px;
      transform: rotate(30deg);
    }
    #home-screen > * { position: relative; z-index: 1; }

    /* Logo */
    .home-logo { font-size: 52px; margin-bottom: 8px; line-height: 1; }

    /* Two-tone FretNerd wordmark matching website */
    .home-title {
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      font-size: clamp(3rem, 10vw, 4.5rem); font-weight: 800;
      letter-spacing: 0.03em; margin-bottom: 4px; margin-top: 0;
      line-height: 1;
    }
    .home-title .fret-word { color: var(--hs-inlay); }
    .home-title .nerd-word { color: var(--hs-copper); }

    .home-tagline {
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      font-size: 1.1rem; font-weight: 700;
      letter-spacing: 0.18em; text-transform: uppercase;
      color: var(--hs-inlay2); margin-bottom: 28px;
    }

    /* Instrument toggle */
    .inst-toggle {
      display: flex; width: 100%; max-width: 480px;
      border: 1px solid var(--hs-fret); border-radius: 2px;
      overflow: hidden; margin-bottom: 0; flex-shrink: 0;
      background: var(--hs-ebony); /* screen — hides dots behind toggle */
    }
    .inst-btn {
      flex: 1; padding: 10px 8px; font-size: 0.85rem; font-weight: 700;
      border: none; cursor: pointer;
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      letter-spacing: 0.1em; text-transform: uppercase;
      -webkit-appearance: none; -webkit-tap-highlight-color: transparent;
      background: transparent; color: var(--hs-silver);
      transition: background 0.15s, color 0.15s;
    }
    .inst-btn.active { background: var(--hs-copper); color: var(--hs-ebony); }
    .inst-btn + .inst-btn { border-left: 1px solid var(--hs-fret); }

    .module-grid {
      display: flex; flex-direction: column; gap: 0;
      width: 100%; max-width: 480px;
      border-top: 1px solid var(--hs-fret);
    }
    .module-card {
      background: var(--hs-ebony); /* screen — hides dots behind cards */
      border-bottom: 1px solid var(--hs-fret);
      padding: 14px 16px;
      cursor: pointer; display: flex; align-items: flex-start; gap: 14px;
      -webkit-tap-highlight-color: transparent;
      transition: background 0.15s;
      text-align: left; width: 100%;
      font-family: var(--font); -webkit-appearance: none;
      border-radius: 0; outline: none; border-top: none;
      border-left: none; border-right: none;
    }
    .module-card.available:hover  { background: var(--hs-ebony3); }
    .module-card.available:active { background: var(--hs-ebony3); }
    .module-card.coming-soon { opacity: 0.6; cursor: default; pointer-events: none; }
    .module-icon {
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      font-size: 2rem; font-weight: 800;
      flex-shrink: 0; line-height: 1;
      color: var(--hs-silver); width: 32px; text-align: center;
      align-self: flex-start; padding-top: 2px;
    }
    .module-card.available .module-icon { color: var(--hs-copper); }
    .module-info { flex: 1; }
    .module-name {
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800;
      text-transform: uppercase; letter-spacing: 0.01em;
      color: var(--hs-inlay); margin-bottom: 2px; line-height: 1;
    }
    .module-desc { font-size: 0.9rem; color: var(--hs-inlay2); line-height: 1.5; font-weight: 300; }
    .module-badge {
      font-size: 0.7rem; font-weight: 700; padding: 3px 9px;
      border-radius: 2px; flex-shrink: 0; letter-spacing: 0.1em;
      text-transform: uppercase;
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      align-self: flex-start;
    }
    .badge-available {
      background: rgba(114,196,66,0.12);
      color: var(--hs-signal);
    }
    .badge-soon {
      background: rgba(196,120,56,0.1);
      color: var(--hs-copper);
      border: 1px solid rgba(196,120,56,0.25);
    }
    .badge-demo {
      background: var(--amber-lt);
      color: var(--amber-txt);
    }

    /* Company footer on home screen */
    .home-footer {
      margin-top: 24px; width: 100%; max-width: 480px;
      border-top: 1px solid var(--hs-fret);
      padding: 14px 0 4px 0;
      display: flex; align-items: center; justify-content: space-between;
      flex-wrap: wrap; gap: 8px;
    }
    .home-footer-logo {
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      font-weight: 800; font-size: 1rem; letter-spacing: 0.03em;
      color: var(--hs-inlay);
    }
    .home-footer-logo span { color: var(--hs-copper); }
    .home-footer-copy {
      font-family: 'Barlow Condensed', -apple-system, sans-serif;
      font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
      color: var(--hs-silver); opacity: 0.5;
    }

    /* ═══════════════════════════════════════════════
       FIRST-LAUNCH TOUR
    ═══════════════════════════════════════════════ */
    #tour-overlay {
      display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.75); z-index: 3000;
      align-items: center; justify-content: center; padding: 20px;
    }
    #tour-overlay.open { display: flex; }
    .tour-panel {
      background: var(--surface); border-radius: 20px;
      width: 100%; max-width: 420px;
      padding: 32px 28px 24px;
      display: flex; flex-direction: column; align-items: center;
      text-align: center; gap: 0;
    }
    .tour-icon { font-size: 56px; margin-bottom: 16px; line-height: 1; }
    .tour-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
    .tour-body { font-size: 16px; color: var(--text2); line-height: 1.6; margin-bottom: 28px; }
    .tour-body b { color: var(--text); }
    .tour-dots { display: flex; gap: 7px; margin-bottom: 24px; }
    .tour-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background 0.2s; }
    .tour-dot.active { background: var(--teal); }
    .tour-btns { display: flex; gap: 10px; width: 100%; }
    .tour-skip {
      flex: 1; padding: 11px; font-size: 15px; font-weight: 500;
      background: none; border: 1px solid var(--border); border-radius: 10px;
      cursor: pointer; color: var(--text2); font-family: var(--font);
      -webkit-appearance: none;
    }
    .tour-next {
      flex: 2; padding: 11px; font-size: 14px; font-weight: 700;
      background: var(--teal); color: #fff; border: none; border-radius: 10px;
      cursor: pointer; font-family: var(--font); -webkit-appearance: none;
    }
