:root {
  --bg: #0b0d12;
  --bg-rail: #0f1219;
  --bg-panel: #141924;
  --bg-input: #0c0f16;
  --line: #222a38;
  --line-soft: #1a202b;
  --ink: #e6ebf5;
  --ink-dim: #8d99ae;
  --ink-faint: #5d6779;
  --accent: #5b8cff;
  --danger: #ff6b6b;
  --ok: #3ecf8e;
  --warn: #e8b64c;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
/* An element given `display` by a rule would otherwise ignore the attribute,
   and every hidden panel on this page has one. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: 320px 1fr; height: 100dvh; }

/* ---------- rail ---------- */
.rail {
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 18px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.rail-head .brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px rgba(91,140,255,.15);
  flex: none;
}
.rail h1 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { margin: 0; font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }

.panel { background: var(--bg-panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px; }
.panel-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint); margin-bottom: 9px; display: flex; justify-content: space-between; align-items: baseline;
}
.hint { text-transform: none; letter-spacing: 0; font-size: 10px; }

textarea, input[type=text] {
  width: 100%; background: var(--bg-input); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 10px; resize: vertical; outline: none;
}
textarea:focus, input:focus { border-color: var(--accent); }
#topic { font-size: 13px; line-height: 1.5; margin-bottom: 8px; }

.btn {
  background: #1b2231; border: 1px solid var(--line); color: var(--ink);
  border-radius: 9px; padding: 8px 12px; cursor: pointer; transition: .12s;
  font-size: 13px; font-weight: 500;
}
.btn:hover:not(:disabled) { background: #232c3e; border-color: #33405a; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #05070c; font-weight: 650; }
.btn-primary:hover:not(:disabled) { background: #7aa1ff; border-color: #7aa1ff; }
.btn-danger:hover:not(:disabled) { background: #3a1d22; border-color: #6d3038; color: #ffb3b3; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.pace { margin-top: 12px; display: grid; gap: 3px; }
.pace label { font-size: 11px; color: var(--ink-dim); display: flex; justify-content: space-between; }
.pace label span { color: var(--ink); font-family: var(--mono); font-size: 11px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 0 0 8px; }

/* ---------- roster ---------- */
.floor-note { margin: 10px 0 0; font-size: 11px; line-height: 1.5; color: var(--ink-faint); }

.roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.seat {
  border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 10px;
  background: #0e131c; position: relative; overflow: hidden; transition: .15s;
}
.seat.is-speaking { border-color: var(--seat); box-shadow: 0 0 0 1px var(--seat) inset; }
.seat.is-muted { opacity: .45; }
.seat.is-resting { border-color: rgba(232,182,76,.35); }
.seat-tag.resting { color: var(--warn); border-color: rgba(232,182,76,.5); }
.seat-rest { font-size: 10.5px; font-family: var(--mono); color: var(--warn); margin-top: 6px; }
.seat-top { display: flex; align-items: center; gap: 8px; }
.seat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--seat); flex: none; }
.seat-name { font-weight: 600; font-size: 13px; }
.seat-tag {
  margin-left: auto; font-size: 9.5px; font-family: var(--mono); letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line);
  color: var(--ink-faint);
}
.seat-tag.now { color: #05070c; background: var(--seat); border-color: var(--seat); font-weight: 700; }
.seat-tag.next { color: var(--seat); border-color: var(--seat); }
.seat-model { font-size: 10.5px; font-family: var(--mono); color: var(--ink-faint); margin: 5px 0 7px; word-break: break-all; }
.seat-acts { display: flex; gap: 6px; }
.seat-acts .btn { padding: 4px 8px; font-size: 11px; }
.seat-health { font-size: 10.5px; font-family: var(--mono); margin-top: 6px; }
.seat-health.ok { color: var(--ok); }
.seat-health.bad { color: var(--danger); }

/* ---------- the showcase ---------- */
.archive { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 340px; overflow-y: auto; }
.archive li { position: relative; }
.archive button {
  width: 100%; text-align: left; background: #0e131c; border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 9px 10px; cursor: pointer; transition: .12s; color: inherit;
}
.archive button:hover { background: #141b27; border-color: #2b3547; }
.archive button.open { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.arc-title { font-size: 12.5px; font-weight: 600; line-height: 1.35; display: block; }
.arc-meta { font-size: 10px; font-family: var(--mono); color: var(--ink-faint); margin-top: 5px; display: block; }
.arc-live {
  font-size: 9px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .09em;
  color: #05070c; background: var(--ok); border-radius: 4px; padding: 1px 5px; margin-left: 6px;
}

.archive-bar {
  display: flex; align-items: center; gap: 12px; padding: 9px 20px;
  background: rgba(91,140,255,.07); border-bottom: 1px solid var(--line);
}
.archive-meta { font-size: 11.5px; font-family: var(--mono); color: var(--ink-dim); flex: 1; min-width: 0; }

.probe { margin-top: 8px; display: grid; gap: 5px; font-size: 11px; font-family: var(--mono); }
.probe div { color: var(--ink-dim); word-break: break-word; }
.probe .ok { color: var(--ok); }
.probe .bad { color: var(--danger); }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.stage-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: rgba(11,13,18,.9);
  backdrop-filter: blur(8px);
}
.stage-title { min-width: 0; flex: 1; }
.motion { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.pill {
  font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--ink-dim);
}
.pill.running { color: var(--ok); border-color: rgba(62,207,142,.5); background: rgba(62,207,142,.08); }
.pill.paused { color: var(--warn); border-color: rgba(232,182,76,.5); background: rgba(232,182,76,.08); }
.meta-num { font-size: 10.5px; font-family: var(--mono); color: var(--ink-faint); }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.conn.live { background: var(--ok); box-shadow: 0 0 8px rgba(62,207,142,.8); }
.rail-toggle { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink-dim); }

.transcript { flex: 1; overflow-y: auto; padding: 22px 20px 8px; scroll-behavior: smooth; }
.empty { color: var(--ink-faint); text-align: center; margin: 60px auto; max-width: 460px; font-size: 14px; }
.empty strong { color: var(--ink-dim); display: block; margin-bottom: 6px; font-size: 15px; }

.turn { display: flex; gap: 12px; margin: 0 auto 20px; max-width: 780px; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: color-mix(in srgb, var(--seat) 18%, transparent);
  color: var(--seat); border: 1px solid color-mix(in srgb, var(--seat) 45%, transparent);
}
.turn-body { min-width: 0; flex: 1; }
.turn-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.turn-name { font-weight: 650; font-size: 13.5px; color: var(--seat); }
.turn-model { font-size: 10px; font-family: var(--mono); color: var(--ink-faint); }
.turn-time { font-size: 10px; font-family: var(--mono); color: var(--ink-faint); margin-left: auto; }
.turn-text { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.turn.human .turn-text {
  background: rgba(232,182,76,.07); border-left: 2px solid var(--warn);
  padding: 9px 12px; border-radius: 0 9px 9px 0;
}
.turn-text .cursor {
  display: inline-block; width: 7px; height: 15px; background: var(--seat);
  vertical-align: -2px; animation: blink 1s steps(2) infinite; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }
/* Written by the room about a seat — never a model's words, and it must not
   be possible to mistake one for the other. */
.turn-system .turn-text {
  background: rgba(232,182,76,.06); border: 1px dashed rgba(232,182,76,.4);
  padding: 9px 12px; border-radius: 9px; color: #e6d3a8; font-size: 13.5px;
}
.turn-system .turn-name { color: var(--warn); }
.turn-system .avatar { --seat: var(--warn); }
.sys-tag {
  font-size: 9px; font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--warn); border: 1px solid rgba(232,182,76,.45); border-radius: 4px; padding: 1px 5px;
}
.turn-error {
  font-family: var(--mono); font-size: 11.5px; color: #ffb3b3;
  background: rgba(255,107,107,.07); border-left: 2px solid var(--danger);
  padding: 8px 11px; border-radius: 0 9px 9px 0; white-space: pre-wrap; word-break: break-word;
}
.notice {
  max-width: 780px; margin: 0 auto 18px; text-align: center; font-size: 12px;
  color: var(--ink-faint); font-family: var(--mono);
}

.on-deck {
  min-height: 20px; padding: 0 20px 6px; font-size: 11.5px; font-family: var(--mono);
  color: var(--ink-faint); max-width: 820px; margin: 0 auto; width: 100%;
}
.on-deck b { color: var(--ink-dim); font-weight: 500; }

.composer { display: flex; gap: 9px; padding: 10px 20px 4px; max-width: 820px; margin: 0 auto; width: 100%; align-items: flex-end; }
.composer textarea { max-height: 180px; min-height: 44px; }
.composer .btn { height: 44px; padding: 0 20px; }
.composer-note { max-width: 820px; margin: 0 auto; padding: 0 20px 14px; width: 100%; font-size: 11px; color: var(--ink-faint); }
.composer-note strong { color: var(--warn); font-weight: 600; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 300px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .rail.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .rail-toggle { display: block; }
}
