/* PredictiveMaintenance.app — site styles
   Layout concept: an engineer's notebook on steel. Cool steel neutrals, a single
   safety-amber accent for "attention", teal for links and data, a faint
   measurement grid behind heroes. Archivo (expanded) for display, IBM Plex for
   reading and data. */

:root {
  --bg: #EDF0F2;
  --surface: #FFFFFF;
  --surface-2: #E3E8EB;
  --ink: #14212B;
  --ink-2: #4A5A66;
  --ink-3: #6E7E8A;
  --line: #CBD3D9;
  --line-2: #DDE3E7;
  --accent: #E08A12;          /* safety amber */
  --accent-strong: #A65A00;   /* amber readable as text on light */
  --accent-soft: #FBEBD3;
  --on-accent: #1B1206;
  --link: #0D6880;            /* steel teal */
  --link-soft: #DCEEF3;
  --good: #2E7D4F; --good-soft: #E1F1E7;
  --warn: #A86E00; --warn-soft: #FBF0D6;
  --bad: #B83A2B;  --bad-soft: #F8E2DE;
  --grid: rgba(20, 33, 43, .055);
  --shadow: 0 1px 2px rgba(20,33,43,.06), 0 8px 24px rgba(20,33,43,.06);
  --c1: #0D6880; --c2: #E08A12; --c3: #7A5BC7; --c4: #2E7D4F; --c5: #B83A2B; --c6: #5C6B77;

  --f-display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: .875rem; --step-0: 1rem; --step-1: 1.2rem; --step-2: 1.5rem; --step-3: 2rem; --step-4: 2.75rem; --step-5: 3.5rem;
  --r: 6px; --r-lg: 10px;
  --wrap: 1180px; --measure: 68ch;
  --gutter: clamp(16px, 4vw, 40px);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E151B; --surface: #151F27; --surface-2: #1B2731; --ink: #E4EBF0; --ink-2: #A0B0BC; --ink-3: #7B8C99;
  --line: #2B3A47; --line-2: #22303B; --accent: #F2A33A; --accent-strong: #F6B65E; --accent-soft: #3A2A12; --on-accent: #1B1206;
  --link: #62C4DB; --link-soft: #12323B; --good: #5EC48A; --good-soft: #14301F; --warn: #E7B547; --warn-soft: #33290F; --bad: #F07A66; --bad-soft: #3A1C16;
  --grid: rgba(228, 235, 240, .05); --shadow: none;
  --c1: #62C4DB; --c2: #F2A33A; --c3: #A98BFF; --c4: #5EC48A; --c5: #F07A66; --c6: #8C9DAA; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0E151B; --surface: #151F27; --surface-2: #1B2731; --ink: #E4EBF0; --ink-2: #A0B0BC; --ink-3: #7B8C99;
  --line: #2B3A47; --line-2: #22303B; --accent: #F2A33A; --accent-strong: #F6B65E; --accent-soft: #3A2A12; --on-accent: #1B1206;
  --link: #62C4DB; --link-soft: #12323B; --good: #5EC48A; --good-soft: #14301F; --warn: #E7B547; --warn-soft: #33290F; --bad: #F07A66; --bad-soft: #3A1C16;
  --grid: rgba(228, 235, 240, .05); --shadow: none;
  --c1: #62C4DB; --c2: #F2A33A; --c3: #A98BFF; --c4: #5EC48A; --c5: #F07A66; --c6: #8C9DAA; color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.65 var(--f-body); }
img, svg, canvas { max-width: 100%; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-family: var(--f-display); font-stretch: 112%; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.6vw, var(--step-5)); font-weight: 800; }
h2 { font-size: clamp(1.45rem, 2.6vw, var(--step-3)); font-weight: 700; }
h3 { font-size: var(--step-1); font-weight: 650; }
p { margin: 0; }
code, kbd, .mono { font-family: var(--f-mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.stack > * + * { margin-top: 1rem; }
.section { padding-block: clamp(40px, 6vw, 80px); }
.section + .section { border-top: 1px solid var(--line-2); }
.eyebrow { font: 600 .78rem/1.2 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent-strong); }
.lede { font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: var(--ink-2); max-width: 60ch; }
.muted { color: var(--ink-2); }
.small { font-size: var(--step--1); }
.grid-bg { background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; }

/* ---------- header ---------- */
.site-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 700 1.05rem/1 var(--f-display); font-stretch: 110%; white-space: nowrap; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { color: var(--accent-strong); font-weight: 800; }
.site-nav { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem; padding: 8px 11px; border-radius: var(--r); }
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 18px; height: 18px; }
.nav-toggle { display: none; }
@media (max-width: 1140px) {
  .nav-toggle { display: inline-grid; margin-left: auto; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px var(--gutter) 16px; margin: 0; }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 8px; border-bottom: 1px solid var(--line-2); border-radius: 0; }
  .site-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--accent); padding-left: 14px; }
}

/* ---------- buttons, chips ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .95rem/1 var(--f-body); text-decoration: none; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font: 500 .78rem/1.4 var(--f-mono); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.amber { background: var(--accent-soft); color: var(--accent-strong); }
.chip.teal { background: var(--link-soft); color: var(--link); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- hero ---------- */
.hero { padding-block: clamp(36px, 6vw, 72px) clamp(32px, 5vw, 56px); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.hero h1 { margin-block: 14px 18px; }
.hero h1 em { font-style: normal; color: var(--accent-strong); }
.hero .btn-row { margin-top: 28px; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.page-hero { padding-block: clamp(32px, 5vw, 60px) clamp(24px, 4vw, 40px); border-bottom: 1px solid var(--line); }
.page-hero h1 { margin-block: 10px 14px; font-size: clamp(1.9rem, 4vw, 3rem); }
.crumbs { font: 500 .82rem/1.4 var(--f-mono); color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--link); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* instrument panel (hero live demo) */
.instrument { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.instrument-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); font: 500 .78rem/1.3 var(--f-mono); color: var(--ink-3); }
.instrument-head .live { display: inline-flex; align-items: center; gap: 6px; color: var(--good); }
.instrument-head .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.instrument canvas { display: block; width: 100%; }
.readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line-2); }
.readouts > div { padding: 10px 14px; border-right: 1px solid var(--line-2); min-width: 0; }
.readouts > div:last-child { border-right: 0; }
.readouts .l { font: 500 .7rem/1.3 var(--f-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.readouts .v { font: 600 1.25rem/1.3 var(--f-mono); font-variant-numeric: tabular-nums; }
.readouts .v small { font-size: .72rem; color: var(--ink-3); font-weight: 400; margin-left: 3px; }

/* ---------- journey strip ---------- */
.journey { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.journey a { position: relative; display: block; padding: 18px 16px 18px; text-decoration: none; color: var(--ink); border-right: 1px solid var(--line-2); min-width: 0; transition: background .15s; }
.journey a:last-child { border-right: 0; }
.journey a:hover { background: var(--surface-2); }
.journey .n { font: 600 .72rem/1 var(--f-mono); color: var(--accent-strong); }
.journey h3 { font-size: 1.02rem; margin: 8px 0 6px; }
.journey p { font-size: .86rem; color: var(--ink-2); line-height: 1.45; }
.journey a::after { content: ""; position: absolute; right: -7px; top: 50%; width: 12px; height: 12px; transform: translateY(-50%) rotate(45deg); background: inherit; border-top: 1px solid var(--line-2); border-right: 1px solid var(--line-2); z-index: 1; }
.journey a:last-child::after { display: none; }
@media (max-width: 980px) { .journey { grid-template-columns: repeat(3, minmax(0, 1fr)); } .journey a:nth-child(3) { border-right: 0; } .journey a:nth-child(-n+3) { border-bottom: 1px solid var(--line-2); } .journey a::after { display: none; } }
@media (max-width: 560px) { .journey { grid-template-columns: 1fr 1fr; } .journey a { border-bottom: 1px solid var(--line-2); } .journey a:nth-child(odd) { border-right: 1px solid var(--line-2); } .journey a:nth-child(even) { border-right: 0; } }

/* ---------- cards ---------- */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .cards.three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .cards.three { grid-template-columns: 1fr; } }
.card { display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink); text-decoration: none; min-width: 0; }
a.card { transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--ink-3); transform: translateY(-2px); }
.card h3 { font-size: 1.08rem; }
.card p { color: var(--ink-2); font-size: .94rem; line-height: 1.55; }
.card .foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 6px; }
.card .thumb { margin: -20px -20px 4px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); aspect-ratio: 16/7; display: block; overflow: hidden; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.card .thumb svg { width: 100%; height: 100%; display: block; }
.card .go { font-weight: 600; color: var(--link); font-size: .9rem; }
.card.soon { opacity: .9; }
.card.soon .thumb { filter: grayscale(.4); }
.sec-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.sec-head .stack { max-width: 62ch; }

/* paths */
.paths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .paths { grid-template-columns: 1fr; } }
.path { padding: 22px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.path h3 { margin-bottom: 4px; }
.path ol { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 8px; }
.path li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr; gap: 8px; font-size: .93rem; }
.path li::before { content: counter(s); font: 600 .75rem/22px var(--f-mono); text-align: center; height: 22px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); }

/* banner */
.banner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: clamp(22px, 4vw, 40px); border-radius: var(--r-lg); background: var(--ink); color: var(--bg); }
.banner h2 { color: var(--bg); }
.banner p { color: color-mix(in srgb, var(--bg) 78%, var(--ink)); margin-top: 8px; max-width: 60ch; }
.banner .eyebrow { color: var(--accent); }
@media (max-width: 760px) { .banner { grid-template-columns: 1fr; } }

/* ---------- doc layout (learn / vibe coding) ---------- */
.doc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); padding-block: 36px 72px; }
.toc { position: sticky; top: 88px; align-self: start; font-size: .88rem; max-height: calc(100vh - 110px); overflow: auto; }
.toc h4 { font: 600 .72rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 6px 0 6px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; line-height: 1.35; }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); border-left-color: var(--accent); font-weight: 500; }
.toc .side-links { margin-top: 24px; display: grid; gap: 6px; }
@media (max-width: 900px) { .doc { grid-template-columns: 1fr; } .toc { position: static; max-height: none; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; background: var(--surface); } .toc .side-links { display: none; } }
.prose { min-width: 0; }
.prose > * + * { margin-top: 1.05rem; }
.prose > h2 { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--line-2); }
.prose > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose > h3 { margin-top: 2rem; }
.prose p, .prose li { max-width: var(--measure); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .35rem; }
.prose strong { font-weight: 600; }
.prose .h2num { font: 600 .8rem/1 var(--f-mono); color: var(--accent-strong); display: block; margin-bottom: 8px; letter-spacing: .06em; }

/* callouts */
.box { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; background: var(--surface); max-width: 820px; }
.box > * + * { margin-top: .6rem; }
.box h4 { font: 600 .75rem/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; display: flex; align-items: center; gap: 8px; }
.box.baseline { background: var(--surface-2); border-style: dashed; }
.box.baseline h4 { color: var(--ink-2); }
.box.key { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.box.key h4 { color: var(--accent-strong); }
.box.try { border-color: color-mix(in srgb, var(--link) 45%, var(--line)); background: color-mix(in srgb, var(--link-soft) 55%, var(--surface)); display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.box.try h4 { color: var(--link); }
.box.try > div { min-width: 0; flex: 1 1 280px; }
.box.try > div > * + * { margin-top: .4rem; }
.box ul { padding-left: 1.2rem; margin: 0; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; max-width: 860px; background: var(--surface); }
.vs > div { padding: 16px 18px; min-width: 0; }
.vs > div + div { border-left: 1px solid var(--line); }
.vs h4 { font: 600 .75rem/1.2 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.vs .old h4 { color: var(--ink-3); } .vs .new h4 { color: var(--accent-strong); }
.vs ul { margin: 0; padding-left: 1.1rem; font-size: .94rem; }
.vs .old { background: var(--surface-2); }
@media (max-width: 640px) { .vs { grid-template-columns: 1fr; } .vs > div + div { border-left: 0; border-top: 1px solid var(--line); } }

/* figure / explainer */
.fig { margin: 1.6rem 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; max-width: 900px; }
.fig-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.fig-head b { font: 600 .9rem/1.3 var(--f-display); font-stretch: 108%; }
.fig-head .tag { font: 500 .72rem/1 var(--f-mono); color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.fig-body { padding: 14px 16px; }
.fig-body canvas, .fig-body svg { display: block; width: 100%; height: auto; }
.fig figcaption { padding: 12px 16px 14px; border-top: 1px solid var(--line-2); font-size: .88rem; color: var(--ink-2); line-height: 1.55; }
.fig figcaption b { color: var(--ink); font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); font-size: .86rem; }
.controls label { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.controls input[type=range] { width: 140px; accent-color: var(--accent); }
.controls output { font: 600 .82rem/1 var(--f-mono); color: var(--ink); min-width: 3.5ch; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 11px; font: 500 .82rem/1 var(--f-body); color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border-top: 1px solid var(--line-2); }
.stat-row > div { padding: 10px 16px; border-right: 1px solid var(--line-2); min-width: 0; }
.stat-row > div:last-child { border-right: 0; }
.stat-row .l { font: 500 .7rem/1.3 var(--f-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.stat-row .v { font: 600 1.05rem/1.4 var(--f-mono); font-variant-numeric: tabular-nums; }

/* svg diagram text */
.dg text { font-family: var(--f-body); fill: var(--ink); }
.dg .t-mono { font-family: var(--f-mono); }
.dg .t-muted { fill: var(--ink-2); }
.dg .t-accent { fill: var(--accent-strong); }
.dg .t-link { fill: var(--link); }
.dg .stroke-line { stroke: var(--line); }
.dg .stroke-ink { stroke: var(--ink-2); }
.dg .fill-surface { fill: var(--surface); }
.dg .fill-s2 { fill: var(--surface-2); }
.dg .flow { stroke-dasharray: 6 6; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -24; } }

/* tables */
.tbl-wrap { overflow-x: auto; max-width: 900px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font: 600 .74rem/1.3 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.n { font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; }

/* code */
pre.code { position: relative; margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; overflow-x: auto; font: 400 .85rem/1.6 var(--f-mono); color: var(--ink); max-width: 900px; white-space: pre-wrap; word-break: break-word; }
.code-block { position: relative; max-width: 900px; }
.code-block .copy { position: absolute; top: 8px; right: 8px; }
.code-block .label { display: block; font: 600 .72rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }

/* quiz */
.quiz { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); max-width: 820px; overflow: hidden; }
.quiz-q { padding: 18px 20px; border-bottom: 1px solid var(--line-2); }
.quiz-q:last-of-type { border-bottom: 0; }
.quiz-q p { font-weight: 600; margin-bottom: 10px; }
.quiz-q p span { font: 600 .78rem/1 var(--f-mono); color: var(--accent-strong); margin-right: 8px; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-opts button { text-align: left; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: var(--r); padding: 10px 14px; font: 400 .94rem/1.4 var(--f-body); cursor: pointer; }
.quiz-opts button:hover:not([disabled]) { border-color: var(--ink-3); }
.quiz-opts button.right { border-color: var(--good); background: var(--good-soft); }
.quiz-opts button.wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz-opts button[disabled] { cursor: default; }
.quiz-why { margin-top: 10px; font-size: .9rem; color: var(--ink-2); }
.quiz-score { padding: 12px 20px; background: var(--surface-2); font: 500 .85rem/1.4 var(--f-mono); color: var(--ink-2); }

/* prev/next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 3rem; max-width: 900px; }
.pager a { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--ink-3); }
.pager span { display: block; font: 500 .74rem/1 var(--f-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.pager b { font-family: var(--f-display); font-stretch: 108%; }
.pager .next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { grid-column: 1; } }

/* forms */
.form { display: grid; gap: 14px; max-width: 640px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 500; font-size: .92rem; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 400 1rem/1.4 var(--f-body); }
.field textarea { min-height: 130px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--link); outline: none; box-shadow: 0 0 0 3px var(--link-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.form-msg { font-size: .92rem; padding: 10px 14px; border-radius: var(--r); background: var(--good-soft); color: var(--good); }
.form-msg.err { background: var(--bad-soft); color: var(--bad); }

/* filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 24px; }
.filters .seg button { padding: 8px 12px; }
.filters input[type=search] { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: inherit; width: min(280px, 100%); }

/* checklist */
.check { display: grid; gap: 8px; max-width: 820px; padding: 0; list-style: none; }
.check li { max-width: none; }
.check label { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--good); }
.check label:has(input:checked) { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); background: color-mix(in srgb, var(--good-soft) 60%, var(--surface)); }
.check b { display: block; font-weight: 600; }
.check span { color: var(--ink-2); font-size: .92rem; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; max-width: 820px; }
.meter i { display: block; height: 100%; background: var(--good); width: 0; transition: width .3s; }

/* steps timeline */
.timeline { list-style: none; padding: 0; margin: 0; max-width: 860px; border-left: 2px solid var(--line); }
.timeline > li { position: relative; padding: 0 0 26px 26px; max-width: none; }
.timeline > li::before { content: attr(data-n); position: absolute; left: -15px; top: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); font: 600 .75rem/24px var(--f-mono); text-align: center; color: var(--accent-strong); }
.timeline h3 { font-size: 1.05rem; margin-bottom: 6px; }
.timeline p { color: var(--ink-2); }
.timeline .code-block { margin-top: 10px; }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding-block: 44px 28px; margin-top: 0; }
.foot-grid { display: grid; grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)); gap: 28px; }
.foot-grid h4 { font: 600 .74rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .92rem; }
.foot-grid a { color: var(--ink-2); text-decoration: none; }
.foot-grid a:hover { color: var(--link); }
.foot-grid p { color: var(--ink-2); font-size: .92rem; margin-top: 12px; max-width: 34ch; }
.foot-base { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line-2); font-size: .82rem; color: var(--ink-3); }
@media (max-width: 860px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-grid > div:first-child { grid-column: 1 / -1; } }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-size: .9rem; z-index: 80; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .site-header, .site-footer, .toc, .pager { display: none; } }

/* checkbox rows inside forms */
.field input[type=checkbox], .field input[type=radio] { width: auto; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; }
.checks-grid label { display: flex; gap: 8px; align-items: center; font-weight: 400; }

/* longer brand name: keep header buttons full size on phones */
.site-header .icon-btn { flex: none; }
.brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 440px) {
  .site-header .wrap { gap: 10px; }
  .brand { font-size: .94rem; font-stretch: 100%; gap: 8px; }
  .brand svg { width: 26px; height: 26px; }
}

/* ================= ML apps ================= */
.page-hero.compact { padding-block: 22px 20px; }
.page-hero.compact h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-block: 8px 8px; }
.page-hero.compact .lede { font-size: 1rem; }
.app { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; padding-block: 24px 48px; align-items: start; }
@media (max-width: 960px) { .app { grid-template-columns: 1fr; } }
.side { display: grid; gap: 14px; position: sticky; top: 80px; max-height: calc(100vh - 96px); overflow: auto; padding-right: 2px; }
@media (max-width: 960px) { .side { position: static; max-height: none; overflow: visible; } }
.main { display: grid; gap: 16px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel > .ph { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 14px; border-bottom: 1px solid var(--line-2); }
.panel > .ph b { font: 600 .92rem/1.3 var(--f-display); font-stretch: 106%; }
.panel > .ph .tag { font: 500 .7rem/1 var(--f-mono); color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.panel > .pb { padding: 12px 14px; }
.panel > .pb > * + * { margin-top: 10px; }
.panel canvas { display: block; width: 100%; }
.panel .note { font-size: .84rem; color: var(--ink-2); line-height: 1.5; }
.ctl { display: grid; gap: 6px; }
.ctl + .ctl { margin-top: 12px; }
.ctl > label, .ctl > .lbl { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .86rem; font-weight: 500; color: var(--ink); }
.ctl output { font: 600 .8rem/1 var(--f-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ctl input[type=range] { width: 100%; accent-color: var(--accent); }
.ctl select, .ctl input[type=number] { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 400 .9rem/1.2 var(--f-body); }
.ctl .hint { font-size: .78rem; color: var(--ink-3); line-height: 1.4; }
.ctl .seg { display: flex; flex-wrap: wrap; }
.ctl .seg button { flex: 1 1 auto; padding: 7px 8px; }
.checks { display: grid; gap: 5px; font-size: .86rem; }
.checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checks input { accent-color: var(--accent); width: 16px; height: 16px; }
.btn.block { width: 100%; justify-content: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.kpis > div { padding: 10px 14px; border-right: 1px solid var(--line-2); min-width: 0; }
.kpis > div:last-child { border-right: 0; }
.kpis .l { font: 500 .68rem/1.3 var(--f-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.kpis .v { font: 600 1.15rem/1.35 var(--f-mono); font-variant-numeric: tabular-nums; }
.kpis .s { font-size: .76rem; color: var(--ink-3); }
.cm-wrap { overflow-x: auto; }
table.cm { border-collapse: separate; border-spacing: 2px; font: 500 .8rem/1 var(--f-mono); font-variant-numeric: tabular-nums; }
table.cm th { font: 500 .72rem/1.2 var(--f-body); color: var(--ink-2); text-align: right; padding: 4px 6px; white-space: nowrap; }
table.cm thead th { text-align: center; vertical-align: bottom; max-width: 52px; white-space: normal; font-size: .66rem; padding: 3px 2px; }
table.cm .cm-corner { text-align: left; color: var(--ink-3); font-size: .66rem; }
table.cm td { width: 36px; min-width: 32px; height: 30px; text-align: center; border-radius: 4px; position: relative; color: var(--ink); background: var(--surface-2); }
table.cm td.diag { background: color-mix(in srgb, var(--good) calc(var(--a) * 100%), var(--surface-2)); }
table.cm td.off { background: color-mix(in srgb, var(--bad) calc(var(--a) * 100%), var(--surface-2)); }
table.cm td.n { background: transparent; color: var(--ink-2); width: auto; padding: 0 6px; }
.pbars { display: grid; gap: 6px; }
.pbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr minmax(44px, auto); gap: 10px; align-items: center; font-size: .84rem; }
.pbar .pl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar .pt { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.pbar .pt i { display: block; height: 100%; border-radius: 5px; }
.pbar .pv { white-space: nowrap; font: 500 .78rem/1 var(--f-mono); text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pbar.on .pl { font-weight: 700; }
.models { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.model-card .acc { font: 700 1.6rem/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.model-card .acc small { font-size: .78rem; color: var(--ink-3); font-weight: 500; margin-left: 6px; }
.model-card.baseline { background: var(--surface-2); border-style: dashed; }
.tbl-scroll { overflow-x: auto; }
.status { display: inline-flex; align-items: center; gap: 6px; font: 500 .78rem/1 var(--f-mono); color: var(--ink-3); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.status.ok::before { background: var(--good); } .status.run::before { background: var(--accent); animation: blink 1s infinite; } .status.err::before { background: var(--bad); }
.dropzone { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 12px; text-align: center; font-size: .84rem; color: var(--ink-2); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--link); color: var(--ink); }
.theory { padding-block: 8px 56px; }
.theory .prose { max-width: 860px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.img-grid canvas { width: 100%; aspect-ratio: 1; border-radius: 4px; image-rendering: pixelated; }
.img-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
.img-row + .img-row { margin-top: 8px; }
.img-row .nm { font-size: .84rem; font-weight: 600; }
@media (max-width: 520px) { .img-row { grid-template-columns: 1fr; } }
.chip.live { background: var(--good-soft); color: var(--good); }
table.t td.n { white-space: nowrap; }
table.cm { width: 100%; table-layout: fixed; }
table.cm col.lab { width: 82px; } table.cm col.rec { width: 42px; }
table.cm td { width: auto; min-width: 0; }
table.cm td.n { font-size: .72rem; padding: 0 2px; text-align: right; }
table.cm tbody th { font-size: .7rem; padding: 3px 4px; overflow: hidden; text-overflow: ellipsis; }
.models { align-items: start; }

/* donate */
.donate-btn { min-height: 38px; padding: 0 14px; font-size: .9rem; gap: 6px; flex: none; }
.donate-btn svg { width: 15px; height: 15px; }
@media (max-width: 440px) { .donate-btn { padding: 0 10px; } .donate-btn span { display: none; } }
.donate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 20px; align-items: start; }
.donate-card { gap: 14px; padding: 24px; }
.qr-box { width: min(240px, 100%); padding: 12px; background: #FFFFFF; border: 1px solid var(--line); border-radius: var(--r-lg); }
.pay-id { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.pay-id .l { font: 600 .72rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.pay-id .v { font-size: .98rem; color: var(--ink); overflow-wrap: anywhere; user-select: all; }

@media (max-width: 440px) {
  .site-header .wrap { gap: 8px; }
  .site-header .icon-btn { width: 36px; height: 36px; }
  .donate-btn { min-height: 36px; padding: 0 9px; }
}
@media (max-width: 400px) { .brand { font-size: .86rem; } .brand svg { width: 24px; height: 24px; } }
@media (max-width: 370px) { .brand { font-size: .8rem; gap: 6px; } .site-header .wrap { gap: 6px; } }

/* PdM Program Guide */
.steps-list { counter-reset: st; list-style: none; padding-left: 0; max-width: var(--measure); }
.steps-list > li { counter-increment: st; position: relative; padding: 2px 0 2px 46px; min-height: 34px; }
.steps-list > li + li { margin-top: .9rem; }
.steps-list > li::before { content: counter(st, decimal-leading-zero); position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); font: 700 .8rem/1 var(--f-mono); }
.diagram-flow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 22px; margin: 1.4rem 0; max-width: 900px; }
.diagram-flow > div { position: relative; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.diagram-flow > div b { font: 600 .88rem/1.25 var(--f-display); }
.diagram-flow > div span { font-size: .8rem; color: var(--ink-2); line-height: 1.4; }
.diagram-flow > div:not(:last-child)::after { content: "→"; position: absolute; right: -18px; top: 50%; transform: translateY(-50%); color: var(--accent-strong); font-weight: 700; }
@media (max-width: 760px) { .diagram-flow { grid-auto-flow: row; gap: 18px; } .diagram-flow > div:not(:last-child)::after { content: "↓"; right: auto; left: 18px; top: auto; bottom: -19px; transform: none; } }
table.t.center-cols td:not(:first-child), table.t.center-cols th:not(:first-child) { text-align: center; color: var(--accent-strong); font-weight: 700; }
.crit-grid { display: grid; gap: 10px; }
.crit-row { display: grid; grid-template-columns: minmax(150px, 230px) minmax(0, 1fr); gap: 12px; align-items: center; font-size: .9rem; }
.crit-row select { width: 100%; min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 400 .9rem/1.2 var(--f-body); }
@media (max-width: 560px) { .crit-row { grid-template-columns: 1fr; gap: 4px; } }
[data-crit-out] b { color: var(--ink); }

/* PdM Program Setup app */
.planner .asset-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; max-height: 340px; overflow: auto; }
.asset-item { width: 100%; display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 8px; text-align: left; padding: 7px 8px; border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--ink); cursor: pointer; font: inherit; }
.asset-item:hover { background: var(--surface-2); }
.asset-item.on { border-color: var(--accent); background: var(--accent-soft); }
.asset-item .tier { grid-row: span 2; align-self: center; }
.asset-item .nm { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-item .ty { font-size: .74rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tier { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 6px; font: 700 .76rem/1 var(--f-mono); }
.tier.tA { background: var(--bad-soft); color: var(--bad); }
.tier.tB { background: var(--accent-soft); color: var(--accent-strong); }
.tier.tC { background: var(--good-soft); color: var(--good); }
.btn-row.tight { gap: 8px; }
.btn-row.tight .btn { flex: 1 1 auto; justify-content: center; }
.editor-body fieldset { border: 0; border-top: 1px solid var(--line-2); padding: 12px 0 2px; margin: 0; min-width: 0; }
.editor-body fieldset:first-child { border-top: 0; padding-top: 0; }
.editor-body legend { font: 600 .72rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 0 8px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px 14px; margin-top: 8px; }
.editor-body .field label { font-size: .84rem; }
.editor-body .field input, .editor-body .field select { min-height: 38px; padding: 6px 10px; font-size: .9rem; }
.editor-body .field .hint, .field .hint { font-size: .76rem; color: var(--ink-3); line-height: 1.35; }
.editor-body .seg { display: flex; flex-wrap: wrap; margin-top: 8px; }
.editor-body .seg button { flex: 1 1 auto; padding: 8px 10px; }
.fm-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); margin-top: 8px; }
.planner h4.rh { font: 600 .72rem/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-top: 16px; }
.small-list { padding-left: 1.1rem; font-size: .86rem; color: var(--ink-2); line-height: 1.5; }
.small-list li + li { margin-top: 4px; }
.small-list b { color: var(--ink); }
.kpis.mini .v { font-size: .95rem; }
.fund { border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 12px; }
.fund + .fund { margin-top: 8px; }
.fund summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: .9rem; }
.fund[open] { padding-bottom: 12px; }
.fund > * + * { margin-top: 8px; }
.planner .panel table.t td, .planner .panel table.t th { padding: 8px 10px; font-size: .86rem; }
.planner .panel table.t th { font-size: .68rem; }
.planner .side { max-height: none; position: static; }
.ctl input[type=text] { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 400 .9rem/1.2 var(--f-body); }
.form-grid { align-items: start; }
.form-grid .field { align-content: start; }
.card > .chip { align-self: flex-start; }

/* account pages */
.auth-card { max-width: 460px; gap: 16px; padding: 24px; }
.auth-card .form { max-width: none; }
.auth-tabs { display: flex; margin-bottom: 16px; }
.auth-tabs button { flex: 1; padding: 10px; font-size: .92rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; text-decoration: underline; }
