:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1d1c19;
  --muted: #6b675e;
  --border: #dedad0;
  --accent: #2b59c3;
  --accent-ink: #ffffff;
  --good: #1f7a4d;
  --good-bg: #e3f3ea;
  --bad: #b3261e;
  --bad-bg: #fbe6e4;
  --c-prefix: #6d3fc0;
  --c-no: #1f5fbf;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151513;
    --surface: #1e1e1b;
    --surface-2: #272723;
    --text: #ecebe6;
    --muted: #9c988d;
    --border: #34332e;
    --accent: #7ea2ff;
    --accent-ink: #0e1630;
    --good: #5fd39a;
    --good-bg: #173326;
    --bad: #ff8a80;
    --bad-bg: #3a1c1a;
    --c-prefix: #b99cff;
    --c-no: #7fb0ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: .92em; }
:not(pre) > code { background: var(--surface-2); padding: .08em .35em; border-radius: 4px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 2.2rem 0 .8rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: normal; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; }
.brand-ref { font-size: .8rem; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--text); padding: 6px 10px; border-radius: 6px; }
nav a:hover { background: var(--surface-2); }
nav a.on { background: var(--surface-2); font-weight: 600; }
nav a.muted { color: var(--muted); }
main { padding-top: 24px; padding-bottom: 40px; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 32px; }

/* references */
.ref { font-family: var(--mono); font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.ref.big { font-size: clamp(1.3rem, 5vw, 2.2rem); }
.r-prefix { color: var(--c-prefix); }
.r-no { color: var(--c-no); }

/* cards, forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 12px; }
.grid.series { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin: 12px 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 7px 14px; }
button:disabled { opacity: .5; cursor: wait; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); font-weight: 500; }
button.ghost:hover { background: var(--surface-2); }
.form-card { display: flex; flex-direction: column; gap: 8px; border-style: dashed; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .grow { flex: 1 1 220px; }
.inline-form label:not(.grow) { flex: 0 1 110px; }
.series-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: 1.1rem; }
.kv { display: flex; gap: 8px; align-items: baseline; font-size: .88rem; padding: 2px 0; flex-wrap: wrap; }
.kv > span:first-child { color: var(--muted); min-width: 108px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-family: var(--mono); font-size: .88rem; overflow-wrap: anywhere; }
.flash.ok { background: var(--good-bg); color: var(--good); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
.err-text { color: var(--bad); margin: 0; }

/* intro / anatomy */
.intro p { max-width: 760px; color: var(--muted); margin-top: 0; }
.anatomy { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.anatomy dl { margin: 0; display: grid; gap: 2px; font-size: .86rem; }
.anatomy dl div { display: flex; gap: 10px; }
.anatomy dt { font-family: var(--mono); font-weight: 600; min-width: 74px; }
.anatomy dd { margin: 0; color: var(--muted); }
.big-anatomy { justify-content: center; }

/* register */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
.register td { border-top: 1px solid var(--border); }
.register tbody tr:first-child td { border-top: 0; }
th, td { text-align: left; padding: 8px 12px; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.danger-zone { margin-top: 32px; display: flex; }
.danger-zone form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* login */
.login { max-width: 380px; margin: 10vh auto 0; text-align: center; }
.login form { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 20px; }
.login-ref { font-size: 1.4rem; margin: 0 0 8px; }

/* lab */
.lab-form { display: grid; gap: 16px; }
.strategy-groups { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.strategies { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; align-content: start; }
.strategies legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; margin-bottom: 6px; }
.strategies:has(.radio.bad) legend { color: var(--bad); }
.strategies:has(.radio.good) legend { color: var(--good); }
.radio { flex-direction: row; align-items: flex-start; gap: 8px; color: var(--text); font-size: .9rem; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.radio.bad b { color: var(--bad); }
.radio.good b { color: var(--good); }
.radio input { margin-top: 4px; }
.lab-params { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.lab-go { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 12px; }
.chip { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 99px; padding: 4px 12px; font-size: .82rem; font-weight: 500; }
.chip:hover { border-color: var(--accent); }
.chip.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.chip.good { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.verdict { padding: 14px 16px; border-radius: var(--radius); font-size: 1.05rem; }
.verdict.good { background: var(--good-bg); color: var(--good); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.stat-v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-l { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.stat-n { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.stat.good .stat-v { color: var(--good); }
.stat.bad .stat-v { color: var(--bad); }
.chart-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
table.mini td, table.mini th { padding: 4px 10px; font-family: var(--mono); font-size: .85rem; }
.explain .card.bad, .verdict-card.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.explain .card.good, .verdict-card.good { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }

/* number map */
.map-card { margin: 12px 0; }
.nummap { display: grid; grid-template-columns: repeat(auto-fill, minmax(12px, 1fr)); gap: 2px; }
.sq { display: block; aspect-ratio: 1; border-radius: 2px; }
.sq.c1 { background: color-mix(in srgb, var(--c-no) 55%, transparent); }
.sq.c2 { background: var(--bad); }
.sq.c0 { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .sq { width: 12px; height: 12px; }

/* overview */
.hero h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); max-width: 860px; }
.hero .lede { max-width: 760px; color: var(--text); font-size: 1.08rem; }
.anatomy-note { flex-basis: 100%; margin: 0; }
.verdicts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.verdict-card { display: flex; flex-direction: column; }
.verdict-card p, .verdict-card ul { margin: 0 0 .6rem; font-size: .93rem; }
.verdict-card ul { padding-left: 1.1rem; }
.vc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.vc-head h3 { margin: 0; }
.vc-badge { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 99px; }
.vc-badge.bad { background: var(--bad-bg); color: var(--bad); }
.vc-badge.good { background: var(--good-bg); color: var(--good); }
.vc-rec { font-size: .78rem; color: var(--muted); }
.vc-links { margin-top: auto !important; display: flex; gap: 16px; flex-wrap: wrap; font-weight: 600; font-size: .9rem; }
.steps { padding-left: 1.3rem; max-width: 820px; }
.steps li { margin-bottom: .4rem; }
.explain p { margin: 0; font-size: .92rem; }

/* doc */
.doc { max-width: 820px; }
.doc section { scroll-margin-top: 72px; }
.doc p, .doc li { font-size: 1rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.lede { font-size: 1.1rem !important; }
.req { padding-left: 1.1rem; }
.toc { margin: 24px 0; }
.toc ol { margin: 8px 0 0; padding-left: 1.3rem; columns: 2 260px; }
.spec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: block; overflow-x: auto; margin: 12px 0; }
.spec td, .spec th { border-bottom: 1px solid var(--border); font-size: .9rem; }
.spec tr:last-child td { border-bottom: 0; }
pre.code-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-size: .86rem; line-height: 1.5; }
.layers { display: grid; gap: 14px; margin: 18px 0; }
.layer-item { display: grid; grid-template-columns: 36px 1fr; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.layer-item p { margin: 0 0 .5rem; }
.layer-item p:last-child { margin-bottom: 0; }
.layer-n { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.timeline { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 16px 0; background: var(--surface); }
.timeline .tl-head, .timeline .tl-row { display: grid; grid-template-columns: 1fr 1fr; }
.timeline .tl-head span { padding: 6px 12px; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.timeline .tl-row > * { padding: 6px 12px; border-bottom: 1px dashed var(--border); background: transparent; font-size: .84rem; overflow-wrap: anywhere; }
.timeline .tl-row > *:first-child { border-right: 1px solid var(--border); }
.timeline .tl-foot { padding: 8px 12px; font-size: .9rem; }
.timeline.bad .tl-foot { background: var(--bad-bg); color: var(--bad); }
.timeline.good .tl-foot { background: var(--good-bg); color: var(--good); }
.next { margin-top: 32px; font-weight: 600; }

/* code */
.code-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: start; }
.file-list { display: flex; flex-direction: column; padding: 8px; position: sticky; top: 72px; }
.file-list a { text-decoration: none; color: var(--text); font-family: var(--mono); font-size: .82rem; padding: 6px 8px; border-radius: 6px; overflow-wrap: anywhere; }
.file-list a.on { background: var(--surface-2); font-weight: 600; }
.code-view { padding: 0; overflow: hidden; }
.code-title { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.code-view pre { margin: 0; overflow-x: auto; }
.code-view pre code { display: block; padding: 14px 16px; font-size: .82rem; line-height: 1.55; background: transparent; }
.code-view pre code.hljs { background: transparent; }

@media (max-width: 720px) {
  .code-layout { grid-template-columns: 1fr; }
  .file-list { position: static; flex-direction: row; flex-wrap: wrap; }
  .brand-name { display: none; }
  .top { position: static; }
  .timeline .tl-head, .timeline .tl-row { grid-template-columns: 1fr 1fr; }
}
