/* ==========================================================================
   base.css — the whole site's stylesheet.

   One file, served exactly as written: no build step, no framework. It is
   small enough that splitting it per page would cost more in requests than it
   saves in bytes.

   Sections
     1. Tokens          colours, radii, fonts, the two layout widths
     2. Reset           the handful of resets that are actually needed
     3. App frame       sidebar + top bar + main column
     4. Blocks          hero, section rhythm, buttons, chips
     5. Instrument      the measurement panel and its charts
     6. Widgets         comparison lanes, calculator, device card
     7. Content         article, tables, FAQ, related cards, CTA, footer
     8. Pages           legal, error pages
     9. Responsive
   ========================================================================== */

/* ============================================================
   1. Tokens
   ============================================================ */
:root {
    --bg: #F5F5FA;
    --bg-2: #ECEBF5;
    --surface: #FFF;
    --surface-2: #F4F3FB;
    --surface-3: #E9E7F6;
    --text: #131320;
    --text-2: #5A5975;
    --text-3: #8A88A5;
    --outline: #E3E1F0;
    --outline-2: #CECBE4;
    --primary: #5B4BFF;
    --primary-hover: #4636F2;
    --on-primary: #FFF;
    --primary-container: #E7E3FF;
    --on-primary-container: #1C1070;
    --good: #00A06B;
    --warn: #B87400;
    --bad: #D62A55;
    --shadow-1: 0 1px 2px rgba(20, 20, 45, .06), 0 1px 3px rgba(20, 20, 45, .05);
    --shadow-2: 0 4px 12px rgba(20, 20, 45, .06), 0 14px 34px rgba(20, 20, 45, .07);
    --shadow-3: 0 12px 28px rgba(20, 20, 45, .09), 0 34px 70px rgba(26, 22, 80, .10);
    --r-xs: 8px;
    --r-sm: 12px;
    --r-md: 18px;
    --r-lg: 26px;
    --r-xl: 32px;
    --r-full: 999px;
    --side-w: 266px;
    --top-h: 62px;
    --f-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --f-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --f-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

[data-theme="dark"] {
    --bg: #08080E;
    --bg-2: #0C0C15;
    --surface: #12121C;
    --surface-2: #181824;
    --surface-3: #212131;
    --text: #EDECF7;
    --text-2: #A5A3BE;
    --text-3: #7B7994;
    --outline: #262636;
    --outline-2: #333349;
    --primary: #9E92FF;
    --primary-hover: #B2A9FF;
    --on-primary: #150B50;
    --primary-container: #2A2176;
    --on-primary-container: #E4DFFF;
    --good: #2FDCA3;
    --warn: #FFC24D;
    --bad: #FF5F80;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 6px 18px rgba(0, 0, 0, .45);
    --shadow-3: 0 18px 46px rgba(0, 0, 0, .6);
}

/* The rail is the collapsed sidebar: icons only, no labels. */
[data-rail="1"] {
    --side-w: 78px;
}

/* ---- per-page accents ----
   Each tool carries its own accent so the pages are not eleven prints of the
   same layout. Set with 'accent' in config/tools.php, which lands on <body>.
   Only the primary ramp moves; --good, --warn and --bad keep their meaning
   everywhere, because the instrument uses them to say what is happening. */
.accent-azure { --primary: #0B72D0; --primary-hover: #0961B2; --primary-container: #D6E9FC; --on-primary-container: #06375F; }
.accent-amber { --primary: #B45309; --primary-hover: #96450A; --primary-container: #FCEBD2; --on-primary-container: #5A2A05; }
.accent-teal { --primary: #0D8B84; --primary-hover: #0B756F; --primary-container: #CFEEEB; --on-primary-container: #06423E; }
.accent-violet { --primary: #7C3AED; --primary-hover: #6A2BD9; --primary-container: #E9DDFD; --on-primary-container: #3A1078; }
.accent-rose { --primary: #D01F52; --primary-hover: #B01844; --primary-container: #FCDDE5; --on-primary-container: #6B0C28; }
.accent-fuchsia { --primary: #B026C4; --primary-hover: #951FA6; --primary-container: #F8DBFC; --on-primary-container: #5A0F66; }
.accent-cyan { --primary: #0E7C94; --primary-hover: #0B677D; --primary-container: #D0EDF4; --on-primary-container: #063946; }
.accent-emerald { --primary: #0A7C55; --primary-hover: #086847; --primary-container: #CDEEE0; --on-primary-container: #043826; }
.accent-orange { --primary: #C2410C; --primary-hover: #A5370A; --primary-container: #FCE1D2; --on-primary-container: #601F05; }

[data-theme="dark"] .accent-azure { --primary: #7CC0FF; --primary-hover: #9BD0FF; --on-primary: #062B4C; --primary-container: #12456F; --on-primary-container: #D7EBFF; }
[data-theme="dark"] .accent-amber { --primary: #FFC069; --primary-hover: #FFD08C; --on-primary: #3A1F02; --primary-container: #6B3D08; --on-primary-container: #FFE7C7; }
[data-theme="dark"] .accent-teal { --primary: #5BD6CD; --primary-hover: #83E2DB; --on-primary: #05322E; --primary-container: #0D5A54; --on-primary-container: #CBF3EF; }
[data-theme="dark"] .accent-violet { --primary: #B99DFF; --primary-hover: #CBB6FF; --on-primary: #260B60; --primary-container: #43229A; --on-primary-container: #E6DBFF; }
[data-theme="dark"] .accent-rose { --primary: #FF87A6; --primary-hover: #FFA5BC; --on-primary: #470A1D; --primary-container: #7C1435; --on-primary-container: #FFD9E2; }
[data-theme="dark"] .accent-fuchsia { --primary: #EC91F8; --primary-hover: #F3ADFB; --on-primary: #430B4C; --primary-container: #741781; --on-primary-container: #FBD9FE; }
[data-theme="dark"] .accent-cyan { --primary: #5FCDE4; --primary-hover: #88DBEC; --on-primary: #032F3A; --primary-container: #0A5567; --on-primary-container: #CCEFF7; }
[data-theme="dark"] .accent-emerald { --primary: #4FD8A1; --primary-hover: #7BE4BA; --on-primary: #02311F; --primary-container: #075739; --on-primary-container: #CBF3E1; }
[data-theme="dark"] .accent-orange { --primary: #FFA36B; --primary-hover: #FFBC92; --on-primary: #401403; --primary-container: #7A2E0A; --on-primary-container: #FFDCC7; }

/* ============================================================
   2. Reset
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--top-h) + 16px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--f-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--f-display);
    line-height: 1.13;
    letter-spacing: -.025em;
    margin: 0;
}

h2 {
    font-size: clamp(1.5rem, 3vw, 2.15rem);
    font-weight: 600;
}

h3 {
    font-size: 1.04rem;
    font-weight: 600;
}

p {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

canvas {
    display: block;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mono {
    font-family: var(--f-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}

:focus-visible {
    outline: 2.5px solid var(--primary);
    outline-offset: 3px;
    border-radius: 6px;
}

.skip {
    position: absolute;
    left: -999px;
    top: 8px;
    z-index: 200;
    background: var(--primary);
    color: var(--on-primary);
    padding: 10px 16px;
    border-radius: var(--r-full);
}

.skip:focus {
    left: 16px;
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ============================================================
   3. App frame
   ============================================================ */
.app {
    display: grid;
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    min-height: 100vh;
}

.wrap {
    width: 100%;
    max-width: 1120px;
    margin-inline: auto;
    padding-inline: 26px;
}

.wrap.narrow {
    max-width: 820px;
}

.center {
    text-align: center;
}

/* --- sidebar --- */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--outline);
    z-index: 80;
}

.side-head {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--top-h);
    padding: 0 18px;
    border-bottom: 1px solid var(--outline);
    flex: none;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    margin-right: auto;
}

.mark {
    display: inline-flex;
    gap: 3px;
    align-items: flex-end;
    height: 22px;
    flex: none;
}

.mark i {
    width: 5px;
    border-radius: 3px;
    display: block;
}

.mark i:nth-child(1) { height: 10px; background: var(--bad); }
.mark i:nth-child(2) { height: 22px; background: var(--good); }
.mark i:nth-child(3) { height: 15px; background: var(--primary); }

.brand-name {
    font-family: var(--f-display);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -.03em;
    white-space: nowrap;
}

.brand-name span {
    color: var(--text-3);
    font-weight: 500;
}

/* Only the mobile drawer needs a close button. Scoped past .icon-btn, which
   is defined further down and would otherwise win on source order. */
.sidebar .side-close {
    display: none;
}

.side-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px 8px;
}

.side-label {
    font-family: var(--f-mono);
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--text-3);
    padding: 14px 12px 7px;
}

.side-nav {
    display: grid;
    gap: 2px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-2);
    position: relative;
    transition: background .15s, color .15s;
}

.side-nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.side-nav a.is-active {
    background: var(--primary-container);
    color: var(--on-primary-container);
    font-weight: 600;
}

.side-nav a.is-active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}

.side-nav svg {
    width: 18px;
    height: 18px;
    flex: none;
    opacity: .85;
}

.side-nav span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-badge {
    margin-left: auto;
    font-family: var(--f-mono);
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--good);
    background: color-mix(in srgb, var(--good) 16%, transparent);
    padding: 2px 7px;
    border-radius: var(--r-full);
}

.side-foot {
    flex: none;
    padding: 12px;
    border-top: 1px solid var(--outline);
}

.side-tip {
    background: var(--surface-2);
    border-radius: var(--r-md);
    padding: 14px;
    font-size: .78rem;
    color: var(--text-2);
    line-height: 1.5;
}

.side-tip b {
    display: block;
    color: var(--text);
    font-size: .82rem;
    margin-bottom: 4px;
    font-family: var(--f-display);
}

.kbd {
    font-family: var(--f-mono);
    font-size: .68rem;
    border: 1px solid var(--outline-2);
    border-radius: 5px;
    padding: 1px 6px;
    color: var(--text-2);
}

[data-rail="1"] .brand-name,
[data-rail="1"] .side-label,
[data-rail="1"] .side-nav span,
[data-rail="1"] .side-badge,
[data-rail="1"] .side-tip {
    display: none;
}

[data-rail="1"] .side-nav a { justify-content: center; padding: 12px 0; }
[data-rail="1"] .side-head { justify-content: center; padding: 0; }
[data-rail="1"] .brand { margin-right: 0; }
[data-rail="1"] .side-foot { padding: 8px; }

/* --- top bar --- */
.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding-top: var(--top-h);
}

.topbar {
    position: fixed;
    top: 0;
    left: var(--side-w);
    right: 0;
    z-index: 60;
    height: var(--top-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 26px;
    border-bottom: 1px solid var(--outline);
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(14px) saturate(160%);
    transition: left .26s cubic-bezier(.3, .7, .3, 1);
}

.page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
    min-width: 0;
    font-family: var(--f-display);
    font-size: 1.06rem;
    font-weight: 600;
    letter-spacing: -.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-title .ti {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 10px;
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.page-title svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.9;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    min-width: 38px;
    padding: 0 10px;
    border-radius: var(--r-full);
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-2);
    transition: background .15s, color .15s;
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: block; }

#menuBtn { display: none; }

.pop { position: relative; }

.dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 190px;
    max-height: 64vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
    padding: 6px;
    z-index: 90;
}

.dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--r-xs);
    font-size: .89rem;
    color: var(--text-2);
    white-space: nowrap;
}

.dropdown .flag {
    font-size: 1.05rem;
    line-height: 1;
    flex: none;
}

.dropdown a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.dropdown a.is-current {
    background: var(--primary-container);
    color: var(--on-primary-container);
    font-weight: 600;
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 25, .45);
    z-index: 75;
    backdrop-filter: blur(2px);
}

/* ============================================================
   4. Blocks
   ============================================================ */
.eyebrow {
    font-family: var(--f-mono);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: var(--primary);
    margin-bottom: 10px;
}

.sub {
    color: var(--text-2);
    margin-top: 12px;
    font-size: 1.01rem;
}

.block {
    padding: 72px 0;
}

.block.alt {
    background: var(--bg-2);
}

.hero {
    padding: 52px 0 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -180px;
    width: 760px;
    height: 340px;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, color-mix(in srgb, var(--primary) 16%, transparent), transparent);
    pointer-events: none;
    z-index: -1;
}

.hero-h {
    font-size: clamp(2.2rem, 5.4vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -.04em;
    margin-bottom: 14px;
}

/* The split hero: copy on the left, the chips stacked as a card on the right.
   Used by the pages that answer a yes/no question, where a centred headline
   reads like a repeat of the home page. */
.hero.is-split {
    text-align: left;
    padding-bottom: 30px;
}

.hero.is-split::after {
    left: 22%;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 40px;
    align-items: center;
}

.hero.is-split .lead {
    margin-inline: 0;
}

.hero.is-split .hero-h {
    font-size: clamp(2rem, 4.4vw, 3rem);
}

.hero-facts {
    list-style: none;
    margin: 0;
    padding: 20px 22px;
    display: grid;
    gap: 11px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
}

.hero-facts li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: .87rem;
    color: var(--text-2);
}

.hero-facts li::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-top: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.lead {
    color: var(--text-2);
    font-size: 1.04rem;
    max-width: 620px;
    margin-inline: auto;
}

.chips {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 0;
    margin: 22px 0 0;
}

.chips li {
    font-size: .79rem;
    font-weight: 500;
    color: var(--text-2);
    border: 1px solid var(--outline-2);
    border-radius: var(--r-full);
    padding: 6px 14px;
    background: var(--surface);
}

.tool-wrap {
    padding-bottom: 64px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--r-full);
    cursor: pointer;
    padding: 11px 20px;
    font-size: .89rem;
    font-weight: 600;
    transition: .15s;
}

.btn:active { transform: translateY(1px); }

.btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    stroke: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: var(--shadow-1);
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-tonal {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.btn-tonal:hover { filter: brightness(.96); }

.btn-ghost {
    background: none;
    color: var(--text-2);
    border-color: var(--outline-2);
}

.btn-ghost:hover {
    background: var(--surface-3);
    color: var(--text);
}

.chip {
    border: 1px solid var(--outline-2);
    background: var(--surface);
    color: var(--text-2);
    border-radius: var(--r-full);
    padding: 7px 15px;
    font-size: .82rem;
    font-weight: 500;
    font-family: var(--f-mono);
    cursor: pointer;
    transition: .15s;
}

.chip:hover { color: var(--text); border-color: var(--primary); }

.chip.on {
    background: var(--primary-container);
    border-color: transparent;
    color: var(--on-primary-container);
    font-weight: 600;
}

.field-label {
    display: block;
    font-size: .72rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 8px;
}

/* ============================================================
   5. Instrument
   ============================================================ */
.panel {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-3);
    overflow: hidden;
}

.panel-plain {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
    padding: 22px;
}

.panel-top {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 18px;
    border-bottom: 1px solid var(--outline);
    background: var(--surface-2);
}

.pid {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-2);
    margin-right: auto;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-3);
    flex: none;
}

.dot.live {
    background: var(--good);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent);
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
    50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--good) 5%, transparent); }
}

.modes {
    display: inline-flex;
    background: var(--bg-2);
    border-radius: var(--r-full);
    padding: 3px;
    gap: 2px;
}

.mode {
    border: 0;
    background: none;
    cursor: pointer;
    padding: 7px 14px;
    border-radius: var(--r-full);
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-2);
    transition: .16s;
}

.mode:hover { color: var(--text); }

.mode.on {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-1);
    font-weight: 600;
}

.pmeta {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .79rem;
}

.pmeta .k { color: var(--text-3); }
.pmeta .v { font-weight: 600; }

.pbody {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr) 244px;
}

.is-compact .pbody {
    grid-template-columns: 236px minmax(0, 1fr);
}

.readout {
    padding: 22px 20px;
    border-right: 1px solid var(--outline);
}

.ring {
    position: relative;
    width: 174px;
    height: 174px;
    margin: 0 auto 4px;
}

.ring svg {
    width: 174px;
    height: 174px;
    display: block;
    stroke: none;
}

.ring .track {
    fill: none;
    stroke: var(--surface-3);
    stroke-width: 11;
    stroke-linecap: round;
}

.ring .prog {
    fill: none;
    stroke: var(--primary);
    stroke-width: 11;
    stroke-linecap: round;
    transition: stroke-dasharray .25s ease, stroke .3s;
}

.ring-mid {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ring-num {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.05em;
}

.ring-unit {
    font-family: var(--f-display);
    font-size: .74rem;
    font-weight: 600;
    color: var(--text-3);
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-top: 4px;
}

.grade {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

.grade b {
    font-family: var(--f-display);
    font-size: .86rem;
    padding: 4px 12px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--text-2);
}

.grade b.g-a { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.grade b.g-b { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.grade b.g-c { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.grade b.g-d { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }

.verdict {
    font-size: .83rem;
    color: var(--text-2);
    margin-top: 12px;
    text-align: center;
    min-height: 3.2em;
}

.verdict b { color: var(--text); }

.hz {
    margin-top: 14px;
    background: var(--surface-2);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 13px;
}

.hz-l {
    font-family: var(--f-mono);
    font-size: .63rem;
    text-transform: uppercase;
    letter-spacing: .13em;
    color: var(--text-3);
}

.hz-v {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.25;
}

.hz-v em {
    font-style: normal;
    font-size: .85rem;
    color: var(--text-3);
    font-weight: 500;
}

.hz-c {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 7px;
    font-size: .7rem;
    color: var(--text-2);
}

.hz-n {
    font-size: .71rem;
    color: var(--text-3);
    margin-top: 7px;
    line-height: 1.45;
}

.bar {
    flex: 1;
    display: block;
    height: 6px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    overflow: hidden;
}

.bar i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: var(--r-full);
    background: var(--primary);
    transition: width .3s ease;
}

.bar.inv i { background: var(--warn); }

.stagewrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stage {
    position: relative;
    flex: 1;
    min-height: 296px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 5%, var(--surface)), var(--surface));
    cursor: crosshair;
}

#stageC {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.hint {
    position: absolute;
    left: 14px;
    bottom: 11px;
    font-size: .73rem;
    color: var(--text-3);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    padding: 4px 10px;
    border-radius: var(--r-full);
    backdrop-filter: blur(6px);
    pointer-events: none;
}

.trace {
    border-top: 1px solid var(--outline);
    background: var(--surface-2);
    padding: 9px 14px 11px;
}

.thead {
    display: flex;
    justify-content: space-between;
    font-size: .71rem;
    color: var(--text-3);
    margin-bottom: 5px;
}

.thead b { color: var(--text); font-weight: 600; }

#traceC { width: 100%; height: 70px; }

.metrics {
    padding: 18px 16px;
    border-left: 1px solid var(--outline);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    align-content: start;
}

.metric {
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 9px 11px;
}

.metric .k {
    display: block;
    font-size: .65rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.metric .v {
    display: block;
    font-size: 1.22rem;
    font-weight: 700;
    margin-top: 1px;
}

.metric .v em {
    font-style: normal;
    font-size: .62rem;
    color: var(--text-3);
    margin-left: 2px;
}

.metric.wide { grid-column: 1 / -1; }

.gauge {
    grid-column: 1 / -1;
    margin-top: 3px;
}

.grow {
    display: flex;
    justify-content: space-between;
    font-size: .71rem;
    color: var(--text-2);
    margin-bottom: 5px;
}

.pfoot {
    border-top: 1px solid var(--outline);
    background: var(--surface-2);
    padding: 16px 18px 18px;
    display: grid;
    gap: 16px;
}

.crow {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ico-stop { display: none; }
.running .ico-play { display: none; }
.running .ico-stop { display: block; }

.stress {
    flex: 1;
    min-width: 280px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 14px 16px 13px;
}

.s-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 11px;
}

.s-lab { flex: 1; min-width: 0; }

.s-lab span {
    display: block;
    font-size: .87rem;
    font-weight: 600;
    font-family: var(--f-display);
}

.s-lab p {
    font-size: .73rem;
    color: var(--text-3);
    line-height: 1.35;
    margin-top: 2px;
}

.s-badge {
    display: flex;
    align-items: baseline;
    gap: 1px;
    flex: none;
    padding: 5px 11px;
    border-radius: var(--r-full);
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.s-badge b { font-family: var(--f-mono); font-size: 1rem; font-weight: 700; line-height: 1; }
.s-badge span { font-size: .68rem; opacity: .75; }

.s-presets {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--r-full);
    padding: 3px;
}

.s-presets button {
    border: 0;
    background: none;
    cursor: pointer;
    padding: 7px 4px;
    border-radius: var(--r-full);
    font-size: .76rem;
    font-weight: 500;
    color: var(--text-2);
    transition: .15s;
}

.s-presets button:hover { color: var(--text); }

.s-presets button.on {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-1);
}

.s-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: var(--r-full);
    margin: 15px 0 0;
    background: var(--surface-3);
    cursor: pointer;
}

.s-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--surface);
    box-shadow: var(--shadow-1);
    cursor: grab;
}

.s-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--surface);
    box-shadow: var(--shadow-1);
    cursor: grab;
}

.s-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 11px;
    font-size: .73rem;
    color: var(--text-3);
}

.s-foot b { color: var(--text); font-weight: 600; margin-left: 3px; }
.s-foot b.down { color: var(--bad); }

.charts {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 14px;
}

.chart {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 11px 13px;
}

.chead {
    display: flex;
    justify-content: space-between;
    font-size: .71rem;
    color: var(--text-3);
    margin-bottom: 6px;
}

.chead b { color: var(--text); }

#histC, #distC { width: 100%; height: 62px; }

/* display:flex would otherwise beat the hidden attribute. */
.summary[hidden] {
    display: none;
}

.summary {
    background: var(--surface);
    border: 1px solid var(--primary);
    border-radius: var(--r-md);
    padding: 16px 18px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.summary .s-txt {
    flex: 1;
    min-width: 220px;
    font-size: .88rem;
    color: var(--text-2);
}

.summary .s-txt b {
    color: var(--text);
    font-family: var(--f-display);
    display: block;
    margin-bottom: 3px;
}

.caption {
    max-width: 680px;
    margin: 16px auto 0;
    text-align: center;
    font-size: .81rem;
    color: var(--text-3);
}

.panel:fullscreen {
    border-radius: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.panel:fullscreen .pbody { flex: 1; }
.panel:fullscreen .stage { min-height: 0; }

/* ------------------------------------------------------------
   Instrument variants

   Each measurement page gets its own silhouette. They share the
   panel shell, the top bar and the footer; everything between is
   the page's own. Set with 'panel' in config/tools.php.
   ------------------------------------------------------------ */

/* --- minimal: one enormous number (FPS Checker) --- */
.p-minimal .mini-body {
    padding: 34px 26px 26px;
    text-align: center;
}

.mini-num {
    font-size: clamp(4.5rem, 15vw, 8rem);
    font-weight: 700;
    line-height: .9;
    letter-spacing: -.06em;
}

.mini-unit {
    font-family: var(--f-display);
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-top: 8px;
}

.p-minimal .grade { margin-top: 14px; }

.mini-arc {
    display: block;
    width: min(460px, 100%);
    height: 6px;
    margin: 18px auto 0;
    stroke: none;
}

.mini-arc .track { stroke: var(--surface-3); stroke-width: 6; stroke-linecap: round; }
.mini-arc .prog { stroke: var(--primary); stroke-width: 6; stroke-linecap: round; }

.p-minimal .verdict { min-height: 2.6em; max-width: 46ch; margin-inline: auto; }

.mini-stage {
    /* Tall enough for the three motion rows and their labels. */
    min-height: 136px;
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    overflow: hidden;
    margin-top: 6px;
}

.mini-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 18px;
    text-align: left;
}

.mini-side {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 10px 14px;
    border: 1px solid var(--outline);
    border-radius: var(--r-full);
    font-size: .78rem;
    color: var(--text-2);
    text-align: left;
}

.mini-side .hz-l { flex: none; }
.mini-side .bar { max-width: 120px; }

/* --- verdict: answers a yes/no question first (120 FPS Test) --- */
.verdict-banner {
    padding: 26px 24px 22px;
    text-align: center;
    border-bottom: 1px solid var(--outline);
    background: var(--surface-2);
}

.vb-text {
    font-family: var(--f-display);
    font-size: clamp(1.5rem, 3.6vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -.03em;
}

.vb-sub { font-size: .87rem; color: var(--text-2); margin-top: 8px; }

.verdict-banner[data-state="pass"] { background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.verdict-banner[data-state="pass"] .vb-text { color: var(--good); }
.verdict-banner[data-state="near"] { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.verdict-banner[data-state="near"] .vb-text { color: var(--warn); }
.verdict-banner[data-state="miss"] { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.verdict-banner[data-state="miss"] .vb-text { color: var(--bad); }

.vb-race {
    padding: 18px 24px;
    display: grid;
    gap: 10px;
    border-bottom: 1px solid var(--outline);
}

.vb-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 108px;
    gap: 14px;
    align-items: center;
}

.vb-label { font-size: .75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }

.vb-bar {
    height: 18px;
    border-radius: var(--r-xs);
    background: var(--surface-3);
    overflow: hidden;
}

.vb-bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: var(--r-xs);
    transition: width .3s ease, background .3s;
}

.vb-row.is-target .vb-bar { background: var(--surface-2); border: 1px dashed var(--outline-2); }
.vb-row.is-target .vb-bar i { background: repeating-linear-gradient(90deg, var(--outline-2) 0 6px, transparent 6px 12px); }
.vb-num { font-size: 1.05rem; text-align: right; }
.vb-num em { font-style: normal; font-size: .72rem; color: var(--text-3); }

.v-body { grid-template-columns: minmax(0, 1fr) 268px; }

.v-side {
    border-left: 1px solid var(--outline);
    padding: 16px;
    display: grid;
    gap: 12px;
    align-content: start;
}

.v-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

/* --- phone: the stage inside a handset (Phone FPS Test) --- */
.ph-body {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 26px;
    padding: 26px;
    align-items: start;
}

.ph-frame {
    position: relative;
    border: 9px solid var(--text);
    border-radius: 38px;
    background: var(--text);
    padding: 0;
    box-shadow: var(--shadow-2);
    overflow: hidden;
}

.ph-notch {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 88px;
    height: 18px;
    border-radius: var(--r-full);
    background: var(--text);
    z-index: 2;
}

.ph-bar {
    position: absolute;
    bottom: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 96px;
    height: 4px;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, .55);
    z-index: 2;
}

.ph-screen {
    min-height: 470px;
    border-radius: 28px;
    overflow: hidden;
}

.ph-screen .hint { bottom: 22px; left: 50%; transform: translateX(-50%); white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }

.ph-side { display: grid; gap: 14px; align-content: start; }

.ph-readout { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ph-num { font-size: 3.4rem; font-weight: 700; line-height: 1; letter-spacing: -.05em; }
.ph-unit { font-family: var(--f-display); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }

.ph-arc {
    flex: 1 0 100%;
    height: 6px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    overflow: hidden;
}

.ph-arc i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s ease; }

.p-phone .grade { justify-content: flex-start; margin: 0; }
.p-phone .verdict { text-align: left; margin: 0; min-height: 0; }

.ph-rows { display: grid; gap: 1px; background: var(--outline); border: 1px solid var(--outline); border-radius: var(--r-md); overflow: hidden; }

.ph-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 13px;
    background: var(--surface);
    font-size: .82rem;
    color: var(--text-2);
}

.ph-row b { color: var(--text); font-weight: 600; }
.ph-row em { font-style: normal; font-size: .68rem; color: var(--text-3); }
.ph-row .bar { max-width: 110px; }
.ph-trace { border: 1px solid var(--outline); border-radius: var(--r-md); }

/* --- stage: edge to edge canvas with a floating HUD (Screen FPS Test) --- */
.st-full { min-height: 460px; }

.st-hud {
    position: absolute;
    top: 16px;
    left: 16px;
    display: grid;
    gap: 7px;
    padding: 15px 18px;
    min-width: 190px;
    border-radius: var(--r-md);
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    border: 1px solid var(--outline);
    backdrop-filter: blur(10px);
    pointer-events: none;
}

.st-main { display: flex; align-items: baseline; gap: 8px; }
.st-num { font-size: 2.6rem; font-weight: 700; line-height: 1; letter-spacing: -.05em; }
.st-unit { font-family: var(--f-display); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }

.st-arc { display: block; height: 5px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.st-arc i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s ease; }

.st-pair { display: flex; justify-content: space-between; gap: 14px; font-size: .74rem; color: var(--text-3); }
.st-pair b { color: var(--text); font-weight: 600; }
.st-pair em { font-style: normal; color: var(--text-3); font-weight: 500; }
.st-hud .grade { margin: 2px 0 0; justify-content: flex-start; }
.st-hud .grade b { font-size: .74rem; padding: 3px 10px; }

.st-strip {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 7px;
    padding: 14px 18px;
    border-top: 1px solid var(--outline);
    background: var(--surface-2);
}

.st-trace { border-top: 1px solid var(--outline); }

/* --- cluster: four gauges in a row (Monitor FPS Test) --- */
.cl-gauges {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr 1fr;
    gap: 1px;
    background: var(--outline);
    border-bottom: 1px solid var(--outline);
}

.cl-gauge {
    background: var(--surface);
    padding: 18px 20px 16px;
    display: grid;
    gap: 4px;
    align-content: start;
}

.cl-k { font-family: var(--f-mono); font-size: .63rem; text-transform: uppercase; letter-spacing: .13em; color: var(--text-3); }
.cl-v { font-size: 2.5rem; font-weight: 700; line-height: 1; letter-spacing: -.05em; }
.cl-gauge.is-lead .cl-v { font-size: 3.4rem; color: var(--primary); }
.cl-u { font-family: var(--f-display); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.cl-gauge .bar { margin-top: 6px; }
.cl-note { font-size: .68rem; color: var(--text-3); }

.cl-trace { padding: 12px 18px 14px; border-bottom: 1px solid var(--outline); background: var(--surface-2); }
.cl-trace canvas { width: 100%; height: 96px; }

.cl-lower { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.cl-stage { min-height: 250px; }
.cl-side { border-left: 1px solid var(--outline); padding: 16px; display: grid; gap: 10px; align-content: start; }
.p-cluster .grade { justify-content: flex-start; margin: 0; }
.p-cluster .verdict { text-align: left; margin: 0; min-height: 0; font-size: .8rem; }
.cl-rows { display: grid; gap: 1px; background: var(--outline); border: 1px solid var(--outline); border-radius: var(--r-md); overflow: hidden; }

/* --- graph: the chart is the subject (Frame Rate Checker) --- */
.gr-main { position: relative; }
.gr-stage { min-height: 380px; }

.gr-readout {
    position: absolute;
    top: 14px;
    right: 18px;
    display: flex;
    align-items: baseline;
    gap: 9px;
    padding: 10px 16px;
    border-radius: var(--r-full);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    border: 1px solid var(--outline);
    backdrop-filter: blur(10px);
    pointer-events: none;
}

.gr-num { font-size: 1.9rem; font-weight: 700; line-height: 1; letter-spacing: -.04em; }
.gr-unit { font-family: var(--f-display); font-size: .66rem; letter-spacing: .13em; text-transform: uppercase; color: var(--text-3); }
.gr-ft { font-size: .82rem; color: var(--text-2); border-left: 1px solid var(--outline); padding-left: 9px; }

.gr-charts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--outline);
    background: var(--surface-2);
}

.gr-charts canvas { width: 100%; height: 66px; }

.gr-strip {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    padding: 0 18px 14px;
    background: var(--surface-2);
}

.gr-strip .metric { background: var(--surface); }
.gr-strip .metric .v { font-size: 1.02rem; }

.gr-quality {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 15px 18px;
    border-top: 1px solid var(--outline);
}

/* .gauge spans the full width inside the metrics grid; here it is a column. */
.gr-quality .gauge {
    grid-column: auto;
    margin-top: 0;
}

.gr-verdict { text-align: center; padding: 0 18px 4px; min-height: 0; }

/* --- hz: the number is the page (Refresh Rate Test) --- */
.hz-hero { padding: 34px 24px 26px; text-align: center; }

.hz-big {
    font-size: clamp(5rem, 17vw, 9.5rem);
    font-weight: 700;
    line-height: .85;
    letter-spacing: -.07em;
    color: var(--primary);
}

.hz-big-unit {
    font-family: var(--f-display);
    font-size: .9rem;
    font-weight: 600;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-top: 10px;
}

.hz-conf {
    display: flex;
    align-items: center;
    gap: 11px;
    justify-content: center;
    max-width: 380px;
    margin: 20px auto 0;
    font-size: .74rem;
    color: var(--text-2);
}

.hz-conf-k { font-family: var(--f-mono); font-size: .63rem; text-transform: uppercase; letter-spacing: .13em; color: var(--text-3); }
.hz-note { font-size: .78rem; color: var(--text-3); margin-top: 10px; }

.hz-ladder {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 0 18px 22px;
}

.rate-step {
    display: grid;
    justify-items: center;
    gap: 1px;
    min-width: 56px;
    padding: 7px 9px;
    border: 1px solid var(--outline);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    transition: .2s;
}

.rate-step b { font-size: .88rem; font-weight: 600; color: var(--text-2); }
.rate-step em { font-style: normal; font-size: .63rem; color: var(--text-3); }

.rate-step.on {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

.rate-step.on b { color: var(--on-primary); }
.rate-step.on em { color: color-mix(in srgb, var(--on-primary) 75%, transparent); }

.hz-lower { display: grid; grid-template-columns: minmax(0, 1fr) 260px; border-top: 1px solid var(--outline); }
.hz-stage { min-height: 210px; }
.hz-side { border-left: 1px solid var(--outline); padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; align-content: start; }
.hz-trace { border-top: 1px solid var(--outline); }
.hz-verdict { text-align: center; padding: 12px 18px 0; min-height: 0; }

/* --- colour field (screen bleeding test) --- */
.field {
    position: relative;
    min-height: 420px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    cursor: pointer;
    /* No transition: a colour that fades through an in-between shade is a
       colour you cannot judge a panel by. */
    background: #000;
}

.field:focus-visible {
    outline-offset: -4px;
}

.field p {
    margin: 0 0 18px;
    padding: 7px 16px;
    border-radius: var(--r-full);
    font-size: .8rem;
    color: rgba(255, 255, 255, .82);
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(6px);
    pointer-events: none;
}

.field.is-light p {
    color: rgba(0, 0, 0, .75);
    background: rgba(255, 255, 255, .5);
}

.field.is-full {
    min-height: 100vh;
    align-items: flex-end;
}

.field.is-full p {
    margin-bottom: 26px;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 14px;
    border-top: 1px solid var(--outline);
    background: var(--surface-2);
}

.swatch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 13px 6px 7px;
    border: 1px solid var(--outline-2);
    border-radius: var(--r-full);
    background: var(--surface);
    color: var(--text-2);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: .15s;
}

.swatch:hover {
    color: var(--text);
    border-color: var(--primary);
}

.swatch.on {
    border-color: var(--primary);
    background: var(--primary-container);
    color: var(--on-primary-container);
    font-weight: 600;
}

.sw-chip {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex: none;
    /* A white swatch on a white chip needs an edge to exist at all. */
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
}

.looking .look {
    font-size: .85rem;
    color: var(--text-2);
}

.looking .look b {
    color: var(--text);
    font-family: var(--f-display);
    margin-right: 6px;
}

/* ============================================================
   6. Widgets
   ============================================================ */
.device {
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-lg);
    padding: 20px 22px;
}

.device h3 {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.device h3 svg { width: 18px; height: 18px; color: var(--primary); }

.dgrid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
}

.dcell {
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    min-width: 0;
}

.dcell .k {
    display: block;
    font-size: .65rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.dcell .v {
    display: block;
    font-size: .86rem;
    font-weight: 600;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dnote {
    font-size: .76rem;
    color: var(--text-3);
    margin-top: 12px;
}

.lane-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 16px;
    justify-content: center;
}

.lanes {
    display: grid;
    gap: 8px;
}

.lane {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 13px 17px;
}

.lane.is-off { display: none; }

.lane.you {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 11%, transparent);
}

.lane .li b { display: block; font-size: .9rem; font-weight: 600; }
.lane .li span { display: block; font-size: .73rem; color: var(--text-3); }

.track {
    position: relative;
    height: 34px;
    border-radius: var(--r-xs);
    background: var(--surface-3);
    overflow: hidden;
}

.puck {
    position: absolute;
    top: 6px;
    left: 0;
    width: 34px;
    height: 22px;
    border-radius: 6px;
    background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 68%, #000));
    will-change: transform;
}

.lane.you .puck {
    background: linear-gradient(180deg, var(--good), color-mix(in srgb, var(--good) 68%, #000));
}

.lfoot {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.lfoot p {
    font-size: .81rem;
    color: var(--text-3);
    flex: 1;
    min-width: 250px;
}

.calc {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: end;
}

.calc label {
    display: block;
    font-size: .72rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 6px;
}

.calc input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--outline-2);
    background: var(--surface-2);
    font-family: var(--f-mono);
    font-size: 1.25rem;
    font-weight: 600;
}

.calc input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.eq {
    font-family: var(--f-display);
    font-size: 1.3rem;
    color: var(--text-3);
    padding-bottom: 12px;
}

.calc-quick { margin-top: 20px; }

.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.calcout {
    margin-top: 16px;
    text-align: center;
    font-size: .86rem;
    color: var(--text-2);
}

/* ============================================================
   7. Content
   ============================================================ */
.article > * + * { margin-top: 18px; }
.article > h2 { margin-top: 44px; }
.article > h2:first-child { margin-top: 0; }
.article > h3 { margin-top: 30px; }

.article p { color: var(--text-2); }

.article .lead-p {
    font-size: 1.06rem;
    color: var(--text);
}

.article a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.article ul,
.article ol {
    margin: 0;
    padding-left: 20px;
    display: grid;
    gap: 9px;
    color: var(--text-2);
}

.article li::marker { color: var(--primary); }
.article strong { color: var(--text); }

.callout {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-left: 3px solid var(--primary);
    border-radius: var(--r-sm);
    padding: 15px 18px;
    font-size: .92rem;
    color: var(--text-2);
}

.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.mini {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 15px;
}

.mini b { display: block; font-size: .89rem; margin-bottom: 4px; }
.mini p { font-size: .84rem; }

.gloss {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 13px;
}

.gloss article {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 19px;
}

.gloss b {
    display: block;
    font-family: var(--f-display);
    font-size: 1rem;
    margin-bottom: 5px;
}

.gloss p { font-size: .85rem; }

.levels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 13px;
}

.level {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 19px;
}

.level header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 7px;
}

.level header b { font-family: var(--f-display); font-size: 1.14rem; font-weight: 600; }

.level header span {
    font-size: .72rem;
    color: var(--on-primary-container);
    background: var(--primary-container);
    padding: 3px 9px;
    border-radius: var(--r-full);
    white-space: nowrap;
}

.level p { font-size: .86rem; }

.tips {
    display: block;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-1);
}

.tips h3 { margin-bottom: 13px; }
.tips ul { padding-left: 18px; }
.tips li { font-size: .87rem; }

.steps {
    list-style: none;
    padding: 0;
    margin: 32px 0 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.steps li {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-lg);
    padding: 22px;
}

.sn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 29px;
    height: 29px;
    border-radius: var(--r-full);
    background: var(--primary-container);
    color: var(--on-primary-container);
    font-size: .8rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.steps h3 { margin-bottom: 5px; }
.steps p { font-size: .87rem; color: var(--text-2); }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    background: var(--surface);
}

.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.tbl th,
.tbl td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--outline);
}

.tbl th {
    font-family: var(--f-mono);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-3);
    background: var(--surface-2);
    white-space: nowrap;
}

.tbl td { color: var(--text-2); }
.tbl td.mono { color: var(--text); font-weight: 500; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }

.faq {
    margin-top: 28px;
    display: grid;
    gap: 8px;
}

.faq details {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    overflow: hidden;
}

.faq summary {
    cursor: pointer;
    padding: 16px 19px;
    font-weight: 500;
    font-size: .94rem;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
    content: "+";
    font-family: var(--f-mono);
    font-size: 1.2rem;
    color: var(--primary);
    flex: none;
    transition: transform .2s;
}

.faq details[open] summary::after { transform: rotate(45deg); }

.faq p {
    padding: 0 19px 17px;
    font-size: .89rem;
    color: var(--text-2);
    max-width: 70ch;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 30px;
}

.related-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 16px 18px;
    transition: border-color .15s, transform .15s;
}

.related-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.rc-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.rc-ico svg { width: 19px; height: 19px; }

.rc-txt { flex: 1; min-width: 0; }
.rc-txt b { display: block; font-size: .92rem; font-weight: 600; }
.rc-txt span { display: block; font-size: .8rem; color: var(--text-3); }

.rc-go { flex: none; color: var(--text-3); }
.rc-go svg { width: 18px; height: 18px; }
.related-card:hover .rc-go { color: var(--primary); }

.cta {
    display: grid;
    grid-template-columns: .8fr 1.2fr;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
}

.cta-art {
    display: flex;
    align-items: flex-end;
    gap: 9px;
    padding: 32px;
    min-height: 190px;
    background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 92%, #000), color-mix(in srgb, var(--primary) 52%, #291968));
}

.cta-art span {
    flex: 1;
    border-radius: 8px 8px 0 0;
    background: rgba(255, 255, 255, .26);
}

.cta-art span:nth-child(1) { height: 22%; }
.cta-art span:nth-child(2) { height: 44%; }
.cta-art span:nth-child(3) { height: 78%; background: rgba(255, 255, 255, .88); }
.cta-art span:nth-child(4) { height: 56%; }
.cta-art span:nth-child(5) { height: 32%; }

.cta-copy { padding: 34px 36px; align-self: center; }
.cta-copy p { color: var(--text-2); margin: 11px 0 20px; }

.foot {
    border-top: 1px solid var(--outline);
    background: var(--bg-2);
    padding: 44px 0 24px;
    margin-top: auto;
}

.fgrid {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: 32px;
}

.fnote {
    font-size: .82rem;
    color: var(--text-3);
    margin-top: 12px;
    max-width: 38ch;
}

.fh {
    font-family: var(--f-mono);
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .13em;
    color: var(--text-3);
    margin-bottom: 10px;
}

.foot nav a {
    display: block;
    font-size: .86rem;
    color: var(--text-2);
    padding: 5px 0;
}

.foot nav a:hover { color: var(--primary); }

.fbot {
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid var(--outline);
    font-size: .79rem;
    color: var(--text-3);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.fbot a { color: var(--text-2); }
.fbot a:hover { color: var(--primary); }

/* ============================================================
   8. Pages
   ============================================================ */
.page-wrap {
    padding-top: 48px;
    padding-bottom: 72px;
}

.page-head { margin-bottom: 32px; }

.page-head .lede {
    font-size: 1.06rem;
    color: var(--text-2);
    max-width: 60ch;
}

.page-head.center .lede { margin-inline: auto; }

.updated {
    font-size: .8rem;
    color: var(--text-3);
    margin-top: 12px;
}

.toc {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 18px 22px;
}

.toc h2 {
    font-size: .72rem;
    font-family: var(--f-mono);
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-3);
    margin-bottom: 10px;
}

.toc ol {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
    font-size: .9rem;
}

.toc a { color: var(--primary); }
.toc a:hover { text-decoration: underline; }

.prose { margin-top: 40px; }
.prose section + section { margin-top: 38px; }
.prose h2 { font-size: 1.4rem; margin-bottom: 12px; }
.prose p { color: var(--text-2); }
.prose p + p { margin-top: 12px; }
.prose ul { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); }
.prose li::marker { color: var(--primary); }
.prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

.err-code {
    font-family: var(--f-mono);
    font-size: clamp(3.4rem, 12vw, 6rem);
    color: var(--primary);
    letter-spacing: -.06em;
}

.error-actions { margin-top: 24px; }
.err-list { margin-top: 20px; }
.err-list h2 { font-size: 1.2rem; text-align: center; }

/* ============================================================
   9. Responsive
   ============================================================ */
@media (max-width: 1180px) {
    .pbody { grid-template-columns: 1fr 1fr; }
    .stagewrap { grid-column: 1 / -1; order: 3; border-top: 1px solid var(--outline); }
    .is-compact .stagewrap { grid-column: auto; order: 0; border-top: 0; }
    .metrics { border-left: 1px solid var(--outline); }
    .dgrid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        transform: translateX(-102%);
        transition: transform .26s cubic-bezier(.3, .7, .3, 1);
        box-shadow: var(--shadow-3);
    }

    [data-drawer="1"] .sidebar { transform: none; }

    .sidebar .side-close { display: inline-flex; }
    #menuBtn { display: inline-flex; }
    #railBtn { display: none; }
    .topbar { left: 0; }
    .levels, .gloss { grid-template-columns: 1fr 1fr; }
    .steps { grid-template-columns: 1fr; }
    .hero-grid { grid-template-columns: 1fr; gap: 26px; }
    .fgrid { grid-template-columns: 1fr 1fr; }
    .related-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .block { padding: 52px 0; }
    .wrap, .topbar { padding-inline: 18px; }
    .pbody, .is-compact .pbody { grid-template-columns: 1fr; }
    .readout { border-right: 0; border-bottom: 1px solid var(--outline); }
    .metrics { border-left: 0; border-top: 1px solid var(--outline); order: 4; }
    .stage { min-height: 230px; }
    .charts { grid-template-columns: 1fr; }
    .lane { grid-template-columns: 1fr; gap: 9px; }
    .levels, .gloss, .two, .dgrid { grid-template-columns: 1fr; }
    .calc { grid-template-columns: 1fr; }
    .eq { display: none; }
    .cta { grid-template-columns: 1fr; }
    .cta-art { min-height: 120px; }
    .cta-copy { padding: 26px 24px; }
    .fgrid { grid-template-columns: 1fr; gap: 24px; }
    .crow { flex-direction: column; align-items: stretch; gap: 14px; }
    .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .controls .btn { min-width: 0; padding: 13px 12px; }
    .controls .btn:first-child { grid-column: 1 / -1; }
    .stress { min-width: 0; }
    .page-title { font-size: .98rem; }
    .pmeta { margin-left: auto; }
    .ring, .ring svg { width: 158px; height: 158px; }
    .ring-num { font-size: 2.7rem; }
    .metrics { padding: 14px 12px; }
    .modes { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; order: 3; width: 100%; justify-content: flex-start; }
    .modes::-webkit-scrollbar { display: none; }
    .panel-top { gap: 9px 12px; padding: 11px 14px; }
    .pid { order: 1; }
    .pmeta { order: 2; }
    .mode { white-space: nowrap; padding: 8px 13px; }
    .summary { flex-direction: column; align-items: stretch; }
    .summary .btn { width: 100%; }
    .panel-plain { padding: 18px; }
    .field { min-height: 300px; }
    .sw-name { display: none; }
    .swatch { padding: 7px; }
    .swatches { justify-content: center; }

    /* Instrument variants collapse to one column. */
    .ph-body { grid-template-columns: 1fr; }
    .ph-frame { max-width: 300px; margin-inline: auto; }
    .ph-screen { min-height: 380px; }
    .cl-lower, .hz-lower, .v-body { grid-template-columns: 1fr; }
    .cl-side, .hz-side, .v-side { border-left: 0; border-top: 1px solid var(--outline); }
    .cl-gauges { grid-template-columns: 1fr 1fr; }
    .gr-charts { grid-template-columns: 1fr; }
    .gr-strip { grid-template-columns: repeat(2, 1fr); }
    .gr-quality { grid-template-columns: 1fr 1fr; }
    .gr-stage { min-height: 260px; }
    .gr-readout { top: auto; bottom: 12px; right: 12px; padding: 8px 12px; }
    .st-full { min-height: 320px; }
    .st-strip { grid-template-columns: repeat(3, 1fr); }
    .st-hud { top: 10px; left: 10px; padding: 11px 13px; min-width: 0; }
    .st-num { font-size: 1.9rem; }
    .mini-tiles { grid-template-columns: 1fr 1fr; }
    .mini-side { flex-wrap: wrap; }
    .vb-row { grid-template-columns: 74px minmax(0, 1fr) 86px; gap: 10px; }
    .hz-side { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
    .wrap, .topbar { padding-inline: 14px; }
    .s-presets button { font-size: .7rem; padding: 7px 2px; }
    .metric .v { font-size: 1.1rem; }
    .ring, .ring svg { width: 142px; height: 142px; }
    .ring-num { font-size: 2.4rem; }
    .stage { min-height: 210px; }
    .s-foot { flex-direction: column; gap: 4px; }
    .chips li { font-size: .74rem; padding: 5px 11px; }
    .tbl th, .tbl td { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}
