/* Design tokens. Colours change per theme; sizes and shapes do not. */
:root {
  --control-h: 36px;        /* every button, chip, input and select */
  --control-h-sm: 32px;     /* top navigation */
  --badge-h: 20px;
  --radius: 8px;            /* controls */
  --radius-lg: 10px;        /* cards, lists, panels */
  --pill: 999px;
  --fs-control: 14px;
  --fs-sm: 13px;
  --fs-xs: 12px;
}
:root {
  --bg: #f7f7f5; --surface: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e3e2dd;
  --accent: #3d5afe; --fact: #1b8a5a; --assume: #c27c0e; --req: #3d5afe; --spec: #7b3fbf; --question: #c2255c;
  --bad: #c62828; --soft: #f0efeb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --text: #ecebe6; --muted: #9c9b95; --line: #33332f;
    --accent: #7c8cff; --fact: #4cc38a; --assume: #e6a23c; --req: #7c8cff; --spec: #b98cf0; --question: #f06595;
    --bad: #ef6b6b; --soft: #262624;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1d1b; --text: #ecebe6; --muted: #9c9b95; --line: #33332f;
  --accent: #7c8cff; --fact: #4cc38a; --assume: #e6a23c; --req: #7c8cff; --spec: #b98cf0; --question: #f06595;
  --bad: #ef6b6b; --soft: #262624;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); padding: 0 4px; border-radius: 4px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
.muted { color: var(--muted); }

.top {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); }
.brand span { color: var(--accent); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { display: inline-flex; align-items: center; height: var(--control-h-sm); padding: 0 10px; border-radius: var(--radius); color: var(--muted); }
.top nav a:hover { text-decoration: none; color: var(--text); }
.top nav a[aria-current] { background: var(--soft); color: var(--text); }
main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; outline: none; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

/* tiles & cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.tile, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; }
.tile b { display: block; font-size: 1.7rem; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.card h3 { margin: 4px 0 8px; font-size: 1rem; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; background: var(--fact); }

/* badges */
.badge { display: inline-flex; align-items: center; height: var(--badge-h); font-size: var(--fs-xs); line-height: 1; padding: 0 8px; border-radius: var(--pill); border: 1px solid currentColor; white-space: nowrap; vertical-align: middle; }
.s-active, .s-validated { color: var(--fact); }
.s-open, .s-provisional, .s-draft { color: var(--assume); }
.s-answered { color: var(--fact); }
.s-broken, .s-invalidated, .s-deprecated { color: var(--bad); }
.t-ASM { color: var(--assume); } .t-FCT { color: var(--fact); } .t-REQ { color: var(--req); } .t-SPC { color: var(--spec); } .t-QST { color: var(--question); }
.rid { font: 600 13px ui-monospace, Menlo, monospace; }

/* lists */
.list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.list li { display: flex; gap: 12px; align-items: baseline; padding: 10px 14px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li .grow { flex: 1; min-width: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 16px 0; }

/* Controls: one height, one font size, always a 1px border so filled and outlined variants line up. */
.btn, .chip, input:not([type="checkbox"]), select {
  box-sizing: border-box; height: var(--control-h); font: inherit; font-size: var(--fs-control); border: 1px solid var(--line);
}
.btn, .chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 14px; line-height: 1; white-space: nowrap; cursor: pointer;
}
.btn:hover, .chip:hover { text-decoration: none; }
.chip { border-radius: var(--pill); background: var(--surface); color: var(--text); }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.filter { background: transparent; color: var(--accent); border-color: var(--accent); }
input, textarea, select { color: var(--text); background: var(--surface); border-radius: var(--radius); width: 100%; }
input:not([type="checkbox"]), select { padding: 0 10px; }
textarea { font: inherit; font-size: var(--fs-control); border: 1px solid var(--line); padding: 8px 10px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.toolbar input { flex: 1; min-width: 180px; width: auto; }

/* record page */
.record-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
@media (max-width: 800px) { .record-grid { grid-template-columns: 1fr; } }
.prose h2 { font-size: 1rem; }
.prose ul { padding-left: 20px; }
.meta dt { font-size: 12px; color: var(--muted); margin-top: 10px; }
.meta dd { margin: 2px 0 0; }
.issues { border-left: 3px solid var(--bad); padding: 8px 12px; background: var(--soft); border-radius: 0 8px 8px 0; margin: 12px 0; }
.btn { border-radius: var(--radius); background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: var(--surface); color: var(--accent); border-color: var(--line); }
.btn:hover { filter: brightness(1.08); }
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* graph */
.graph-wrap { overflow-x: auto; }
.graph { position: relative; display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 40px; min-width: 1060px; padding: 8px 0; }
.graph svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.node {
  position: relative; z-index: 1; display: block; width: 100%; text-align: left; margin-bottom: 10px; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; font: inherit; font-size: 13px; line-height: 1.35; transition: opacity .15s;
}
.node.t-ASM { border-left-color: var(--assume); } .node.t-FCT { border-left-color: var(--fact); }
.node.t-REQ { border-left-color: var(--req); } .node.t-SPC { border-left-color: var(--spec); } .node.t-QST { border-left-color: var(--question); }
.node-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.node.dim { opacity: .25; }
.node.sel { outline: 2px solid var(--accent); }
.edge { fill: none; stroke: var(--fact); stroke-width: 1.5; opacity: .7; transition: opacity .15s; }
.edge.weak { stroke: var(--assume); stroke-dasharray: 5 4; }
.edge.dim { opacity: .08; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 8px 0 16px; }
.legend i { display: inline-block; width: 24px; border-top: 2px solid var(--fact); vertical-align: middle; margin-right: 6px; }
.legend i.weak { border-top: 2px dashed var(--assume); }

/* capture */
.capture { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 800px) { .capture { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }
.field label, .field legend { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field small { color: var(--muted); display: block; margin-top: 4px; }
fieldset.field { border: 0; padding: 0; margin: 0 0 14px; }
.checks { max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; background: var(--surface); }
.checks label { display: flex; gap: 8px; font-weight: normal; font-size: 13px; padding: 3px 0; }
.checks input { width: auto; }
pre.preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; overflow: auto; font-size: 12.5px; white-space: pre-wrap; }
.note { font-size: 13px; color: var(--muted); }

/* state: done / wait / bad / off */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.dot.done, .seg-done { background: var(--fact); }
.dot.wait, .seg-wait { background: var(--assume); }
.dot.bad, .seg-bad { background: var(--bad); }
.dot.off, .seg-off { background: var(--line); }
.callout {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; margin: 16px 0 8px; padding: 16px 18px;
  border-radius: var(--radius-lg); border: 1px solid var(--line); border-left: 6px solid; background: var(--surface); color: var(--text);
}
.callout:hover { text-decoration: none; }
.callout b { font-size: 1.25rem; }
.callout .go { margin-left: auto; color: var(--accent); font-weight: 600; }
.callout.bad { border-left-color: var(--bad); } .callout.wait { border-left-color: var(--assume); } .callout.done { border-left-color: var(--fact); }
.states { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 4px 16px; }
.state { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.state:first-child { border-top: 0; }
.state-name { font-weight: 600; color: var(--text); }
.seg { display: flex; gap: 3px; height: 14px; }
.seg a { border-radius: 4px; min-width: 6px; }
.seg a:hover { filter: brightness(1.15); }
.seg-legend { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.seg-legend a { color: var(--muted); }
@media (max-width: 600px) { .state { grid-template-columns: 1fr; } .seg-legend { grid-column: 1; } }
.blockers { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.blockers li { padding: 4px 0 4px 10px; border-left: 3px solid var(--line); margin-top: 4px; }
.blockers li.wait { border-left-color: var(--assume); } .blockers li.bad { border-left-color: var(--bad); } .blockers li.ready { border-left-color: var(--fact); }
.count { display: inline-flex; align-items: center; justify-content: center; height: var(--badge-h); min-width: var(--badge-h); margin-left: 6px; padding: 0 6px; border-radius: var(--pill); background: var(--assume); color: #fff; font-size: var(--fs-xs); line-height: 1; font-weight: 600; vertical-align: middle; }
.count.fix { background: var(--bad); } .count.answer { background: var(--question); } .count.quick { background: var(--fact); } .count.tidy { background: var(--muted); }
.tasks { display: grid; gap: 10px; }
.task { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius-lg); padding: 12px 16px; }
.task.fix { border-left-color: var(--bad); } .task.answer { border-left-color: var(--question); } .task.test { border-left-color: var(--assume); } .task.quick { border-left-color: var(--fact); }
.task-title { font-weight: 600; }
.task-title .muted { font-weight: normal; }
.task-why { margin: 6px 0; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
