/* chordlab player ---------------------------------------------------------- */

/* Ubuntu, served from this host rather than a font CDN: the page already only
   talks to one machine, and a second origin is a second thing that can be
   slow, blocked, or watching. Latin subset only, three weights, 93 KB. */
@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ubuntu-400.woff2") format("woff2");
}
@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ubuntu-500.woff2") format("woff2");
}
@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/ubuntu-700.woff2") format("woff2");
}

:root {
  /* Black by default, the way Apple does dark: a true black ground, surfaces
     lifted off it in greys, hairline edges, and colour kept for what matters --
     the chord. Every colour on the page is one of these tokens, and the light
     theme below redefines the same set. app.js reads the chord and canvas ones
     from here, so the script holds no colours of its own. */
  color-scheme: dark;
  --bg: #000000;
  --bg-tint-a: rgba(48, 209, 88, 0.10);
  --bg-tint-b: rgba(48, 209, 88, 0.04);
  --bg-tint-c: rgba(0, 0, 0, 0);
  --bg-tint-d: rgba(0, 0, 0, 0);

  /* Two materials. Cards are glass: translucent, blurred, lit at the top edge.
     Anything that floats over other content -- menus, the settings drawer,
     toasts, tooltips, dialogs -- is the thick material: nearly opaque, because
     text laid over other text has to be read, and see-through there is not
     glass, it is clutter. */
  --panel: rgba(28, 28, 30, 0.78);
  --panel-2: rgba(255, 255, 255, 0.05);
  --panel-3: rgba(255, 255, 255, 0.10);
  --bar: rgba(12, 12, 14, 0.72);
  --popover: rgba(36, 36, 38, 0.94);
  --popover-edge: rgba(255, 255, 255, 0.10);
  --sheen: rgba(255, 255, 255, 0.07);
  --glass-hi: rgba(255, 255, 255, 0.05);
  --glass-lo: rgba(255, 255, 255, 0);
  --glass-edge: rgba(255, 255, 255, 0.08);
  --glass-edge-hi: rgba(255, 255, 255, 0.22);

  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.15);

  --text: #f5f5f7;
  --muted: rgba(235, 235, 245, 0.62);
  --faint: rgba(235, 235, 245, 0.36);

  --accent: #30d158;
  --accent-2: #5fdc86;
  --grad: linear-gradient(180deg, #30c158 0%, #22a047 100%);
  --on-accent: #ffffff;
  --accent-soft: rgba(48, 209, 88, 0.16);
  --accent-wash: rgba(48, 209, 88, 0.08);
  --accent-glow: rgba(48, 209, 88, 0.30);
  --focus-ring: rgba(48, 209, 88, 0.22);
  --danger: #ff453a;
  --danger-text: #ff6961;
  /* the mixer's mute and solo, coloured as Logic colours them */
  --mute-on: rgba(10, 132, 255, 0.24);
  --mute-ink: #64a8ff;
  --solo-on: rgba(255, 214, 10, 0.22);
  --solo-ink: #ffd60a;
  --danger-edge: rgba(255, 69, 58, 0.45);
  --ok-edge: rgba(48, 209, 88, 0.40);

  --radius: 22px;
  --radius-sm: 14px;
  --blur: saturate(180%) blur(26px);
  --blur-thick: saturate(180%) blur(34px);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lift: 0 18px 48px rgba(0, 0, 0, 0.60);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
  --scrim: rgba(0, 0, 0, 0.60);

  --field: rgba(118, 118, 128, 0.20);
  --field-edge: rgba(255, 255, 255, 0.08);
  --field-inset: inset 0 1px 2px rgba(0, 0, 0, 0.30);

  --tint-1: rgba(255, 255, 255, 0.04);
  --tint-2: rgba(255, 255, 255, 0.10);
  --barline: rgba(255, 255, 255, 0.08);
  --beat: rgba(255, 255, 255, 0.25);
  --lane-playhead: #ffffff;

  --diag-fret: rgba(255, 255, 255, 0.20);
  --diag-nut: rgba(255, 255, 255, 0.85);
  --diag-string: rgba(255, 255, 255, 0.32);
  --diag-open: rgba(255, 255, 255, 0.62);
  --diag-mute: rgba(255, 255, 255, 0.45);
  --dot-ring: #000000;
  --key-white: #e5e5ea;
  --key-black: #1c1c1e;
  --key-edge: rgba(0, 0, 0, 0.55);
  --key-name: #1c1c1e;

  /* the seek bar's canvas, read once by app.js and again on a theme change */
  --wave-dim: rgba(255, 255, 255, 0.22);
  --wave-hover: rgba(255, 255, 255, 0.42);
  --playhead: #ffffff;
  --loop-fill: rgba(48, 209, 88, 0.18);
  --loop-edge: rgba(48, 209, 88, 0.92);

  /* Chord colour. The hue walks the circle of fifths (app.js); saturation and
     lightness are the theme's. On black the fills are lighter and the names
     lighter still, and text on a solid chord fill turns dark. */
  --chord-s: 68%;
  --chord-s-minor: 52%;
  --chord-l: 60%;
  --chord-l-minor: 64%;
  --nc-s: 6%;
  --nc-l: 56%;
  --nc-block-l: 48%;
  --ink-a: 14%;            /* the chord name, against its card */
  --ink-b: 18%;            /* chord names in the lane */
  --ink-c: 20%;            /* chord names in the sheet and legend */
  --on-chord: rgba(0, 0, 0, 0.86);

  --sans: "Ubuntu", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Ubuntu Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  /* current chord colour, updated from script */
  --h: 152;
  --s: var(--chord-s);
  --l: var(--chord-l);
}

/* The pale green glass, for whoever prefers it (Settings, Appearance). */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eaf3ec;
  --bg-tint-a: rgba(86, 196, 140, 0.44);
  --bg-tint-b: rgba(112, 205, 212, 0.34);
  --bg-tint-c: rgba(108, 212, 160, 0.40);
  --bg-tint-d: rgba(154, 222, 182, 0.34);

  --panel: rgba(255, 255, 255, 0.30);
  --panel-2: rgba(255, 255, 255, 0.18);
  --panel-3: rgba(255, 255, 255, 0.46);
  --bar: rgba(255, 255, 255, 0.30);
  --popover: rgba(248, 252, 249, 0.92);
  --popover-edge: rgba(255, 255, 255, 0.85);
  --sheen: rgba(255, 255, 255, 0.90);
  --glass-hi: rgba(255, 255, 255, 0.45);
  --glass-lo: rgba(255, 255, 255, 0.02);
  --glass-edge: rgba(255, 255, 255, 0.55);
  --glass-edge-hi: rgba(255, 255, 255, 0.90);

  --line: rgba(22, 74, 46, 0.10);
  --line-2: rgba(22, 74, 46, 0.20);

  --text: #16301f;
  --muted: #4a6d57;
  --faint: #7a9887;

  --accent: #1f9d62;
  --accent-2: #46bd8a;
  --grad: linear-gradient(135deg, #2aa96c 0%, #57c9a0 100%);
  --on-accent: #ffffff;
  --accent-soft: rgba(31, 157, 98, 0.14);
  --accent-wash: rgba(31, 157, 98, 0.07);
  --accent-glow: rgba(31, 157, 98, 0.35);
  --focus-ring: rgba(31, 157, 98, 0.16);
  --danger: #c0392b;
  --danger-text: #a8261b;
  --mute-on: rgba(0, 96, 223, 0.14);
  --mute-ink: #0058cc;
  --solo-on: rgba(196, 146, 0, 0.18);
  --solo-ink: #7a5a00;
  --danger-edge: rgba(192, 57, 43, 0.40);
  --ok-edge: rgba(31, 157, 98, 0.35);

  --shadow: 0 10px 30px rgba(18, 64, 40, 0.10);
  --shadow-lift: 0 16px 40px rgba(18, 64, 40, 0.16);
  --shadow-sm: 0 2px 8px rgba(18, 64, 40, 0.12);
  --scrim: rgba(12, 32, 22, 0.32);

  --field: rgba(255, 255, 255, 0.50);
  --field-edge: rgba(255, 255, 255, 0.70);
  --field-inset: inset 0 1px 2px rgba(18, 64, 40, 0.06);

  --tint-1: rgba(22, 74, 46, 0.04);
  --tint-2: rgba(22, 74, 46, 0.10);
  --barline: rgba(22, 74, 46, 0.09);
  --beat: rgba(22, 74, 46, 0.22);
  --lane-playhead: #ffffff;

  --diag-fret: rgba(22, 74, 46, 0.22);
  --diag-nut: rgba(22, 74, 46, 0.78);
  --diag-string: rgba(22, 74, 46, 0.34);
  --diag-open: rgba(22, 74, 46, 0.65);
  --diag-mute: rgba(22, 74, 46, 0.50);
  --dot-ring: #ffffff;
  --key-white: #fdfffe;
  --key-black: #1d3b2a;
  --key-edge: rgba(22, 74, 46, 0.45);
  --key-name: #16301f;

  --wave-dim: rgba(22, 74, 46, 0.20);
  --wave-hover: rgba(22, 74, 46, 0.38);
  --playhead: #16301f;
  --loop-fill: rgba(31, 157, 98, 0.18);
  --loop-edge: rgba(31, 157, 98, 0.92);

  --chord-s: 58%;
  --chord-s-minor: 46%;
  --chord-l: 33%;
  --chord-l-minor: 36%;
  --nc-s: 8%;
  --nc-l: 44%;
  --nc-block-l: 52%;
  --ink-a: -6%;
  --ink-b: -10%;
  --ink-c: 8%;
  --on-chord: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

/* An app, not a document: it is laid out for the screen it is on, and nothing
   on it is better for being zoomed. The viewport tag forbids pinch-zoom where
   it is honoured; iOS Safari ignores that part of it, so the same is said
   here, where it is listened to -- panning allowed, zooming (pinch and double
   tap) not. Text inputs and sliders are left with their own behaviour, and
   the chord lane and seek bar keep the "none" they need for scrubbing. */
html, body, body *:not(input) { touch-action: pan-x pan-y; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Pull-to-refresh on a phone reloads the page, and a reload mid-song is
     never what somebody dragging the lane down meant. */
  overscroll-behavior: none;
}
body { overscroll-behavior: none; }
button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

body {
  background:
    radial-gradient(1100px 700px at 12% -12%, var(--bg-tint-a), transparent 60%),
    radial-gradient(900px 600px at 96% 4%, var(--bg-tint-b), transparent 55%),
    radial-gradient(760px 520px at 50% 106%, var(--bg-tint-c), transparent 62%),
    radial-gradient(520px 420px at 78% 72%, var(--bg-tint-d), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* The glass recipe, in one place: a translucent fill, a blurred backdrop, a
   lit top edge and a soft shadow underneath. For cards -- things that sit on
   the ground, not over other content. */
.glass,
.gate-card, .admin-card, .loading-card, .offline-card,
.recent-item, .now, .lane, .transport, .sheet {
  background:
    linear-gradient(180deg, var(--glass-hi), var(--glass-lo) 46%),
    var(--panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow), inset 0 1px 0 var(--sheen);
}

/* The thick material, for what floats over other content. The export menu
   used to be glass at 18% -- the song's chords showed straight through its
   list, and on a phone the menu was hard to read at all. It is nearly opaque
   now, and the little that does come through is blurred to a tint. */
.menu-list, .drawer, .dialog, .modal-card, .toast, .seek-tip, .swap-card,
.lane-zoom .icon-btn, .stems-sheet {
  background: var(--popover);
  backdrop-filter: var(--blur-thick);
  -webkit-backdrop-filter: var(--blur-thick);
  border: 1px solid var(--popover-edge);
  box-shadow: var(--shadow-lift), inset 0 1px 0 var(--sheen);
}

button, input, select, output, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.ico { width: 18px; height: 18px; flex: none; display: block; }
/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  font-weight: 560;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: var(--glass-edge-hi); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; }
.btn.primary {
  background: var(--grad);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 680;
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--grad); }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.icon-btn.small { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.small .ico { width: 16px; height: 16px; }

/* ------------------------------------------------------------------- app */
.app {
  /* dvh, not vh: on a phone 100vh is the height with the browser's toolbars
     hidden, so the bottom of the player sat underneath them. */
  height: 100vh;
  height: 100dvh;
  display: grid;
  /* With viewport-fit=cover the page reaches into the notch and the home
     indicator in landscape; keep everything that matters out of them. */
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
           env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  grid-template-rows: 64px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  /* A grid item is never narrower than its content unless told otherwise, and
     a long song title would otherwise push the whole page wider than a phone. */
  min-width: 0;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

/* Glass that has a popover inside it keeps its blur on a layer behind its
   content, not on itself. An element with backdrop-filter becomes the edge of
   the world for anything inside it that blurs: the export menu, inside the top
   bar, had nothing to blur, so the chords under it came through sharp -- text
   through text -- instead of as a frosted tint. Same for the seek-bar tooltip
   in the transport and the zoom buttons in the lane. */
.topbar::before, .transport::before, .lane::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.topbar::before { background: var(--bar); }
.transport, .lane {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.transport { position: relative; z-index: 0; }
.lane { z-index: 0; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px;
  border-radius: 10px;
}
.brand-mark { width: 30px; height: 30px; }
.brand-text { display: grid; gap: 1px; text-align: left; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
/* What the name stands for, once, quietly, beside it. */
.brand-expand {
  font-size: 10.5px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--faint);
  white-space: nowrap;
}
.brand-name b { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.track { flex: 1; min-width: 0; padding-left: 16px; border-left: 1px solid var(--line); }
.track-title { font-weight: 640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.track-meta b { color: var(--text); font-weight: 620; }
.track-meta .arrow { color: var(--accent-2); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.menu { position: relative; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 230px;
  /* Fourteen rows: taller than a phone held sideways, so it scrolls there. */
  max-height: calc(100dvh - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border-radius: 14px;
  display: none;
  z-index: 40;
}
.menu-list.open { display: block; }
.menu-note { padding: 6px 10px 8px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.menu-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 10px;
  border: 0;
  background: none;
  border-radius: 9px;
  text-align: left;
}
.menu-list button:hover { background: var(--panel-3); }
.menu-list small { color: var(--faint); font-family: var(--mono); }

.view { min-height: 0; }

/* ----------------------------------------------------------------- start */
.start {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr);
  gap: 28px;
  padding: 34px 40px 30px;
  overflow: auto;
}
.start-hero { display: flex; flex-direction: column; justify-content: center; max-width: 660px; min-width: 0; }
.back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding: 6px 12px 6px 8px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  max-width: 100%;
  min-width: 0;
}
/* One line, however long the title: three lines of song name in a pill is a
   paragraph, not a button. */
.back-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-link .ico { flex: none; }
.back-link:hover { color: var(--text); }
.start h1 {
  font-size: clamp(38px, 5.2vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.045em;
  font-weight: 800;
}
.start h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); font-size: 16px; max-width: 520px; margin: 18px 0 26px; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 20px;
  border-radius: 22px;
  border: 1.5px dashed var(--line-2);
  background: linear-gradient(180deg, var(--accent-wash), transparent);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.drop:hover, .drop.over { border-color: var(--accent-2); background: linear-gradient(180deg, var(--accent-soft), var(--accent-wash)); }
.drop-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--grad);
  color: var(--on-accent);
  margin-bottom: 8px;
  box-shadow: 0 10px 30px var(--accent-glow);
}
.drop-icon .ico { width: 26px; height: 26px; }
.drop-title { font-size: 18px; font-weight: 680; }
.drop-sub { color: var(--muted); font-size: 13px; }
.drop-sub u { color: var(--text); text-underline-offset: 3px; }

.path-row { display: flex; gap: 8px; margin-top: 14px; }
.path-row input, .field select {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--field);
  font-family: var(--mono);
  font-size: 13px;
}
.path-row .btn { height: 42px; }

.start-side { display: flex; flex-direction: column; gap: 16px; min-height: 0; min-width: 0; }
.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel.grow { flex: 1; min-height: 260px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.panel-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 640; }
.empty-note { padding: 6px 16px 16px; color: var(--faint); font-size: 13px; }

.recent { padding: 0 8px 10px; display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
.recent-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 12px;
  border: 0;
  background: none;
  text-align: left;
}
.recent-item:hover { background: var(--panel-3); }
.recent-art {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--on-chord);
  background: hsl(var(--h) var(--s) var(--l));
}
.recent-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-meta { font-size: 12px; color: var(--muted); }
.recent-time { font-size: 12px; color: var(--faint); font-family: var(--mono); }

.browser-path {
  margin: 0 16px 6px;
  font: 11px var(--mono);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
}
.browser { flex: 1; overflow: auto; padding: 0 8px 10px; min-height: 0; }
.entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  text-align: left;
  font-size: 13px;
}
.entry:hover { background: var(--panel-3); }
.entry .ico { width: 16px; height: 16px; color: var(--faint); }
.entry.audio .ico { color: var(--accent-2); }
.entry-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-size { font: 11px var(--mono); color: var(--faint); }

/* --------------------------------------------------------------- loading */
.loading { display: grid; place-items: center; padding: 24px; }
.loading-card {
  width: min(460px, 100%);
  padding: 34px 34px 28px;
  border-radius: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
  text-align: center;
}
.eq { display: flex; justify-content: center; align-items: flex-end; gap: 5px; height: 46px; margin-bottom: 20px; }
.eq i {
  width: 7px;
  border-radius: 4px;
  background: var(--grad);
  animation: eq 1.1s ease-in-out infinite;
}
.eq i:nth-child(1) { animation-delay: -0.9s; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.7s; }
.eq i:nth-child(4) { animation-delay: -0.1s; }
.eq i:nth-child(5) { animation-delay: -0.5s; }
.eq i:nth-child(6) { animation-delay: -0.2s; }
.eq i:nth-child(7) { animation-delay: -0.8s; }
@keyframes eq { 0%, 100% { height: 18%; } 50% { height: 100%; } }
.loading.failed .eq i { animation: none; height: 20%; background: var(--danger); }

.loading-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.loading-title { font-size: 21px; font-weight: 700; margin: 4px 0 2px; word-break: break-word; }
.loading-stage { color: var(--muted); font-size: 13px; min-height: 20px; }
.progress { height: 6px; border-radius: 99px; background: var(--panel-3); overflow: hidden; margin: 18px 0 20px; }
.progress i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width 0.3s ease; }
.steps { list-style: none; padding: 0; margin: 0; text-align: left; display: grid; gap: 8px; }
.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 13px;
}
.steps li::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
}
.steps li.active { color: var(--text); }
.steps li.active::before { border-color: var(--accent-2); border-right-color: transparent; animation: spin 0.8s linear infinite; }
.steps li.done { color: var(--muted); }
.steps li.done::before {
  content: "\2713";
  display: grid;
  place-items: center;
  border: 0;
  background: var(--grad);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 800;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-error { margin-top: 18px; }
.loading-error-text { color: var(--danger); font-size: 13px; margin-bottom: 14px; word-break: break-word; }
.loading-error .row { display: flex; gap: 8px; justify-content: center; }

/* ---------------------------------------------------------------- player */
.player {
  display: grid;
  grid-template-rows: auto 124px auto minmax(0, 1fr);
  gap: 14px;
  padding: 16px 20px 18px;
  position: relative;
}

/* Swapping in the karaoke track, or a stream that has stalled: one quiet card
   over the player. It fades in only after a quarter of a second, so a swap
   that is over at once never flashes it. Out of the grid's flow, so showing
   it moves nothing. */
.swap-card {
  position: absolute;
  left: 50%;
  top: 38%;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px 13px 16px;
  border-radius: 99px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: swap-in 0.22s ease 0.25s both;
}
.player.is-swapping > :not(.swap-card) { opacity: 0.72; transition: opacity 0.25s ease; }
.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes swap-in {
  from { opacity: 0; transform: translate(-50%, -42%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* now playing */
.now {
  position: relative;
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr) 236px;
  align-items: center;
  gap: 28px;
  padding: 20px 26px;
  min-height: 214px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    radial-gradient(90% 150% at 38% -20%, hsl(var(--h) var(--s) var(--l) / 0.22), transparent 62%),
    var(--panel);
  overflow: hidden;
  transition: background 0.4s ease;
}
.now::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, hsl(var(--h) var(--s) var(--l) / 0.7), transparent);
}
.now-diagram { cursor: pointer; position: relative; display: grid; place-items: center; min-height: 176px; }
.now-main { min-width: 0; }
.now-kicker { display: flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--muted); }
.now-kicker .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.now-chord {
  margin: 2px 0 6px;
  font-size: clamp(64px, 8.6vw, 128px);
  line-height: 0.98;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: hsl(var(--h) var(--s) calc(var(--l) + var(--ink-a)));
  text-shadow: 0 0 60px hsl(var(--h) var(--s) var(--l) / 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-chord.nc { color: var(--muted); text-shadow: none; }
.now-chord.pop { animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes pop { from { transform: translateY(6px) scale(0.97); opacity: 0.4; } to { transform: none; opacity: 1; } }
.now-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; min-height: 22px; font-size: 14px; color: var(--muted); }
.now-sub .roman {
  font: 700 13px var(--mono);
  color: hsl(var(--h) var(--s) calc(var(--l) + var(--ink-b)));
  padding: 1px 8px;
  border-radius: 99px;
  background: hsl(var(--h) var(--s) var(--l) / 0.14);
}
.now-sub .roman:empty { display: none; }
.now-sub .notes { letter-spacing: 0.04em; }
.now-sub .capo-note { color: var(--accent-2); }
.now-sure { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.meter { width: 120px; height: 5px; border-radius: 99px; background: var(--tint-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 99px; background: hsl(var(--h) var(--s) var(--l)); transition: width 0.3s ease; }
.alt { color: var(--text); }
.alt:empty { display: none; }
.alt b { font-weight: 650; }

.now-next {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 12px;
  border-radius: 18px;
  background: var(--tint-1);
  border: 1px solid var(--line);
}
.next-head { display: flex; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.next-in { font-family: var(--mono); letter-spacing: 0; text-transform: none; color: var(--text); }
.next-body { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.next-chord {
  flex: 1;
  min-width: 0;
  font-size: clamp(22px, 2.5vw, 38px);
  font-weight: 780;
  letter-spacing: -0.04em;
  line-height: 1;
  overflow-wrap: anywhere;
  color: hsl(var(--h) var(--s) calc(var(--l) + var(--ink-a)));
}
.next-diagram { width: 76px; flex: none; }
.next-progress { height: 3px; border-radius: 99px; background: var(--tint-2); overflow: hidden; }
.next-progress i { display: block; height: 100%; width: 0; background: hsl(var(--h) var(--s) var(--l)); }

/* chord diagrams */
.diag { display: block; width: 100%; height: auto; overflow: visible; }
.diag.large { width: 150px; }
.diag.large.piano { width: 176px; }
.legend-item .diag.piano { width: 44px; }
.diag .fret { stroke: var(--diag-fret); stroke-width: 1.2; }
.diag .nut { stroke: var(--diag-nut); stroke-width: 4; stroke-linecap: round; }
.diag .string { stroke: var(--diag-string); stroke-width: 1.2; }
.diag .dot { fill: hsl(var(--h) var(--s) var(--l)); }
.diag .dot.root { stroke: var(--dot-ring); stroke-width: 2; }
.diag .barre { fill: hsl(var(--h) var(--s) var(--l)); }
.diag .open { fill: none; stroke: var(--diag-open); stroke-width: 1.6; }
.diag .open.root { stroke: hsl(var(--h) var(--s) calc(var(--l) + var(--ink-b))); stroke-width: 2.2; }
.diag .mute { fill: var(--diag-mute); font: 700 11px var(--sans); }
.diag .base { fill: var(--muted); font: 600 10px var(--mono); }
.diag .sname { fill: var(--faint); font: 600 8.5px var(--mono); }
.diag .key-white { fill: var(--key-white); stroke: var(--key-edge); stroke-width: 1; }
.diag .key-black { fill: var(--key-black); stroke: var(--key-edge); stroke-width: 1; }
.diag .key-white.on { fill: hsl(var(--h) var(--s) var(--l)); }
.diag .key-black.on { fill: hsl(var(--h) var(--s) calc(var(--l) - 12%)); }
.diag .key-white.bass { fill: hsl(var(--h) calc(var(--s) - 30%) calc(var(--l) + 8%)); }
.diag .kname { font: 700 8px var(--sans); fill: var(--key-name); }
.diag-empty {
  width: 118px;
  height: 140px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px dashed var(--line-2);
  color: var(--faint);
  font-weight: 700;
}
.next-diagram .diag-empty { width: 80px; height: 94px; font-size: 12px; }
.diag-count {
  position: absolute;
  right: 0;
  bottom: -4px;
  font: 600 10px var(--mono);
  color: var(--muted);
  background: var(--panel-3);
  border-radius: 99px;
  padding: 1px 7px;
}

/* chord lane */
.lane {
  position: relative;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.lane.dragging { cursor: grabbing; }
.lane-track { position: absolute; inset: 0 auto 0 0; will-change: transform; }
.barline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--barline); }
.barline b { position: absolute; top: 7px; left: 6px; font: 600 10px var(--mono); color: var(--faint); }
.beat { position: absolute; bottom: 9px; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--beat); }
.block {
  position: absolute;
  top: 28px;
  bottom: 22px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  overflow: hidden;
  background: hsl(var(--h) var(--s) var(--l) / 0.13);
  box-shadow: inset 0 0 0 1px hsl(var(--h) var(--s) var(--l) / 0.32);
  transition: background 0.2s, box-shadow 0.2s, opacity 0.3s;
}
.block span {
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: hsl(var(--h) var(--s) calc(var(--l) + var(--ink-b)));
}
.block:hover { background: hsl(var(--h) var(--s) var(--l) / 0.22); }
.block.past { opacity: 0.42; }
.block.active {
  opacity: 1;
  background: hsl(var(--h) var(--s) var(--l));
  box-shadow: 0 10px 34px hsl(var(--h) var(--s) var(--l) / 0.45);
}
.block.active span { color: var(--on-chord); }
.block.nc { --h: 220; --s: var(--nc-s); --l: var(--nc-block-l); }
.block.narrow { padding: 0 6px; }
.block.narrow span { font-size: 13px; }
.block.tiny span { display: none; }
.lane-fade { position: absolute; top: 0; bottom: 0; width: 70px; pointer-events: none; }
.lane-fade.left { left: 0; background: linear-gradient(90deg, var(--panel), transparent); }
.lane-fade.right { right: 0; background: linear-gradient(270deg, var(--panel), transparent); }
.lane-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 36%;
  width: 2px;
  margin-left: -1px;
  background: var(--lane-playhead);
  box-shadow: 0 0 14px var(--accent-glow);
  pointer-events: none;
}
.lane-playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -6px;
  border: 7px solid transparent;
  border-top-color: var(--lane-playhead);
}
.lane-zoom { position: absolute; right: 8px; bottom: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.2s; }
.lane:hover .lane-zoom { opacity: 1; }

/* transport */
.transport {
  min-width: 0;             /* the controls wrap; without this they widen the page */
  padding: 12px 18px 12px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.seek { position: relative; height: 56px; }
.seek canvas { display: block; width: 100%; height: 56px; cursor: pointer; touch-action: none; }
.seek-tip {
  position: absolute;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.seek-tip b { font-weight: 720; margin-right: 8px; }
.seek-tip span { font-family: var(--mono); color: var(--muted); }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-top: 8px; }
.time { font: 13px var(--mono); color: var(--muted); }
.time span:first-child { color: var(--text); }
.time .slash { margin: 0 6px; color: var(--faint); }
.buttons { display: flex; align-items: center; gap: 6px; }
.play {
  width: 54px;
  height: 54px;
  margin: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--grad);
  color: var(--on-accent);
  box-shadow: 0 10px 30px var(--accent-glow);
  transition: transform 0.12s, filter 0.15s;
}
.play:hover { filter: brightness(1.08); }
.play:active { transform: scale(0.96); }
.play .ico { width: 24px; height: 24px; }

.tools { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.segmented { display: flex; padding: 3px; border-radius: 11px; background: var(--panel-3); }
.segmented button {
  border: 0;
  background: none;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.segmented.wide button { flex: 1; padding: 8px 10px; font-size: 13px; }
.segmented button[aria-checked="true"] { background: var(--popover); color: var(--text); box-shadow: inset 0 1px 0 var(--sheen), var(--shadow-sm); }
.stepper { display: flex; align-items: center; height: 32px; border-radius: 10px; background: var(--panel-3); padding: 0 3px 0 10px; }
.stepper-label { font-size: 11px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.stepper button { width: 24px; height: 24px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 15px; line-height: 1; }
.stepper button:hover { background: var(--panel); color: var(--text); }
.stepper output { min-width: 24px; text-align: center; font: 600 12px var(--mono); }
.stepper output.changed { color: var(--accent-2); }
/* The key control's own progress, as the vocals slider has: a hairline that
   fills while the host prepares the new key, the music playing on meanwhile. */
.key-stepper { position: relative; }
.stepper-progress {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.3s;
  pointer-events: none;
}
.key-stepper[data-state="preparing"] .stepper-progress,
.speed-wrap[data-state="preparing"] .stepper-progress { opacity: 1; }
.speed-wrap { position: relative; display: inline-flex; }
.speed-wrap[data-state="preparing"] .speed { color: var(--accent-2); }
.key-stepper[data-state="preparing"] output { color: var(--accent-2); animation: key-wait 1.4s ease-in-out infinite; }
.key-stepper[data-state="error"] output { color: var(--danger); }
@keyframes key-wait { 50% { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) {
  .key-stepper[data-state="preparing"] output { animation: none; }
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 10px;
  border: 0;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.pill .ico { width: 15px; height: 15px; }
.pill:hover { color: var(--text); }
.pill[aria-pressed="true"], .pill[data-mode="chord"], .pill[data-mode="bar"] {
  background: var(--accent-soft);
  color: var(--accent-2);
}
.speed {
  height: 32px;
  border-radius: 10px;
  border: 0;
  background: var(--panel-3);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.volume { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.volume .ico { width: 16px; height: 16px; }
.volume input { width: 80px; accent-color: var(--accent-2); }

/* vocal volume (karaoke) */
.vocals {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 3px;
  border-radius: 10px;
  background: var(--panel-3);
}
.vocals-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.vocals-toggle .ico { width: 15px; height: 15px; }
.vocals-toggle:hover { color: var(--text); background: var(--panel); }
.vocals-toggle[aria-pressed="true"] { background: var(--grad); color: var(--on-accent); }
.vocals-slider { position: relative; display: flex; align-items: center; }
.vocals-slider input { width: 112px; accent-color: var(--accent); }
.vocals-progress {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.3s;
  pointer-events: none;
}
.vocals[data-state="preparing"] .vocals-progress { opacity: 1; }
.vocals output { min-width: 36px; text-align: right; font: 600 11px var(--mono); color: var(--muted); }
.vocals[data-state="preparing"] output,
.vocals[data-state="error"] output { min-width: 70px; color: var(--accent-2); }
.vocals[data-state="error"] output { color: var(--danger); }
.vocals[data-state="unavailable"] { opacity: 0.45; }
.vocals[data-state="unavailable"] input { pointer-events: none; }
.stems-open[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-2); }

/* The song being split: a line under the slider that fills as the split goes,
   with a sheen running along it so that a split waiting its turn on the GPU
   still looks alive; and a ring round the Stems icon saying the same. Once the
   split has got far enough to mix from, the slider works and its number is
   its level again; the line and the ring carry on until the split is done. */
.vocals[data-state="preparing"] .vocals-progress {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 45%,
                              var(--accent) 55%, var(--accent-2) 100%);
  background-size: 220% 100%;
  animation: sheen 1.6s linear infinite;
}
.vocals[data-live="true"] output { min-width: 36px; color: var(--muted); }
@keyframes sheen { from { background-position: 100% 0; } to { background-position: -120% 0; } }
.stems-badge { position: relative; display: inline-grid; place-items: center; }
.stems-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), var(--line-2) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), currentColor calc(100% - 1.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), currentColor calc(100% - 1.5px));
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.stems-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(transparent 0 0.8turn, var(--accent-2) 0.97turn, transparent 1turn);
  animation: spin 1.6s linear infinite;
}
.vocals[data-state="preparing"] .stems-ring { opacity: 1; }
/* Ready: one pulse, so that it is noticed without anybody having to look. */
.vocals.just-ready { animation: ready-pulse 1.1s ease-out 2; }
.stems-open.just-ready { animation: ready-pulse 1.1s ease-out 2; border-radius: 8px; }
@keyframes ready-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  60% { box-shadow: 0 0 0 7px var(--accent-soft); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
/* A change that is on its way: the music plays on, and the number says it
   has been heard. */
.vocals.pending output, .stem-row.pending .stem-value { animation: key-wait 1s ease-in-out infinite; color: var(--accent-2); }

/* ------------------------------------------------------------ stem mixer */
/* A sheet over the bottom of the player rather than a page of its own: the
   chord and the lane stay in view while the parts are balanced. */
.stems-sheet {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 16px));
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 62;
  border-radius: 22px;
  padding: 14px 14px 12px;
  animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up {
  from { opacity: 0; transform: translate(-50%, 18px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.stems-head { display: flex; align-items: center; gap: 10px; margin: 0 4px 6px; }
.stems-head h2 { font-size: 17px; font-weight: 700; flex: none; line-height: 1.15; }
.stems-title { display: grid; flex: none; }
.stems-time { font: 600 11px var(--mono); color: var(--muted); }
.stems-play {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--grad);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.stems-play .ico { width: 17px; height: 17px; }
.stems-play:active { transform: scale(0.94); }
.stems-status {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stems-work { display: grid; gap: 6px; margin: 2px 4px 10px; }
.stems-work-bar {
  position: relative;
  height: 6px;
  border-radius: 6px;
  background: var(--panel-3);
  overflow: hidden;
}
.stems-work-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 45%,
                              var(--accent) 55%, var(--accent-2) 100%);
  background-size: 220% 100%;
  animation: sheen 1.6s linear infinite;
  transition: width 0.5s ease;
}
/* Where the song is playing, against how far it has been split. */
.stems-work-bar b {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--text);
  opacity: 0.8;
  transition: left 0.25s linear;
}
.stems-work-text {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}
.stems-work-text span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stems-work-text span:first-child { color: var(--text); font-weight: 560; }
.stems-list { display: grid; gap: 2px; }
.stem-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 40px 32px 32px 30px;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 4px;
  border-radius: 12px;
  transition: opacity 0.2s;
}
.stem-row.dimmed { opacity: 0.45; }
.stems-sheet[data-ready="false"] .stem-row,
.stems-sheet[data-ready="off"] .stem-row { opacity: 0.55; }
.stems-sheet[data-ready="false"] .stem-level { animation: key-wait 1.8s ease-in-out infinite; }
.stem-name { font-weight: 600; font-size: 14px; min-width: 0; }
.stem-level { width: 100%; min-width: 0; accent-color: var(--accent); }
.stem-value { font: 600 11px var(--mono); color: var(--muted); text-align: right; }
.stem-toggle {
  width: 32px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--muted);
  font: 700 12px var(--sans);
  transition: background 0.15s, color 0.15s;
}
.stem-toggle:hover { color: var(--text); }
.stem-toggle[data-act="mute"][aria-pressed="true"] {
  background: var(--mute-on);
  border-color: transparent;
  color: var(--mute-ink);
}
.stem-toggle[data-act="solo"][aria-pressed="true"] {
  background: var(--solo-on);
  border-color: transparent;
  color: var(--solo-ink);
}
.stems-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 4px 0;
  border-top: 1px solid var(--line);
}
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line-2); }
.menu-list button:disabled { opacity: 0.38; cursor: default; background: none; }

/* chord sheet */
.sheet {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}
.sheet-head { display: flex; align-items: center; gap: 18px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 640; flex: none; }
.legend { display: flex; gap: 6px; overflow-x: auto; min-width: 0; scrollbar-width: thin; padding-bottom: 2px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: hsl(var(--h) var(--s) var(--l) / 0.08);
  white-space: nowrap;
  flex: none;
}
.legend-item:hover { background: hsl(var(--h) var(--s) var(--l) / 0.18); }
.legend-item .diag { width: 30px; }
.legend-item .diag-empty { width: 30px; height: 36px; font-size: 9px; border-radius: 6px; }
.legend-item b { font-weight: 700; color: hsl(var(--h) var(--s) calc(var(--l) + var(--ink-c))); }
.legend-item small { color: var(--faint); font: 11px var(--mono); }

.sheet-body { overflow: auto; padding: 10px 16px 16px; min-height: 0; scroll-behavior: smooth; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px 8px 14px;
  border-left: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
}
.cell:nth-child(4n + 1) { border-left-width: 2px; }
.cell:hover { background: var(--tint-1); }
.cell .num { position: absolute; top: 4px; left: 6px; font: 600 9px var(--mono); color: var(--faint); }
.cell .chords { display: flex; flex-wrap: wrap; gap: 2px 12px; padding-top: 6px; }
.cell .chords b { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: hsl(var(--h) var(--s) calc(var(--l) + var(--ink-c))); }
.cell .chords em { font-style: normal; color: var(--faint); font-size: 15px; }
.cell .fill { position: absolute; inset: auto 0 0 0; height: 2px; width: 0; background: var(--accent-2); }
.cell.active { background: var(--accent-wash); }

/* ------------------------------------------------------ drawer & dialogs */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 60; backdrop-filter: blur(2px); }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 100%);
  z-index: 61;
  display: flex;
  flex-direction: column;
  border-width: 0 0 0 1px;
  animation: slide 0.22s ease-out;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.drawer-head h2 { font-size: 17px; font-weight: 700; }
.drawer-body { flex: 1; overflow: auto; padding: 6px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.field output { font: 12px var(--mono); color: var(--accent-2); }
.field small { color: var(--faint); font-size: 12px; }
/* flex: none -- the rule it shares with the link input says flex: 1, which in
   this column collapsed every select to 20px tall. */
.field select { flex: none; font-family: var(--sans); font-size: 14px; }
.field input[type="range"] { accent-color: var(--accent-2); }
.field.check > span { align-items: center; }
.field.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent-2); }
.segmented button:disabled { opacity: 0.4; }

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--scrim); padding: 20px; }
.modal-card { width: min(460px, 100%); border-radius: 22px; padding-bottom: 18px; }
.modal-card > p { margin: 10px 20px 0; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 4px 20px 0; align-items: center; }
.keys dt { text-align: right; white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  background: var(--panel-3);
  font: 600 11px var(--mono);
  text-align: center;
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(560px, calc(100% - 40px));
  padding: 11px 16px;
  border-radius: 14px;
  font-size: 13px;
}
.toast.error { border-color: var(--danger-edge); color: var(--danger-text); }

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--popover);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.dropzone > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 90px;
  border-radius: 28px;
  border: 2px dashed var(--accent-2);
  font-size: 22px;
  font-weight: 700;
}
.dropzone .ico { width: 44px; height: 44px; color: var(--accent-2); }

/* ---------------------------------------------------------------- offline */
.offline {
  display: grid;
  place-items: center;
  padding: 24px;
}
.offline-card {
  max-width: 460px;
  padding: 40px 34px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}
.offline-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--muted);
}
.offline-mark .ico { width: 30px; height: 30px; }
.offline h2 { margin: 0 0 12px; font-size: 24px; letter-spacing: -0.01em; }
.offline-lead { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.offline-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.offline-checked { color: var(--muted); font-size: 12.5px; }
.offline-note { margin-top: 18px; color: var(--muted); font-size: 12px; opacity: .8; }

/* ------------------------------------------------------------- link input */
.link-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  padding: 6px 6px 6px 14px;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.link-row:focus-within {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-2) 18%, transparent);
}
.link-icon { display: flex; color: var(--muted); }
.link-icon .ico { width: 20px; height: 20px; }
.link-row input {
  min-width: 0;
  padding: 12px 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
}
.link-row input::placeholder { color: var(--muted); }
.link-note {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12.5px;
}


/* ------------------------------------------------------------------- the door */
.gate {
  display: grid;
  place-items: center;
  padding: 32px 18px;
  overflow: auto;
}

.gate-card {
  width: min(390px, 100%);
  min-width: 0;
  text-align: center;
  border-radius: 28px;
  padding: 40px 28px 32px;
}

.gate-mark { width: 60px; height: 60px; margin-bottom: 4px; }

.gate-title {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.3px;
  margin: 10px 0 4px;
}
.gate-title b { color: var(--accent-2); font-weight: 600; }

/* What the name stands for. Small and quiet: it is there for the person who
   wonders, not a headline. */
.gate-expand {
  margin: 2px 0 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.gate-lead {
  margin: 0 0 26px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
}

.gate-sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.gate-status {
  margin-top: 16px;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.gate-status[data-kind="ok"] { border-color: var(--ok-edge); }
.gate-status[data-kind="warn"] { border-color: var(--danger-edge); color: var(--danger-text); }

.gate-form { display: grid; gap: 10px; text-align: left; }
.gate-form input {
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border-radius: 16px;
  background: var(--field);
  border: 1px solid var(--field-edge);
  box-shadow: var(--field-inset);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.gate-form input::placeholder { color: var(--faint); }
.gate-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.gate-form .btn {
  height: 52px;
  justify-content: center;
  margin-top: 4px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 500;
}

/* ------------------------------------------------------------------ approvals */
.admin { padding: 26px 18px; overflow: auto; }

.admin-card {
  width: min(620px, 100%);
  min-width: 0;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.admin-head h2 { font-size: 17px; font-weight: 600; min-width: 0; }

.admin-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--faint);
}
.admin-sub .count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--muted);
  text-align: center;
  letter-spacing: 0;
}

.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.admin-list li.empty {
  justify-content: flex-start;
  color: var(--faint);
  background: none;
  border-style: dashed;
}
.admin-list .who { min-width: 0; display: grid; gap: 1px; }
.admin-list .who b { font-weight: 550; overflow-wrap: anywhere; }
.admin-list .who span { font-size: 12px; color: var(--muted); }
.admin-list .who .when { color: var(--faint); font-size: 11.5px; }
.admin-list .acts { display: flex; gap: 6px; flex: none; }
.admin-list .acts .btn { padding: 7px 11px; font-size: 12.5px; }

/* "you" or "only owner" where a Remove button would be, so the row still
   lines up with the ones that have one. */
.who-note {
  padding: 7px 11px;
  font-size: 12.5px;
  color: var(--faint);
  white-space: nowrap;
}

.admin-note { margin: 9px 2px 0; font-size: 12px; color: var(--faint); }

.admin-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.admin-add input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line-2);
  outline: none;
}
.admin-add input:focus { border-color: var(--accent); }

/* A count of people waiting, on the topbar button that leads to them. */
.icon-btn { position: relative; }
.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  line-height: 15px;
  text-align: center;
}

.more-tools { display: none; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .now { grid-template-columns: 150px minmax(0, 1fr) 200px; gap: 20px; }
  .diag.large { width: 132px; }
  .controls { grid-template-columns: auto 1fr; }
  .controls .time { grid-row: 1; }
  .controls .buttons { grid-row: 1; justify-self: end; }
  .controls .tools { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 860px), (max-height: 740px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; min-height: 100dvh; }
  .player { grid-template-rows: auto 116px auto auto; }
  .sheet-body { max-height: 60vh; }
  .start { grid-template-columns: 1fr; padding: 24px 18px; }
}

@media (max-width: 860px) {
  .link-row { margin-top: 18px; }
  .link-row .btn span { display: inline; }
  /* Squeezed onto one line the song title leaves no room for its own details,
     so the header becomes two rows: controls, then the track. */
  .app { grid-template-rows: auto minmax(0, 1fr); }
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 10px; row-gap: 2px; }
  .track { order: 3; flex: 1 0 100%; padding-left: 0; border-left: 0; }
  .track-meta { font-size: 11.5px; gap: 2px 10px; }
  .brand-name, .brand-expand, .btn span { display: none; }
  /* ...except where the label is the only thing telling you what it does. */
  .admin-head .btn span, .stems-foot .btn span { display: inline; }
  .track { padding-left: 10px; }
  .now { grid-template-columns: 1fr; text-align: center; padding: 18px; }
  .now-diagram { order: 2; min-height: 0; }
  .now-sub, .now-sure, .now-kicker { justify-content: center; }
  .now-next { order: 3; }
  .sheet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cell:nth-child(4n + 1) { border-left-width: 1px; }
  .cell:nth-child(2n + 1) { border-left-width: 2px; }
  .player { padding: 12px; }
}

/* A phone is held at arm's length, one-handed, usually while holding an
   instrument in the other. What earns its place on that screen is the chord you
   are on, the one coming, and the transport. Everything else -- the chord
   sheet, the fingering of the next chord, a volume slider the phone already has
   hardware buttons for -- is either folded away behind Tools or simply gone.
   Nothing is removed from the desktop layout by any of this. */
@media (max-width: 720px) {
  /* The sheet is a reference table; on a phone it is a wall of small type that
     pushes the player off the screen. */
  .sheet { display: none; }
  /* The lane's floor is set on its row, not on the lane: a floor on the lane
     let it spill out of a row squeezed smaller, under the transport. On the
     row, a screen too short for everything makes the player scroll instead. */
  .player { grid-template-rows: auto minmax(96px, 1fr) auto; }

  /* The lane already shows what is coming, with more of it. */
  .now-next { display: none; }
  .lane-zoom { display: none; }
  /* Its floor is on its grid row (above), where it cannot spill. */
  .lane { min-height: 0; }

  /* "Changing key to F♯ minor, slowing to 0.75×" is wider than a phone. */
  .swap-card { max-width: calc(100% - 24px); white-space: normal; text-align: center; }
  #swappingLabel { min-width: 0; }

  /* Hardware buttons do this better, and it is one slider too many. */
  .volume { display: none; }

  /* iOS zooms the whole page in on any text field smaller than 16px the
     moment it is focused, and does not zoom back out. */
  input:not([type="range"]), select, textarea { font-size: 16px; }

  /* Chord and fingering side by side rather than stacked: a guitar diagram
     is taller than it is wide, and stacked under the chord it took half the
     screen and squeezed the lane to a sliver. Side by side the card is about
     half the height. The diagram takes what width the phone's height allows,
     so a short phone gives up a little of it rather than the lane. */
  .now {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    text-align: left;
    padding: 12px 14px;
    gap: 12px;
  }
  .now-main { order: 1; }
  .now-diagram { order: 2; width: clamp(84px, calc(100dvh - 560px), 118px); min-height: 0; margin: 0; }
  /* The diagrams have fixed widths for the desktop; here they fill the box. */
  .now-diagram .diag.large, .now-diagram .diag.large.piano { width: 100%; }
  .now-sub, .now-sure, .now-kicker { justify-content: flex-start; }
  .now-chord { font-size: clamp(42px, 14vw, 68px); line-height: 1.05; }

  /* The player is one screen, not a page: chord, lane and transport all in
     view at once, nothing to scroll to. If Tools makes it taller than the
     screen after all, the player scrolls inside itself rather than the page
     sliding out from under the header. */
  .app[data-view="player"] { height: 100vh; height: 100dvh; min-height: 0; }
  .player { gap: 10px; padding: 10px 12px; overflow-y: auto; overscroll-behavior: contain; }

  /* One row: elapsed time, transport, and the way to the rest. Then vocals
     across the full width. Everything else is behind Tools. Each of these is
     placed explicitly because the Tools button is itself a grid child, and
     left to flow it would push the transport off the right edge at 375px. */
  .controls {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px 8px;
  }
  .controls .time { grid-column: 1; grid-row: 1; justify-self: start; }
  .controls .buttons { grid-column: 2; grid-row: 1; justify-self: center; gap: 8px; }
  .more-tools { grid-column: 3; grid-row: 1; justify-self: end; display: inline-flex; }
  .controls .tools {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
  }

  /* The lane scrubs by touch and is right above these, so stepping chord by
     chord does not also need two of the five buttons under the thumb. */
  #btnPrevChord, #btnNextChord { display: none; }
  .play { width: 54px; height: 54px; }
  .icon-btn { width: 40px; height: 40px; }

  /* Vocals is the reason most people are here: it never folds away. Its
     slider takes whatever width the row has left. */
  .vocals { flex: 1 0 100%; min-width: 0; }
  .vocals-slider { flex: 1; min-width: 0; }
  .vocals-slider input { width: 100%; }
  .stem-row { grid-template-columns: 52px minmax(0, 1fr) 34px 30px 30px 28px; gap: 6px; }
  .app:not([data-tools="open"]) .tools > *:not(.vocals) { display: none; }

  .topbar { padding: 7px 10px; gap: 6px; }
  .track-meta { display: none; }
  /* A list of keyboard shortcuts is no use on a phone. */
  #btnHelp { display: none; }
  .gate-card { padding: 26px 18px 20px; }
  .admin-card { padding: 16px 14px; }
  .admin-list li { flex-wrap: wrap; }
  .admin-list .acts { width: 100%; }
  .admin-list .acts .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* Standing still, the ring's moving arc would read as progress that is not
     there; its fill alone says how far the split has got. */
  .stems-ring::after { display: none; }
}

/* Storage, in the owner's panel: a row per kind of cached file. */
.cache-list li { padding: 8px 12px; }
.cache-list .who b { font-weight: 500; }
.cache-list .size { color: var(--muted); font-variant-numeric: tabular-nums; }
.cache-list .btn { padding: 6px 10px; font-size: 12.5px; }

/* The mark: an open ring with a dot in its gap. currentColor, so it takes the
   accent in the top bar and on the sign-in card without a second asset. */
.brand-mark, .gate-mark { color: var(--accent); }

/* The sign-in screen hides the top bar, which would otherwise leave the card
   sitting in the row the bar was occupying. One row, so it centres. */
.app[data-view="gate"] { grid-template-rows: minmax(0, 1fr); }

/* Between phone and desktop the expansion is the first thing to go: the song
   title beside it matters more than the motto. */
@media (max-width: 1100px) and (min-width: 861px) {
  .brand-expand { display: none; }
}
