:root {
  --bg: #fbfbfa; --panel: #ffffff; --sunken: #f3f3f1; --line: #e7e6e3; --line-strong: #d6d5d1;
  --text: #1b1c1f; --muted: #6b6e76; --faint: #9a9da5;
  --accent: #1f7a55; --accent-soft: #e5f3ec; --accent-text: #17603f;
  --active: #3456c9; --active-soft: #e9edfb;
  --warn: #b25a14; --warn-soft: #fbeee2;
  --bad: #b4232c; --bad-soft: #fbe9ea;
  --radius: 8px; --shadow: 0 1px 2px rgba(20,20,30,.05), 0 0 0 1px var(--line);
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #0e0f11; --panel: #15161a; --sunken: #1b1d21; --line: #25272d; --line-strong: #33363d;
    --text: #e8e9ec; --muted: #9a9ea8; --faint: #6c707a;
    --accent: #3ecf8e; --accent-soft: #12271e; --accent-text: #5fe0a5;
    --active: #8aa2ff; --active-soft: #1a2040;
    --warn: #f0a35c; --warn-soft: #2b1e12; --bad: #ff7b82; --bad-soft: #2d1416;
    --shadow: 0 0 0 1px var(--line); color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #0e0f11; --panel: #15161a; --sunken: #1b1d21; --line: #25272d; --line-strong: #33363d;
  --text: #e8e9ec; --muted: #9a9ea8; --faint: #6c707a;
  --accent: #3ecf8e; --accent-soft: #12271e; --accent-text: #5fe0a5;
  --active: #8aa2ff; --active-soft: #1a2040;
  --warn: #f0a35c; --warn-soft: #2b1e12; --bad: #ff7b82; --bad-soft: #2d1416;
  --shadow: 0 0 0 1px var(--line); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--active); }
:focus-visible { outline: 2px solid var(--active); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--muted); text-transform: none; letter-spacing: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
code, .mono { font-family: var(--mono); font-size: 12px; }
pre { font-family: var(--mono); font-size: 12px; background: var(--sunken); border-radius: 6px; padding: 10px 12px; overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }
.prose { white-space: pre-wrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }

/* shell */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand img { width: 22px; height: 22px; }
.nav a { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--sunken); color: var(--text); }
.nav a.on { background: var(--sunken); color: var(--text); }
.nav svg { width: 16px; height: 16px; flex: none; }
.nav .count { margin-left: auto; font-size: 11px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 0 7px; font-weight: 600; }
.side .group { margin-top: 18px; padding: 0 8px 4px; font-size: 11px; color: var(--faint); font-weight: 600; }
.side .foot { margin-top: auto; padding: 8px; display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); z-index: 5; }
.top .crumbs { color: var(--muted); display: flex; gap: 6px; align-items: center; }
.top .crumbs a:last-child { color: var(--text); font-weight: 500; }
.top .spacer { flex: 1; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }
.search-btn { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); padding: 5px 8px 5px 10px; border-radius: 7px; cursor: pointer; font: inherit; min-width: 220px; }
.content { padding: 24px 28px 64px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -6px 0 20px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.on { color: var(--text); border-color: var(--text); }

/* blocks */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: 2fr 1fr; }
@media (max-width: 960px) { .shell { grid-template-columns: 1fr; } .side { display: none; } .cols-2, .cols-3 { grid-template-columns: 1fr; } .content { padding: 18px; } }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card.flush { padding: 0; }
.card > h2 { display: flex; align-items: center; gap: 8px; }
.card > h2 .more { margin-left: auto; font-weight: 500; color: var(--faint); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 10px; align-items: center; padding: 9px 16px; border-top: 1px solid var(--line); min-width: 0; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .wrap { flex: 1; min-width: 0; }
.card .list > li { padding-left: 0; padding-right: 0; }
.card.flush .list > li { padding: 10px 16px; }
.num { color: var(--faint); font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; min-width: 34px; }
.empty { color: var(--faint); padding: 18px 0; text-align: center; }
.empty strong { display: block; color: var(--muted); font-weight: 500; margin-bottom: 2px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 16px; }
.metric { background: var(--panel); padding: 12px 16px; }
.metric .v { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric .k { font-size: 12px; color: var(--muted); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 20px; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--accent-soft); color: var(--accent-text); }
.badge.active { background: var(--active-soft); color: var(--active); }
.badge.active::before { animation: pulse 1.6s ease-in-out infinite; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.plain::before { display: none; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.src-observed { color: var(--accent-text); } .src-verifier { color: var(--active); } .src-claim { color: var(--warn); }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .badge.active::before { animation: none; } }

/* forms */
input, textarea, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px; width: 100%; }
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--active); box-shadow: 0 0 0 3px var(--active-soft); }
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin: 10px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 13px; }
label.check input { width: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; font-size: 13px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--sunken); color: var(--text); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: .9; }
.btn.good { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
form.inline { display: inline; }
details > summary { cursor: pointer; color: var(--muted); font-weight: 500; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 14px; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
.flash { padding: 10px 14px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); margin-bottom: 16px; }
.secret { font-family: var(--mono); background: var(--accent-soft); color: var(--accent-text); padding: 10px 12px; border-radius: 6px; word-break: break-all; }

/* item page */
.lifecycle { display: flex; gap: 4px; margin: 4px 0 18px; flex-wrap: wrap; }
.lifecycle span { font-size: 11px; padding: 3px 8px; border-radius: 4px; background: var(--sunken); color: var(--faint); }
.lifecycle span.done { color: var(--accent-text); background: var(--accent-soft); }
.lifecycle span.now { color: var(--active); background: var(--active-soft); font-weight: 600; }
.criteria { list-style: none; padding: 0; margin: 0; counter-reset: c; }
.criteria li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); counter-increment: c; }
.criteria li:first-child { border-top: 0; }
.criteria li::before { content: counter(c); color: var(--faint); font-family: var(--mono); font-size: 12px; min-width: 16px; padding-top: 1px; }
.criteria .mark { margin-left: auto; flex: none; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 5px 0; font-size: 13px; }
.timeline .t { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline .a { color: var(--faint); font-size: 12px; }
.progress-line { color: var(--active); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* decisions */
.decision { padding: 18px; }
.decision + .decision { border-top: 1px solid var(--line); }
.decision .q { font-size: 15px; font-weight: 600; margin: 4px 0 6px; }
.decision .meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.options { display: grid; gap: 6px; margin: 10px 0; }
.option { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--panel); font: inherit; color: inherit; cursor: pointer; }
.option:hover { border-color: var(--active); background: var(--active-soft); }
.option.rec { border-color: var(--accent); }
.option .l { font-weight: 600; }
.option .d { color: var(--muted); font-size: 12px; }
.rec-badge { margin-left: auto; font-size: 11px; color: var(--accent-text); font-weight: 600; white-space: nowrap; }

/* report */
.report { max-width: 820px; }
.report section { margin-bottom: 26px; }
.report h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 8px; }
.report .lead { font-size: 16px; line-height: 1.6; }
.proof { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.proof figure { margin: 0; }
.proof img, .proof video, .media video { width: 100%; border-radius: 6px; box-shadow: var(--shadow); background: var(--sunken); }
.proof figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.evidence-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.evidence-row:first-child { border-top: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--faint); }
.dot.ok { background: var(--accent); } .dot.warn { background: var(--bad); }

/* palette */
.palette { position: fixed; inset: 0; background: rgba(10,10,14,.35); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 50; }
.palette.open { display: flex; }
.palette .box { width: min(620px, 92vw); background: var(--panel); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3), 0 0 0 1px var(--line); overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 16px; font-size: 15px; box-shadow: none !important; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette li { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; align-items: center; }
.palette li.sel { background: var(--sunken); }
.palette li .type { font-size: 11px; color: var(--faint); width: 74px; flex: none; }
.palette .hint { padding: 8px 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; display: flex; gap: 14px; }

.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 360px; padding: 28px; }
.login .brand { padding: 0 0 18px; font-size: 16px; }
.side .foot .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
