:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --border: #dedcd5;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7973;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  /* status (reserved: never reused for series) */
  --good: #1f8a3b;     --good-bg: #e3f3e6;
  --warn: #a66a00;     --warn-bg: #fbf0d6;
  --serious: #c2540a;  --serious-bg: #fde6d6;
  --critical: #c22f2f; --critical-bg: #fbe1e1;
  --gray: #8c8b85;     --gray-bg: #ecebe7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #34332f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #95948b; --accent: #3987e5;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --good: #4cc26a; --good-bg: #183621;
    --warn: #e5b33d; --warn-bg: #3a2f12;
    --serious: #f08a4b; --serious-bg: #3d2414;
    --critical: #f07070; --critical-bg: #3f1b1b;
    --gray: #8f8e86; --gray-bg: #2a2a27;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #34332f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #95948b; --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --good: #4cc26a; --good-bg: #183621;
  --warn: #e5b33d; --warn-bg: #3a2f12;
  --serious: #f08a4b; --serious-bg: #3d2414;
  --critical: #f07070; --critical-bg: #3f1b1b;
  --gray: #8f8e86; --gray-bg: #2a2a27;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
code { font-size: .85em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }

.layout { display: flex; min-height: 100vh; }
nav.side {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
nav.side .brand { font-weight: 700; margin: 0 .5rem 1rem; }
nav.side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 1rem .5rem .25rem; }
nav.side a { display: block; padding: .35rem .5rem; border-radius: 6px; color: var(--text); }
nav.side a.active { background: var(--surface-2); font-weight: 600; }
nav.side a:hover { background: var(--surface-2); text-decoration: none; }
main { flex: 1; min-width: 0; padding: 1.5rem 2rem 4rem; max-width: 1200px; }

.proto-banner {
  background: var(--warn-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .8rem; margin-bottom: 1.25rem; font-size: .85rem;
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.1rem; margin: .75rem 0; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--text-2); font-size: .85rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
tr.clickable:hover td { background: var(--surface-2); cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-flex; align-items: center; gap: .3rem; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.green  { color: var(--good); background: var(--good-bg); }
.pill.yellow { color: var(--warn); background: var(--warn-bg); }
.pill.orange { color: var(--serious); background: var(--serious-bg); }
.pill.red    { color: var(--critical); background: var(--critical-bg); }
.pill.gray   { color: var(--gray); background: var(--gray-bg); }
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); font-size: .78rem; margin: 1px 2px 1px 0; }
.tag.primary { font-weight: 700; }

.btn {
  display: inline-block; padding: .4rem .8rem; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.done-note { color: var(--good); font-weight: 600; font-size: .88rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 1rem 0; }
.tabs a { padding: .45rem .8rem; color: var(--text-2); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

label { display: block; font-weight: 600; font-size: .88rem; margin: .8rem 0 .25rem; }
input[type=text], input[type=number], textarea, select {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; }

.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.score { display: flex; align-items: center; gap: .4rem; }
.meter { position: relative; height: 8px; width: 110px; background: var(--surface-2); border-radius: 4px; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--text-3); }
.meter .tgt { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }

.debate .msg { padding: .6rem .8rem; border-radius: 8px; margin: .4rem 0; background: var(--surface-2); }
.debate .msg.critic { border-left: 3px solid var(--serious); }
.debate .msg.sean { border-left: 3px solid var(--accent); }
.debate .who { font-weight: 700; font-size: .82rem; }

.tree-feature > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; }
.tree-feature > summary::-webkit-details-marker { display: none; }
.tree-feature { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin: .5rem 0; }
.tree-feature table { border-top: 1px solid var(--border); }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.swatch.gray { background: var(--gray); } .swatch.red { background: var(--critical); }
.swatch.yellow { background: var(--warn); } .swatch.green { background: var(--good); }

.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-2); font-size: 11px; }
.chart .label { fill: var(--text); font-size: 12px; font-weight: 600; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); margin: .25rem 0 .5rem; }
.legend .key { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: .35rem; border-radius: 2px; }
.legend .key.dash { background: none; border-top: 2px dashed var(--text-3); height: 0; }

.one-action { border: 2px solid var(--accent); }
.one-action .big { font-size: 1.2rem; font-weight: 700; }
.indent-1 { padding-left: 1.6rem !important; }
.indent-2 { padding-left: 3.2rem !important; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  nav.side { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .1rem; }
  nav.side .group { display: none; }
  nav.side .brand { width: 100%; }
  main { padding: 1rem 16px 3rem; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* Hypothesis hierarchy */
.hyp-switch { padding: 0 .5rem .25rem; }
.hyp-switch select { font-size: .85rem; padding: .35rem .4rem; }
.nav-tree { border-left: 2px solid var(--border); margin-left: .9rem; padding-left: .2rem; }
.hyp-context { border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; padding: .5rem .8rem; margin-bottom: 1rem; }
.hyp-context .crumbs { color: var(--text-2); }
.hyp-context .hyp-title { font-weight: 600; }
.hyp-group { margin: 1.5rem 0 .5rem; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.hyp-group .id { font-weight: 700; }
.hyp-group .rank { font-size: .78rem; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.tree-row td:first-child { border-left: 3px solid transparent; }
tr.exp-row td { background: var(--bg); }
tr.prog-row td { background: var(--surface-2); padding-top: .35rem; padding-bottom: .35rem; }
tr.prog-row td:first-child { padding-left: 1.6rem; }
tr.exp-row td:first-child { padding-left: 3.2rem; }
.tree-branch { color: var(--text-3); }
@media (max-width: 800px) {
  .hyp-switch { width: 100%; padding: .25rem 0; }
  .nav-tree { display: flex; flex-wrap: wrap; border-left: none; margin: 0; padding: 0; }
}
.htag { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: .78rem; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); margin-right: 2px; }

/* Coverage matrix */
.cov td, .cov th { text-align: center; }
.cov td:first-child, .cov th:first-child { text-align: left; }
.cov .dot { font-size: 1.1rem; line-height: 1; }
.cov .dot.primary { color: var(--accent); }
.cov .dot.incidental { color: var(--text-3); }
.cov th.target { color: var(--text); }

/* Three kinds of buttons: links with an arrow go somewhere; filled buttons do something;
   DECISION cards record a choice (system option, Sean's own option, or advice). */
.btn.nav { background: transparent; border-color: transparent; color: var(--accent); padding-left: .25rem; padding-right: .25rem; }
.btn.nav:hover { background: transparent; text-decoration: underline; }
.btn.nav::after { content: " →"; }
.decision { border-left: 4px solid var(--warn); }
.decision-head { margin-bottom: .3rem; }
.decision-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--warn); margin-right: .3rem; }
.decision label { font-weight: 600; }
.decision textarea { min-height: 60px; }
.rec-badge { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: .4rem; opacity: .9; }
.decision-result { margin-top: .4rem; }
.error-note { color: var(--critical); font-weight: 600; font-size: .88rem; }
.one-action.decision { border: 2px solid var(--accent); border-left-width: 4px; }

/* Interviewer chat */
.chat-log { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; margin: .5rem 0; }
.chat-msg { padding: .5rem .75rem; border-radius: 10px; max-width: 85%; white-space: pre-wrap; font-size: .9rem; }
.chat-msg.from-sean { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--border); }
.chat-msg.from-agent { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); }
.chat-meta { font-size: .72rem; color: var(--text-3); margin-bottom: .15rem; white-space: normal; }

/* Asset library */
.asset-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin: .5rem 0; }
.asset { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; background: var(--bg); }
.asset-copy { font-size: .9rem; background: var(--surface); border: 1px dashed var(--border); border-radius: 6px; padding: .45rem .55rem; margin: .35rem 0; }
.asset-img { width: 100%; height: auto; border-radius: 6px; margin: .35rem 0; display: block; }
label.radio { font-weight: 400; display: flex; gap: .5rem; align-items: baseline; margin: .4rem 0; }
label.radio input { width: auto; }
.btn.nav-logout { background: none; border: none; color: var(--text-2); font-size: .85rem; padding: .35rem .5rem; }
tr.seg-focus td { background: var(--warn-bg); }

/* Live mode */
nav.side .later { font-size: .68rem; color: var(--text-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: .25rem; }
.edit-panel { border-top: 1px dashed var(--border); margin-top: .5rem; padding-top: .5rem; }
.edit-panel form { margin: .4rem 0; }
.edit-panel .inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.edit-panel .inline label { margin: 0; font-size: .8rem; }
.edit-panel input[type=number] { width: 6rem; }
.edit-panel input[type=text] { min-width: 16rem; flex: 1; }
.run-card .bar { margin: .4rem 0; height: 10px; }
.flash-error { background: var(--critical-bg); border: 1px solid var(--critical); border-radius: 8px; padding: .5rem .8rem; margin-bottom: 1rem; }
