/* Hallmark · genre: atmospheric · macrostructure: Workbench (stage + parameter panel) · theme: Lumen
 * design-system: src/musicxml_model/serve/DESIGN.md (read it before changing this page)
 * themes: white · midnight (default dark) · sky · arcana · black (data-theme, theme menu) · enrichment: Tier-A CSS staff apparatus (wait view)
 * nav: N9 edge-aligned · footer: Ft2 folded credits · tone: utilitarian studio · anchor hue: brass 50 / indigo 268
 * fonts: Noto Serif KR (display, roman) + Pretendard (body) + JetBrains Mono (readouts) · icons: Lucide (ISC), inlined
 * Hallmark · pre-emit critique: P4 H5 E4 S4 R5 V4
 */
:root {
  --font-display: "Noto Serif KR", "Nanum Myeongjo", serif;
  --font-body: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --space-3xs: 0.25rem; --space-2xs: 0.5rem; --space-xs: 0.75rem; --space-sm: 1rem;
  --space-md: 1.5rem; --space-lg: 2rem; --space-xl: 3rem; --space-2xl: 4.5rem;

  --text-2xs: 0.6875rem; --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.5rem; --text-2xl: 2rem;
  --text-display: clamp(1.875rem, 4.2vw + 0.6rem, 2.875rem);
  --text-letter: clamp(3rem, 8vw, 4.5rem);

  --radius-sm: 8px; --radius-md: 14px; --radius-lg: 22px; --radius-pill: 999px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 140ms; --dur-short: 220ms; --dur-med: 420ms; --dur-pulse: 4s;
  --dur-tip: 150ms;                                   /* hover delay before a help tip shows (focus/tap: none) */

  --color-tip: var(--color-ink); --color-tip-ink: var(--color-paper);
  --shell-max: 72rem; --read-max: 46rem; --params-w: 22rem;
  --icon-help: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
  --icon-sliders: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='21' x2='14' y1='4' y2='4'/%3E%3Cline x1='10' x2='3' y1='4' y2='4'/%3E%3Cline x1='21' x2='12' y1='12' y2='12'/%3E%3Cline x1='8' x2='3' y1='12' y2='12'/%3E%3Cline x1='21' x2='16' y1='20' y2='20'/%3E%3Cline x1='12' x2='3' y1='20' y2='20'/%3E%3Cline x1='14' x2='14' y1='2' y2='6'/%3E%3Cline x1='8' x2='8' y1='10' y2='14'/%3E%3Cline x1='16' x2='16' y1='18' y2='22'/%3E%3C/svg%3E");
}
/* Themes (10-16): data-theme on <html>, picked in the theme menu, kept in localStorage['fermata-theme'].
 * Every theme sets the full colour set below; page rules use only these tokens.
 * dark themes: midnight · arcana · black   light themes: white · sky                                        */
:root, :root[data-theme="midnight"] {
  /* 미드나잇 블루 · deep navy, brass accent (was "Night Foundry") */
  color-scheme: dark;
  --color-paper:    oklch(15% 0.035 262);
  --color-paper-2:  oklch(19% 0.038 262);
  --color-paper-3:  oklch(23% 0.04 262);
  --color-ink:      oklch(96% 0.008 262);
  --color-ink-2:    oklch(80% 0.018 262);
  --color-ink-3:    oklch(64% 0.022 262);
  --color-rule:     oklch(96% 0.008 262 / 0.09);
  --color-rule-2:   oklch(96% 0.008 262 / 0.16);
  --color-accent:   oklch(76% 0.17 50);
  --color-accent-ink: oklch(18% 0.03 50);
  --color-accent-soft: oklch(76% 0.17 50 / 0.14);
  --color-accent-2: oklch(68% 0.16 18);
  --color-glow:     oklch(80% 0.16 50 / 0.42);
  --color-paper-emit: oklch(60% 0.12 262 / 0.08);
  --color-focus:    oklch(82% 0.15 50);
  --color-ok:       oklch(78% 0.14 150);
  --color-shadow:   oklch(0% 0 0 / 0.55);
  --color-scrim:    oklch(0% 0 0 / 0.5);
}
:root[data-theme="white"] {
  /* 화이트 · plain white, neutral greys (no tint), indigo accent */
  color-scheme: light;
  --color-paper:    oklch(100% 0 0);
  --color-paper-2:  oklch(100% 0 0);
  --color-paper-3:  oklch(96.5% 0 0);
  --color-ink:      oklch(20% 0 0);
  --color-ink-2:    oklch(38% 0 0);
  --color-ink-3:    oklch(53% 0 0);
  --color-rule:     oklch(20% 0 0 / 0.1);
  --color-rule-2:   oklch(20% 0 0 / 0.18);
  --color-accent:   oklch(48% 0.22 268);
  --color-accent-ink: oklch(99% 0 0);
  --color-accent-soft: oklch(48% 0.22 268 / 0.08);
  --color-accent-2: oklch(55% 0.2 25);
  --color-glow:     oklch(55% 0.2 268 / 0.22);
  --color-paper-emit: transparent;
  --color-focus:    oklch(48% 0.22 268);
  --color-ok:       oklch(50% 0.14 150);
  --color-shadow:   oklch(20% 0 0 / 0.12);
  --color-scrim:    oklch(20% 0 0 / 0.35);
}
:root[data-theme="sky"] {
  /* 스카이 블루 · pale sky paper, white cards, sky-blue accent */
  color-scheme: light;
  --color-paper:    oklch(96.5% 0.022 230);
  --color-paper-2:  oklch(99.5% 0.006 230);
  --color-paper-3:  oklch(93% 0.03 230);
  --color-ink:      oklch(24% 0.05 245);
  --color-ink-2:    oklch(40% 0.05 245);
  --color-ink-3:    oklch(53% 0.045 240);
  --color-rule:     oklch(30% 0.05 240 / 0.1);
  --color-rule-2:   oklch(30% 0.05 240 / 0.18);
  --color-accent:   oklch(56% 0.15 238);
  --color-accent-ink: oklch(99% 0.005 230);
  --color-accent-soft: oklch(56% 0.15 238 / 0.1);
  --color-accent-2: oklch(56% 0.19 22);
  --color-glow:     oklch(62% 0.15 238 / 0.25);
  --color-paper-emit: transparent;
  --color-focus:    oklch(52% 0.16 238);
  --color-ok:       oklch(50% 0.14 155);
  --color-shadow:   oklch(35% 0.06 240 / 0.14);
  --color-scrim:    oklch(24% 0.05 245 / 0.35);
}
:root[data-theme="arcana"] {
  /* 아르카나 퍼플 · deep violet, orchid accent */
  color-scheme: dark;
  --color-paper:    oklch(16% 0.05 300);
  --color-paper-2:  oklch(20.5% 0.06 300);
  --color-paper-3:  oklch(25% 0.065 300);
  --color-ink:      oklch(96% 0.012 310);
  --color-ink-2:    oklch(81% 0.03 310);
  --color-ink-3:    oklch(66% 0.04 305);
  --color-rule:     oklch(96% 0.012 310 / 0.1);
  --color-rule-2:   oklch(96% 0.012 310 / 0.18);
  --color-accent:   oklch(76% 0.16 322);
  --color-accent-ink: oklch(18% 0.05 310);
  --color-accent-soft: oklch(76% 0.16 322 / 0.15);
  --color-accent-2: oklch(72% 0.15 15);
  --color-glow:     oklch(76% 0.16 322 / 0.4);
  --color-paper-emit: oklch(55% 0.18 310 / 0.1);
  --color-focus:    oklch(82% 0.14 322);
  --color-ok:       oklch(78% 0.14 150);
  --color-shadow:   oklch(0% 0 0 / 0.55);
  --color-scrim:    oklch(0% 0 0 / 0.5);
}
:root[data-theme="black"] {
  /* 블랙 · true black (OLED), neutral greys, brass accent */
  color-scheme: dark;
  --color-paper:    oklch(0% 0 0);
  --color-paper-2:  oklch(14% 0 0);
  --color-paper-3:  oklch(20% 0 0);
  --color-ink:      oklch(96% 0 0);
  --color-ink-2:    oklch(78% 0 0);
  --color-ink-3:    oklch(62% 0 0);
  --color-rule:     oklch(100% 0 0 / 0.1);
  --color-rule-2:   oklch(100% 0 0 / 0.18);
  --color-accent:   oklch(78% 0.16 60);
  --color-accent-ink: oklch(15% 0.02 60);
  --color-accent-soft: oklch(78% 0.16 60 / 0.14);
  --color-accent-2: oklch(68% 0.16 18);
  --color-glow:     oklch(80% 0.15 60 / 0.35);
  --color-paper-emit: transparent;
  --color-focus:    oklch(84% 0.14 60);
  --color-ok:       oklch(78% 0.14 150);
  --color-shadow:   oklch(0% 0 0 / 0.7);
  --color-scrim:    oklch(0% 0 0 / 0.6);
}
/* swatch colours for the theme menu (paper + accent of each theme, shown regardless of the active one) */
:root {
  --sw-white-paper: oklch(100% 0 0);           --sw-white-accent: oklch(48% 0.22 268);
  --sw-midnight-paper: oklch(15% 0.035 262);   --sw-midnight-accent: oklch(76% 0.17 50);
  --sw-sky-paper: oklch(96.5% 0.022 230);      --sw-sky-accent: oklch(56% 0.15 238);
  --sw-arcana-paper: oklch(16% 0.05 300);      --sw-arcana-accent: oklch(76% 0.16 322);
  --sw-black-paper: oklch(0% 0 0);             --sw-black-accent: oklch(78% 0.16 60);
}


* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; color: var(--color-ink); background-color: var(--color-paper);
  background-image:
    radial-gradient(60rem 36rem at 85% -10%, var(--color-paper-emit), transparent 70%),
    radial-gradient(40rem 30rem at -10% 110%, var(--color-paper-emit), transparent 70%);
  background-attachment: fixed;
  font: 400 var(--text-md)/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.mono { font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-ink-3); }
.meta { font-size: var(--text-xs); color: var(--color-ink-3); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }

.shell { max-width: var(--shell-max); margin: 0 auto; padding: var(--space-md) var(--space-sm) var(--space-2xl); }
.view { max-width: var(--read-max); margin-inline: auto; }
.view.wide { max-width: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* N9 edge-aligned bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding-block: var(--space-xs) var(--space-xl); }
.brand { display: flex; align-items: baseline; gap: var(--space-2xs); text-decoration: none; }
.brand b { font: 700 var(--text-xl)/1 var(--font-display); letter-spacing: -0.01em; }
.brand .clef-mark { color: var(--color-accent); font: 500 var(--text-xl)/1 var(--font-display); }
.who { display: flex; align-items: center; gap: var(--space-2xs); min-width: 0; }
.who .name { font-size: var(--text-sm); color: var(--color-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .model { white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-ok); box-shadow: 0 0 0 3px oklch(78% 0.14 150 / 0.18); flex: none; }

h1, h2 { font-family: var(--font-display); font-style: normal; font-weight: 700; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; min-width: 0; }
h1 { font-size: var(--text-display); line-height: 1.18; }
h2 { font-size: var(--text-xl); line-height: 1.3; }
.lede { color: var(--color-ink-2); margin: var(--space-xs) 0 0; max-width: 34rem; }
.hl { color: var(--color-accent); }

.card { background: var(--color-paper-2); border: 1px solid var(--color-rule); border-radius: var(--radius-lg);
        box-shadow: 0 24px 60px -28px var(--color-shadow); }
.section-gap { margin-top: var(--space-xl); }

/* inputs */
.field { display: grid; gap: var(--space-3xs); min-width: 0; }
.field > span { font-size: var(--text-xs); color: var(--color-ink-3); }
.input, .select {
  width: 100%; min-width: 0; padding: 0.7rem 0.85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--color-rule-2); background: var(--color-paper); transition: border-color var(--dur-fast) var(--ease-out);
}
.input:hover, .select:hover { border-color: var(--color-ink-3); }
.input:focus-visible, .select:focus-visible { outline-offset: 0; border-color: var(--color-focus); }
.input::placeholder { color: var(--color-ink-3); }
textarea.lyrics { display: block; min-height: 9rem; resize: vertical; font: inherit; line-height: 1.55; margin-top: var(--space-xs); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2xs);
  min-height: 2.75rem; padding: 0 1.15rem; border-radius: var(--radius-pill); white-space: nowrap;
  border: 1px solid var(--color-rule-2); background: transparent; cursor: pointer; text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.btn:hover { background: var(--color-paper-3); border-color: var(--color-ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--color-accent); color: var(--color-accent-ink); border-color: var(--color-accent); font-weight: 600; }
.btn-primary:hover { background: var(--color-accent); border-color: var(--color-accent); box-shadow: 0 10px 30px -10px var(--color-glow); }
.btn-primary:disabled:hover { box-shadow: none; }
.btn-lg { min-height: 3.25rem; padding: 0 1.6rem; font-size: var(--text-lg); }
.btn[data-state="loading"] { pointer-events: none; opacity: 0.7; }
.btn[data-state="loading"]::before { content: ""; width: 0.9em; height: 0.9em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.err { color: var(--color-accent-2); font-size: var(--text-sm); margin: var(--space-xs) 0 0; min-height: 1.4em; }

/* login / account */
.login { padding: var(--space-lg); display: grid; gap: var(--space-sm); }
.login .actions { margin-top: var(--space-2xs); display: flex; gap: var(--space-xs); flex-wrap: wrap; align-items: center; }
.login .hint { font-size: var(--text-xs); color: var(--color-ink-3); margin: 0; }
.auth-tabs { margin-top: var(--space-lg); }
.linkrow { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-sm); margin-top: var(--space-sm); font-size: var(--text-sm); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--color-ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
.linkbtn:hover { color: var(--color-ink); }
.ok { color: var(--color-ink-2); font-size: var(--text-sm); margin: var(--space-xs) 0 0; }
.acct-grid { display: grid; gap: var(--space-md); margin-top: var(--space-lg); }
.acct-grid h2 { font-size: var(--text-lg); }
.acct-grid .err:empty, .acct-grid .ok:empty { display: none; }
/* API keys (account page) */
.key-list { list-style: none; margin: 0 0 var(--space-sm); padding: 0; display: grid; gap: var(--space-2xs); }
.key-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3xs) var(--space-xs);
               padding: var(--space-2xs) 0; border-bottom: 1px solid var(--color-rule); }
.key-list li:last-child { border-bottom: 0; }
.key-name { font-weight: 600; color: var(--color-ink); }
.key-meta { flex: 1 1 12rem; font-size: var(--text-xs); color: var(--color-ink-3); }
.key-meta code, .key-new code { font-family: var(--font-mono); }
.key-empty { color: var(--color-ink-3); font-size: var(--text-sm); }
.key-new { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); margin-top: var(--space-sm);
           padding: var(--space-xs) var(--space-sm); border: 1px solid var(--color-rule); border-radius: var(--radius-md);
           background: var(--color-paper-2); }
.key-new code { flex: 1 1 16rem; font-size: var(--text-sm); color: var(--color-ink); overflow-wrap: anywhere; user-select: all; }
button.who { border: 0; background: transparent; padding: 0.25rem 0.5rem; border-radius: var(--radius-pill); cursor: pointer; font: inherit; color: inherit; }
button.who:hover { background: var(--color-paper-3); }

/* composer */
.prompt { margin-top: var(--space-lg); padding: var(--space-2xs); display: flex; gap: var(--space-2xs); align-items: center; }
.prompt .input { border: 0; background: transparent; font-size: var(--text-lg); padding: 0.75rem 0.9rem; }
.prompt .input:focus-visible { outline: none; }
.prompt:focus-within { border-color: var(--color-focus); }
.nl-notes { margin: var(--space-xs) 0 0; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-md); background: var(--color-accent-soft); color: var(--color-ink-2); font-size: var(--text-sm); }
.nl-notes b { color: var(--color-ink); font-weight: 600; }

.label-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin: var(--space-sm) 0 var(--space-xs); }
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.25rem), 1fr)); gap: 6px; }
.style {
  text-align: left; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); border: 1px solid var(--color-rule);
  background: var(--color-paper-2); cursor: pointer; display: grid; gap: 2px; min-width: 0;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.style:hover { border-color: var(--color-rule-2); background: var(--color-paper-3); }
.style .t { font-weight: 600; font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.style .s { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-ink-3); letter-spacing: 0.02em; }
.style[aria-pressed="true"] { border-color: var(--color-accent); background: var(--color-accent-soft); }
.style[aria-pressed="true"] .s { color: var(--color-accent); }

details.adv { margin-top: var(--space-md); border-top: 1px solid var(--color-rule); }
details.adv > summary { list-style: none; cursor: pointer; padding: var(--space-sm) 0; display: flex; justify-content: space-between; align-items: center; color: var(--color-ink-2); }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::after { content: "+"; font-family: var(--font-mono); color: var(--color-ink-3); transition: transform var(--dur-short) var(--ease-out); }
details.adv[open] > summary::after { transform: rotate(45deg); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 0.4rem 0.75rem; border-radius: var(--radius-pill); border: 1px solid var(--color-rule-2);
  font-size: var(--text-sm); cursor: pointer; user-select: none; background: transparent; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.chip:hover { border-color: var(--color-ink-3); }
.chip[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-ink); }
.chip .n { font-family: var(--font-mono); font-size: var(--text-2xs); margin-left: 4px; opacity: 0.75; }
.toggle { display: inline-flex; align-items: center; gap: var(--space-2xs); margin-top: var(--space-sm); cursor: pointer; color: var(--color-ink-2); font-size: var(--text-sm); }
.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--color-accent); }

.go-row { display: flex; align-items: center; gap: var(--space-2xs); }

/* wait — the staff apparatus */
.wait { padding: var(--space-xl) var(--space-lg); text-align: center; }
.staff { position: relative; height: 7.5rem; margin: var(--space-lg) auto var(--space-md); max-width: 30rem; overflow: hidden;
         mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent); }
.staff i { position: absolute; left: 0; right: 0; height: 1px; background: var(--color-rule-2); }
.staff i:nth-child(1) { top: 20%; } .staff i:nth-child(2) { top: 35%; } .staff i:nth-child(3) { top: 50%; }
.staff i:nth-child(4) { top: 65%; } .staff i:nth-child(5) { top: 80%; }
.staff b { position: absolute; width: 0.85rem; height: 0.62rem; border-radius: 50%; background: var(--color-accent);
           transform: rotate(-20deg); box-shadow: 0 0 14px 2px var(--color-glow); left: 100%;
           animation: drift 3.2s linear infinite; }
.staff b:nth-of-type(1) { top: calc(50% - 0.31rem); animation-delay: 0s; }
.staff b:nth-of-type(2) { top: calc(35% - 0.31rem); animation-delay: -0.8s; }
.staff b:nth-of-type(3) { top: calc(27.5% - 0.31rem); animation-delay: -1.6s; }
.staff b:nth-of-type(4) { top: calc(42.5% - 0.31rem); animation-delay: -2.4s; }
@keyframes drift { from { transform: translateX(0) rotate(-20deg); } to { transform: translateX(-34rem) rotate(-20deg); } }
.readout { display: flex; justify-content: center; gap: var(--space-sm); flex-wrap: wrap; margin-top: var(--space-sm); }

/* A/B */
.ab { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); margin-top: var(--space-lg); }
@media (max-width: 620px) { .ab { grid-template-columns: minmax(0, 1fr); } }
.take { padding: var(--space-md); display: grid; gap: var(--space-sm); transition: border-color var(--dur-short) var(--ease-out); }
.take.playing { border-color: var(--color-accent); }
.take-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-xs); }
.letter { font: 700 var(--text-letter)/0.9 var(--font-display); letter-spacing: -0.03em; }
.take-meta { text-align: right; display: grid; gap: 2px; }
.player { display: flex; align-items: center; gap: var(--space-xs); }
.play {
  flex: none; width: 3rem; height: 3rem; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--color-ink); color: var(--color-paper); display: grid; place-items: center;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.play:hover { background: var(--color-accent); color: var(--color-accent-ink); }
.play:active { transform: scale(0.96); }
.play svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.scrub { flex: 1; min-width: 0; display: grid; gap: 4px; }
.scrub input[type=range] { width: 100%; accent-color: var(--color-accent); margin: 0; height: 1.25rem; cursor: pointer; }
.times { display: flex; justify-content: space-between; }
.listen { display: grid; gap: 6px; }
.meter { height: 3px; border-radius: 3px; background: var(--color-rule-2); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; background: var(--color-accent); transition: width var(--dur-short) linear; }
.listen.ok .meter > span { background: var(--color-ok); }
.listen.ok .meta { color: var(--color-ok); }
.take .btn { width: 100%; }
.ab-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; margin-top: var(--space-md); }

/* done */
.done { padding: var(--space-lg); }
.done .actions, .ab-foot .actions { display: flex; gap: var(--space-2xs); flex-wrap: wrap; margin-top: var(--space-md); }
.ab-foot .actions { margin-top: 0; }

/* Ft2 inline line */
footer { margin-top: var(--space-2xl); padding-top: var(--space-md); border-top: 1px solid var(--color-rule); color: var(--color-ink-3); font-size: var(--text-xs); line-height: 1.7; }
footer a { text-decoration-color: var(--color-rule-2); text-underline-offset: 3px; }
footer summary { cursor: pointer; width: max-content; }
.foot-links { margin: 0 0 var(--space-2xs); }
.foot-links a { color: var(--color-ink-2); font-weight: 600; }
.consent { margin: 0; }
.consent a { color: var(--color-ink-2); text-underline-offset: 3px; }
/* privacy policy page (/privacy) */
.doc { max-width: var(--read-max); margin: 0 auto; }
.doc h1 { margin-bottom: var(--space-xs); }
.doc h2 { font-size: var(--text-lg); margin: var(--space-xl) 0 var(--space-xs); }
.doc p, .doc li { color: var(--color-ink-2); line-height: 1.75; word-break: keep-all; overflow-wrap: anywhere; }
.doc ul { padding-left: 1.2em; margin: var(--space-2xs) 0; }
.doc .table-wrap { overflow-x: auto; border: 1px solid var(--color-rule); border-radius: var(--radius-md); margin: var(--space-xs) 0; }
.doc table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
.doc th, .doc td { text-align: left; vertical-align: top; padding: var(--space-2xs) var(--space-xs); border-bottom: 1px solid var(--color-rule);
                   color: var(--color-ink-2); word-break: keep-all; }
.doc th { color: var(--color-ink); font-weight: 600; background: var(--color-paper-2); white-space: nowrap; }
.doc tr:last-child td { border-bottom: 0; }
.doc code { font-family: var(--font-mono); font-size: 0.92em; color: var(--color-ink); overflow-wrap: anywhere; }
.doc pre { margin: var(--space-xs) 0; padding: var(--space-sm); overflow-x: auto; border: 1px solid var(--color-rule);
           border-radius: var(--radius-md); background: var(--color-paper-2); }
.doc pre code { font-size: var(--text-xs); line-height: 1.6; overflow-wrap: normal; white-space: pre; }
.doc .todo { color: var(--color-accent-2); font-weight: 600; }
footer summary:hover { color: var(--color-ink-2); }
footer p { margin: var(--space-2xs) 0 0; }

/* transcription page */
.tr-up { margin-top: var(--space-lg); padding: var(--space-md); display: grid; gap: var(--space-sm); }
.trial-cta { margin: var(--space-md) 0; padding: var(--space-md); display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-sm); flex-wrap: wrap; }
.trial-cta .meta { margin: 4px 0 0; }
.tr-trial { margin-top: var(--space-sm); }
.drop { position: relative; display: grid; gap: 6px; justify-items: center; text-align: center; padding: var(--space-lg) var(--space-md);
        border: 1.5px dashed var(--color-rule-2); border-radius: var(--radius-md); cursor: pointer; color: var(--color-ink-2);
        transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--color-accent); background: var(--color-accent-soft); }
.drop b { color: var(--color-ink); font-weight: 600; overflow-wrap: anywhere; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tr-go-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; }
.tr-list { display: grid; gap: var(--space-sm); margin-top: var(--space-lg); }
.tr-item { padding: var(--space-md); display: grid; gap: var(--space-sm); min-width: 0; }
.tr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-xs); }
.tr-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill); border: 1px solid var(--color-rule-2);
         font-size: var(--text-xs); color: var(--color-ink-2); white-space: nowrap; flex: none; }
.badge.ok { color: var(--color-ok); border-color: currentColor; }
.badge.bad { color: var(--color-accent-2); border-color: currentColor; }
.badge .sp { width: 0.8em; height: 0.8em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 2px 10px; border-radius: var(--radius-pill); background: var(--color-paper-3); font-size: var(--text-xs); color: var(--color-ink-2); white-space: nowrap; }
.tag i { font-style: normal; width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: 0; }
.roll-wrap { overflow-x: auto; border-radius: var(--radius-md); background: var(--color-paper); border: 1px solid var(--color-rule); }
.roll-wrap canvas { display: block; cursor: pointer; }
.tr-item audio { width: 100%; height: 2.5rem; }
.tr-dl { display: flex; flex-wrap: wrap; gap: var(--space-2xs); align-items: center; }
.tr-dl .linkbtn { margin-left: auto; }
.tr-err { color: var(--color-accent-2); font-size: var(--text-sm); margin: 0; }
/* bar: tabs + theme toggle */
.bar-mid { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); border: 1px solid var(--color-rule); background: var(--color-paper-2); }
.tab { border: 0; background: transparent; padding: 0.4rem 0.9rem; border-radius: var(--radius-pill); cursor: pointer; color: var(--color-ink-2); font-size: var(--text-sm); white-space: nowrap; }
.tab:hover { color: var(--color-ink); }
.tab[aria-selected="true"] { background: var(--color-paper-3); color: var(--color-ink); font-weight: 600; }
.icon-btn { width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 1px solid var(--color-rule); background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--color-ink-2); flex: none; }
.icon-btn:hover { color: var(--color-ink); border-color: var(--color-rule-2); }
.icon-btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.bar-right { display: flex; align-items: center; gap: var(--space-xs); min-width: 0; }

/* seed */
.seed { display: flex; align-items: center; gap: var(--space-2xs); flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); border: 1px solid var(--color-rule-2); }
.seg button { border: 0; background: transparent; padding: 0.35rem 0.8rem; border-radius: var(--radius-pill); cursor: pointer; font-size: var(--text-sm); color: var(--color-ink-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--color-ink); color: var(--color-paper); }
.seed .input { width: 8.5rem; font-family: var(--font-mono); font-size: var(--text-sm); padding: 0.45rem 0.7rem; }

/* publish */
.publish { margin-top: var(--space-md); padding-top: var(--space-md); border-top: 1px solid var(--color-rule); display: grid; gap: var(--space-xs); }
.title-row { display: flex; gap: var(--space-2xs); }
.title-row .input { flex: 1; }

/* gallery */
.gal-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; }
.quota { min-width: 10rem; display: grid; gap: 6px; }
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr)); gap: var(--space-sm); margin-top: var(--space-lg); }
.item { overflow: hidden; display: grid; grid-template-rows: auto 1fr; }
.cover { position: relative; aspect-ratio: 1; display: block; width: 100%; border: 0; padding: 0; cursor: pointer; background: var(--color-paper-3); }
.cover svg { display: block; width: 100%; height: 100%; }
.cover .ov { position: absolute; right: var(--space-xs); bottom: var(--space-xs); width: 2.75rem; height: 2.75rem; border-radius: 50%;
             background: var(--color-ink); color: var(--color-paper); display: grid; place-items: center; transition: transform var(--dur-fast) var(--ease-out); }
.cover:hover .ov { transform: scale(1.06); }
.cover .ov svg { width: 1rem; height: 1rem; fill: currentColor; }
.item.playing { border-color: var(--color-accent); }
.item-body { padding: var(--space-sm); display: grid; gap: 6px; align-content: start; }
.item-title { font: 700 var(--text-lg)/1.3 var(--font-display); margin: 0; overflow-wrap: anywhere; }
.item-prog { height: 2px; background: var(--color-rule); border-radius: 2px; overflow: hidden; }
.item-prog > span { display: block; height: 100%; width: 0; background: var(--color-accent); }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.btn-sm { min-height: 2.1rem; padding: 0 0.8rem; font-size: var(--text-sm); }
.empty { padding: var(--space-xl) var(--space-lg); text-align: center; color: var(--color-ink-2); }
.gal-tools { display: grid; gap: var(--space-sm); margin-top: var(--space-lg); }
.gal-row { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; }
.gal-search { flex: 1 1 14rem; min-width: 0; }
.gal-genres { display: flex; flex-wrap: wrap; gap: 6px; }
.gal-genres .chip .n { font-family: var(--font-mono); font-size: var(--text-2xs); opacity: 0.7; margin-left: 4px; }
.gal-genres .chip:disabled { opacity: 0.4; cursor: default; }
.gal-count { font-size: var(--text-sm); color: var(--color-ink-3); }
.like { display: inline-flex; align-items: center; gap: 5px; }
.like svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; }
.like[aria-pressed="true"] { color: var(--color-accent-2); border-color: var(--color-accent-2); }
.like[aria-pressed="true"] svg { fill: currentColor; }
.like.static { pointer-events: none; opacity: 0.75; }
.gal-more { display: flex; justify-content: center; margin-top: var(--space-md); }
@media (max-width: 420px) { .bar { flex-wrap: wrap; } .bar-mid { order: 3; width: 100%; } .bar-mid .tab { flex: 1; } }

/* section label: the one line of text a control group gets (help lives in a '?' next to it) */
.label { display: inline-flex; align-items: center; gap: var(--space-3xs); font-size: var(--text-sm); font-weight: 600; color: var(--color-ink-2); }

/* '?' help: icon only; the text shows on hover (after --dur-tip), keyboard focus or tap, in one shared tooltip (#tip) */
.help { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; margin: -0.25rem 0; padding: 0; border: 0;
        border-radius: 50%; background: transparent; color: var(--color-ink-3); cursor: help; vertical-align: middle; flex: none;
        transition: color var(--dur-fast) var(--ease-out); }
.help::before { content: ""; width: 1rem; height: 1rem; background: currentColor;
                -webkit-mask: var(--icon-help) center / contain no-repeat; mask: var(--icon-help) center / contain no-repeat; }
.help:hover, .help[aria-describedby] { color: var(--color-ink); }
h1 .help, h2 .help { margin-left: var(--space-3xs); }
#tip { position: fixed; z-index: 80; max-width: min(18rem, calc(100vw - 2 * var(--space-sm))); padding: var(--space-2xs) var(--space-xs);
       border-radius: var(--radius-sm); background: var(--color-tip); color: var(--color-tip-ink);
       font: 400 var(--text-xs)/1.55 var(--font-body); letter-spacing: normal; word-break: keep-all; overflow-wrap: anywhere;
       box-shadow: 0 12px 30px -12px var(--color-shadow); pointer-events: none; opacity: 0; visibility: hidden;
       transition: opacity var(--dur-fast) var(--ease-out), visibility 0s linear var(--dur-fast); }
#tip.on { opacity: 1; visibility: visible; transition: opacity var(--dur-fast) var(--ease-out); }

.ico { display: inline-block; width: 1rem; height: 1rem; background: currentColor; flex: none; }
.ico-sliders { -webkit-mask: var(--icon-sliders) center / contain no-repeat; mask: var(--icon-sliders) center / contain no-repeat; }

/* workbench: stage (input + preview of what will be made) | params (sidebar >= 768px, bottom sheet below) */
.bench { display: grid; gap: var(--space-md); align-items: start; }
.stage { display: grid; gap: var(--space-sm); min-width: 0; }
.stage .prompt { margin-top: 0; }
.stage > .seg { justify-self: start; }
.panel { padding: var(--space-md); display: grid; gap: var(--space-sm); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.brief .summary { margin: 0; color: var(--color-ink); font-size: var(--text-lg); overflow-wrap: anywhere; }
.brief .summary:empty::before { content: "—"; color: var(--color-ink-3); }
.params { display: grid; gap: var(--space-md); padding: var(--space-md); background: var(--color-paper-2);
          border: 1px solid var(--color-rule); border-radius: var(--radius-lg); min-width: 0; }
.params-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.params-head h2 { font-size: var(--text-lg); }
.group { display: grid; gap: var(--space-xs); min-width: 0; }
.params details.adv { margin-top: 0; }
.params details.adv > summary { gap: var(--space-xs); }
.params details.adv > summary .meta { flex: 1; min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { display: none; }

@media (min-width: 768px) {
  .bench { grid-template-columns: minmax(0, 1fr) var(--params-w); }
  .params { position: sticky; top: var(--space-md); max-height: calc(100dvh - 2 * var(--space-md)); overflow-y: auto; overscroll-behavior: contain; }
  .params-open, .params-close { display: none; }
}
@media (max-width: 767.98px) {
  .params { position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain;
            border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; box-shadow: 0 -24px 60px -20px var(--color-shadow);
            padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
            transform: translateY(105%); visibility: hidden;
            transition: transform var(--dur-med) var(--ease-out), visibility 0s linear var(--dur-med); }
  .params.open { transform: none; visibility: visible; transition: transform var(--dur-med) var(--ease-out); }
  .params-head { position: sticky; top: calc(-1 * var(--space-md)); margin: calc(-1 * var(--space-md)) calc(-1 * var(--space-md)) 0;
                 padding: var(--space-md); background: var(--color-paper-2); border-bottom: 1px solid var(--color-rule); z-index: 1; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 69; background: var(--color-scrim); opacity: 0; pointer-events: none;
           transition: opacity var(--dur-med) var(--ease-out); }
  .scrim.on { opacity: 1; pointer-events: auto; }
  body.sheet-open { overflow: hidden; }
}

/* theme menu: header button -> popover with five swatches; the same list sits in the params panel */
.theme-wrap { position: relative; }
.theme-menu { position: absolute; right: 0; top: calc(100% + var(--space-2xs)); z-index: 60; width: 13.5rem; padding: var(--space-2xs);
              background: var(--color-paper-2); border: 1px solid var(--color-rule-2); border-radius: var(--radius-md);
              box-shadow: 0 20px 50px -20px var(--color-shadow); }
.themes { display: grid; gap: 2px; }
.theme-opt { display: flex; align-items: center; gap: var(--space-xs); width: 100%; padding: 0.45rem 0.6rem; border: 0; border-radius: var(--radius-sm);
             background: transparent; cursor: pointer; text-align: left; font-size: var(--text-sm); color: var(--color-ink-2);
             transition: background-color var(--dur-fast) var(--ease-out); }
.theme-opt:hover { background: var(--color-paper-3); color: var(--color-ink); }
.theme-opt[aria-checked="true"] { color: var(--color-ink); font-weight: 600; }
.theme-opt[aria-checked="true"]::after { content: ""; margin-left: auto; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--color-accent); }
.swatch { width: 1.25rem; height: 1.25rem; border-radius: 50%; flex: none; border: 1px solid var(--color-rule-2);
          background: linear-gradient(135deg, var(--sw-paper) 0 55%, var(--sw-accent) 55% 100%); }
.swatch[data-t="white"] { --sw-paper: var(--sw-white-paper); --sw-accent: var(--sw-white-accent); }
.swatch[data-t="midnight"] { --sw-paper: var(--sw-midnight-paper); --sw-accent: var(--sw-midnight-accent); }
.swatch[data-t="sky"] { --sw-paper: var(--sw-sky-paper); --sw-accent: var(--sw-sky-accent); }
.swatch[data-t="arcana"] { --sw-paper: var(--sw-arcana-paper); --sw-accent: var(--sw-arcana-accent); }
.swatch[data-t="black"] { --sw-paper: var(--sw-black-paper); --sw-accent: var(--sw-black-accent); }
.params .themes { grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr)); }
.params .theme-opt { border: 1px solid var(--color-rule); }
.params .theme-opt[aria-checked="true"] { border-color: var(--color-accent); }

/* notice + reconnect banners */
.banner { display: flex; align-items: flex-start; gap: var(--space-xs); padding: var(--space-xs) var(--space-sm);
          border-radius: var(--radius-md); margin-bottom: var(--space-md); font-size: var(--text-sm); }
.banner b { font-weight: 600; }
.banner p { margin: 2px 0 0; color: var(--color-ink-2); }
.banner .x { margin-left: auto; flex: none; border: 0; background: transparent; cursor: pointer; color: var(--color-ink-3); font-size: var(--text-lg); line-height: 1; padding: 0 4px; }
.banner .x:hover { color: var(--color-ink); }
/* notice popup: x = closed for this visit, "a week" = not again for 7 days (per notice id) */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--space-md);
         background: color-mix(in oklch, var(--color-ink) 45%, transparent); }
.modal-card { position: relative; width: min(100%, 30rem); max-height: calc(100dvh - 2 * var(--space-md)); overflow: auto;
              background: var(--color-paper-2); border: 1px solid var(--color-rule); border-radius: var(--radius-lg);
              padding: var(--space-lg); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.45); }
.modal-card h2 { font-size: var(--text-xl); padding-right: 2.5rem; word-break: keep-all; }
.modal-card .body { margin: var(--space-sm) 0 0; color: var(--color-ink-2); white-space: pre-line; word-break: keep-all; overflow-wrap: anywhere; }
.modal-card .x { position: absolute; top: var(--space-sm); right: var(--space-sm); width: 2.25rem; height: 2.25rem; border-radius: 50%;
                 border: 0; background: transparent; cursor: pointer; color: var(--color-ink-3); font-size: 1.5rem; line-height: 1; }
.modal-card .x:hover { background: var(--color-paper-3); color: var(--color-ink); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; margin-top: var(--space-lg); }
.modal-foot .toggle { margin-top: 0; }
.down { background: var(--color-paper-3); border: 1px solid var(--color-rule-2); align-items: center; }
.down .spin { width: 0.9rem; height: 0.9rem; flex: none; border-radius: 50%; border: 2px solid var(--color-ink-3); border-right-color: transparent; animation: spin 0.8s linear infinite; }

.view { animation: fade var(--dur-med) var(--ease-out); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 150ms !important; animation-iteration-count: 1 !important; transition-duration: 0ms !important; }
  .staff b { animation: none; left: 45%; }
  .staff b:nth-of-type(2) { left: 55%; } .staff b:nth-of-type(3) { left: 65%; } .staff b:nth-of-type(4) { left: 35%; }
}
@media (max-width: 420px) {
  .shell { padding-inline: var(--space-sm); }
  .who .model { display: none; }
  .prompt { flex-wrap: wrap; }
  .prompt .btn { width: 100%; }
}
