/* Nerve — "Workshop". Daylight, not neon: a light work surface, technical
   type (IBM Plex), hairline borders, and one safety-orange accent used
   sparingly, the way a good power tool uses its one bright color. Chosen
   2026-10-07 to get away from the generic dark-and-electric-blue look every
   AI-built app shares. Numbers and labels use Plex Mono. */

:root {
  --bg: #f4f4f2;            /* the bench */
  --panel: #ffffff;         /* surfaces sitting on it */
  --panel-2: #f8f8f6;       /* inset areas */
  --hover: #ececea;
  --text: #1b1b1a;
  --muted: #6b6b66;
  --faint: #9a9a94;
  --ink: #1b1b1a;           /* primary buttons */
  --accent: #c2410c;        /* safety orange — citations, the one thing to look at */
  --accent-soft: rgba(194, 65, 12, .08);
  --accent-2: #9a3412;
  --ok: #2f7a4a;            /* confirmed, healthy */
  --ok-soft: rgba(47, 122, 74, .10);
  --danger: #b42318;        /* disputed, waiting */
  --danger-soft: rgba(180, 35, 24, .08);
  --border: #dadad5;
  --border-strong: #c4c4be;
  --shadow: 0 1px 0 rgba(27, 27, 26, .04);
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.accent { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
.hidden { display: none !important; }
h2, h3 { font-weight: 500; letter-spacing: -.01em; }
a { color: var(--accent); }

#login-overlay {
  position: fixed; inset: 0; z-index: 10; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
#login-form {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 2.2rem; width: 340px; display: flex; flex-direction: column; gap: .7rem;
}
#login-form h1 { margin: 0; font-size: 1.4rem; font-weight: 500; }
#login-form .sub { margin: 0 0 .8rem; color: var(--muted); font-size: .9rem; }

header {
  display: flex; align-items: center; gap: 1.4rem;
  padding: 0 1.2rem; background: var(--panel); border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.brand {
  font-family: var(--mono); font-weight: 500; font-size: .95rem; letter-spacing: .02em;
  cursor: pointer; display: flex; align-items: center; gap: .45rem;
}
.brand::before {
  content: ""; width: 10px; height: 10px; background: var(--accent); display: inline-block;
}
.brand .accent { color: var(--text); }
nav { display: flex; gap: .2rem; align-self: stretch; }
.spacer { flex: 1; }
#whoami { color: var(--muted); font-size: .85rem; }

button {
  background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 6px;
  padding: .45rem .9rem; font: 500 .88rem "IBM Plex Sans", system-ui, sans-serif; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
button:hover { background: #3a3a37; border-color: #3a3a37; }
button:disabled { opacity: .55; cursor: default; }
button.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); }
button.ghost:hover { background: var(--hover); }
/* Secondary actions in a header row (Edit, Confirm): quiet outlines, so the
   page has at most one solid button. */
button.approve { background: var(--panel); color: var(--text); border-color: var(--border-strong); margin-left: .3rem; }
button.approve:hover { background: var(--hover); border-color: var(--border-strong); }
button.tab {
  background: transparent; color: var(--muted); border: 0; border-radius: 0;
  border-bottom: 2px solid transparent; padding: 0 .7rem; height: 100%;
}
button.tab:hover { color: var(--text); background: transparent; }
button.tab.active { color: var(--text); border-bottom-color: var(--accent); }

input, select {
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 6px;
  color: var(--text); padding: .5rem .75rem; font: inherit; font-size: .92rem;
}
input:focus, select:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(27, 27, 26, .08); }
input::placeholder { color: var(--faint); }

main { flex: 1; overflow: hidden; display: flex; }
.panel { display: none; flex: 1; flex-direction: column; padding: 1.2rem; overflow-y: auto; }
.panel.active { display: flex; }

/* ------------------------------------------------------------------ home */
.home-wrap { max-width: 1060px; margin: 0 auto; width: 100%; padding-top: 1.2rem; }
.home-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }
.home-head h2 { margin: 0; font-size: 1.15rem; }
#home-search { flex: 0 1 320px; margin-left: auto; }

.carousel-wrap { position: relative; }
.carousel {
  display: flex; gap: .8rem; overflow-x: auto; scroll-snap-type: x proximity;
  padding: .2rem .1rem .8rem; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.wcard {
  flex: 0 0 250px; scroll-snap-align: start; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; transition: border-color .12s ease;
}
.wcard:hover { border-color: var(--text); }
.wcard .thumb { width: 100%; height: 140px; object-fit: cover; display: block; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.wcard .thumb.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 2rem; color: var(--faint); background: var(--panel-2);
}
.wcard-body { padding: .6rem .75rem .7rem; }
.wcard-title {
  font-size: .9rem; font-weight: 500; line-height: 1.35; margin-bottom: .45rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.4em;
}
.wcard-meta { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: .68rem; font-weight: 500; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 4px; padding: .05rem .45rem; text-transform: lowercase;
}
.chip.ok-chip { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.chip.review-chip { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.car-arrow {
  position: absolute; top: 40%; z-index: 2; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 6px; padding: 0;
  background: var(--panel); color: var(--text); border: 1px solid var(--border-strong);
  font-size: 1.1rem; line-height: 1;
}
.car-arrow:hover { background: var(--hover); }
#car-left { left: -14px; }
#car-right { right: -14px; }

/* ----------------------------------------------- the weekly report
   Read in under a minute: numbers as tiles, people as a table, then at
   most five findings, each a short headline and one line. */
#digest-section { margin-bottom: 2.2rem; }
#digest-section .home-head { flex-wrap: wrap; align-items: center; }
.digest-meta { font-family: var(--mono); font-size: .75rem; color: var(--muted); letter-spacing: .02em; }
#digest-history { margin-left: auto; max-width: 200px; padding: .35rem .6rem; font-size: .82rem; }
#digest-refresh { margin-left: auto; }
#digest-history:not(.hidden) + #digest-refresh { margin-left: 0; }
.digest {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 1.2rem 1.3rem 1rem;
}
.digest-headline { font-size: 1.12rem; font-weight: 500; line-height: 1.4; margin: 0 0 1rem; max-width: 52rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; margin-bottom: 1.1rem; }
.tile { border: 1px solid var(--border); border-radius: 6px; padding: .65rem .8rem; background: var(--panel-2); }
.tile .k { font-size: .78rem; color: var(--muted); margin: 0; }
.tile .v { font-family: var(--mono); font-size: 1.6rem; line-height: 1.2; margin: .1rem 0 0; }
.tile .d { font-size: .76rem; color: var(--muted); margin: .1rem 0 0; }
.tile.warn .v { color: var(--accent); }
.digest h3 {
  font-family: var(--mono); font-size: .7rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin: 0 0 .4rem;
}
.people { width: 100%; max-width: 560px; margin-bottom: 1.2rem; font-size: .88rem; }
.people td { padding: .3rem .4rem .3rem 0; border-bottom: 1px solid var(--border); }
.people td.num { font-family: var(--mono); text-align: right; white-space: nowrap; color: var(--muted); }
.people td.name { font-weight: 500; width: 9rem; }
.ratebar { position: relative; height: 6px; background: var(--hover); border-radius: 3px; min-width: 120px; }
.ratebar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--text); border-radius: 3px; }
.finding { display: flex; gap: .8rem; align-items: baseline; padding: .6rem 0; border-top: 1px solid var(--border); }
.finding:first-of-type { border-top: 0; }
.tag {
  flex: 0 0 auto; font-family: var(--mono); font-size: .66rem; font-weight: 500; letter-spacing: .05em;
  text-transform: uppercase; padding: .1rem .4rem; border-radius: 3px;
  background: var(--hover); color: var(--text); min-width: 4.6rem; text-align: center;
}
.tag.works { background: var(--accent); color: #fff; }
.tag.rule, .tag.doesnt, .tag.conflict { background: var(--danger-soft); color: var(--danger); }
.tag.learned, .tag.done { background: var(--ok-soft); color: var(--ok); }
.finding-body { flex: 1; min-width: 0; }
.finding-title { font-weight: 500; }
.finding-detail { color: var(--muted); font-size: .9rem; }
.finding-src {
  flex: 0 0 auto; font-family: var(--mono); font-size: .75rem; color: var(--accent);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.finding-src:hover { text-decoration: underline; background: none; }
.src-list { margin: .35rem 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .15rem; }
.src-list .cite {
  display: inline; background: none; color: var(--accent); font: .82rem/1.4 var(--mono);
  padding: 0; margin: 0; border-radius: 0; cursor: pointer;
}
.src-list .cite:hover { text-decoration: underline; background: none; }
.digest-empty { color: var(--muted); margin: 0; }

#threads-section { margin-top: 2rem; }
.thread-row {
  display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .8rem; margin-bottom: .4rem; font-size: .9rem;
}
.thread-title { font-weight: 500; }
.thread-meta { margin-left: auto; font-size: .8rem; }

.home-ask { margin-top: 2.6rem; text-align: center; }
.home-ask h2 { margin: 0 0 .2rem; font-size: 1.15rem; }
.home-ask h2 .accent { color: var(--text); }
.home-ask p { margin: 0 0 1rem; }
#home-ask-form { display: flex; gap: .5rem; max-width: 640px; margin: 0 auto; }
#home-ask-form input { flex: 1; padding: .65rem .9rem; }

/* ------------------------------------------------------------------ chat */
#tab-chat { max-width: 860px; margin: 0 auto; width: 100%; }
#chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; padding-bottom: 1rem; }
.msg { border-radius: 8px; padding: .8rem 1.05rem; }
.msg.q {
  background: var(--ink); color: #fff;
  align-self: flex-end; max-width: 75%; white-space: pre-wrap;
}
.msg.a { background: var(--panel); border: 1px solid var(--border); }

.msg.a > :first-child { margin-top: 0; }
.msg.a > :last-child { margin-bottom: 0; }
.msg.a p, .msg.a ul, .msg.a ol { margin: .55rem 0; }
.msg.a li { margin: .25rem 0; }
.msg.a h1, .msg.a h2, .msg.a h3 { font-size: 1rem; margin: 1rem 0 .35rem; }
.msg.a hr { border: 0; border-top: 1px solid var(--border); margin: .8rem 0; }
.msg.a blockquote { margin: .55rem 0; padding: .1rem .9rem; border-left: 3px solid var(--border-strong); color: var(--muted); }

.cite {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-size: .7rem; font-weight: 500; line-height: 1.4;
  border-radius: 3px; padding: 0 .35rem; margin: 0 .1rem;
  vertical-align: text-top; cursor: default;
}

.cite.general { background: var(--hover); color: var(--muted); cursor: help; }
.cite.general:hover { background: var(--border); }

details.citations { margin-top: .8rem; border-top: 1px solid var(--border); padding-top: .55rem; font-size: .84rem; }
details.citations summary { cursor: pointer; color: var(--muted); font-weight: 500; user-select: none; list-style-position: inside; }
details.citations summary:hover { color: var(--text); }
details.citations[open] summary { margin-bottom: .45rem; }
.citation-row { display: flex; gap: .5rem; align-items: baseline; color: var(--muted); margin-bottom: .35rem; }
.citation-row b { color: var(--text); font-weight: 500; }

#ask-form { display: flex; gap: .5rem; padding-top: .8rem; }
.chat-top { display: flex; justify-content: flex-end; min-height: 0; }
.chat-top button { margin-bottom: .6rem; }
/* Suggested questions: what THIS brain can answer. */
.suggest { display: flex; flex-wrap: wrap; gap: .4rem; }
#chat-suggest { justify-content: center; padding: 0 0 .2rem; }
#home-suggest { justify-content: center; margin-top: .8rem; }
button.suggestion {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: .35rem .8rem; font-size: .85rem; font-weight: 400;
}
button.suggestion:hover { background: var(--hover); border-color: var(--border-strong); }
#ask-form input { flex: 1; }

/* -------------------------------------------------------- lists & detail */
.split { display: flex; gap: 1rem; flex: 1; min-height: 0; }
.list-col { width: 320px; display: flex; flex-direction: column; gap: .5rem; min-height: 0; }
.list-col .list { width: auto; flex: 1; }
.list { width: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; }
.list .item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .7rem; cursor: pointer; font-size: .88rem;
  transition: border-color .12s ease;
}
.list .item:hover { border-color: var(--text); }
.list .item .type { font-family: var(--mono); color: var(--muted); font-size: .7rem; letter-spacing: .03em; }
.detail {
  flex: 1; overflow-y: auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 1.1rem 1.3rem;
}
.claim { border-left: 3px solid var(--border-strong); padding: .45rem .85rem; margin: .6rem 0; background: var(--panel-2); }
.claim.disputed { border-left-color: var(--danger); background: var(--danger-soft); }
.claim .quote { color: var(--muted); font-size: .82rem; font-style: italic; }

.area-group { margin-bottom: 1.15rem; }
.area-head {
  font-family: var(--mono); font-size: .7rem; font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding-bottom: .3rem; margin-bottom: .45rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer; display: flex; justify-content: space-between; align-items: baseline;
  transition: color .12s ease;
}
.area-head:hover { color: var(--text); border-bottom-color: var(--text); }
.hub-hint { font-size: .68rem; color: var(--accent); opacity: .8; text-transform: none; letter-spacing: 0; }
.area-head:hover .hub-hint { opacity: 1; }

.hub-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .8rem; margin: .6rem 0 1rem;
}
.hub-cards .wcard { flex: none; width: auto; }
.activity-row {
  display: flex; gap: .6rem; align-items: baseline; padding: .35rem 0;
  border-bottom: 1px solid var(--border); font-size: .88rem;
}
.activity-row .muted { margin-left: auto; white-space: nowrap; }
.review-chip { background: var(--danger-soft); color: var(--danger); border-radius: 3px; padding: .02rem .4rem; font-weight: 500; font-size: .8em; }

/* ------------------------------------------------- wiki-how step cards */
.steps-bar { display: flex; justify-content: space-between; align-items: center; margin: .8rem 0 .2rem; }
.small-btn { padding: .2rem .6rem; font-size: .78rem; }
details.step-card { display: block; }
details.step-card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
details.step-card > summary::-webkit-details-marker { display: none; }
details.step-card > summary::after { content: "+"; margin-left: auto; font-family: var(--mono); color: var(--muted); }
details.step-card[open] > summary::after { content: "−"; }
details.step-card[open] > summary { margin-bottom: .5rem; }
.step-body { display: flex; gap: 1rem; align-items: flex-start; }
details.branch > summary { cursor: pointer; }
details.history-panel {
  margin-top: 1.2rem; border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .8rem; background: var(--panel-2);
}
details.history-panel > summary { cursor: pointer; font-weight: 500; }
details.history-panel[open] > summary { margin-bottom: .4rem; }
details.area-group > summary { list-style: none; }
details.area-group > summary::-webkit-details-marker { display: none; }
details.area-group > summary::before { content: "▾"; margin-right: .35rem; color: var(--faint); }
details.area-group:not([open]) > summary::before { content: "▸"; }
.area-n { margin-right: auto; margin-left: .4rem; font-family: var(--mono); }
.step-card {
  display: flex; gap: 1rem; align-items: flex-start;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: .8rem .95rem; margin: .6rem 0;
}
.step-text { flex: 1; min-width: 0; }
.step-head { margin-bottom: .25rem; }
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 4px;
  background: var(--ink); color: #fff; font-family: var(--mono);
  font-size: .75rem; font-weight: 500; margin-right: .3rem;
}
.step-shot {
  flex: 0 0 260px; max-width: 40%; border-radius: 6px; border: 1px solid var(--border);
  cursor: zoom-in; display: block;
}
@media (max-width: 900px) { .step-body { flex-direction: column; } .step-shot { max-width: 100%; flex-basis: auto; } }

/* --------------------------------------------------- knowledge graph */
#dropzone {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border: 1.5px dashed var(--border-strong); border-radius: 6px;
  padding: .6rem 1rem; margin-bottom: .8rem; cursor: pointer;
  color: var(--muted); font-size: .88rem; background: var(--panel);
  transition: border-color .12s ease, background .12s ease;
}
#dropzone:hover, #dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
#upload-status { white-space: nowrap; }

#graph-panel {
  position: relative; height: 46vh; min-height: 280px; margin-bottom: 1rem;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--panel);
}
#graph { position: absolute; inset: 0; }
#graph-legend {
  position: absolute; left: .8rem; bottom: .6rem; display: flex; flex-direction: column; gap: .3rem;
  font-size: .74rem; color: var(--muted); max-width: 85%;
}
.legend-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: .3rem; }
.legend-item .dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; }
.legend-item.toggle {
  cursor: pointer; background: rgba(255, 255, 255, .9); border: 1px solid var(--border);
  border-radius: 4px; padding: .06rem .5rem; user-select: none;
  transition: opacity .12s ease, border-color .12s ease;
}
.legend-item.toggle:hover { border-color: var(--text); color: var(--text); }
.legend-item.toggle.off { opacity: .35; text-decoration: line-through; }
.legend-item.focus-chip {
  cursor: pointer; background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; padding: .06rem .5rem; font-weight: 500;
}
.legend-item.hint { opacity: .7; }

.diff-panel {
  margin: .5rem 0 .8rem; border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .8rem; background: var(--panel-2); font-size: .88rem;
}
.diff-panel summary { cursor: pointer; color: var(--muted); font-weight: 500; user-select: none; }
.diff-panel summary:hover { color: var(--text); }
.diff-panel[open] summary { margin-bottom: .4rem; }
.diff-row { padding: .12rem 0; font-family: var(--mono); font-size: .82rem; }
.diff-row.added { color: var(--ok); }
.diff-row.removed { color: var(--danger); }
.diff-row.changed { color: var(--accent); }

/* Recording settings */
.settings-intro { margin: -.2rem 0 .8rem; }
.mode-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.mode-opt {
  display: flex; gap: .55rem; align-items: flex-start; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: .65rem .75rem;
}
.mode-opt.selected { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.mode-opt input { margin-top: .25rem; accent-color: var(--accent); }
.mode-opt b { display: block; font-weight: 500; font-size: .9rem; }
.mode-opt small { color: var(--muted); font-size: .8rem; line-height: 1.35; display: block; }
.policy-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; min-height: 1.6rem; align-items: center; }
.policy-chip {
  display: inline-flex; align-items: center; gap: .3rem; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 4px; padding: .1rem .2rem .1rem .55rem; font-size: .85rem;
}
.policy-chip button { background: none; border: 0; color: var(--muted); padding: 0 .3rem; font-size: 1rem; line-height: 1; }
.policy-chip button:hover { color: var(--danger); background: none; }
#policy-add { display: flex; gap: .4rem; max-width: 520px; }
#policy-add input { flex: 1; }
.seen-table td { padding: .3rem .5rem; vertical-align: middle; }
.seen-app { font-family: var(--mono); font-size: .8rem; white-space: nowrap; }
.seen-title { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
.seen-state { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.seen-state.rec { color: var(--ok); }
.seen-state.skip { color: var(--muted); }
.always-blocked { font-size: .82rem; margin: .8rem 0; }
#seen-more { margin-top: .4rem; }
details.older-agents > summary { cursor: pointer; margin: .3rem 0; font-size: .85rem; }
.policy-actions { display: flex; gap: .8rem; align-items: center; }
@media (max-width: 760px) { .mode-choice { grid-template-columns: minmax(0, 1fr); } }
#policy-editor { max-width: 640px; margin-bottom: 1rem; }
#policy-editor select { margin-bottom: .4rem; font-size: .9rem; }
#policy-editor textarea { font-family: var(--mono); font-size: .85rem; }
#policy-status { margin-left: .6rem; font-size: .85rem; }
.card-warn { border-color: var(--danger); }
.card-warn .n { color: var(--danger); }
#feedback-pop {
  position: fixed; top: 3.6rem; right: 1rem; z-index: 50; width: 320px;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: .8rem; box-shadow: 0 8px 24px rgba(27, 27, 26, .12);
  display: flex; flex-direction: column; gap: .5rem;
}
#feedback-pop.hidden { display: none; }
#feedback-pop textarea { width: 100%; font: inherit; font-size: .9rem; }
#feedback-status { margin-left: .5rem; font-size: .85rem; }
#policy-test { display: flex; gap: .4rem; align-items: center; margin: .4rem 0 .6rem; flex-wrap: wrap; }
#policy-test input { flex: 1; min-width: 140px; }
#policy-test-result { font-size: .85rem; font-weight: 500; }
#policy-test-result.test-blocked { color: var(--danger); }
#policy-test-result.test-watched { color: var(--accent); }

/* ------------------------------------------------------------- status */
.cards { display: flex; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: .8rem 1.2rem; }
.card .n { font-family: var(--mono); font-size: 1.5rem; font-weight: 500; color: var(--text); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
td, th { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.branch { margin: .3rem 0 .3rem 1rem; padding-left: .6rem; border-left: 2px dashed var(--border-strong); font-size: .88rem; }
.version { padding: .45rem .4rem; border-bottom: 1px solid var(--border); font-size: .88rem; cursor: pointer; }
.version:hover { background: var(--panel-2); }
.version.viewing { background: var(--accent-soft); border-left: 3px solid var(--accent); }
textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 6px;
  color: var(--text); padding: .5rem .7rem; font: inherit; margin: .2rem 0 .5rem;
}
textarea:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(27, 27, 26, .08); }
.edit-step input.step-title { width: 100%; margin-bottom: .3rem; font-weight: 500; }
.del-step { margin-top: .2rem; font-size: .75rem; }
.edit-shot-row { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; flex-wrap: wrap; }
.edit-shot { height: 64px; border-radius: 4px; border: 1px solid var(--border); }
.pick-shot, .clear-shot { font-size: .75rem; }
.frame-picker { margin-top: .5rem; }
.frame-preview img {
  width: 100%; max-height: 360px; object-fit: contain; display: block;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
}
.frame-preview > span { display: block; font-size: .74rem; margin: .25rem 0 .1rem; }
.frame-strip {
  display: flex; gap: .5rem; overflow-x: auto; padding: .5rem 0 .7rem; margin-top: .2rem;
  scrollbar-width: auto; scrollbar-color: var(--border-strong) var(--panel-2);
}
.frame-strip::-webkit-scrollbar { height: 10px; }
.frame-strip::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
.frame-strip::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.frame-thumb {
  flex: 0 0 200px; cursor: pointer; text-align: center;
  border: 2px solid transparent; border-radius: 6px; padding: 2px;
  transition: border-color .12s ease;
}
.frame-thumb:hover { border-color: var(--text); }
.frame-thumb.selected { border-color: var(--accent); background: var(--accent-soft); }
.frame-thumb img { width: 100%; border-radius: 4px; display: block; }
.frame-thumb span { font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.version .approve { margin-left: .6rem; padding: .15rem .6rem; font-size: .78rem; }
.ok { color: var(--ok); font-weight: 500; }
code { font-family: var(--mono); background: var(--panel-2); border: 1px solid var(--border); padding: .05rem .3rem; border-radius: 3px; font-size: .85em; }
.status-done { color: var(--ok); }
.status-error, .status-dead { color: var(--danger); }
.status-running, .status-queued { color: var(--accent); }

/* ---------------------------------------------------------------- disputes */
.badge {
  display: inline-block; margin-left: .4rem; padding: 0 .4rem; min-width: 1.1rem;
  background: var(--danger); color: #fff; border-radius: 3px;
  font-family: var(--mono); font-size: .7rem; line-height: 1.4; text-align: center;
}
.disputes-head { max-width: 900px; margin: 0 auto .8rem; }
.disputes-head h2 { margin-bottom: .2rem; }
#disputes-list { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: .9rem; }
.dispute-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .9rem 1rem; }
.dispute-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: .8rem; align-items: start; }
.dispute-sides .vs { color: var(--muted); font-size: .8rem; align-self: center; }
.dispute-side { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: .6rem .75rem; }
.side-label { font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.side-entity { font-size: .8rem; color: var(--accent-2); margin: .15rem 0; }
.side-text { font-size: .92rem; }
.dispute-side blockquote {
  margin: .5rem 0 0; padding: .35rem .6rem; border-left: 2px solid var(--accent);
  background: var(--accent-soft); font-size: .82rem;
}
.dispute-side blockquote footer { color: var(--muted); font-size: .74rem; margin-top: .2rem; }
.dispute-reason { margin: .6rem 0 0; font-size: .82rem; }
.dispute-actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; align-items: center; }
.dispute-actions .dispute-note { flex: 1; min-width: 180px; font-size: .82rem; }
.dispute-ruled { margin: .6rem 0 0; color: var(--ok); font-size: .88rem; }
.resolved-flash { border-color: var(--ok); transition: border-color .2s ease; }

/* ---------------------------------------------------------------- status */
.status-wrap { max-width: 980px; margin: 0 auto; }
.status-heading {
  margin: 1.6rem 0 .7rem; padding-bottom: .3rem;
  border-bottom: 1px solid var(--border); font-size: 1rem;
}
.status-wrap h4 { margin: 1rem 0 .4rem; color: var(--muted); font-family: var(--mono); font-size: .72rem; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; }
#jobs-summary { margin: .6rem 0 0; }
.status-wrap details {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: .55rem .8rem; margin: .5rem 0;
}
.status-wrap details summary { cursor: pointer; user-select: none; }
.status-wrap details[open] summary { margin-bottom: .5rem; }

/* ------------------------------------------------------- grouped disputes */
.dispute-question { font-size: .95rem; margin-bottom: .6rem; }
.dispute-sides.multi { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.team-note { font-size: .78rem; font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: .5rem; }
.claim-meta { color: var(--muted); font-size: .8rem; margin-left: .35rem; }
.claim.history { opacity: .75; border-left-style: dashed; }
.claim-group { margin-top: 1.4rem; }
details.claim-history > summary { cursor: pointer; margin-top: 1.4rem; color: var(--muted); }
.conflict-chip { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.evidence-chip { color: var(--text); background: var(--hover); border-color: transparent; }
.pick-claim { margin-top: .5rem; font-size: .8rem; }
.dispute-side .pick-claim:hover { border-color: var(--ok); color: var(--ok); }

/* -------------------------------------------------------- source viewer */
#source-viewer {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(27, 27, 26, .35);
  display: flex; align-items: center; justify-content: center;
}
#source-viewer.hidden { display: none; }
#source-panel {
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 8px;
  width: min(860px, 92vw); max-height: 84vh; display: flex; flex-direction: column;
  box-shadow: 0 16px 40px rgba(27, 27, 26, .18);
}
#source-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-weight: 500;
}
#source-body {
  padding: 1rem; overflow-y: auto; white-space: pre-wrap;
  font-family: var(--mono); font-size: .82rem; line-height: 1.6;
}
#source-body mark { background: #fde7d6; color: var(--text); border-radius: 2px; padding: .05rem .15rem; outline: 1px solid var(--accent); }
.cite { cursor: pointer; }
.cite:hover { background: rgba(194, 65, 12, .14); }

/* ---------------------------------------------------------- graph search */
/* The graph canvas absolutely fills the panel, so anything meant to be
   clickable must float ABOVE it (same reason the legend is absolute). */
#graph-search {
  position: absolute; top: .6rem; left: .8rem; z-index: 5;
  width: min(320px, 65%); font-size: .9rem;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}
#graph-search-status {
  position: absolute; top: 2.7rem; left: .9rem; z-index: 5; font-size: .78rem;
}
