/* Debate Rounds - app-like, compact, dark by default. One accent (lime on dark,
 * deep green on light) used only for the active step and the primary action.
 * Spacing runs on a 4 px grid. */
:root, :root[data-theme="dark"] {
  --bg: #0d0f12;
  --panel: #15181d;
  --panel-2: #1c2026;
  --line: #2a2f37;
  --text: #e6e9ed;
  --muted: #8d96a2;
  --accent: #c6f24e;
  --accent-ink: #0d0f12;
  --good: #5fbf8f;
  --warn: #e0a84a;
  --bad: #e5675b;
  --code-bg: #101317;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.35);
  --r: 8px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f6;
  --panel: #ffffff;
  --panel-2: #eef0f2;
  --line: #d8dce1;
  --text: #15181c;
  --muted: #5b6470;
  --accent: #2f6a00;
  --accent-ink: #ffffff;
  --good: #23784f;
  --warn: #93620a;
  --bad: #b3372b;
  --code-bg: #f1f3f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 18px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.strong { font-weight: 650; }
.hidden { display: none !important; }

/* --- buttons and fields --- */
.btn {
  font: inherit; font-size: 13px; font-weight: 550;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; line-height: 1.3;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.tiny { padding: 2px 6px; font-size: 11px; }
.btn.ghost { background: transparent; }
.btn.icon { padding: 4px 8px; font-size: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); border-color: var(--accent); }
.btn:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible, .step:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea, select, input[type="text"] {
  font: inherit; color: var(--text); background: var(--code-bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px;
  width: 100%;
}
textarea { resize: vertical; min-height: 40px; }
select { width: auto; padding: 6px 8px; }
.field-label { display: block; font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* --- top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mark { width: 24px; height: 24px; color: var(--text); flex: none; }
.brand-text { min-width: 0; }
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.motion-title { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.session { display: flex; align-items: center; gap: 8px; flex: none; }
.chip-link { font-size: 12px; color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.chip-link:hover { color: var(--text); background: var(--panel-2); }
.credits { font-size: 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; }

/* --- shell --- */
.shell {
  flex: 1;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr) 312px;
  gap: 0;
  align-items: start;
}
.rail {
  position: sticky; top: 49px; align-self: start;
  height: calc(100vh - 49px); overflow-y: auto;
  border-right: 1px solid var(--line); padding: 12px 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.step {
  width: 100%; display: grid; grid-template-columns: 24px 1fr 8px; align-items: center; gap: 8px;
  text-align: left; font: inherit; color: var(--text); background: transparent;
  border: 1px solid transparent; border-radius: 6px; padding: 8px; cursor: pointer;
}
.step:hover { background: var(--panel-2); }
.step .num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; border: 1px solid var(--line); color: var(--muted);
}
.st-text { display: flex; flex-direction: column; min-width: 0; }
.st-title { font-size: 13px; font-weight: 600; }
.st-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; border: 1px solid var(--line); }
.step.st-draft .st-dot { background: var(--muted); border-color: var(--muted); }
.step.st-done .st-dot { background: var(--good); border-color: var(--good); }
.step.st-stale .st-dot { background: var(--warn); border-color: var(--warn); }
.step.st-done .num { color: var(--good); border-color: var(--good); }
.step.active { background: var(--panel); border-color: var(--line); }
.step.active .num { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rail-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
.rt-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.rt-value { font-size: 16px; font-weight: 700; }
.rail-block { display: flex; flex-direction: column; gap: 8px; }
.rb-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; padding: 0 4px; }
.rb-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px; }
.sitting-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sit { display: flex; align-items: stretch; border-radius: 6px; }
.sit.current { background: var(--panel); outline: 1px solid var(--line); }
.sit-open {
  flex: 1; min-width: 0; text-align: left; font: inherit; color: var(--text); background: transparent;
  border: 0; padding: 4px 8px; cursor: pointer; display: flex; flex-direction: column; border-radius: 6px;
}
.sit-open:hover { background: var(--panel-2); }
.sit-motion { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- stage --- */
.stage { padding: 16px 20px 32px; min-width: 0; }
.panel { max-width: 860px; }
.panel-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.ph-num {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
}
.panel-head h2 { font-size: 18px; font-weight: 700; }
.panel-head p { font-size: 13px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-3 select { width: 100%; }
.seg { border: 0; padding: 0; margin: 0; }
.seg label { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; font-size: 13px; cursor: pointer; }
.method { margin-top: 16px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r); }
.method h3 { font-size: 13px; margin-bottom: 4px; }
.method-list { margin: 0 0 8px; padding-left: 20px; font-size: 13px; }
.method-list li { margin: 2px 0; }
.handoff { margin-top: 16px; display: flex; justify-content: flex-end; }
.row-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* case editor */
.contentions { display: flex; flex-direction: column; gap: 12px; }
.con-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 8px 12px 12px; }
.con-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.con-peek { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.con-lint { color: var(--muted); }
.slot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.slot { display: flex; flex-direction: column; gap: 4px; }
.slot-top { display: flex; justify-content: space-between; align-items: center; }
.slot-name { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.slot-chip { padding: 0 6px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.slot-chip.filled { color: var(--text); }
.slot-chip.empty { border-style: dashed; }
.slot-chip.strong { color: var(--good); border-color: var(--good); }
.slot-chip.weak { color: var(--warn); border-color: var(--warn); }
.slot-chip.missing { color: var(--bad); border-color: var(--bad); }
.slot textarea { min-height: 52px; font-size: 13px; }

/* opposition */
.case-summary { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.cs-row { display: flex; gap: 8px; align-items: baseline; }
.own-counter { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.own-counter .field-label { margin: 0; }
.own-row { display: flex; gap: 8px; flex-wrap: wrap; }
.own-counter .btn { align-self: flex-start; }
.counter-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.counter-item { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); flex-wrap: wrap; }
.ci-text { flex: 1 1 240px; min-width: 0; }
.tag { font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.tag.bad { color: var(--bad); border-color: var(--bad); }
.tag.accent-outline { color: var(--text); border-color: var(--muted); }
.pips { display: inline-flex; gap: 2px; }
.pip { width: 6px; height: 10px; border-radius: 1px; background: var(--line); }
.pip.on { background: var(--bad); }

/* drill */
.drill { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; }
.drill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.drill-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 4px;
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; cursor: pointer;
}
.drill-item.active { border-color: var(--text); }
.drill-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.drill-attack { font-size: 13px; color: var(--text); }
.timer-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.timer { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; min-width: 72px; }
.timer.over { color: var(--bad); }
.parts { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.part { font-size: 12px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.part.on { color: var(--good); border-color: var(--good); }
.part-meta { margin-left: 4px; }
.attempts { margin-top: 4px; }

/* closing */
.checklist { border: 0; padding: 0; margin: 8px 0 0; }
#checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.check { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; }
#closeLint { margin-top: 4px; }

/* run bar + progress */
.run-bar { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.rb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meter { flex: 1 1 200px; }
.run-gate { margin-top: 8px; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.progress { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.pg-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; }
.pg-steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.pg-steps li { font-size: 11px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.pg-steps li.done { color: var(--good); border-color: var(--good); }
.pg-steps li.now { color: var(--text); border-color: var(--text); }

/* feedback */
.feedback { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.fb-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.headline { font-size: 15px; font-weight: 600; }
.notice { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); }
.notice.warn { border-color: var(--warn); color: var(--warn); }
.recon summary { cursor: pointer; color: var(--muted); }
.recon-list { margin: 4px 0 0; padding-left: 20px; }
.rc-gap { color: var(--bad); }
.rc-disagree { color: var(--warn); }
.rc-note { color: var(--muted); }
.fb-sec { display: flex; flex-direction: column; gap: 6px; }
.fb-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.count { padding: 0 6px; border-radius: 8px; background: var(--panel-2); color: var(--text); font-size: 11px; }
.none { font-style: italic; }
.toulmin { border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.toulmin th { font-weight: 600; color: var(--muted); text-transform: capitalize; padding: 2px 4px; }
.toulmin td.cell { width: 64px; height: 28px; text-align: center; border-radius: 4px; font-weight: 700; cursor: help; }
.cell.strong { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.cell.weak { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.cell.missing { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }
.cell.absent { background: var(--panel-2); color: var(--muted); }
.slot-notes { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mini-card { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.mc-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.quote { margin: 0; padding-left: 8px; border-left: 2px solid var(--line); color: var(--muted); font-size: 13px; }
.ba-card { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.ba-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ba { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.ba.before { background: var(--code-bg); }
.ba.after { border-color: var(--good); }
.ba-tag { text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.ba-card .btn, .judge-card .btn { align-self: flex-start; }
.score { display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 4px; border-radius: 4px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); }
.score.shi { color: var(--good); border-color: var(--good); }
.score.smid { color: var(--warn); border-color: var(--warn); }
.score.slo { color: var(--bad); border-color: var(--bad); }
.score-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.score-row { display: grid; grid-template-columns: 150px minmax(60px, 1fr) 32px; gap: 8px; align-items: center; }
.score-row .sr-why { grid-column: 1 / -1; }
.score-row.absent { opacity: 0.6; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; display: block; }
.bar .fill { display: block; height: 100%; background: var(--text); opacity: 0.75; }
.steelman { padding: 8px 10px; border-left: 3px solid var(--muted); background: var(--panel); border-radius: 0 6px 6px 0; font-size: 13px; }
.next { font-size: 13px; padding: 8px 10px; background: var(--panel-2); border-radius: 6px; }
.attack-line { font-style: italic; }
.parts-row { display: flex; gap: 4px; flex-wrap: wrap; }
.part.off { color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.decision-banner { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); }
.decision-banner .db-call { font-size: 16px; font-weight: 750; }
.decision-banner.carries { border-color: var(--good); }
.decision-banner.carries .db-call { color: var(--good); }
.decision-banner.loses { border-color: var(--bad); }
.decision-banner.loses .db-call { color: var(--bad); }
.decision-banner.toss-up .db-call { color: var(--warn); }
.ballot-total { font-size: 13px; font-weight: 700; }
.example { color: var(--muted); }

/* scorecard pane */
.scorepane {
  position: sticky; top: 49px; align-self: start; max-height: calc(100vh - 49px); overflow-y: auto;
  border-left: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 12px;
}
.sp-head { display: flex; justify-content: space-between; align-items: center; }
.sp-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.decision { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); }
.decision.carries { color: var(--good); border-color: var(--good); }
.decision.loses { color: var(--bad); border-color: var(--bad); }
.decision.toss-up { color: var(--warn); border-color: var(--warn); }
.score-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.score-table th:first-child { width: 34%; }
.score-table th, .score-table td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: center; }
.score-table th[scope="row"] { text-align: left; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-table thead th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; }
.score-table tr.g-content th[scope="row"] { box-shadow: inset 2px 0 0 var(--muted); }
.score-table tr.g-delivery th[scope="row"] { box-shadow: inset 2px 0 0 var(--line); }
.score-table tfoot th, .score-table tfoot td { font-weight: 700; border-bottom: 0; }
.score-table td.gap { color: var(--warn); font-weight: 700; }
.self-sel { padding: 1px 0; font-size: 12px; background: transparent; border-color: var(--line); width: 100%; max-width: 48px; }
.group-bars { display: flex; flex-direction: column; gap: 6px; }
.gb-row { display: grid; grid-template-columns: 88px 1fr 48px; gap: 8px; align-items: center; }
.exports { display: flex; gap: 4px; flex-wrap: wrap; }

/* footer + toasts */
.foot { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.foot a { color: var(--muted); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 6px; padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow); transition: opacity 0.5s; display: flex; gap: 8px; flex-wrap: wrap; }
.toast.ok { border-left-color: var(--good); }
.toast.err { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast.gone { opacity: 0; }

/* --- responsive --- */
@media (max-width: 1199px) {
  .shell { grid-template-columns: 208px minmax(0, 1fr); }
  .scorepane { grid-column: 2; position: static; max-height: none; border-left: 0; border-top: 1px solid var(--line); padding: 16px 20px; }
}
@media (max-width: 859px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: sticky; top: 49px; z-index: 10; height: auto; overflow: visible;
    border-right: 0; border-bottom: 1px solid var(--line); background: var(--bg);
    padding: 8px 16px; gap: 8px;
  }
  .steps { flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .steps li { flex: none; }
  .step { grid-template-columns: 24px auto; padding: 4px 8px 4px 4px; }
  .st-sub, .st-dot { display: none; }
  .rail-total { display: none; }
  .rail-block { flex-direction: row; align-items: center; gap: 8px; }
  .rb-head span:first-child { display: none; }
  .rb-head { padding: 0; }
  .rb-actions { padding: 0; flex: none; }
  .sitting-list { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .sit { flex: none; max-width: 180px; }
  .sit-meta { display: none; }
  .scorepane { grid-column: 1; padding: 16px; }
  .stage { padding: 12px 16px 24px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .slot-grid, .ba-grid, #checklist { grid-template-columns: minmax(0, 1fr); }
  .drill { grid-template-columns: minmax(0, 1fr); }
  .drill-list { flex-direction: row; overflow-x: auto; }
  .drill-item { width: auto; }
  .score-row { grid-template-columns: 120px minmax(40px, 1fr) 32px; }
  .motion-title { max-width: 40vw; }
  .chip-link#home { display: none; }
}
