:root {
  --paper: #ffffff;
  --card: #faf9f6;
  --ink: #141311;
  --ink-soft: #3f3d38;
  --muted: #6d6a62;
  --rule: #e2ded4;
  --accent: #c2410c;
  --accent-soft: #fdeede;
  --good: #1e7e34;
  --warn: #9a6700;
  --dust: #92400e;
  --water: #075985;
  --bar-h: 3.25rem;
  --radius: 14px;
  --display: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
html[data-theme="dark"] {
  --paper: #111113;
  --card: #18181c;
  --ink: #f2f0ea;
  --ink-soft: #c9c6bd;
  --muted: #9e9b92;
  --rule: #2b2b30;
  --accent: #fb923c;
  --accent-soft: #2a1c10;
  --good: #4ade80;
  --warn: #fbbf24;
  --dust: #fbbf24;
  --water: #38bdf8;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: #fff; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---- house topbar: one line, jumps, language, sun/moon icon ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .9rem;
  height: var(--bar-h); padding: 0 1rem;
  background: var(--paper); border-bottom: 1px solid var(--rule);
  font-size: .92rem; white-space: nowrap;
}
.topbar .home { color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.02em; }
.topbar .home:hover { color: var(--accent); }
.topnav { display: flex; gap: 1rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--ink-soft); text-decoration: none; padding: .4rem .1rem; }
.topnav a:hover { color: var(--accent); }
.topnav a[aria-current="true"] { color: var(--accent); font-weight: 700; }
.topbar .spacer { flex: 1 1 auto; }
.topbar .chip {
  color: var(--ink); text-decoration: none; font-weight: 600;
  border: 1px solid var(--rule); border-radius: 999px; padding: .3rem .8rem;
}
.topbar .chip:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; border: 1px solid var(--rule); border-radius: 50%;
  background: transparent; color: var(--ink); cursor: pointer; flex: none;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

/* ---- layout ---- */
.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1.25rem; }
.prose { max-width: 44rem; }
section { scroll-margin-top: calc(var(--bar-h) + .75rem); }
section.block { padding: 3rem 0; border-top: 1px solid var(--rule); }
h1, h2, h3 { line-height: 1.12; letter-spacing: -.03em; text-wrap: balance; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); margin: 0 0 1rem; }
h2 .perma { color: var(--muted); text-decoration: none; font-weight: 400; margin-left: .2rem; padding: .5rem; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: var(--paper); padding: .7rem 1.1rem; z-index: 100; border-radius: 0 0 8px 0; font-weight: 700; }
.skip:focus { left: 0; }
.svg-notch { fill: var(--card); }
.svg-dot { fill: #fb923c; }
.svg-num { font: 700 15px system-ui, sans-serif; fill: #17171b; text-anchor: middle; }
.anatomy { display: flex; gap: 2rem; align-items: center; }
.anatomy svg { flex: 1 1 52%; min-width: 0; }
.legend { flex: 1 1 48%; min-width: 0; margin: 0; padding: 0; list-style: none; counter-reset: leg; display: grid; gap: .9rem; }
.legend li { counter-increment: leg; display: flex; gap: .7rem; align-items: baseline; }
.legend li::before {
  content: counter(leg); flex: none;
  width: 1.55rem; height: 1.55rem; border-radius: 50%;
  background: #fb923c; color: #17171b;
  font: 700 .85rem/1.55rem system-ui, sans-serif; text-align: center;
}
html[data-theme="dark"] .legend li::before { color: #111113; }
.legend b { font-family: var(--mono); white-space: nowrap; }
.legend span { color: var(--ink-soft); font-size: .95rem; }
h2 .perma:hover { color: var(--accent); }
.lede { font-size: clamp(1.1rem, 1.8vw, 1.3rem); color: var(--ink-soft); max-width: 40rem; }

/* ---- hero + decoder ---- */
.hero { padding: clamp(2.5rem, 6vw, 4.5rem) 0 2.5rem; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.3rem); font-weight: 850; margin: 0 0 1rem; max-width: 16ch; }
.hero h1 .q { color: var(--accent); }
.decoder {
  margin-top: 2rem; background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 2rem);
}
.decoder label { display: block; font-weight: 700; margin-bottom: .5rem; }
.decoder .row { display: flex; gap: .6rem; flex-wrap: wrap; }
.decoder input[type="text"] {
  flex: 1 1 16rem; min-height: 3.2rem;
  font: 500 1.15rem/1.3 var(--mono);
  color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 10px; padding: .6rem .9rem;
}
.decoder input[type="text"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  min-height: 3.2rem; padding: .6rem 1.2rem;
  border-radius: 10px; border: 1.5px solid var(--ink);
  background: var(--ink); color: var(--paper);
  font: 700 .95rem/1 var(--display); cursor: pointer; white-space: nowrap;
}
html[data-theme="dark"] .btn { background: var(--ink); color: #111113; border-color: var(--ink); }
html[data-theme="dark"] .btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.example-line { margin: .7rem 0 0; color: var(--muted); font-size: .92rem; }
.example-line button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 3px;
}

/* ---- notes ---- */
.notes { margin: 1.2rem 0 0; padding: 0; list-style: none; display: grid; gap: .6rem; }
.note {
  border-left: 3px solid var(--rule); padding: .15rem 0 .15rem .8rem;
  color: var(--ink-soft); font-size: .98rem;
}
.note.same { border-color: var(--accent); color: var(--ink); font-weight: 600; font-size: 1.05rem; }
.note.honest { border-color: var(--accent); color: var(--ink); font-weight: 600; }

/* ---- IP result: two chambers, one per axis ---- */
.ipcards { display: grid; gap: 1rem; margin-top: 1.4rem; }
.ipcard {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 12px;
  padding: 1.1rem 1.2rem 1.2rem;
}
.ipcard p { margin: 0 0 .5rem; }
.ipcard p:last-child { margin-bottom: 0; }
.ip-code { font: 700 1.6rem/1.2 var(--mono); letter-spacing: -.02em; }
.chambers { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-top: .8rem; }
.chamber {
  background: var(--card); border: 1px solid var(--rule); border-radius: 10px;
  border-top: 3px solid var(--muted); padding: .9rem 1rem; min-width: 0;
}
.chamber.solids { border-top-color: var(--dust); }
.chamber.water { border-top-color: var(--water); }
.ch-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.ch-axis { font-size: .72rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ch-digit { font: 700 2rem/1 var(--mono); }
.solids .ch-digit { color: var(--dust); }
.water .ch-digit { color: var(--water); }
.ch-k { font-size: 1.1rem; }
.ch-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.gauge { position: relative; display: flex; gap: 3px; padding-bottom: 1rem; margin-top: .4rem; }
.gauge i { flex: 1 1 0; height: .55rem; min-width: 0; background: var(--rule); border-radius: 3px; }
.chamber.solids .gauge i.on { background: var(--dust); }
.chamber.water .gauge i.on { background: var(--water); }
.gauge.x i { background: transparent; border: 1px dashed var(--muted); }
.g-min, .g-max { position: absolute; bottom: 0; font-size: .7rem; color: var(--muted); font-family: var(--mono); }
.g-min { left: 0; }
.g-max { right: 0; }
.ch-test { color: var(--ink-soft); font-size: .95rem; }
.gauge-note { color: var(--muted); font-size: .85rem; margin-top: .7rem; }
.ip-verdict { font-size: 1.02rem; margin-top: .7rem; }

/* ---- compare ---- */
.compare { margin-top: 1.2rem; }
.compare-panel { margin-top: .8rem; border-top: 1px solid var(--rule); padding-top: .9rem; }
.compare-panel input[type="text"] { margin-bottom: .4rem; }
.cmp {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 10px;
  padding: .9rem 1rem; margin-top: .6rem;
}
.cmp p { margin: 0 0 .45rem; }
.cmp p:last-child { margin-bottom: 0; }
.cmp-vs { font: 700 1.1rem/1.3 var(--mono); letter-spacing: -.01em; }
.cmp-vs span { color: var(--muted); }
.cmp-row { color: var(--ink-soft); padding-left: .65rem; border-left: 3px solid var(--muted); }
.cmp-row.solids { border-left-color: var(--dust); }
.cmp-row.water { border-left-color: var(--water); }
.cmp-row b { color: var(--ink); }
.cmp-overall { font-weight: 700; }

/* ---- devices figure ---- */
.pkg { fill: var(--card); stroke: var(--ink); stroke-width: 3; }
.pkgl { stroke: var(--muted); stroke-width: 2; fill: none; }
.note.warn { border-color: var(--warn); }
.note.unknown { color: var(--muted); }
.empty-note { color: var(--muted); margin-top: 1.2rem; }

/* ---- anatomy figure ---- */
.figure { margin: 2.2rem 0 0; }
.figure svg { width: 100%; height: auto; display: block; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); }
.figure figcaption { color: var(--muted); font-size: .92rem; margin-top: .6rem; max-width: 44rem; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 1.4rem 0; border: 1px solid var(--rule); border-radius: var(--radius); }
table.spec { width: 100%; border-collapse: collapse; font-size: .98rem; min-width: 34rem; }
table.spec caption { text-align: left; font-weight: 800; font-size: 1.05rem; padding: .9rem 1.1rem .4rem; }
table.spec th, table.spec td { text-align: left; padding: .6rem 1.1rem; border-top: 1px solid var(--rule); vertical-align: top; }
table.spec thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-top: 0; }
table.spec td.n, table.spec th.n { font-family: var(--mono); white-space: nowrap; }
table.spec.solids td.n { color: var(--dust); font-weight: 700; }
table.spec.water td.n { color: var(--water); font-weight: 700; }

/* ---- faq ---- */
.faq { display: grid; gap: .7rem; margin-top: 1.4rem; }
.faq details { border: 1px solid var(--rule); border-radius: 12px; background: var(--card); padding: 0 1.1rem; }
.faq summary { cursor: pointer; font-weight: 700; font-size: 1.08rem; padding: 1rem 0; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; color: var(--accent); font-family: var(--mono); margin-right: .6rem; }
.faq details[open] summary::before { content: "–"; }
.faq details p { margin: 0 0 1.1rem; color: var(--ink-soft); max-width: 44rem; }
.faq details p:last-child { margin-bottom: 1.2rem; }

/* ---- sources + footer ---- */
.method { color: var(--ink-soft); max-width: 44rem; }
.method li { margin-bottom: .5rem; }
footer.site { border-top: 1px solid var(--rule); margin-top: 3rem; padding: 2rem 0 3rem; color: var(--muted); font-size: .92rem; }
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; align-items: baseline; justify-content: space-between; }
footer.site a { color: inherit; }
footer.site a:hover { color: var(--accent); }

/* ---- 404 ---- */
.nf { padding: 5rem 0; text-align: left; }
.nf h1 { font-size: clamp(2.5rem, 7vw, 4rem); margin: 0 0 1rem; }

/* ---- responsive ---- */
@media (max-width: 40rem) {
  .chambers { grid-template-columns: 1fr; }
}
@media (max-width: 30rem) {
  .anatomy { flex-direction: column; }
  body { font-size: 1rem; }
  .topbar { gap: .7rem; padding: 0 .8rem; font-size: .86rem; }
  .topnav a + a { display: none; }
  .decoder input[type="text"] { font-size: 1rem; }
  section.block { padding: 2.2rem 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
