/* ==========================================================================
   Bulletin Studio — Broadcast Control Room
   A late-night studio: warm darks, tungsten amber, editorial serif draft.
   No Tailwind. Every token is intentional.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..900;1,9..144,300..900&family=Instrument+Sans:ital,wght@0,400..700;1,400..700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Canvas: warm darks, like an analog console at 2am */
  --bg-0: #0d0b08;
  --bg-1: #141110;
  --bg-2: #1c1813;
  --bg-3: #241f18;
  --surface-glass: rgba(28, 24, 19, 0.62);

  --border: #2a251e;
  --border-bright: #3d352a;
  --border-glow: #5a4a33;

  --text: #ece6d9;
  --text-muted: #998f80;
  --text-dim: #625a4e;
  --text-dim: #fff;
  --text-ghost: #3e392f;

  /* Signature accent: tungsten amber — the warning band of a VU meter */
  --amber: #e8b84d;
  --amber-bright: #f5cb63;
  --amber-dim: #8a6e2b;
  --amber-glow: rgba(232, 184, 77, 0.18);

  /* Live-broadcast red, used sparingly */
  --on-air: #e84a3c;
  --on-air-glow: rgba(232, 74, 60, 0.45);

  /* State colors — muted, not Tailwind-default */
  --signal: #9fb58a;
  --signal-dim: #4e6043;
  --alert: #e8a54a;
  --danger: #d85a54;

  /* Typography */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-ui: 'Instrument Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;

  /* Radii */
  --r-sm: 2px;
  --r-md: 4px;
  --r-lg: 8px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snap: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & base ================================================= */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(232, 184, 77, 0.05), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(232, 74, 60, 0.03), transparent 70%),
    var(--bg-0);
  position: relative;
}

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

button { cursor: pointer; background: none; border: none; padding: 0; }
button:disabled { opacity: 0.35; cursor: not-allowed; }

.hidden { display: none !important; }

/* ===== Grain overlay: subtle 70s film texture ======================= */

.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}

/* ===== Header / console top ========================================= */

.console-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 22px 40px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-1) 0%, transparent 100%);
}

.console-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright) 20%, var(--border-bright) 80%, transparent);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 20px;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 26px;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 96, 'SOFT' 50;
  color: var(--text);
}

.brand-mark em {
  font-style: italic;
  color: var(--amber);
  font-weight: 400;
}

.brand-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

/* ON-AIR indicator */
.on-air {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  transition: all 240ms var(--ease);
}

.on-air-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-ghost);
  box-shadow: inset 0 0 3px rgba(0,0,0,0.6);
  transition: all 240ms var(--ease);
}

.on-air.live {
  border-color: var(--on-air);
  color: var(--on-air);
  background: rgba(232, 74, 60, 0.06);
}

.on-air.live .on-air-dot {
  background: var(--on-air);
  box-shadow: 0 0 0 0 var(--on-air-glow), inset 0 0 4px rgba(255, 200, 190, 0.5);
  animation: onAirPulse 1.4s ease-in-out infinite;
}

@keyframes onAirPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--on-air-glow), inset 0 0 4px rgba(255, 200, 190, 0.5); }
  50%      { box-shadow: 0 0 0 8px transparent, inset 0 0 4px rgba(255, 200, 190, 0.9); }
}

/* ===== Buttons ======================================================= */

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-approve,
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 9px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: all 140ms var(--ease-snap);
  white-space: nowrap;
  line-height: 1;
}

/* Primary — tungsten amber, the signature action */
.btn-primary {
  background: var(--amber);
  color: var(--bg-0);
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 8px 24px -10px rgba(232, 184, 77, 0.5);
}
.btn-primary:hover:not(:disabled) {
  background: var(--amber-bright);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 12px 28px -10px rgba(232, 184, 77, 0.7);
}
.btn-primary:active { transform: translateY(0); }

/* Approve — the "send it to air" gesture */
.btn-approve {
  background: transparent;
  color: var(--signal);
  border: 1px solid var(--signal-dim);
  font-weight: 600;
}
.btn-approve:hover:not(:disabled) {
  background: rgba(159, 181, 138, 0.08);
  border-color: var(--signal);
  color: #c3d4b2;
}

/* Secondary — quiet, for retries and saves */
.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-bright);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border-glow);
}

/* Ghost — text-only, for destructive/cancel */
.btn-ghost {
  color: var(--text-dim);
  padding: 9px 10px;
}
.btn-ghost:hover:not(:disabled) { color: var(--danger); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(216, 90, 84, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(216, 90, 84, 0.08);
  border-color: var(--danger);
}

.btn-primary svg,
.btn-approve svg,
.btn-secondary svg { width: 14px; height: 14px; }

/* ===== Main layout =================================================== */

.console-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  min-height: calc(100vh - 72px);
}

/* ===== Rundown (history panel) ======================================= */

.rundown {
  border-right: 1px solid var(--border);
  padding: 28px 24px 40px;
  background: linear-gradient(180deg, rgba(20, 17, 16, 0.4), transparent 200px);
}

.rundown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}

.rundown-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
}

.rundown-title::before {
  content: "// ";
  color: var(--amber-dim);
}

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

.rundown-item {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px 14px 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-1);
  transition: all 180ms var(--ease);
  cursor: pointer;
  opacity: 0;
  animation: rundownIn 420ms var(--ease) forwards;
}

@keyframes rundownIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.rundown-item:hover {
  border-color: var(--border-glow);
  background: var(--bg-2);
}

.rundown-item.is-selected {
  border-color: var(--amber-dim);
  background: linear-gradient(90deg, rgba(232, 184, 77, 0.06), transparent 60%);
}

.rundown-item.is-selected::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 2px;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}

.rundown-item-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.kind-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  fill: none;
}

.kind-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-ghost);
  flex-shrink: 0;
}
.state-dot.is-pending { background: var(--amber); animation: dotPulse 1.2s ease-in-out infinite; }
.state-dot.is-review  { background: var(--alert); }
.state-dot.is-done    { background: var(--signal); }
.state-dot.is-fail    { background: var(--danger); }
.state-dot.is-cancel  { background: var(--text-dim); }

@keyframes dotPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.2); }
}

.state-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rundown-item-time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.rundown-item-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  font-variation-settings: 'opsz' 14;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.rundown-item-excerpt {
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}

.rundown-empty {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  line-height: 1.7;
}

/* ===== Console (detail panel) ======================================== */

.console {
  padding: 40px 56px 80px;
  min-width: 0;
}

/* Empty state: hero treatment */
.console-empty {
  padding-top: 80px;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.console-empty-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--amber);
  margin-bottom: 24px;
}

.console-empty-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 72px;
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variation-settings: 'opsz' 96, 'SOFT' 30;
  margin: 0 0 20px;
  color: var(--text);
}

.console-empty-title em {
  font-style: italic;
  color: var(--amber);
  font-weight: 400;
}

.console-empty-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 480px;
  margin: 0 auto 48px;
}

.pipeline-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 48px 0 0;
}

.pipeline-diagram-step {
  padding: 14px 28px;
  border: 1px solid var(--border-bright);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  background: var(--bg-1);
}

.pipeline-diagram-arrow {
  width: 42px;
  height: 1px;
  background: linear-gradient(90deg, var(--border-bright), var(--amber-dim), var(--border-bright));
  position: relative;
}

.pipeline-diagram-arrow::after {
  content: "";
  position: absolute;
  right: -4px;
  top: -3px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--amber-dim);
  border-top: 1px solid var(--amber-dim);
  transform: rotate(45deg);
}

/* ===== Detail — bulletin view ======================================== */

.detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.detail-kind {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border-bright);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}

.detail-kind .kind-icon {
  stroke: var(--amber);
  width: 14px;
  height: 14px;
}

.detail-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.detail-summary {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.detail-error {
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(216, 90, 84, 0.35);
  background: rgba(216, 90, 84, 0.06);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--danger);
  letter-spacing: 0.02em;
}

/* ===== Pipeline with rail ============================================ */

.pipeline {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 0;
  padding-top: 32px;
}

.rail {
  position: relative;
  padding-top: 16px;
}

.rail-line {
  position: absolute;
  left: 50%;
  top: 16px;
  bottom: 16px;
  width: 1px;
  background: linear-gradient(180deg, var(--border), var(--border-bright) 20%, var(--border-bright) 80%, var(--border));
  transform: translateX(-50%);
}

.rail-node {
  position: relative;
  width: 14px;
  height: 14px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--bg-0);
  border: 1px solid var(--border-bright);
  transition: all 240ms var(--ease);
}

.rail-node[data-step="text"]      { margin-top: 28px; }
.rail-node[data-step="voice"]     { margin-top: calc(50vh * 0 + 280px); }
.rail-node[data-step="published"] { margin-top: 280px; }

.rail-node.is-done {
  background: var(--signal);
  border-color: var(--signal);
  box-shadow: 0 0 12px rgba(159, 181, 138, 0.4);
}

.rail-node.is-active {
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-glow), 0 0 16px rgba(232, 184, 77, 0.5);
  animation: nodeActive 1.8s ease-in-out infinite;
}

@keyframes nodeActive {
  0%, 100% { box-shadow: 0 0 0 4px var(--amber-glow), 0 0 16px rgba(232, 184, 77, 0.5); }
  50%      { box-shadow: 0 0 0 8px transparent, 0 0 20px rgba(232, 184, 77, 0.75); }
}

.rail-node.is-fail {
  background: var(--danger);
  border-color: var(--danger);
}

/* The "signal" dot that runs down the rail */
.rail-signal {
  position: absolute;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber), 0 0 16px var(--amber-dim);
  opacity: 0;
  pointer-events: none;
  animation: signalTravel 2.2s var(--ease) infinite;
}

.pipeline.has-active-signal .rail-signal {
  opacity: 1;
}

@keyframes signalTravel {
  0%   { top: 16px; opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { top: calc(100% - 16px); opacity: 0; }
}

.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-left: 24px;
}

/* ===== Step cards ==================================================== */

.step {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-1);
  overflow: hidden;
  transition: border-color 240ms var(--ease);
}

.step.is-active {
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 1px rgba(232, 184, 77, 0.08), 0 20px 60px -30px rgba(232, 184, 77, 0.25);
}

.step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-2), transparent);
}

.step-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
}

.step-title-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--amber-dim);
  border-radius: 50%;
  font-size: 9px;
  color: var(--amber);
  background: rgba(232, 184, 77, 0.06);
}

.step-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.step-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.step-actions .spacer { flex: 1; }

/* ===== Text editor (the draft) ======================================= */

.draft-editor {
  width: 100%;
  min-height: 240px;
  padding: 24px 28px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.7;
  font-variation-settings: 'opsz' 14;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 140ms var(--ease);
}

.draft-editor:focus {
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px var(--amber-glow);
}

.draft-editor::selection {
  background: var(--amber);
  color: var(--bg-0);
}

.draft-editor[readonly] {
  color: var(--text-muted);
  cursor: default;
  background: var(--bg-1);
}

.draft-editor[readonly]:focus {
  border-color: var(--border);
  box-shadow: none;
}

/* ===== Refine prompt panel ========================================== */

.refine-panel {
  margin-top: 14px;
  padding: 16px 18px;
  background: var(--bg-1);
  border: 1px solid var(--amber-dim);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 3px var(--amber-glow) inset;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.refine-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.refine-editor {
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 6px);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 140ms var(--ease);
}

.refine-editor:focus {
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px var(--amber-glow);
}

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

.refine-actions .spacer { flex: 1; }

/* Locked state: greys the step chrome, shows "LOCKED" chip in the header */
.step.is-locked .step-title { color: var(--text-dim); }
.step.is-locked .step-title-num {
  border-color: var(--border-bright);
  color: var(--text-dim);
  background: var(--bg-2);
}

.step.is-locked .step-head::after {
  content: "LOCKED";
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  margin-left: 14px;
  border: 1px solid var(--border-bright);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  background: var(--bg-2);
}

/* When generating: show scanning bars instead of editor */
.draft-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 240px;
  justify-content: center;
}

.draft-loading-bar {
  height: 14px;
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  border-radius: 2px;
  animation: shimmer 1.4s linear infinite;
}

.draft-loading-bar:nth-child(1) { width: 94%; }
.draft-loading-bar:nth-child(2) { width: 88%; animation-delay: 0.15s; }
.draft-loading-bar:nth-child(3) { width: 96%; animation-delay: 0.3s; }
.draft-loading-bar:nth-child(4) { width: 72%; animation-delay: 0.45s; }
.draft-loading-bar:nth-child(5) { width: 84%; animation-delay: 0.6s; }

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

/* ===== Custom audio player (the hero) ================================ */

.player {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  padding: 22px 24px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  align-items: center;
}

.player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 1px solid var(--amber-dim);
  background: radial-gradient(circle at 30% 30%, rgba(232, 184, 77, 0.2), rgba(232, 184, 77, 0.04));
  border-radius: 50%;
  color: var(--amber);
  transition: all 140ms var(--ease-snap);
  position: relative;
}

.player-btn::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid transparent;
  transition: border-color 240ms var(--ease);
}

.player-btn:hover {
  background: radial-gradient(circle at 30% 30%, rgba(232, 184, 77, 0.3), rgba(232, 184, 77, 0.08));
  color: var(--amber-bright);
}
.player-btn:hover::before { border-color: var(--amber-dim); }

.player-btn svg { width: 20px; height: 20px; fill: currentColor; }

.player-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.waveform {
  position: relative;
  height: 76px;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 2px;
}

.waveform canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.waveform-times {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.waveform-times .elapsed { color: var(--amber); }

/* Synthesis loading: oscilloscope-style sine */
.player.is-loading .waveform {
  overflow: hidden;
}
.player.is-loading .waveform::after {
  content: "SYNTHESISING";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--amber);
  animation: flicker 2s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ===== Published step ================================================ */

.step.is-published {
  border-color: var(--signal-dim);
  background: linear-gradient(180deg, rgba(159, 181, 138, 0.04), var(--bg-1));
}

.step.is-published .step-head {
  border-bottom-color: var(--signal-dim);
}

.step.is-published .step-title {
  color: var(--signal);
}

.step.is-published .step-title-num {
  border-color: var(--signal-dim);
  color: var(--signal);
  background: rgba(159, 181, 138, 0.06);
}

.published-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.published-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 16px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.published-row:last-child { border-bottom: none; }

.published-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.published-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  word-break: break-all;
  letter-spacing: 0.02em;
}

.published-seal {
  position: absolute;
  top: 14px;
  right: 22px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--signal);
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid var(--signal-dim);
  border-radius: 2px;
  transform: rotate(-4deg);
}

.step.is-published .step-head { position: relative; }

/* ===== Status line =================================================== */

.status-line {
  margin-top: 24px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
  border-top: 1px dashed var(--border);
  min-height: 2em;
}

.status-line::before { content: "» "; color: var(--amber); }
.status-line.is-error { color: var(--danger); }
.status-line.is-error::before { color: var(--danger); }

/* ===== Modal ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 6, 4, 0.8);
  backdrop-filter: blur(10px);
  animation: fadeIn 200ms var(--ease);
}

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 24px 320px;   /* extra bottom space so the voice dropdown
                                  (opens downward) can scroll into view */
  overflow-y: auto;
}

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg-1);
  border: 1px solid var(--border-bright);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(232, 184, 77, 0.06);
  animation: modalIn 260ms var(--ease);
  /* NOTE: no overflow:hidden — otherwise the absolutely-positioned flag
     dropdown menus get clipped at the modal boundary. Children that need
     to honour the rounded corners carry their own border-radius. */
  position: relative;
}

.modal::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 24;
  margin: 0;
}

.modal-title em { font-style: italic; color: var(--amber); }

.modal-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  border-radius: var(--r-sm);
  transition: all 140ms var(--ease);
}
.modal-close:hover { color: var(--text); background: var(--bg-2); }

.modal-body {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 26px;
  border-top: 1px solid var(--border);
  background: var(--bg-0);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.modal-head {
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

/* The amber hairline that used to sit at top:0 of .modal must follow the
   rounded corner now that the modal no longer clips overflow. */
.modal::before { border-radius: var(--r-lg) var(--r-lg) 0 0; }

.modal-foot .spacer { flex: 1; }

/* ===== Form ========================================================== */

.form-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.form-label-hint {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text-ghost);
  margin-left: 6px;
  font-style: italic;
}

.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.form-check:hover {
  border-color: var(--accent, #ffa400);
}
.form-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.form-check-dot {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: transparent;
  position: relative;
  margin-top: 2px;
  transition: border-color 0.15s, background-color 0.15s;
}
.form-check input:checked + .form-check-dot {
  border-color: var(--accent, #ffa400);
  background: var(--accent, #ffa400);
}
.form-check input:checked + .form-check-dot::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--bg-0);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.form-check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}
.form-check-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.form-input,
.form-select {
  padding: 11px 14px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.01em;
  transition: all 140ms var(--ease);
  outline: none;
  width: 100%;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px var(--amber-glow);
  background: var(--bg-1);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23998f80' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Flag dropdown (custom, so we can render inline SVG flags) */
.select-flag {
  position: relative;
  width: 100%;
}

.select-flag-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: all 140ms var(--ease);
}

.select-flag-trigger:hover { border-color: var(--border-glow); }

.select-flag.is-open .select-flag-trigger {
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px var(--amber-glow);
  background: var(--bg-1);
}

.select-flag-current {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.select-flag-current .flag {
  width: 22px;
  height: 15px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}

/* Song row: preview play button on the right of each option.
   The outer option stays clickable; the play button stops propagation so
   sampling doesn't also select the song. */
.song-select .select-flag-current .song-icon,
.select-flag-option .song-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(232, 184, 77, 0.08);
  border: 1px solid var(--border-bright);
  color: var(--amber);
}
.song-icon svg { width: 11px; height: 11px; }

.song-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-bright);
  color: var(--text-muted);
  background: var(--bg-1);
  transition: all 140ms var(--ease);
  flex-shrink: 0;
}
.song-preview:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(232, 184, 77, 0.1);
}
.song-preview.is-playing {
  border-color: var(--amber);
  color: var(--bg-0);
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-glow);
}
.song-preview svg { width: 11px; height: 11px; fill: currentColor; }

.song-preview.is-pending {
  border-color: var(--amber-dim);
  color: var(--amber);
  background: transparent;
}
.song-preview.is-pending svg { display: none; }
.song-preview.is-pending::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--amber-dim);
  border-top-color: var(--amber);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Voice dropdown: language tag sits between the name and the preview button */
.voice-lang,
.voice-lang-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 6px;
  margin-left: auto;
  border: 1px solid var(--border-bright);
  background: var(--bg-0);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.voice-lang .flag,
.voice-lang-tag .flag {
  width: 14px;
  height: 10px;
  border-radius: 1px;
  flex-shrink: 0;
}

.select-flag-option.is-voice {
  gap: 10px;
}

.select-flag-option.is-voice .song-name {
  flex: 0 1 auto;
  max-width: 120px;
}

.select-flag-option.is-voice .voice-lang-tag {
  margin-left: 0;
}

.select-flag-option.is-voice .song-preview {
  margin-left: auto;
}

/* Current-value area keeps the lang tag compact on the trigger */
.select-flag-current .voice-lang {
  margin-left: auto;
}

/* Song option: name on the left, preview button on the right */
.select-flag-option.is-song {
  gap: 10px;
}
.select-flag-option.is-song .song-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Gender badge — a small circular chip with the male/female glyph.
   Uses amber for male and a soft rose for female, scaled to the palette. */
.gender-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.gender-badge svg { width: 13px; height: 13px; }

.gender-badge.is-male {
  background: rgba(232, 184, 77, 0.12);
  border-color: var(--amber-dim);
  color: var(--amber);
}

.gender-badge.is-female {
  background: rgba(216, 130, 140, 0.12);
  border-color: rgba(216, 130, 140, 0.45);
  color: #e8a4ae;
}

.select-flag-chev {
  width: 12px;
  height: 8px;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 180ms var(--ease);
}

.select-flag.is-open .select-flag-chev { transform: rotate(180deg); }

.select-flag-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--bg-2);
  border: 1px solid var(--border-bright);
  border-radius: var(--r-md);
  box-shadow: 0 20px 48px -16px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(232, 184, 77, 0.05);
  padding: 4px;
  display: none;
  animation: modalIn 160ms var(--ease);
}

.select-flag.is-open .select-flag-menu { display: block; }

.select-flag-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background 120ms var(--ease);
}

.select-flag-option:hover { background: var(--bg-3); }

.select-flag-option.is-selected {
  background: rgba(232, 184, 77, 0.08);
  color: var(--amber);
}

.select-flag-option .flag {
  width: 22px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.select-flag-option-sub {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* Slider — horizontal range input with amber fill and tick labels */
.slider {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 10px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  background: transparent;
  outline: none;
  cursor: pointer;
  margin: 0;
}

/* WebKit track + thumb */
.slider-input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--amber) 0%,
    var(--amber) var(--slider-pct, 20%),
    var(--bg-3) var(--slider-pct, 20%),
    var(--bg-3) 100%
  );
}
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--bg-0);
  box-shadow: 0 0 0 1px var(--amber-dim), 0 4px 10px -2px rgba(232, 184, 77, 0.5);
  cursor: grab;
  transition: transform 120ms var(--ease);
}
.slider-input:active::-webkit-slider-thumb { transform: scale(1.15); }

/* Firefox */
.slider-input::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-3);
}
.slider-input::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--amber);
}
.slider-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--bg-0);
  box-shadow: 0 0 0 1px var(--amber-dim), 0 4px 10px -2px rgba(232, 184, 77, 0.5);
  cursor: grab;
}

.slider-input:focus::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--amber-glow), 0 0 0 1px var(--amber-dim); }
.slider-input:focus::-moz-range-thumb     { box-shadow: 0 0 0 3px var(--amber-glow), 0 0 0 1px var(--amber-dim); }

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Region chips: multi-select pills */
.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 44px;
  align-content: flex-start;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  background: var(--bg-1);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.01em;
  transition: all 140ms var(--ease);
  cursor: pointer;
}

.chip:hover {
  border-color: var(--border-glow);
  color: var(--text);
}

.chip.is-selected {
  border-color: var(--amber-dim);
  background: rgba(232, 184, 77, 0.1);
  color: var(--amber);
}

.chip.is-selected::before {
  content: "✓";
  margin-right: 6px;
  font-size: 10px;
}

/* Kind selector — tabs */
.kind-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.kind-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--r-sm);
  transition: all 160ms var(--ease);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.kind-tab svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-dim);
  stroke-width: 1.5;
  fill: none;
  transition: all 160ms var(--ease);
}

.kind-tab:hover {
  color: var(--text);
  background: var(--bg-2);
}
.kind-tab:hover svg { stroke: var(--text); }

.kind-tab.is-active {
  background: rgba(232, 184, 77, 0.1);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px var(--amber-dim);
}

.kind-tab.is-active svg { stroke: var(--amber); }

.kind-tab.is-disabled,
.kind-tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.kind-tab.is-disabled::after,
.kind-tab:disabled::after {
  content: "soon";
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-left: 6px;
  opacity: 0.7;
}

/* ===== Scrollbar ===================================================== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border: 2px solid var(--bg-0);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-glow); }

/* ===== Responsive =================================================== */

@media (max-width: 900px) {
  .console-grid { grid-template-columns: 1fr; }
  .rundown { border-right: none; border-bottom: 1px solid var(--border); }
  .console { padding: 32px 24px 60px; }
  .console-empty-title { font-size: 48px; }
  .pipeline { grid-template-columns: 32px 1fr; }
  .pipeline-steps { padding-left: 16px; }
}
