/* ProofVault — design tokens
   ink    #141C28  vault background (dark)      paper  #F3F5F8 (light)
   panel  #1B2433  surfaces                      #FFFFFF
   rule   #2A3546  hairlines                     #DCE1E8
   text   #E6EAF0  primary text                  #172131
   muted  #8B97A8  secondary text                #5B6676
   brass  #C8A35A  seal / primary action / integrity (the only accent)
   ok     #5BB98B  integrity match    flag #E3735E  needs review */
:root {
  --ink: #141C28; --panel: #1B2433; --panel-2: #222D3E; --rule: #2A3546; --text: #E6EAF0; --muted: #8B97A8;
  --brass: #C8A35A; --brass-ink: #1A1408; --brass-soft: rgba(200,163,90,.14);
  --ok: #5BB98B; --ok-soft: rgba(91,185,139,.14); --flag: #E3735E; --flag-soft: rgba(227,115,94,.14);
  --info: #86A9D6; --info-soft: rgba(134,169,214,.14);
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-sheet: 18px; --r-card: 12px; --r-ctl: 9px; --r-pill: 999px;
  --nav-w: 232px; --tab-h: 64px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --ink: #F3F5F8; --panel: #FFFFFF; --panel-2: #F7F8FA; --rule: #DCE1E8; --text: #172131; --muted: #5B6676;
  --brass: #9C7A33; --brass-ink: #FFFFFF; --brass-soft: rgba(156,122,51,.12);
  --ok: #2E8B5E; --ok-soft: rgba(46,139,94,.10); --flag: #C2492F; --flag-soft: rgba(194,73,47,.09);
  --info: #3A68A8; --info-soft: rgba(58,104,168,.09);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ink); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: .86em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; }
.brand-name { font: 600 19px/1 var(--serif); letter-spacing: -.01em; }
.rail a.nav { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-ctl); text-decoration: none; color: var(--muted); font-weight: 500; }
.rail a.nav:hover { color: var(--text); background: var(--panel); }
.rail a.nav[aria-current="page"] { color: var(--text); background: var(--panel); box-shadow: inset 2px 0 0 var(--brass); }
.rail .spacer { flex: 1; }
.rail .who { padding: 12px; border-top: 1px solid var(--rule); font-size: 13px; }
.icon { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
main { min-width: 0; padding: 30px clamp(18px, 4vw, 48px) 80px; max-width: 1180px; width: 100%; }
.tabbar { display: none; }

/* ---------- type ---------- */
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.page-title { font: 600 clamp(26px, 3.4vw, 34px)/1.15 var(--serif); }
.record-title { font: 600 clamp(26px, 4vw, 40px)/1.1 var(--serif); letter-spacing: -.015em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.lede { color: var(--muted); max-width: 62ch; margin: 8px 0 0; }
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r-ctl);
  border: 1px solid var(--rule); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brass); color: var(--brass-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel); }
.btn.danger { color: var(--flag); }
.btn.big { min-height: 52px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .icon { width: 17px; height: 17px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, textarea.input, select.input { width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--r-ctl); border: 1px solid var(--rule); background: var(--ink); }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.check input { margin-top: 3px; accent-color: var(--brass); width: 17px; height: 17px; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .input { padding-left: 40px; min-height: 46px; }

/* ---------- surfaces ---------- */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-card); }
.pad { padding: 18px; }
.list { display: grid; }
.list > .item { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--rule); text-decoration: none; min-width: 0; }
.list > .item:first-child { border-top: 0; }
a.item:hover { background: var(--panel-2); }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 14px; }

/* chips (status / provenance) — sentence case, no tracking */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--rule); white-space: nowrap; }
.chip.id { font-family: var(--mono); font-weight: 500; font-size: 11.5px; color: var(--text); }
.chip.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.chip.flag { color: var(--flag); background: var(--flag-soft); border-color: transparent; }
.chip.brass { color: var(--brass); background: var(--brass-soft); border-color: transparent; }
.chip.info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.prov { font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.prov::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--prov, var(--muted)); }
.prov.user { --prov: var(--text); } .prov.meta { --prov: var(--info); } .prov.ai { --prov: var(--brass); } .prov.sys { --prov: var(--ok); } .prov.unknown { --prov: var(--flag); }

/* ---------- dashboard ---------- */
.greet { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.ledger { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--panel); margin-top: 24px; }
.ledger > * { padding: 16px 18px; border-left: 1px solid var(--rule); color: inherit; }
.ledger > a:hover { background: var(--panel-2); }
.ledger > *:first-child { border-left: 0; }
.ledger .n { font: 600 30px/1 var(--serif); font-variant-numeric: tabular-nums; }
.ledger .k { font-size: 13px; color: var(--muted); margin-top: 6px; }
.cat { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--rule); flex: none; color: var(--muted); }

/* ---------- incident ---------- */
.rec-head { display: grid; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--rule); }
.rec-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 2px; margin: 18px 0 22px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--rule); }
.tabs button { background: none; border: 0; padding: 11px 14px; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--brass); }
.tabs .count { font-weight: 500; color: var(--muted); margin-left: 4px; }
.grid-ev { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.ev-card { display: grid; grid-template-rows: auto 1fr; text-decoration: none; overflow: hidden; }
.ev-card:hover { border-color: var(--muted); }
.ev-thumb { aspect-ratio: 16 / 10; background: var(--panel-2); display: grid; place-items: center; border-bottom: 1px solid var(--rule); overflow: hidden; position: relative; }
.ev-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ev-thumb .ft { font: 600 13px var(--mono); color: var(--muted); }
.ev-body { padding: 12px 14px; display: grid; gap: 6px; min-width: 0; }
.ev-body .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.processing { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--info); }
.processing::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- timeline ---------- */
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: var(--rule); }
.tl-day { font: 600 15px var(--serif); margin: 22px 0 10px -26px; padding-left: 26px; position: relative; }
.tl-day:first-child { margin-top: 0; }
.tl-ev { position: relative; padding: 12px 16px; margin-bottom: 10px; }
.tl-ev::before { content: ""; position: absolute; left: -25px; top: 18px; width: 11px; height: 11px; border-radius: 50%; background: var(--ink); border: 2px solid var(--brass); }
.tl-ev.approx::before { border-style: dashed; border-color: var(--muted); }
.tl-ev.unknown::before { border-color: var(--flag); }
.tl-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.tl-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tl-links a { text-decoration: none; }

/* ---------- integrity seal (signature element) ---------- */
.seal-wrap { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.seal { width: 132px; height: 132px; position: relative; flex: none; }
.seal svg { width: 100%; height: 100%; display: block; }
.seal .ring { fill: none; stroke: var(--brass); stroke-width: 2.5; stroke-dasharray: 400; stroke-dashoffset: 0; transform-origin: 50% 50%; }
.seal.verifying .ring { animation: draw 1.1s cubic-bezier(.6,.1,.2,1) both; }
.seal.mismatch .ring { stroke: var(--flag); }
@keyframes draw { from { stroke-dashoffset: 400; transform: rotate(-90deg); } to { stroke-dashoffset: 0; transform: rotate(0); } }
.seal-mini { width: 26px; height: 26px; flex: none; }
.hash { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; word-break: break-all; color: var(--text); }
.hash-line { background: var(--ink); border: 1px solid var(--rule); border-radius: var(--r-ctl); padding: 10px 12px; }
.verdict { font: 600 20px/1.2 var(--serif); }
.verdict.ok { color: var(--ok); } .verdict.flag { color: var(--flag); }

/* key/value */
.kv { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; }
.kv > div { padding: 10px 0; border-top: 1px solid var(--rule); min-width: 0; overflow-wrap: anywhere; }
.kv > div:nth-child(-n+2) { border-top: 0; }
.kv .k { color: var(--muted); font-size: 13px; padding-right: 12px; }
.extracted { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; background: var(--ink); border: 1px dashed var(--rule); border-radius: var(--r-ctl); padding: 14px; max-height: 360px; overflow: auto; }
.preview { border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--rule); background: var(--panel-2); }
.preview img, .preview video { display: block; width: 100%; max-height: 520px; object-fit: contain; background: #000; }
.preview audio { width: 100%; display: block; padding: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 16px; }

/* ask */
.ask-log { display: grid; gap: 14px; }
.q { justify-self: end; max-width: 80%; background: var(--panel-2); border: 1px solid var(--rule); padding: 10px 14px; border-radius: 14px 14px 4px 14px; }
.a { max-width: 92%; padding: 14px 16px; border-left: 2px solid var(--brass); background: var(--panel); border-radius: 0 12px 12px 0; }
.a p { margin: 0; white-space: pre-wrap; }
.a .foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest button { border: 1px solid var(--rule); background: transparent; border-radius: var(--r-pill); padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.suggest button:hover { color: var(--text); border-color: var(--muted); }

/* conflict + radar */
.conflict { padding: 16px; border-left: 3px solid var(--flag); }
.conflict.reviewed { border-left-color: var(--muted); opacity: .8; }
.vs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
.vs > div { background: var(--ink); border: 1px solid var(--rule); border-radius: var(--r-ctl); padding: 10px 12px; }
.vs .v { font: 600 18px var(--serif); }
.radar { padding: 16px; border: 1px solid var(--brass-soft); background: linear-gradient(var(--brass-soft), transparent 70%), var(--panel); }

/* sheet / modal */
.scrim { position: fixed; inset: 0; background: rgba(5,8,14,.55); z-index: 40; display: grid; place-items: center; padding: 18px; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-sheet); padding: 22px; animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.cats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cats button { display: grid; gap: 6px; place-items: center; padding: 12px 4px; border: 1px solid var(--rule); background: var(--ink); border-radius: 10px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.cats button[aria-pressed="true"] { border-color: var(--brass); color: var(--text); box-shadow: inset 0 0 0 1px var(--brass); }
.actions { display: grid; gap: 4px; }
.actions button, .actions label { display: flex; align-items: center; gap: 14px; padding: 13px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; font-weight: 600; }
.actions button:hover, .actions label:hover { background: var(--panel-2); }
.actions .cat { width: 36px; height: 36px; }
.drop { border: 1.5px dashed var(--rule); border-radius: var(--r-card); padding: 26px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--brass); background: var(--brass-soft); color: var(--text); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 22px); transform: translateX(-50%); background: var(--text); color: var(--ink); padding: 11px 18px; border-radius: 10px; font-weight: 600; z-index: 60; font-size: 14px; max-width: calc(100% - 32px); animation: rise .2s ease-out; }
.toast.err { background: var(--flag); color: #fff; }
.notice { padding: 12px 14px; border-radius: var(--r-ctl); background: var(--info-soft); color: var(--text); font-size: 13.5px; }
.notice.warn { background: var(--flag-soft); }
.disclaimer { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 26px; max-width: 75ch; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { padding: 48px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--rule); background:
  radial-gradient(120% 80% at 0% 100%, var(--brass-soft), transparent 60%), var(--ink); }
.auth-art h1 { font: 600 clamp(34px, 4.6vw, 58px)/1.04 var(--serif); letter-spacing: -.02em; max-width: 11ch; }
.flow { display: grid; gap: 8px; margin-top: 28px; max-width: 360px; }
.flow div { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.flow b { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--rule); display: grid; place-items: center; font: 600 11px var(--mono); color: var(--brass); }
.auth-form { display: grid; place-items: center; padding: 32px 22px; }
.auth-form form { width: min(380px, 100%); }
.demo { margin-top: 18px; padding: 14px; border: 1px dashed var(--rule); border-radius: var(--r-card); font-size: 13.5px; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  main { padding: 18px 16px calc(var(--tab-h) + 40px); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--rule); z-index: 30; }
  .tabbar a, .tabbar button { display: grid; place-items: center; align-content: center; gap: 3px; font-size: 11px; font-weight: 600; text-decoration: none; color: var(--muted); background: none; border: 0; }
  .tabbar a[aria-current="page"] { color: var(--text); }
  .tabbar .plus { width: 54px; height: 54px; border-radius: 18px; background: var(--brass); color: var(--brass-ink); margin: -18px auto 0; box-shadow: 0 8px 22px rgba(0,0,0,.35); display: grid; place-items: center; }
  .tabbar .plus .icon { width: 26px; height: 26px; stroke-width: 2.2; }
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger > *:nth-child(3) { border-left: 0; }
  .ledger > *:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .cols { grid-template-columns: 1fr; }
  .scrim { place-items: end center; padding: 0; }
  .sheet { border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .cats { grid-template-columns: repeat(5, 1fr); }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 22px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .auth-art .flow { display: none; }
  .seal-wrap { grid-template-columns: 1fr; justify-items: start; }
  .kv { grid-template-columns: 1fr; }
  .kv .k { padding-bottom: 0; border-top: 1px solid var(--rule); }
  .kv > div:not(.k) { border-top: 0; padding-top: 2px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
