:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #eae7de;
  --surface-3: #181a1f;
  --ink: #141619;
  --muted: #525866;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-ink: #ffffff;
  --link: #b13a0a;
  --rule: rgba(20, 22, 25, 0.14);
  --rule-strong: rgba(20, 22, 25, 0.28);
  --ok-bg: #e6f1e8;
  --ok-ink: #18452a;
  --warn-bg: #fbeee2;
  --warn-ink: #7a2e0b;
  --bad-bg: #f8e3e1;
  --bad-ink: #7f1d1d;
  --seg-w: #181a1f;
  --seg-kv: #c2410c;
  --seg-x: #8a8f99;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --step-small: clamp(0.86rem, 0.84rem + 0.1vw, 0.92rem);
  --step-body: clamp(1rem, 0.98rem + 0.16vw, 1.08rem);
  --step-lead: clamp(1.12rem, 1.06rem + 0.22vw, 1.22rem);
  --step-h2: clamp(1.4rem, 1.18rem + 1vw, 1.95rem);
  --step-head: clamp(1.9rem, 1.35rem + 2.1vw, 2.85rem);
  --gap: 8px;
  --max-w: 1360px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 16px; line-height: 1.55; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: var(--step-body); overflow-x: clip; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--link); text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1.5px; }
a:hover { color: var(--accent-hover); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0 0 0.5em; font-family: var(--font-sans); font-weight: 600; color: inherit; text-align: left; }
h1 { font-size: var(--step-head); line-height: 1.04; letter-spacing: -0.025em; }
h2 { font-size: var(--step-h2); line-height: 1.12; letter-spacing: -0.015em; }
h3 { font-size: var(--step-lead); line-height: 1.25; }
p, ul, ol, dl, table, pre { margin: 0 0 0.95rem; }
p, li { max-width: 66ch; overflow-wrap: anywhere; }
p:last-child, ul:last-child, ol:last-child { margin-bottom: 0; }
strong, td, th, dd, .stat-pill strong, .ui-kpi strong { font-variant-numeric: tabular-nums; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.88em; }
p code, li code, td code, dd code, summary code { background: var(--surface-2); color: var(--ink); padding: 0.08em 0.34em; }
pre { max-width: 100%; background: var(--surface-3); color: #e9e6dc; padding: 0.95rem 1.1rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: var(--step-small); font-variant-numeric: tabular-nums; }

.board-shell { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 14px 20px; }
.top-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: stretch; gap: var(--gap); margin-bottom: var(--gap); }
.brand-tile { background: var(--surface-3); color: #ffffff; padding: 10px 16px; min-height: 46px; display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--step-body); text-decoration: none; }
.brand-mark { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 600; border: 1.5px solid var(--accent); color: #ffd9c4; padding: 2px 5px; letter-spacing: 0.04em; }
.brand-tile:hover { background: #000000; color: #ffffff; }
.nav-tile { background: var(--surface); border: 1px solid var(--rule); padding: 8px 18px; min-height: 46px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.nav-tile a { color: var(--ink); text-decoration: none; font-size: var(--step-small); font-weight: 500; }
.nav-tile a:hover, .nav-tile a[aria-current="page"] { color: var(--accent); text-decoration: underline; }
.cta-tile { background: var(--accent); color: #ffffff; padding: 12px 20px; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--step-small); text-decoration: none; }
.cta-tile:hover { background: var(--accent-hover); color: #ffffff; }

.board-section { margin-top: clamp(40px, 4.5vw, 68px); }
.board-section--first { margin-top: 0; }
.tile-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.tile { background: var(--surface); color: var(--ink); padding: 24px; border: 1px solid var(--rule); display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.tile--top { justify-content: flex-start; }
.tile-elev { background: var(--surface-2); }
.tile-dark { background: var(--surface-3); color: #eeebe2; border-color: var(--surface-3); }
.tile-dark h2 { color: #ffffff; }
.tile-dark p { color: #d2cfc6; }
.tile-photo { padding: 0; position: relative; overflow: hidden; min-height: 240px; justify-content: flex-start; }
.tile-photo img { width: 100%; flex: 1 1 auto; height: 0; min-height: 240px; object-fit: cover; display: block; }
.photo-strip { background: var(--surface-3); color: #ffffff; padding: 8px 14px; font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.35; }
.prose h2 { margin-top: 0; }
.prose p + h2 { margin-top: 1.4rem; }

.c-12 { grid-column: span 12; }
.c-8  { grid-column: span 8; }
.c-7  { grid-column: span 7; }
.c-6  { grid-column: span 6; }
.c-5  { grid-column: span 5; }
.c-4  { grid-column: span 4; }
.c-3  { grid-column: span 3; }
.c-2  { grid-column: span 2; }

.eyebrow { font-family: var(--font-mono); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 10px; }
.hero-lead { font-size: var(--step-lead); line-height: 1.5; color: var(--ink); margin: 0.4rem 0 0.8rem; max-width: 66ch; }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.btn-primary { background: var(--accent); color: #ffffff; padding: 11px 20px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--step-small); text-decoration: none; border: 0; cursor: pointer; font-family: var(--font-sans); }
.btn-primary:hover { background: var(--accent-hover); color: #ffffff; }
.btn-ghost { background: var(--surface); color: var(--ink); padding: 11px 16px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-weight: 500; font-size: var(--step-small); text-decoration: none; border: 1px solid var(--rule-strong); cursor: pointer; font-family: var(--font-sans); }
.btn-ghost:hover { background: var(--surface-3); color: #ffffff; }
.btn-mini { background: var(--accent); color: #ffffff; border: 0; padding: 5px 12px; font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; cursor: pointer; min-height: 30px; }
.btn-mini:hover { background: var(--accent-hover); }
.stat-note { font-size: var(--step-small); color: var(--muted); margin: 0.4rem 0 0; }
.tile-dark .stat-note { color: #b8b5ac; }
.stat-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 14px; }
.stat-pill { background: var(--surface-2); padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; border-left: 3px solid var(--accent); }
.stat-pill span { font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-pill strong { font-size: 1rem; font-weight: 600; font-family: var(--font-mono); }

.spec-list { margin: 0 0 1rem; display: grid; gap: 0; }
.spec-list div { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 12px; padding: 7px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.18); }
.spec-list dt { font-family: var(--font-mono); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: #b8b5ac; }
.spec-list dd { margin: 0; font-family: var(--font-mono); font-size: 0.9rem; color: #ffffff; }

/* Interactive tools */
[data-ui].ui-split { display: grid; grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); background: var(--surface); border: 1px solid var(--rule-strong); margin-top: 6px; }
[data-ui] .ui-controls { padding: 18px; background: var(--surface-2); display: flex; flex-direction: column; gap: 12px; border-right: 1px solid var(--rule); }
[data-ui] .ui-output { padding: 18px 20px; background: var(--surface); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
[data-ui] .ctrl-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
[data-ui] .ctrl-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
[data-ui] .ctrl-field label, [data-ui] legend { font-size: var(--step-small); font-weight: 600; color: var(--ink); }
[data-ui] .ctrl-checks { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; }
[data-ui] .ctrl-checks label { display: flex; gap: 8px; align-items: center; font-size: var(--step-small); cursor: pointer; }
[data-ui] .ctrl-checks input { width: 17px; height: 17px; accent-color: var(--accent); }
[data-ui] .ctrl-hint { font-size: 0.82rem; color: var(--muted); margin: 0; max-width: none; }
[data-ui] select, [data-ui] input[type="number"], [data-ui] input[type="text"], [data-ui] textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; background: #ffffff; color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 0; font-family: var(--font-sans); font-size: var(--step-small); font-variant-numeric: tabular-nums;
}
[data-ui] input:disabled { background: #f1efe9; color: var(--muted); }
[data-ui] textarea { font-family: var(--font-mono); line-height: 1.45; resize: vertical; min-height: 70px; }
[data-ui] input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-ticks { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
[data-ui] .ui-kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
[data-ui] .ui-kpi { background: var(--surface-2); padding: 10px 12px; min-width: 0; }
[data-ui] .ui-kpi span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 3px; }
[data-ui] .ui-kpi strong { display: block; font-family: var(--font-mono); font-size: 1.22rem; font-weight: 600; overflow-wrap: anywhere; }
[data-ui] .ui-kpi--hl { background: var(--surface-3); color: #ffffff; }
[data-ui] .ui-kpi--hl span { color: #c9c6bd; }
[data-ui] .ui-verdict { background: var(--surface-2); padding: 12px 14px; border-left: 4px solid var(--accent); }
[data-ui] .ui-verdict.is-ok { background: var(--ok-bg); color: var(--ok-ink); border-left-color: #2f7d4a; }
[data-ui] .ui-verdict.is-warn { background: var(--warn-bg); color: var(--warn-ink); border-left-color: var(--accent); }
[data-ui] .ui-verdict.is-bad { background: var(--bad-bg); color: var(--bad-ink); border-left-color: #b91c1c; }
[data-ui] .ui-verdict strong { display: block; font-size: var(--step-body); margin-bottom: 3px; }
[data-ui] .ui-verdict p { font-size: var(--step-small); margin: 0; max-width: none; }
[data-ui] pre { margin: 0; }
.pre-tall { max-height: 360px; overflow-y: auto; }
.cmd-box { border: 1px solid var(--surface-3); }
.cmd-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #2a2d34; color: #ffffff; padding: 6px 10px; font-family: var(--font-mono); font-size: 0.78rem; }

.mem-stack { position: relative; display: flex; height: 26px; background: var(--surface-2); border: 1px solid var(--rule-strong); overflow: hidden; }
.mem-seg { height: 100%; transition: width 160ms ease-out; }
.seg-w { background: var(--seg-w); }
.seg-kv { background: var(--seg-kv); }
.seg-x { background: var(--seg-x); }
.mem-limit { position: absolute; top: -2px; bottom: -2px; width: 3px; background: #1f8a4c; left: 100%; }
.mem-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono); }
.mem-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.lg-w::before { background: var(--seg-w); }
.lg-kv::before { background: var(--seg-kv); }
.lg-x::before { background: var(--seg-x); }
.lg-l::before { background: #1f8a4c; width: 3px !important; }

.loop-diagram { background: var(--surface-2); padding: 12px; display: flex; flex-direction: column; gap: 5px; }
.loop-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: center; }
.loop-tag { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); text-transform: uppercase; }
.loop-cells { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.lc { height: 20px; background: #d8d4c8; font-family: var(--font-mono); font-size: 0.56rem; color: transparent; display: flex; align-items: center; justify-content: center; }
.lc.on { background: var(--surface-3); color: #ffffff; }
.lc.on.full { background: var(--accent); }
.loop-key { display: flex; gap: 14px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.loop-key span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.k-swa::before { background: var(--surface-3); }
.k-full::before { background: var(--accent); }

.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 64px; gap: 8px; align-items: center; font-size: var(--step-small); }
.bar-row .bar-name { font-weight: 500; overflow-wrap: anywhere; }
.bar-track { height: 18px; background: var(--surface-2); }
.bar-fill { height: 100%; background: var(--seg-x); transition: width 160ms ease-out; }
.bar-row.is-ink .bar-fill { background: var(--accent); }
.bar-val { font-family: var(--font-mono); text-align: right; }
.fit-yes { color: #1f6b3a; font-weight: 600; }
.fit-no { color: #9a1b1b; font-weight: 600; }

.next-row-title { font-size: var(--step-lead); font-weight: 600; margin-bottom: 10px; }
.next-card { text-decoration: none; gap: 8px; }
.next-card:hover { border-color: var(--accent); }
.next-q { font-weight: 600; color: var(--ink); font-size: 0.98rem; }
.next-a { font-size: var(--step-small); color: var(--muted); }
.next-go { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; color: var(--accent); margin-top: auto; }

.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); }
table { width: 100%; border-collapse: collapse; font-size: var(--step-small); font-variant-numeric: tabular-nums; margin: 0; }
th, td { text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--surface-2); vertical-align: top; }
th { background: var(--surface-3); color: #ffffff; font-weight: 600; font-size: 0.8rem; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.03em; }
td:not(:first-child) { font-family: var(--font-mono); font-size: 0.86rem; }

.spec-sources { border-top: 3px solid var(--surface-3); padding-top: 12px; }
.source-list { margin: 8px 0 0; padding-left: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 24px; font-size: var(--step-small); }

.faq-layout { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: var(--gap); align-items: start; }
.faq-sticky { position: sticky; top: 24px; padding-right: 12px; }
.faq-sticky p { color: var(--muted); margin-top: 8px; font-size: var(--step-small); }
.faq-stack { display: flex; flex-direction: column; gap: var(--gap); }
.faq-tile { background: var(--surface); color: var(--ink); border: 1px solid var(--rule); }
.faq-tile summary { list-style: none; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; font-weight: 600; cursor: pointer; }
.faq-tile summary::-webkit-details-marker { display: none; }
.faq-plus { width: 14px; height: 14px; position: relative; flex-shrink: 0; }
.faq-plus::before, .faq-plus::after { content: ""; position: absolute; background: currentColor; }
.faq-plus::before { top: 6px; left: 0; width: 14px; height: 2px; }
.faq-plus::after { top: 0; left: 6px; width: 2px; height: 14px; }
.faq-tile[open] { border-color: var(--surface-3); }
.faq-tile[open] summary { background: var(--surface-3); color: #ffffff; }
.faq-tile[open] .faq-plus::after { display: none; }
.faq-ans { padding: 14px 18px 16px; font-size: var(--step-small); line-height: 1.55; }

.ad-slot { margin: 12px 0; background: var(--surface); border: 1px solid var(--rule); padding: 6px 10px; overflow: hidden; }
.ad-leader, .ad-300 { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 68px; }
.ad-n, .ad-native { display: block; width: 100%; text-align: center; }
.ad-slot-label { display: block; font-size: 0.74rem; color: var(--muted); margin-bottom: 4px; font-family: var(--font-mono); }
.ad-slot-pending { display: none; }

.footer-board { margin-top: clamp(56px, 7vw, 100px); display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.footer-title { font-size: var(--step-lead); font-weight: 600; margin-bottom: 8px; }
.footer-head { margin-bottom: 10px; display: block; font-family: var(--font-mono); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.footer-board p { font-size: var(--step-small); }
.footer-wordmark { background: var(--surface-3); color: #ffffff; padding: 24px; display: flex; align-items: flex-end; min-height: 160px; }
.footer-wordmark span { font-family: var(--font-mono); font-size: clamp(1.6rem, 4vw, 3.4rem); font-weight: 600; line-height: 0.95; letter-spacing: -0.02em; }
.footer-cta-tile { background: var(--accent); color: #ffffff; padding: 22px; min-height: 160px; text-decoration: none; display: flex; flex-direction: column; justify-content: space-between; }
.footer-cta-tile:hover { background: var(--accent-hover); color: #ffffff; }
.footer-cta-tile strong { font-size: var(--step-lead); line-height: 1.22; }
.footer-cta-arrow { align-self: flex-end; }
.footer-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
.footer-list a { text-decoration: none; color: var(--ink); font-size: var(--step-small); }
.footer-list a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 980px) {
  .top-bar { grid-template-columns: 1fr auto; }
  .nav-tile { grid-column: 1 / -1; order: 3; }
  .c-3, .c-2 { grid-column: span 6; }
  .c-8, .c-7, .c-6, .c-5, .c-4 { grid-column: span 12; }
  [data-ui].ui-split, .faq-layout { grid-template-columns: 1fr; }
  [data-ui] .ui-controls { border-right: 0; border-bottom: 1px solid var(--rule); }
  .faq-sticky { position: static; }
}
@media (max-width: 680px) {
  .board-shell { padding: 10px 12px; }
  .tile { padding: 18px 16px; }
  .tile-grid, .footer-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c-12, .c-8, .c-7, .c-6, .c-5, .c-4, .c-3, .c-2 { grid-column: span 2; }
  [data-ui] .ctrl-row, [data-ui] .ui-kpi-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px minmax(0, 1fr) 56px; }
  .loop-row { grid-template-columns: 1fr; gap: 3px; }
  .board-section--first .tile-photo img { flex: none; height: 200px; min-height: 0; }
}
@media print {
  .top-bar, .ad-slot, .next-row, .footer-board { display: none !important; }
  body, .board-shell, .tile { background: #ffffff !important; }
}
