/* ==========================================================
   CALCULATOR SILO
   Components for the 15 dedicated calculator pages and the
   /calculators/ hub. Built on the tokens declared in
   homepage.css — this file adds, it never redefines them.
   ========================================================== */

.calc-page {
    background: var(--clr-bg);
    color: var(--clr-text);
    font-family: var(--font-sans);
    line-height: 1.65;
}

.calc-page main {
    padding-top: 68px;
}

.calc-page .container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
}


/* ==========================================================
   HEADER — CALCULATORS DROPDOWN
   ========================================================== */

/* The header-inner uses space-between, which on wide screens strands a
   short nav in the dead centre with big empty gaps either side. Push the
   nav (and the toggle after it) to the right so it groups against the
   theme toggle — the standard, balanced header layout. Scoped to
   .calc-page so the homepage header is untouched. */
.calc-page .nav {
    margin-left: auto;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-dropdown-toggle svg {
    transition: transform var(--dur-md) var(--ease-out);
}

.nav-dropdown.open .nav-dropdown-toggle svg {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    width: min(760px, calc(100vw - 32px));
    padding: var(--space-xl);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity var(--dur-md) var(--ease-out),
        transform var(--dur-md) var(--ease-out),
        visibility var(--dur-md);
    z-index: 120;
}

.nav-dropdown.open .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xl);
}

.nav-dropdown-col ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-dropdown-heading {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: var(--clr-text-dim);
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-sm);
    border-bottom: 1px solid var(--clr-border);
}

.nav-dropdown-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    margin-left: -9px;
    border-radius: var(--radius-sm);
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--clr-text-secondary);
    transition: all var(--dur-fast);
}

.nav-dropdown-link:hover {
    background: var(--clr-accent-soft);
    color: var(--clr-accent);
}

.nav-dropdown-link.current {
    color: var(--clr-accent);
    font-weight: 600;
}

.nav-dropdown-glyph {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 4px;
    background: var(--clr-surface-2);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--clr-text-muted);
}

.nav-dropdown-link:hover .nav-dropdown-glyph,
.nav-dropdown-link.current .nav-dropdown-glyph {
    background: rgba(var(--accent-rgb), 0.12);
    color: var(--clr-accent);
}

.nav-dropdown-all {
    display: block;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--clr-border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--clr-accent);
}

.nav-dropdown-all:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}


/* ==========================================================
   PAGE HEAD — BREADCRUMB + HERO
   ========================================================== */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--clr-text-muted);
    margin-bottom: var(--space-xl);
}

.breadcrumb a {
    color: var(--clr-text-muted);
    transition: color var(--dur-fast);
}

.breadcrumb a:hover {
    color: var(--clr-accent);
}

.breadcrumb span[aria-hidden] {
    color: var(--clr-text-dim);
}

.breadcrumb [aria-current] {
    color: var(--clr-text);
    font-weight: 500;
}

.calc-hero {
    padding: var(--space-2xl) 0 var(--space-xl);
}

.calc-hero-inner {
    max-width: 720px;
}

.calc-hero-title {
    font-size: clamp(2rem, 4.4vw, 3.05rem);
    line-height: 1.08;
    color: var(--clr-text);
    margin-bottom: var(--space-lg);
}

.calc-hero-intro {
    font-size: 1.08rem;
    line-height: 1.72;
    color: var(--clr-text-secondary);
}

.calc-hero-formula {
    display: inline-flex;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding: 7px 7px 7px var(--space-md);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xs);
}

.calc-hero-formula-label {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--clr-text-dim);
}

.calc-hero-formula-value {
    padding: 3px 14px;
    border-radius: var(--radius-full);
    background: var(--clr-accent-soft);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--clr-accent);
    white-space: nowrap;
}


/* ==========================================================
   THE CALCULATOR CARD
   ========================================================== */
.calc-tool {
    padding: var(--space-md) 0 var(--space-4xl);
    scroll-margin-top: 90px;
}

.calc-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Mode switcher along the top of the card */
.calc-modes {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-surface-2);
    overflow-x: auto;
    scrollbar-width: none;
}

.calc-modes::-webkit-scrollbar {
    display: none;
}

.calc-mode {
    flex: 1 0 auto;
    min-width: max-content;
    padding: var(--space-md) var(--space-xl);
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--dur-fast);
}

.calc-mode:hover {
    color: var(--clr-text);
    background: var(--clr-accent-softer);
}

.calc-mode[aria-pressed='true'] {
    color: var(--clr-accent);
    background: var(--clr-surface);
    border-bottom-color: var(--clr-accent);
}

.calc-body {
    padding: var(--space-2xl);
}

.calc-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-2xl);
    background: var(--clr-accent-softer);
    border: 1px solid rgba(var(--accent-rgb), 0.12);
    border-left: 3px solid var(--clr-accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.86rem;
    line-height: 1.6;
    color: var(--clr-text-secondary);
}

.calc-note strong {
    color: var(--clr-text);
}

.calc-note code,
.calc-note kbd {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--clr-surface-2);
    border: 1px solid var(--clr-border);
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--clr-accent);
}


/* ── Field primitives ── */
.calc-fields {
    display: grid;
    gap: var(--space-lg) var(--space-xl);
}

.calc-fields.cols-2 { grid-template-columns: repeat(2, 1fr); }
.calc-fields.cols-3 { grid-template-columns: repeat(3, 1fr); }
.calc-fields.cols-4 { grid-template-columns: repeat(4, 1fr); }

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.field-label {
    display: flex;
    align-items: baseline;
    gap: 7px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--clr-text-muted);
}

.field-label .field-tag {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--clr-accent);
}

.field-hint {
    font-size: 0.75rem;
    color: var(--clr-text-dim);
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
}

.input {
    width: 100%;
    padding: 12px var(--space-md);
    background: var(--clr-bg-warm);
    border: 1px solid var(--clr-surface-3);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 1.02rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--clr-text);
    transition: all var(--dur-fast) var(--ease-out);
}

.input::placeholder {
    color: var(--clr-text-dim);
    font-weight: 400;
}

.input:focus {
    outline: none;
    border-color: var(--clr-accent);
    background: var(--clr-surface);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.input.is-error {
    border-color: var(--clr-error);
    background: var(--clr-error-bg);
}

.input.is-target {
    border-color: var(--clr-accent);
    border-style: dashed;
    background: var(--clr-accent-softer);
    color: var(--clr-accent);
}

.input-sm {
    padding: 9px var(--space-sm);
    font-size: 0.92rem;
    text-align: center;
}

select.input {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    cursor: pointer;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% + 1px),
        calc(100% - 13px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 38px;
}


/* ── The A/B = C/D fraction rig ── */
.rig {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-lg);
    padding: var(--space-lg) 0 var(--space-2xl);
}

.rig-term {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    width: 148px;
    flex-shrink: 0;
}

.rig-term .input {
    text-align: center;
    font-size: 1.2rem;
    padding: 13px var(--space-sm);
}

.rig-bar {
    height: 2px;
    border-radius: 2px;
    background: var(--clr-text-dim);
    opacity: 0.55;
}

.rig-op {
    font-family: var(--font-display);
    font-size: 2rem;
    line-height: 1;
    color: var(--clr-text-muted);
    flex-shrink: 0;
    padding: 0 2px;
}

.rig-cap {
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--clr-text-dim);
}


/* ── Inline ratio strip (a : b : c …) ── */
.strip {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-md) 0 var(--space-xl);
}

.strip-item {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 106px;
}

.strip-item .input {
    text-align: center;
}

.strip-colon {
    font-family: var(--font-display);
    font-size: 1.6rem;
    line-height: 1;
    padding-bottom: 12px;
    color: var(--clr-text-muted);
}


/* ── Actions row ── */
.calc-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 26px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.btn-solid {
    background: var(--clr-accent);
    border-color: var(--clr-accent-deep);
    color: #fff;
}

.btn-solid:hover {
    background: var(--clr-accent-deep);
    transform: translateY(-1px);
}

[data-theme='dark'] .btn-solid {
    color: #12261f;
    border-color: transparent;
}

.btn-ghost {
    background: var(--clr-surface-2);
    border-color: var(--clr-border);
    color: var(--clr-text-secondary);
}

.btn-ghost:hover {
    border-color: var(--clr-border-hover);
    color: var(--clr-text);
}

.btn-link {
    padding: 0;
    background: none;
    border: none;
    color: var(--clr-accent);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(var(--accent-rgb), 0.35);
}

.btn-link:hover {
    text-decoration-color: currentColor;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px dashed var(--clr-border);
}

.chips-label {
    width: 100%;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--clr-text-dim);
    margin-bottom: 2px;
}

.chip {
    padding: 6px 14px;
    background: var(--clr-surface-2);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--clr-text-secondary);
    cursor: pointer;
    transition: all var(--dur-fast);
}

.chip:hover {
    background: var(--clr-accent-soft);
    border-color: var(--clr-accent-light);
    color: var(--clr-accent);
}

.chip[aria-pressed='true'] {
    background: var(--clr-accent);
    border-color: var(--clr-accent-deep);
    color: #fff;
}

[data-theme='dark'] .chip[aria-pressed='true'] {
    color: #12261f;
}


/* ==========================================================
   OUTPUT
   ========================================================== */
.out {
    margin-top: var(--space-2xl);
    border: 1px solid var(--clr-success-border);
    border-radius: var(--radius-lg);
    background: var(--clr-success-bg);
    overflow: hidden;
    animation: outIn 0.32s var(--ease-out) both;
}

@keyframes outIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.out-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--clr-success-border);
    background: rgba(21, 112, 79, 0.05);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: var(--clr-success);
}

.out-body {
    padding: var(--space-xl);
}

.out-headline {
    font-family: var(--font-mono);
    font-size: clamp(1.35rem, 3.4vw, 1.85rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
    color: var(--clr-text);
    word-break: break-word;
}

.out-sub {
    margin-top: 6px;
    font-size: 0.9rem;
    color: var(--clr-text-secondary);
    line-height: 1.65;
}

.out-sub strong {
    color: var(--clr-text);
}

/* Metric tiles */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.metric {
    padding: var(--space-md);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
}

.metric-label {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: var(--clr-text-dim);
    margin-bottom: 5px;
}

.metric-value {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--clr-text);
    word-break: break-word;
}

.metric-value.accent {
    color: var(--clr-accent);
}

/* Equation restatement */
.out-eq {
    display: block;
    margin-top: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    color: var(--clr-text-secondary);
    overflow-x: auto;
    white-space: nowrap;
}

/* Step-by-step working */
.steps {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px dashed var(--clr-success-border);
}

.steps-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: var(--clr-text-muted);
    margin-bottom: var(--space-lg);
}

.step {
    display: flex;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.08);
}

.step:last-child {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
}

.step-n {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--clr-accent);
}

.step-final .step-n {
    background: var(--clr-accent);
    border-color: var(--clr-accent-deep);
    color: #fff;
}

[data-theme='dark'] .step-final .step-n {
    color: #12261f;
}

.step-text {
    min-width: 0;
    font-size: 0.86rem;
    color: var(--clr-text-secondary);
    line-height: 1.55;
}

.step-math {
    display: block;
    margin-top: 5px;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
    color: var(--clr-text);
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
}

.step-math strong {
    color: var(--clr-accent);
}

/* Error panel */
.err {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: var(--space-2xl);
    padding: var(--space-lg);
    background: var(--clr-error-bg);
    border: 1px solid var(--clr-error-border);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--clr-error);
    animation: nudge 0.3s var(--ease-out);
}

.err svg {
    flex-shrink: 0;
    margin-top: 1px;
}

@keyframes nudge {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

.is-hidden {
    display: none !important;
}


/* ── Verdict badge (proportional / not proportional) ── */
.verdict {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.verdict-yes {
    background: rgba(21, 112, 79, 0.1);
    border: 1px solid var(--clr-success-border);
    color: var(--clr-success);
}

.verdict-no {
    background: rgba(var(--clay-rgb), 0.1);
    border: 1px solid rgba(var(--clay-rgb), 0.28);
    color: var(--clr-clay);
}

/* Neutral output shell for "check" style answers */
.out.out-neutral {
    border-color: var(--clr-border);
    background: var(--clr-surface-2);
}

.out.out-neutral .out-head {
    border-bottom-color: var(--clr-border);
    background: transparent;
    color: var(--clr-text-muted);
}

.out.out-neutral .steps {
    border-top-color: var(--clr-border);
}


/* ── Result tables (equivalent ratios, value tables, shares) ── */
.out-table-wrap {
    margin-top: var(--space-lg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    background: var(--clr-surface);
    overflow-x: auto;
}

.out-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.out-table th {
    padding: 10px var(--space-md);
    text-align: left;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: var(--clr-text-muted);
    background: var(--clr-surface-2);
    border-bottom: 1px solid var(--clr-border);
    white-space: nowrap;
}

.out-table td {
    padding: 10px var(--space-md);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--clr-text-secondary);
    border-bottom: 1px solid var(--clr-border);
    white-space: nowrap;
}

.out-table tbody tr:last-child td {
    border-bottom: none;
}

.out-table tbody tr:hover td {
    background: var(--clr-accent-softer);
}

.out-table tr.row-mark td {
    background: rgba(var(--accent-rgb), 0.07);
    color: var(--clr-text);
    font-weight: 600;
}

/* Proportion bar — parts of a whole */
.bar {
    display: flex;
    height: 34px;
    margin-top: var(--space-lg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--clr-border);
    background: var(--clr-surface);
}

.bar-seg {
    display: grid;
    place-items: center;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    white-space: nowrap;
    transition: flex-basis var(--dur-slow) var(--ease-out);
}

/* Six sequential tints of the one brand hue — a scale, not a rainbow */
.bar-seg:nth-child(1) { background: #0d413b; }
.bar-seg:nth-child(2) { background: #12564e; }
.bar-seg:nth-child(3) { background: #1a7d70; }
.bar-seg:nth-child(4) { background: #3d9c8c; }
.bar-seg:nth-child(5) { background: #67b8aa; }
.bar-seg:nth-child(6) { background: #96d2c7; color: #0d413b; }

.bar-key {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.bar-key-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--clr-text-secondary);
}

.bar-key-swatch {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Aspect-ratio preview frame */
.frame-wrap {
    display: grid;
    place-items: center;
    min-height: 190px;
    margin-top: var(--space-lg);
    padding: var(--space-lg);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    background-image:
        linear-gradient(var(--clr-surface-2) 1px, transparent 1px),
        linear-gradient(90deg, var(--clr-surface-2) 1px, transparent 1px);
    background-size: 18px 18px;
}

.frame {
    display: grid;
    place-items: center;
    max-width: 100%;
    max-height: 190px;
    border: 2px solid var(--clr-accent);
    border-radius: 4px;
    background: rgba(var(--accent-rgb), 0.07);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--clr-accent);
    transition: all var(--dur-slow) var(--ease-out);
}

/* Inline SVG graph shell */
.graph {
    margin-top: var(--space-lg);
    padding: var(--space-lg);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
}

.graph svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.graph-axis   { stroke: var(--clr-text-dim); stroke-width: 1; }
.graph-grid   { stroke: var(--clr-border); stroke-width: 1; }
.graph-curve  { stroke: var(--clr-accent); stroke-width: 2; fill: none; stroke-linecap: round; }
.graph-fill   { fill: rgba(var(--accent-rgb), 0.08); }
.graph-dot    { fill: var(--clr-clay); }
.graph-dot-2  { fill: var(--clr-accent); }
.graph-label  { fill: var(--clr-text-muted); font-family: var(--font-mono); font-size: 9px; }

/* Cross-multiplication diagram */
.cross-viz {
    margin-top: var(--space-lg);
    padding: var(--space-xl) var(--space-lg);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
}

.cross-viz svg {
    display: block;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    height: auto;
}

.cross-num  { fill: var(--clr-text); font-family: var(--font-mono); font-size: 17px; font-weight: 600; }
.cross-rule { stroke: var(--clr-text-dim); stroke-width: 1.6; }
.cross-eq   { fill: var(--clr-text-muted); font-family: var(--font-display); font-size: 22px; }
.cross-arm-a { stroke: var(--clr-accent); stroke-width: 1.6; stroke-dasharray: 4 3; }
.cross-arm-b { stroke: var(--clr-clay); stroke-width: 1.6; stroke-dasharray: 4 3; }
.cross-tag-a { fill: var(--clr-accent); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.cross-tag-b { fill: var(--clr-clay); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }


/* ==========================================================
   PROSE / CONTENT SECTIONS
   ========================================================== */
.sec {
    padding: var(--space-4xl) 0;
    scroll-margin-top: 90px;
}

.sec-tint {
    background: var(--clr-bg-alt);
}

.sec-head {
    max-width: 680px;
    margin-bottom: var(--space-2xl);
}

.sec-head.center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.sec-eyebrow {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--clr-clay);
    margin-bottom: var(--space-md);
}

.sec-title {
    font-family: var(--font-display);
    font-size: clamp(1.55rem, 3vw, 2.15rem);
    font-weight: 500;
    line-height: 1.18;
    letter-spacing: -0.015em;
    color: var(--clr-text);
}

.sec-lede {
    margin-top: var(--space-md);
    font-size: 1.02rem;
    line-height: 1.72;
    color: var(--clr-text-secondary);
}

.prose {
    max-width: 720px;
    font-size: 1rem;
    line-height: 1.78;
    color: var(--clr-text-secondary);
}

.prose > * + * {
    margin-top: var(--space-lg);
}

.prose h3 {
    font-family: var(--font-display);
    font-size: 1.28rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--clr-text);
    margin-top: var(--space-2xl);
}

.prose strong {
    color: var(--clr-text);
    font-weight: 600;
}

.prose a {
    color: var(--clr-accent);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(var(--accent-rgb), 0.35);
}

.prose a:hover {
    text-decoration-color: currentColor;
}

.prose ul,
.prose ol {
    padding-left: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.prose li::marker {
    color: var(--clr-accent);
}

.prose code {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--clr-surface-2);
    border: 1px solid var(--clr-border);
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--clr-accent);
}

/* Formula plate — a framed equation */
.plate {
    padding: var(--space-xl);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-left: 3px solid var(--clr-accent);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    box-shadow: var(--shadow-sm);
}

.plate-eq {
    font-family: var(--font-mono);
    font-size: clamp(1.1rem, 2.6vw, 1.45rem);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--clr-text);
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
}

.plate-note {
    margin-top: var(--space-md);
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--clr-text-muted);
}

.plate-note strong {
    color: var(--clr-text-secondary);
}

/* Two-column split */
.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3xl);
    align-items: start;
}

.split-tight {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: var(--space-3xl);
    align-items: start;
}

/* Card grid */
.cards {
    display: grid;
    gap: var(--space-lg);
}

.cards.c2 { grid-template-columns: repeat(2, 1fr); }
.cards.c3 { grid-template-columns: repeat(3, 1fr); }
.cards.c4 { grid-template-columns: repeat(4, 1fr); }

.card {
    padding: var(--space-xl);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: all var(--dur-md) var(--ease-out);
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.card-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: var(--space-md);
    border-radius: var(--radius-sm);
    background: var(--clr-accent-soft);
    border: 1px solid rgba(var(--accent-rgb), 0.14);
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--clr-accent);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--clr-text);
    margin-bottom: 7px;
}

.card-text {
    font-size: 0.88rem;
    line-height: 1.68;
    color: var(--clr-text-muted);
}

.card-text strong {
    color: var(--clr-text-secondary);
}

.card-eq {
    display: block;
    margin-top: var(--space-md);
    padding: 9px var(--space-md);
    background: var(--clr-surface-2);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
    color: var(--clr-text);
    overflow-x: auto;
    white-space: nowrap;
}

/* Numbered how-it-works list */
.numbered {
    counter-reset: nlist;
    display: grid;
    gap: var(--space-lg);
}

.numbered-item {
    counter-increment: nlist;
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: var(--space-md);
    align-items: start;
}

.numbered-item::before {
    content: counter(nlist, decimal-leading-zero);
    display: grid;
    place-items: center;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--clr-accent);
}

.numbered-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--clr-text);
    margin-bottom: 4px;
    padding-top: 6px;
}

.numbered-text {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--clr-text-muted);
}

.numbered-text code {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--clr-surface-2);
    border: 1px solid var(--clr-border);
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--clr-accent);
}

/* Worked example */
.worked {
    padding: var(--space-xl);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.worked-tag {
    display: inline-block;
    padding: 3px 11px;
    margin-bottom: var(--space-md);
    border-radius: var(--radius-full);
    background: var(--clr-clay-soft);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    color: var(--clr-clay);
}

.worked-q {
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1.55;
    color: var(--clr-text);
    margin-bottom: var(--space-lg);
}

.worked-lines {
    display: grid;
    gap: 9px;
    padding-top: var(--space-md);
    border-top: 1px solid var(--clr-border);
}

.worked-line {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: var(--space-md);
    align-items: baseline;
    font-size: 0.85rem;
}

.worked-line dt {
    color: var(--clr-text-muted);
}

.worked-line dd {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--clr-text);
    overflow-x: auto;
    white-space: nowrap;
}

.worked-answer {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--clr-border);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--clr-accent);
}

/* Reference table */
.ref-wrap {
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    background: var(--clr-surface);
    box-shadow: var(--shadow-card);
    overflow-x: auto;
}

.ref {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.ref th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--clr-accent);
    background: var(--clr-accent-soft);
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.18);
    white-space: nowrap;
}

.ref td {
    padding: var(--space-md) var(--space-lg);
    color: var(--clr-text-secondary);
    border-bottom: 1px solid var(--clr-border);
    vertical-align: top;
}

.ref td:first-child {
    font-weight: 600;
    color: var(--clr-text);
    white-space: nowrap;
}

.ref .mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ref tbody tr:last-child td {
    border-bottom: none;
}

.ref tbody tr:hover td {
    background: var(--clr-accent-softer);
}

/* Comparison pair */
.versus {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.versus-side {
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    border: 1px solid var(--clr-border);
    background: var(--clr-surface);
}

.versus-side.is-a { border-top: 3px solid var(--clr-accent); }
.versus-side.is-b { border-top: 3px solid var(--clr-clay); }

.versus-name {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--clr-text);
    margin-bottom: 5px;
}

.versus-eq {
    font-family: var(--font-mono);
    font-size: 0.86rem;
    color: var(--clr-text-muted);
    margin-bottom: var(--space-lg);
}

.versus-list {
    display: grid;
    gap: 9px;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--clr-text-secondary);
    list-style: none;
}

.versus-list li {
    display: grid;
    grid-template-columns: 15px 1fr;
    gap: 9px;
}

.versus-list li::before {
    content: '—';
    color: var(--clr-text-dim);
}


/* ==========================================================
   FAQ
   ========================================================== */
.faq-wrap {
    max-width: 760px;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.faq-item {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--dur-md);
}

.faq-item[open] {
    border-color: var(--clr-border-hover);
    box-shadow: var(--shadow-sm);
}

.faq-q {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--clr-text);
    cursor: pointer;
    list-style: none;
    transition: color var(--dur-fast);
}

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

.faq-q:hover { color: var(--clr-accent); }

.faq-q::after {
    content: '+';
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--clr-surface-2);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--clr-text-dim);
    transition: all var(--dur-md) var(--ease-out);
}

.faq-item[open] .faq-q::after {
    content: '−';
    background: var(--clr-accent-soft);
    color: var(--clr-accent);
}

.faq-a {
    padding: 0 var(--space-xl) var(--space-lg);
    font-size: 0.92rem;
    line-height: 1.78;
    color: var(--clr-text-muted);
}

.faq-a strong { color: var(--clr-text-secondary); }

.faq-a code {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--clr-surface-2);
    border: 1px solid var(--clr-border);
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--clr-accent);
}

.faq-a a {
    color: var(--clr-accent);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
}


/* ==========================================================
   RELATED CALCULATORS + HUB GRID
   ========================================================== */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
    gap: var(--space-md);
}

.tool {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: all var(--dur-md) var(--ease-out);
}

.tool:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card-hover);
    border-color: rgba(var(--accent-rgb), 0.3);
}

.tool-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--space-md);
}

.tool-glyph {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--clr-accent-soft);
    border: 1px solid rgba(var(--accent-rgb), 0.14);
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--clr-accent);
    transition: all var(--dur-md);
}

.tool:hover .tool-glyph {
    background: var(--clr-accent);
    border-color: var(--clr-accent-deep);
    color: #fff;
}

[data-theme='dark'] .tool:hover .tool-glyph {
    color: #12261f;
}

.tool-formula {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--clr-text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-name {
    font-size: 0.96rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--clr-text);
    margin-bottom: 6px;
}

.tool:hover .tool-name {
    color: var(--clr-accent);
}

.tool-blurb {
    font-size: 0.84rem;
    line-height: 1.62;
    color: var(--clr-text-muted);
    margin-bottom: var(--space-md);
}

.tool-go {
    margin-top: auto;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--clr-accent);
}

.tool-link {
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.tool-link span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.tool.tool-current {
    border-color: rgba(var(--accent-rgb), 0.35);
    background: var(--clr-accent-softer);
}

.tool-badge {
    align-self: flex-start;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    background: var(--clr-accent);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #fff;
}

[data-theme='dark'] .tool-badge { color: #12261f; }


/* ==========================================================
   FOOTER — WIDER GRID FOR THE SILO
   ========================================================== */
.footer-grid-calc {
    display: grid;
    grid-template-columns: 1.4fr repeat(4, 1fr);
    gap: var(--space-xl);
}


/* ==========================================================
   HUB PAGE
   ========================================================== */
.hub-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xl);
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--clr-border);
}

.hub-stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 500;
    line-height: 1;
    color: var(--clr-accent);
}

.hub-stat-label {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--clr-text-muted);
}

.hub-group {
    padding-top: var(--space-3xl);
}

.hub-group-head {
    display: flex;
    align-items: baseline;
    gap: var(--space-md);
    flex-wrap: wrap;
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-xl);
    border-bottom: 1px solid var(--clr-border);
}

.hub-group-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--clr-text);
}

.hub-group-note {
    font-size: 0.88rem;
    color: var(--clr-text-muted);
}

.hub-group-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--clr-text-dim);
    white-space: nowrap;
}


/* ==========================================================
   CTA STRIP
   ========================================================== */
.cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-lg);
    padding: var(--space-xl) var(--space-2xl);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.cta-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--clr-text);
    margin-bottom: 4px;
}

.cta-text {
    font-size: 0.9rem;
    color: var(--clr-text-muted);
    max-width: 46ch;
}


/* ==========================================================
   REVEAL ANIMATION
   ========================================================== */
.reveal-up {
    opacity: 0;
    transform: translateY(16px);
    transition:
        opacity 0.5s var(--ease-out),
        transform 0.5s var(--ease-out);
}

.reveal-up.shown {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .reveal-up,
    .reveal-up.shown {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .out,
    .err {
        animation: none;
    }
}


/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 1024px) {
    .nav-dropdown-menu {
        width: min(600px, calc(100vw - 32px));
    }

    .nav-dropdown-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid-calc {
        grid-template-columns: repeat(3, 1fr);
    }

    .cards.c4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .split,
    .split-tight,
    .versus {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .cards.c3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .calc-page main { padding-top: 60px; }

    .calc-page .container { padding: 0 var(--space-lg); }

    /* Mobile nav: the dropdown becomes a plain nested list */
    .nav {
        position: fixed;
        top: 61px;
        left: 0;
        right: 0;
        max-height: calc(100vh - 61px);
        overflow-y: auto;
        flex-direction: column;
        gap: 2px;
        padding: var(--space-lg);
        background: var(--nav-mobile-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--clr-border);
        transform: translateY(-12px);
        opacity: 0;
        visibility: hidden;
        transition: all var(--dur-md) var(--ease-out);
    }

    .nav.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-link {
        width: 100%;
        text-align: left;
        padding: var(--space-md);
        font-size: 0.95rem;
    }

    .nav-dropdown { width: 100%; }

    .nav-dropdown-toggle { justify-content: space-between; }

    .nav-dropdown-menu {
        position: static;
        width: 100%;
        transform: none;
        padding: 0;
        margin: 0;
        background: none;
        border: none;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        display: none;
    }

    .nav-dropdown.open .nav-dropdown-menu {
        display: block;
        transform: none;
    }

    .nav-dropdown-grid {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
        padding: var(--space-md) 0 var(--space-md) var(--space-md);
    }

    .mobile-menu-btn { display: flex; }

    .calc-body { padding: var(--space-xl) var(--space-lg); }

    .calc-mode { padding: var(--space-md) var(--space-lg); font-size: 0.8rem; }

    .calc-fields.cols-3,
    .calc-fields.cols-4 { grid-template-columns: repeat(2, 1fr); }

    .rig { gap: var(--space-md); }

    .rig-term { width: 118px; }

    .rig-term .input { font-size: 1.05rem; }

    .footer-grid-calc { grid-template-columns: repeat(2, 1fr); }

    .cards.c2,
    .cards.c3,
    .cards.c4 { grid-template-columns: 1fr; }

    .sec { padding: var(--space-3xl) 0; }

    .hub-stats { gap: var(--space-xl); }

    .worked-line { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 520px) {
    .calc-fields.cols-2,
    .calc-fields.cols-3,
    .calc-fields.cols-4 { grid-template-columns: 1fr; }

    .rig { flex-direction: column; }

    .rig-term { width: 100%; max-width: 220px; }

    .rig-op { transform: rotate(90deg); }

    .strip-item { width: 78px; }

    .footer-grid-calc { grid-template-columns: 1fr; }

    .calc-actions .btn { width: 100%; }

    .cta { flex-direction: column; align-items: flex-start; }

    .metrics { grid-template-columns: 1fr 1fr; }
}
