/* ————————————————————————————————— tokens ————————————————————————————— */
:root {
  --bg: #0a0b0d;
  --bg-raise: #0f1114;
  --panel: #111318;
  --panel-2: #151821;
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eaed;
  --text-dim: #8b919c;
  --text-faint: #565b66;
  --acid: #b8ff2e;
  --acid-soft: rgba(184, 255, 46, 0.14);
  --acid-line: rgba(184, 255, 46, 0.38);
  --danger: #ff5d5d;
  --radius: 14px;
  --radius-sm: 9px;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ————————————————————————————————— base ——————————————————————————————— */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
a { color: var(--text); text-decoration-color: var(--text-faint); text-underline-offset: 3px; }
a:hover { color: var(--acid); text-decoration-color: var(--acid-line); }
em { font-style: normal; color: var(--acid); }
kbd {
  font-family: var(--mono);
  font-size: 0.68em;
  padding: 2px 5px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 5px;
  opacity: 0.6;
}

/* ————————————————————————————————— topbar ————————————————————————————— */
.topbar {
  flex: none;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--hairline);
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.5px;
  text-decoration: none;
}
.brand:hover { color: var(--acid); }
.rail-toggle {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.rail-toggle:hover { background: var(--bg-raise); border-color: var(--hairline); }
.rail-toggle[aria-expanded='true'] { background: var(--acid-soft); border-color: var(--acid-line); }
.rail-icon { display: flex; flex-direction: column; gap: 3px; }
.rail-icon i {
  display: block;
  width: 13px; height: 1.5px;
  border-radius: 2px;
  background: var(--text-dim);
  transition: background 0.16s var(--ease), width 0.16s var(--ease);
}
.rail-icon i:nth-child(2) { width: 9px; }
.rail-toggle:hover .rail-icon i { background: var(--text); }
.rail-toggle[aria-expanded='true'] .rail-icon i { background: var(--acid); }
.topnav { display: flex; align-items: center; gap: 14px; }
.ghost-btn {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 99px;
  padding: 5px 13px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.ghost-btn:hover { color: var(--acid); border-color: var(--acid-line); background: var(--acid-soft); }

/* ————————————————————————————————— shell —————————————————————————————— */
.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns:
    var(--rail-w, 0px)
    var(--rail-div, 0px)
    var(--side-w, 340px)
    6px
    1fr;
  background: var(--bg);
}
.shell.rail-open { --rail-w: 232px; --rail-div: 6px; }

/* dividers */
.divider {
  position: relative;
  background: var(--hairline);
  transition: background 0.16s var(--ease);
}
.divider-v { cursor: col-resize; }
.divider-h { cursor: row-resize; height: 6px; }
.divider::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.16s var(--ease);
}
.divider:hover::after, .divider.dragging::after, .divider:focus-visible::after {
  background: var(--acid-line);
}
.divider:focus-visible { outline: none; }
#divider-rail { pointer-events: none; }
.shell.rail-open #divider-rail { pointer-events: auto; }

/* ————————————————————————————————— rail ——————————————————————————————— */
.rail {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.rail-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px 9px;
  border-bottom: 1px solid var(--hairline);
}
.rail-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  text-transform: uppercase;
  flex: 1;
}
.rail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 0 20px; }
.rail-empty {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 14px 14px;
  margin: 0;
  line-height: 1.6;
}

/* timeline */
.timeline { list-style: none; margin: 0; padding: 6px 0 0 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 19px; top: 0; bottom: 0;
  width: 1px;
  background: var(--hairline);
}
.tl-item { position: relative; }
.tl-link {
  display: block;
  text-decoration: none;
  padding: 8px 12px 8px 34px;
  position: relative;
  transition: background 0.16s var(--ease);
  animation: rise 0.3s var(--ease) backwards;
}
.tl-link::before {
  content: '';
  position: absolute;
  left: 15px; top: 14px;
  width: 9px; height: 9px;
  border-radius: 99px;
  background: var(--panel);
  border: 1.5px solid var(--text-faint);
  transition: all 0.18s var(--ease);
}
.tl-link:hover { background: var(--bg-raise); }
.tl-link:hover::before { border-color: var(--acid); }
.tl-link.current { background: var(--acid-soft); }
.tl-link.current::before { border-color: var(--acid); background: var(--acid); box-shadow: 0 0 8px rgba(184,255,46,.5); }
.tl-title {
  display: block;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
}
.tl-link:hover .tl-title { color: var(--acid); }
.tl-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
.tl-meta .mark { width: 9px; height: 9px; opacity: 0.6; }
.tl-genre { color: var(--acid); opacity: 0.75; }

/* ———————————————————————————————— sidebar ————————————————————————————— */
.sidebar {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr;
  background: var(--panel);
  overflow: hidden;
}
.sidebar.adv-open { grid-template-rows: 1fr 6px var(--adv-h, 300px); }
.side-pane { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.generate-dock {
  flex: none;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.gate-hint {
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: center;
  min-height: 14px;
  transition: color 0.2s var(--ease);
}
.gate-hint.ready { color: var(--acid); opacity: 0.7; }

.side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 16px; }
.field { display: block; }
.control-label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 0.7px;
  margin-bottom: 7px;
  text-transform: uppercase;
}
.prompt-wrap { position: relative; }
#prompt {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  background: var(--bg-raise);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 11px 12px 22px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
#prompt:focus {
  outline: none;
  border-color: var(--acid-line);
  box-shadow: 0 0 0 3px rgba(184, 255, 46, 0.08);
}
#prompt::placeholder { color: var(--text-faint); }
.prompt-count {
  position: absolute;
  right: 9px; bottom: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  pointer-events: none;
}

/* advanced tab pinned to the bottom of the sidebar */
.advanced-tab {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--panel-2);
  border: 0;
  border-top: 1px solid var(--hairline);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 11px 14px;
  cursor: pointer;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
.advanced-tab:hover { color: var(--text); background: var(--bg-raise); }
.advanced-tab[aria-expanded='true'] { color: var(--acid); }
.adv-chevron { display: inline-block; transition: transform 0.28s var(--ease); color: var(--acid); }
.advanced-tab[aria-expanded='true'] .adv-chevron { transform: rotate(180deg); }
.adv-count {
  margin-left: auto;
  background: var(--acid);
  color: #0a0b0d;
  font-weight: 600;
  border-radius: 99px;
  font-size: 10px;
  padding: 1px 7px;
}

/* advanced pane (second window under the main one) */
.side-advanced { background: var(--bg-raise); animation: slideup 0.28s var(--ease); }
@keyframes slideup {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.adv-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  background: var(--panel-2);
}
.adv-head-title {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--acid);
  flex: 1;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 5px;
  transition: color 0.16s var(--ease), background 0.16s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--hairline); }
.adv-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }

/* ————————————————————————————————— stage —————————————————————————————— */
.stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.player {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.empty-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  padding: 20px;
  text-align: center;
}
.empty-line { font-family: var(--mono); font-size: 13px; color: var(--text-faint); margin: 0; }
.empty-sub { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); opacity: 0.65; margin: 0; line-height: 1.8; }

/* segmented controls */
.controls-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .controls-row { grid-template-columns: 1fr; } }
.segmented {
  display: flex;
  background: var(--bg-raise);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.segmented button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 6px;
  background: transparent;
  color: var(--text-dim);
  border: 0;
  border-radius: 7px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.1s var(--ease);
}
.segmented button small {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.2px;
}
.segmented button:hover { color: var(--text); }
.segmented button:active { transform: scale(0.98); }
.segmented button.active {
  background: var(--panel-2);
  color: var(--acid);
  box-shadow: inset 0 0 0 1px var(--acid-line), 0 2px 8px rgba(0, 0, 0, 0.3);
}
.segmented button.active small { color: var(--text-dim); }

/* genre chips */
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.genre-chips button {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--hairline);
  background: var(--bg-raise);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.genre-chips button:hover { border-color: var(--hairline-strong); color: var(--text); transform: translateY(-1px); }
.genre-chips button.active {
  background: var(--acid-soft);
  border-color: var(--acid-line);
  color: var(--acid);
}

/* ————————————————————————————— advanced tab ——————————————————————————— */
.advanced { border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--bg-raise); }
.advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.4px;
  padding: 12px 15px;
  cursor: pointer;
  transition: color 0.18s var(--ease);
}
.advanced-toggle:hover { color: var(--text); }
.adv-chevron { display: inline-block; transition: transform 0.25s var(--ease); color: var(--acid); }
.advanced.open .adv-chevron { transform: rotate(90deg); }
.adv-count {
  background: var(--acid);
  color: #0a0b0d;
  font-weight: 600;
  border-radius: 99px;
  font-size: 10.5px;
  padding: 1px 7px;
}
.adv-hint { margin-left: auto; font-size: 10.5px; color: var(--text-faint); }
@media (max-width: 640px) { .adv-hint { display: none; } }
.advanced-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.34s var(--ease);
}
.advanced.open .advanced-body { grid-template-rows: 1fr; }
.advanced-inner { overflow: hidden; }
.adv-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  padding: 4px 14px 10px;
}
.adv-group {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  margin: 0;
  padding: 12px 14px 14px;
  min-inline-size: 0;
  background: rgba(0, 0, 0, 0.18);
  transition: opacity 0.25s var(--ease);
}
.adv-group legend {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--acid);
  padding: 0 6px;
  letter-spacing: 0.8px;
}
.adv-group.disabled { opacity: 0.35; pointer-events: none; }
.adv-group .group-note { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); margin: 0 0 6px; }
.adv-control { margin-bottom: 12px; }
.adv-control:last-child { margin-bottom: 0; }
.adv-control-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.adv-control-head label {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.adv-value {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  transition: color 0.18s var(--ease);
}
.adv-control.dirty .adv-value { color: var(--acid); }
.dirty-dot {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--acid);
  opacity: 0;
  transform: scale(0.4);
  transition: all 0.2s var(--ease);
  cursor: pointer;
  flex: none;
}
.adv-control.dirty .dirty-dot { opacity: 1; transform: scale(1); }

/* range */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--acid-line) var(--fill, 0%), rgba(255, 255, 255, 0.12) var(--fill, 0%));
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  margin-top: -5px;
  border-radius: 99px;
  background: var(--text);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--hairline-strong);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}
input[type='range']:hover::-webkit-slider-thumb { transform: scale(1.15); background: var(--acid); }
input[type='range']::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255,255,255,0.12); }
input[type='range']::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--acid-line); }
input[type='range']::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 99px;
  background: var(--text); border: 2px solid var(--bg);
}

/* select + text input inside advanced */
.adv-control select, .adv-control input[type='text'] {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 7px 9px;
  transition: border-color 0.18s var(--ease);
}
.adv-control select:focus, .adv-control input[type='text']:focus {
  outline: none;
  border-color: var(--acid-line);
}

/* toggle */
.toggle-row { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.toggle-row input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.toggle-row input:focus-visible + .toggle-pill {
  outline: 2px solid var(--acid-line);
  outline-offset: 2px;
}
.toggle-pill {
  width: 30px; height: 17px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  transition: background 0.2s var(--ease);
  flex: none;
}
.toggle-pill::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 99px;
  background: var(--text-dim);
  transition: all 0.2s var(--ease);
}
.toggle-row input:checked + .toggle-pill { background: var(--acid-soft); box-shadow: inset 0 0 0 1px var(--acid-line); }
.toggle-row input:checked + .toggle-pill::after { left: 15px; background: var(--acid); }
.toggle-row .toggle-label { font-size: 12px; color: var(--text-dim); font-family: var(--mono); }

.adv-footer { padding: 0 16px 14px; display: flex; }

/* ———————————————————— provider + key (one row) ——————————————————————— */
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mark { width: 14px; height: 14px; fill: currentColor; flex: none; }

.key-docs {
  float: right;
  font-size: 10px;
  color: var(--text-faint);
  text-decoration: none;
  letter-spacing: 0;
  text-transform: none;
  transition: color 0.16s var(--ease);
}
.key-docs:hover { color: var(--acid); }

.key-combo, .key-set {
  display: flex;
  align-items: stretch;
  background: var(--bg-raise);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.key-combo:focus-within {
  border-color: var(--acid-line);
  box-shadow: 0 0 0 3px rgba(184, 255, 46, 0.08);
}
.provider-toggle {
  display: flex;
  flex: none;
  border-right: 1px solid var(--hairline);
  background: rgba(0, 0, 0, 0.25);
}
.provider-toggle button {
  width: 30px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0;
  transition: color 0.16s var(--ease), background 0.16s var(--ease);
}
.provider-toggle button:hover { color: var(--text); background: var(--hairline); }
.provider-toggle button.active { color: var(--acid); background: var(--acid-soft); }
.provider-toggle button.active .mark { transform: scale(1.05); }
.provider-toggle button:focus-visible { outline: 1px solid var(--acid-line); outline-offset: -2px; }

#key-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 9px 10px;
}
#key-input:focus { outline: none; }
#key-input::placeholder { color: var(--text-faint); }
.key-action {
  flex: none;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--hairline);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 0 12px;
  cursor: pointer;
  transition: color 0.16s var(--ease), background 0.16s var(--ease);
}
.key-action:hover { color: var(--acid); background: var(--acid-soft); }

.key-set { align-items: center; padding-right: 8px; gap: 8px; }
.key-set code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  flex: 1;
  padding-left: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-set .linklike { font-size: 10.5px; }

/* plan strip */
.plan-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  border-top: 1px solid var(--hairline);
  padding-top: 13px;
  margin-top: auto;
}
.plan-active { color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.plan-active::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 99px;
  background: var(--acid);
  margin-right: 6px;
  vertical-align: middle;
}
.plan-soon {
  margin-left: auto;
  border: 1px dashed var(--hairline-strong);
  border-radius: 99px;
  padding: 2px 9px;
  cursor: default;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.plan-soon:hover { border-color: var(--acid-line); color: var(--text-dim); }
.plan-soon em { font-style: normal; color: var(--acid); opacity: 0.7; }

/* ————————————————————————————————— buttons ———————————————————————————— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  padding: 11px 18px;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  width: 100%;
  background: var(--acid);
  color: #0b0d05;
  font-size: 15.5px;
  padding: 13px 18px;
  letter-spacing: 0.1px;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 30px rgba(184, 255, 46, 0.28);
  transform: translateY(-1px);
}
.btn-primary.busy {
  background: var(--panel-2);
  color: var(--acid);
  border-color: var(--acid-line);
}
.btn-secondary {
  background: var(--bg-raise);
  color: var(--text);
  border-color: var(--hairline-strong);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--acid-line); color: var(--acid); }
.linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--text-faint);
  text-underline-offset: 3px;
  transition: color 0.16s var(--ease);
}
.linklike:hover { color: var(--acid); }

.generate-row { display: flex; }

/* ————————————————————————————————— statusline ————————————————————————— */
.statusline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--hairline);
  padding-top: 13px;
  margin-top: 2px;
  min-height: 18px;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 99px;
  flex: none;
  transition: background 0.2s;
}
.status-dot.idle { background: var(--text-faint); }
.status-dot.busy { background: var(--acid); animation: pulse 1.1s ease-in-out infinite; }
.status-dot.play { background: var(--acid); animation: pulse 0.46s ease-in-out infinite; }
.status-dot.error { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(184, 255, 46, 0.4); }
  50% { opacity: 0.55; box-shadow: 0 0 0 5px rgba(184, 255, 46, 0); }
}

/* ————————————————————————————————— player ————————————————————————————— */
.player-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--hairline);
  background: var(--panel);
}
.transport { display: flex; gap: 7px; }
.btn-play {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--acid);
  color: #0b0d05;
  font-size: 12px;
  padding: 0;
  position: relative;
}
.btn-play:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(184, 255, 46, 0.35); }
.btn-play.playing { background: var(--panel-2); color: var(--acid); border: 1px solid var(--acid-line); }
.btn-play.playing::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 13px;
  border: 1px solid var(--acid-line);
  animation: ring 1.35s var(--ease) infinite;
}
@keyframes ring {
  from { transform: scale(0.92); opacity: 0.9; }
  to { transform: scale(1.14); opacity: 0; }
}
.btn-update { font-family: var(--mono); font-size: 11.5px; padding: 0 12px; height: 34px; }
.btn-update.dirty {
  border-color: var(--acid-line);
  color: var(--acid);
  animation: pulse 1.4s ease-in-out infinite;
}
.player-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.player-readouts { display: flex; gap: 7px; }
.readout {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--hairline);
  padding: 4px 9px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.editor-shell { position: relative; background: #0c0e11; flex: 1; min-height: 0; overflow: hidden; }
.stream-preview {
  margin: 0;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c7cdd6;
  height: 100%;
  overflow-y: auto;
}
.stream-preview .tok-comment { color: #6b7280; }
.stream-preview .tok-string { color: var(--acid); }
.stream-preview .tok-number { color: #7dd3fc; }
.stream-caret { color: var(--acid); animation: blink 0.8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.editor-host { height: 100%; overflow-y: auto; }
.editor-host .cm-editor { background: transparent !important; padding: 8px 6px; height: 100%; }
.editor-host .cm-scroller { overflow-y: auto; }
.editor-host .cm-editor .cm-gutters { background: transparent !important; border-right: 1px solid var(--hairline) !important; }
.editor-host .cm-editor .cm-activeLine { background: rgba(255, 255, 255, 0.03) !important; }
.editor-host .cm-editor.cm-focused { outline: none !important; }
.engine-veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 14, 17, 0.82);
  backdrop-filter: blur(3px);
  animation: fadein 0.25s var(--ease);
  z-index: 5;
}
.engine-veil.retry { cursor: pointer; }
.engine-veil.retry .spinner { animation: none; border-top-color: var(--danger); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.engine-veil-inner {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
}
.spinner {
  width: 14px; height: 14px;
  border-radius: 99px;
  border: 2px solid var(--hairline-strong);
  border-top-color: var(--acid);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.player-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-top: 1px solid var(--hairline);
  background: var(--panel);
  flex-wrap: wrap;
}
.save-group { display: flex; gap: 7px; align-items: center; }
#save-title {
  background: var(--bg-raise);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 7px 10px;
  width: 180px;
  transition: border-color 0.18s var(--ease);
}
#save-title:focus { outline: none; border-color: var(--acid-line); }
#btn-save { font-family: var(--mono); font-size: 11.5px; padding: 7px 12px; }
.share-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--acid-soft);
  border: 1px solid var(--acid-line);
  border-radius: 99px;
  padding: 4px 11px;
  animation: rise 0.3s var(--ease);
}
.share-pill a { color: var(--acid); text-decoration: none; }
.spacer { flex: 1; }

.statusline {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--hairline);
  background: var(--panel-2);
  padding: 6px 14px;
  min-height: 26px;
}
.status-dot { width: 6px; height: 6px; border-radius: 99px; flex: none; transition: background 0.2s; }
.status-dot.idle { background: var(--text-faint); }
.status-dot.busy { background: var(--acid); animation: pulse 1.1s ease-in-out infinite; }
.status-dot.play { background: var(--acid); animation: pulse 0.46s ease-in-out infinite; }
.status-dot.error { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(184, 255, 46, 0.4); }
  50% { opacity: 0.55; box-shadow: 0 0 0 5px rgba(184, 255, 46, 0); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ————————————————————————————— about modal ———————————————————————————— */
.about-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 9, 11, 0.6);
  backdrop-filter: blur(14px) saturate(0.8);
  -webkit-backdrop-filter: blur(14px) saturate(0.8);
  animation: fadein 0.22s var(--ease);
}
.about-backdrop.closing { animation: fadeout 0.18s var(--ease) forwards; }
@keyframes fadeout { to { opacity: 0; } }
.about-card {
  position: relative;
  width: min(860px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  padding: 34px 34px 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: pop 0.28s var(--ease);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.about-close { position: absolute; top: 14px; right: 16px; font-size: 14px; }
.about-kicker {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--acid);
  margin: 0 0 12px;
}
.about-card h2 {
  font-size: clamp(22px, 3.2vw, 32px);
  font-weight: 600;
  letter-spacing: -0.8px;
  line-height: 1.15;
  margin: 0 0 26px;
}
.about-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--hairline);
}
@media (max-width: 720px) { .about-cols { grid-template-columns: 1fr; gap: 22px; } }
.about-cols h3 {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--acid);
  margin: 0 0 8px;
  font-weight: 600;
}
.about-cols p { margin: 0; color: var(--text-dim); font-size: 13.5px; line-height: 1.65; }
.about-foot {
  margin: 16px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
}

/* ————————————————————————————————— toast —————————————————————————————— */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--acid-line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  border-radius: 99px;
  padding: 9px 18px;
  z-index: 50;
  animation: toast-in 0.25s var(--ease);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.toast.out { opacity: 0; transition: opacity 0.3s; }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

/* ————————————————————————— download menu ——————————————————————————— */
.dl-wrap { position: relative; }
.dl-trigger[aria-expanded='true'] { color: var(--acid); }
.dl-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 236px;
  background: var(--panel-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  padding: 5px;
  z-index: 40;
  animation: dl-in 0.18s var(--ease);
}
@keyframes dl-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.dl-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s var(--ease);
}
.dl-item:hover:not(:disabled) { background: var(--acid-soft); }
.dl-item:disabled { opacity: 0.4; cursor: not-allowed; }
.dl-ext { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.dl-item:hover:not(:disabled) .dl-ext { color: var(--acid); }
.dl-note { font-family: var(--mono); font-size: 10px; color: var(--text-faint); margin-left: auto; }
.dl-sep { height: 1px; background: var(--hairline); margin: 5px 4px; }
.dl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 7px;
}
.dl-row-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  flex: 1;
}
#dl-seconds {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 6px;
}
#dl-seconds:focus { outline: none; border-color: var(--acid-line); }
.dl-foot {
  margin: 6px 4px 3px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--text-faint);
}
.dl-foot.working { color: var(--acid); }
