/* ─────────────────────────────────────────────────────────────
   ScaleDr v2 — Direction A "Practice Studio"
   Dark practice-instrument theme inspired by TE Tuner / iReal Pro.
   ───────────────────────────────────────────────────────────── */

:root {
  --bg-deepest: #0a0f14;
  --bg-deep: #11181f;
  --bg-card: #161e26;
  --bg-elevated: #1d2630;

  --line: #232e3a;
  --line-soft: #1a232c;

  --ink: #e8eef5;
  --ink-soft: #a6b2c0;
  --ink-muted: #5a6675;

  --accent: #f17a3a;        /* brighter take on the v1 #c96d36 */
  --accent-deep: #c9521b;
  --accent-soft: #f7a472;
  --accent-glow: rgba(241, 122, 58, 0.25);

  --good: #4ec07b;
  --warn: #e6b357;
  --danger: #e07060;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  --control-height: 38px;
  --label-font: 11px;

  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-top: env(safe-area-inset-top, 0);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: #050708;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    "Helvetica Neue", "Avenir Next", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(ellipse at top, rgba(241, 122, 58, 0.04), transparent 55%),
    linear-gradient(180deg, #060a0e 0%, #050708 100%);
}

h1, h2, h3, p, ol, ul {
  margin: 0;
  padding: 0;
}

ol, ul {
  list-style: none;
}

button {
  font-family: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ─────────────────────────────────────────────────────────────
   App shell — vertical column, max device width on desktop
   ───────────────────────────────────────────────────────────── */

.app-shell {
  min-height: 100vh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-deepest);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

@media (min-width: 720px) {
  .app-shell {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}

/* ─────────────────────────────────────────────────────────────
   Top context bar (always visible)
   ───────────────────────────────────────────────────────────── */

.context-bar {
  flex-shrink: 0;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  /* Top padding includes safe-area-inset-top so the wordmark / chips
     don't slide under the iOS status bar when launched as a standalone
     PWA from the home screen. In regular browser tabs the inset is 0,
     so the visible padding is unchanged. */
  padding: calc(8px + var(--safe-top)) 14px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.context-brand {
  margin-bottom: 6px;
}

.wordmark {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  line-height: 1;
}
.wordmark-dr {
  color: var(--accent);
}

/* Visually hidden — content stays in DOM for screen readers / JS. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.context-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: stretch;
  row-gap: 6px;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
  height: 30px;
}
.chip:hover, .chip:focus-within {
  background: var(--bg-elevated);
}

/* Chip-as-select: a native <select> styled to look like a chip. iOS
   shows its wheel picker on tap, Android shows a dropdown — both are
   far better than building a custom popover. The arrow caret indicates
   the chip is editable. */
.chip-select {
  padding-right: 4px;
}
.chip-select select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0 0 0 0;
  cursor: pointer;
  outline: none;
  max-width: 100px;
  text-overflow: ellipsis;
  text-align: left;
}
.chip-select select::-ms-expand {
  display: none;
}
.chip-caret {
  color: var(--ink-muted);
  font-size: 9px;
  padding-right: 4px;
  line-height: 1;
}

/* In-chip label prefix — used by the control-row chips
   (Pattern / Ext / Sus / Interval / Exercise). The label sits inside
   the chip alongside the value so it reads as part of the control
   rather than as separate descriptive text outside the dropdown. */
.chip-select .chip-label {
  color: var(--ink-muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 2px;
}

/* Wider variant for the Exercise chip — the option labels are
   long enough that the default 100px max-width truncates them. */
.chip-select.chip-select-wide select {
  max-width: 220px;
}

/* Clef toggle moved into the Setup drawer (segmented two-button
   control inside the Instrument section — see .clef-toggle further
   down in this file). No top-strip chip styling needed anymore. */

@media (max-width: 360px) {
  .chip,
  .chip-select select {
    font-size: 12px;
  }
  .chip {
    padding: 5px 8px;
  }
  .tempo-widget input[type="number"] {
    width: 44px;
    font-size: 14px;
  }
}

/* Narrow-phone safety: if anything still overflows, allow horizontal
   scroll but keep the chip strip well-distributed. */
@media (max-width: 360px) {
  .chip {
    padding: 5px 8px;
    font-size: 12px;
  }
  .context-chips {
    gap: 4px;
  }
}

/* ─────────────────────────────────────────────────────────────
   Hero notation display
   ───────────────────────────────────────────────────────────── */

.hero {
  /* Hero hugs its content — no longer grows to fill empty space, which
     was leaving a tall blank area below the staff. Spare vertical space
     now lives between the hero and the layers row (visual breathing
     room rather than wasted padding inside the staff panel). */
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, var(--bg-deepest) 0%, #0c1218 100%);
  gap: 6px;
}

.chord-symbol-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chord-symbol-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chord-symbol {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.chord-symbol-alt {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
  font-style: italic;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill-mode {
  background: rgba(241, 122, 58, 0.08);
  color: var(--accent-soft);
  border-color: rgba(241, 122, 58, 0.22);
}

.pill-direction {
  background: var(--bg-card);
}

.practice-status {
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.material-subtitle {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.notation-container {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  display: block;
  overflow: hidden;
}

.notation-staff {
  /* Sized to VexFlow's rendered height (170px from app.js) plus a small
     vertical padding. No flex-grow, so empty space doesn't accumulate
     below the staff. Horizontal scroll keeps notes at VexFlow's natural
     ~620px+ width so each notehead stays legible on phone; app.js's
     scrollStaffToNote() advances the scroll position as practice
     progresses. */
  background: #fafaf6;
  border-radius: 8px;
  padding: 4px 6px;
  color: #1b1b1b;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  height: 180px;
  display: block;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}
.notation-staff::-webkit-scrollbar {
  height: 4px;
}
.notation-staff::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}
.notation-staff svg {
  /* Do NOT constrain max-width here — VexFlow renders the SVG at its
     natural ~620+px width and the container scrolls horizontally.
     Constraining to 100% squashed the staff and made the notes
     unreadable on phone (the original v2 complaint). */
  display: block;
}

/* When VexFlow draws into the staff, give playing notes a glow */
.notation-staff g.vf-stavenote {
  transition: fill 0.1s ease;
}
.notation-staff g.staff-note-active,
.notation-staff g.staff-note-active * {
  fill: #c9521b !important;
  stroke: #c9521b !important;
}

.note-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}
.note-strip::-webkit-scrollbar { display: none; }

.note-token {
  flex-shrink: 0;
  min-width: 30px;
  padding: 6px 10px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.note-token.active,
.note-token.is-active {
  background: var(--accent);
  color: var(--bg-deepest);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.note-token-spacer {
  background: transparent;
  border-color: transparent;
  color: transparent;
}

.hero-direction-row {
  display: flex;
  justify-content: flex-end;
}

/* ─────────────────────────────────────────────────────────────
   Tempo row — slider + live BPM readout, always visible
   ───────────────────────────────────────────────────────────── */

.tempo-row {
  margin-top: auto;  /* pushes this + everything below to the bottom */
  flex-shrink: 0;
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tempo-row-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
  font-family: "Bravura", inherit;
}

.tempo-slider {
  flex: 1;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 24px;
  margin: 0;
  cursor: pointer;
  min-width: 0;
}
.tempo-slider::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
.tempo-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -8px;
  background: var(--accent);
  border: 1px solid var(--accent-deep);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
}
.tempo-slider::-moz-range-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
.tempo-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border: 1px solid var(--accent-deep);
  border-radius: 50%;
  cursor: pointer;
}

.tempo-row-value {
  appearance: textfield;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  text-align: right;
  width: 46px;
  padding: 0;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.tempo-row-value::-webkit-outer-spin-button,
.tempo-row-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.tempo-row-value:focus-visible {
  outline: none;
  background: rgba(241, 122, 58, 0.08);
  border-radius: 4px;
}

/* ─────────────────────────────────────────────────────────────
   Progression row — Progression toggle + Type select, grouped as
   a single configuration block with an accent tint + left stripe
   so the toggle's relationship to its Type is immediately legible.
   Always visible (no show/hide) so the user can preview/change Type
   even while Progression is off.
   ───────────────────────────────────────────────────────────── */

.progression-row {
  flex-shrink: 0;
  background: rgba(241, 122, 58, 0.04);
  border-top: 1px solid rgba(241, 122, 58, 0.22);
  border-left: 3px solid var(--accent);
  padding: 8px 14px;
}

.progression-row-grid {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────────────────────────
   Layers row — always-visible reference-layer toggles
   ───────────────────────────────────────────────────────────── */

.layers-row {
  /* Tempo row above has margin-top: auto, so this stack already sits
     at the bottom; no need to repeat it here. */
  flex-shrink: 0;
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.layer-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.layer-pill:hover {
  background: var(--bg-elevated);
}
.layer-pill input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 16px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.layer-pill input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  background: var(--ink-muted);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}
.layer-pill input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.layer-pill input[type="checkbox"]:checked::after {
  transform: translateX(11px);
  background: var(--bg-deepest);
}
/* Active layer pill — outlined in accent so it's easy to scan which
   layers are currently engaged. */
.layer-pill:has(input:checked) {
  color: var(--ink);
  border-color: rgba(241, 122, 58, 0.4);
}

/* Progression toggle gets a subtle accent tint so it reads as a more
   structural change than the audio reference layers. */
.layer-pill-progression {
  background: rgba(241, 122, 58, 0.04);
}
.layer-pill-progression:has(input:checked) {
  background: rgba(241, 122, 58, 0.12);
  color: var(--accent);
}

/* Octaves pill — the select fills the entire pill so tapping anywhere
   on the pill triggers the iOS picker. The native <label> wrapper
   doesn't reliably propagate taps to nested <select>s on Safari, so
   the previous "label + tiny select inside" pattern had a small hit
   target. Now the wrapper has no padding and the select handles its
   own padding (covering the full pill area). */
.layer-pill-octaves {
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.layer-pill-octaves select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  /* Match the visual height of the other layer-pills (6px vertical +
     12px horizontal padding gives ~32px tall, same as the toggle
     pills' content box). */
  padding: 7px 14px;
  cursor: pointer;
  outline: none;
  width: 100%;
  text-align: center;
}

/* Keys pill — number-input variant of the layer-pill. Compact "Keys 12"
   pair sits among the other layer-pills as a per-practice parameter. */
.layer-pill-keys {
  gap: 6px;
  padding: 6px 10px;
}
.layer-pill-keys .layer-pill-label {
  color: var(--ink-muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.layer-pill-keys input[type="number"] {
  appearance: textfield;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  width: 32px;
  padding: 0;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.layer-pill-keys input[type="number"]::-webkit-outer-spin-button,
.layer-pill-keys input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.layer-pill-keys input[type="number"]:focus-visible {
  background: rgba(241, 122, 58, 0.1);
  border-radius: 4px;
}

/* ─────────────────────────────────────────────────────────────
   Inline control row — contextual per practice type
   ───────────────────────────────────────────────────────────── */

.control-row {
  flex-shrink: 0;
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 60px;
}

.control-block {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.control-block.hidden {
  display: none;
}
.control-block-end {
  margin-left: auto;
}

.control-label {
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.control-field {
  display: inline-flex;
  align-items: center;
}

.control-field select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 26px 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23a6b2c0' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-height: 32px;
}
.control-field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.control-field-wide select {
  min-width: 200px;
}

.control-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.control-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 30px;
  height: 18px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.control-toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--ink-soft);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}
.control-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.control-toggle input[type="checkbox"]:checked::after {
  transform: translateX(12px);
  background: var(--bg-deepest);
}

/* ─────────────────────────────────────────────────────────────
   Bottom tab bar — primary navigation
   ───────────────────────────────────────────────────────────── */

.tab-bar {
  flex-shrink: 0;
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.tab {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  padding: 11px 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  transition: color 0.12s ease;
}
.tab:hover:not(.is-active) {
  color: var(--ink-soft);
}
.tab.is-active {
  color: var(--accent);
}
.tab.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
}
.tab-icon {
  font-size: 18px;
  line-height: 1;
}
/* ⚙ renders much larger than the music-note glyphs at the same
   font-size — scale it down so all five tab icons read at the same
   optical size. */
.tab[data-tab="setup"] .tab-icon {
  font-size: 14px;
}
.tab-label {
  font-size: 9.5px;
}

/* ─────────────────────────────────────────────────────────────
   Transport bar (persistent, bottom)
   ───────────────────────────────────────────────────────────── */

.transport-bar {
  flex-shrink: 0;
  background: var(--bg-deepest);
  border-top: 1px solid var(--line-soft);
  padding: 10px 14px calc(12px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
}

/* .transport-copy is .visually-hidden in HTML — the summary text and
   "Transport" label are not shown, but the elements remain in the DOM
   so app.js can still write to #transportSummary. */
.display-label {
  font-size: 9.5px;
  color: var(--ink-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.transport-actions {
  display: flex;
  gap: 8px;
  flex: 1;
}

.transport-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  flex: 1;
  transition: background 0.12s ease, transform 0.05s ease;
}
.transport-button:active {
  transform: scale(0.97);
}
.transport-button.is-primary {
  background: var(--accent);
  color: var(--bg-deepest);
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  /* Give Start more weight than Stop — primary action. */
  flex: 2;
}
.transport-button.is-primary:hover {
  background: var(--accent-soft);
}
.transport-button.is-secondary {
  background: var(--bg-card);
  color: var(--ink-soft);
}
.transport-button.is-secondary:hover {
  background: var(--bg-elevated);
}

/* ─────────────────────────────────────────────────────────────
   Setup drawer (slides up from bottom)
   ───────────────────────────────────────────────────────────── */

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 8, 0.6);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.drawer-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow: var(--shadow-lg);
}
.drawer.is-open {
  transform: translate(-50%, 0);
}

.drawer[hidden] {
  display: flex;
}

.drawer-header {
  flex-shrink: 0;
  padding: 14px 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.drawer-header::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
}

.drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
  margin-top: 4px;
}

.drawer-close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.drawer-close:hover {
  background: var(--bg-card);
  color: var(--ink);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.drawer-section.audio-debug { gap: 8px; }
.drawer-section.hidden { display: none; }

.drawer-section-title {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.drawer-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  min-width: 0;
}

.drawer-field select,
.drawer-field input[type="number"],
.drawer-field input[type="text"] {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
}
.drawer-field select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23a6b2c0' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.drawer-field select:focus-visible,
.drawer-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.drawer-field.is-hidden-visually {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Clef toggle inside drawer */
.clef-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px;
  align-self: flex-start;
}
.clef-toggle-button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
  text-transform: uppercase;
}
.clef-toggle-button.is-active {
  background: var(--accent);
  color: var(--bg-deepest);
}

/* BPM control inside drawer */
.bpm-control {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
  align-items: stretch;
}
.bpm-stepper {
  appearance: none;
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.bpm-stepper:hover { background: var(--bg-elevated); }
.bpm-control input[type="number"] {
  text-align: center;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.bpm-slider {
  width: 100%;
  margin-top: 8px;
  accent-color: var(--accent);
}

/* Drawer toggle (switch-style row) */
.drawer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.drawer-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 22px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.drawer-toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--ink-soft);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}
.drawer-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.drawer-toggle input[type="checkbox"]:checked::after {
  transform: translateX(14px);
  background: var(--bg-deepest);
}

.drawer-helper {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.drawer-section-summary .drawer-summary-line {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  padding: 4px 0;
}
.drawer-summary-label {
  color: var(--ink-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 6px;
}

.drawer-footer-link {
  text-align: center;
  padding-top: 12px;
}

.ghost-link {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}
.ghost-link:hover {
  color: var(--accent);
}

.secondary-action {
  appearance: none;
  background: var(--bg-card);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.secondary-action:hover {
  background: var(--bg-elevated);
  color: var(--ink);
}

/* ─────────────────────────────────────────────────────────────
   Search affordance — top-bar icon + slide-down overlay
   ───────────────────────────────────────────────────────────── */

.context-brand {
  /* Originally just held the wordmark. The search-button sits next
     to it; keep alignment via flex. */
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.search-button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.search-button:hover,
.search-button:focus-visible {
  background: var(--bg-elevated);
  color: var(--ink);
  border-color: var(--ink-muted);
  outline: none;
}

/* Website link icon — matches .search-button geometry so the two
   icons read as a paired toolbar next to the wordmark. Anchor
   element (not button) because it navigates externally. */
.site-link {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.site-link:hover,
.site-link:focus-visible {
  background: var(--bg-elevated);
  color: var(--ink);
  border-color: var(--ink-muted);
  outline: none;
}

.search-scrim {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 8, 0.6);
  z-index: 70;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.search-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.search-overlay {
  position: fixed;
  top: 6vh;
  left: 50%;
  transform: translate(-50%, -12px);
  width: min(560px, calc(100vw - 28px));
  max-height: 80vh;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 80;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.search-overlay.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
}

.search-input-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-muted);
}
.search-input-row:focus-within {
  border-color: var(--accent);
  color: var(--ink);
}

.search-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;  /* ≥16px avoids iOS auto-zoom on focus */
  font-weight: 500;
  outline: none;
  padding: 0;
}
.search-input-row input::placeholder {
  color: var(--ink-muted);
}

.search-close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 24px;
  line-height: 1;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 8px;
}
.search-close:hover,
.search-close:focus-visible {
  background: var(--bg-card);
  color: var(--ink);
  outline: none;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.search-result {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
}
.search-result:hover,
.search-result:focus-visible {
  background: var(--bg-card);
  border-color: var(--line);
  outline: none;
}

.search-result-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 15px;
  font-weight: 600;
}

.search-result-kind {
  grid-column: 2;
  grid-row: 1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--bg-card);
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.search-result-kind-chord {
  color: var(--accent);
  border-color: rgba(241, 122, 58, 0.35);
  background: rgba(241, 122, 58, 0.08);
}
.search-result-kind-mode {
  color: #8fc4f0;
  border-color: rgba(143, 196, 240, 0.35);
  background: rgba(143, 196, 240, 0.08);
}
.search-result-kind-scale {
  color: #aac28d;
  border-color: rgba(170, 194, 141, 0.35);
  background: rgba(170, 194, 141, 0.08);
}

.search-result-desc {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.search-empty {
  padding: 16px 14px;
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.4;
  text-align: center;
}

.search-hint {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: 11px;
  color: var(--ink-muted);
  border-top: 1px solid var(--line);
  line-height: 1.4;
}
.search-hint em {
  font-style: normal;
  color: var(--ink-soft);
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  margin: 0 1px;
}

/* ─────────────────────────────────────────────────────────────
   Exercise info button + white-background popover
   ───────────────────────────────────────────────────────────── */

.exercise-info-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink-soft);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.exercise-info-button:hover,
.exercise-info-button:focus-visible {
  background: var(--bg-elevated);
  color: var(--ink);
  outline: none;
}

.info-popover-scrim {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 8, 0.55);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.info-popover-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.info-popover {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 12px));
  width: min(420px, calc(100vw - 36px));
  max-height: calc(100vh - 80px);
  background: #f7f4ee;
  color: #1a1a1a;
  border-radius: 14px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.3);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.info-popover.is-open {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.info-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.info-popover-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: #1a1a1a;
  letter-spacing: 0.01em;
}

.info-popover-close {
  appearance: none;
  background: transparent;
  border: none;
  color: #4a4a4a;
  font-size: 24px;
  line-height: 1;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 6px;
}
.info-popover-close:hover,
.info-popover-close:focus-visible {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
  outline: none;
}

.info-popover-body {
  padding: 14px 18px 18px;
  font-size: 14px;
  line-height: 1.5;
  color: #2a2a2a;
  overflow-y: auto;
  margin: 0;
}

/* ─────────────────────────────────────────────────────────────
   Shared utilities
   ───────────────────────────────────────────────────────────── */

.hidden,
[hidden] {
  display: none !important;
}

/* tabs.js removes the [hidden] attribute when opening the drawer,
   so no override needed — the .is-open class drives the slide-in
   via transform on .drawer / opacity on .drawer-scrim. */
