/* Layout: sticky strip, then page content. Tool pages: dark instrument panel (live readout + one-cycle current trace),
   bench with inputs beside the analysis sheet, then explanatory prose. One column on phones. */
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/chakra-petch-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/chakra-petch-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #ECEEEA;
  --panel: #FAFAF8;
  --field: #FFFFFF;
  --ink: #16191C;
  --muted: #5A6067;
  --rule: #D2D5CE;
  --accent: #E3AE00;
  --accent-ink: #8C6600;
  --link: #1F5BC4;
  --focus: #2E6BD6;
  --c-tx: #E3AE00;
  --c-act: #2E6BD6;
  --c-sleep: #178A77;
  --c-base: #C9472F;
  --c-sd: #8576B3;
  --note-bg: #F6EBCB;
  --note-ink: #5E4100;
  --err-bg: #F7DDD6;
  --err-ink: #8A2414;
  --scope-bg: #16191C;
  --scope-edge: #16191C;
  --scope-ink: #ECEEE8;
  --scope-dim: #8E969E;
  --scope-grid: #2A3036;
  --scope-trace: #F4C21E;
  --font-display: "Chakra Petch", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215; --panel: #171A1E; --field: #1D2126; --ink: #E5E7EA; --muted: #99A0A8; --rule: #2A2F35;
    --accent: #F4C21E; --accent-ink: #F4C21E; --link: #8DB2F7; --focus: #6E9BF2;
    --c-tx: #F4C21E; --c-act: #5C8FEF; --c-sleep: #2DB8A0; --c-base: #E86E58; --c-sd: #A898D8;
    --note-bg: #33290F; --note-ink: #F1D27E; --err-bg: #3A1A14; --err-ink: #F2A898;
    --scope-bg: #0A0C0E; --scope-edge: #262B31; --scope-grid: #23292F;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--link); text-underline-offset: 2px; }
.gut { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.skip { position: absolute; left: 12px; top: -48px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: var(--r); z-index: 50; }
.skip:focus { top: 8px; }
a:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* strip */
.bar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--rule); }
.bar-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 14px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .01em; white-space: nowrap; color: var(--ink); text-decoration: none; }
.cell { width: 24px; height: 13px; border: 2px solid var(--ink); border-radius: 3px; position: relative; padding: 1px; flex: none; }
.cell::before { content: ""; display: block; height: 100%; width: 60%; background: var(--accent); border-radius: 1px; }
.cell::after { content: ""; position: absolute; right: -5px; top: 2.5px; width: 3px; height: 4px; background: var(--ink); border-radius: 0 1px 1px 0; }
.bar-readout { margin-left: auto; font-family: var(--font-mono); font-size: 13px; color: var(--muted); opacity: 0; transition: opacity .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-variant-numeric: tabular-nums; }
.bar-readout.on { opacity: 1; }
.bar-readout b { color: var(--ink); font-weight: 500; }
.lang { display: flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; flex: none; margin-left: auto; }
.bar-readout + .lang { margin-left: 0; }
.lang a, .lang span { font: 500 12px/1 var(--font-mono); letter-spacing: .06em; padding: 8px 10px; color: var(--muted); text-decoration: none; }
.lang span[aria-current] { background: var(--ink); color: var(--bg); }
.lang a:hover { color: var(--ink); }

main { max-width: 1180px; margin: 0 auto; padding-block: 0 56px; display: block; }

/* intro */
.intro { padding-block: 28px 20px; max-width: 780px; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 4.4vw, 42px); line-height: 1.08; letter-spacing: -.005em; margin: 0 0 10px; text-wrap: balance; }
.lede { margin: 0; color: var(--muted); font-size: 16px; max-width: 64ch; }

/* instrument panel */
.scope { background: var(--scope-bg); color: var(--scope-ink); border: 1px solid var(--scope-edge); border-radius: 12px; padding: 22px clamp(16px, 2.5vw, 28px) 16px; display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.6fr); gap: 22px 34px; }
@media (max-width: 860px) { .scope { grid-template-columns: minmax(0, 1fr); } }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.scope .eyebrow { color: var(--scope-dim); }
.readout { min-width: 0; display: flex; flex-direction: column; }
.big { font-family: var(--font-display); font-weight: 700; font-size: clamp(54px, 8vw, 82px); line-height: .95; margin: 12px 0 8px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--scope-trace); }
.big .u { font-size: .4em; color: var(--scope-ink); margin-left: .2em; letter-spacing: 0; }
.sub { font-family: var(--font-mono); font-size: 13px; color: var(--scope-dim); min-height: 1.5em; }
.readout .sub { margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--scope-grid); }
.stats > div { display: flex; flex-direction: column; min-width: 0; }
.stats dt { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--scope-dim); line-height: 1.3; }
.stats dd { margin: auto 0 0; padding-top: 5px; font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.trace { margin: 0; min-width: 0; }
.svgbox { width: 100%; margin-top: 6px; min-height: 200px; }
.svgbox svg { display: block; width: 100%; overflow: visible; }

/* bench */
.bench { display: grid; grid-template-columns: minmax(0, 390px) minmax(0, 1fr); gap: 28px 36px; margin-top: 30px; align-items: start; }
@media (max-width: 900px) { .bench { grid-template-columns: minmax(0, 1fr); } }
fieldset { border: 0; border-top: 1px solid var(--rule); margin: 0 0 26px; padding: 0; min-width: 0; }
legend { font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; padding: 0 10px 0 0; }
.fs { display: grid; gap: 15px; padding-top: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.lbl { font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.sw { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.tx { background: var(--c-tx); } .act { background: var(--c-act); } .sleep { background: var(--c-sleep); } .base { background: var(--c-base); } .sd { background: var(--c-sd); }
.inp { display: flex; align-items: stretch; background: var(--field); border: 1px solid var(--rule); border-radius: var(--r); min-width: 0; }
.inp:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.inp input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); font: 400 15px/1.2 var(--font-mono); padding: 10px; font-variant-numeric: tabular-nums; outline: none; }
.inp .unit { font: 400 12.5px/1 var(--font-mono); color: var(--muted); padding: 0 10px 0 4px; display: flex; align-items: center; white-space: nowrap; }
.inp select { border: 0; border-left: 1px solid var(--rule); background: transparent; color: var(--ink); font: 400 13px var(--font-mono); padding: 0 8px; outline: none; cursor: pointer; }
select.sel { width: 100%; max-width: 100%; background: var(--field); border: 1px solid var(--rule); border-radius: var(--r); color: var(--ink); font: 400 14px/1.3 var(--font-body); padding: 9px 10px; cursor: pointer; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.mini { font: 400 11px/1.2 var(--font-mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* analysis sheet */
.sheet { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 4px clamp(16px, 2.4vw, 26px); min-width: 0; }
.sheet > section { padding-block: 20px; border-top: 1px solid var(--rule); }
.sheet > section:first-child { border-top: 0; }
.sheet h2 { font-family: var(--font-display); font-weight: 600; font-size: 19px; line-height: 1.2; margin: 0 0 14px; text-wrap: balance; }
.stack { display: flex; gap: 2px; height: 14px; border-radius: 3px; overflow: hidden; }
.stack span { display: block; height: 100%; min-width: 2px; }
.legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; }
.legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 3.4em; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--rule); font-size: 14px; }
.legend li:last-child { border-bottom: 0; }
.legend .v, .legend .p { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.legend .v { color: var(--muted); }
.legend .p { font-weight: 500; }
.notes { display: grid; gap: 10px; }
.notes:not(:empty) { margin-bottom: 16px; }
.note { background: var(--note-bg); color: var(--note-ink); padding: 10px 12px; border-radius: var(--r); font-size: 14px; }
.note.err { background: var(--err-bg); color: var(--err-ink); }
.tips { display: grid; gap: 16px; }
.tip h3 { margin: 0 0 5px; font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.tip p { margin: 0; max-width: 68ch; }
.cap { margin: 10px 0 0; font-size: 13px; color: var(--muted); max-width: 70ch; }
.dbl { margin: 12px 0 0; font-size: 14.5px; max-width: 70ch; }
.dbl b { font-weight: 600; }
.copyrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.btn { font: 500 14px/1 var(--font-body); background: var(--ink); color: var(--panel); border: 0; border-radius: var(--r); padding: 11px 15px; cursor: pointer; }
.btn:hover { opacity: .9; }
.status { font-size: 13px; color: var(--muted); }
#fallback { display: block; width: 100%; margin-top: 12px; font: 12.5px/1.45 var(--font-mono); background: var(--field); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px; min-height: 150px; resize: vertical; }
.method { font-size: 13px; color: var(--muted); margin: 14px 0 0; max-width: 72ch; }

/* svg */
.g-grid { stroke: var(--scope-grid); stroke-width: 1; }
.g-axis { stroke: var(--scope-dim); stroke-width: 1; opacity: .5; }
.g-lab { fill: var(--scope-dim); font: 400 10.5px var(--font-mono); }
.g-val { fill: var(--scope-ink); font: 500 11.5px var(--font-mono); }
.g-trace { fill: none; stroke: var(--scope-trace); stroke-width: 2; stroke-linejoin: round; }
.g-area { fill: var(--scope-trace); fill-opacity: .13; }
.g-gap { fill: var(--scope-bg); }
.g-break { stroke: var(--scope-dim); stroke-width: 1.5; fill: none; }
.ph-sleep { fill: var(--c-sleep); } .ph-act { fill: var(--c-act); } .ph-tx { fill: var(--c-tx); }
.c-grid { stroke: var(--rule); stroke-width: 1; }
.c-lab { fill: var(--muted); font: 400 10.5px var(--font-mono); }
.c-line { fill: none; stroke: var(--accent-ink); stroke-width: 2.25; stroke-linejoin: round; }
.c-area { fill: var(--accent); fill-opacity: .12; }
.c-asym { stroke: var(--muted); stroke-width: 1.25; stroke-dasharray: 5 4; }
.c-drop { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; opacity: .5; }
.c-dot { fill: var(--panel); stroke: var(--ink); stroke-width: 2; }
.c-now { fill: var(--ink); font: 500 12px var(--font-mono); }
.c-ann { fill: var(--muted); font: 400 11px var(--font-mono); }

/* prose under the tool, privacy page */
.prose { max-width: 760px; margin-top: 48px; }
.prose h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 3vw, 27px); line-height: 1.15; margin: 40px 0 12px; text-wrap: balance; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 17px; font-weight: 600; margin: 24px 0 6px; line-height: 1.3; }
.prose p, .prose li { font-size: 16px; line-height: 1.65; max-width: 68ch; }
.prose p { margin: 0 0 14px; }
.prose code { font-family: var(--font-mono); font-size: .92em; }
.formula { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px 16px; overflow-x: auto; white-space: pre; margin: 0 0 16px; }
.tbl { overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); }
.tbl table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.tbl th, .tbl td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { font: 500 11px/1.3 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.tbl td.n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tblcap { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.faq h3 { margin-top: 26px; }
.updated { font-size: 13px; color: var(--muted); }

/* home */
.home-hero { padding-block: 44px 28px; max-width: 820px; }
.home-hero h1 { font-size: clamp(32px, 5.4vw, 54px); }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 18px; }
.card { display: grid; grid-template-rows: auto 1fr; background: var(--scope-bg); color: var(--scope-ink); border: 1px solid var(--scope-edge); border-radius: 12px; text-decoration: none; overflow: hidden; }
.card:hover .card-cta { text-decoration: underline; }
.card svg { display: block; width: 100%; height: 96px; }
.card-body { padding: 4px 20px 20px; display: grid; gap: 6px; align-content: start; }
.card .eyebrow { color: var(--scope-dim); }
.card h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 24px; color: var(--scope-trace); }
.card p { margin: 0; color: var(--scope-ink); }
.card-cta { margin-top: 8px; font-weight: 500; color: var(--scope-ink); }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 22px 30px; margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--rule); }
.why h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.why p { margin: 0; color: var(--muted); }

/* footer */
.foot { border-top: 1px solid var(--rule); }
.foot-in { max-width: 1180px; margin: 0 auto; padding-block: 22px 32px; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: baseline; font-size: 13px; color: var(--muted); }
.foot-in p { margin: 0; flex: 1 1 320px; max-width: 72ch; }
.foot-in nav { display: flex; gap: 16px; flex-wrap: wrap; }
.foot-in a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .bar-readout { transition: none; } }
