:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #18212f;
  --muted: #5b6678;
  --line: #dde2ea;
  --accent: #2b4bb8;
  --accent-ink: #ffffff;
  --accent-soft: #e8edfb;
  --good: #14733a;
  --good-soft: #e3f4ea;
  --warn: #8a5a00;
  --warn-soft: #fff1d1;
  --high: #a8480a;
  --high-soft: #ffe8d6;
  --bad: #b42318;
  --bad-soft: #fde7e5;
  --note: #4a5568;
  --note-soft: #eceff4;
  --mark: #ffe58a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.06), 0 2px 8px rgba(20, 30, 50, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --surface: #171e29; --ink: #e8edf5; --muted: #9aa6b8; --line: #2a3445;
    --accent: #7c9bff; --accent-ink: #0b1020; --accent-soft: #1d2a4d;
    --good: #5fd08a; --good-soft: #12291c; --warn: #f0c35a; --warn-soft: #302410;
    --high: #ffa56b; --high-soft: #35200f; --bad: #ff8a7d; --bad-soft: #351514;
    --note: #b4bfd0; --note-soft: #1f2836; --mark: #5a4a10;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .9em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.right { text-align: right; }
.hide { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 54px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand svg { flex: none; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-size: .9rem; white-space: nowrap; }
.nav a:hover { background: var(--note-soft); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.proto { background: transparent; color: var(--accent); border: 1px solid var(--accent); font-weight: 600; margin: 0 6px; }
.nav a.proto.active { background: var(--accent); color: var(--accent-ink); }

@media (max-width: 700px) {
  .topbar-in { gap: 0; padding-top: 8px; }
  .nav { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
}
.container { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; outline: none; }
.footer { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }
.narrow { max-width: 820px; }

/* prototype toolbar */
.proto-bar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; box-shadow: var(--shadow); }
.roles { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.roles .lbl { font-size: .78rem; color: var(--muted); margin-right: 4px; text-transform: uppercase; letter-spacing: .04em; }
.role-pill { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 5px 11px; border-radius: 999px; font: inherit; font-size: .86rem; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.role-pill:hover { border-color: var(--accent); }
.role-pill[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.role-pill .count { background: var(--bad); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; }
.proto-bar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--muted); padding: 5px 10px; font: inherit; font-size: .82rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

/* guide */
.guide { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.guide .steps { display: flex; gap: 6px; }
.guide .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .72rem; display: grid; place-items: center; font-weight: 600; }
.guide .dot.done { background: var(--good); color: #fff; border-color: var(--good); }
.guide .dot.now { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.guide .txt { flex: 1; min-width: 240px; }
.guide .txt strong { display: block; }

/* cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h3 { margin-bottom: .6em; }
.card.flat { box-shadow: none; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: 1fr 1fr; } .split { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } h1 { font-size: 1.55rem; } }
.page-head { margin-bottom: 18px; }
.page-head .eyebrow { color: var(--accent); font-weight: 600; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; }
.page-head p.lead { font-size: 1.08rem; color: var(--muted); max-width: 760px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* buttons */
.btn { font: inherit; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 7px 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.sm { padding: 4px 10px; font-size: .82rem; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn:focus-visible, .role-pill:focus-visible, a:focus-visible, summary:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--note-soft); color: var(--note); white-space: nowrap; }
.chip.hard { background: var(--bad-soft); color: var(--bad); }
.chip.high { background: var(--high-soft); color: var(--high); }
.chip.medium { background: var(--warn-soft); color: var(--warn); }
.chip.note { background: var(--note-soft); color: var(--note); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.wait { background: var(--accent-soft); color: var(--accent); }
.chip.action { background: var(--warn-soft); color: var(--warn); }
.chip.outline { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }

/* forms */
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 4px; }
input[type="text"], input[type="number"], select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field { margin-bottom: 12px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.err { color: var(--bad); font-size: .86rem; margin-top: 6px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--note-soft) 60%, transparent); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--accent-soft); }
.tbl-wrap { overflow-x: auto; }

/* tracker */
.track { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.track:last-child { border-bottom: 0; }
.track .ico { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .9rem; background: var(--accent-soft); color: var(--accent); }
.track.done .ico { background: var(--good-soft); color: var(--good); }
.track.action .ico { background: var(--warn-soft); color: var(--warn); }
.track .body { flex: 1; min-width: 0; }
.status-big { font-size: 1.15rem; font-weight: 700; }
.status-big.good { color: var(--good); } .status-big.action { color: var(--warn); } .status-big.bad { color: var(--bad); } .status-big.wait { color: var(--accent); }

/* document viewer */
.doc { position: relative; font-family: var(--serif); font-size: .93rem; line-height: 1.65; white-space: pre-wrap; background: color-mix(in srgb, var(--surface) 92%, #fff8e0); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; max-height: 620px; overflow: auto; }
mark.hl { background: var(--mark); color: inherit; padding: 1px 0; border-radius: 3px; box-shadow: 0 0 0 2px var(--mark); }
mark.hl.other { background: transparent; box-shadow: none; border-bottom: 2px dotted var(--muted); }
.quote { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; color: var(--ink); font-family: var(--serif); font-size: .9rem; }
.callout { border-radius: 8px; padding: 10px 12px; background: var(--accent-soft); font-size: .92rem; }
.callout.warn { background: var(--warn-soft); } .callout.bad { background: var(--bad-soft); } .callout.good { background: var(--good-soft); }
.callout.note { background: var(--note-soft); }
.exposure { font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; }

details.act { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--surface); }
details.act > summary { cursor: pointer; padding: 9px 12px; font-weight: 600; font-size: .9rem; list-style: none; display: flex; align-items: center; gap: 8px; }
details.act > summary::-webkit-details-marker { display: none; }
details.act > summary::before { content: "▸"; color: var(--muted); }
details.act[open] > summary::before { content: "▾"; }
details.act > .in { padding: 4px 12px 12px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 92px 110px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .85rem; }
.timeline li:last-child { border-bottom: 0; }
@media (max-width: 620px) { .timeline li { grid-template-columns: 1fr; gap: 0; } }

.sample { display: flex; flex-direction: column; gap: 8px; }
.sample h4 { margin: 0; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
@media (max-width: 620px) { .kv { grid-template-columns: 1fr; } }
.tag { font-family: var(--mono); font-size: .78rem; background: var(--note-soft); border-radius: 6px; padding: 1px 6px; color: var(--ink); }
.ph { background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); border-radius: 6px; padding: 1px 7px; font-weight: 600; font-size: .88em; }
.ph-block { background: var(--warn-soft); border: 1px dashed var(--warn); border-radius: 8px; padding: 12px 14px; color: var(--warn); }
.pill-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .85rem; }
.hero { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--line); border-radius: 14px; padding: 28px 26px; margin-bottom: 18px; }
.hero h1 { font-size: 2.1rem; max-width: 780px; }
.hero p { font-size: 1.1rem; max-width: 720px; color: var(--muted); }
.stat { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.bar { height: 8px; background: var(--note-soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; font-size: .9rem; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } html { scroll-behavior: auto; } .toast { transition: none; } }
ul.clean { list-style: none; padding: 0; margin: 0; } ul.clean li { padding: 4px 0; }
ul.tight { margin: 0 0 .9em; padding-left: 1.2em; } ul.tight li { margin-bottom: .3em; }
blockquote.q { margin: 0 0 .9em; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
