:root {
  --bg: #0d0c10;
  --panel: #15131b;
  --panel-2: #1c1925;
  --line: #2a2733;
  --ink: #e8e6ef;
  --ink-dim: #9a96a8;
  --accent: #c9a24b;       /* brass / courtroom gold */
  --accent-soft: #c9a24b22;
  --judge: #7da7d9;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

/* ── topbar ── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #16131d, #110f16);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.brand span { color: var(--accent); }
.tabs { display: flex; gap: 6px; margin-left: 8px; }
.tabs button {
  background: transparent; border: 1px solid transparent; color: var(--ink-dim);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--bg); background: var(--accent); font-weight: 600; }
.reset { margin-left: auto; font-size: 13px; color: var(--ink-dim); font-family: var(--mono); }
.reset span { color: var(--accent); }

/* ── views ── */
.view { flex: 1; padding: 22px; max-width: 1100px; width: 100%; margin: 0 auto; }
.hidden { display: none; }

.topic-panel { margin-bottom: 18px; }
.topic-label { font-size: 11px; letter-spacing: 2px; color: var(--ink-dim); }
.topic-panel h1 { font-size: 26px; margin: 6px 0 8px; font-weight: 600; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-dim); font-family: var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: #5fd08a; box-shadow: 0 0 8px #5fd08a88; }
.dot.off { background: #d0625f; }

/* ── court layout ── */
.court { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 720px) {
  .court { grid-template-columns: 1fr; }
}

.gallery {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; position: sticky; top: 84px;
}
.gallery-title { font-size: 11px; letter-spacing: 1.5px; color: var(--ink-dim); margin-bottom: 10px; }
#roster {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px;
  /* Cap height so a full 5-agent court scrolls inside the panel instead of
     stretching it. 84px topbar + ~46px title/padding -> leave the rest. */
  max-height: calc(100vh - 84px - 46px); overflow-y: auto; padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
#roster::-webkit-scrollbar { width: 6px; }
#roster::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
#roster::-webkit-scrollbar-track { background: transparent; }

/* Mobile: gallery sits on top full-width. A vertical list of 5 members eats
   the whole screen, so turn the roster into a horizontal swipeable strip —
   slide sideways through attendees. MUST come after the base #roster rules
   above (equal specificity → source order wins). */
@media (max-width: 720px) {
  .gallery { position: static; top: auto; }
  #roster {
    flex-direction: row; max-height: none;
    overflow-x: auto; overflow-y: hidden;
    padding: 2px 0 8px; gap: 10px; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  #roster .member {
    flex: 0 0 auto; min-width: 140px; max-width: 200px; scroll-snap-align: start;
  }
}
.member {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 10px; background: var(--panel-2); border: 1px solid transparent;
  transition: border-color .2s, background .2s;
}
.member.speaking { border-color: var(--accent); background: var(--accent-soft); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: #2c2738; color: var(--accent);
}
.member .meta { min-width: 0; }
.member .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .role { font-size: 11px; color: var(--ink-dim); text-transform: capitalize; }

/* ── feed ── */
.feed-wrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px;
  /* Own scroll context: the debate box scrolls internally so the topbar +
     topic + roster stay put (fixes topbar covering content on mobile) and
     new messages auto-stick to the bottom. */
  max-height: calc(100vh - 200px); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  scroll-behavior: smooth;
}
.feed-wrap::-webkit-scrollbar { width: 8px; }
.feed-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.feed-wrap::-webkit-scrollbar-track { background: transparent; }
.feed { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.bubble { padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); animation: rise .35s ease; overflow-wrap: anywhere; word-break: break-word; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bubble .head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.bubble .who { font-weight: 600; font-size: 14px; }
.bubble .role { font-size: 11px; color: var(--ink-dim); text-transform: capitalize; }
.bubble .kind { margin-left: auto; font-size: 10px; letter-spacing: 1px; color: var(--ink-dim); text-transform: uppercase; font-family: var(--mono); }
.bubble .ts { font-size: 10px; color: var(--ink-dim); font-family: var(--mono); margin-left: 8px; }
.bubble .text { font-size: 15px; }

.bubble.kind-concede { border-left: 3px solid #d6a05f; }
.bubble.kind-agree { border-left: 3px solid #6fae7e; }
.bubble.kind-rebuttal { border-left: 3px solid #c47b7b; }

.bubble.judge { background: #161d28; border-color: #2c3a4d; }
.bubble.judge .who { color: var(--judge); }
.bubble.judge .text { color: #d6e2f0; }

.sys { text-align: center; font-size: 12px; color: var(--ink-dim); font-style: italic; padding: 2px; overflow-wrap: anywhere; }
.sys .ts { font-style: normal; font-family: var(--mono); font-size: 10px; opacity: .7; margin-left: 6px; }

/* ── archive ── */
.archive { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
@media (max-width: 720px) { .archive { grid-template-columns: 1fr; } }
.archive-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.archive-list li {
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; transition: border-color .2s;
}
.archive-list li:hover { border-color: var(--accent); }
.archive-list .q { font-size: 14px; font-weight: 600; }
.archive-list .d { font-size: 11px; color: var(--ink-dim); font-family: var(--mono); margin-top: 2px; }
.muted { color: var(--ink-dim); padding: 14px; }
