:root {
  --bg: #000;
  --panel: rgba(18, 18, 22, 0.82);
  --line: rgba(255, 255, 255, 0.10);
  --text: rgba(255, 255, 255, 0.88);
  --muted: rgba(255, 255, 255, 0.45);
  --accent: #7dd3fc;
}

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

/* `display` in the rules below would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  display: grid;
  place-items: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  font: 12px/1.4 ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  color: var(--text);
}

#ring { display: block; position: relative; z-index: 1; }

/* ------------------------------------------------------------- panel --- */

/* A drawer flush to the left edge rather than a card floating in space: it
   spans the full height, and slides out on its own transform so the open and
   shut states animate instead of snapping. */
.panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 268px;
  max-width: 88vw;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  z-index: 10;
  transform: translateX(-100%);
  transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.panel.open { transform: none; }

/* Kept out of the pointer's way while shut, so the strip it covers still
   passes clicks through to the circle behind it. */
.panel:not(.open) { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}

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

.title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* The title is a link home. It has to keep looking like a title rather than
   growing an underline and a blue: the point is that it is there when you want
   it, not that it advertises itself over the picture. */
.mark-home {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 160ms;
}
.mark-home img { display: block; border-radius: 4px; }
.mark-home:hover { background: rgba(255, 255, 255, 0.07); }
.mark-home:focus-visible { outline: 2px solid var(--accent, #7dd3fc); outline-offset: 2px; }

/* What is playing on all three layers, whatever tab is open. Each chip steps
   its own layer, so the strip is a readout and a control at once. */
.chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 5px 6px;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.chip:hover { background: rgba(255, 255, 255, 0.12); }
/* A layer that is switched off says so, and reads as inactive. */
.chip.off { opacity: 0.5; }
.chip.off span { color: var(--muted); font-style: italic; }

.chip b {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip span {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sep {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.row { display: flex; align-items: center; gap: 6px; }
.row.buttons { margin-top: 4px; }
.grow { flex: 1; min-width: 0; }

.ctl {
  display: grid;
  grid-template-columns: 44px 1fr 42px;
  align-items: center;
  gap: 8px;
}

.ctl.bpm { grid-template-columns: 44px 1fr 50px; }

/* Dimmed once a manual speed change has taken the ring off the beat. */
.ctl.bpm.off > select, .ctl.bpm.off > input { opacity: 0.45; }

/* The YouTube link box borrows the number field's dressing. */
input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 5px 7px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 7px;
}
input[type="text"]::placeholder { color: var(--muted); }
input[type="text"]:focus { outline: 1px solid var(--accent); background: rgba(255, 255, 255, 0.14); }

input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 5px 4px;
  font: inherit;
  text-align: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 7px;
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]:hover { background: rgba(255, 255, 255, 0.12); }
input[type="number"]:focus { outline: 1px solid var(--accent); background: rgba(255, 255, 255, 0.14); }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.ctl > span, .lbl-static { color: var(--muted); }
.ctl > output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* The label is the pin. It is the one spare surface on a row, and pinning is
   what you reach for while Chaos is running. */
.lbl {
  padding: 0;
  font: inherit;
  text-align: left;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lbl:hover { color: var(--text); }
.lbl.nopin { cursor: default; }
.lbl.nopin:hover { color: var(--muted); }

/* Pinned: yours, and Chaos may not have it. The dot is drawn in the label so
   the row keeps its three columns. */
.ctl.pinned > .lbl, .btn.pinned {
  color: var(--text);
}
.ctl.pinned > .lbl::after {
  content: " \2022";
  color: var(--accent);
}
.btn.pinned { box-shadow: inset 0 0 0 1px var(--accent); }

/* Driven: Chaos has hold of this one right now. */
.ctl.driven > .lbl { color: var(--accent); }
.ctl.driven > input[type="range"]::-webkit-slider-thumb { background: var(--accent); }
.ctl.driven > input[type="range"]::-moz-range-thumb { background: var(--accent); }
.ctl.driven > output { color: var(--accent); }
.btn.driven { color: var(--accent); }

/* How many beats one cycle of this layer now spans — what the BPM lock did. */
.bpm-wrap { display: flex; flex-direction: column; gap: 2px; }
.beats {
  padding-left: 52px;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.75;
}
.bpm.off + .beats { opacity: 0; }

/* Chaos scope: small on/off pills that wrap. */
.chipset { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  padding: 4px 8px;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.pill:hover { color: var(--text); background: rgba(255, 255, 255, 0.12); }
.pill.on {
  color: #06121a;
  background: var(--accent);
  border-color: var(--accent);
}

.head-actions { display: flex; align-items: center; gap: 3px; }
.head-actions .icon.on { color: var(--accent); }
.chipset.pinned { outline: 1px solid var(--accent); border-radius: 8px; }
.chipset.driven { filter: drop-shadow(0 0 4px var(--accent)); }

.btn.big { padding: 9px 10px; font-weight: 600; }
.status { min-height: 1.4em; font-variant-numeric: tabular-nums; }
.status.warn { color: var(--accent); }

/* ---------------------------------------------------------- scenes --- */

.scene-list { display: flex; flex-direction: column; gap: 4px; }

.scene {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 2px;
  align-items: center;
}

.scene-name {
  min-width: 0;
  padding: 6px 8px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scene-name:hover { background: rgba(255, 255, 255, 0.14); }

.scene .icon {
  width: 24px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--muted);
}
.scene .icon:hover { color: var(--text); }

.scene.sub { grid-template-columns: 1fr; padding-left: 10px; }
.scene.sub .scene-name { font-size: 11px; color: var(--muted); }
.scene.sub .scene-name:hover { color: var(--text); }
.scene-name.dead { opacity: 0.45; text-decoration: line-through; }

/* Whole-app Shows are intentionally more descriptive than saved scenes: the
   second line explains the shared visual idea, while the footer makes the
   common tempo and active layers visible before committing to it. */
.show-list { display: flex; flex-direction: column; gap: 5px; }
.show-card {
  width: 100%;
  padding: 8px 9px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.show-card:hover { background: rgba(255, 255, 255, 0.12); }
.show-card.on {
  border-color: var(--accent);
  background: rgba(125, 211, 252, 0.1);
  box-shadow: inset 3px 0 0 var(--accent);
}
.show-card b,
.show-card span,
.show-card small { display: block; }
.show-card b { margin-bottom: 3px; font-size: 11px; font-weight: 600; }
.show-card span { color: var(--muted); font-size: 10px; line-height: 1.35; }
.show-card small {
  margin-top: 5px;
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.03em;
}

/* Generated assets in Settings: compact enough for long libraries, while the
   independent On/Off and Remove actions remain explicit. */
.asset-list { display: flex; flex-direction: column; gap: 4px; }
.asset {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px;
  align-items: center;
}
.asset-main {
  min-width: 0;
  padding: 5px 7px;
  text-align: left;
}
.asset-main b,
.asset-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-main b { font-size: 11px; font-weight: 500; }
.asset-main small { color: var(--muted); font-size: 9px; }
.asset.off .asset-main { opacity: 0.48; }
.asset .asset-toggle { min-width: 38px; }
.asset .asset-remove { color: #fda4af; }

.settings-summary {
  padding: 7px 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-variant-numeric: tabular-nums;
}

/* A text link rather than a button: reaching for a different key than the
   one in .env is a rare thing to want. */
.linky {
  align-self: flex-start;
  padding: 2px 0;
  font: inherit;
  font-size: 10px;
  color: var(--muted);
  background: none;
  border: none;
  text-decoration: underline;
}
.linky:hover { color: var(--text); background: none; }
.linky[hidden] { display: none; }

/* Present for the password manager, absent for everyone else. Not
   display:none, because a field the browser cannot see does not satisfy it. */
.offscreen {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:disabled:hover { background: rgba(255, 255, 255, 0.05); color: var(--muted); }

/* ---------------------------------------------------------------- music --- */

/* One block per source; only the selected one is in the flow. */
.src { display: flex; flex-direction: column; gap: 8px; }
.src[hidden] { display: none; }

.meter-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
}

.meter {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.meter > i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.beat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.15;
}

/* The player has to keep rendering for the audio to keep playing, so hiding it
   means clipping it, never display:none. */
.yt-wrap {
  height: 138px;
  overflow: hidden;
  border-radius: 8px;
  transition: height 0.2s ease;
}
.yt-wrap.hidden { height: 0; }
.yt-wrap iframe { width: 100%; height: 138px; border: 0; }

/* ---------------------------------------------------------- controls --- */

button, select {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  cursor: pointer;
}

button:hover, select:hover { background: rgba(255, 255, 255, 0.12); }
button:active { transform: translateY(1px); }
select { appearance: none; padding-right: 8px; }
option { background: #14141a; color: var(--text); }

.btn { min-width: 30px; text-align: center; }
.btn.wide { flex: 1; }
.btn.on { background: var(--accent); border-color: var(--accent); color: #04121b; font-weight: 600; }

.icon {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
}
.icon:hover { color: var(--text); background: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent);
}

input[type="color"] {
  flex: 1;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: none;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type="color"].pinned { outline: 1px solid var(--accent); }
input[type="color"].driven { box-shadow: 0 0 8px var(--accent); }

/* ----------------------------------------------------------- overlay --- */

/* Screened over the ring so crossing beams add up instead of hiding it, and
   transparent to clicks until the lasers are unlocked for dragging. */
/* Sized in per cent, not by inset: a canvas is a replaced element, and with
   width auto it would keep its own bitmap size instead of stretching. */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  touch-action: none;
  mix-blend-mode: screen;
}
.overlay.edit { pointer-events: auto; cursor: grab; }
.overlay.edit.drag { cursor: grabbing; }

/* The Spirograph is part of the ring composition, beneath the foreground
   beams, sheet, logo and type layers. */
.spiro { z-index: 4; }

/* The grid sheet goes over the lasers as well as the ring, and blends
   normally rather than screening: it is meant to tint and break up what is
   under it, which an additive layer cannot do. Its own opacity control does
   the rest, so it never gets a blend mode of its own. */
.sheet {
  z-index: 7;
  mix-blend-mode: normal;
}

/* Uploaded artwork belongs inside the hole and should remain legible above
   the additive effects. The panel and its edge handle still sit above it. */
.centre-logo {
  z-index: 8;
  mix-blend-mode: normal;
}

/* Milk is the backdrop: it goes under the ring rather than over it, so the
   circle reads against the feedback instead of being swallowed by it. */
.milk {
  z-index: 0;
  mix-blend-mode: normal;
}

/* Text goes above the shape laser — it is the thing you are meant to read. */
.type {
  z-index: 9;
  mix-blend-mode: screen;
}

/* Above every other layer, and the one overlay that does not blend. Screen
   would let whatever is behind it wash through the letters, and a subtitle
   that is hard to read has failed at the only thing it does. */
.subs { z-index: 12; }

/* The shape laser sits over everything and screens, so beams crossing the
   ring add up the way real ones do rather than cutting it out. */
.beam {
  z-index: 8;
  mix-blend-mode: screen;
}

/* Cell count under the on/off button, pushed to the right of the row. */
.tally { margin: 0 0 0 auto; text-align: right; white-space: nowrap; }

/* -------------------------------------------------------------- tabs --- */

/* Five equal columns: a flex row let the last tab clip once Music joined. */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }

.tab {
  min-width: 0;
  padding: 6px 2px;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab.on { color: #04121b; background: var(--accent); border-color: var(--accent); font-weight: 600; }

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

/* The pane opens with its own heading, so it needs no rule above it. */
.pane > .sep:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.hint { font-size: 10px; line-height: 1.35; color: var(--muted); }

/* -------------------------------------------------------------- dock --- */

/* Drives the circle and the lasers together. It sits in the drawer's flow
   under the "Both" separator — fixed positioning here would be resolved
   against the panel anyway, the panel's backdrop-filter being a containing
   block for it, which spilled the buttons out over both edges. */
.dock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 2px;
}

.dock .dock-wide { grid-column: 1 / -1; }

.clock-dock {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: 6px;
}
.clock-dock select { min-width: 0; text-align: center; }
.clock-dock.on select {
  color: #04121b;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.dock-sep { width: 1px; height: 18px; background: var(--line); }

/* --------------------------------------------------------------- fab --- */

/* The drawer's handle: a tab welded to the same edge the panel comes out of,
   so the way back in is where the panel went. */
.fab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 84px;
  padding: 0;
  border-left: none;
  border-radius: 0 12px 12px 0;
  font-size: 17px;
  color: var(--text);
  background: var(--panel);
  backdrop-filter: blur(14px);
  opacity: 0.6;
  transition: opacity 0.18s ease;
  z-index: 10;
}
.fab:hover { opacity: 1; }

/* A generous invisible hit area. The handle sits against the very edge of the
   screen, which is where a pointer is hardest to place — and a miss used to
   land on the page background and do nothing at all, so reopening the drawer
   took several attempts. A pseudo-element hit-tests as its own button, so this
   catches near-misses without changing how anything looks. */
.fab::before {
  content: '';
  position: absolute;
  inset: -16px -20px -16px 0;
}
.fab[hidden] { display: none; }

@media (max-width: 520px) {
  /* Nearly the whole width on a phone, the drawer still coming from the edge. */
  .panel { width: 300px; max-width: 92vw; }
}

/* --------------------------------------------------------------- drop --- */

/* Shown only while a file is over the window. It sits above the visuals but
   below the panel, so dropping onto the controls still works. */
.drop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.drop[hidden] { display: none; }
.drop-card {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 28px 40px;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  text-align: center;
}
.drop-card strong { font-size: 20px; letter-spacing: 0.01em; }
.drop-card span { font-size: 13px; opacity: 0.7; }

/* The record progress bar reuses the meter, but has to be able to vanish. */
.meter.hidden { display: none; }

/* ------------------------------------------------------------- words --- */

/* The wordlist is the one control on the Text tab that is not a slider, so it
   breaks out of .ctl's three-column grid and lays itself out. */
.ctl.words {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.words-head { display: flex; align-items: center; gap: 8px; }
.words-head .lbl-static { flex: 0 0 44px; }

.wordlist {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.wordlist:empty { display: none; }

/* One entry. The whole row is the target for selecting it; the field inside
   stays editable, because renaming a word should not mean deleting it and
   typing it again. */
.word {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}
.word:hover { background: rgba(255, 255, 255, 0.08); }

/* Selected: this is the word the controls below are editing. */
.word.on {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.09);
}

.word .word-text {
  border: 0;
  background: none;
  padding: 3px 0;
  font: inherit;
  color: inherit;
  min-width: 0;
}
.word .word-text:focus { outline: none; }
.word.on .word-text { color: var(--accent); }

.btn.tiny {
  flex: 0 0 auto;
  padding: 2px 7px;
  line-height: 1.2;
  font-size: 13px;
}

/* ------------------------------------------------------- logo library --- */

.logo-lib .sep { margin-top: 4px; }

/* Two strips of thumbnails: the user's own, and what ships with the app.
   Wrapping rather than scrolling, because the built-in set is meant to grow
   and a row that scrolls sideways hides the half you have not seen. */
.logo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.logo-strip[hidden] { display: none; }

/* Reads as a link under the strip rather than as another control competing
   with the pills above it. */
.logo-more {
  margin-top: 6px;
  padding: 2px 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.logo-more:hover { color: #e9edf2; }
.logo-more[hidden] { display: none; }

/* The sign-in prompt. Lives on the body rather than in the logo section, and
   has to: that section sits in a tab pane that is display:none most of the
   time, and inside a panel whose backdrop-filter would capture a fixed child
   and shrink it to the sidebar. Above the panel (z-index 10) and the drop
   hint (30), because it is the one thing on screen waiting on a decision. */
.ask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 9, 12, 0.82);
  backdrop-filter: blur(6px);
}
.ask[hidden] { display: none; }
.ask-card {
  display: grid;
  gap: 10px;
  width: min(340px, 86vw);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(20, 22, 28, 0.96);
  text-align: left;
}
.ask-card strong { font-size: 15px; }
.ask-card span { font-size: 12px; opacity: 0.72; line-height: 1.45; }
.ask-card .hint:empty { display: none; }

/* Stacked over the sign-in prompt rather than replacing it, so cancelling
   puts you back where you were. Deliberately thinner than the layer below and
   with no blur of its own: two full-strength backdrops stack into an opaque
   wall, and the prompt you can still go back to disappears behind it. */
.ask.sure {
  z-index: 51;
  background: rgba(8, 9, 12, 0.5);
  backdrop-filter: none;
}

/* The way out of a modal should not look like the thing it is steering you
   away from, so this reads as a link rather than a third button. */
.btn.link {
  justify-self: center;
  padding: 2px 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn.link:hover { color: #e9edf2; background: none; }

.logo-tile {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}
.logo-tile:hover { background: rgba(255, 255, 255, 0.1); }

/* Selected: this is the artwork on screen right now. */
.logo-tile.on {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
}

.logo-tile img {
  max-width: 38px;
  max-height: 38px;
  object-fit: contain;
  pointer-events: none;
}

.logo-tile.add {
  border-style: dashed;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.logo-tile.add:hover { color: #e9edf2; }

/* The remove button only earns its space once you are over the tile. */
.logo-tile > .btn.tiny {
  position: absolute;
  top: -5px;
  right: -5px;
  padding: 0 5px;
  opacity: 0;
  background: rgba(8, 10, 14, 0.95);
}
.logo-tile:hover > .btn.tiny,
.logo-tile > .btn.tiny:focus { opacity: 1; }

/* The fine tuning: which of the library Chaos is allowed to reach for. */
.logo-rota { margin-top: 4px; }
.logo-rota > summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0;
}
.logo-rota > summary:hover { color: #e9edf2; }

.rota-all { gap: 6px; }
.rota-all .btn { flex: 0 0 auto; padding: 3px 10px; }

.rota-head {
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.rota-item { padding: 1px 0; }
.rota-item span { font-size: 12px; }

/* Out of play because the Pick from pill excludes this whole list. The tick
   is still yours to set; it just is not deciding anything right now. */
.rota-item.muted { opacity: 0.42; }

/* A tick row is easier to scan by artwork than by filename. */
.rota-thumb {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex: 0 0 auto;
  opacity: 0.9;
}

/* ============================================================== ai tab === */

/* The paid section, built to look like gear rather than like a pricing page.
   Everything else in this app is named after a lighting rig — Rig, Beams,
   Sheet, Bursts, Blackout — so the budget reads as a channel meter with a
   headroom mark rather than as a progress bar. That is not decoration: the
   plans are sold as unlimited under fair use, and headroom is exactly what
   that means. You may run past the line. It just goes hot. */

.ai {
  /* The ramp is club lighting, not a traffic light: it belongs to the same
     world as the gels and washes the app is driving. Legibility of the
     over-the-line state is carried by the words, not by the hue alone. */
  --lit:  #34d399;
  --mid:  #7dd3fc;
  --warm: #c084fc;
  --hot:  #f472b6;
  --over: #fb7185;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* --- the plan strip, always at the top ---------------------------------- */

/* Explanatory asides. Quieter than a hint and smaller than body copy: it is
   there for the person who wants it and out of the way of the one who does
   not. */
.ai-fine {
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  opacity: 0.86;
}
.ai-fine[hidden] { display: none; }

.ai-intro {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.ai-plan {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(125, 211, 252, 0.07), transparent 60%),
    rgba(255, 255, 255, 0.03);
}

.ai-plan-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 9px;
}
.ai-plan-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.ai-plan-state {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
/* Lit while the subscription is live, so the state is legible at a glance
   from further away than the words are. */
.ai-plan-state::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}
.ai-plan.live .ai-plan-state { color: var(--lit); }
.ai-plan.over .ai-plan-state { color: var(--over); }

/* --- the meter --------------------------------------------------------- */

.ai-meter {
  position: relative;
  height: 14px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

/* The colour lives on the track and is revealed by the fill's width, so the
   ramp is a property of *position along the meter* rather than of the current
   value. A bar at 20% is therefore green at 20% and stays green there, the
   way a real meter behaves — rather than the whole bar changing hue, which
   would make the ramp a status colour wearing a meter's clothes. */
.ai-meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg,
    var(--lit) 0%, var(--lit) 34%,
    var(--mid) 52%, var(--warm) 74%, var(--hot) 100%);
  transition: width 220ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* Cut into segments by masking, not by drawing thirty nodes. */
.ai-meter-grid {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg,
    transparent 0 4px, rgba(18, 18, 22, 0.92) 4px 6px);
  pointer-events: none;
}

/* Where fair use ends. A tick on the scale, like a headroom mark. */
.ai-meter-line {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 1px;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.ai-plan.over .ai-meter-fill {
  background: linear-gradient(90deg, var(--hot), var(--over));
}
@media (prefers-reduced-motion: no-preference) {
  .ai-plan.over .ai-meter-fill { animation: ai-hot 1.6s ease-in-out infinite; }
}
@keyframes ai-hot { 50% { opacity: 0.72; } }

/* Sits under the meter it is priced from, so the number and the reason for it
   are read together. */
.ai-up {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}
.ai-up[hidden] { display: none; }

/* Sits under the plan, quiet: leaving is not a thing to advertise, but it has
   to be findable without an email to support. */
.ai-manage { margin-top: 8px; justify-self: start; }
.ai-manage[hidden] { display: none; }
.ai-up .btn { font-variant-numeric: tabular-nums; }
.ai-up .hint { font-size: 11px; line-height: 1.45; }

.ai-read {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 7px;
  font: 11px/1 ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.ai-read b { font-weight: 600; }
.ai-read span { margin-left: auto; color: var(--muted); letter-spacing: 0.04em; }
.ai-note { margin-top: 6px; font-size: 11px; line-height: 1.45; color: var(--muted); }
.ai-note.hot { color: var(--over); }

/* --- the tools --------------------------------------------------------- */

.ai-tools { display: flex; flex-direction: column; gap: 4px; }

.ai-tool {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}
.ai-tool.open { background: rgba(255, 255, 255, 0.045); }

.ai-tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ai-tool-head:hover { background: rgba(255, 255, 255, 0.04); }
.ai-tool-name { font-size: 12px; }
.ai-tool-cost {
  margin-left: auto;
  font: 10px/1 ui-monospace, Consolas, monospace;
  color: var(--muted);
}
/* Turns with the panel it opens, so the control says which way it goes. */
.ai-tool-chev {
  width: 8px;
  color: var(--muted);
  transition: transform 160ms ease;
}
.ai-tool.open .ai-tool-chev { transform: rotate(90deg); }

.ai-tool-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px 10px;
}
.ai-tool:not(.open) .ai-tool-body { display: none; }
.ai-tool-body .hint { font-size: 11px; }

/* --- locked ------------------------------------------------------------ */

/* Shown, not hidden. Someone deciding whether to pay should be able to see
   exactly what they would be paying for — which means being able to open a
   tool and read it. Only the controls that would spend money are inert; the
   header still opens, because a row that will not even expand reads as broken
   rather than as locked.

   `.ai-keep` is the exception that matters. What somebody generated is theirs,
   and a lapsed subscription must not take it away — so the controls that play,
   list or delete existing work stay live and undimmed while the controls that
   would bill them do not. Paying buys the making, never the keeping. */
.ai-locked .ai-tool-name,
.ai-locked .ai-tool-cost { opacity: 0.55; }
.ai-locked .ai-tool-body > *:not(.ai-keep) { opacity: 0.5; }
.ai-locked .ai-tool-body :is(input, button):not(.ai-keep, .ai-keep *) {
  pointer-events: none;
}

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

.ai-tier {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.ai-tier.pick {
  border-color: rgba(125, 211, 252, 0.5);
  background:
    radial-gradient(140% 120% at 100% 0%, rgba(125, 211, 252, 0.10), transparent 62%),
    rgba(255, 255, 255, 0.04);
}
.ai-tier-head { display: flex; align-items: baseline; gap: 6px; }
.ai-tier-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.ai-tier-price {
  margin-left: auto;
  font: 600 17px/1 ui-monospace, "SF Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.ai-tier-price i { font: inherit; font-size: 10px; font-style: normal; color: var(--muted); }
.ai-tier-what { margin: 7px 0 9px; font-size: 11px; line-height: 1.5; color: var(--muted); }
.ai-tier .btn { width: 100%; }

.ai-signin { display: flex; justify-content: center; padding-top: 2px; }

.ai-free {
  padding-top: 2px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

/* ----------------------------------------------------------- subtitles --- */

.sub-own[hidden] { display: none; }
.sub-own { display: flex; flex-direction: column; gap: 6px; }

.sub-edit-head { margin-top: 2px; font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); }
.sub-edit-head .btn.tiny { flex: 0 0 auto; }

/* Scrolls rather than growing: a four-minute track is several hundred words,
   and the panel has other controls under this one. */
.sub-words {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 210px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.sub-word { display: flex; gap: 4px; align-items: center; }
/* Fixed width and tabular figures so the times form a column the eye can run
   down, which is how a mistimed word gets spotted. */
.sub-word .sub-at {
  flex: 0 0 48px;
  padding: 3px 4px;
  font: 10px/1 ui-monospace, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.sub-word input[type="text"]:not(.sub-at) { padding: 3px 6px; font-size: 11px; }

/* ------------------------------------------------------- ai examples --- */

/* One worked example per tool. Set apart from the controls by a rule and a
   darker ground, so it reads as a specimen rather than as another input. */
.ai-eg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
}

.ai-eg-frame {
  display: grid;
  place-items: center;
  min-height: 62px;
  padding: 4px;
}
.ai-eg-frame img { max-height: 78px; max-width: 100%; }
/* Grid and subtitles are shown edge to edge: one is a field, the other a
   line of type, and neither reads when it is boxed small. */
.ai-eg-frame.full { padding: 0; }
.ai-eg-frame.full img { max-height: none; width: 100%; border-radius: 5px; }

/* Drawn live rather than shipped as a GIF: at this size a GIF of a cell grid
   is a few hundred soft kilobytes fixed to one resolution, and this is a few
   lines of arithmetic that stays crisp on any display and pauses when it
   scrolls out of view. */
.ai-eg-grid {
  display: block;
  width: 100%;
  height: 104px;
  border-radius: 5px;
}

.ai-eg-svg { width: 96px; height: 96px; overflow: visible; }
.ai-eg-svg polyline {
  fill: none;
  stroke: var(--accent);
  /* In user units, so it scales with the box. `non-scaling-stroke` would
     resolve this in screen pixels instead and draw a 0.022px hairline —
     which is to say nothing at all. */
  stroke-width: 0.02;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(125, 211, 252, 0.5));
}

/* The words arrive on their own timings, looping, because when a word lands
   is the entire feature and a still cannot show it. */
.ai-eg-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  padding: 10px 4px;
  font-weight: 600;
  font-size: 13px;
}
.ai-eg-subs span {
  opacity: 0.28;
  animation: ai-eg-say var(--loop, 3s) steps(1, end) infinite;
}
@keyframes ai-eg-say {
  0%, 12% { opacity: 1; text-shadow: 0 0 10px currentColor; }
  13%, 100% { opacity: 0.28; text-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-eg-subs span { animation: none; opacity: 0.85; }
}

.ai-eg-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}
.ai-eg-list b {
  width: 100%;
  margin-bottom: 1px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ai-eg-list span {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 10px;
  color: var(--muted);
}

.ai-eg-said { display: flex; gap: 5px; font-size: 10px; line-height: 1.4; }
.ai-eg-said b {
  flex: 0 0 auto;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.ai-eg-said span { color: var(--text); opacity: 0.78; font-style: italic; }
/* Pushed to the end of the caption row: it is an offer, not the point of the
   example, so it should not be the first thing the eye lands on. */
.ai-eg-take { flex: 0 0 auto; margin-left: auto; align-self: flex-start; }
.ai-eg-take.done { color: var(--accent); }

/* --------------------------------------------------------------- modes --- */

/* Simple or Advanced. A segmented pair rather than a tab in the strip below,
   because it does not select a pane — it selects which panel you are looking
   at, and the strip is part of what it hides. */
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
}
.mode {
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: 600 11px/1 inherit;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.mode:hover { color: var(--text); }
.mode.on { color: #06121a; background: var(--accent); }

/* The whole desk belongs to Advanced: twelve tabs and a dock above a
   two-button panel would make "simple" a claim the screen contradicts. */
.panel.simple-mode .chips,
.panel.simple-mode .tabs,
.panel.simple-mode .dock,
.panel.simple-mode > .sep { display: none; }

/* -------------------------------------------------------------- simple --- */

.simple { display: flex; flex-direction: column; gap: 8px; }
.simple[hidden] { display: none; }

.simple-lede { font-size: 12px; line-height: 1.5; color: var(--muted); }
.simple-fine { font-size: 11px; line-height: 1.5; color: var(--muted); opacity: 0.85; }
.simple-fine[hidden] { display: none; }
.simple-status { min-height: 1.4em; font-size: 11px; color: var(--muted); }

.simple .row[hidden] { display: none; }

/* The one control that matters, sized like it. */
.simple-go {
  padding: 15px 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.simple-go.on {
  color: #06121a;
  background: var(--accent);
  border-color: var(--accent);
}
