/* CleverCalculator — Calculator Subpage (from v18) */

/* Atmospheric, category-tinted background glow. This stylesheet loads on
   calculator pages only, so the body rule is effectively page-scoped. */
body::before {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(ellipse 920px 560px at 8% -6%, var(--cat-color-soft), transparent 60%),
        radial-gradient(ellipse 720px 520px at 97% 3%, rgba(37,99,235,0.04), transparent 60%);
}

/* === BREADCRUMB === */
/* Inline at the top of the content — no separate bar, flows straight into
   the title section (matches the v41 layout). */
.breadcrumb {
    padding: calc(var(--header-h) + 22px) 0 0;
}

/* Preview banner — shown on calculator pages when is_published=0 and either
   CC_ENV=development or the cc_preview cookie is set. Sits just below the
   fixed header (margin-top eats the header offset). The adjacent-sibling rule
   below removes the breadcrumb's header-height padding when the banner is
   present — the banner has already handled the offset. */
.preview-banner {
    margin-top: var(--header-h);
    background: #fef3c7;
    color: #78350f;
    padding: 8px 16px;
    text-align: center;
    font: 600 12.5px/1.4 var(--sans);
    border-bottom: 1px solid #fcd34d;
}
.preview-banner + .breadcrumb {
    padding-top: 22px;
}
.breadcrumb nav {
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; color: var(--ink-3);
}
.breadcrumb a {
    color: var(--ink-3); text-decoration: none;
    transition: color 0.15s ease;
}
.breadcrumb a:hover { color: var(--cat-color); }
.breadcrumb .sep { color: var(--ink-3); }
.breadcrumb .current { color: var(--ink-3); }

/* === TITLE SECTION === */
.top-bar { padding: 16px 0 0; }
.calc-head { padding-bottom: 0; }
.calc-head h1 {
    font-size: 34px; font-weight: 700;
    line-height: 1.14; letter-spacing: -0.022em;
    opacity: 0; animation: fadeUp 0.4s ease 0.1s forwards;
}
/* The generic "Calculator"/"Converter" noun renders in serif italic + the
   category accent — a two-tone, editorial headline. */
.calc-head h1 i {
    font-family: var(--serif-italic); font-style: italic;
    font-weight: 500; color: var(--cat-color);
    letter-spacing: 0.005em;
}

/* Lede — one concise sentence under the title; small, sets the tone.
   Wide measure so a short sentence stays on one line; text-wrap:pretty
   keeps the greedy fill but avoids a stranded last word when it wraps. */
.calc-lede {
    margin-top: 9px; max-width: 760px;
    font-size: 14px; line-height: 1.5; color: var(--ink-3);
    text-wrap: pretty;
    opacity: 0; animation: fadeUp 0.4s ease 0.16s forwards;
}

/* Metadata row under the title — category kicker, feature tags and the
   rating cluster, all left-aligned. Reads like an article byline. */
.calc-meta-row {
    display: flex; align-items: center;
    flex-wrap: wrap; gap: 9px 12px;
    margin-top: 16px;
    opacity: 0; animation: fadeUp 0.4s ease 0.22s forwards;
}
.calc-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.calc-cat {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 11.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--cat-color);
}
.calc-cat .cc-sq { width: 7px; height: 7px; background: var(--cat-color); }
.calc-tag {
    font-size: 11.5px; font-weight: 600; color: var(--ink-2);
    padding: 3px 9px;
    border: 1px solid var(--line); background: var(--white);
    white-space: nowrap;
}
/* Hairline divider separating the tag cluster from the rating */
.meta-div { width: 1px; height: 15px; background: var(--line); }

/* Rating — inline cluster (stars + "Rate this" label), part of the meta row */
.calc-rate { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.calc-rate .rating-stars { display: flex; gap: 2.5px; }
.calc-rate .star {
    width: 15px; height: 15px; cursor: pointer; color: var(--line);
    transition: color 0.12s ease, transform 0.12s ease;
}
.calc-rate .star.active,
.calc-rate .star:hover { color: #f59e0b; }
.calc-rate .star:hover { transform: scale(1.14); }
.calc-rate .cr-text {
    font-size: 12px; color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}
.calc-rate .cr-label { font-weight: 600; transition: color 0.12s ease; }
.calc-rate:hover .cr-label { color: var(--ink-2); }
.calc-rate .cr-score strong { color: var(--ink); font-weight: 700; }
.calc-rate .cr-score[hidden] { display: none; }

/* Spectrum bar */
.spectrum-bar {
    display: flex; height: 7px; margin-top: 18px; gap: 0; overflow: hidden;
    opacity: 0; animation: fadeUp 0.4s ease 0.32s forwards;
}
.spectrum-bar .seg { flex: 1; position: relative; }
.spectrum-bar .seg:nth-child(1) { background: var(--c-money); }
.spectrum-bar .seg:nth-child(2) { background: var(--c-health); }
.spectrum-bar .seg:nth-child(3) { background: var(--c-home); }
.spectrum-bar .seg:nth-child(4) { background: var(--c-science); }
.spectrum-bar .seg:nth-child(5) { background: var(--c-nature); }
.spectrum-bar .seg:nth-child(6) { background: var(--c-convert); }
.spectrum-bar .seg:nth-child(7) { background: var(--c-auto); }
.spectrum-bar .seg:nth-child(8) { background: var(--c-everyday); }
.spectrum-bar .seg.active { animation: segPulse 2.5s ease-in-out infinite; }

/* === TWO-COLUMN LAYOUT === */
.two-col { padding: 32px 0 0; }
.two-col .container {
    display: grid; grid-template-columns: 43% 1fr;
    gap: 36px; align-items: start;
}

/* LEFT STICKY — calculator */
.left-col { position: sticky; top: calc(var(--header-h) + 20px); }

/* CALCULATOR CARD */
.calc-card {
    background: var(--white); border: 1px solid var(--line);
    box-shadow: 0 4px 24px rgba(0,0,0,0.04);
}
.calc-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--line);
}
.calc-header h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.calc-header .calc-meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.calc-body { padding: 24px; }

.calc-inputs {
    display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px;
    align-items: end; margin-bottom: 16px;
}
/* When 3+ children (e.g. multi-input physics calculators), stack vertically.
   The 1fr/auto/1fr swap layout only fits 2 fields + button cleanly. */
.calc-inputs:has(> :nth-child(3)) {
    grid-template-columns: 1fr;
}

/* === FIELD: label + input wrapper ===
   .input-wrap is the styling anchor. A custom calc may wrap it in .calc-field,
   .rv-field, .rt-field, .la-fields … — the field styling must NOT depend on
   that outer class, or the calculator renders unstyled. */
.calc-field label {
    display: block; font-size: 11px; font-weight: 600; color: var(--ink-2);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
}
.input-wrap { position: relative; }
.calc-field input, .input-wrap input {
    width: 100%; padding: 14px 44px 14px 14px;
    font: 600 20px var(--sans); color: var(--ink);
    border: 1px solid var(--line); background: var(--bg);
    outline: none; font-variant-numeric: tabular-nums;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.calc-field input:focus, .input-wrap input:focus {
    border-color: var(--cat-color);
    box-shadow: 0 0 0 4px var(--cat-color-soft);
}
.input-wrap .unit {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    font-size: 13px; font-weight: 600; color: var(--ink-3);
    pointer-events: none;
}
/* Currency / symbol prefix shown inside an input (overtime, salary, etc.). */
.input-wrap .prefix {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    font: 700 14px var(--sans); color: var(--ink-3); pointer-events: none;
}
.input-wrap:has(> .prefix) input { padding-left: 38px; }

/* A <select> sitting alone in an .input-wrap is the field's PRIMARY control —
   render it as a proper full-width field, not a tiny chip. */
.input-wrap > select {
    width: 100%; padding: 12px 38px 12px 13px;
    font: 600 15px var(--sans); color: var(--ink);
    border: 1px solid var(--line); background-color: var(--white);
    cursor: pointer; appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239490a0' stroke-width='1.6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.input-wrap > select:hover { border-color: var(--cat-color); }
.input-wrap > select:focus {
    outline: none; border-color: var(--cat-color);
    box-shadow: 0 0 0 4px var(--cat-color-soft);
}
/* …unless the wrap ALSO holds an <input>: then the select is a small inline
   unit picker (nH/μH/mH, Hz/kHz/MHz) — park it as a chip on the input's right. */
.input-wrap:has(> input) select {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    width: auto; padding: 4px 22px 4px 9px;
    font: 600 12px var(--sans);
    background-color: var(--bg-2);
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-position: calc(100% - 11px) 50%, calc(100% - 7px) 50%;
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
}
.input-wrap:has(> input) select:focus {
    outline: 2px solid var(--cat-color-soft); outline-offset: -2px;
    box-shadow: none;
}

/* Baseline for any custom-calc <select> not wrapped in .input-wrap — kills the
   OS-native dropdown chrome and applies the site arrow. Calc-specific rules
   that set explicit padding/colours still win on specificity. */
#calcContainer select:not([data-styled]) {
    appearance: none; -webkit-appearance: none;
    padding: 10px 32px 10px 12px;
    font: 600 14px var(--sans); color: var(--ink);
    border: 1px solid var(--line); background-color: var(--white);
    cursor: pointer; border-radius: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239490a0' stroke-width='1.6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
#calcContainer select:not([data-styled]):hover { border-color: var(--cat-color); }
#calcContainer select:not([data-styled]):focus {
    outline: none; border-color: var(--cat-color);
    box-shadow: 0 0 0 3px var(--cat-color-soft);
}

/* Inline unit-toggle (two small buttons inside an input field, e.g. kg/lb,
   cm/in). Used by health calculators (pediatric-dose, steps-to-miles, etc.). */
.input-wrap .height-unit-toggle,
.input-wrap > .toggle-group {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    display: flex;
    border: 1px solid var(--line);
    background: var(--bg-2);
}
.input-wrap .height-unit-toggle button,
.input-wrap > .toggle-group button {
    padding: 4px 10px;
    font: 600 11px var(--sans);
    background: transparent;
    color: var(--ink-2);
    border: none;
    border-right: 1px solid var(--line);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.input-wrap .height-unit-toggle button:last-child,
.input-wrap > .toggle-group button:last-child { border-right: none; }
.input-wrap .height-unit-toggle button.active,
.input-wrap > .toggle-group button.active {
    background: var(--cat-color); color: var(--white);
}
.input-wrap .height-unit-toggle button:hover:not(.active),
.input-wrap > .toggle-group button:hover:not(.active) {
    background: var(--white);
}
.swap-btn {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: var(--cat-color); color: var(--white);
    border: none; cursor: pointer;
    font-size: 18px; font-weight: 700; margin-bottom: 4px;
    transition: background 0.15s ease, transform 0.15s ease;
}
.swap-btn:hover { background: var(--ink); transform: scale(1.06); }

.calc-controls { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; max-width: 100%; }
.control-group { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
/* Defensive: a select with long option text must never overflow the narrow calc column */
.calc-body select { max-width: 100%; }
.control-group select, .control-group .precision-select { min-width: 0; }
.control-group .clabel {
    font-size: 11px; font-weight: 600; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.toggle-group { display: flex; border: 1px solid var(--line); }
.toggle-group button {
    padding: 6px 12px; font: 600 12px var(--sans);
    background: var(--white); color: var(--ink-2);
    border: none; cursor: pointer;
    border-right: 1px solid var(--line);
    transition: all 0.15s ease;
}
.toggle-group button:last-child { border-right: none; }
.toggle-group button.active { background: var(--cat-color); color: var(--white); }
.toggle-group button:hover:not(.active) { background: var(--bg-2); }
.precision-select {
    padding: 6px 10px; font: 600 12px var(--sans);
    border: 1px solid var(--line); background: var(--white);
    color: var(--ink); cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239490a0' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
    padding-right: 24px;
}

/* Full-width primary <select> for custom calculators — a proper visible field
   control, not the tiny .precision-select chip. */
.calc-select {
    width: 100%; padding: 12px 38px 12px 13px;
    font: 600 15px var(--sans); color: var(--ink);
    border: 1px solid var(--line); background-color: var(--white);
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239490a0' stroke-width='1.6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.calc-select:hover { border-color: var(--cat-color); }
.calc-select:focus {
    outline: none; border-color: var(--cat-color);
    box-shadow: 0 0 0 4px var(--cat-color-soft);
}

.quick-picks { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 16px; }
.quick-picks .qp-label {
    font-size: 11px; font-weight: 600; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.04em;
    display: flex; align-items: center; margin-right: 2px;
}
.quick-pick {
    padding: 5px 10px;
    background: var(--bg); border: 1px solid var(--line);
    font: 500 12px var(--sans); color: var(--ink);
    cursor: pointer; transition: all 0.15s ease;
}
.quick-pick:hover { background: var(--cat-color); color: var(--white); border-color: var(--cat-color); }

.formula-display {
    padding: 14px 16px;
    background: var(--bg-2); border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 14px; flex-wrap: wrap;
}
.formula-display .fd-val { font-weight: 700; font-size: 16px; color: var(--cat-color); font-variant-numeric: tabular-nums; }
.formula-display .fd-eq { color: var(--ink-3); font-weight: 500; }
.formula-display .fd-result { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.formula-display .fd-val, .formula-display .fd-result { min-width: 0; overflow-wrap: anywhere; }

/* === RIGHT COLUMN === */
.right-col { min-width: 0; }

/* TAB BAR (sticky) */
.tab-bar {
    position: sticky; top: var(--header-h); z-index: 50;
    background: rgba(250,250,248,0.92); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex; gap: 0; margin-bottom: 32px;
}
.tab-btn {
    padding: 14px 18px; font: 600 13px var(--sans); color: var(--ink-3);
    background: none; border: none; cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--cat-color); border-bottom-color: var(--cat-color); }

/* TAB SECTIONS */
.tab-section {
    margin-bottom: 56px;
    scroll-margin-top: calc(var(--header-h) + 60px);
}
.tab-section h2 {
    font-size: 24px; font-weight: 700; letter-spacing: -0.02em;
    margin-bottom: 20px; line-height: 1.2;
}
.tab-section h3 {
    font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
    margin: 24px 0 10px; line-height: 1.3;
}
.tab-section p { font-size: 15px; color: var(--ink-2); line-height: 1.7; margin-bottom: 14px; }

/* INSTRUCTIONS — compact horizontal step rows (kept understated so the
   calculator stays the focus). Display-only: article HTML is unchanged.
   Grid: number in col 1 (spans both rows), title + description stacked in col 2. */
/* Quiet modern stepper — numbers linked by a hairline, no boxes. */
.steps-grid { display: flex; flex-direction: column; gap: 0; margin-bottom: 20px; }
.step-card {
    background: none; border: 0; padding: 0 0 20px 0; text-align: left;
    display: grid; grid-template-columns: 26px 1fr;
    column-gap: 15px; row-gap: 3px;
    position: relative;
}
.step-card::before {
    content: ''; position: absolute; left: 12.5px; top: 31px; bottom: 0;
    width: 1.5px; background: var(--line);
}
.step-card:last-child { padding-bottom: 0; }
.step-card:last-child::before { display: none; }
.step-num {
    width: 26px; height: 26px; border-radius: 50%;
    grid-row: 1 / span 2; align-self: start; margin: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--cat-color-soft); color: var(--cat-color);
    font-size: 12px; font-weight: 700;
    position: relative; z-index: 1; flex-shrink: 0;
}
.step-card h3 {
    grid-column: 2;
    font-size: 14.5px; font-weight: 700; margin: 3px 0 0;
    letter-spacing: -0.01em; line-height: 1.32;
}
.step-card p {
    grid-column: 2;
    font-size: 13px; color: var(--ink-2); line-height: 1.58; margin: 0;
}
.tip-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.tip-item {
    background: var(--bg-2); border: 0;
    padding: 14px 16px; font-size: 13px; color: var(--ink-2); line-height: 1.6;
}
.tip-item strong { color: var(--ink); }

/* FORMULA CARDS — DARK */
/* minmax(0,1fr) — not 1fr — so a wide formula can't force the cell wider than
   its share (the cell content then scrolls via .katex-display overflow-x). */
.formula-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.formula-card-dark {
    background: var(--ink); color: var(--white);
    padding: 20px 18px; position: relative; overflow: hidden;
}
.formula-card-dark::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(79,70,229,0.15), transparent 60%);
    pointer-events: none;
}
.formula-card-dark .fcd-title {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: rgba(255,255,255,0.5); margin-bottom: 10px; position: relative;
}
.formula-card-dark .fcd-formula {
    font-size: 15px; margin-bottom: 8px; min-height: 32px;
    display: flex; align-items: center; position: relative;
    overflow-x: auto; overflow-y: hidden;
    /* subtle scrollbar so a wide formula on the dark card doesn't jar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.22) transparent;
}
.formula-card-dark .fcd-formula::-webkit-scrollbar { height: 5px; }
.formula-card-dark .fcd-formula::-webkit-scrollbar-track { background: transparent; }
.formula-card-dark .fcd-formula::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
.formula-card-dark .fcd-formula::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.34); }
.formula-card-dark .fcd-formula .katex { color: var(--white); }
.formula-card-dark .fcd-desc {
    font-size: 12px; color: rgba(255,255,255,0.55); line-height: 1.5; position: relative;
}

/* REFERENCE */
.qref-card { background: var(--white); border: 1px solid var(--line); margin-bottom: 20px; }
.qref-card .qref-header {
    padding: 12px 18px; border-bottom: 1px solid var(--line);
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-3); background: var(--bg-2);
}
.qref-table { width: 100%; border-collapse: collapse; }
.qref-table th {
    padding: 8px 14px; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-3); text-align: left; background: var(--bg);
    border-bottom: 1px solid var(--line);
}
.qref-table td {
    padding: 7px 14px; font-size: 12px; font-variant-numeric: tabular-nums;
    border-bottom: 1px solid var(--line-soft);
}
.qref-table tr:last-child td { border-bottom: none; }
.qref-table td:first-child { font-weight: 600; }
.qref-table td:nth-child(2), .qref-table td:nth-child(3) { color: var(--ink-2); }

.tables-side { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.table-block { background: var(--white); border: 1px solid var(--line); }
.table-block .tb-header {
    padding: 12px 16px; border-bottom: 1px solid var(--line);
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; gap: 8px; background: var(--bg-2);
}
.table-block .tb-header .flag { font-size: 18px; }
.conv-table { width: 100%; border-collapse: collapse; }
.conv-table th {
    padding: 8px 14px; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-3); text-align: left; background: var(--bg);
    border-bottom: 1px solid var(--line);
}
.conv-table td {
    padding: 7px 14px; font-size: 13px; font-variant-numeric: tabular-nums;
    border-bottom: 1px solid var(--line-soft);
}
.conv-table tr:last-child td { border-bottom: none; }
.conv-table td:first-child { font-weight: 600; }
.conv-table td:nth-child(2) { color: var(--ink-2); }

/* Default styling for any <table> in tab content (reference data, article
   tables) — covers plain tables AND ad-hoc classes like .ref-table. The two
   purpose-built table classes (.qref-table, .conv-table) are excluded so they
   keep their own styling. */
.tab-section table:not(.qref-table):not(.conv-table) {
    width: 100%; border-collapse: collapse;
    margin: 18px 0; font-size: 13px;
    border: 1px solid var(--line);
}
.tab-section table:not(.qref-table):not(.conv-table) th,
.tab-section table:not(.qref-table):not(.conv-table) td {
    padding: 8px 12px; text-align: left;
    border-bottom: 1px solid var(--line-soft);
    border-right: 1px solid var(--line-soft);
}
.tab-section table:not(.qref-table):not(.conv-table) th:last-child,
.tab-section table:not(.qref-table):not(.conv-table) td:last-child { border-right: none; }
.tab-section table:not(.qref-table):not(.conv-table) tr:last-child td { border-bottom: none; }
.tab-section table:not(.qref-table):not(.conv-table) th {
    background: var(--bg-2);
    font: 700 11px var(--sans);
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--ink-2);
    border-bottom: 1px solid var(--line);
}
.tab-section table:not(.qref-table):not(.conv-table) td { color: var(--ink-2); }
.tab-section table:not(.qref-table):not(.conv-table) td:first-child { color: var(--ink); font-weight: 600; }
.tab-section table:not(.qref-table):not(.conv-table) tbody tr:nth-child(even) { background: var(--bg-2); }

/* A wide KaTeX display formula must scroll inside its own box, never poke out
   of the article column. */
.tab-section .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 0;
}

/* ARTICLE */
.article-content h3 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin: 28px 0 10px; line-height: 1.3; }
.article-content p { font-size: 15px; color: var(--ink-2); line-height: 1.7; margin-bottom: 14px; }
.article-content p.lead { font-size: 17px; line-height: 1.65; color: var(--ink); }

/* Default list styling for ALL tab sections (instructions, formulas, reference,
   article, faq). Plain <ul>/<ol> without a class get category-coloured bullets
   and numbers. `<ul class="fact-list">` and `.inline-toc ol` override this with
   their own layouts. */
.tab-section ul:not([class]),
.tab-section ol:not([class]) {
    margin: 14px 0 18px 0;
    font-size: 15px; color: var(--ink-2); line-height: 1.65;
}
.tab-section ul:not([class]) { list-style: none; padding-left: 0; }
.tab-section ul:not([class]) > li {
    position: relative; padding: 4px 0 4px 22px;
}
.tab-section ul:not([class]) > li::before {
    content: ''; position: absolute; left: 4px; top: 14px;
    width: 6px; height: 6px; background: var(--cat-color);
}
.tab-section ol:not([class]) { list-style: none; padding-left: 0; counter-reset: alist; }
.tab-section ol:not([class]) > li {
    position: relative; counter-increment: alist;
    padding: 4px 0 4px 32px;
}
.tab-section ol:not([class]) > li::before {
    content: counter(alist) ".";
    position: absolute; left: 0; top: 4px;
    font-weight: 700; color: var(--cat-color);
    font-variant-numeric: tabular-nums;
    min-width: 24px;
}
.tab-section ul:not([class]) > li strong:first-child,
.tab-section ol:not([class]) > li strong:first-child { color: var(--ink); }

/* Inline TOC — the inner <ol> has no class, so the generic `.tab-section ol`
   rules above also match it (and outrank a bare `.inline-toc` selector). These
   rules are scoped with `.tab-section` to win, and use a flex row so the number
   and the title share a baseline instead of drifting apart. */
.tab-section .inline-toc {
    background: var(--white); border: 1px solid var(--line);
    padding: 18px 22px; margin-bottom: 28px;
}
.tab-section .inline-toc .itoc-title {
    font-size: 12px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px;
}
.tab-section .inline-toc ol {
    list-style: none; counter-reset: toc;
    margin: 0; padding: 0;
}
.tab-section .inline-toc ol > li {
    counter-increment: toc;
    display: flex; align-items: baseline; gap: 8px;
    padding: 5px 0;
    break-inside: avoid;
}
.tab-section .inline-toc ol > li::before {
    content: counter(toc) ".";
    /* override the generic `.tab-section ol li::before` absolute positioning
       so this becomes a normal flex item beside the title */
    position: static;
    flex-shrink: 0; min-width: 20px;
    font-weight: 700; color: var(--cat-color);
    font-size: 13px; line-height: 1.5;
    font-variant-numeric: tabular-nums;
}
.tab-section .inline-toc a {
    font-size: 13px; line-height: 1.5;
    color: var(--ink-2); text-decoration: none;
    transition: color 0.15s ease;
}
.tab-section .inline-toc a:hover { color: var(--cat-color); }

/* "Did You Know" dark callout */
.callout-dark { padding: 20px 22px; background: var(--ink); color: var(--white); margin: 22px 0; position: relative; }
.callout-dark .cd-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    color: rgba(255,255,255,0.6); margin-bottom: 8px;
    text-decoration: underline; text-decoration-color: var(--cat-color);
    text-underline-offset: 4px; text-decoration-thickness: 2px;
}
.callout-dark p, .callout-dark blockquote {
    font-family: var(--serif-italic); font-style: italic; font-size: 15px;
    color: rgba(255,255,255,0.85); line-height: 1.6; margin-bottom: 0;
}

/* Warning card */
.warning-bottom {
    padding: 16px 18px; background: var(--c-health-soft); border: 0;
    margin: 14px 0;
}
.warning-bottom .wb-title {
    font-size: 14px; font-weight: 700; margin-bottom: 6px;
    display: flex; align-items: center; gap: 8px;
}
.warning-bottom .wb-title .wicon { color: var(--c-health); font-size: 16px; }
.warning-bottom p { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin-bottom: 0; }

/* Tip bullet */
.tip-bullet { padding: 16px 18px; background: var(--cat-color-soft); margin: 14px 0; }
.tip-bullet .tb-label {
    font-size: 12px; font-weight: 700; color: var(--ink);
    text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.tip-bullet .tb-label::before { content: '\25CF'; color: var(--cat-color); margin-right: 8px; font-size: 10px; }
.tip-bullet p { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin-bottom: 0; }

/* Comparison viz */
.comparison-viz { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.comp-col { background: var(--white); border: 1px solid var(--line); padding: 18px; text-align: center; }
.comp-col .comp-flag { font-size: 28px; margin-bottom: 6px; }
.comp-col .comp-label {
    font-size: 11px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px;
}
.comp-col .comp-bar { height: 6px; background: var(--bg-2); margin-bottom: 6px; }
.comp-col .comp-bar i { display: block; height: 100%; background: var(--cat-color); }
.comp-col .comp-val { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.comp-col .comp-detail { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

/* Country cards */
.country-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.country-card { background: var(--white); border: 1px solid var(--line); padding: 12px 10px; text-align: center; }
.country-card .cc-flag { font-size: 22px; margin-bottom: 4px; }
.country-card .cc-name { font-size: 12px; font-weight: 600; }
.country-card .cc-system { font-size: 11px; color: var(--ink-3); }

/* Icon list */
.icon-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0; }
.icon-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: var(--white); border: 1px solid var(--line);
    font-size: 13px; font-weight: 500;
}
.icon-item .ii-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: var(--cat-color-soft); font-size: 15px; flex-shrink: 0;
}

/* Fact list — bordered card of key/explanation rows.
   Each <li> starts with a <strong> (the value); rest is explanatory prose. */
.article-content ul.fact-list {
    list-style: none; margin: 22px 0; padding: 0;
    background: var(--white); border: 1px solid var(--line);
}
.article-content ul.fact-list li {
    display: flex; align-items: baseline; gap: 18px;
    padding: 12px 18px;
    font-size: 14px; line-height: 1.55; color: var(--ink-2);
    border-bottom: 1px solid var(--line);
    margin: 0;
    transition: background 0.15s ease;
}
.article-content ul.fact-list li:last-child { border-bottom: none; }
.article-content ul.fact-list li:hover { background: var(--bg-2); }
.article-content ul.fact-list li strong:first-child {
    flex: 0 0 auto; min-width: 96px; padding-right: 16px;
    font-weight: 700; color: var(--ink); font-size: 14px;
    font-variant-numeric: tabular-nums; letter-spacing: -0.005em;
    border-right: 2px solid var(--cat-color);
}
@media (max-width: 600px) {
    .article-content ul.fact-list li { flex-direction: column; gap: 4px; padding: 10px 14px; }
    .article-content ul.fact-list li strong:first-child {
        border-right: none; border-left: 3px solid var(--cat-color);
        padding: 0 0 0 10px; min-width: 0;
    }
}

/* Cheat sheet */
.cheat-sheet { background: var(--bg-2); border: 1px solid var(--line); padding: 18px 20px; margin: 20px 0; }
.cheat-sheet .cs-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.cheat-sheet code {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.cheat-sheet .cs-row {
    display: flex; justify-content: space-between;
    padding: 3px 0; border-bottom: 1px solid var(--line-soft);
}
.cheat-sheet .cs-row:last-child { border-bottom: none; }

/* FAQ accordion */
.faq-list { margin-top: 14px; }
.faq-item { border: 1px solid var(--line); background: var(--white); margin-bottom: 9px; }
.faq-question {
    display: flex; align-items: center; gap: 12px;
    padding: 15px 18px; cursor: pointer;
    width: 100%; text-align: left;
    background: none; border: none;
    font: 600 14.5px var(--sans); color: var(--ink);
    transition: background 0.15s ease;
}
.faq-question:hover { background: var(--bg); }
.faq-question .fq-num {
    flex-shrink: 0;
    font-size: 11px; font-weight: 700; color: var(--cat-color);
    font-variant-numeric: tabular-nums;
}
.faq-question .fq-text { flex: 1; }
.faq-question .fq-arrow {
    width: 14px; height: 14px; flex-shrink: 0;
    transition: transform 0.22s ease; color: var(--ink-3);
}
.faq-item.open .fq-arrow { transform: rotate(180deg); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.faq-item.open .faq-answer { max-height: 800px; }
.faq-answer-inner { padding: 0 18px 16px 42px; font-size: 14px; color: var(--ink-2); line-height: 1.65; }

/* RELATED */
.related-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.related-card {
    background: var(--white); border: 1px solid var(--line);
    padding: 16px; text-decoration: none; color: var(--ink);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.related-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.05); }
.related-card .rc-cat {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.related-card .rc-dot { width: 5px; height: 5px; }
.related-card h3 { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 4px; }
.related-card p { font-size: 12px; color: var(--ink-2); line-height: 1.5; margin-bottom: 0; }

/* PDF BUTTON — hidden until the first calculation runs (revealed by app JS) */
.calc-extras { padding: 18px 0 4px; }
.pdf-button {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; background: var(--bg-2); border: 1px solid var(--line);
    font: 600 13px var(--sans); color: var(--ink);
    text-decoration: none; cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pdf-button[hidden] { display: none; }
.pdf-button:hover { background: var(--ink); color: var(--white); border-color: var(--ink); }
.pdf-button svg { width: 14px; height: 14px; }

/* SOURCES SECTION */
.sources-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}
.sources-section h3 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    margin-bottom: 12px;
}
.sources-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sources-section li {
    font-size: 13px;
    color: var(--ink-2);
    padding-left: 16px;
    position: relative;
}
.sources-section li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--cat-color, var(--ink-3));
}
.sources-section a {
    color: var(--ink-2);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    transition: color 0.15s, border-color 0.15s;
}
.sources-section a:hover {
    color: var(--cat-color, var(--ink));
    border-color: var(--cat-color, var(--ink));
}

/* === RELATED CALCULATORS — full-width section below the calculator === */
.related-calcs {
    background: var(--bg-2);
    border-top: 1px solid var(--line);
    margin-top: 52px;
    padding: 48px 0 62px;
}
/* Heading: "Related <Category>" — the category name set in Newsreader
   italic and the accent colour so it carries the section. */
.rc-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 24px; margin-bottom: 26px;
    padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.rc-head h2 {
    font-size: 27px; font-weight: 700;
    letter-spacing: -0.02em; line-height: 1.15;
}
.rc-head h2 em {
    font-family: var(--serif-italic); font-style: italic;
    font-weight: 500; color: var(--cat-color);
    letter-spacing: -0.01em;
}
.rc-viewall {
    flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 600; color: var(--cat-color);
    text-decoration: none;
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease, gap 0.15s ease;
}
.rc-viewall svg { width: 13px; height: 13px; }
.rc-viewall:hover { border-color: var(--cat-color); gap: 11px; }

.rc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.rc-card {
    position: relative;
    background: var(--white);
    border: 1px solid var(--line);
    padding: 19px 18px 16px;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    min-height: 162px;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.rc-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--cat-color);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.22s ease;
}
/* Index marker — a quiet editorial touch in the accent colour */
.rc-idx {
    font-size: 12px; font-weight: 700;
    font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
    color: var(--cat-color); opacity: 0.38;
    margin-bottom: 10px;
    transition: opacity 0.18s ease;
}
.rc-card h3 {
    font-size: 14.5px; font-weight: 700;
    letter-spacing: -0.01em; line-height: 1.32;
    margin-bottom: 6px;
}
.rc-card p {
    font-size: 12px; color: var(--ink-2);
    line-height: 1.5; margin: 0 0 auto;
}
.rc-go {
    margin-top: 14px;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-3);
    transition: color 0.15s ease, gap 0.15s ease;
}
.rc-go svg { width: 11px; height: 11px; }
.rc-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.07);
    border-color: var(--cat-color);
}
.rc-card:hover::before { transform: scaleY(1); }
.rc-card:hover .rc-idx { opacity: 1; }
.rc-card:hover .rc-go { color: var(--cat-color); gap: 9px; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .two-col .container { grid-template-columns: 1fr; }
    .left-col { position: static; }
    .steps-grid { grid-template-columns: 1fr; }
    .formula-grid { grid-template-columns: 1fr; }
    .tables-side { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: repeat(2, 1fr); }
    .rc-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    /* Tab nav stops being sticky on mobile (otherwise it eats viewport when
       you scroll into the article tab). Buttons wrap instead of side-scrolling
       so the user doesn't have to swipe horizontally to find Formulas/FAQ. */
    .tab-bar {
        position: static; top: auto;
        background: transparent; backdrop-filter: none;
        border-bottom: 1px solid var(--line);
        flex-wrap: wrap; gap: 2px;
        overflow-x: visible;
    }
    .tab-btn {
        padding: 10px 14px; font-size: 12.5px;
        flex: 0 0 auto;
    }

    /* Wide article tables — keep their semantic layout but scroll horizontally
       instead of breaking page width. `display: block` lets the table itself
       act as scroll container; explicit `display: table` on tbody/thead/tfoot
       preserves column widths so cells don't collapse. Covers all three table
       classes used in articles: plain, .qref-table, .conv-table. */
    .tab-section table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .tab-section table > thead,
    .tab-section table > tbody,
    .tab-section table > tfoot {
        display: table;
        width: max-content;
        min-width: 100%;
    }
}
@media (max-width: 600px) {
    .calc-head h1 { font-size: 26px; }
    .calc-lede { font-size: 15px; }
    .rc-head { flex-direction: column; align-items: flex-start; gap: 10px; }
    .rc-head h2 { font-size: 23px; }
    .calc-inputs { grid-template-columns: 1fr; }
    .swap-btn { margin: 0 auto; transform: rotate(90deg); }
    .comparison-viz { grid-template-columns: 1fr; }
    .country-cards { grid-template-columns: repeat(2, 1fr); }
    .icon-list { grid-template-columns: 1fr; }
    .tip-row { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: 1fr; }
    .rc-grid { grid-template-columns: 1fr; }
}

/* === ARTICLE MODULES — modern lift + cleanup === */
/* card modules: a soft shadow lifts them off the surface (no accent bars) */
.fact-list,
.comp-col,
.country-card,
.icon-item {
    box-shadow: 0 1px 2px rgba(20,18,24,0.04), 0 16px 32px -20px rgba(20,18,24,0.24);
}
.cheat-sheet {
    background: var(--white);
    box-shadow: 0 1px 2px rgba(20,18,24,0.04), 0 16px 32px -20px rgba(20,18,24,0.24);
}
/* hide icon containers emptied by display-time icon-stripping */
.comp-flag:empty,
.cc-flag:empty,
.wicon:empty,
.ii-icon:empty { display: none; }
/* article lead paragraph — an editorial standfirst, not plain body text */
.article-content .lead {
    font-size: 17.5px; line-height: 1.6; color: var(--ink);
    letter-spacing: -0.011em; margin: 2px 0 20px;
}

/* inline hint under a number input when the browser rejects the typed value
   (comma decimal separator etc.) — injected by calculator-core.js */
.cc-decimal-hint {
    display: block; font-size: 12px; line-height: 1.4; margin-top: 4px;
    color: #b45309;
}
