/* ==========================================================================
   A Bubble Level — base stylesheet
   Design tokens, page chrome (app bar, drawer, bottom navigation, footer),
   the instrument primitives every tool reuses, and article typography.
   Tool-specific rules live in their own file (bubble.css, plumb.css, …).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   Material 3 colour roles, seeded from the chartreuse fluid inside a real
   spirit-level vial.
   -------------------------------------------------------------------------- */
:root {
    --primary: #3F6300;
    --on-primary: #FFFFFF;
    --primary-container: #C0EE7A;
    --on-primary-container: #0E2000;
    --secondary: #57624A;
    --on-secondary: #FFFFFF;
    --secondary-container: #DBE7C8;
    --on-secondary-container: #151E0B;
    --tertiary: #00696E;
    --on-tertiary: #FFFFFF;
    --tertiary-container: #9CF1F6;
    --on-tertiary-container: #002021;
    --error: #BA1A1A;
    --error-container: #FFDAD6;
    --on-error-container: #410002;

    --surface: #F7F9EE;
    --on-surface: #191D13;
    --surface-dim: #D8DBCF;
    --sc-lowest: #FFFFFF;
    --sc-low: #F2F5E8;
    --sc: #ECEFE3;
    --sc-high: #E6E9DD;
    --sc-highest: #E1E4D8;
    --on-surface-variant: #44483D;
    --outline: #75796C;
    --outline-variant: #C5C8BA;
    --inverse-surface: #2E312A;
    --inverse-on-surface: #F0F2E6;

    --bubble-fill: #D6F55C;
    --bubble-edge: #8FBF17;
    --vial-glass: #20301A;
    --vial-fluid: #33501F;

    --e1: 0 1px 3px 1px rgba(30, 40, 20, .10), 0 1px 2px rgba(30, 40, 20, .16);
    --e2: 0 2px 6px 2px rgba(30, 40, 20, .10), 0 1px 2px rgba(30, 40, 20, .16);
    --e3: 0 4px 8px 3px rgba(30, 40, 20, .10), 0 1px 3px rgba(30, 40, 20, .16);

    --ease-spring: cubic-bezier(.2, 1.3, .35, 1);
    --ease-std: cubic-bezier(.2, 0, 0, 1);

    --font: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --nav-h: 78px;
    --wrap: 760px;
}

:root[data-theme="dark"] {
    --primary: #A5D26A;
    --on-primary: #1D3400;
    --primary-container: #2C4C00;
    --on-primary-container: #C0EE7A;
    --secondary: #BFCBAD;
    --on-secondary: #2A331F;
    --secondary-container: #404A34;
    --on-secondary-container: #DBE7C8;
    --tertiary: #80D4DA;
    --on-tertiary: #00373A;
    --tertiary-container: #004F53;
    --on-tertiary-container: #9CF1F6;
    --error: #FFB4AB;
    --error-container: #93000A;
    --on-error-container: #FFDAD6;

    --surface: #11150C;
    --on-surface: #E1E4D8;
    --surface-dim: #11150C;
    --sc-lowest: #0C1007;
    --sc-low: #191D13;
    --sc: #1D2117;
    --sc-high: #282C21;
    --sc-highest: #33372B;
    --on-surface-variant: #C5C8BA;
    --outline: #8F9384;
    --outline-variant: #44483D;
    --inverse-surface: #E1E4D8;
    --inverse-on-surface: #2E312A;

    --bubble-fill: #E4FF7A;
    --bubble-edge: #A8D63C;
    --vial-glass: #0A0F06;
    --vial-fluid: #16210F;

    --e1: 0 1px 3px 1px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .6);
    --e2: 0 2px 6px 2px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .6);
    --e3: 0 4px 10px 3px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .6);
}

/* --------------------------------------------------------------------------
   2. Reset & elements
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--surface);
    color: var(--on-surface);
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: .005em;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
    overflow-x: hidden;
    transition: background-color .3s var(--ease-std), color .3s var(--ease-std);
}

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

a:hover {
    text-decoration-thickness: 2.5px;
}

h1,
h2,
h3 {
    line-height: 1.2;
    letter-spacing: -.025em;
    text-wrap: balance;
    font-weight: 700;
}

img,
svg,
canvas {
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

::selection {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

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

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

.skip-link {
    position: absolute;
    left: 50%;
    top: -60px;
    transform: translateX(-50%);
    z-index: 90;
    background: var(--primary);
    color: var(--on-primary);
    padding: 10px 18px;
    border-radius: 0 0 12px 12px;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    transition: top .2s var(--ease-std);
}

.skip-link:focus {
    top: 0;
}

/* --------------------------------------------------------------------------
   3. App bar
   -------------------------------------------------------------------------- */
.appbar {
    position: static;
    background: var(--surface);
}

.appbar__inner {
    max-width: var(--wrap);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}

.appbar__spacer {
    flex: 1;
}

/* The site name is the page's H1 on every tool page, so it is a heading
   element here rather than a plain link — sized like a wordmark, not like a
   headline. */
.brand {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.2;
    min-width: 0;
}

.brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--on-surface);
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 12px;
    min-width: 0;
}

.brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    flex: none;
    background: var(--primary-container);
    display: grid;
    place-items: center;
}

.brand-mark span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--bubble-fill);
    border: 1.5px solid var(--bubble-edge);
    box-shadow: inset -1.5px -1.5px 2px rgba(0, 0, 0, .18), inset 1.5px 1.5px 2px rgba(255, 255, 255, .7);
    animation: idlefloat 5s ease-in-out infinite;
}

@keyframes idlefloat {

    0%,
    100% {
        transform: translateX(-3px);
    }

    50% {
        transform: translateX(3px);
    }
}

.icon-btn {
    width: 44px;
    height: 44px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--on-surface-variant);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background-color .18s, color .18s;
}

.icon-btn:hover {
    background: color-mix(in srgb, var(--on-surface) 8%, transparent);
    color: var(--on-surface);
}

.icon-btn:active {
    background: color-mix(in srgb, var(--on-surface) 14%, transparent);
}

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

/* --------------------------------------------------------------------------
   4. Drawer
   -------------------------------------------------------------------------- */
.scrim {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(20, 26, 12, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s var(--ease-std);
}

.scrim.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    z-index: 75;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(340px, 88vw);
    background: var(--sc-low);
    border-inline-end: 1px solid var(--outline-variant);
    box-shadow: var(--e3);
    display: flex;
    flex-direction: column;
    transform: translateX(-102%);
    transition: transform .34s var(--ease-spring);
    padding-bottom: env(safe-area-inset-bottom);
}

[dir="rtl"] .drawer {
    transform: translateX(102%);
}

.drawer.open {
    transform: none;
}

.drawer__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 12px 20px;
    border-bottom: 1px solid var(--outline-variant);
}

.drawer__title {
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -.02em;
}

.drawer__list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 14px;
    border-radius: 16px;
    color: var(--on-surface);
    text-decoration: none;
    transition: background-color .16s;
}

.nav-item:hover {
    background: color-mix(in srgb, var(--on-surface) 7%, transparent);
}

.nav-item[aria-current="page"] {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}

.nav-item__ico {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--sc-high);
    color: var(--on-surface-variant);
}

.nav-item[aria-current="page"] .nav-item__ico {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.nav-item__ico svg {
    width: 22px;
    height: 22px;
}

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

.nav-item__txt strong {
    font-size: .9375rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.nav-item__txt span {
    font-size: .75rem;
    line-height: 1.35;
    color: var(--on-surface-variant);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nav-item .badge {
    margin-inline-start: auto;
    flex: none;
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--primary);
    color: var(--on-primary);
}

.drawer__foot {
    border-top: 1px solid var(--outline-variant);
    padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
    font-size: .8125rem;
    color: var(--on-surface-variant);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.drawer__foot a {
    color: var(--on-surface-variant);
}

/* --------------------------------------------------------------------------
   5. Bottom navigation
   -------------------------------------------------------------------------- */
.bottom-nav {
    position: fixed;
    z-index: 60;
    left: 0;
    right: 0;
    bottom: 0;
    background: color-mix(in srgb, var(--sc) 92%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    backdrop-filter: blur(20px) saturate(1.5);
    border-top: 1px solid var(--outline-variant);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    align-items: stretch;
}

.nav-tab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--on-surface-variant);
    padding: 2px 2px 0;
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-pill {
    width: 62px;
    max-width: 100%;
    height: 32px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    transition: background-color .22s var(--ease-std);
}

.nav-tab svg {
    width: 23px;
    height: 23px;
}

.nav-label {
    font-size: .6875rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-tab:hover .nav-pill {
    background: color-mix(in srgb, var(--on-surface) 8%, transparent);
}

.nav-tab[aria-current="page"] {
    color: var(--on-surface);
}

.nav-tab[aria-current="page"] .nav-pill {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.nav-tab[aria-current="page"] .nav-label {
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   6. Layout
   -------------------------------------------------------------------------- */
.wrap {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 14px max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
}

/* The single line above the instrument: which level this is, and which
   direction it reads. There is no page H1 here — the brand carries it. */
.eyebrow {
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    margin: 20px 0 14px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.eyebrow::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--outline-variant);
}

.section-title {
    font-size: 1.4375rem;
    margin: 44px 0 6px;
}

.section-sub {
    color: var(--on-surface-variant);
    margin: 0 0 18px;
    font-size: .9375rem;
}

/* --------------------------------------------------------------------------
   7. The instrument frame
   -------------------------------------------------------------------------- */
.tool {
    position: relative;
    border-radius: 32px;
    padding: 26px 20px 22px;
    background: linear-gradient(180deg, var(--sc-low), var(--sc));
    box-shadow: var(--e2), inset 0 1px 0 color-mix(in srgb, var(--sc-lowest) 70%, transparent);
    border: 1px solid var(--outline-variant);
    scroll-margin-top: 74px;
}

/* Machined corner screws — a nod to the physical tool. */
.tool::before,
.tool::after {
    content: "";
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--outline-variant), var(--outline));
    opacity: .55;
    top: 16px;
}

.tool::before {
    left: 16px;
}

.tool::after {
    right: 16px;
}

/* Readout ---------------------------------------------------------------- */
.readout {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    margin-bottom: 2px;
}

.degrees {
    font-family: var(--mono);
    font-size: clamp(3.2rem, 14vw, 4.5rem);
    font-weight: 700;
    line-height: .95;
    letter-spacing: -.045em;
    font-variant-numeric: tabular-nums;
    color: var(--on-surface);
    transition: color .25s var(--ease-std);
}

.tool.level .degrees {
    color: var(--primary);
}

.deg-unit {
    font-family: var(--mono);
    font-size: 1.625rem;
    font-weight: 500;
    color: var(--on-surface-variant);
    padding-bottom: .45rem;
}

.verdict {
    text-align: center;
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    min-height: 1.3em;
    margin-bottom: 18px;
    transition: color .25s;
}

.tool.level .verdict {
    color: var(--primary);
}

/* A row of secondary numbers under the main reading. */
.sub-readout {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0 0;
}

.stat {
    flex: 1 1 120px;
    min-width: 96px;
    text-align: center;
    padding: 10px 8px;
    border-radius: 18px;
    background: var(--sc-high);
    border: 1px solid var(--outline-variant);
}

.stat b {
    display: block;
    font-family: var(--mono);
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.03em;
    color: var(--on-surface);
}

.stat span {
    display: block;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    margin-top: 2px;
}

/* The vial ---------------------------------------------------------------- */
.vial {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--vial-glass) 0%, var(--vial-fluid) 45%, var(--vial-glass) 100%);
    box-shadow:
        inset 0 3px 8px rgba(0, 0, 0, .55),
        inset 0 -2px 6px rgba(0, 0, 0, .4),
        0 1px 0 color-mix(in srgb, var(--sc-lowest) 60%, transparent);
    border: 1px solid color-mix(in srgb, var(--outline) 40%, transparent);
}

.vial--h {
    height: 88px;
    border-radius: 44px;
}

.tol-zone {
    position: absolute;
    background: color-mix(in srgb, var(--bubble-edge) 16%, transparent);
    transition: background-color .3s var(--ease-std);
}

.vial--h .tol-zone {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 74px;
    transform: translateX(-50%);
}

.tool.level .tol-zone {
    background: color-mix(in srgb, var(--bubble-fill) 30%, transparent);
}

.groove {
    position: absolute;
    background: color-mix(in srgb, #fff 42%, transparent);
    border-radius: 2px;
}

.vial--h .groove {
    top: 9px;
    bottom: 9px;
    width: 2px;
}

.vial--h .groove.a {
    left: calc(50% - 37px);
}

.vial--h .groove.b {
    left: calc(50% + 35px);
}

.bubble {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 62px;
    height: 62px;
    margin: -31px 0 0 -31px;
    border-radius: 50%;
    will-change: transform;
    background: radial-gradient(circle at 32% 28%,
            color-mix(in srgb, #fff 75%, var(--bubble-fill)) 0%,
            var(--bubble-fill) 46%,
            color-mix(in srgb, var(--bubble-edge) 80%, var(--bubble-fill)) 100%);
    border: 1.5px solid var(--bubble-edge);
    box-shadow:
        inset -3px -4px 8px color-mix(in srgb, var(--bubble-edge) 70%, transparent),
        inset 3px 4px 9px rgba(255, 255, 255, .75),
        0 0 18px color-mix(in srgb, var(--bubble-fill) 45%, transparent);
    transition: box-shadow .3s;
}

.tool.level .bubble {
    box-shadow:
        inset -3px -4px 8px color-mix(in srgb, var(--bubble-edge) 70%, transparent),
        inset 3px 4px 9px rgba(255, 255, 255, .8),
        0 0 30px color-mix(in srgb, var(--bubble-fill) 85%, transparent);
}

.sheen {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, .05) 32%, transparent 52%, rgba(255, 255, 255, .06) 100%);
}

/* Ruler ------------------------------------------------------------------- */
.ruler {
    position: relative;
    height: 26px;
    margin-top: 10px;
}

.tick {
    position: absolute;
    top: 0;
    width: 1px;
    background: var(--outline-variant);
    transform: translateX(-50%);
}

.tick.minor {
    height: 5px;
}

.tick.major {
    height: 9px;
    background: var(--outline);
    width: 1.5px;
}

.tick-label {
    position: absolute;
    top: 11px;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: .625rem;
    font-weight: 500;
    color: var(--on-surface-variant);
    letter-spacing: -.02em;
}

/* Status chip ------------------------------------------------------------- */
.status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px auto 0;
    padding: 7px 14px;
    width: fit-content;
    max-width: 100%;
    border-radius: 999px;
    border: 1px solid var(--outline-variant);
    background: var(--sc-high);
    font-size: .8125rem;
    color: var(--on-surface-variant);
    text-align: center;
}

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

.status[data-state="live"] {
    border-color: transparent;
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.status[data-state="live"] .dot {
    background: var(--primary);
    animation: pulse 1.8s ease-in-out infinite;
}

.status[data-state="demo"] {
    border-color: transparent;
    background: var(--tertiary-container);
    color: var(--on-tertiary-container);
}

.status[data-state="demo"] .dot {
    background: var(--tertiary);
}

.status[data-state="error"] {
    border-color: transparent;
    background: var(--error-container);
    color: var(--on-error-container);
}

.status[data-state="error"] .dot {
    background: var(--error);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .35;
        transform: scale(.8);
    }
}

/* --------------------------------------------------------------------------
   8. Buttons
   -------------------------------------------------------------------------- */
.controls {
    display: flex;
    gap: 10px;
    margin: 18px 0 0;
    flex-wrap: wrap;
}

.btn {
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 0 20px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: transform .16s var(--ease-spring), background-color .18s, box-shadow .18s, border-radius .3s var(--ease-spring);
}

.btn svg {
    width: 19px;
    height: 19px;
    flex: none;
}

.btn:active {
    transform: scale(.96);
    border-radius: 18px;
}

.btn.filled {
    background: var(--primary);
    color: var(--on-primary);
    flex: 1 1 190px;
    box-shadow: var(--e1);
}

.btn.filled:hover {
    box-shadow: var(--e2);
    background: color-mix(in srgb, var(--primary) 92%, var(--on-primary));
}

.btn.tonal {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
    flex: 1 1 120px;
}

.btn.tonal:hover {
    background: color-mix(in srgb, var(--secondary-container) 88%, var(--on-secondary-container));
}

.btn.outlined {
    background: transparent;
    color: var(--primary);
    border-color: var(--outline);
    flex: 1 1 120px;
}

.btn.outlined:hover {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.hint {
    margin: 14px 0 0;
    font-size: .8125rem;
    color: var(--on-surface-variant);
    text-align: center;
    text-wrap: pretty;
}

/* Segmented control, for tools that switch units or modes. */
.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: var(--sc-high);
    border: 1px solid var(--outline-variant);
    margin: 18px auto 0;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
    display: none;
}

.seg {
    border: 0;
    background: transparent;
    color: var(--on-surface-variant);
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .2s, color .2s;
}

.seg[aria-pressed="true"] {
    background: var(--primary);
    color: var(--on-primary);
}

/* --------------------------------------------------------------------------
   9. Article typography
   -------------------------------------------------------------------------- */
.article {
    padding: 8px 0 0;
}

.article h2 {
    font-size: 1.4375rem;
    margin: 40px 0 12px;
}

.article h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -.015em;
    margin: 0 0 4px;
}

.article p {
    margin: 0 0 16px;
    color: var(--on-surface-variant);
    text-wrap: pretty;
}

.article strong,
.article b {
    color: var(--on-surface);
    font-weight: 600;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 18px 0 8px;
}

.feature {
    background: var(--sc-low);
    border: 1px solid var(--outline-variant);
    border-radius: 20px;
    padding: 18px;
}

.feature .ico {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: var(--primary-container);
    color: var(--on-primary-container);
    margin-bottom: 12px;
}

.feature .ico svg {
    width: 22px;
    height: 22px;
}

.feature p {
    margin: 0;
    font-size: .9375rem;
}

.uses {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 18px 0 8px;
}

.uses li {
    display: flex;
    gap: 13px;
    align-items: flex-start;
    color: var(--on-surface-variant);
    font-size: .9375rem;
}

.uses .bullet {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--secondary-container);
    color: var(--on-secondary-container);
    display: grid;
    place-items: center;
    font-size: .75rem;
    font-weight: 700;
    margin-top: 2px;
}

.uses b {
    color: var(--on-surface);
    font-weight: 600;
}

/* How-to steps ------------------------------------------------------------ */
.how-to {
    scroll-margin-top: 74px;
}

.steps {
    list-style: none;
    counter-reset: step;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-radius: 24px;
    border: 1px solid var(--outline-variant);
    background: var(--sc-low);
    overflow: hidden;
}

.steps li {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    border-bottom: 1px solid var(--outline-variant);
}

.steps li:last-child {
    border-bottom: 0;
}

.steps__n {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    display: grid;
    place-items: center;
    font-family: var(--mono);
    font-size: .8125rem;
    font-weight: 700;
}

.steps__txt {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.steps__txt strong {
    font-weight: 600;
    letter-spacing: -.01em;
}

.steps__txt span {
    color: var(--on-surface-variant);
    font-size: .9375rem;
}

/* FAQ --------------------------------------------------------------------- */
.faq {
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--outline-variant);
    background: var(--sc-low);
}

.acc {
    border-bottom: 1px solid var(--outline-variant);
}

.acc:last-child {
    border-bottom: 0;
}

.acc summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 18px;
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    transition: background-color .18s;
}

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

.acc summary h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -.015em;
}

.acc summary:hover {
    background: color-mix(in srgb, var(--on-surface) 5%, transparent);
}

.acc .chev {
    flex: none;
    color: var(--on-surface-variant);
    display: grid;
    place-items: center;
    transition: transform .28s var(--ease-spring);
}

.acc .chev svg {
    width: 20px;
    height: 20px;
}

.acc[open] summary {
    background: color-mix(in srgb, var(--primary) 7%, transparent);
}

.acc[open] summary .chev {
    transform: rotate(180deg);
    color: var(--primary);
}

.acc[open] summary h3 {
    color: var(--primary);
}

.acc-body {
    padding: 2px 18px 18px;
    color: var(--on-surface-variant);
    font-size: .9375rem;
}

.acc-body p {
    margin: 0;
    text-wrap: pretty;
}

/* Notice ------------------------------------------------------------------ */
.notice {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin: 34px 0 0;
    padding: 16px 18px;
    border-radius: 20px;
    background: var(--tertiary-container);
    color: var(--on-tertiary-container);
}

.notice__ico {
    flex: none;
    display: grid;
    place-items: center;
}

.notice__ico svg {
    width: 22px;
    height: 22px;
}

.notice h2 {
    font-size: .9375rem;
    font-weight: 700;
    margin: 0 0 3px;
}

.notice p {
    margin: 0;
    font-size: .875rem;
    opacity: .9;
    text-wrap: pretty;
}

/* Tool grid — the 404 page lists every tool with one of these. --------------- */
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.related-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 14px 16px;
    border-radius: 20px;
    background: var(--sc-low);
    border: 1px solid var(--outline-variant);
    color: var(--on-surface);
    text-decoration: none;
    transition: background-color .18s, transform .18s var(--ease-spring), box-shadow .18s;
}

.related-card:hover {
    background: var(--sc-high);
    box-shadow: var(--e1);
    transform: translateY(-2px);
}

.related-card .ico {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.related-card .ico svg {
    width: 22px;
    height: 22px;
}

.related-card .txt {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.related-card .txt strong {
    font-size: .9375rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.related-card .txt span {
    font-size: .8125rem;
    color: var(--on-surface-variant);
    line-height: 1.4;
}

.related-card .go {
    margin-inline-start: auto;
    flex: none;
    color: var(--outline);
    display: grid;
    place-items: center;
}

.related-card .go svg {
    width: 18px;
    height: 18px;
}

[dir="rtl"] .related-card .go svg,
[dir="rtl"] .drawer__foot svg {
    transform: scaleX(-1);
}

/* --------------------------------------------------------------------------
   10. Footer
   -------------------------------------------------------------------------- */
.foot {
    max-width: var(--wrap);
    margin: 44px auto 0;
    padding: 28px max(16px, env(safe-area-inset-left)) 34px;
    border-top: 1px solid var(--outline-variant);
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    text-align: center;
}

/* Language switcher --------------------------------------------------------
   It sits at the foot of the page and opens upward. Every entry is a real
   link, so each translation of the current page stays crawlable. */
.lang {
    position: relative;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid var(--outline);
    background: transparent;
    color: var(--on-surface);
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .18s, border-color .18s;
}

.lang-btn:hover {
    background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.lang-btn svg {
    width: 19px;
    height: 19px;
    color: var(--on-surface-variant);
}

.lang-btn .chev {
    display: grid;
    place-items: center;
    transition: transform .28s var(--ease-spring);
}

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

.lang.open .lang-btn .chev {
    transform: rotate(180deg);
}

.lang-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(.9);
    transform-origin: bottom center;
    opacity: 0;
    pointer-events: none;
    background: var(--sc-high);
    border: 1px solid var(--outline-variant);
    border-radius: 18px;
    box-shadow: var(--e3);
    padding: 8px;
    min-width: 224px;
    max-height: min(60vh, 320px);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 50;
    text-align: start;
    transition: opacity .18s var(--ease-std), transform .26s var(--ease-spring);
}

.lang.open .lang-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}

.lang-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    color: var(--on-surface);
    text-decoration: none;
    font-size: .9375rem;
    transition: background-color .15s;
}

.lang-menu a:hover {
    background: color-mix(in srgb, var(--on-surface) 8%, transparent);
}

.lang-menu a[aria-current="true"] {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
    font-weight: 600;
}

.lang-menu .flag {
    font-size: 1.125rem;
    line-height: 1;
    width: 22px;
    text-align: center;
    flex: none;
}

.foot-links {
    font-size: .875rem;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.foot-links a {
    color: var(--on-surface-variant);
}

.copy {
    font-size: .8125rem;
    color: var(--outline);
}

/* --------------------------------------------------------------------------
   11. Toast
   -------------------------------------------------------------------------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
    transform: translate(-50%, 26px);
    opacity: 0;
    pointer-events: none;
    z-index: 80;
    background: var(--inverse-surface);
    color: var(--inverse-on-surface);
    padding: 14px 20px;
    border-radius: 14px;
    box-shadow: var(--e3);
    font-size: .875rem;
    max-width: min(92vw, 460px);
    text-wrap: pretty;
    transition: opacity .22s var(--ease-std), transform .34s var(--ease-spring);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   12. Desktop
   -------------------------------------------------------------------------- */
@media (min-width: 860px) {
    :root {
        --nav-h: 92px;
    }

    .bottom-nav {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: 18px;
        width: auto;
        border-radius: 28px;
        border: 1px solid var(--outline-variant);
        box-shadow: var(--e3);
        padding: 10px 12px;
        gap: 2px;
        justify-content: center;
        background: color-mix(in srgb, var(--sc-high) 90%, transparent);
    }

    .nav-tab {
        flex: 0 0 auto;
        width: 112px;
        padding: 2px 6px 0;
    }

    .nav-tab:hover {
        color: var(--on-surface);
    }

    .wrap {
        padding: 0 24px;
    }

    .toast {
        bottom: calc(var(--nav-h) + 26px);
    }

    .vial--h {
        height: 104px;
        border-radius: 52px;
    }

    .vial--h .bubble {
        width: 74px;
        height: 74px;
        margin: -37px 0 0 -37px;
    }

    .vial--h .groove.a {
        left: calc(50% - 44px);
    }

    .vial--h .groove.b {
        left: calc(50% + 42px);
    }

    .vial--h .tol-zone {
        width: 88px;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
