/* ==========================================================================
   JamScroll — stage-first dark UI
   ========================================================================== */

:root {
  --bg: #0b0d10;
  --bg-raised: #14181d;
  --bg-sunken: #070a0c;
  --surface: rgba(22, 27, 33, 0.92);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --fg: #f2f5f8;
  --fg-dim: #97a2ae;
  --fg-faint: #626d79;

  --accent: #ffb020;
  --accent-ink: #1a1204;
  --accent-soft: rgba(255, 176, 32, 0.16);
  --chord: #ffc85c;

  --radius: 14px;
  --radius-sm: 10px;
  --bar-h: 68px;
  --stage-font: 22px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  color-scheme: dark;
}

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

/* The UA stylesheet's [hidden] { display: none } is an author-beatable rule:
   any author `display` declaration wins over it, regardless of specificity.
   Several overlays here set display (flex/grid), which would leave them laid
   out at inset:0 with opacity:0 — invisible, but swallowing every tap on the
   app. This makes `hidden` mean hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;                 /* the viewer scrolls, never the document */
  overscroll-behavior: none;        /* kills pull-to-refresh and rubber-banding */
  background: var(--bg);
  color: var(--fg);
}

body {
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  touch-action: manipulation;       /* no double-tap zoom, no 300ms delay */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
  font-size: 16px;                  /* anything smaller makes iOS zoom on focus */
}

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ==========================================================================
   Viewer
   ========================================================================== */

#viewer-container {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
}
#viewer-container::-webkit-scrollbar { width: 0; height: 0; }

.layer { display: block; }
.layer[hidden] { display: none; }

/* Room for the last line to clear the control bar. */
.tail-space {
  height: calc(var(--bar-h) + 42vh + env(safe-area-inset-bottom));
}

/* ---------- PDF pages ---------- */

#pdf-layer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0 0;
}

.page {
  width: min(100%, 1400px);
  background: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.page canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Chord charts ---------- */

.chart {
  font-size: var(--stage-font);
  padding: clamp(14px, 3vw, 32px);
  max-width: 1200px;
  margin: 0 auto;
  line-height: 1.3;
}

.song-head { margin: 0 0 1.2em; }
.song-title { font-size: 1.5em; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.song-artist { font-size: 0.8em; margin: 0.2em 0 0; color: var(--fg-dim); }

.chart .section {
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 1.5em 0 0.55em;
}
.chart .comment {
  font-size: 0.78em;
  font-style: italic;
  color: var(--fg-dim);
  margin: 0.4em 0;
}
.chart .gap { height: 0.85em; }

.chart .line {
  margin: 0 0 0.1em;
}
/* Chorded lines stack a chord row above the lyric row. */
.chart .line:not(.lyric-only) { margin-bottom: 0.45em; }

.unit {
  display: inline-block;
  vertical-align: bottom;
  white-space: pre;
}

.chord {
  display: block;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78em;
  font-weight: 700;
  line-height: 1.15;
  color: var(--chord);
  padding-right: 0.75em;      /* keeps adjacent chords from colliding */
  white-space: pre;
}

.lyric { display: block; white-space: pre; }

/* Lines with no chords can wrap normally. */
.chart .lyric-only .unit,
.chart .lyric-only .lyric { white-space: pre-wrap; }

/* ---------- Welcome ---------- */

#welcome {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 8vh 24px calc(var(--bar-h) + 40px);
}
#welcome[hidden] { display: none; }
.welcome-mark { width: 92px; height: 92px; stroke: none; }
#welcome h1 { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
#welcome p { margin: 0; max-width: 42ch; color: var(--fg-dim); }
.welcome-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.welcome-hint { font-size: 13px; color: var(--fg-faint); max-width: 40ch; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  appearance: none;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: transform 0.08s var(--ease), background 0.15s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }

.icon-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.icon-btn:hover { color: var(--fg); }
.icon-btn:active { background: rgba(255, 255, 255, 0.07); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn[hidden] { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   Control bar
   ========================================================================== */

#controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  transition: transform 0.28s var(--ease), opacity 0.28s var(--ease);
}
#controls.hidden {
  transform: translateY(calc(100% + 4px));
  opacity: 0;
  pointer-events: none;
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px clamp(10px, 2vw, 18px);
  min-height: var(--bar-h);
  overflow-x: auto;
  scrollbar-width: none;
}
.bar::-webkit-scrollbar { height: 0; }

#controls.no-song .play-btn,
#controls.no-song #btn-restart,
#controls.no-song .mode-switch,
#controls.no-song #speed-group,
#controls.no-song #duration-group,
#controls.no-song #count-group,
#controls.no-song .progress { opacity: 0.35; pointer-events: none; }

.play-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(255, 176, 32, 0.3);
  transition: transform 0.08s var(--ease);
}
.play-btn:active { transform: scale(0.94); }
.play-btn svg { width: 28px; height: 28px; }
.play-btn .ico-pause { display: none; }
.play-btn.playing .ico-play { display: none; }
.play-btn.playing .ico-pause { display: block; }

.group { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.group[hidden] { display: none; }
.group.grow { flex: 1 1 180px; min-width: 140px; }

.field { display: flex; flex-direction: column; gap: 2px; }
.field-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
  white-space: nowrap;
}
.field input {
  width: 76px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-sunken);
  color: var(--fg);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.readout {
  font-size: 13px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 4.5em;
}
.readout.key { color: var(--chord); font-weight: 700; font-size: 15px; min-width: 3.5em; text-align: center; }

/* Range slider */
input[type="range"] {
  appearance: none;
  flex: 1 1 auto;
  min-width: 90px;
  height: 34px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10.5px;
  border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.16); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border: none; border-radius: 50%; background: var(--fg); }

/* Segmented mode switch */
.mode-switch {
  display: flex;
  flex: 0 0 auto;
  padding: 3px;
  gap: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}
.seg {
  appearance: none;
  min-height: 34px;
  padding: 0 13px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.seg[aria-pressed="true"] { background: var(--bg-raised); color: var(--fg); }

/* +/− steppers */
.stepper .step {
  appearance: none;
  min-width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.stepper .step:active { background: rgba(255, 255, 255, 0.09); }

/* Progress */
.progress {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.09);
  cursor: pointer;
}
.progress-fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: var(--accent);
}

/* ==========================================================================
   Library drawer
   ========================================================================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.22s var(--ease);
}
.scrim.visible { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 51;
  width: min(400px, 86vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.24s var(--ease);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.drawer.visible { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 14px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 { margin: 0; font-size: 19px; }

.drawer-actions { display: flex; gap: 10px; padding: 14px 16px; }
.drawer-actions .btn { flex: 1; padding: 0 10px; }

/* Set-list status strip, shown only when the deployment ships a songs/ folder */
.setlist-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 10px;
  padding: 9px 8px 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}
.setlist-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}
.setlist-label {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--fg-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setlist-sync {
  appearance: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
}
.setlist-sync:active { background: rgba(255, 255, 255, 0.07); }
.setlist-sync svg { width: 18px; height: 18px; }
.setlist-sync.busy { color: var(--accent); }
.setlist-sync.busy svg { animation: spin 0.9s linear infinite; }
.setlist-sync:disabled { cursor: default; }

/* Sources panel (Drive folder configuration) */
.sources { margin: 0 16px 10px; }
/* A real, tappable row. The previous version was an 11px uppercase label in
   --fg-faint, which measures 3.38:1 on this background — below the 4.5:1 AA
   minimum for small text — and was collapsed by default, so the Drive setup was
   effectively invisible. */
.sources-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--fg);
}
.sources-summary::-webkit-details-marker { display: none; }
.sources-summary:active { background: rgba(255, 255, 255, 0.05); }

.sources-glyph { width: 22px; height: 22px; flex: 0 0 auto; color: var(--fg-dim); }

.sources-heading { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sources-name { font-size: 15px; font-weight: 600; }
.sources-state {
  font-size: 12.5px;
  color: var(--accent); /* 9.75:1 — "not connected" should draw the eye */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sources-state.connected { color: #6ddf9c; }

.sources-chevron {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--fg-dim);
  transition: transform 0.2s var(--ease);
}
.sources[open] .sources-chevron { transform: rotate(90deg); }

/* Unconfigured: lift the whole row so it reads as the next thing to do. */
.sources:not([data-configured]) .sources-summary {
  border-color: var(--accent-soft);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg-sunken);
}

.sources-body { margin-top: 8px; }

.sources-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}
.sources-hint, .sources-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg-faint);
}
.sources-hint em { color: var(--fg-dim); font-style: normal; font-weight: 600; }
.sources-note { border-top: 1px solid var(--border); padding-top: 9px; }

.src-field { display: flex; flex-direction: column; gap: 4px; }
.src-field input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  font-size: 16px; /* below 16px iOS zooms the page on focus */
  text-overflow: ellipsis;
}

.sources-actions { display: flex; align-items: center; gap: 10px; }
.drive-status { flex: 1; min-width: 0; font-size: 12px; color: var(--fg-faint); }
.drive-status.ok { color: #6ddf9c; }
.drive-status.warn { color: #ffb020; }

.song-revert {
  appearance: none;
  width: 36px;
  height: 40px;
  flex: 0 0 auto;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-faint);
  font-size: 17px;
  cursor: pointer;
}
.song-revert:active { color: var(--accent); background: var(--accent-soft); }

.song-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 1px;
}

.song-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; -webkit-overflow-scrolling: touch; }
.song-list .empty { color: var(--fg-faint); text-align: center; padding: 32px 16px; font-size: 15px; }

.song-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
}
.song-row.current { background: var(--accent-soft); }

.song-open {
  appearance: none;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  min-width: 0;
}
.song-open:active { background: rgba(255, 255, 255, 0.06); }
.song-icon { font-size: 20px; flex: 0 0 auto; }
.song-body { display: flex; flex-direction: column; min-width: 0; }
.song-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-sub { font-size: 12.5px; color: var(--fg-faint); }
.song-row.current .song-name { color: var(--accent); }

.song-delete {
  appearance: none;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-faint);
  font-size: 16px;
  cursor: pointer;
}
.song-delete:active { color: #ff6b6b; background: rgba(255, 107, 107, 0.12); }

.drawer-foot {
  margin: 0;
  padding: 12px 20px;
  font-size: 12px;
  color: var(--fg-faint);
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Editor
   ========================================================================== */

.editor {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateY(1.5%);
  opacity: 0;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
  padding-top: env(safe-area-inset-top);
  padding-bottom: var(--kb-inset, env(safe-area-inset-bottom));
}
.editor.visible { transform: none; opacity: 1; }

.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.editor-name {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-sunken);
  color: var(--fg);
  font: inherit;
  font-weight: 550;
}
.editor-status { font-size: 12.5px; color: var(--fg-faint); min-width: 4.5em; text-align: right; }

.editor-palette {
  display: flex;
  gap: 7px;
  padding: 9px 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.editor-palette::-webkit-scrollbar { height: 0; }
.chip {
  appearance: none;
  flex: 0 0 auto;
  min-width: 44px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--chord);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.chip:active { background: var(--accent-soft); }

.editor-body { flex: 1; position: relative; min-height: 0; }

.editor-text {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
  border: none;
  resize: none;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.5;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.editor-text:focus { outline: none; }

.editor-preview {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  --stage-font: 18px;
}
.editor-preview.visible { display: block; }
.editor-preview .tail-space { height: 24px; }

.editor-help {
  margin: 0;
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--fg-faint);
  border-top: 1px solid var(--border);
}
.editor-help code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--chord);
}

/* ==========================================================================
   Install banner
   ========================================================================== */

/* Sits above the control bar, but below the drawer and the editor — an
   invitation to install must never cover what the musician opened. */
.install {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom));
  width: min(560px, calc(100vw - 28px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, 14px);
  opacity: 0;
  transition: transform 0.24s var(--ease), opacity 0.24s var(--ease);
}
.install.visible { transform: translate(-50%, 0); opacity: 1; }
.install-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.install-sub, .install-hint { font-size: 13px; color: var(--fg-dim); }
.install-hint em { color: var(--fg); font-style: normal; font-weight: 600; }
.share-glyph { width: 15px; height: 15px; vertical-align: -2px; margin: 0 1px; }

/* ==========================================================================
   Count-in
   ========================================================================== */

.countdown {
  position: fixed;
  inset: 0;
  /* Below the control bar (40) on purpose: the backdrop blur must dim the
     chart without smearing the Play button you cancel the count-in with. */
  z-index: 39;
  display: grid;
  place-items: center;
  /* Transparent to taps, so the bar underneath stays reachable. */
  pointer-events: none;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.countdown-num {
  font-size: clamp(120px, 34vmin, 340px);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 70px rgba(255, 176, 32, 0.35);
  animation: count-pop 0.95s var(--ease) both;
}

@keyframes count-pop {
  0%   { transform: scale(0.55); opacity: 0; }
  16%  { transform: scale(1);    opacity: 1; }
  100% { transform: scale(1.08); opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  .countdown-num { animation: none; }
}

/* ==========================================================================
   Busy + toast
   ========================================================================== */

.busy {
  position: fixed;
  z-index: 45;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--fg-dim);
}
.busy[hidden] { display: none; }
.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(var(--bar-h) + 22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: #23282f;
  border: 1px solid var(--border-strong);
  font-size: 14.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Night / stage mode
   ==========================================================================
   PDFs get inverted so white paper turns black. Chord charts are already
   light-on-dark, so they just get dimmed — inverting them too would undo the
   theme. Scoping the filter to the canvas is what keeps the control bar and
   the chart out of it. */

.night #pdf-layer .page { background: #000; box-shadow: none; }
.night #pdf-layer .page canvas { filter: invert(0.9) hue-rotate(180deg); }

.night {
  --fg: #cbd3db;
  --fg-dim: #7c8792;
  --accent: #d18f1e;
  --chord: #d9a94f;
}
.night body { background: #000; }
.night #viewer-container { background: #000; }

/* ==========================================================================
   Motion / display preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Landscape phones and short windows: shrink the bar so music keeps the room. */
@media (max-height: 460px) {
  :root { --bar-h: 56px; }
  .play-btn { width: 46px; height: 46px; }
  .field-label { display: none; }
}

/* Wide iPad: editor shows text and preview side by side. */
@media (min-width: 900px) {
  .editor-preview.visible {
    left: 50%;
    border-left: 1px solid var(--border);
  }
  .editor-body:has(.editor-preview.visible) .editor-text {
    right: 50%;
  }
}
