@charset "utf-8";

    .btn:disabled,
    .btn:disabled:hover {
      opacity: 0.38;
      cursor: default;
      background: var(--surface2);
      border-color: var(--fret-line);
      color: var(--text);
    }

    .sec-move-btn {
      padding: 1px 7px;
      font-size: 0.8rem;
      line-height: 1.3;
      margin-left: 3px;
    }

    /* Selection: make the entry being edited unmistakable */
    .entry-token.selected {
      box-shadow: 0 0 0 2px rgba(77, 208, 225, 0.45);
    }

    .app-footer {
      font-size: 0.72rem;
      color: var(--text-dim);
      text-align: center;
      padding: 14px 20px 24px;
    }
    .app-footer strong { color: var(--text); font-weight: 600; }
    .saved-status { margin-top: 4px; font-size: 0.68rem; color: var(--text-dim); }
    .saved-status.warn { color: #ffb74d; }

    /* ── Section header: name left, equal-size controls right, bordered ── */
    .section-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      border: 1px solid var(--fret-line);
      border-radius: 8px;
      padding: 4px 6px 4px 10px;
      margin-bottom: 8px;
    }
    .section-header .section-name-input { flex: 1; min-width: 0; }
    .section-controls { display: flex; gap: 4px; flex-shrink: 0; }
    .sec-btn {
      width: 30px; height: 30px; padding: 0; flex-shrink: 0;
      display: inline-flex; align-items: center; justify-content: center;
      font-size: 0.9rem; line-height: 1;
      background: var(--surface2); color: var(--text);
      border: 1px solid var(--fret-line); border-radius: 6px; cursor: pointer;
      transition: background 0.12s, border-color 0.12s, color 0.12s;
    }
    .sec-btn:hover { background: #2d3148; border-color: var(--accent); }
    .sec-btn.active { background: #1b3a3e; border-color: var(--accent); color: var(--accent); }
    .sec-btn:disabled { opacity: 0.35; cursor: default; background: var(--surface2); border-color: var(--fret-line); }
    .sec-btn.sec-del:hover { background: #3a1515; border-color: #ff7070; color: #ff7070; }

    /* Center the chart at the fretboard width; the toolbar spans full width */
    .chart-display { max-width: var(--board-w, 100%); margin-left: auto; margin-right: auto; }

    /* ── Collapsible fretboard ────────────────────────── */
    .board-toggle { text-align: center; padding: 0; margin-top: -1px; }
    .board-toggle-btn {
      background: var(--surface2); color: var(--text-dim);
      border: 1px solid var(--fret-line); border-bottom: none;
      border-radius: 8px 8px 0 0;
      padding: 4px 20px; font-size: 0.72rem; cursor: pointer;
    }
    .board-toggle-btn:hover { color: var(--text); border-color: var(--accent); }
    body.board-collapsed main { display: none; }

    /* ── Full-width toolbar: File/edit left · transport center · title/writer right ── */
    .panel-toolbar {
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px 16px; flex-wrap: wrap; margin-bottom: 14px;
    }
    .toolbar-left { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
    .toolbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
    .meta-narrow { width: 190px; flex: 0 1 190px; }
    .icon-btn { min-width: 34px; text-align: center; font-size: 0.95rem; padding: 5px 10px; }

    /* File dropdown */
    .menu { position: relative; }
    .menu-list {
      position: absolute; left: 0; top: calc(100% + 4px); z-index: 40;
      background: var(--surface2); border: 1px solid var(--fret-line); border-radius: 8px;
      box-shadow: 0 6px 20px rgba(0,0,0,0.45); padding: 5px; min-width: 175px;
      display: flex; flex-direction: column; gap: 2px;
    }
    .menu-list[hidden] { display: none; }
    .menu-item {
      background: transparent; border: none; color: var(--text); text-align: left;
      padding: 8px 12px; border-radius: 6px; font-size: 0.85rem; cursor: pointer;
    }
    .menu-item:hover { background: #2d3148; }
    .menu-item.danger { color: #ff7070; }
    .menu-item.danger:hover { background: #3a1515; }
    .menu-sep { height: 1px; background: var(--fret-line); margin: 4px 2px; }

    /* Transport group (Time / Play / Metro / BPM / Speed) — sits in the middle of the toolbar */
    .transport-group {
      display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
      border: 1px solid var(--fret-line); border-radius: 10px; padding: 7px 14px;
      flex: 0 1 auto;
    }

    /* 3-way transport picker: Play · Play+Metronome · Metronome */
    .transport-picker { display: inline-flex; }
    .transport-seg {
      display: inline-flex; align-items: center; justify-content: center; gap: 3px;
      min-width: 46px; height: 34px; padding: 4px 10px; font-size: 1rem; line-height: 1;
      border-radius: 0; position: relative; margin-left: -1px;   /* overlap shared borders by 1px */
    }
    .transport-seg:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
    .transport-seg:last-child  { border-radius: 0 8px 8px 0; }
    .transport-seg:not(:first-child):not(:last-child) { border-radius: 0; }
    /* Raise the hovered/active/focused segment so all four of its borders show */
    .transport-seg:hover,
    .transport-seg:focus-visible,
    .transport-seg.active { z-index: 1; }
    .transport-seg.active { background: #1b3a3e; border-color: var(--accent); color: var(--accent); }
    .transport-seg svg { display: block; }
    .tp-play-glyph { font-size: 0.82rem; }

    /* Merged transpose control (♭ / ♯) to the right of the Key selector */
    .transpose-control { display: inline-flex; }
    .transpose-control .xpose-btn { border-radius: 0; }
    .transpose-control .xpose-btn:first-child { border-radius: 8px 0 0 8px; }
    .transpose-control .xpose-btn:last-child  { border-radius: 0 8px 8px 0; border-left: none; }

    /* Add-section affordances */
    .add-section-row { text-align: center; margin: 10px auto 4px; max-width: var(--board-w, 100%); }
    .add-section-btn {
      background: var(--surface2); color: var(--text-dim);
      border: 1px dashed var(--fret-line); border-radius: 8px;
      padding: 7px 18px; font-size: 0.8rem; cursor: pointer;
    }
    .add-section-btn:hover { color: var(--accent); border-color: var(--accent); }
    .sec-empty-hint { color: var(--text-dim); font-size: 0.82rem; font-style: italic; padding: 4px 2px 2px; }

    /* ── First-run intro ──────────────────────────────── */
    .intro-panel {
      max-width: 640px;
      margin: 8px auto 28px;
      padding: 22px 26px 26px;
      background: var(--surface);
      border: 1px solid var(--fret-line);
      border-radius: 12px;
      text-align: center;
    }
    .intro-panel.hidden { display: none; }
    .intro-title { font-size: 1.15rem; color: var(--accent); margin-bottom: 8px; }
    .intro-sub { font-size: 0.9rem; color: var(--text); line-height: 1.55; margin-bottom: 16px; }
    .intro-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
    .intro-primary {
      background: #1b3a3e; border-color: var(--accent); color: var(--accent); font-weight: 600;
    }
    .intro-primary:hover { background: #22484d; }
    .intro-how { margin-top: 14px; text-align: left; }
    .intro-how summary {
      font-size: 0.8rem; color: var(--text-dim); cursor: pointer; text-align: center;
      list-style: none; text-transform: uppercase; letter-spacing: 0.05em;
    }
    .intro-how summary:hover { color: var(--text); }
    .intro-how ol { margin: 12px 0 0; padding-left: 22px; }
    .intro-how li { font-size: 0.85rem; color: var(--text); line-height: 1.5; margin-bottom: 7px; }
    .intro-how strong { color: var(--accent); font-weight: 600; }

    /* ── Status toast ─────────────────────────────────── */
    .status-toast {
      position: fixed;
      bottom: 20px; left: 50%; transform: translateX(-50%) translateY(12px);
      background: var(--surface2); color: var(--text);
      border: 1px solid var(--accent);
      padding: 9px 18px; border-radius: 22px; font-size: 0.85rem;
      box-shadow: 0 4px 18px rgba(0,0,0,0.4);
      opacity: 0; pointer-events: none;
      transition: opacity 0.2s, transform 0.2s;
      z-index: 70;
    }
    .status-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    /* ── Section name (touch-reliable input, replaces contentEditable) ── */
    .section-name-input {
      background: transparent;
      border: none;
      border-bottom: 1px solid transparent;
      color: var(--text-dim);
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      padding: 2px 2px 3px;
      outline: none;
      min-width: 90px;
      max-width: 240px;
    }
    .section-name-input::placeholder { color: #555; }
    .section-name-input:hover { border-bottom-color: var(--fret-line); }
    .section-name-input:focus { border-bottom-color: var(--accent); color: var(--text); }

    /* ── Keyboard focus visibility ────────────────────── */
    .btn:focus-visible,
    .ctrl-select:focus-visible,
    .entry-token:focus-visible,
    .micro-btn:focus-visible,
    input:focus-visible,
    summary:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    :root {
      --bg:        #0f1117;
      --surface:   #1a1d27;
      --surface2:  #252836;
      --accent:    #4dd0e1;
      --orange:    #ffb74d;
      --text:      #e2e2e2;
      --text-dim:  #777;
      --fret-line: #3a3d4d;
      --nut-line:  #888;
      --fw: 56px;
      --fh: 54px;
      --dot: 34px;
    }

    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    /* ── Header ───────────────────────────────────────── */
    header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 20px;
      background: var(--surface);
      border-bottom: 1px solid var(--fret-line);
      flex-wrap: wrap;
      gap: 10px;
    }

    .app-title {
      font-size: 1.15rem;
      font-weight: 700;
      color: var(--accent);
      letter-spacing: 0.04em;
      flex-shrink: 0;
    }

    .header-controls {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .ctrl-group {
      display: flex;
      align-items: center;
      gap: 5px;
    }

    .ctrl-label {
      font-size: 0.7rem;
      color: var(--text-dim);
    }

    .ctrl-select {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      padding: 5px 22px 5px 8px;
      border-radius: 8px;
      font-size: 0.82rem;
      cursor: pointer;
      outline: none;
      appearance: none;
      -webkit-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23777' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 7px center;
    }

    .ctrl-select:hover { border-color: var(--accent); }

    .tuning-badge {
      font-size: 0.75rem;
      color: var(--text-dim);
      background: var(--surface2);
      padding: 4px 10px;
      border-radius: 20px;
      white-space: nowrap;
    }

    .btn {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      padding: 5px 13px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 0.8rem;
      transition: background 0.12s, border-color 0.12s, color 0.12s;
      white-space: nowrap;
    }

    .btn:hover { background: #2d3148; border-color: var(--accent); }

    .btn.active {
      background: #1b3a3e;
      border-color: var(--accent);
      color: var(--accent);
    }

    /* ── Main ─────────────────────────────────────────── */
    main {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 28px 20px;
      overflow-x: auto;
    }

    /* ── Fretboard grid ───────────────────────────────── */
    .fretboard {
      display: grid;
      grid-template-columns: 44px repeat(16, var(--fw));
      background: var(--surface);
      border: 1px solid var(--fret-line);
      border-radius: 10px;
      overflow: hidden;
      user-select: none;
    }

    .ruler-cell {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 26px;
      font-size: 0.68rem;
      color: var(--text-dim);
      background: var(--surface2);
      border-right: 1px solid var(--fret-line);
    }

    .ruler-cell:last-child { border-right: none; }
    .ruler-cell.nut-col    { border-right: 3px solid var(--nut-line); }

    .string-label-cell {
      display: flex;
      align-items: center;
      justify-content: center;
      height: var(--fh);
      font-size: 0.88rem;
      font-weight: 700;
      color: var(--text-dim);
      background: var(--surface2);
      border-right: 1px solid var(--fret-line);
    }

    .fret-cell {
      position: relative;
      height: var(--fh);
      display: flex;
      align-items: center;
      justify-content: center;
      border-right: 1px solid var(--fret-line);
    }

    .fret-cell:last-child { border-right: none; }
    .fret-cell.nut-col    { border-right: 3px solid var(--nut-line); }

    .fret-cell::before {
      content: '';
      position: absolute;
      left: 0; right: 0;
      top: 50%;
      height: var(--sh, 2px);
      transform: translateY(-50%);
      background: linear-gradient(90deg, #777, #bbb 40%, #bbb 60%, #777);
      pointer-events: none;
      z-index: 0;
    }

    /* ── Note dots ────────────────────────────────────── */
    .note-dot {
      position: relative;
      z-index: 1;
      width: var(--dot);
      height: var(--dot);
      border-radius: 50%;
      border: none;
      background: var(--accent);
      color: #0a1a1c;
      font-size: 0.7rem;
      font-weight: 700;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.1s ease, box-shadow 0.15s ease;
      flex-shrink: 0;
      outline: none;
    }

    .note-dot:hover              { transform: scale(1.15); box-shadow: 0 0 14px var(--accent); }
    .note-dot:focus-visible      { box-shadow: 0 0 0 3px rgba(77,208,225,0.5); }
    .note-dot.root               { background: var(--orange); color: #1a0a00; }
    .note-dot.root:hover         { box-shadow: 0 0 14px var(--orange); }

    .note-dot.playing            { animation: pluck      0.35s ease-out forwards; }
    .note-dot.root.playing       { animation: pluck-root 0.35s ease-out forwards; }

    @keyframes pluck {
      0%   { transform: scale(1.3); box-shadow: 0 0 22px var(--accent); }
      100% { transform: scale(1);   box-shadow: none; }
    }
    @keyframes pluck-root {
      0%   { transform: scale(1.3); box-shadow: 0 0 22px var(--orange); }
      100% { transform: scale(1);   box-shadow: none; }
    }

    .note-dot .lbl { display: none; pointer-events: none; }

    body.label-notes .note-dot .lbl-note { display: block; }
    body.label-frets .note-dot .lbl-fret { display: block; }
    body.label-nns   .note-dot .lbl-nns  { display: block; }

    /* ── NNS dot coloring (transcribe mode) ───────────── */
    body.transcribe-active .note-dot              { background: var(--accent); color: #0a1a1c; }
    body.transcribe-active .note-dot.nns-root     { background: var(--orange); color: #1a0a00; }
    body.transcribe-active .note-dot.nns-out      { background: #3a3a4a; color: #666; }
    body.transcribe-active .note-dot.nns-out:hover { box-shadow: 0 0 10px #777; }

    /* ── Position markers ─────────────────────────────── */
    .marker-cell {
      height: 22px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--surface);
      border-right: 1px solid var(--fret-line);
      color: var(--text-dim);
      font-size: 0.5rem;
      letter-spacing: 2px;
    }

    .marker-cell:last-child { border-right: none; }
    .marker-cell.nut-col    { border-right: 3px solid var(--nut-line); }

    /* ── Transcribe panel ─────────────────────────────── */
    .transcribe-panel {
      background: var(--surface);
      border-top: 2px solid var(--fret-line);
      padding: 16px 20px 20px;
    }

    .transcribe-panel.hidden { display: none; }

    .panel-toolbar {
      display: flex;
      align-items: flex-start;
      gap: 14px;
      flex-wrap: wrap;
      margin-bottom: 14px;
    }

    .panel-meta {
      display: flex;
      flex-direction: column;
      gap: 6px;
      flex: 1;
      min-width: 200px;
    }

    .meta-input {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      border-radius: 8px;
      padding: 5px 10px;
      font-size: 0.82rem;
      outline: none;
    }

    .meta-input:focus { border-color: var(--accent); }

    .panel-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .section-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .section-input {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      border-radius: 8px;
      padding: 5px 10px;
      font-size: 0.82rem;
      width: 155px;
      outline: none;
    }

    .section-input:focus { border-color: var(--accent); }

    /* ── Chart display ────────────────────────────────── */
    .chart-display {
      min-height: 52px;
      padding: 4px 0 8px;
    }

    .chart-empty {
      color: var(--text-dim);
      font-size: 0.85rem;
      font-style: italic;
      padding: 10px 2px;
    }

    .section-block { margin-bottom: 14px; }

    .section-name-label {
      font-size: 0.72rem;
      font-weight: 700;
      color: var(--text-dim);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      margin-bottom: 6px;
      border-bottom: 1px solid transparent;
      transition: border-color 0.15s;
      cursor: text;
      outline: none;
      display: inline-block;
      min-width: 60px;
    }
    .section-name-label:hover  { border-bottom-color: var(--fret-line); }
    .section-name-label:focus  { border-bottom-color: var(--accent); color: var(--text); }
    .section-name-label:empty::before { content: attr(data-placeholder); color: #444; }

    .bars-row {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 2px;
      row-gap: 6px;
    }

    .bar { display: flex; align-items: center; }

    .bar-sep {
      color: var(--text-dim);
      font-size: 1rem;
      padding: 0 5px;
      line-height: 1;
      user-select: none;
    }
    .bar-sep-btn {
      background: transparent;
      border: none;
      font: inherit;
      cursor: pointer;
      transition: color 0.15s;
    }
    .bar-sep-btn:hover { color: var(--accent); }
    .bar-sep.break-here { color: var(--orange); }
    .bar-sep.break-here::after {
      content: '↵';
      font-size: 0.55em;
      vertical-align: super;
      margin-left: 1px;
    }

    .entry-token {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      border-radius: 6px;
      padding: 3px 7px;
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.1s, border-color 0.1s;
      min-width: 26px;
      text-align: center;
      line-height: 1.5;
    }

    .entry-token:hover    { background: #2d3148; border-color: #666; }
    .entry-token.selected    { background: #1b3a3e; border-color: var(--accent); color: var(--accent); }
    .entry-token.playing-now { background: #1a2e1a; border-color: #66bb6a;     color: #66bb6a; box-shadow: 0 0 8px rgba(102,187,106,0.35); }
    .entry-token.subdivision { border-bottom: 2px solid currentColor; border-radius: 6px 6px 2px 2px; }

    .bpm-input {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      border-radius: 8px;
      padding: 4px 6px;
      font-size: 0.82rem;
      width: 52px;
      text-align: center;
      outline: none;
      -moz-appearance: textfield;
      appearance: textfield;
    }
    .bpm-input::-webkit-inner-spin-button,
    .bpm-input::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; }
    .bpm-input:focus { border-color: var(--accent); }

    /* ── Entry editor ─────────────────────────────────── */
    .entry-editor {
      position: fixed;
      left: 0; right: 0; bottom: 0;
      z-index: 60;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 16px;
      /* right padding reserves room for the fixed dismiss cluster */
      padding: 12px 104px 12px 20px;
      background: var(--surface);
      border-top: 2px solid var(--accent);
      box-shadow: 0 -6px 22px rgba(0,0,0,0.45);
    }

    .entry-editor.hidden { display: none; }

    /* Close + collapse live in a fixed spot so they never move as the
       editor's contents reflow. ✕ closes and NEVER deletes — delete is
       the trash icon in the action row. */
    .editor-dismiss {
      position: absolute;
      top: 8px; right: 12px;
      display: flex;
      gap: 6px;
    }

    .editor-close, .editor-collapse {
      background: #2b2e3d;
      border-color: #464a5e;
      color: var(--text-dim, #b9bdd0);
    }
    .editor-close:hover, .editor-collapse:hover {
      background: #363a4d;
      color: #fff;
    }

    /* Chevron points up when collapsed (tap to expand) */
    .entry-editor.collapsed .editor-collapse svg { transform: rotate(180deg); }

    /* Collapsed: keep the chord symbol and its duration readout, drop the rest */
    .entry-editor.collapsed { padding-top: 8px; padding-bottom: 8px; }
    .entry-editor.collapsed .beat-grid,
    .entry-editor.collapsed .editor-label,
    .entry-editor.collapsed .editor-group,
    .entry-editor.collapsed .slash-group,
    .entry-editor.collapsed .edit-hint,
    .entry-editor.collapsed #insert-after-btn,
    .entry-editor.collapsed #delete-entry-btn { display: none !important; }

    .editor-symbol {
      font-size: 1.35rem;
      font-weight: 700;
      color: var(--accent);
      min-width: 38px;
      text-align: center;
    }

    .editor-group {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .editor-label {
      font-size: 0.68rem;
      color: var(--text-dim);
      white-space: nowrap;
    }

    .btn-row { display: flex; gap: 3px; }

    .micro-btn {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      padding: 3px 8px;
      border-radius: 6px;
      cursor: pointer;
      font-size: 0.73rem;
      font-weight: 600;
      transition: background 0.1s, border-color 0.1s;
      line-height: 1.4;
    }

    .micro-btn:hover { background: #2d3148; border-color: #666; }
    .micro-btn.sel   { background: #1b3a3e; border-color: var(--accent); color: var(--accent); }

    /* ── Beat grid ────────────────────────────────────── */
    .beat-grid-group {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .beat-grid {
      display: flex;
      gap: 3px;
      cursor: pointer;
      user-select: none;
      touch-action: none;
    }

    .beat-cell {
      min-width: 16px;
      max-width: 40px;
      flex: 1;
      height: 34px;
      border-radius: 6px;
      border: 1px solid var(--fret-line);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.72rem;
      font-weight: 600;
      background: var(--surface2);
      color: var(--text-dim);
      transition: background 0.07s, border-color 0.07s, color 0.07s;
      pointer-events: none; /* grid handles all events */
    }

    .beat-cell.bc-mine {
      background: var(--accent);
      color: #0a1a1c;
      border-color: var(--accent);
    }

    .beat-cell.bc-free {
      background: var(--surface2);
      color: #555;
      border-color: var(--fret-line);
    }

    .beat-cell.bc-other {
      background: #1e2030;
      color: #3a3a4a;
      border-color: #2a2a38;
    }

    .beat-cell.bc-preview {
      background: rgba(77, 208, 225, 0.22);
      border-color: rgba(77, 208, 225, 0.5);
      color: var(--accent);
    }

    .beat-value-label {
      font-size: 0.7rem;
      color: var(--text-dim);
      font-style: italic;
      min-height: 1em;
    }

    /* ── Slash + other controls ───────────────────────── */
    .slash-group {
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 0.85rem;
      color: var(--text-dim);
    }

    .slash-input {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      border-radius: 6px;
      padding: 3px 6px;
      font-size: 0.78rem;
      font-weight: 600;
      width: 42px;
      text-align: center;
      outline: none;
    }

    .slash-input:focus { border-color: var(--accent); }

    .measure-note-input {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--fret-line);
      border-radius: 6px;
      padding: 3px 8px;
      font-size: 0.78rem;
      width: 130px;
      outline: none;
    }
    .measure-note-input:focus { border-color: var(--accent); }

    .btn.danger       { color: #ff7070; border-color: #6a2a2a; }
    .btn.danger:hover { background: #3a1515; border-color: #ff7070; }
    /* green "done editing" check */
    .btn.save-changes       { color: #66bb6a; border-color: #2e5a3a; }
    .btn.save-changes:hover { background: #16301b; border-color: #66bb6a; }

    /* Compact icon buttons in the entry editor (copy / delete / done) */
    .editor-icon-btn {
      display: inline-flex; align-items: center; justify-content: center;
      min-width: 38px; padding: 6px 10px; font-size: 1rem; line-height: 1;
    }
    .editor-icon-btn svg { display: block; }

    /* Beat-grid: subtle divider at each beat boundary in the sixteenth grid */
    .beat-cell.beat-start { border-left: 2px solid #4a4d5d; }

    .edit-hint {
      font-size: 0.68rem;
      color: var(--accent);
      opacity: 0.75;
      font-style: italic;
      white-space: nowrap;
    }

    .ref-details {
      margin-top: 14px;
      border-top: 1px solid var(--fret-line);
      padding-top: 10px;
    }
    .ref-details summary {
      font-size: 0.75rem;
      color: #888;
      cursor: pointer;
      user-select: none;
      letter-spacing: 0.05em;
      text-transform: uppercase;
    }
    .ref-details summary:hover { color: var(--text); }
    .ref-table {
      margin-top: 8px;
      width: 100%;
      border-collapse: collapse;
      font-size: 0.78rem;
    }
    .ref-table th {
      text-align: left;
      color: #888;
      font-weight: 600;
      padding: 3px 10px 3px 0;
      border-bottom: 1px solid var(--fret-line);
      font-size: 0.72rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    .ref-table td {
      padding: 4px 10px 4px 0;
      color: var(--text);
      border-bottom: 1px solid #1e2130;
    }
    .ref-table td:first-child {
      font-weight: 700;
      color: var(--accent);
      width: 52px;
    }
    .ref-diatonic { margin-top: 10px; }
    .ref-diatonic table {
      border-collapse: collapse;
      font-size: 0.78rem;
    }
    .ref-diatonic td {
      padding: 3px 12px 3px 0;
      color: var(--text);
    }
    .ref-diatonic td:first-child {
      font-weight: 700;
      color: var(--accent);
      width: 28px;
    }
    .ref-sub-label {
      font-size: 0.72rem;
      color: #888;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin: 10px 0 4px;
    }

    /* ── Transpose / Speed controls ──────────────────── */
    .key-transpose { display:flex; align-items:center; gap:4px; }
    .xpose-btn { padding:3px 8px; font-size:0.9rem; }
    .speed-range { width:70px; accent-color:var(--accent); }
    .speed-label { font-size:0.75rem; color:var(--text-dim); min-width:3em; }

    /* ── Loop button ──────────────────────────────────── */
    .loop-btn { padding:2px 7px; font-size:0.85rem; }

    /* ── Responsive ───────────────────────────────────── */
    @media (max-width: 1060px) {
      :root { --fw: 46px; --fh: 50px; --dot: 30px; }
    }
    @media (max-width: 820px) {
      :root { --fw: 36px; --fh: 44px; --dot: 26px; }
      .note-dot { font-size: 0.62rem; }
    }
    @media (max-width: 620px) {
      :root { --fw: 28px; --fh: 40px; --dot: 22px; }
      .note-dot { font-size: 0.55rem; }
    }

    /* Touch devices: comfortable tap targets (Apple 44px guideline).
       Placed after the width queries above so it wins on touch screens. */
    @media (pointer: coarse) {
      :root { --fw: 54px; --fh: 54px; --dot: 44px; }
      .note-dot { font-size: 0.72rem; }
      .btn, .ctrl-select, .micro-btn, .sec-move-btn, .loop-btn, .xpose-btn {
        min-height: 42px;
        padding-top: 8px; padding-bottom: 8px;
      }
      .entry-token { min-height: 40px; padding: 8px 11px; }
      .beat-cell { height: 42px; }
      .section-name-input { font-size: 0.82rem; min-height: 36px; }
    }
