/*
 * Stage Console: the mix builder (index.html).
 *
 * Every colour comes from the tokens below, so a group-inspired theme only has
 * to redefine --accent* (never logos or official art). Dark is the default;
 * Light is [data-theme="light"] on <html>, set before paint by index.html.
 *
 * PINK (--accent) = cutting and creating: scissors, the cut range, Generate.
 * CYAN (--cyan) = listening: the playhead, Preview.
 */

/* ===== Tokens ===== */
:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: #15171d;
  --raised: #1c1f27;
  --inset: #0f1116;
  --line: #2a2e38;
  --line2: #22252e;
  --lineStrong: #6b7385; /* field and stepper borders: 3:1 against the panels */
  --text: #eef0f4;
  --muted: #9aa3b2;
  --accent: #ff3d8b;
  --accentText: #0b0c10; /* text on --accent */
  --accentInk: #ff7ab0; /* pink text on panels */
  --accentSoft: #221a26;
  --accentLine: #5a2440;
  --popBg: #3a1a2a;
  --cyan: #2de2e6;
  --cyanText: #0b0c10; /* text on --cyan */
  --cyanInk: #2de2e6; /* cyan text on any surface */
  --ok: #4ade80;
  --heat: #5c6577;
  --focus: #2de2e6;
  --warnBg: #2a2210;
  --warnLine: #6b5418;
  --warnText: #fcd77a;
  --errBg: #2a1416;
  --errLine: #6b2a30;
  --errText: #ff8a8a;
  --footerBg: #07080b;
  --footerLine: #1a1d24;
  --footerText: #7d8594; /* body text: ~5:1, quieter than --muted */
  --footerHead: #b3b9c4; /* headings: softer than --text */
  --overlay: rgba(5, 6, 10, 0.7);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --glow: 0 0 24px rgba(255, 61, 139, 0.35);
  --glowSm: 0 0 6px rgba(255, 61, 139, 0.8);
  --glowCyan: 0 0 8px #2de2e6;

  --sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --topbar-h: 56px;
  --statusbar-h: 30px;
  --radius: 10px;
  --radius-sm: 6px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #eef0f4;
  --panel: #ffffff;
  --raised: #f1f3f7;
  --inset: #f7f8fa;
  --line: #d9dde5;
  --line2: #e6e9ef;
  --lineStrong: #868e9c;
  --text: #14161c;
  --muted: #5b6472;
  --accent: #e0136b;
  --accentText: #ffffff;
  --accentInk: #c2185b;
  --accentSoft: #fde7f0;
  --accentLine: #f5a3c4;
  --popBg: #fde7f0;
  --cyan: #0b7c82;
  --cyanText: #ffffff;
  --cyanInk: #0a7278;
  --ok: #15803d;
  --heat: #8a93a3;
  --focus: #0a7278;
  --warnBg: #fef3c7;
  --warnLine: #d9a520;
  --warnText: #7a4d00;
  --errBg: #fdecec;
  --errLine: #e8a0a0;
  --errText: #b42318;
  --footerBg: #e2e5eb;
  --footerLine: #d0d5de;
  --footerText: #565f6d;
  --footerHead: #3a404b;
  --overlay: rgba(20, 22, 28, 0.45);
  --shadow: 0 12px 32px rgba(20, 22, 28, 0.18);
  --glow: none;
  --glowSm: none;
  --glowCyan: none;
}

/*
 * Album themes: fan-made colours from one album cover each (no logos or
 * official art). The list lives in public/app/studio/themes.js. --accent is
 * still "cut / create" and --cyan "listen", whatever their colour here.
 */

/* ARIRANG (BTS): monochrome suits and a red seal. Listen = steel blue. */
:root[data-theme='arirang'] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #161618;
  --raised: #1f1f22;
  --inset: #0f0f10;
  --line: #2c2c30;
  --line2: #232326;
  --lineStrong: #74747c;
  --text: #f2f2f3;
  --muted: #a4a4ab;
  --accent: #d81539;
  --accentText: #ffffff;
  --accentInk: #ff5470;
  --accentSoft: #24131a;
  --accentLine: #5c1a28;
  --popBg: #3a1420;
  --cyan: #a9bfdc;
  --cyanText: #0a0a0b;
  --cyanInk: #a9bfdc;
  --ok: #4ade80;
  --heat: #6a6a72;
  --focus: #a9bfdc;
  --warnBg: #2a2210;
  --warnLine: #6b5418;
  --warnText: #fcd77a;
  --errBg: #2a1416;
  --errLine: #6b2a30;
  --errText: #ff8a8a;
  --footerBg: #060607;
  --footerLine: #1b1b1e;
  --footerText: #85858d;
  --footerHead: #b8b8be;
  --overlay: rgba(4, 4, 5, 0.72);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --glow: 0 0 24px rgba(216, 21, 57, 0.35);
  --glowSm: 0 0 6px rgba(216, 21, 57, 0.8);
  --glowCyan: 0 0 8px #a9bfdc;
}

/* It's Me (ILLIT): blue-hour haze and white veils. Light. Listen = dusk rose. */
:root[data-theme='itsme'] {
  color-scheme: light;
  --bg: #e2e8f4;
  --panel: #f8faff;
  --raised: #ecf0f9;
  --inset: #f3f6fc;
  --line: #cfd8e8;
  --line2: #dee5f1;
  --lineStrong: #7b88a2;
  --text: #131a2b;
  --muted: #4f5c76;
  --accent: #4460b8;
  --accentText: #ffffff;
  --accentInk: #3550a6;
  --accentSoft: #e3e9f9;
  --accentLine: #a8b7e5;
  --popBg: #e3e9f9;
  --cyan: #b0306a;
  --cyanText: #ffffff;
  --cyanInk: #b0306a;
  --ok: #15803d;
  --heat: #7d8aa4;
  --focus: #b0306a;
  --warnBg: #fef3c7;
  --warnLine: #d9a520;
  --warnText: #7a4d00;
  --errBg: #fdecec;
  --errLine: #e8a0a0;
  --errText: #b42318;
  --footerBg: #d5ddec;
  --footerLine: #c5cfe2;
  --footerText: #4c586f;
  --footerHead: #2c3548;
  --overlay: rgba(19, 26, 43, 0.45);
  --shadow: 0 12px 32px rgba(19, 26, 43, 0.18);
  --glow: none;
  --glowSm: none;
  --glowCyan: none;
}

/* THIS & THAT (Stray Kids): black and burnt orange. Listen = mint (the Y2K
   concept photos); --ok goes lime so "saved" never reads as mint. */
:root[data-theme='thisthat'] {
  color-scheme: dark;
  --bg: #0c0a09;
  --panel: #181412;
  --raised: #211b18;
  --inset: #110e0c;
  --line: #322a26;
  --line2: #27201d;
  --lineStrong: #7a6a61;
  --text: #f6f0ea;
  --muted: #b0a196;
  --accent: #f2581f;
  --accentText: #0c0a09;
  --accentInk: #ff8b5e;
  --accentSoft: #26170f;
  --accentLine: #602b16;
  --popBg: #3b1d10;
  --cyan: #8fe3c8;
  --cyanText: #0c0a09;
  --cyanInk: #8fe3c8;
  --ok: #a3e635;
  --heat: #7a6a61;
  --focus: #8fe3c8;
  --warnBg: #2a2210;
  --warnLine: #6b5418;
  --warnText: #fcd77a;
  --errBg: #2a1416;
  --errLine: #6b2a30;
  --errText: #ff8a8a;
  --footerBg: #070605;
  --footerLine: #1e1916;
  --footerText: #8a7c72;
  --footerHead: #c2b5aa;
  --overlay: rgba(8, 6, 5, 0.72);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --glow: 0 0 24px rgba(242, 88, 31, 0.35);
  --glowSm: 0 0 6px rgba(242, 88, 31, 0.8);
  --glowCyan: 0 0 8px #8fe3c8;
}

/* LEMONADE (aespa): neon lime on black. Listen = water aqua; warnings go
   amber so they don't blend into the lime. */
:root[data-theme='lemonade'] {
  color-scheme: dark;
  --bg: #080a05;
  --panel: #12160c;
  --raised: #1a1f12;
  --inset: #0d1009;
  --line: #28301e;
  --line2: #20271a;
  --lineStrong: #6e7a60;
  --text: #f3f7e6;
  --muted: #a5af93;
  --accent: #d7f30f;
  --accentText: #0b0d06;
  --accentInk: #dff54a;
  --accentSoft: #1a2008;
  --accentLine: #4a5812;
  --popBg: #222a0a;
  --cyan: #7fe6dc;
  --cyanText: #0b0d06;
  --cyanInk: #7fe6dc;
  --ok: #4ade80;
  --heat: #64735a;
  --focus: #7fe6dc;
  --warnBg: #2a1d0c;
  --warnLine: #6b4a18;
  --warnText: #ffb454;
  --errBg: #2a1416;
  --errLine: #6b2a30;
  --errText: #ff8a8a;
  --footerBg: #050603;
  --footerLine: #191e12;
  --footerText: #848d75;
  --footerHead: #bcc4ab;
  --overlay: rgba(4, 5, 2, 0.72);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --glow: 0 0 24px rgba(215, 243, 15, 0.3);
  --glowSm: 0 0 6px rgba(215, 243, 15, 0.7);
  --glowCyan: 0 0 8px #7fe6dc;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

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

[hidden] {
  display: none !important;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--raised);
  border: 1px solid var(--lineStrong);
  text-decoration: none;
  font-weight: 700;
}

.skip-link:focus {
  top: 8px;
}

/* Theme switch: a short crossfade, only while switching. */
html.theme-fade,
html.theme-fade *,
html.theme-fade *::before,
html.theme-fade *::after {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, fill 0.2s ease !important;
}

/* ===== Buttons ===== */
.btn {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--lineStrong);
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn svg {
  flex: none;
}

.btn-primary {
  border: 0;
  background: var(--accent);
  color: var(--accentText);
  font-weight: 700;
  box-shadow: var(--glow);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-outline {
  background: transparent;
  border-color: var(--accent);
  color: var(--accentInk);
  font-weight: 700;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-quiet {
  background: transparent;
}

.link-btn {
  background: transparent;
  border: 0;
  padding: 4px 2px;
  color: var(--accentInk);
  text-decoration: underline;
  font-size: 12px;
}

/* ===== Top bar ===== */
.topbar {
  position: relative;
  z-index: 20;
  min-height: var(--topbar-h);
  padding: 8px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-left {
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  flex: none;
}

.brand h1 {
  margin: 0;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.badge-studio {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyanText);
  background: var(--cyan);
  padding: 3px 6px;
  border-radius: 4px;
}

.mainnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mainnav a {
  white-space: nowrap;
  text-decoration: none;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}

.mainnav a:hover {
  color: var(--text);
}

.mainnav a[aria-current='page'] {
  color: var(--text);
  font-weight: 700;
  background: var(--raised);
}

.draft-state {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ok);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  white-space: nowrap;
}

.draft-state .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.draft-state[data-state='off'] {
  color: var(--warnText);
}

.draft-state.pulse .dot {
  animation: pulse 0.3s ease-out;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 var(--ok);
  }
  100% {
    box-shadow: 0 0 0 7px transparent;
  }
}

/* ===== Menus (disclosure: a button with aria-expanded and a panel) ===== */
.menu-wrap {
  position: relative;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: 250px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: pop-in 0.14s ease-out both;
  transform-origin: top right;
}

.menu-item {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-decoration: none;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--raised);
}

.menu-item[aria-disabled='true'] {
  color: var(--muted);
  cursor: default;
}

.menu-item[aria-disabled='true']:hover {
  background: transparent;
}

.menu-item .check {
  color: var(--accentInk);
  font-weight: 700;
  visibility: hidden;
}

.menu-item[aria-pressed='true'] .check {
  visibility: visible;
}

.menu-sep {
  height: 1px;
  background: var(--line2);
  margin: 4px 0;
}

.menu-note {
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.menu-label {
  margin: 0;
  padding: 6px 10px 2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.theme-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
}

/* The theme's name can be long ("THIS & THAT"): never let it stretch the topbar. */
#themeName {
  display: inline-block;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* A theme in miniature: its background with the cut and listen colours.
   Fixed colours, so every option looks the same whatever theme is on. */
.theme-pill {
  flex: none;
  width: 28px;
  height: 16px;
  border-radius: 8px;
  border: 1px solid var(--pill-line);
  background: var(--pill-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.theme-pill::before,
.theme-pill::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pill-a);
}

.theme-pill::after {
  background: var(--pill-b);
}

.theme-pill[data-pill='dark'] { --pill-bg: #0b0c10; --pill-line: #6b7385; --pill-a: #ff3d8b; --pill-b: #2de2e6; }
.theme-pill[data-pill='light'] { --pill-bg: #eef0f4; --pill-line: #868e9c; --pill-a: #e0136b; --pill-b: #0b7c82; }
.theme-pill[data-pill='arirang'] { --pill-bg: #0a0a0b; --pill-line: #74747c; --pill-a: #d81539; --pill-b: #a9bfdc; }
.theme-pill[data-pill='itsme'] { --pill-bg: #e2e8f4; --pill-line: #7b88a2; --pill-a: #4460b8; --pill-b: #b0306a; }
.theme-pill[data-pill='thisthat'] { --pill-bg: #0c0a09; --pill-line: #7a6a61; --pill-a: #f2581f; --pill-b: #8fe3c8; }
.theme-pill[data-pill='lemonade'] { --pill-bg: #080a05; --pill-line: #6e7a60; --pill-a: #d7f30f; --pill-b: #7fe6dc; }

.theme-opt {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.theme-opt small {
  color: var(--muted);
  font-size: 11px;
}

/* Phone menu sheet: the album themes as a 2×2 grid of chips. */
.theme-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-chip {
  position: relative;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--inset);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  align-items: center;
  text-align: left;
}

.theme-chip b {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-chip small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
}

.theme-chip[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* The check sits in the corner so a long name's ellipsis never hides it. */
.theme-chip[aria-pressed='true']::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accentInk);
}

.theme-chip b {
  padding-right: 12px;
}

/* Dark / Light in the phone menu sheet carry the same swatch. */
.seg .theme-pill {
  margin-right: 6px;
  vertical-align: -3px;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== App: three columns ===== */
.app {
  max-width: 1760px;
  margin: 0 auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: minmax(200px, 15fr) minmax(270px, 25fr) minmax(420px, 60fr);
  gap: 12px;
  height: calc(100vh - var(--topbar-h) - var(--statusbar-h));
  height: calc(100dvh - var(--topbar-h) - var(--statusbar-h));
  min-height: 620px;
}

.panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  height: 40px;
  flex: none;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--glowSm);
  flex: none;
}

.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-foot {
  flex: none;
  border-top: 1px solid var(--line2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Songs panel ===== */
.tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.tab {
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tab[aria-selected='true'] {
  background: var(--raised);
  color: var(--text);
}

.tab:disabled {
  opacity: 0.6;
}

.pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.search-row {
  display: flex;
  gap: 6px;
  margin: 0;
}

.search-row .field {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  font-size: 13px;
}

.btn.square {
  width: 36px;
  height: 36px;
  padding: 0;
  flex: none;
}

.hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

/* Toggle with equal-width options (theme, countdown, fade-out). */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--inset);
}

.seg button {
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--raised);
  color: var(--text);
}

/* Desktop: the mix options sit in the setlist footer instead. */
.mix-rows {
  display: none;
}

/* ===== Setlist footer ===== */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tile {
  display: flex;
  flex-direction: column;
  background: var(--inset);
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-width: 0;
}

.tile-k {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* Countdown and fade-out: label on the left, toggle on the right. Both
   toggles share one column so their edges line up. */
.mix-options {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
}

.mix-option {
  display: contents;
}

.mix-options .seg {
  padding: 1px;
}

.mix-options .seg button,
.mix-rows .seg button {
  font-family: var(--mono);
  font-size: 13px;
}

.mix-options .seg button {
  height: 28px;
}

.mix-options .seg button[aria-pressed='true'],
.mix-rows .seg button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accentText);
}

.tile-v {
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
}

.generate-btn {
  width: 100%;
  height: 52px;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: var(--accentText);
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--glow);
}

.generate-btn:disabled {
  border: 1px dashed var(--lineStrong);
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.generate-why {
  margin: -4px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ===== Search results and Top 10 ===== */
.result-count {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line2);
  min-width: 0;
}

.result-thumb {
  width: 48px;
  aspect-ratio: 16 / 9;
  flex: none;
  border-radius: 4px;
  object-fit: cover;
  background: var(--raised);
}

.result-text {
  flex: 1 1 auto;
  min-width: 0;
}

.result-title {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank {
  width: 20px;
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.rank.is-top {
  color: var(--accentInk);
}

.add-btn {
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accentInk);
  font-weight: 700;
  font-size: 15px;
}

.add-btn:hover {
  background: var(--accentSoft);
}

.add-btn.pop {
  animation: pop-added 0.18s ease-out both;
}

@keyframes pop-added {
  from {
    transform: scale(0.8);
    opacity: 0.4;
  }
}

/* Already in the setlist: quiet, still clickable to add a second copy. */
.add-btn.is-added {
  border-color: var(--line);
  color: var(--ok);
}

.result.skeleton {
  border-top-color: transparent;
}

.shimmer {
  width: 100%;
  height: 30px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--raised) 0%, var(--line) 50%, var(--raised) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

.result-msg {
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.result-msg p {
  margin: 0;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.show-more {
  flex: none;
  width: 100%;
}

#searchPane {
  flex: 1 1 auto;
}

/* ===== Setlist rows ===== */
.head-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-head .btn-small,
.btn-small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-warn {
  background: transparent;
  border-color: var(--warnText);
  color: var(--warnText);
  font-weight: 700;
}

.warnings {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.warnings:empty {
  display: none;
}

.warn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warnLine);
  background: var(--warnBg);
  color: var(--warnText);
  font-size: 12px;
}

.rows-wrap {
  position: relative;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.row-highlight {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  border-radius: var(--radius-sm);
  background: var(--accentSoft);
  border: 1px solid var(--accentLine);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.22s;
  pointer-events: none;
  z-index: 0;
}

.row {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.row-main {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 2px;
}

.row-pick {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  border-radius: 4px;
}

.row-num {
  width: 22px;
  flex: none;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.row.is-selected .row-num {
  color: var(--accentInk);
}

.row-thumb {
  width: 48px;
  aspect-ratio: 16 / 9;
  flex: none;
  border-radius: 4px;
  background: var(--raised) center / cover no-repeat;
}

.row.is-error .row-thumb {
  opacity: 0.4;
}

.row-text {
  flex: 1 1 auto;
  min-width: 0;
}

.row-title {
  display: block;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Desktop columns are narrow; next to a cover, a title gets two lines. */
@media (min-width: 900px) {
  .result-title,
  .row-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.25;
  }
}

.row-meta {
  display: block;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-btn {
  width: 26px;
  height: 26px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--raised);
  color: var(--text);
}

.row-btn:hover:not(:disabled) {
  background: var(--line);
}

.row-btn:disabled {
  opacity: 0.35;
}

.row-x {
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}

.row-done {
  color: var(--ok);
  font-weight: 700;
  font-size: 13px;
  padding: 0 4px;
}

.row.is-dup {
  background: var(--warnBg);
}

.row.is-dup .row-num,
.row.is-dup .row-meta {
  color: var(--warnText);
}

.row.is-error {
  background: var(--errBg);
  border-color: var(--errLine);
}

.row.is-error .row-num {
  color: var(--errText);
}

.row-error {
  /* lines up under the title, past the number and the cover */
  padding: 0 8px 8px 96px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row-error p {
  margin: 0;
  font-size: 12px;
  color: var(--errText);
}

.row-error-actions {
  display: flex;
  gap: 6px;
}

.row-error .btn {
  border-color: var(--errLine);
  background: transparent;
}

/* Desktops under 1600px: the columns are too narrow to spare room for covers. */
@media (min-width: 900px) and (max-width: 1599px) {
  .result-thumb,
  .row-thumb {
    display: none;
  }

  .row-error {
    padding-left: 38px;
  }
}

.row.row-in {
  animation: row-in 0.24s 0.2s ease-out both;
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
}

.row.flash {
  animation: row-flash 0.7s ease-out;
}

.row.flash-info {
  animation: row-flash-info 0.7s ease-out;
}

@keyframes row-flash-info {
  25% {
    box-shadow: 0 0 0 3px var(--accentLine);
  }
}

@keyframes row-flash {
  25% {
    box-shadow: 0 0 0 3px var(--errLine);
  }
}

.fly-chip {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--accentSoft);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--glowSm);
}

.generate-why.is-problem {
  color: var(--errText);
}

button.generate-why {
  border: 0;
  background: transparent;
  text-decoration: underline;
  width: 100%;
  padding: 4px;
}

/* ===== Editor ===== */
.ed-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ed-counter {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.btn.square-sm {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 15px;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 4px 4px;
}

.ed-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  font-size: 22px;
  font-weight: 700;
}

.ed-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ed-group {
  flex: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.ed-title.swap {
  animation: swap-in 0.22s ease-out;
}

@keyframes swap-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.video {
  position: relative;
  width: 100%;
  /* The controls below need about 540px of the window; the video gets the rest. */
  max-width: max(320px, calc((100vh - 560px) * 16 / 9));
  max-width: max(320px, calc((100dvh - 560px) * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  flex: none;
  border-radius: 8px;
  overflow: hidden;
  background: var(--inset);
  border: 1px solid var(--line);
}

.video iframe,
.video #ytHost {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.ph-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  pointer-events: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyanText);
  background: var(--cyan);
  padding: 3px 7px;
  border-radius: 4px;
}

.video-cover {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.video-cover.shimmer {
  height: auto;
  border-radius: 0;
  opacity: 0.8;
}

.video-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: var(--inset);
  color: var(--text);
  font-size: 14px;
}

.video-msg p {
  margin: 0;
  max-width: 44ch;
}

.video-hint {
  margin: -6px 0 0;
  text-align: center;
}

/* Short desktop windows need the room for the cut controls. */
@media (min-width: 900px) and (max-height: 799px) {
  .video-hint {
    display: none;
  }
}

.tl-block {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tl-head,
.tl-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.ph-label {
  color: var(--cyanInk);
}

.cut-len {
  color: var(--accentInk);
}

.timeline {
  position: relative;
  height: 56px;
  touch-action: none;
  cursor: pointer;
}

.heat {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  height: 26px;
}

.heat.is-empty {
  border-bottom: 1px dashed var(--line);
}

.heat.draw {
  animation: draw-in 0.3s ease-out;
}

@keyframes draw-in {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

.track,
.range {
  position: absolute;
  top: 34px;
  height: 8px;
  border-radius: 4px;
}

.track {
  left: 0;
  right: 0;
  background: var(--line);
}

.range {
  background: var(--accent);
  box-shadow: var(--glowSm);
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--cyan);
  box-shadow: var(--glowCyan);
  pointer-events: none;
}

.handle {
  position: absolute;
  top: 26px;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  touch-action: none;
}

.handle::before {
  content: "";
  width: 20px;
  height: 20px;
  box-sizing: border-box;
  border-radius: 4px;
  background: var(--panel);
  border: 3px solid var(--accent);
  box-shadow: var(--glowSm);
}

.handle.dragging::before,
.handle:hover::before {
  background: var(--accentSoft);
}

.handle.flashing::before {
  animation: handle-flash 0.3s ease-out;
}

@keyframes handle-flash {
  40% {
    transform: scale(1.4);
    box-shadow: 0 0 18px var(--accent);
  }
}

.cut-source {
  flex: none;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
}

.src-chip {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--raised);
  color: var(--text);
}

.src-chip.is-popular {
  background: var(--popBg);
  color: var(--accentInk);
}

.src-text {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.cut-source .link-btn {
  padding: 6px 2px;
}

.cuts {
  flex: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cut-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.stepper {
  display: flex;
  align-items: stretch;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--lineStrong);
  background: var(--inset);
  overflow: hidden;
}

.step {
  width: 44px;
  flex: none;
  padding: 0;
  border: 0;
  background: var(--raised);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.step:first-child {
  border-right: 1px solid var(--line);
}

.step:last-child {
  border-left: 1px solid var(--line);
}

.step:hover {
  background: var(--line);
}

.step-mid {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: text;
  overflow: hidden;
}

.step-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.step-input {
  width: 7ch;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}

.step-input:focus-visible {
  outline: none;
}

.stepper:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.step-input[aria-invalid='true'] {
  color: var(--errText);
}

.step-input.roll-up {
  animation: roll-up 0.18s ease-out;
}

.step-input.roll-down {
  animation: roll-down 0.18s ease-out;
}

@keyframes roll-up {
  from {
    transform: translateY(80%);
    opacity: 0;
  }
}

@keyframes roll-down {
  from {
    transform: translateY(-80%);
    opacity: 0;
  }
}

.snip {
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accentInk);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
}

.snip:hover {
  background: var(--accentSoft);
}

.snip-icon {
  flex: none;
}

.snip-icon.snipping {
  animation: snip 0.26s ease-out;
}

@keyframes snip {
  40% {
    transform: scale(1.25) rotate(-14deg);
  }
}

.listen {
  flex: none;
  display: flex;
  gap: 10px;
}

.listen-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.listen-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.listen-range {
  font-size: 11px;
}

.listen-preview {
  border: 0;
  background: var(--cyan);
  color: var(--cyanText);
}

.listen-ending {
  border: 1px solid var(--cyan);
  background: transparent;
  color: var(--cyanInk);
}

.listen-btn:hover {
  filter: brightness(1.06);
}

.cut-msg {
  margin: -4px 0 0;
  font-size: 12px;
  color: var(--errText);
}

.listen-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.why-link {
  font-size: 12px;
  color: var(--errText);
}

@media (max-width: 1199px) {
  .ed-title {
    font-size: 18px;
  }

  .snip {
    font-size: 12px;
    gap: 4px;
  }
}

/* ===== Generate: running, ready, failed ===== */
.gen-area:empty {
  display: none;
}

.gen-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gen-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line2);
  background: var(--inset);
  animation: fade-in 0.18s ease-out both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.gen-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.leds {
  display: flex;
  gap: 3px;
}

.led {
  flex: 1 1 0;
  height: 10px;
  border-radius: 2px;
  background: var(--line);
}

.led.is-done {
  background: var(--accent);
  box-shadow: var(--glowSm);
}

.led.is-working {
  background: var(--accent);
  animation: led 0.6s ease-in-out infinite;
}

@keyframes led {
  50% {
    opacity: 0.3;
  }
}

.gen-text,
.gen-note {
  margin: 0;
}

.gen-text {
  font-size: 12px;
}

.gen-note {
  font-size: 11px;
  color: var(--muted);
}

.row-done:not([hidden]) {
  animation: pop-check 0.25s ease-out both;
}

@keyframes pop-check {
  0% {
    transform: scale(0);
  }
  70% {
    transform: scale(1.3);
  }
}

.ready {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fade-in 0.18s ease-out both;
}

.ready-head {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ok);
}

.download-btn {
  height: 48px;
  border-radius: 8px;
  font-size: 15px;
}

.download-btn.sweep {
  position: relative;
  overflow: hidden;
}

.download-btn.sweep::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: sweep 0.6s 0.1s ease-out 1 forwards;
  pointer-events: none;
}

@keyframes sweep {
  to {
    transform: translateX(120%);
  }
}

.ready-setlist {
  height: 36px;
  border-radius: 8px;
}

.ready-skipped {
  font-size: 12px;
  color: var(--muted);
  background: var(--inset);
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.ready-skipped p,
.ready-skipped ul {
  margin: 0;
}

.ready-skipped ul {
  padding-left: 16px;
}

.ready-skipped strong {
  color: var(--text);
  font-weight: 500;
}

.ready-note {
  margin: 0;
  font-size: 12px;
  color: var(--warnText);
}

.ready-again {
  align-self: center;
}

.ready-kofi {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line2);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.ready-kofi a {
  color: var(--accentInk);
}

/* Shop link (kpop.exchange affiliate): US and Canada only, see app/shop-region.js.
 * Cyan, not pink: pink is for creating the mix. The whole row is the link. */
html:not([data-shop]) .aff {
  display: none !important;
}

.aff-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.ready-shop {
  min-height: 44px;
  padding: 8px 4px;
  border-top: 1px solid var(--line2);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
}

.ready-shop:hover {
  background: var(--inset);
}

.ready-shop u {
  color: var(--cyanInk);
  text-underline-offset: 2px;
}

.gen-failed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--errLine);
  background: var(--errBg);
}

.gen-failed p {
  margin: 0;
  font-size: 13px;
}

.gen-failed-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--errText);
}

@media (max-width: 899px) {
  .ready-setlist,
  .ready-again {
    min-height: 44px;
  }
}

/* ===== Empty states ===== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 2px;
}

.empty-title {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
}

.empty-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 46ch;
}

.empty-center {
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips a {
  text-decoration: none;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--inset);
}

.site-footer .chips a {
  color: var(--footerHead);
  border-color: var(--footerLine);
  background: transparent;
}

.chips a:hover {
  border-color: var(--accent);
}

.arrow-link {
  color: var(--accentInk);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.arrow-link:hover {
  text-decoration: underline;
}

/* ===== Status bar ===== */
.statusbar {
  height: var(--statusbar-h);
  padding: 0 20px;
  border-top: 1px solid var(--line2);
  border-bottom: 1px solid var(--line2);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.statusbar span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Footer ===== */
.site-footer {
  /* Full-width band; content stays within the 1760px layout. */
  padding: 28px max(20px, calc((100% - 1720px) / 2));
  background: var(--footerBg);
  border-top: 1px solid var(--footerLine);
  color: var(--footerText);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

/* The status bar above already draws the dividing line. */
.statusbar + .site-footer {
  border-top: 0;
}

.fcol {
  background: transparent;
  border: 1px solid var(--footerLine);
  border-radius: var(--radius);
  padding: 0 14px;
}

.fcol h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--footerHead);
}

.fcol .sub {
  display: block;
  font-size: 12px;
  color: var(--footerText);
  font-weight: 400;
}

.fcol-head {
  padding: 12px 0 8px;
}

.fcol details + details,
.fcol-head + details {
  border-top: 1px solid var(--footerLine);
}

.fcol summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--footerHead);
}

.fcol summary::-webkit-details-marker {
  display: none;
}

.fcol summary.big {
  padding: 12px 0;
  font-size: 15px;
}

.chev {
  flex: none;
  transition: transform 0.2s ease;
}

details[open] > summary .chev {
  transform: rotate(180deg);
}

details[open] > summary ~ * {
  animation: fade-down 0.22s ease-out;
}

@keyframes fade-down {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.fcol-body {
  padding: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--footerText);
  font-size: 13px;
  line-height: 1.6;
}

.fcol-body p,
.fcol-body ul,
.fcol-body ol {
  margin: 0;
}

.fcol-body ul,
.fcol-body ol {
  padding-left: 18px;
}

.fcol-body strong {
  color: var(--footerHead);
  font-weight: 500;
}

.fcol-support {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fcol-support .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.fcol-support .thanks {
  font-size: 11px;
  color: var(--footerText);
}

.fcol-support .foot-shop {
  margin: 0;
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 8px;
}

/* A 44px tap target, like the buttons above it. */
.fcol-support .foot-shop a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.fcol-support .foot-shop a {
  color: var(--footerHead);
}

.fcol-support .foot-shop .aff-label {
  color: var(--footerText);
}

.fcol-support .foot-disc {
  margin: 0;
  font-size: 11px;
  color: var(--footerText);
}

/* ===== Contact dialog ===== */
.dialog {
  width: 440px;
  max-width: calc(100% - 32px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.4);
}

.dialog[open] {
  animation: pop-in 0.16s ease-out both;
}

.dialog::backdrop {
  background: var(--overlay);
}

.dialog form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dialog h2 {
  margin: 0;
  font-size: 18px;
}

.dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--raised);
  color: var(--text);
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.field {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--lineStrong);
  border-radius: var(--radius-sm);
  background: var(--inset);
  color: var(--text);
}

/* Browser default placeholders are too faint in Light. */
.field::placeholder {
  color: var(--muted);
  opacity: 1;
}

textarea.field {
  padding: 8px 10px;
  resize: vertical;
}

.field:focus-visible {
  outline-offset: 0;
}

.honeypot {
  position: absolute;
  left: -9999px;
}

.form-status {
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.form-status.ok {
  background: var(--inset);
  color: var(--ok);
  border: 1px solid var(--line2);
}

.form-status.err {
  background: var(--errBg);
  color: var(--errText);
  border: 1px solid var(--errLine);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions .btn {
  height: 38px;
  padding: 0 16px;
}

/* ===== Toast ===== */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 32px);
}

/* Desktop: sit over the status bar so a toast never covers Preview cut or Generate. */
@media (min-width: 900px) {
  .toast-region {
    bottom: 4px;
  }
}

.toast {
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 8px 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out both;
}

.toast .btn {
  height: 30px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== Old browser notice ===== */
.unsupported {
  max-width: 560px;
  margin: 40px auto;
  padding: 16px;
  border: 1px solid var(--warnLine);
  background: var(--warnBg);
  color: var(--warnText);
  border-radius: var(--radius);
}

/* ===== Narrow screens (the full mobile layout comes later) ===== */
@media (min-width: 900px) {
  .topbar {
    flex-wrap: nowrap;
  }

  .topbar-left,
  .topbar-right {
    flex-wrap: nowrap;
  }
}

@media (max-width: 1099px) {
  .app {
    grid-template-columns: minmax(190px, 1fr) minmax(260px, 1.4fr) minmax(380px, 3fr);
  }
}

/* The full bar needs about 1115 px; below 1200 it gets the compact one. */
@media (max-width: 1199px) {
  /* Help has it too; the bar must not wrap. */
  .mainnav .nav-how {
    display: none;
  }

  .draft-state .long {
    display: none;
  }

  /* "NOT SAVED" always says so in full. */
  .draft-state[data-state='off'] .long {
    display: inline;
  }

  /* "THIS & THAT" would push the compact bar past the window. */
  #themeName {
    max-width: 6.5em;
  }

  /* Hidden from sight only: screen readers still hear "Theme: Dark". */
  .theme-prefix {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .topbar-left {
    gap: 12px;
  }

  .mainnav a {
    padding: 7px 8px;
  }
}

/* The compact bar still needs about 945 px; the badge goes first. */
@media (min-width: 900px) and (max-width: 999px) {
  .badge-studio {
    display: none;
  }
}

@media (max-width: 899px) {
  .topbar {
    padding: 8px 16px;
  }

  .mainnav .nav-how {
    display: inline;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    padding: 12px 16px;
  }

  .panel {
    max-height: none;
  }

  .site-footer {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .statusbar {
    padding: 0 16px;
  }
}

/* ===== Phones: bottom bar, views, sheets (below 900 px) ===== */
.cut-cap,
.bottom-bar,
.sheet,
.sheet-backdrop,
.sheet-grab,
.sheet-done,
.sheet-song-nav,
.menu-btn,
.mobile-only,
.add-label {
  display: none;
}

@media (max-width: 899px) {
  :root {
    --bar-h: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  body {
    padding-bottom: var(--bar-h);
  }

  /* Top bar: logo, saved state and ☰ only; the rest is in the menu sheet. */
  .topbar {
    min-height: 52px;
    padding: 4px 4px 4px 16px;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
  }

  .topbar-left {
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
  }

  .topbar-right {
    flex: none;
    flex-wrap: nowrap;
    gap: 2px;
  }

  .brand {
    min-width: 0;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand h1 {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .badge-studio,
  .mainnav,
  .topbar-right [data-menu],
  .topbar-right > .btn-outline {
    display: none !important;
  }

  .draft-state .long {
    display: none;
  }

  .menu-btn {
    display: inline-flex;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  /* One view at a time. */
  .app {
    display: block;
    padding: 12px 12px 16px;
  }

  .app[data-view='search'] #setlistPanel,
  .app[data-view='mix'] #songsPanel {
    display: none;
  }

  .app > .panel {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .app > .panel .panel-head {
    height: 48px;
    border-bottom: 0;
    padding: 0 4px;
  }

  .app > .panel .panel-body {
    overflow: visible;
    padding: 0 4px;
  }

  /* Tap targets: 44 px everywhere. */
  .tabs {
    min-height: 44px;
  }

  .tab {
    height: 44px;
    font-size: 14px;
  }

  .brand {
    min-height: 44px;
  }

  .search-row .field {
    min-height: 48px;
    font-size: 16px;
  }

  .btn.square {
    width: 48px;
    height: 48px;
  }

  .btn,
  .btn-small,
  .panel-head .btn-small {
    min-height: 44px;
  }

  .result {
    min-height: 60px;
    gap: 10px;
  }

  .result-thumb,
  .row-thumb {
    width: 64px;
  }

  .row-error {
    padding-left: 112px;
  }

  .result-title {
    font-size: 14px;
  }

  .result-meta {
    font-size: 11px;
  }

  .add-btn {
    width: auto;
    min-width: 84px;
    height: 44px;
    padding: 0 12px;
    font-size: 14px;
  }

  .add-label {
    display: inline;
    margin-left: 4px;
  }

  .row-main {
    min-height: 56px;
  }

  .row-num {
    font-size: 13px;
  }

  .row-meta {
    font-size: 11px;
  }

  .row-meta .meta-group {
    display: none;
  }

  .statusbar span:last-child {
    display: none;
  }

  .row-btn {
    width: 44px;
    height: 44px;
    background: transparent;
    font-size: 17px;
  }

  .mobile-only {
    display: inline-flex;
  }

  .search-songs {
    margin-top: 4px;
  }

  /* ----- bottom bar ----- */
  .bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: var(--bar-h);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: 1fr 1fr 1.15fr;
    gap: 8px;
    background: var(--panel);
    border-top: 1px solid var(--line2);
  }

  .bb-cell {
    position: relative;
    min-height: 56px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }

  .bb-cell[aria-current='page'] {
    background: var(--raised);
    color: var(--text);
  }

  .bb-cell[aria-current='page']::before {
    content: '';
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: var(--glowSm);
  }

  .badge-count {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--accentSoft);
    border: 1px solid var(--accentLine);
    color: var(--text);
    font-size: 11px;
  }

  .badge-count.bump {
    animation: bump 0.3s ease-out;
  }

  @keyframes bump {
    40% {
      transform: scale(1.35);
    }
  }

  .bb-gen {
    position: relative;
    overflow: hidden;
    min-height: 56px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accentText);
    font-size: 15px;
    font-weight: 700;
    box-shadow: var(--glow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
  }

  .bb-gen small {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
  }

  .bb-gen-label,
  .bb-gen small {
    position: relative;
    z-index: 1;
  }

  .bottom-bar[data-gen='running'] .bb-gen {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
  }

  .bb-fill {
    position: absolute;
    inset: auto 0 0 0;
    height: 4px;
    background: var(--accentText);
    opacity: 0.5;
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.3s ease-out;
  }

  .bottom-bar:not([data-gen='running']) .bb-fill {
    display: none;
  }

  .bb-gen.sweep::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
    transform: translateX(-120%);
    animation: sweep 0.6s 0.1s ease-out 1 forwards;
    pointer-events: none;
  }

  .toast-region {
    bottom: calc(var(--bar-h) + 12px);
    width: calc(100% - 24px);
  }

  /* With a sheet open, messages show at the top so they don't cover its buttons. */
  body.sheet-open .toast-region {
    bottom: auto;
    top: calc(8px + env(safe-area-inset-top, 0px));
    z-index: 60;
  }

  .toast {
    justify-content: space-between;
  }

  .toast .btn {
    min-height: 44px;
  }

  /* ----- sheets: the Editor panel, the Mix sheet and the menu ----- */
  .sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 44;
    background: var(--overlay);
  }

  .sheet-backdrop[hidden] {
    display: none;
  }

  .sheet,
  #editorPanel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    max-height: calc(100dvh - 24px);
    display: flex;
    flex-direction: column;
    border: 0;
    border-top: 1px solid var(--accentLine);
    border-radius: 16px 16px 0 0;
    background: var(--panel);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow: hidden;
  }

  .sheet[hidden] {
    display: none;
  }

  /* The Editor stays in the page (its YouTube player must not be moved or
     destroyed), parked below the screen until a song is opened. */
  #editorPanel:not(.is-open) {
    transform: translateY(110%);
    visibility: hidden;
  }

  #editorPanel .panel-body {
    overflow-y: auto;
    padding: 0 16px 8px;
  }

  #editorPanel .panel-head {
    border-bottom: 0;
    padding: 0 12px 0 16px;
  }

  .sheet-grab {
    display: flex;
    align-self: center;
    flex: none;
    width: 120px;
    height: 44px;
    margin-bottom: -14px;
    border: 0;
    background: transparent;
    align-items: center;
    justify-content: center;
    touch-action: none;
    cursor: grab;
  }

  .sheet-grab span {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--lineStrong);
  }

  .sheet-done {
    display: inline-flex;
    min-height: 44px;
    padding: 0 16px;
    font-weight: 700;
  }

  .sheet-head {
    flex: none;
    height: 52px;
    padding: 0 12px 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .sheet-body {
    overflow-y: auto;
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .sheet-body .panel-foot {
    border-top: 0;
    padding: 0;
  }

  .sheet-song-nav {
    display: flex;
    flex: none;
    gap: 8px;
    padding: 8px 16px 12px;
  }

  .sheet-song-nav .btn {
    flex: 1 1 0;
    min-height: 48px;
    font-weight: 700;
  }

  /* Editor controls at thumb size. */
  .video {
    max-width: 100%;
  }

  .ed-title {
    font-size: 17px;
  }

  .ed-nav .square-sm {
    display: none;
  }

  .timeline {
    height: 60px;
  }

  .handle {
    width: 44px;
    height: 44px;
    margin-left: -22px;
    top: 16px;
  }

  .handle::before {
    width: 24px;
    height: 24px;
  }

  .cut-source {
    height: 32px;
    font-size: 13px;
  }

  .cuts {
    gap: 8px;
  }

  .cut-cap {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--muted);
  }

  .step-label {
    display: none;
  }

  .stepper {
    height: 46px;
  }

  .step-mid {
    align-self: stretch;
  }

  .step-input {
    height: 100%;
    width: 100%;
    text-align: center;
  }

  .step {
    font-size: 12px;
  }

  .step-input {
    font-size: 16px;
  }

  .snip {
    height: 44px;
  }

  .listen-btn {
    min-height: 56px;
  }

  /* ----- the menu sheet ----- */
  .menu-sheet .menu-item {
    min-height: 48px;
    font-size: 15px;
  }

  .menu-sheet .menu-item small {
    color: var(--muted);
    font-size: 12px;
  }

  .menu-sheet .menu-kofi {
    color: var(--accentInk);
    font-weight: 700;
  }

  .menu-sheet .menu-shop {
    color: var(--cyanInk);
  }

  .seg button {
    height: 44px;
  }

  /* My mix: the mix options above the bottom bar's Generate. */
  .mix-rows {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px 4px; /* same inset as the song rows above */
    border-top: 1px solid var(--line2);
  }

  .mix-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    color: var(--muted);
  }

  /* 196px keeps each of the four fade-out buttons at least 44px wide. */
  .mix-row .seg {
    flex: none;
    width: 196px;
  }

  .mix-options .seg button {
    height: 44px;
  }

  /* With a sheet open, the page behind it doesn't scroll. */
  body.sheet-open {
    overflow: hidden;
  }

  .sheet-body,
  #editorPanel .panel-body {
    overscroll-behavior: contain;
  }

  /* The footer: stacked, below the active view. */
  .site-footer .fcol summary {
    min-height: 48px;
  }

  .dialog {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    height: 100%;
    border-radius: 0;
  }
}

@media (max-width: 899px) and (prefers-reduced-motion: reduce) {
  #editorPanel {
    transition: none;
  }
}

/* ===== Reduced motion: everything off ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }

  /* The row flash points at a problem: keep it, as a still ring with no fade. */
  .row.flash,
  .row.flash-info {
    animation-duration: 0.7s !important;
    animation-timing-function: step-end !important;
  }
}
