:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --text: #1c1c1e;
  --muted: #6c6b68;
  --border: #e2dfd8;
  --accent: #2f6db5;
  --accent-soft: rgba(47, 109, 181, 0.12);
  --signal: #3b7dd8;
  --signal-fill: rgba(59, 125, 216, 0.18);
  --cut: #d9534f;
  --speech: #2f8f5b;
  --watched: rgba(47, 143, 91, 0.35);
  --warn: #b56a00;
  --warn-soft: rgba(224, 161, 0, 0.14);
  --bad: #c0392b;
  --bad-soft: rgba(192, 57, 43, 0.1);
  --ok: #2f8f5b;
  --ok-soft: rgba(47, 143, 91, 0.12);
  --uncertain: #7c5cc4;
  --playhead: #1c1c1e;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141416;
    --surface: #1d1d20;
    --surface-2: #232327;
    --text: #ececec;
    --muted: #9b9a97;
    --border: #34343a;
    --accent: #6ea3e6;
    --accent-soft: rgba(110, 163, 230, 0.16);
    --signal: #6ea3e6;
    --signal-fill: rgba(110, 163, 230, 0.22);
    --cut: #ef7470;
    --speech: #5cc28c;
    --watched: rgba(92, 194, 140, 0.4);
    --warn: #f2c14e;
    --warn-soft: rgba(242, 193, 78, 0.14);
    --bad: #ef7470;
    --bad-soft: rgba(239, 116, 112, 0.14);
    --ok: #5cc28c;
    --ok-soft: rgba(92, 194, 140, 0.14);
    --uncertain: #a98bf0;
    --playhead: #ffffff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.crumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.who { font-size: 12px; color: var(--muted); white-space: nowrap; }
.who button { margin-left: 6px; }

.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 2px 7px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.5; cursor: default; }
input[type=text], input:not([type]), textarea, select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 5px 7px; width: 100%;
}
textarea { resize: vertical; min-height: 54px; }
label.inline { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }

.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap;
}
.pill.COMPUTED, .pill.ok, .pill.ASSESSED { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.PROVISIONAL, .pill.warn, .pill.UNCERTAIN { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.ERROR, .pill.bad, .pill.UNASSESSABLE { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.ABSENT, .pill.INAPPLICABLE { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.priority { background: var(--accent); color: #fff; border-color: transparent; }

.notice { padding: 8px 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.notice.warn { background: var(--warn-soft); border-color: transparent; }
.notice.bad { background: var(--bad-soft); border-color: transparent; }
.notice.ok { background: var(--ok-soft); border-color: transparent; }

/* index */
.asset-list { display: grid; gap: 10px; }
.asset { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.asset .meta { font-size: 12px; color: var(--muted); }
.assessment-row { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
table.plain { border-collapse: collapse; width: 100%; font-size: 12px; }
table.plain td, table.plain th { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.plain th { color: var(--muted); font-weight: 500; }

/* review screen */
.review { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); gap: 14px; padding: 14px 16px 90px; }
@media (max-width: 960px) { .review { grid-template-columns: 1fr; } }
.left { min-width: 0; }
.left .sticky { position: sticky; top: 58px; }
video { width: 100%; background: #000; border-radius: var(--radius); display: block; max-height: 52vh; }
.timeline-wrap { position: relative; margin-top: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
canvas.timeline { display: block; width: 100%; cursor: crosshair; }
.player-bar { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 12px; flex-wrap: wrap; }
.player-bar .time { font-variant-numeric: tabular-nums; }
.identity { margin-top: 10px; font-size: 12px; }
.identity dt { color: var(--muted); }
.identity dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 0; }
.identity dd { margin: 0; overflow-wrap: anywhere; }
.undeclared { color: var(--warn); }

.right { min-width: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 10px; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 7px 10px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { font-size: 11px; color: var(--muted); margin-left: 3px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 4px 9px; cursor: pointer; font-size: 12px; }
.seg button.on { background: var(--accent); color: #fff; }

.area-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 14px 0 6px; }
.question { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.question > .qhead { display: flex; gap: 8px; align-items: flex-start; padding: 9px 11px; cursor: pointer; }
.question > .qhead .qid { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); padding-top: 2px; }
.question > .qhead .qlabel { flex: 1; font-weight: 600; }
.question.open > .qhead { border-bottom: 1px solid var(--border); }
.qbody { padding: 10px 11px; }
.qbody .baseline { font-style: italic; margin-bottom: 8px; }
details.guide { font-size: 12px; margin-bottom: 10px; }
details.guide summary { cursor: pointer; color: var(--accent); }
details.guide dl { margin: 6px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; }
details.guide dt { color: var(--muted); }
details.guide dd { margin: 0; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

.field { border-top: 1px dashed var(--border); padding-top: 9px; margin-top: 9px; }
.field:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.field-head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.field-head .flabel { font-weight: 600; }

.unit { border: 1px solid var(--border); border-radius: 6px; padding: 9px; margin-bottom: 8px; background: var(--surface-2); }
.unit.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.unit .uhead { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.unit .uid { width: 7em; }
.unit .span { font-variant-numeric: tabular-nums; font-size: 12px; }
.unit .sub { font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
.states { display: flex; gap: 4px; flex-wrap: wrap; }
.states label { border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; font-size: 12px; cursor: pointer; background: var(--surface); }
.states input { display: none; }
.states label.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.anchor { display: grid; grid-template-columns: auto 1fr; gap: 6px; align-items: start; padding: 4px 0; cursor: pointer; font-size: 13px; }
.anchor .def { color: var(--muted); font-size: 12px; }
.anchor.legacy { opacity: 0.5; }
.evidence { display: grid; grid-template-columns: auto 6em 1fr auto; gap: 6px; align-items: center; margin-bottom: 4px; }
.hints { margin-top: 6px; font-size: 12px; color: var(--warn); }
.hints div::before { content: "• "; }
.policy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.modreason textarea { border-color: var(--uncertain); }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: 10px; align-items: center;
  padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap;
}
.savebar .status { flex: 1; min-width: 200px; font-size: 13px; }
.errors { font-size: 12px; max-height: 30vh; overflow: auto; }
.errors li { cursor: pointer; }

.diff { border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin-bottom: 6px; background: var(--surface); cursor: pointer; font-size: 13px; }
.diff .sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; font-size: 12px; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

.gate { max-width: 420px; margin: 60px auto; }
