/* Khaos Listening Space — khaos.dev design language in a player-app
   shell: fixed sidebar, focused creation panel, outputs feed, persistent
   bottom player bar. Brand teal owns interactive chrome; each artist keeps
   a derived --accent on their own trims. */

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

/* The hidden attribute always wins, whatever display an element's class
   sets — without this, any `display: flex` rule silently defeats it. */
[hidden] { display: none !important; }

:root {
  --bg:          #030809;
  --panel:       #081114;
  --panel-hover: #0e1a1e;
  --field:       #102226;
  --highlight:   #2ee5d2;
  --highlight-glow: rgba(46, 229, 210, 0.25);
  --cyan:        #80ced7;
  --text:        #f0f9f9;
  /* --fs-micro is uppercase labels and chips, --fs-note the muted
     explanatory lines. Every inline size below 12 px points here. */
  --fs-micro:    11px;
  --fs-note:     12px;
  /* The type scale both rooms draw from: the Space defines it, the Workshop mirrors it. */
  --fs-body:     14px;
  --fs-ui:       15px;
  --fs-lead:     18px;
  --fs-h3:       20px;
  --fs-h2:       26px;
  --fs-h1:       34px;
  --fw-regular:  400;
  --fw-strong:   700;
  /* The active nav row and grey pill, and the two stops of a generated
     cover (a dark teal gradient with a waveform texture). */
  --pill:        #15262a;
  --cover-a:     #0f2b30;
  --cover-b:     #05100f;
  --muted:       #80ced7;
  --border:      rgba(128, 206, 215, 0.18);
  --border-light:rgba(128, 206, 215, 0.3);
  --success:     #2ee5d2;
  --warn:        #f59e0b;
  --danger:      #ff6b6b;
  --ink-on-highlight: #04211d; /* dark teal text on teal fills */
  --ink-on-danger:    #180808; /* dark red text on danger fills */
  --ink-on-warn:      #1c1303; /* dark amber text on warn fills */
  --wave-unplayed:    #5fa9b5; /* WaveSurfer unplayed bars — read from JS */
  /* Wave-region tints: every MEANING has its own hue, vivid enough to read
     on teal bars — the operator's parts must never blend together. Teal =
     the LIVE selection (and the loop band on the bar), violet = SAVED plan
     parts, amber = repaint/extend HISTORY. All read from JS. */
  --select-tint:      rgba(46, 229, 210, 0.35);  /* the part being chosen / looped */
  --select-edge:      #2ee5d2;
  --plan-tint:        rgba(167, 139, 250, 0.32); /* parts saved for one chained Fix */
  --plan-edge:        #a78bfa;
  --repaint-tint:     rgba(245, 158, 11, 0.30); /* a repainted/extended span on any wave — read from JS */
  --repaint-tint-dim: rgba(245, 158, 11, 0.14); /* an ancestor's span in the family history */
  --moment-centroid:  rgba(255, 215, 0, 0.40);  /* a distinctive-moment centroid on a wave */
  --moment-tint:      rgba(255, 100, 100, 0.30); /* other distinctive moments */
  /* Glass: the page ground at an alpha, so the light theme can carry it too. */
  --glass:            rgba(3, 8, 9, 0.92);   /* the player bar over the page */
  --radius:      8px;
  --accent:      var(--highlight);
  --sidebar-w:   232px;
  --player-h:    76px;
  color-scheme: dark;   /* native controls (selects, scrollbars) follow the theme */
}

/* The LIGHT theme. Dark is the default; the artist's choice is stamped on
   <html data-theme="light"> before first paint (shell.js / _head.html).
   Only the colour tokens are redefined; the brand teal is darkened until it
   passes 4.5:1 on white. prefers-color-scheme is NOT consulted.
   The Workshop mirrors this block verbatim. */
:root[data-theme="light"] {
  --bg:          #f4fafa;
  --panel:       #ffffff;
  --panel-hover: #eaf4f4;
  --field:       #dfeced;
  --highlight:   #0a746b;
  --highlight-glow: rgba(10, 116, 107, 0.25);
  --cyan:        #3f7378;
  --text:        #07211f;
  --muted:       #2f5c60;
  --border:      rgba(10, 116, 107, 0.22);
  --border-light:rgba(10, 116, 107, 0.38);
  --success:     #0a746b;
  --warn:        #8a5200;
  --danger:      #b52f2e;
  --ink-on-highlight: #ffffff;
  --ink-on-danger:    #ffffff;
  --ink-on-warn:      #ffffff;
  --wave-unplayed:    #7fb6bd;
  --select-tint:      rgba(10, 116, 107, 0.30);
  --select-edge:      #0a746b;
  --plan-tint:        rgba(109, 74, 232, 0.26);
  --plan-edge:        #6d4ae8;
  --repaint-tint:     rgba(196, 118, 0, 0.30);
  --repaint-tint-dim: rgba(196, 118, 0, 0.14);
  --moment-centroid:  rgba(184, 140, 0, 0.45);
  --moment-tint:      rgba(200, 56, 58, 0.30);
  --glass:            rgba(244, 250, 250, 0.92);
  --accent:      var(--highlight);
  color-scheme: light;
  --pill:        #e4efef;
  --cover-a:     #cfe6e6;
  --cover-b:     #9fc3c8;
}
/* The wordmark is white on transparency (DESIGN.md: "needs a dark ground");
   on the light theme it is inked, and keeps its teal glow. */
:root[data-theme="light"] .brand img { filter: brightness(0) drop-shadow(0 0 10px rgba(10, 116, 107, 0.35)); }

html { height: 100%; overflow-y: scroll; scrollbar-gutter: stable; }   /* the column never shifts sideways when the page grows a scrollbar */
body {
  background: var(--bg);
  color: var(--text);
  /* No webfont download (SPEC: no cloud calls) — a locally-installed
     Red Hat Display is used when present, otherwise the system UI stack. */
  font-family: 'Red Hat Display', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; font-weight: 700; }
a { color: inherit; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85em; color: var(--muted); }

/* ── App shell ──────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; position: relative; }   /* relative: the sidebar resizer hangs off it */
.main {
  padding: 26px 34px calc(var(--player-h) + 40px);
  max-width: 1080px; width: 100%; margin: 0 auto;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 14px calc(var(--player-h) + 16px);
  overflow: hidden;
}
.sidebar-brand { padding: 2px 8px 16px; border-bottom: 1px solid var(--border); text-align: center; flex-shrink: 0; }
/* Brand stays fixed; everything below its rule scrolls as one unit. */
.sidebar-scroll {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand img {
  height: 53px; width: auto; display: block; margin: 0 auto;
  filter: drop-shadow(0 0 10px rgba(46, 229, 210, 0.35));
}
.sidebar-brand .brand-sub { display: block; border: none; padding: 6px 0 0; font-size:var(--fs-micro);
  color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
.sidebar-nav { flex: 1; padding-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.nav-heading {
  margin: 16px 8px 6px; color: var(--muted); font-size:var(--fs-micro); font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; opacity: .8;
}
/* Icon + label rows, the active row on --pill, no accent rule. The icons
   are _icons.html's (18 px, stroke 1.7, currentColor). */
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  text-decoration: none; font-size: var(--fs-body); font-weight: 600; color: var(--muted);
  transition: background .12s, color .12s;
}
.nav-link .ico { flex-shrink: 0; }
.nav-link .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link:hover { background: var(--panel-hover); color: var(--text); }
.nav-link.active { background: var(--pill); color: var(--text); }
/* The artists keep their thumbnails: the image when set, else a generated
   cover ground with the initial. */
.nav-thumb {
  width: 28px; height: 28px; border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--cover-a), var(--cover-b));
  background-size: cover; background-position: center;
  font-size: var(--fs-note); font-weight: 700; color: var(--muted);
}
.shutdown-btn {
  margin: 10px 8px 0; padding: 7px 10px;
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--muted); font-family: inherit; font-size:var(--fs-note); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.shutdown-btn:hover { border-color: var(--danger); color: var(--danger); }
.shutdown-btn.confirming { background: var(--danger); border-color: var(--danger); color: var(--ink-on-danger); }
.shutdown-btn:disabled { opacity: .6; cursor: default; }
.operator-link { display: block; width: 100%; padding: 6px 8px; color: var(--muted); font-size: var(--fs-micro); text-decoration: none;
  text-align: center; background: none; border: 0; font-family: inherit; cursor: pointer; }
.operator-link:hover { color: var(--text); }
/* What this visitor may not do is not offered. */
body.space-page:not([data-can-generate]) :is(#generate-btn, .create-panel, .variations-toggle, .pick-btn) { display: none !important; }
body.space-page:not([data-can-manage]) :is(.keep-btn, .delete-btn, .stems-btn, .take-name, .attr-compute, label:has(#keeper), label:has(#steps), label:has(#takes), label:has(#best-of), label:has(.repaint-keeper), label:has(.take-keeper), #keeper-precedence) { display: none !important; }
.visitor-note { margin: 0; color: var(--muted); font-size: var(--fs-body); }
.operator-login { max-width: 420px; }
.pilot-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); margin: 6px 0 14px; }
.pilot-table th { text-align: left; font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border-light); }
.pilot-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.pilot-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.pilot-table tr.total td { font-weight: var(--fw-strong); color: var(--highlight); }
.pilot-table code { font-size: var(--fs-micro); word-break: break-all; }
.pilot-inline { margin-top: 10px; }
.operator-login .check { flex-direction: row; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; }
.operator-login input[type="password"] { height: 40px; padding: 0 12px; border-radius: var(--radius); width: 100%; box-sizing: border-box;
  background: var(--field); color: var(--text); border: 1px solid var(--border); font: inherit; }
.operator-login-error { color: var(--danger); margin: 0; }
.sidebar-foot { padding: 12px 8px 4px; color: var(--muted); font-size:var(--fs-micro); line-height: 1.6; opacity: .7; }
/* The Dark / Light control sits above the footer line. */
.theme-switch { display: flex; margin: 0; }
/* The switch row: under Shut Down, one small pill group, the chosen one lit. */
.sidebar-switches { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 10px; }   /* centred: the Space has the theme alone */
.sidebar-switches .rework-tabs { padding: 2px; gap: 2px; }
.sidebar-switches .rework-tab { padding: 3px 9px; font-size: var(--fs-micro); font-weight: 600; letter-spacing: .04em; }
.sidebar-switches .rework-tab.active { color: var(--text); }

/* ── Dropdowns ─────────────────────────────────────────────────────────────
   One rule for every <select> in the room; the contexts below adjust size
   only. `appearance: none` replaces the OS arrow with a data-URI chevron
   whose colour is written out — a data URI cannot see currentColor. */
select {
  background-color: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 26px 5px 10px;
  font-family: inherit; font-size: var(--fs-note); line-height: 1.4;
  cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2380ced7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  transition: border-color .15s;
}
select:hover { border-color: var(--muted); }
select:focus { outline: none; border-color: var(--highlight);
               box-shadow: 0 0 0 2px var(--highlight-glow); }
select:disabled { opacity: .55; cursor: default; }
/* The popup list itself is drawn by the OS on most platforms — these land
   where it is not, and cost nothing where it is. */
select option { background: var(--bg); color: var(--text); }

/* ── Rework row (variation / repaint / extend per output) ──────────────── */
.rework-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* Base `select` above carries the look; nothing differs here. */

/* ── Audio-to-audio: its own card, separated from prompt+generate ───────── */
.cover-section { margin-top: 22px; }
/* Collapsed by default — the summary wears the panel-heading look, with the
   standard disclosure caret; open only when you mean to use it. */
.cover-section summary {
  cursor: pointer; font-size: var(--fs-note); font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--highlight); list-style: none;
}
.cover-section summary::before { content: "▸ "; transition: none; }
.cover-section[open] summary::before { content: "▾ "; }
.cover-section summary::-webkit-details-marker { display: none; }
.cover-section summary:hover { text-shadow: 0 0 12px var(--highlight-glow); }
.cover-section summary .hint-inline { font-size: var(--fs-note); font-weight: 500; color: var(--muted);
                                      letter-spacing: 0; text-transform: none; margin-left: 8px; }
/* Inside .advanced-grid, whose `label` rule (a column of micro caps) this
   undoes by specificity: .advanced-grid .attest-label outranks it. */
.advanced-grid .attest-label { flex-direction: row; align-items: center;
                font-size: var(--fs-note); text-transform: none; letter-spacing: 0; color: var(--text); }
.attest-label input { accent-color: var(--highlight); }

/* ── Rework waveform (region drag = repaint, edge pull = extend) ────────── */
.rework-wave-wrap { position: relative; display: flex; align-items: stretch;
                    width: 100%; height: 52px; margin: 0; }
.rework-wave { position: relative; flex: 1; min-width: 0; background: var(--field);
               border-radius: var(--radius); }
.rework-extend-handle { width: 18px; margin-left: 4px; border-radius: var(--radius);
  background: var(--field); border: 1px dashed var(--border-light);
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  cursor: ew-resize; user-select: none; touch-action: none; font-size: var(--fs-note); }
.rework-extend-handle:hover { border-color: var(--highlight); color: var(--highlight); }
.rework-extend-ghost { flex: 0 0 0%; margin-left: 4px; min-width: 0; overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--highlight-glow), var(--highlight-glow) 6px,
              transparent 6px, transparent 12px);
  border-radius: var(--radius); pointer-events: none;
  display: flex; align-items: center; justify-content: center; }
.rework-extend-label, .rework-extend-label-left { font-size:var(--fs-note); font-weight: 700; color: var(--highlight); }
.rework-extend-ghost-left { margin-left: 0; margin-right: 4px; }
.rework-extend-handle-left { margin-left: 0; margin-right: 4px; }
/* ── Rework panel: verbs, region tools, chips, review lanes ─────────────── */
.variations-row:focus { outline: none; box-shadow: 0 0 0 2px var(--highlight-glow); }
.rework-tabs { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; align-self: flex-start; }
.rework-tab { padding: 5px 13px; border: none; border-radius: 999px; background: none;
  color: var(--muted); font-family: inherit; font-size: var(--fs-note); font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s; }
.rework-tab:hover { color: var(--text); }
.rework-tab.active { background: var(--field); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-light); }
.rework-tab:focus-visible { outline: 2px solid var(--highlight); outline-offset: 1px; }
.rework-pane { display: flex; flex-direction: column; gap: 8px; }
.rework-region-tools { align-items: flex-end; }
.rework-chip-label { display: flex; flex-direction: column; gap: 4px;
  font-size:var(--fs-micro); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
/* Every chip label sits in .variations-row, whose `label` rule stretches
   (flex: 1; min-width: 180px); this outranks it by specificity. */
.variations-row .rework-chip-label { flex: 0 0 auto; min-width: 0; }
.rework-chip-label input { background-color: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; font-family: inherit; }
.rework-chip-label input, .rework-chip-label select { padding: 5px 8px; font-size: var(--fs-note); }
/* …the arrow needs its room back after the padding above. */
.rework-chip-label select { padding-right: 24px; }
.rework-chip-label input[type="number"] { width: 72px; font-variant-numeric: tabular-nums; }
/* The Keeper chip is the row's shortest column: stretched, its label sits
   on the shared label line and the box drops onto the control line. */
.rework-chip-label.keeper-opt { align-self: stretch; }
.rework-chip-label input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0; margin: 7px 0 0 2px;
  align-self: flex-start; accent-color: var(--highlight); cursor: pointer;
}
.rework-chip-label input:focus, .rework-chip-label select:focus { outline: none; border-color: var(--highlight);
  box-shadow: 0 0 0 2px var(--highlight-glow); }
.rework-loop, .rework-clear, .rework-chip, .rework-lane-name, .rework-keep, .rework-discard,
.rework-more, .rework-review-done {
  padding: 5px 11px; font-size: var(--fs-note); border-radius: 999px; font-family: inherit; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s; }
.rework-loop:hover, .rework-clear:hover, .rework-chip:hover, .rework-lane-name:hover,
.rework-keep:hover, .rework-more:hover, .rework-review-done:hover { border-color: var(--highlight); color: var(--highlight); }
.rework-loop:disabled, .rework-clear:disabled { opacity: .4; cursor: default; }
.rework-chip.active { background: var(--highlight); color: var(--ink-on-highlight); border-color: var(--highlight); }
.rework-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.repaint-direction, .extend-direction { flex: 1; min-width: 220px; background: var(--bg);
  border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 7px 10px;
  font-family: inherit; font-size: var(--fs-note); }
.repaint-direction:focus, .extend-direction:focus { outline: none; border-color: var(--highlight);
  box-shadow: 0 0 0 2px var(--highlight-glow); }
.rework-extend-summary { font-size: var(--fs-note); font-weight: 600; color: var(--highlight); }
.rework-extend-summary.quiet { color: var(--muted); font-weight: 500; }
.rework-wave.active { box-shadow: inset 0 0 0 1px var(--highlight-glow); }
.rework-progress { position: absolute; top: 0; bottom: 0; pointer-events: none; z-index: 6;
  background: rgba(46, 229, 210, .08); border-left: 1px solid var(--highlight); border-right: 1px solid var(--highlight); }
.rework-progress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: repeating-linear-gradient(135deg, var(--highlight-glow), var(--highlight-glow) 6px,
              transparent 6px, transparent 12px); transition: width .4s linear; }
.rework-status { font-size: var(--fs-note); color: var(--text); }
.rework-status.quiet { color: var(--muted); }
.working-rework .rework-region-tools { opacity: .7; pointer-events: none; }
.rework-review { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border-light);
  padding-top: 10px; margin-top: 2px; }
.rework-review-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: var(--fs-note); }
.rework-review-title { font-weight: 700; color: var(--text); }
.rework-lane { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 8px;
  border: 1px solid transparent; }
.rework-lane.active { border-color: var(--border-light); background: var(--bg); }
.rework-lane.active .rework-lane-name { background: var(--highlight); color: var(--ink-on-highlight); border-color: var(--highlight); }
.rework-lane-name { min-width: 34px; text-align: center; font-weight: 700; }
.rework-lane-wave { flex: 1; min-width: 0; background: var(--panel); border-radius: 4px; overflow: hidden; }
.rework-lane-note { font-size:var(--fs-note); flex: 1; }
.rework-discard:hover { border-color: var(--danger); color: var(--danger); }
/* Plan: saved parts as numbered chips */
.rework-plan-row { align-items: center; }
.rework-plan-add { padding: 4px 11px; font-size: var(--fs-note); border-radius: 999px; font-family: inherit; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--border); }
.rework-plan-add:hover { border-color: var(--highlight); color: var(--highlight); }
.rework-plan-add:disabled { opacity: .4; cursor: default; }
.rework-plan { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.rework-plan-part { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px;
  border-radius: 999px; background: var(--bg); border: 1px solid var(--border-light); font-size: var(--fs-note);
  font-variant-numeric: tabular-nums; }
.rework-plan-part b { color: var(--highlight); }
.rework-plan-remove { border: none; background: none; color: var(--muted); cursor: pointer; font-size: var(--fs-note);
  line-height: 1; padding: 0 3px; font-family: inherit; }
.rework-plan-remove:hover { color: var(--danger); }
/* Words strip: lyrics as the selection surface (vocal pieces) */
.rework-words { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.rework-words-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rework-words-note { font-size: var(--fs-note); }
.rework-words-align, .rework-words-edit, .rework-words-cancel {
  padding: 4px 11px; font-size: var(--fs-note); border-radius: 999px; font-family: inherit; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--border); }
.rework-words-align:hover, .rework-words-edit:hover, .rework-words-cancel:hover { border-color: var(--highlight); color: var(--highlight); }
.rework-words-text { font-size: var(--fs-body); line-height: 1.9; user-select: none; -webkit-user-select: none; }
.rework-words-text .rw-tag { display: block; font-size:var(--fs-micro); text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-top: 4px; }
.rework-words-text .rw-line { display: block; }
.rw-word { display: inline-block; padding: 0 3px; margin: 0 1px; border-radius: 4px; cursor: ew-resize;
  border-bottom: 1px solid transparent; }
.rw-word:hover { background: var(--field); }
.rw-word.unplaced { color: var(--muted); border-bottom-style: dotted; border-bottom-color: var(--muted); }
.rw-word.in-region { background: var(--highlight-glow); color: var(--text); border-bottom-color: var(--highlight); }
.rw-word.editing { background: rgba(245, 158, 11, .18); border-bottom-color: var(--warn); }
.rework-words-editor { display: flex; flex-direction: column; gap: 6px; }
.rework-words-input { width: 100%; background: var(--field); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 7px 10px; font-family: inherit; font-size: var(--fs-body); resize: vertical; }
.rework-words-input:focus { outline: none; border-color: var(--highlight); box-shadow: 0 0 0 2px var(--highlight-glow); }
.rework-words-editor-row { display: flex; align-items: center; gap: 10px; }
.rework-words-editor-note { font-size: var(--fs-note); }
.rework-hint { font-size:var(--fs-micro); color: var(--muted); text-transform: uppercase;
               letter-spacing: .07em; margin: 2px 0 6px; }
.rework-selection { font-size: var(--fs-note); font-weight: 600; color: var(--highlight); }
.rework-selection.quiet { color: var(--muted); font-weight: 500; }
.rework-sep { flex: 1; }
.reinterpret-group { border-top: 1px solid var(--border-light); padding-top: 10px; }
.reinterpret-group .reinterpret-prompt { flex: 2; min-width: 220px;
  padding: 7px 10px; border-radius: 6px; background: var(--bg);
  color: var(--text); border: 1px solid var(--border);
  font-family: inherit; font-size: var(--fs-body); }
.reinterpret-group .reinterpret-prompt:focus { outline: none; border-color: var(--highlight);
  box-shadow: 0 0 0 2px var(--highlight-glow); }

/* ── Provenance card ────────────────────────────────────────────────────── */
.prov-card { position: relative; background: var(--field); border: 1px solid var(--border-light);
             border-left: 3px solid var(--highlight); border-radius: var(--radius);
             padding: 12px 16px; margin-top: 8px; }
.prov-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.prov-title { font-size:var(--fs-micro); font-weight: 700; text-transform: uppercase;
              letter-spacing: .09em; color: var(--muted); }
.prov-badge { font-size:var(--fs-micro); font-weight: 700; text-transform: uppercase;
              letter-spacing: .06em; padding: 1px 8px; border-radius: 999px; }
.prov-badge.ok { color: var(--success); background: rgba(46, 229, 210, .12); }
.prov-badge.warn { color: var(--danger); background: rgba(255, 107, 107, .12); }
/* Section dividers inside a prov-grid (attribution card): full row,
   micro-label voice — the card reads as sections, not one long list. */
.prov-section {
  grid-column: 1 / -1; margin-top: 6px;
  font-size:var(--fs-micro); font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--highlight);
}
.prov-section:first-child { margin-top: 0; }
.prov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
             gap: 6px 18px; font-size: var(--fs-note); }
/* A grid item shrinks to its column; a long file name is cut with an
   ellipsis and carried whole in the title, never into the next column. */
.prov-item { min-width: 0; }
.prov-item span { display: block; font-size:var(--fs-micro); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prov-item code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size:var(--fs-note);
                  color: var(--muted); }
.prov-item .quiet { color: var(--muted); }
.prov-prompt { grid-column: 1 / -1; }
/* The Guild seal at the card's bottom right, beside the last rows (base
   model, licence, watermark, prompt); the grid keeps clear of it. */
.prov-seal { position: absolute; right: 16px; bottom: 52px; width: 150px; height: 150px; }
.prov-card:has(.prov-seal) .prov-grid { padding-right: 170px; }
/* The lyrics keep their own lines: a verse read as a paragraph is not a verse. */
.prov-lyrics { white-space: pre-wrap; margin-top: 2px; padding-left: 10px;
  border-left: 2px solid var(--border); }
.prov-raw-toggle { margin-top: 10px;
  padding: 4px 11px; font-size: var(--fs-note); border-radius: 999px;
  background: var(--field); color: var(--text); border: 1px solid var(--border);
  cursor: pointer; font-family: inherit; transition: background .15s, color .15s; }
.prov-raw-toggle:hover { background: var(--highlight); color: var(--ink-on-highlight); }
.prov-raw { margin-top: 8px; font-size:var(--fs-note); overflow-x: auto; color: var(--muted); }

/* ── Global activity (pinned under the brand; empty when idle) ─────────── */
#global-activity { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
#global-activity:not(:empty) {
  padding: 10px 8px 12px;
  border-bottom: 1px solid var(--border);
}
.activity-chip { display: flex; align-items: center; gap: 6px; font-size: var(--fs-note); color: var(--text);
                 background: var(--field); border: 1px solid var(--border); border-radius: 999px;
                 padding: 4px 12px; cursor: pointer; white-space: nowrap; overflow: hidden;
                 text-overflow: ellipsis; transition: border-color .15s; }
.activity-chip:hover { border-color: var(--highlight); }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
                background: var(--highlight); box-shadow: 0 0 6px var(--highlight-glow); }
.activity-dot.queued { background: var(--muted); box-shadow: none; }
.activity-summary { font-size: var(--fs-micro); color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
                    font-weight: 600; padding: 0 4px 2px; }

/* ── Index: artist tiles ────────────────────────────────────────────────── */
/* `.page-sub` on the hero's sentence is the copy gate's marker
   (tests/test_page_copy_is_short.py), not a rule. */
.spaces-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.spaces-grid > .stage-empty { grid-column: 1 / -1; }   /* the empty state is a child of the grid: the whole row, not the first tile's column */
.space-tile {
  display: block; text-decoration: none; background: var(--panel);
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.space-tile:hover {
  border-color: var(--highlight);
  box-shadow: 0 0 0 2px var(--highlight-glow), 0 8px 24px rgba(0, 0, 0, .45);
}
.tile-image { height: 150px; background-size: cover; background-position: center; }
.tile-image-fallback {
  display: flex; align-items: center; justify-content: center;
  font-size: 3.6rem; font-weight: 800; color: #f0f9f922;
  background: linear-gradient(135deg, var(--accent), #03080977);
}
.tile-body { padding: 12px 14px 15px; }
.tile-body h2 { margin: 0 0 4px; font-size: var(--fs-ui); letter-spacing: .02em; }
.tile-body p {
  margin: 0; color: var(--muted); font-size:var(--fs-note);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}

.refused {
  margin-top: 36px; padding: 14px 18px;
  background: var(--panel); border: 1px solid rgba(255, 107, 107, .35);
  border-left: 3px solid var(--danger); border-radius: var(--radius);
}
.refused h3 { margin: 0 0 6px; color: var(--danger); font-size: var(--fs-note); text-transform: uppercase; letter-spacing: .06em; }
.refused p { color: var(--muted); font-size: var(--fs-note); }
.refused li { font-size: var(--fs-note); color: var(--muted); margin-left: 18px; }

/* ── Artist space header: the hero ──────────────────────────────────────
   A 300 px cover at the left with a soft teal bleed behind; the text
   column; then the pill row with the ONE primary. The cover is the artist's
   image when set, else the generated one (the gradient here, the seeded
   waveform texture from 01-helpers). */
.space-page .main { border-top: 2px solid var(--accent); }
.stage-hero { position: relative; margin: 0 0 30px; }
.stage-hero-bleed {
  position: absolute; inset: -60px -34px auto -34px; height: 440px; pointer-events: none;
  background: radial-gradient(70% 90% at 25% 0%, color-mix(in srgb, var(--highlight) 16%, transparent), transparent 70%);
}
.stage-hero-grid { position: relative; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; align-items: end; }
/* The Guild seal in the hero's top-right corner: anchored to the hero
   itself, outside the grid's flow, so it never rides the text column's
   baseline; the title wraps before it reaches the seal. */
.stage-hero-seal { position: absolute; top: 0; right: 0; z-index: 1; }
.stage-hero-seal img { display: block; width: 180px; height: 180px; }
.stage-hero:has(.stage-hero-seal) .stage-hero-text { padding-right: 200px; }
.stage-cover-wrap { position: relative; width: 300px; height: 300px; flex-shrink: 0; }
.portrait-wrap { position: relative; flex-shrink: 0; }
.stage-cover {
  position: relative; width: 300px; height: 300px; border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--cover-a), var(--cover-b) 70%);
  background-size: cover; background-position: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
.stage-cover-bars { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; color: var(--highlight); }
.stage-cover-glyph { position: relative; width: 33%; height: 33%; opacity: .9; }
:root[data-theme="light"] .stage-cover-glyph { filter: brightness(.25); }
.stage-hero-text { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; min-width: 0; }
.stage-eyebrow { font-size: var(--fs-micro); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stage-title { margin: 0; font-size: var(--fs-h1); font-weight: 900; line-height: 1.02; letter-spacing: -.02em; overflow-wrap: anywhere; }
.stage-para { margin: 0; color: var(--muted); font-size: var(--fs-ui); line-height: 1.55; max-width: 60ch; }
.stage-facts { font-size: var(--fs-micro); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stage-pill-row { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 26px; }
.stage-pills { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
/* The other pages: the same hero, `no-cover` where there is no cover to
   show — the text column alone, a shorter bleed. */
.stage-hero.no-cover .stage-hero-grid { grid-template-columns: minmax(0, 1fr); }
.stage-hero.no-cover .stage-hero-bleed { height: 260px; }
.stage-hero.no-cover .stage-hero-text { padding-bottom: 0; }
/* A path in the facts line keeps its case (the MCP page's script). */
.stage-facts .mono { text-transform: none; letter-spacing: 0; font-size: inherit; }
/* The statement, tonal (Stage: panels are never bordered). */
.statement {
  margin-bottom: 20px; padding: 14px 18px; background: var(--panel);
  border-radius: 12px; white-space: pre-line;
}

/* The empty state: one shape for every list with nothing in it — a title,
   one sentence, one primary where the page has none already
   (templates/_empty.html; the Workshop's _emptyStateHTML is the same shape). */
.stage-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 28px 20px; text-align: center; background: var(--panel); border-radius: 12px;
}
.stage-empty-title { font-size: var(--fs-lead); font-weight: 700; }
.stage-empty-sentence { margin: 0 0 6px; color: var(--muted); font-size: var(--fs-body); max-width: 60ch; }

/* ── Model card ─────────────────────────────────────────────────────────── */
/* Tonal, and a fold: the hero says the facts, the grey "Model card" pill opens the rest. */
.model-card {
  margin-bottom: 22px; padding: 16px 20px; background: var(--panel);
  border-radius: 12px;
}
.model-card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.model-card > summary::-webkit-details-marker { display: none; }
.model-card > summary::before { content: "\25B8"; color: var(--highlight); font-size: var(--fs-note); }
.model-card[open] > summary::before { content: "\25BE"; }
.model-card > summary:hover h2 { text-shadow: 0 0 12px var(--highlight-glow); }
.model-card h2 { margin: 0; font-size: var(--fs-note); text-transform: uppercase; letter-spacing: .08em; color: var(--highlight); }
.model-card[open] > summary { margin-bottom: 2px; }
.card-note { color: var(--muted); font-size: var(--fs-note); margin: 0 0 10px; }
.adapter-note { color: var(--muted); font-size: var(--fs-note); }
/* The licence chain on the model card: the downstream sentence under the
   licence name, and the warranty paragraph collapsed behind "What this
   means" — read like the catalogue's details, not a legal notice. */
.licence-permits { color: var(--muted); font-size: var(--fs-note); margin-top: 4px; max-width: 70ch; }
.licence-means { margin-top: 4px; max-width: 70ch; }
.licence-means summary { cursor: pointer; color: var(--muted); font-size: var(--fs-note); }
.licence-means summary:hover { color: var(--highlight); }
.licence-means p { color: var(--muted); font-size: var(--fs-note); margin: 4px 0 0; line-height: 1.55; }
/* Explaining text behind a fold is bullet points — one fact per line, never
   a paragraph. Same block as the Workshop's. */
.fold-points { margin: 6px 0 0; padding-left: 18px; max-width: 72ch; font-size: var(--fs-note);
  color: var(--muted); line-height: 1.5; }
.fold-points li { margin: 3px 0; }
.fold-points ul { margin: 2px 0 0; padding-left: 18px; list-style: circle; }
.fold-points b, .fold-points code { color: var(--text); }
.model-card dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 18px; margin: 10px 0 0; }
.model-card dt {
  color: var(--muted); font-size:var(--fs-micro); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; align-self: center;
}
.model-card dd { margin: 0; font-size: var(--fs-body); }
.catalogue { margin-top: 14px; }
.catalogue summary {
  cursor: pointer; font-size:var(--fs-note); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.catalogue summary:hover { color: var(--highlight); }
.catalogue[open] summary { margin-bottom: 6px; }
.catalogue .table-scroll { max-height: 300px; overflow-y: auto; }
/* Per-track rights: each title opens to its rights record (or honest absence). */
.catalogue .cat-details summary {
  font-size: var(--fs-body); font-weight: 400; text-transform: none; letter-spacing: 0;
  color: var(--text); list-style: none; margin-bottom: 0;
}
.catalogue .cat-details summary::-webkit-details-marker { display: none; }
.catalogue .cat-details summary::before { content: "\25B8  "; color: var(--muted); font-size:var(--fs-note); }
.catalogue .cat-details[open] summary::before { content: "\25BE  "; }
.catalogue .cat-details[open] summary { color: var(--highlight); margin-bottom: 4px; }
.cat-rights { padding: 2px 0 6px 16px; font-size: var(--fs-note); color: var(--muted);
  display: flex; flex-direction: column; gap: 3px; }
.cat-pool { display: flex; gap: 10px; align-items: baseline; }
.cat-pool-label { min-width: 84px; font-size:var(--fs-micro); font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); }
.cat-pool b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-role { font-size:var(--fs-note); opacity: .8; }
.cat-codes { font-family: var(--mono, monospace); font-size:var(--fs-note); }
.model-card table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.model-card th, .model-card td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.model-card th { color: var(--muted); font-weight: 600; font-size:var(--fs-micro); text-transform: uppercase; letter-spacing: .07em; }
.model-card tr:last-child td { border-bottom: none; }

/* ── Creation panel ─────────────────────────────────────────────────────── */
.create-panel {
  margin-bottom: 30px; padding: 18px 20px 16px;
  background: var(--panel); border-radius: 12px;   /* tonal: no border (Stage) */
}
.create-panel h2 { font-size: var(--fs-note); text-transform: uppercase; letter-spacing: .08em; color: var(--highlight); margin-bottom: 10px; }
.lyrics-under { display: block; margin-top: 10px; font-size:var(--fs-micro); font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); }
.lyrics-under textarea { display: block; margin-top: 5px; min-height: 52px; }
.create-panel textarea#prompt, .create-panel textarea#lyrics {
  width: 100%; padding: 13px 15px; border-radius: 10px;
  background: var(--field); color: var(--text); border: 1px solid var(--border);
  font: inherit; font-size: var(--fs-ui); resize: vertical; line-height: 1.5; min-height: 74px;
}
.create-panel textarea:focus, .advanced-grid input:focus, .advanced-grid select:focus, .advanced-grid textarea:focus {
  outline: none; border-color: var(--highlight); box-shadow: 0 0 0 2px var(--highlight-glow);
}
.create-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.create-row .advanced { flex: 1; margin: 0; }
/* Generate and the Keeper toggle, side by side while Advanced is closed. */
.create-actions { display: flex; align-items: center; gap: 10px; }
.create-actions .keeper-opt { margin-left: 0; }
/* Advanced OPEN: the panel is a full-width row BELOW the buttons, which never move. */
.create-row .advanced-panel { flex-basis: 100%; }
.create-row .advanced-panel .advanced-grid { margin-top: 0; }

.advanced summary {
  cursor: pointer; color: var(--muted); font-size:var(--fs-note); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; display: inline-block;
}
.advanced summary:hover { color: var(--highlight); }
.advanced-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px;
  padding: 16px 18px; margin-top: 10px;
  background: var(--field); border: 1px solid var(--border); border-radius: 10px;
}
.advanced-grid label {
  display: flex; flex-direction: column;
  font-size:var(--fs-micro); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
}
.advanced-grid .span2 { grid-column: 1 / -1; }
.advanced-grid .check {
  flex-direction: row; align-items: center; gap: 8px; color: var(--text);
  flex-wrap: wrap; font-size: var(--fs-note); text-transform: none; letter-spacing: 0; font-weight: 500;
}
.advanced-grid .hint { color: var(--muted); font-size:var(--fs-micro); font-weight: 500; letter-spacing: .02em; text-transform: none; }
.advanced-grid input[type="number"], .advanced-grid input[type="text"],
.advanced-grid textarea {
  border-radius: 6px; background-color: var(--bg); color: var(--text);
  border: 1px solid var(--border); font-family: inherit;
}
.advanced-grid select, .advanced-grid textarea {
  padding: 7px 10px; font-size: var(--fs-body); font-weight: 400;
  letter-spacing: normal; text-transform: none; width: 100%;
}
.advanced-grid input[type="range"] { accent-color: var(--highlight); }
.advanced-grid input[type="file"] {
  color: var(--muted); font-size: var(--fs-note); font-family: inherit;
  letter-spacing: normal; text-transform: none;
}
.advanced-grid input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 5px 14px; font-size: var(--fs-note); border-radius: 999px;
  background: var(--field); color: var(--text); border: 1px solid var(--border);
  cursor: pointer; font-family: inherit; transition: background .15s, color .15s;
}
.advanced-grid input[type="file"]::file-selector-button:hover {
  background: var(--highlight); color: var(--ink-on-highlight);
}
.advanced-grid input[type="checkbox"] { accent-color: var(--highlight); width: 15px; height: 15px; }
.dice { background: none; border: none; cursor: pointer; font-size: var(--fs-body); padding: 0; }
.seed-row { display: flex; align-items: center; gap: 6px; }
.seed-row input { flex: 1; min-width: 0; }
/* ONE field shape on the create form: a label line (the name, its value at
   the right), a 40 px box on --radius — a slider sits inside one too, with
   the length's unit beside it — and the hint BELOW the box, never above it. */
.advanced-grid label { gap: 6px; }
.advanced-grid .label-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; }
.advanced-grid input[type="number"], .advanced-grid input[type="text"], .advanced-grid select { height: 40px; padding: 0 12px; border-radius: var(--radius); width: 100%; box-sizing: border-box; }
.advanced-grid select { padding-right: 26px; }
.advanced-grid .range-box { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; box-sizing: border-box; background-color: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.advanced-grid .range-box input[type="range"] { flex: 1; min-width: 0; margin: 0; }
.advanced-grid .range-box .length-unit { flex: 0 0 auto; align-self: center; width: auto; height: 28px; padding: 0 24px 0 10px; font-size: var(--fs-note); text-transform: none; letter-spacing: 0; border-radius: 6px; background-position: right 8px center; }   /* centred in the slider's box */
.advanced-grid .seed-row { gap: 8px; }
.advanced-grid .seed-row .dice { width: 40px; height: 40px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: var(--radius); background-color: var(--bg); }
.advanced-grid .check { min-height: 40px; }

#generate-btn {
  padding: 10px 30px; font: inherit; font-size: var(--fs-body); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-on-highlight); background: var(--highlight); border: 1px solid var(--highlight);
  border-radius: 999px; cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  box-shadow: 0 0 14px var(--highlight-glow);
}
#generate-btn:hover { background: color-mix(in srgb, var(--highlight) 82%, black); box-shadow: 0 0 22px var(--highlight-glow); }
#generate-btn:disabled { opacity: .45; cursor: default; box-shadow: none; transform: none; }

/* ── .k-btn: the shared button system both rooms adopt ──────────────────
   #generate-btn and the per-context *-btn rules are legacy. New buttons in
   either room use .k-btn + one variant; tokens only, no literal colours. */
.k-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  font-family: inherit; font-size: var(--fs-ui); font-weight: 600; line-height: 1;
  color: var(--text); background: transparent; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, color .12s, border-color .15s, box-shadow .15s, transform .15s;
}
.k-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--highlight-glow); }
.k-btn--primary { background: var(--highlight); color: var(--ink-on-highlight); border-color: var(--highlight); }
.k-btn--primary:hover { background: color-mix(in srgb, var(--highlight) 82%, black); border-color: color-mix(in srgb, var(--highlight) 82%, black); box-shadow: 0 0 14px var(--highlight-glow); }   /* darkens under the pointer, never moves */
.k-btn--secondary { background: transparent; color: var(--highlight); border-color: var(--border-light); }
.k-btn--secondary:hover { background: var(--field); border-color: var(--highlight); }
.k-btn--quiet { background: transparent; color: var(--muted); border-color: transparent; }
.k-btn--quiet:hover { color: var(--text); background: var(--panel-hover); }
.k-btn--danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.k-btn--danger:hover { background: var(--danger); color: var(--ink-on-danger); border-color: var(--danger); }
.k-btn--sm { height: 32px; padding: 0 12px; font-size: var(--fs-body); }
.k-btn:disabled, .k-btn[aria-disabled="true"] { opacity: .5; cursor: default; box-shadow: none; transform: none; }

.job-status { margin-top: 12px; display: flex; align-items: center; gap: 14px; }
.bar { flex: 1; height: 6px; background: var(--field); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: 0%; background: var(--highlight); box-shadow: 0 0 10px var(--highlight-glow); transition: width .3s; }
#job-label { color: var(--muted); font-size:var(--fs-note); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; white-space: nowrap; }

/* ── Outputs feed: take cards (the .take-card* block sits after the player bar) ── */
.history h2 { font-size: var(--fs-note); text-transform: uppercase; letter-spacing: .08em; color: var(--highlight); margin-bottom: 12px; }

/* In flight: a job is a take card before it is an output (.take-card.pending,
   08-generate) — the same row, a spinner for the thumbnail, the silhouette
   wave that fills with the render in .take-wave, and its Cancel. */
.queue-summary { color: var(--muted); font-size:var(--fs-note); text-transform: uppercase; letter-spacing: .06em;
                 font-weight: 600; margin-bottom: 8px; }
.pending-list { margin-bottom: 6px; }
.pending-list:empty { display: none; }
.take-thumb.cover-pending {
  display: flex; align-items: center; justify-content: center;
  cursor: default; background: var(--field); color: var(--highlight);
}
.pending-spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-light); border-top-color: var(--highlight);
  animation: pending-spin 1s linear infinite;
}
.take-card.pending.queued .pending-spin { animation-duration: 3s; opacity: .55; }
@keyframes pending-spin { to { transform: rotate(360deg); } }
.pw-layer { position: absolute; inset: 0; display: flex; align-items: center; gap: 1px; padding: 0 4px; }
.pw-layer i { flex: 1; min-width: 1px; border-radius: 2px; background: var(--border-light); }
.pw-fill { clip-path: inset(0 100% 0 0); transition: clip-path .7s linear; }
.pw-fill i { background: var(--highlight); box-shadow: 0 0 6px var(--highlight-glow); }
/* The pending card's actions are words (▲ ▼ ✕ while queued, Cancel while
   rendering): pills, not the row's round icon buttons. */
.take-card.pending .take-actions button {
  padding: 4px 11px; font-size: var(--fs-note); line-height: 1.4; border-radius: 999px; font-family: inherit;
  background: var(--field); color: var(--text); border: 1px solid var(--border); transition: background .15s, color .15s;
}
.take-card.pending .take-actions .move-btn, .take-card.pending .take-actions .remove-btn { padding: 4px 8px; min-width: 28px; }
.take-card.pending .take-actions .move-btn:disabled { opacity: .35; cursor: default; }
.take-card.pending .take-actions .move-btn:disabled:hover { background: var(--field); color: var(--text); border-color: var(--border); }
.take-card.pending .take-actions .remove-btn:hover,
.take-card.pending .take-actions .cancel-btn:hover,
.take-card.pending .take-actions .cancel-btn.confirming {
  background: var(--danger); border-color: var(--danger); color: var(--ink-on-danger);
}
.take-card.pending .take-actions .cancel-btn.confirming { font-weight: 600; }
.take-card.pending .take-actions .cancel-btn:disabled { opacity: .55; cursor: default; }
.take-card.pending .take-actions .cancel-btn:disabled:hover { background: var(--field); color: var(--text); border-color: var(--border); }
@media (prefers-reduced-motion: reduce) {
  .pending-spin { animation: none; border-top-color: var(--border-light); }
  .pw-fill { transition: none; }
}

.lineage-chip {
  display: inline-block; background: var(--field); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 8px; font-size: var(--fs-micro); color: var(--cyan);
  margin-right: 6px; vertical-align: middle;
}
.cover {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #03080999);
  border: none; cursor: pointer; color: #f0f9f9; font-size: var(--fs-ui);
  transition: box-shadow .15s;
}
.cover:hover { box-shadow: 0 0 12px var(--highlight-glow); }
/* The take card's fold: the action row (the name field, then Pick, Rework,
   Stems, Attribution, Provenance, Delete as pills) and the details line. */
.take-fold-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.take-fold-actions button {
  padding: 4px 11px; font-size: var(--fs-note); border-radius: 999px; text-decoration: none;
  background: var(--field); color: var(--text); border: 1px solid var(--border);
  cursor: pointer; font-family: inherit; transition: background .15s, color .15s;
}
.take-fold-actions button:hover { background: var(--highlight); color: var(--ink-on-highlight); }
.take-fold-actions .delete-btn:hover { background: var(--danger); border-color: var(--danger); color: var(--ink-on-danger); }
.take-fold-actions .delete-btn.confirming {
  background: var(--danger); border-color: var(--danger); color: var(--ink-on-danger); font-weight: 600;
}
/* Adapter off — reference: Rework stays in its slot, disabled and muted,
   so the row keeps its shape and the title says why (Workshop parity). */
.take-fold-actions .variations-toggle:disabled { opacity: .45; cursor: default; }
.take-fold-actions .variations-toggle:disabled:hover {
  background: var(--field); color: var(--text); border-color: var(--border);
}
.take-details { margin-top: 8px; font-size: var(--fs-note); color: var(--muted); line-height: 1.9; }
.take-details:empty { display: none; }
.variations-row {
  /* Column stack: full-width waveform on top, hint, then the control row. */
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  margin-top: 8px; padding: 12px 14px;
  background: var(--field); border: 1px solid var(--border); border-radius: 8px;
}
.variations-row label {
  display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 180px;
  font-size:var(--fs-micro); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
}
.variations-row input[type="range"] { accent-color: var(--highlight); }
.variations-row .variations-go,
.variations-row .repaint-go,
.variations-row .extend-go,
.variations-row .reinterpret-go,
#cover-go,
#verify-go {
  padding: 6px 16px; font-size: var(--fs-note); font-weight: 600; font-family: inherit;
  color: var(--ink-on-highlight); background: var(--highlight); border: 1px solid var(--highlight);
  border-radius: 999px; cursor: pointer;
  transition: box-shadow .15s;
}
.variations-row .variations-go:hover,
.variations-row .repaint-go:hover,
.variations-row .extend-go:hover,
#cover-go:hover,
#verify-go:hover { box-shadow: 0 0 14px var(--highlight-glow); }
/* "More like this" sits beside the primary Reinterpret as its quieter
   sibling: the same pill, outlined. */
.rework-group .more-like-btn {
  padding: 6px 16px; font-size: var(--fs-note); font-weight: 600; font-family: inherit;
  color: var(--highlight); background: transparent; border: 1px solid var(--highlight);
  border-radius: 999px; cursor: pointer; transition: box-shadow .15s, background .15s;
}
.rework-group .more-like-btn:hover { box-shadow: 0 0 14px var(--highlight-glow); }
.variations-row .repaint-go:disabled,
#cover-go:disabled,
#verify-go:disabled { opacity: .45; cursor: default; box-shadow: none; }

/* Verify result: same field surface as the provenance card */
.verify-result {
  background: var(--field); border: 1px solid var(--border-light);
  border-radius: 10px; padding: 10px 14px; font-size: var(--fs-body); line-height: 1.55;
}
.verify-result .ok { color: var(--highlight); font-weight: 600; }
.verify-result .warn { color: var(--muted); font-weight: 600; }
.verify-result code { font-family: var(--mono, monospace); font-size: var(--fs-note); }
/* Structured verify card: verdict header, identity lines, divided sections. */
.verify-result .v-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.verify-result .v-conf { font-size:var(--fs-note); color: var(--muted); font-variant-numeric: tabular-nums; }
.verify-result .v-artist { font-size: var(--fs-body); margin-top: 6px; }
/* The Guild seal in the result's top-right corner when the embedded ID was
   read and confirmed: the seal shows wherever the watermark ID does. */
.verify-result { position: relative; }
.verify-result .v-seal { position: absolute; top: 12px; right: 12px; width: 96px; height: 96px; }
.verify-result:has(.v-seal) .v-head, .verify-result:has(.v-seal) .v-artist, .verify-result:has(.v-seal) .v-id { padding-right: 112px; }
.verify-result .v-id { color: var(--muted); font-size: var(--fs-note); margin-top: 2px; }
.verify-result .v-id code { color: var(--text); }
.verify-result .v-sec, .verify-result .v-note {
  margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border);
}
.verify-result .v-note { color: var(--muted); font-size: var(--fs-note); }
.verify-result .v-note + .v-note { border-top: none; margin-top: 4px; padding-top: 0; }
.verify-result .v-label {
  display: block; font-size:var(--fs-micro); font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); margin-bottom: 3px;
}
.verify-result .v-body { font-size: var(--fs-note); }
.verify-result .v-pools { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; }
.verify-result .v-pool-label { color: var(--muted); font-size: var(--fs-note); white-space: nowrap; padding-top: 1px; }
.verify-result .v-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.verify-result .v-dot { color: var(--muted); padding: 0 6px; }
.verify-note { margin-top: 12px; font-size: var(--fs-note); color: var(--muted); line-height: 1.65; }
.rework-wave-gone { display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--muted); font-size: var(--fs-note); }

/* The Artist Compact: a document, not a dashboard — prose panels. */
.promise-terms { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.promise-terms article {
  background: var(--panel); border: 1px solid var(--border-light);
  border-left: 3px solid var(--highlight); border-radius: var(--radius);
  padding: 16px 20px;
}
.promise-terms h2 { font-size: var(--fs-body); margin-bottom: 6px; color: var(--highlight); }
.promise-terms p { font-size: var(--fs-body); line-height: 1.7; color: var(--text); }
.promise-terms .licence-means p { color: var(--muted); font-size: var(--fs-note); line-height: 1.55; }   /* the fold reads as the licence fold does, not as the article */
.promise-terms a { color: var(--cyan); }

/* Simple mode: ghost pill + explanation under the prompt box */
.simple-mode { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.simple-mode button {
  padding: 5px 14px; font-size: var(--fs-note); font-weight: 600; font-family: inherit;
  color: var(--cyan); background: none; border: 1px solid var(--border-light);
  border-radius: 999px; cursor: pointer;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.simple-mode button:hover { border-color: var(--highlight); color: var(--highlight); box-shadow: 0 0 10px var(--highlight-glow); }
.simple-mode button:disabled { opacity: .5; cursor: default; box-shadow: none; }
.simple-hint { font-size: var(--fs-note); color: var(--muted); }
.provenance { margin: 8px 0 2px; }

/* ── Generation families: version chips (.take-versions), the live wave (.take-wave), stems lanes ── */
.fam-chip {
  padding: 3px 11px; font-size:var(--fs-note); font-weight: 600; border-radius: 999px;
  background: var(--field); color: var(--muted); border: 1px solid var(--border);
  cursor: pointer; font-family: inherit; transition: background .12s, color .12s;
}
.fam-chip:hover { color: var(--text); border-color: var(--border-light); }
.fam-chip.active { background: var(--accent); color: var(--ink-on-highlight); border-color: transparent; }
.wave-note { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 30px; color: var(--muted); font-size:var(--fs-note); padding: 6px; flex-wrap: wrap; }
.fam-stems { margin-top: 8px; padding: 10px 12px; background: var(--field); border: 1px solid var(--border); border-radius: 8px; }
.fam-stems-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.fam-stem-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.fam-stem-label { font-size:var(--fs-micro); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); width: 52px; flex-shrink: 0; }
.fam-stem-wave { flex: 1; background: var(--panel); border-radius: 4px; overflow: hidden; min-width: 0; }
/* M / S: DAW mute and solo. Engaged state is the pill flipping — mute to
   the danger outline, solo to the accent fill (aria-pressed is the state;
   the buttons are keyboard-reachable). */
.fam-stem-btn { margin-top: 0; min-width: 30px; padding: 3px 0; text-align: center; font-weight: 700; font-size:var(--fs-note); flex-shrink: 0; }
.fam-stem-mute[aria-pressed="true"] { background: none; border-color: var(--danger); color: var(--danger); }
.fam-stem-mute[aria-pressed="true"]:hover { background: var(--danger); color: var(--ink-on-danger); }
.fam-stem-solo[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: var(--ink-on-highlight); }
.fam-stem-btn:disabled { opacity: .4; cursor: default; }
.fam-stem-btn:disabled:hover { background: var(--field); color: var(--text); }
/* Repainted/extended spans: one tint everywhere (--repaint-tint), the label
   centred in the span. WaveSurfer renders into a SHADOW ROOT, so only
   ::part() reaches the Regions plugin's elements; a descendant selector is
   silently inert. The plugin's inline padding needs !important to lose. */
.take-wave > div::part(region), .rework-wave > div::part(region), .rework-lane-wave > div::part(region) {
  display: flex; align-items: center; justify-content: center; }
.take-wave > div::part(region-content), .rework-wave > div::part(region-content),
.rework-lane-wave > div::part(region-content) {
  font-size:var(--fs-micro); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text); background: color-mix(in srgb, var(--bg) 70%, transparent);
  padding: 1px 8px !important; margin-top: 0 !important; border-radius: 999px;
  line-height: 1.6; max-width: calc(100% - 6px); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; pointer-events: none;
  text-shadow: 0 0 4px color-mix(in srgb, var(--bg) 90%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--highlight) 35%, transparent);
}

/* ── Player bar: the Stage shape ──────────────────────────────────────────
   116 px along the bottom of the artist page (a scoped --player-h: the
   :root token stays 76 px). Mirrored in the Workshop with these class
   names: .stage-player, .stage-player-left / -centre / -right,
   .stage-player-pill. Left: thumbnail, name, artist · adapter, the Keep
   mark, More. Centre: the working waveform inside #player-progress, a
   hairline progress under it, the times at its ends. Right: the transport
   above the volume slider and the record's pill. No loop button, no fold,
   no zoom. */
body.space-page { --player-h: 116px; }
.player-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  height: var(--player-h);
  padding: 0 20px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.stage-player {
  display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 2fr) auto;   /* the right column is its content's width: the wave runs up to the volume */
  align-items: center; gap: 24px;
}
.stage-player-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.stage-player-thumb {
  position: relative; width: 64px; height: 64px; border-radius: 4px; overflow: hidden; flex-shrink: 0;
  border: none; padding: 0; cursor: pointer; color: var(--text);
  background: linear-gradient(160deg, var(--cover-a), var(--cover-b));
}
.stage-player-thumb .stage-cover-bars { opacity: .85; }
.stage-player-thumb:disabled { cursor: default; opacity: .5; }
.stage-player-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.player-title {
  font-size: var(--fs-ui); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-artist { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-player-left .keep-btn { flex-shrink: 0; border: 1px solid transparent; background: none; border-radius: 999px; cursor: pointer; }
.stage-player-more {
  flex-shrink: 0; border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 4px; line-height: 0; border-radius: 50%; transition: color .12s;
}
.stage-player-more:hover { color: var(--text); }
.stage-player-centre { display: flex; flex-direction: column; align-items: center; min-width: 0; }   /* the wave alone; the transport is in the right column */
.stage-player-controls { display: flex; gap: 26px; align-items: center; justify-content: center; flex: 0 0 auto; }   /* pinned to the top of the right column */
.stage-player-ctl {
  width: 32px; height: 32px; border: none; background: none; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; padding: 0;
  transition: color .12s;
}
.stage-player-ctl:hover { color: var(--highlight); }
.stage-player-ctl:disabled { opacity: .35; cursor: default; }
.player-play {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--text); color: var(--bg); border: none; cursor: pointer;
  font-size: var(--fs-body); transition: transform .12s;
}
.player-play:hover { transform: scale(1.06); }
.player-play:disabled { opacity: .35; cursor: default; transform: none; }
.stage-player-line { display: flex; gap: 12px; align-items: center; width: 100%; }
.stage-player-time {
  font-family: ui-monospace, Menlo, monospace; font-size: var(--fs-note); color: var(--muted);
  font-variant-numeric: tabular-nums; min-width: 34px; text-align: center;
}
.stage-player-progress { position: relative; flex: 1; height: calc(var(--player-h) - 32px); border-radius: 4px; cursor: pointer; }   /* follows the bar's drag: the wave (02 barWaveHeight, bar − 36) is this box minus the 4 px under .player-wave */
.stage-player-progress:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--highlight-glow); }
.stage-player-progress-fill { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; border-radius: 2px; background: var(--text); }
.player-wave { position: absolute; inset: 0 0 4px; border-radius: 4px; overflow: hidden; }
.stage-player-right { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 0; min-width: 0; align-self: stretch; padding-top: 0; }   /* the transport and the volume row evenly spaced down the column */
.stage-player-right-row { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.stage-player-pill {
  display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--highlight) 50%, transparent);
  color: var(--highlight); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.player-vol { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.player-vol svg { width: 18px; height: 18px; flex-shrink: 0; }
.player-vol input[type="range"] { width: 90px; height: 12px; cursor: pointer; accent-color: var(--highlight); }

/* ── Take card: ONE row-card for everything you listen to ───────────────
   Thumbnail · title and subtitle (versions beneath) · a small static
   waveform from cached peaks that becomes the live wave while playing ·
   length and date · Keep, Export, More. More opens the fold beneath.
   Mirrored VERBATIM between the Space (canon) and the Workshop. */
.take-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.take-card { background: var(--panel); border-radius: 12px; padding: 10px 14px; transition: background .12s; }
.take-card:hover { background: var(--panel-hover); }
.take-card.playing { background: var(--panel-hover); box-shadow: inset 0 0 0 1px var(--border-light); }
.take-row { display: grid; grid-template-columns: 44px minmax(180px, .9fr) minmax(0, 2fr) auto auto; gap: 14px; align-items: center; }
.take-thumb { position: relative; width: 44px; height: 44px; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 4px; overflow: hidden; color: var(--text); flex-shrink: 0; }
.take-thumb .stage-play-glyph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .12s; }
.take-thumb:hover .stage-play-glyph, .take-card.playing .take-thumb .stage-play-glyph { opacity: 1; }
.take-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.take-title { font-size: var(--fs-ui); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.take-card.kept .take-title { color: var(--highlight); }
.take-sub { font-size: var(--fs-note); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.take-sub:empty { display: none; }
.take-versions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.take-versions:empty { display: none; }
.take-wave { position: relative; height: 48px; border-radius: 6px; overflow: hidden; cursor: pointer; min-width: 0; background: var(--field); transition: height .15s; }
.take-wave:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--highlight-glow); }
.take-peaks { display: block; width: 100%; height: 100%; }
.take-peaks rect { fill: var(--muted); opacity: .55; }
.take-card.kept .take-peaks rect { fill: var(--highlight); opacity: .5; }
.take-card.playing .take-wave { height: 64px; }
.take-wave.live .take-peaks { opacity: 0; }
.take-wave > div { position: absolute; inset: 0; }
.take-facts { font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; text-align: right; }
.take-actions { display: flex; align-items: center; gap: 2px; }
.take-actions button, .take-actions a { display: inline-flex; padding: 6px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 50%; line-height: 0; text-decoration: none; }
.take-actions button:hover, .take-actions a:hover { color: var(--text); background: var(--pill); }
.take-actions .keep-btn.kept { color: var(--highlight); }
.take-actions .more-btn[aria-expanded="true"] { color: var(--text); background: var(--pill); }
.take-fold { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.take-card.pending .take-wave { cursor: default; }
@media (max-width: 760px) {
  .take-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .take-wave, .take-facts { display: none; }
}

.colophon {
  margin-top: 40px; color: var(--muted); font-size:var(--fs-micro);
  text-transform: uppercase; letter-spacing: .08em; opacity: .7;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    padding: 10px 14px; overflow-x: auto; gap: 10px;
  }
  .sidebar-brand { border: none; padding: 0 10px 0 0; }
  .sidebar-scroll { flex-direction: row; align-items: center; gap: 10px; overflow: visible; min-height: auto; }
  .sidebar-nav { flex-direction: row; padding: 0; align-items: center; }
  .nav-heading, .sidebar-foot, #global-activity { display: none; }
  .main { padding: 20px 16px calc(var(--player-h) + 30px); }
  .advanced-grid { grid-template-columns: 1fr; }
  .stage-player { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .stage-player-right, .stage-player-line, .stage-player-more { display: none; }
  .stage-hero-grid { grid-template-columns: 1fr; }
  .stage-hero-seal { display: none; }   /* the small seal on the artwork carries it on a phone */
  .stage-cover-wrap, .stage-cover { width: 100%; max-width: 300px; }
}

/* ── Sidebar base (Shut Down and the switches) ─────────────────────────── */
.sidebar-base { padding: 14px 8px 2px; margin-top: 10px;
  border-top: 1px solid var(--border); text-align: center; }
.sidebar-base .shutdown-btn { margin: 0; width: 100%; }
/* The shell's two drag handles: the sidebar's right edge and the bar's top
   edge; --sidebar-w / --player-h are set on body by shell.js and remembered
   per browser (khaos.sidebarW / khaos.playerH). */
.sidebar-resizer {
  position: absolute; top: 0; bottom: 0; z-index: 150;
  left: calc(var(--sidebar-w) - 3px); width: 6px;
  cursor: col-resize;
  transition: background .12s;
}
.player-resizer {
  position: absolute; top: -3px; left: 0; right: 0; height: 6px;
  cursor: row-resize; z-index: 1;
  transition: background .12s;
}
.sidebar-resizer:hover, .sidebar-resizer.dragging,
.player-resizer:hover, .player-resizer.dragging { background: var(--highlight-glow); }

/* ── MCP / agent surface ─────────────────────────────────────────────────── */
.chip-agent {
  margin-left: 6px; padding: 1px 5px; border: 1px solid var(--border-light);
  border-radius: 4px; font-size:var(--fs-micro); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--highlight);
}
.mcp-tools td:first-child { font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--fs-note); color: var(--highlight); white-space: nowrap; }
.mcp-note-block {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--fs-note);
  line-height: 1.7; color: var(--muted); background: var(--field);
  border-radius: var(--radius); padding: 12px 14px; overflow-x: auto;
}
.mcp-cmd { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--fs-note);
  color: var(--highlight); background: var(--field); border-radius: 6px;
  padding: 6px 10px; display: block; overflow-x: auto; white-space: pre; }


/* Every wait shows work: attach .working to any control whose action is
   in flight. Indeterminate by design — when there is no honest progress
   number, motion says "alive", text says what is happening. */
.working { position: relative; opacity: .85; }
.working::after {
  content: ""; display: inline-block; width: 10px; height: 10px;
  margin-left: 8px; vertical-align: -1px; border-radius: 50%;
  border: 2px solid var(--highlight); border-top-color: transparent;
  animation: khaos-spin .8s linear infinite;
}
@keyframes khaos-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .working::after { animation: none; opacity: .6; }
}

/* ── Expand idea: the preview under the prompt (identical in both apps) ── */
.expand-preview {
  margin-top: 8px; padding: 10px 12px; border: 1px solid var(--border);
  border-left: 3px solid var(--highlight); border-radius: 6px; background: var(--bg);
  display: flex; flex-direction: column; gap: 8px;
}
.expand-from { font-size: var(--fs-note); color: var(--muted); }
.expand-from q { color: var(--text); font-style: italic; quotes: "“" "”"; }
.expand-meta { color: var(--muted); opacity: .8; }
/* Asked-for language vs the language the model says it wrote. Shown only
   when they disagree, so it is never decoration — it is the one signal
   that the named language did not take. */
.expand-warn {
  margin-top: 6px; font-size: var(--fs-note); line-height: 1.45;
  color: var(--warn); border-left: 2px solid var(--warn); padding-left: 8px;
}
.expand-warn em { font-style: normal; color: var(--text); }
.expand-text {
  width: 100%; resize: vertical; font-family: inherit; font-size: var(--fs-body); line-height: 1.5;
  color: var(--text); background: var(--surface, transparent); border: 1px solid var(--border);
  border-radius: 4px; padding: 8px 10px;
}
.expand-opt { display: flex; align-items: center; gap: 8px; font-size: var(--fs-note); color: var(--text); cursor: pointer; }
.expand-opt input { accent-color: var(--highlight); }
.expand-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Keeper and closest marks (identical in both apps) ─────────────────── */
.keeper-opt { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-note); color: var(--muted); cursor: pointer; margin-left: 10px; }
.keeper-opt input { accent-color: var(--highlight); }
.keeper-badge, .closest-mark {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  font-size:var(--fs-micro); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--highlight); border: 1px solid color-mix(in srgb, var(--highlight) 45%, transparent);
  vertical-align: middle;
}
.fam-chip.closest { box-shadow: 0 0 0 1px color-mix(in srgb, var(--highlight) 55%, transparent); }
.fam-chip.closest::after { content: " ★"; }
/* A base keeper without its checkpoint: said on the form, before the click. */
.keeper-fallback { margin-top: 6px; font-size: var(--fs-note); color: var(--danger); }
/* A chip that carries a warning (turbo fallback), and the loudness read-out. */
.lineage-chip.warn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
/* Adapter off — reference: the base model alone, never a keeper, no Keep. */
.keeper-badge.adapter-off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.lineage-chip.quiet { color: var(--muted); }
/* Best-of pick: the chosen one keeps its mark for the session. */
.pick-btn.picked { background: var(--highlight); color: var(--ink-on-highlight); border-color: var(--highlight); }
/* Keep is the Khaos mark: dim to keep, lit when kept; it turns on hover and
   keyboard focus. The transform lives on the mark, never the button, so
   nothing around it moves. The Workshop's .keep-star mirrors this. */
.keep-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; }
.keep-btn .keep-mark {
  width: 16px; height: 16px; object-fit: contain; flex-shrink: 0; opacity: .55;
  filter: drop-shadow(0 0 5px var(--highlight-glow));
  transition: transform .4s cubic-bezier(.25, 1, .5, 1), opacity .4s ease;
}
.keep-btn:hover .keep-mark, .keep-btn:focus-visible .keep-mark { opacity: 1; transform: rotate(45deg) scale(1.1); }
/* Kept: the button lights, the mark goes BLACK on it and holds still. */
.keep-btn.kept { background: var(--highlight); border-color: var(--highlight); }
.keep-btn.kept .keep-mark, .keep-btn.kept:hover .keep-mark, .keep-btn.kept:focus-visible .keep-mark {
  opacity: 1; filter: brightness(0); transform: none; }
@media (prefers-reduced-motion: reduce) {
  .keep-btn .keep-mark { transition: opacity .4s ease; }
  .keep-btn:hover .keep-mark, .keep-btn:focus-visible .keep-mark { transform: none; }
}
/* "More like this one": the audio-to-audio panel seeded from a kept take. */
.cover-source { display: flex; align-items: center; gap: 10px; font-size: var(--fs-body); color: var(--muted); }
.cover-source b { color: var(--text); }
.cover-source button { font-size:var(--fs-note); padding: 2px 8px; }

/* A control wearing its own error for a moment (the dialog-free idiom). */
.flash-err { color: var(--danger) !important; border-color: var(--danger) !important; }
/* A teal primary cannot carry red text: while it flashes a refusal it IS the danger button. */
.k-btn--primary.flash-err, #generate-btn.flash-err { background: var(--danger) !important; color: var(--ink-on-danger) !important; box-shadow: none; }

/* ── Named takes, in the artist's order (mirrored in the Workshop) ───────
   The name field sits on the version rail, one line, for the selected
   version; the sequence sits above the feed. Same tokens as the rail. */
.take-name {
  flex: 1 1 160px; min-width: 120px; max-width: 320px; padding: 3px 10px;
  font-size: var(--fs-note); font-family: inherit; border-radius: 6px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.take-name::placeholder { color: var(--muted); }
.take-name:focus { outline: none; border-color: var(--highlight); box-shadow: 0 0 0 2px var(--highlight-glow); }
/* The kept rail: tonal, one 176 px tile per kept take — a generated cover
   with the play on it, the name, the file beneath, the ordering arrows.
   Draws even when empty (one muted line). */
.kept-order { margin: 0 0 12px; padding: 12px 14px; background: var(--panel); border-radius: 12px; }
.kept-empty { font-size: var(--fs-note); color: var(--muted); }
.kept-order-title { font-size: var(--fs-micro); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--highlight); margin-bottom: 8px; }
.kept-rail { list-style: none; margin: 0; padding: 2px 0 6px; display: flex; gap: 16px; overflow-x: auto; }
.kept-tile { flex: 0 0 176px; width: 176px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kept-tile-cover {
  position: relative; width: 176px; height: 176px; border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--cover-a), var(--cover-b));
}
.kept-tile-cover .stage-cover-bars { opacity: .85; }
.kept-tile-cover .kept-play {
  position: relative; width: 44px; height: 44px; border-radius: 50%; font-size: var(--fs-ui);
  background: var(--highlight); color: var(--ink-on-highlight); border: none; cursor: pointer;
  box-shadow: 0 0 14px var(--highlight-glow); opacity: 0; transition: opacity .12s;
}
.kept-tile-cover:hover .kept-play, .kept-tile-cover .kept-play:focus-visible { opacity: 1; }
.kept-name { font-size: var(--fs-body); font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.kept-name.quiet { color: var(--muted); font-weight: 400; }
.kept-file { font-size: var(--fs-micro); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kept-move { display: flex; gap: 4px; margin-top: 2px; }
.kept-move .move-btn { padding: 2px 8px; min-width: 26px; font-size: var(--fs-note); border-radius: 999px; background: var(--field); color: var(--text); border: 1px solid var(--border); cursor: pointer; font-family: inherit; }
.kept-move .move-btn:disabled { opacity: .35; cursor: default; }
/* The Length unit select, inline under the label; the bars field beside it. */
.advanced-grid #bars { width: 110px; padding: 6px 8px; font-size: var(--fs-body); }


/* ⓘ on a click: the hint's words in a note right after the icon (shell hint handler). */
.hint-pop { display: block; margin: 6px 0 4px; padding: 8px 10px; max-width: 60ch; font-size: var(--fs-note);
  line-height: 1.5; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.hint-pop ul { margin: 0; padding-left: 18px; }
.hint-pop li { margin: 2px 0; }

/* ── Stage: the hero's pills, a jump's flash ──────────────────────────────
   DESIGN.md "Stage" is the spec. The sidebar is the whole navigation; the
   take card is the only view of a list you listen to. */

/* The hero's pills: the 54 px size the header row uses, and the grey one. */
.k-btn--hero { height: 54px; padding: 0 34px; font-size: var(--fs-lead); font-weight: 700; }
.k-btn--grey { background: var(--pill); color: var(--text); border-color: transparent; }
.k-btn--grey:hover { background: var(--panel-hover); }

/* The take card's thumbnail wears the cover gradient under its seeded bars
   (the same cover the rail, the bar and the hero draw). */
.take-thumb .stage-cover-bars { background: linear-gradient(160deg, var(--cover-a), var(--cover-b)); opacity: .85; }
/* A jump (the bar's More) lights its target for a moment. */
.jumped { box-shadow: 0 0 0 2px var(--highlight-glow); transition: box-shadow .3s; }

/* ── Utilities: the inline styles the pages and scripts carried, as classes.
   State a script computes (a progress width, a cover url, an artist's
   --accent) stays inline: it is a value, not a style. ── */
.u-hint { cursor: help; color: var(--muted); }   /* an ⓘ: shell.js opens it on click and keyboard */
.u-micro { font-size: var(--fs-micro); }
.u-mt-10 { margin-top: 10px; }
.u-ml-auto { margin-left: auto; }

/* The farewell after Shut Down (shell.js renderFarewell). */
.farewell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 16px; padding: 20px; text-align: center;
  background: var(--bg); color: var(--text);
}
.farewell-logo { height: 96px; width: auto; filter: drop-shadow(0 0 14px var(--highlight-glow)); }
:root[data-theme="light"] .farewell-logo { filter: brightness(0) drop-shadow(0 0 14px var(--highlight-glow)); }
.farewell-title { font-size: var(--fs-h2); font-weight: 800; letter-spacing: .22em; }
.farewell-body { color: var(--muted); max-width: 460px; line-height: 1.65; }
.farewell-note { color: var(--muted); font-size: var(--fs-note); }
.farewell-back { color: var(--cyan); font-size: var(--fs-note); }
/* The disclosure every piece carries, before its title. */
.ai-badge {
  display: inline-block; margin-right: 8px; padding: 1px 6px; border-radius: 999px;
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .06em;
  color: var(--muted); border: 1px solid color-mix(in srgb, var(--muted) 45%, transparent);
  vertical-align: middle;
}
/* The legal pages: plain headings over the fold-point lists; the operator named the same way everywhere. */
.legal-text h2 { font-size: var(--fs-lead); margin: 20px 0 8px; }
.legal-who { color: var(--muted); }
.sidebar-legal { margin-top: 8px; font-size: var(--fs-micro); }
.sidebar-legal a { color: var(--muted); }
.pilot-report { border-top: 1px solid color-mix(in srgb, var(--muted) 25%, transparent); padding: 10px 0; }
