/* Colour roles, type and spacing per docs/UI-DESIGN.md.
   Severity colour appears only as a small dot and as the left border of a
   selected card — never as a row background, never as coloured prose. Info is
   grey on purpose so it recedes. */

:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-alt: #F4F4F1;
  --border: #E2E2DE;
  --border-strong: #CFCFC9;
  --text: #1A1C20;
  --text-muted: #6B6F76;
  --accent: #2456A6;
  --accent-soft: #E8EFFA;
  --error: #B3251E;
  --warning: #8F6400;
  --info: #5C6470;
  --unresolved: #6B4FA0;
  --true: #1E7A46;

  --f-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181D; --surface: #1E2128; --surface-alt: #23262E;
    --border: #33373F; --border-strong: #454A54;
    --text: #E8E9EB; --text-muted: #9BA0A8;
    --accent: #7DA7E8; --accent-soft: #23303F;
    --error: #F0736C; --warning: #E0B84E; --info: #8A929E;
    --unresolved: #B39DDB; --true: #5BC98A;
  }
}
:root[data-theme="dark"] {
  --bg: #16181D; --surface: #1E2128; --surface-alt: #23262E;
  --border: #33373F; --border-strong: #454A54;
  --text: #E8E9EB; --text-muted: #9BA0A8;
  --accent: #7DA7E8; --accent-soft: #23303F;
  --error: #F0736C; --warning: #E0B84E; --info: #8A929E;
  --unresolved: #B39DDB; --true: #5BC98A;
}
:root[data-theme="light"] {
  --bg: #FAFAF8; --surface: #FFFFFF; --surface-alt: #F4F4F1;
  --border: #E2E2DE; --border-strong: #CFCFC9;
  --text: #1A1C20; --text-muted: #6B6F76;
  --accent: #2456A6; --accent-soft: #E8EFFA;
  --error: #B3251E; --warning: #8F6400; --info: #5C6470;
  --unresolved: #6B4FA0; --true: #1E7A46;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* --- shell --- */

.topbar {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; letter-spacing: -0.01em; }
.brand .mark { color: var(--accent); margin-right: var(--s1); }
.filename {
  font-family: var(--f-mono); font-size: 13px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .spacer { flex: 1; }

.btn {
  padding: 6px var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: 0.9; color: #fff; }

/* --- summary strip: a screenshot of this alone is a status report --- */

.summary {
  display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap;
  padding: var(--s3) var(--s4);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.counts { display: flex; gap: var(--s4); }
.count { display: flex; align-items: center; gap: 6px; }
.count b { font-size: 16px; font-weight: 600; }
.meta { color: var(--text-muted); margin-left: auto; font-family: var(--f-mono); font-size: 12px; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot.error { background: var(--error); }
.dot.warning { background: var(--warning); }
.dot.info { background: var(--info); }
.dot.unresolved { background: var(--unresolved); }

/* --- two-pane layout --- */

.panes { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; min-height: calc(100vh - 118px); }
@media (max-width: 900px) { .panes { grid-template-columns: 1fr; } }

/* The tables are reference material and need the whole width; only Findings
   earns the list-plus-detail split. */
.panes.wide { grid-template-columns: 1fr; }
.panes.wide .pane-right { display: none; }
.panes.wide .pane-left { border-right: none; }

.pane-left { border-right: 1px solid var(--border); background: var(--surface); overflow-x: auto; }
.pane-right { padding: var(--s4); overflow-x: auto; }

.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  padding: var(--s2) var(--s3); background: none; border: none;
  border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 13px;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* --- findings, grouped by code --- */

.group { border-bottom: 1px solid var(--border); }
.group-head {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%; padding: var(--s3) var(--s4); background: none; border: none; text-align: left;
}
.group-head:hover { background: var(--surface-alt); }
.group-title { flex: 1; font-size: 13px; }
.sev-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-right: var(--s2);
}
.group-count { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chev { color: var(--text-muted); font-size: 11px; width: 10px; }

.instance {
  display: block; width: 100%; text-align: left;
  padding: 6px var(--s4) 6px var(--s6);
  background: none; border: none; border-left: 2px solid transparent;
  font-size: 13px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.instance:hover { background: var(--surface-alt); color: var(--text); }
.instance[aria-current="true"] {
  background: var(--accent-soft); color: var(--text);
  border-left-color: var(--accent); font-weight: 600;
}

/* --- detail --- */

.detail { max-width: 900px; }
.detail h2 { margin: 0 0 var(--s1); font-size: 16px; font-weight: 600; }
.detail .code { font-family: var(--f-mono); font-size: 12px; color: var(--text-muted); }
.detail p { margin: var(--s3) 0; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius); padding: var(--s4);
}
.card.error { border-left-color: var(--error); }
.card.warning { border-left-color: var(--warning); }
.card.info { border-left-color: var(--info); }
.card.unresolved { border-left-color: var(--unresolved); }

.label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin: var(--s4) 0 var(--s2);
}
pre.expr {
  font-family: var(--f-mono); font-size: 13px; line-height: 1.6;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s3);
  margin: 0; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}

/* --- rule inspector: brackets rendered as physical containment --- */

.node {
  border: 1px solid var(--border-strong); border-left-width: 3px;
  border-radius: var(--radius); padding: var(--s2) var(--s3);
  margin: var(--s2) 0; background: var(--surface);
}
.node { margin-left: 0; }
.node .node { margin-left: var(--s3); }
.node > .node { background: var(--surface-alt); }
.node > .node > .node { background: var(--surface); }
.node.flagged { border-color: var(--warning); border-left-color: var(--warning); }

.node-head {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 12px; color: var(--text-muted);
}
.op { font-weight: 600; color: var(--text); letter-spacing: 0.04em; }
.node-head .plain { font-weight: 400; }
/* Phase 2 fills these; reserved now so adding live results needs no rework. */
.badge {
  margin-left: auto; font-family: var(--f-mono); font-size: 11px;
  padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border);
  color: var(--text-muted); min-width: 44px; text-align: center;
}
.badge:empty { visibility: hidden; }
.badge.t { color: var(--true); border-color: var(--true); }
.badge.f { color: var(--text-muted); }

.leaf { font-family: var(--f-mono); font-size: 13px; padding: var(--s1) 0; }
.leaf .path { color: var(--accent); }
.leaf .lit { color: var(--text); }
.leaf .cmp { color: var(--text-muted); padding: 0 var(--s1); }
.leaf-value { font-size: 12px; color: var(--text-muted); padding-left: var(--s4); }
.leaf-value:empty { display: none; }

.callout {
  margin-top: var(--s4); padding: var(--s3);
  border: 1px solid var(--warning); border-radius: var(--radius);
  background: color-mix(in srgb, var(--warning) 8%, transparent);
  font-size: 13px;
}
.callout.note { border-color: var(--border-strong); background: var(--surface-alt); }

/* --- tables --- */

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--text-muted);
  padding: var(--s2); border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
td { padding: var(--s2); border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--surface-alt); }
td.mono, th.mono { font-family: var(--f-mono); font-size: 12px; }
.type-pill {
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
  border: 1px solid var(--border-strong); color: var(--text-muted); white-space: nowrap;
}
.table-wrap { overflow-x: auto; }

.filters { display: flex; gap: var(--s2); padding: var(--s3) var(--s4); flex-wrap: wrap; align-items: center; }
.search {
  flex: 1; min-width: 140px; padding: 6px var(--s2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit; font-size: 13px;
}
.chip {
  padding: 4px var(--s3); font-size: 12px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* --- dropzone --- */

.drop {
  margin: 8vh auto; max-width: 560px; padding: var(--s6);
  border: 2px dashed var(--border-strong); border-radius: 10px;
  background: var(--surface); text-align: center;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop h1 { margin: 0 0 var(--s2); font-size: 20px; font-weight: 600; }
.drop p { color: var(--text-muted); margin: var(--s2) 0 var(--s4); }
.drop .privacy { font-size: 12px; margin-top: var(--s4); }
.hidden { display: none; }
/* Needs to beat `.drop p`, which is muted grey — otherwise the error reads as
   helper text and nobody notices it. */
.drop p.err { color: var(--error); font-weight: 600; }
.drop p.err:empty { display: none; }
