/* ==========================================================================
   CalcHub — design system
   Restrained financial-institution look: cool grey canvas with white cards
   floating on it, generous whitespace, one hue per calculator category, and
   typography doing most of the work.
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Fallback tuned to Inter's metrics so the swap does not move anything.
   Values are Inter's own ascent/descent against Arial's em box. */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Segoe UI'), local('Helvetica Neue'), local('Arial'), local('Roboto');
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22.4%;
  line-gap-override: 0%;
}

:root {
  /* Cool grey canvas with pure white cards floating on it. White-on-white
     gave nothing for the cards to sit against, which is what made the whole
     page read flat. Change --bg alone to retune the whole site. */
  --bg: #eef1f6;
  --bg-tint: #e6eaf2;
  --surface: #ffffff;
  --surface-2: #f4f6fa;

  /* hairlines, not borders */
  --line: #e3e7ee;
  --line-strong: #d3d9e4;

  /* ink */
  --text: #0a0b0d;
  --text-2: #5b6270;
  --text-3: #8f95a3;

  /* accent */
  --accent: #2f54eb;
  --accent-hover: #1f3fd0;
  --accent-ink: #ffffff;
  --accent-soft: #e3e9ff;
  --accent-line: #c7d3fb;
  --accent-2: #7c4dff;

  /* one hue per category — colour that means something */
  --c-finance: #2f54eb;  --c-finance-soft: #e3e9ff;  --c-finance-ink: #2545cf;
  --c-math:    #7c4dff;  --c-math-soft:    #ebe4ff;  --c-math-ink:    #6636e6;
  --c-health:  #0f9d6e;  --c-health-soft:  #d8f1e6;  --c-health-ink:  #086445;
  --c-date:    #e08700;  --c-date-soft:    #fbecc9;  --c-date-ink:    #8a5200;
  --c-home:    #0d7f8c;  --c-home-soft:    #d5eef1;  --c-home-ink:    #0a5b64;

  --good: #0f9d6e;
  --warn: #e08700;
  --bad: #e0453e;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;

  /* shadows are barely there — depth comes from hairlines and space */
  --shadow-1: 0 1px 2px rgba(20, 28, 48, .05), 0 1px 1px rgba(20, 28, 48, .03);
  --shadow-2: 0 1px 2px rgba(20, 28, 48, .05), 0 6px 16px -6px rgba(20, 28, 48, .10);
  --shadow-3: 0 2px 4px rgba(20, 28, 48, .06), 0 18px 40px -16px rgba(20, 28, 48, .18);

  /* Frosted header: a translucent white bar blurring the colour wash that
     sits at the top of every page. --wash-a/-b tune the two colour blooms. */
  --header: rgba(255, 255, 255, .62);
  --header-ink: #0a0b0d;
  --header-dim: #3b4252;
  --wash-a: rgba(47, 84, 235, .26);
  --wash-b: rgba(124, 77, 255, .22);
  --wash-h: 420px;

  --maxw: 1120px;
  --measure: 66ch;
  --font: 'Inter', 'Inter Fallback', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
    --bg: #0b0c0f;
    --bg-tint: #101116;
    --surface: #14161b;
    --surface-2: #191b22;
    --line: #23252d;
    --line-strong: #2e313b;

    --text: #f0f1f4;
    --text-2: #a0a6b4;
    --text-3: #737a89;

    --accent: #8fa6ff;
    --accent-hover: #a8b9ff;
    --accent-ink: #0b0c0f;
    --accent-soft: #161a2c;
    --accent-line: #283154;

    --good: #37c48a;
    --warn: #e0a340;
    --bad: #ef6a6a;

    --header: rgba(20, 22, 27, .72);
    --header-ink: #f0f1f4;
    --header-dim: #a0a6b4;
    --wash-a: rgba(47, 84, 235, .20);
    --wash-b: rgba(124, 77, 255, .16);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 1px 3px rgba(0, 0, 0, .5), 0 8px 24px -12px rgba(0, 0, 0, .7);
  --shadow-3: 0 2px 6px rgba(0, 0, 0, .5), 0 20px 48px -20px rgba(0, 0, 0, .8);

  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

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

/* colour bloom across the top of the page — the header blurs this */
body::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--wash-h);
  background:
    radial-gradient(760px 300px at 20% -60px, var(--wash-a), transparent 72%),
    radial-gradient(760px 300px at 80% -30px, var(--wash-b), transparent 72%);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
@media (max-width: 560px) { .wrap { padding: 0 18px; } }

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.15; letter-spacing: -.028em; }
h1 { font-size: clamp(30px, 4.6vw, 42px); }
h2 { font-size: clamp(20px, 2.4vw, 25px); margin: 44px 0 14px; }
h3 { font-size: 16px; margin: 28px 0 8px; letter-spacing: -.015em; }

/* the small-caps label used throughout */
.field label, .result .label, .viz-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .82);
  background: var(--header);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, .55);
}
.site-header .logo { color: var(--header-ink); }
.site-header .logo-mark { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); }
.site-header .logo-mark svg { stroke: #fff; }
.site-header .wrap { display: flex; align-items: center; gap: 10px; height: 64px; }

.logo { display: flex; align-items: center; gap: 10px; font-size: 16.5px; font-weight: 600; letter-spacing: -.028em; color: var(--text); }
.logo:hover .logo-mark { transform: scale(1.06) rotate(-4deg); }
.logo:hover { text-decoration: none; }
.logo-text { white-space: nowrap; }
.logo-text > span { color: var(--accent); }
.logo-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 3px 10px -1px color-mix(in srgb, var(--accent) 55%, transparent), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .18s ease;
}
.logo-mark svg { width: 27px; height: 27px; stroke: #fff; }

/* ==========================================================================
   Hero — search only
   ========================================================================== */
.hero {
  position: relative;
  padding: 60px 0 10px;
  text-align: center;
}

.search { position: relative; max-width: 540px; margin: 0 auto; }
.search input {
  width: 100%;
  height: 52px;
  padding: 0 88px 0 46px;
  font-family: inherit;
  font-size: 15.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r);
  box-shadow: var(--shadow-2);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:hover { border-color: var(--text-3); }
.search input:focus { border-color: var(--accent); box-shadow: var(--shadow-2), 0 0 0 3px var(--accent-soft); }

.search > svg {
  position: absolute; left: 16px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  stroke: var(--text-3);
  pointer-events: none;
}
.search:focus-within > svg { stroke: var(--accent); }

.hint-key {
  position: absolute; right: 16px; top: 50%;
  transform: translateY(-50%);
  min-width: 21px; padding: 2px 6px;
  font: 500 11.5px/1.4 var(--mono);
  text-align: center;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  pointer-events: none;
}
.clear-btn {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--text-3);
  background: transparent;
  border: 0; border-radius: 50%;
  cursor: pointer;
}
.clear-btn:hover { color: var(--text); background: var(--surface-2); }
.clear-btn svg { width: 13px; height: 13px; }

.search-count { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--text-3); }

/* ==========================================================================
   Layout
   ========================================================================== */
/* One centred column. The sidebar was taking 276px from the tool and
   duplicating navigation that the header, menu and related cards already
   carry. */
.page { padding: 28px 0 72px; }

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}
.crumbs .sep { color: var(--line-strong); }
.crumbs a { color: var(--text-3); }
.crumbs .back { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }
.crumbs .back:hover { color: var(--ink, var(--accent)); text-decoration: none; }
.crumbs .back .rev { width: 14px; height: 14px; stroke: currentColor; transform: rotate(180deg); transition: transform .15s; }
.crumbs .back:hover .rev { transform: rotate(180deg) translateX(2px); }
.crumbs .cat-tag { color: var(--ink, var(--text-2)); font-weight: 600; }
.crumbs a:hover { color: var(--accent); }

.page-head { margin: 16px 0 30px; }
.lede { margin: 16px 0 0; max-width: 60ch; font-size: 16.5px; line-height: 1.6; color: var(--text-2); }
.page-title { margin: 34px 0 0; font-size: 15px; font-weight: 600; letter-spacing: -.015em; color: var(--text-3); }

/* ==========================================================================
   Tool
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.tool {
  padding: 26px 28px;
  border-color: transparent;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
@media (max-width: 560px) { .tool { padding: 18px; } }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
@media (max-width: 680px) { .grid2, .grid3 { grid-template-columns: 1fr; gap: 14px; } }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { display: block; }
.field .hint { font-size: 10.5px; font-weight: 500; letter-spacing: .04em; color: var(--text-3); text-transform: none; }

input[type="number"], input[type="text"], input[type="date"], select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
input:hover, select:hover { border-color: var(--text-3); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f95a3' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}

.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.inline select { width: 96px; flex: none; }

/* tabs — underline, not pills */
.tabs {
  display: flex;
  gap: 24px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  padding: 0 0 11px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-3);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color .15s;
}
.tab::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: transparent;
  transition: background .15s;
}
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 600; }
.tab[aria-selected="true"]::after { background: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 42px; padding: 0 18px;
  font-family: inherit; font-size: 14px; font-weight: 550;
  color: #fff;
  background: var(--accent);
  border: 0; border-radius: var(--r-sm);
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-variant-numeric: tabular-nums;
}
.btn.ghost:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.btn.ghost:active { background: var(--accent-soft); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ==========================================================================
   Result — ink on white, framed by a hairline. The number is the design.
   ========================================================================== */
.result {
  position: relative;
  margin-top: 32px;
  padding: 26px 28px 28px;
  /* one flat tint all the way down — a fade to white left an awkward pale
     band under the figures */
  background: var(--tint, var(--accent-soft));
  border: 1px solid transparent;
  border-radius: var(--r);
}
@media (max-width: 560px) { .result { padding: 20px; } }

/* the copy/print buttons sit top-right, so the heading and figure reserve
   room for them and can never run underneath */
.result .label {
  display: block;
  color: var(--ink, var(--accent));
}
.result .big {
  margin-top: 8px;
  font-size: clamp(32px, 6.2vw, 46px);
  font-weight: 600;
  letter-spacing: -.04em;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow-wrap: anywhere;
}

.result .note {
  margin-top: 12px;
  max-width: 62ch;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-2);
}

/* Stats: even grid, no vertical rules. Dividers broke alignment as soon as
   the grid wrapped — every row after the first kept a stray left border. */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 22px 28px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line-strong);
}
.stat { min-width: 0; }
.stat .v {
  display: block;
  font-size: 18px; font-weight: 600; letter-spacing: -.025em;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow-wrap: anywhere;
}
.stat .k {
  display: block;
  margin-top: 5px;
  font-size: 12px; line-height: 1.4;
  color: var(--text-3);
}
.stat .v.pos { color: var(--good); }
.stat .v.neg { color: var(--warn); }

.result-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 32px;
}
.result-head .label { margin: 0; }
.result-tools { margin-left: auto; display: flex; gap: 6px; flex: none; }
.copy-btn, .print-btn {
  position: relative;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.copy-btn:hover, .print-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.copy-btn svg, .print-btn svg { width: 15px; height: 15px; }
.copy-btn.done::after {
  content: "Copied";
  position: absolute; right: 0; top: 38px;
  padding: 4px 9px;
  font-size: 11px; font-weight: 550;
  color: var(--surface);
  background: var(--text);
  border-radius: 5px;
  white-space: nowrap;
}

.err {
  margin-top: 16px;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--bad);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--bad);
  border-radius: var(--r-sm);
}

/* ==========================================================================
   Charts
   ========================================================================== */
.viz {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  margin-top: 28px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.viz.stack { grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (max-width: 640px) { .viz { grid-template-columns: minmax(0, 1fr); gap: 20px; justify-items: center; } }

.viz-title { grid-column: 1 / -1; margin: 0 0 -6px; }

.chart-donut { width: 156px; height: 156px; flex: none; }
.chart-donut .donut-v { font: 600 24px var(--font); letter-spacing: -.03em; fill: var(--text); }
.chart-donut .donut-k { font: 600 10.5px var(--font); letter-spacing: .09em; text-transform: uppercase; fill: var(--text-3); }

.chart-area { width: 100%; height: 140px; display: block; }
.chart-gauge { width: 100%; height: 60px; display: block; }
.chart-gauge .gauge-t { font: 500 10.5px var(--font); fill: var(--text-3); }
.chart-gauge .gauge-pin { fill: var(--text); }

.chart-split { display: flex; height: 36px; border-radius: var(--r-sm); overflow: hidden; }
.chart-split .seg {
  display: grid; place-items: center;
  min-width: 3px;
  font-size: 12px; font-weight: 600; color: #fff;
  transition: width .3s ease;
}

.legend { list-style: none; margin: 0; padding: 0; min-width: 0; }
.legend li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.legend li:last-child { border-bottom: 0; }
.legend i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.legend .lk { color: var(--text-2); }
.legend .lv { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }

.band-key { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12.5px; color: var(--text-3); }
.band-key span { display: inline-flex; align-items: center; gap: 7px; }
.band-key i { width: 8px; height: 8px; border-radius: 2px; }
.band-key span.on { color: var(--text); font-weight: 600; }

.bars { display: flex; gap: 3px; align-items: flex-end; height: 80px; margin-top: 18px; }
.bars .b { flex: 1; min-height: 2px; background: var(--accent-line); border-radius: 2px 2px 0 0; transition: height .3s ease; }
.bars .b:last-child { background: var(--accent); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-scroll { margin-top: 20px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  padding: 11px 16px 11px 0;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
th:first-child, td:first-child { text-align: left; }
th:last-child, td:last-child { padding-right: 0; }
thead th {
  font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 9px;
}
tbody td { border-bottom: 1px solid var(--line); color: var(--text-2); }
tbody td:first-child { color: var(--text); font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }

tbody tr.you td { color: var(--text); }
tbody tr.you td:first-child { font-weight: 600; }
.you-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  font-size: 10px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  vertical-align: 1px;
}

/* collapsible schedules */
.drawer { margin-top: 24px; border-top: 1px solid var(--line); }
.drawer > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 0 0;
  font-size: 14px; font-weight: 550;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}
.drawer > summary::-webkit-details-marker { display: none; }
.drawer > summary:hover { color: var(--accent); }
.drawer > summary::after {
  content: "";
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s;
}
.drawer[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }

/* ==========================================================================
   Guide — collapsed; the summary IS the button
   ========================================================================== */
/* A quiet disclosure at a section boundary, not a floating chip. The button
   still shrink-wraps its own text, so clicking the empty space beside it does
   nothing. */
.guide {
  margin: 34px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.guide-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  padding: 2px 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, var(--accent));
  background: none;
  border: 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.guide-btn::-webkit-details-marker { display: none; }
.guide-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.guide-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.guide-btn svg { flex: none; width: 15px; height: 15px; stroke: currentColor; }
.guide-btn::after {
  content: "";
  width: 6px; height: 6px;
  margin-left: 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s;
}
.guide[open] .guide-btn::after { transform: rotate(-135deg) translateY(-1px); }

.guide-body {
  margin-top: 20px;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}
.guide-body .content { margin-top: 0; }
.guide-body .content + .content { margin-top: 34px; }
.guide-body .faqs { margin-top: 30px; }

/* ==========================================================================
   Long-form
   ========================================================================== */
.content { max-width: var(--measure); }
.page > .content, .guide-body .content { max-width: var(--measure); }
.content p { margin: 0 0 14px; color: var(--text-2); }
.content strong { color: var(--text); font-weight: 600; }
.content code {
  font-family: var(--mono); font-size: .87em;
  padding: 1px 5px;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 4px;
}
.content .table-scroll { max-width: none; }

.facts { list-style: none; margin: 20px 0 0; padding: 0; }
.facts li {
  position: relative;
  padding: 0 0 0 20px;
  margin-bottom: 11px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-2);
}
.facts li::before {
  content: "";
  position: absolute;
  left: 2px; top: 9px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-line);
}
.facts strong { color: var(--text); font-weight: 600; }

.formula {
  margin: 20px 0;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  color: var(--text);
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  overflow-x: auto;
}

.faq { border-bottom: 1px solid var(--line); }
.faq:first-of-type { border-top: 1px solid var(--line); }
.faq summary {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 0;
  font-size: 15px; font-weight: 550;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { color: var(--accent); }
.faq summary::after {
  content: "";
  flex: none; margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s;
}
.faq[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.faq p { margin: 0; padding: 0 0 16px; font-size: 14.5px; color: var(--text-2); max-width: 62ch; }

.disclaimer {
  display: flex; gap: 12px;
  margin-top: 26px;
  padding: 14px 16px;
  font-size: 13.5px; line-height: 1.55;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.disclaimer svg { flex: none; width: 16px; height: 16px; stroke: var(--warn); margin-top: 2px; }

.section-rule {
  margin: 52px 0 18px;
  font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3);
}

/* ==========================================================================
   Calculator cards
   ========================================================================== */
.cat-head { display: flex; align-items: baseline; gap: 14px; margin: 44px 0 18px; }
.cat-head h2 { margin: 0; font-size: 18px; }
.cat-head::before {
  content: "";
  width: 4px; height: 18px;
  border-radius: 2px;
  background: var(--hue, var(--accent));
  align-self: center;
}
.cat-head span { font-size: 13.5px; color: var(--text-3); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px;
}

.calc-card {
  position: relative;
  display: block;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.calc-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--tint, var(--accent-line));
  box-shadow: var(--shadow-2);
}
.calc-card .ico {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  margin-bottom: 14px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
}
.calc-card .ico svg { width: 18px; height: 18px; stroke: var(--accent); }
.calc-card .t { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.calc-card .d { display: block; margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: var(--text-3); }
.calc-card .go {
  position: absolute; top: 20px; right: 20px;
  width: 15px; height: 15px;
  stroke: var(--text-3);
  opacity: 0;
  transition: opacity .15s, transform .15s;
}
.calc-card:hover .go { opacity: 1; transform: translateX(2px); stroke: var(--accent); }

.no-results { padding: 40px; text-align: center; color: var(--text-3); font-size: 15px; }

/* ==========================================================================
   Category colour — each family of calculators has its own hue
   ========================================================================== */
[data-cat="Finance"] { --hue: var(--c-finance); --tint: var(--c-finance-soft); --ink: var(--c-finance-ink); }
[data-cat="Math"]    { --hue: var(--c-math);    --tint: var(--c-math-soft);    --ink: var(--c-math-ink); }
[data-cat="Health"]  { --hue: var(--c-health);  --tint: var(--c-health-soft);  --ink: var(--c-health-ink); }
[data-cat="Date"]    { --hue: var(--c-date);    --tint: var(--c-date-soft);    --ink: var(--c-date-ink); }
[data-cat="Home"]    { --hue: var(--c-home);    --tint: var(--c-home-soft);    --ink: var(--c-home-ink); }

.calc-card[data-cat] .ico { background: var(--tint); }
.calc-card[data-cat] .ico svg { stroke: var(--hue); }
.calc-card[data-cat]:hover .go { stroke: var(--hue); }
.tool[data-cat] .tab[aria-selected="true"]::after { background: var(--hue); }
.tool[data-cat] input:focus,
.tool[data-cat] select:focus { border-color: var(--hue); box-shadow: 0 0 0 3px var(--tint); }
.tool[data-cat] .formula { border-left-color: var(--hue); }
.tool[data-cat] .bars .b:last-child { background: var(--hue); }

/* sidebar entries carry their own hue */

:root[data-theme="dark"] [data-cat="Finance"] { --tint: #131a33; --ink: #93a9ff; }
:root[data-theme="dark"] [data-cat="Math"]    { --tint: #1b1630; --ink: #b79cff; }
:root[data-theme="dark"] [data-cat="Health"]  { --tint: #10241d; --ink: #4fd3a0; }
:root[data-theme="dark"] [data-cat="Date"]    { --tint: #2a1f0e; --ink: #f0bb45; }
:root[data-theme="dark"] [data-cat="Home"]    { --tint: #0e2427; --ink: #4fc4d1; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 36px;
  margin: 64px 0 8px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}
.feature .ico { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 14px; border-radius: var(--r-sm); background: var(--accent-soft); }
.feature .ico svg { width: 16px; height: 16px; stroke: var(--accent); }
.feature h3 { margin: 0 0 6px; font-size: 14.5px; }
.feature p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--text-3); }

/* ==========================================================================
   Ads — reserved space, nothing drawn until enabled
   ========================================================================== */
.ad { display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ad-top { min-height: 90px; margin: 18px 0 0; }
.ad-inline { min-height: 250px; margin: 48px 0; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { margin-top: 56px; padding: 26px 0; border-top: 1px solid var(--line-strong); }
.foot-line {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px 24px;
  font-size: 13px;
  color: var(--text-3);
}
.foot-line a { color: var(--text-3); }
.foot-line a:hover { color: var(--accent); text-decoration: none; }

/* the parent brand reads as part of the copyright, not as another link */
.foot-parent { font-weight: 600; color: var(--text-2); }
.foot-parent:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Print — a clean schedule sheet, no site chrome
   ========================================================================== */
@media print {
  .site-header, .site-footer, .ad, .hero, .crumbs,
  .result-tools, .cards, .section-rule, .tabs, .guide { display: none !important; }

  body { background: #fff; color: #000; font-size: 11pt; }
  .page { display: block; padding: 0; }
  .wrap { max-width: none; padding: 0; }

  .card, .tool, .viz, .drawer, .table-scroll {
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: #fff !important;
    overflow: visible !important;
  }

  .result {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #000 !important;
    border-radius: 0 !important;
    padding: 10pt !important;
  }
  .result .label, .result .note, .stat .k { color: #444 !important; }
  .result .big, .stat .v { color: #000 !important; }
  .stat { border-left: 0 !important; padding: 0 12pt 0 0 !important; }

  details { display: block !important; }
  details > summary { display: none !important; }
  table { width: 100%; font-size: 9.5pt; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  th, td { border-bottom: 1px solid #ddd; padding: 4pt 6pt 4pt 0; }
  thead th { color: #000 !important; }

  .chart-donut, .chart-area, .chart-gauge, .chart-split, .bars { display: none !important; }
  .disclaimer { border: 1px solid #999 !important; background: #fff !important; font-size: 9pt; }
  a[href]::after { content: ""; }
  @page { margin: 14mm; }
}

/* ==========================================================================
   Polish
   ========================================================================== */

::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* one consistent focus ring everywhere, keyboard only */
:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* skip link — invisible until tabbed to */
.skip {
  position: absolute;
  left: 50%; top: 8px;
  transform: translate(-50%, -200%);
  z-index: 100;
  padding: 10px 18px;
  font-size: 14px; font-weight: 550;
  color: #fff;
  background: var(--accent);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  transition: transform .18s;
}
.skip:focus { transform: translate(-50%, 0); text-decoration: none; }

.noscript {
  padding: 12px 24px;
  font-size: 14px;
  text-align: center;
  color: #fff;
  background: var(--warn);
}

/* anchors clear the sticky header */
[id] { scroll-margin-top: 84px; }

/* cards: lift, and reveal the category hue on the top edge */
.calc-card { transition: background .16s ease, transform .16s ease; }
.calc-card::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: var(--hue, var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .22s cubic-bezier(.2, .7, .3, 1);
}
.calc-card:hover::before { transform: scaleX(1); }
.calc-card:hover .ico { transform: scale(1.06); }
.calc-card .ico { transition: transform .16s ease; }

/* table rows respond, and the label column stays put while scrolling wide
   schedules on a phone */
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--surface-2); }
.drawer tbody td:first-child,
.drawer thead th:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
}
.drawer tbody tr:hover td:first-child { background: var(--surface-2); }

/* slim scrollbars on the wide tables */
.table-scroll { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* the answer never jumps as it re-renders */
.result .big { min-height: 1.08em; }
.stat .v { min-height: 1.25em; }

/* buttons feel pressed */
.btn:active, .copy-btn:active, .print-btn:active, .clear-btn:active { transform: translateY(1px); }

/* charts fade in rather than snapping */
.chart-donut circle, .chart-area path { transition: all .35s ease; }


@media print { .skip, .noscript { display: none !important; } }

/* home category sections and the FAQ block inside the guide */
.cat { display: block; }
.guide-body .faqs { margin-top: 30px; }

/* ==========================================================================
   Colour accents and light motion
   Everything here is subtle and short (<400ms), and every one of it is
   disabled under prefers-reduced-motion by the rule further up.
   ========================================================================== */

/* --- content arriving --- */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.tool     { animation: rise .34s cubic-bezier(.2, .7, .3, 1) both; }
.page-head{ animation: rise .32s cubic-bezier(.2, .7, .3, 1) both; }
.hero     { animation: fade .5s ease both; }
.cards    { animation: rise .4s cubic-bezier(.2, .7, .3, 1) both .05s; }

/* --- the result panel: a coloured edge and a soft corner glow --- */
.result { overflow: hidden; }
.result::after {
  content: "";
  position: absolute;
  top: -70px; right: -70px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: var(--hue, var(--accent));
  opacity: .07;
  pointer-events: none;
}
.result > * { position: relative; }

/* the figure eases in whenever it is recalculated */
.result .big { transition: color .2s ease; }

/* --- charts draw themselves --- */
@keyframes sweep { from { stroke-dashoffset: 260; } }
.chart-donut circle { animation: sweep .7s cubic-bezier(.3, .8, .3, 1) both; }
.chart-area path { animation: fade .5s ease both; }
.chart-split .seg { animation: fade .4s ease both; }
.chart-gauge .gauge-pin { animation: rise .45s cubic-bezier(.2, .7, .3, 1) both; }

/* --- category colour reaches further --- */
.calc-card:hover .t { color: var(--ink, var(--accent)); }
.viz-title { color: var(--ink, var(--text-3)); opacity: .9; }
.drawer > summary:hover { color: var(--ink, var(--accent)); }
.guide-btn:hover { border-color: var(--hue, var(--accent)); color: var(--ink, var(--text)); }
.faq summary:hover { color: var(--ink, var(--accent)); }
.faq[open] summary { color: var(--ink, var(--accent)); }
.legend li:hover .lv { color: var(--ink, var(--accent)); }
.crumbs a:hover { color: var(--ink, var(--accent)); }

/* the tinted band behind the tool's own stats */
.stat .v { transition: color .2s ease; }

/* --- sidebar entries tint on hover --- */

/* --- tabs slide rather than snap --- */
.tab::after { transition: background .18s ease, transform .18s ease; transform-origin: center; }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab:not([aria-selected="true"])::after { transform: scaleX(.4); }

/* --- buttons and inputs --- */
.btn, .btn.ghost { transition: background .15s, border-color .15s, color .15s, transform .08s; }
input, select { transition: border-color .16s, box-shadow .16s, background .16s; }

/* --- copy confirmation pops --- */
@keyframes pop { 0% { opacity: 0; transform: translateY(-4px); } 100% { opacity: 1; transform: none; } }
.copy-btn.done::after { animation: pop .18s ease both; }
.copy-btn.done { color: var(--good); border-color: var(--good); }

/* --- the search halo breathes on focus --- */
.search::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  opacity: 0;
  filter: blur(14px);
  transition: opacity .3s ease;
  pointer-events: none;
  z-index: 0;
}
.search:focus-within::after { opacity: .28; }
.search input, .search > svg, .hint-key, .clear-btn { position: relative; z-index: 1; }
.search > svg, .hint-key, .clear-btn { position: absolute; }

/* ==========================================================================
   Calculator switcher — the button that names where you are, and the
   panel that moves you somewhere else. One control on every screen size:
   a right-anchored card on the desktop, a full-width sheet on a phone.
   ========================================================================== */
.nav-switch {
  display: flex; align-items: center; gap: 8px;
  height: 38px;
  margin-left: auto;
  padding: 0 10px 0 11px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--header-ink, var(--text));
  cursor: pointer;
  transition: background .16s, border-color .16s;
}
.nav-switch:hover { background: rgba(255, 255, 255, .7); border-color: var(--text-3); }
.nav-switch[aria-expanded="true"] { background: rgba(255, 255, 255, .7); border-color: var(--accent); }
:root[data-theme="dark"] .nav-switch:hover,
:root[data-theme="dark"] .nav-switch[aria-expanded="true"] { background: rgba(255, 255, 255, .1); }
.nav-switch-icon { display: flex; }
.nav-switch-icon svg { width: 15px; height: 15px; stroke: var(--accent); }
.nav-switch-text { white-space: nowrap; }
.nav-switch-chev { display: flex; }
.nav-switch-chev svg {
  width: 14px; height: 14px;
  stroke: var(--text-3);
  transition: transform .2s cubic-bezier(.2, .7, .3, 1);
}
.nav-switch[aria-expanded="true"] .nav-switch-chev svg { transform: rotate(180deg); }

.nav-panel {
  position: absolute;
  top: calc(100% + 8px); right: max(24px, calc(50% - var(--maxw) / 2 + 24px));
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 26px 60px -28px rgba(20, 28, 48, .45), 0 2px 8px -4px rgba(20, 28, 48, .2);
}
.nav-panel[hidden] { display: none; }
.nav-panel.opening { animation: navdrop .2s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes navdrop { from { opacity: 0; transform: translateY(-8px); } }
.nav-sheet { padding: 16px 18px 14px; }

/* the shortcut row: what most people came for, one tap away */
.nav-pop h3,
.nav-group h3 {
  margin: 0 0 8px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink, var(--text-3));
}
/* the search sits in the panel's top-right corner, level with the heading */
.nav-pop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.nav-pop-head h3 { margin: 0; }
.nav-find {
  position: relative;
  display: flex; align-items: center;
  flex: 0 1 200px;
  margin-left: auto;
}
.nav-find > svg {
  position: absolute;
  left: 9px;
  width: 14px; height: 14px;
  stroke: var(--text-3);
  pointer-events: none;
}
.nav-find input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 28px;
  font: inherit; font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.nav-find input::placeholder { color: var(--text-3); }
.nav-find input:focus {
  background: var(--surface);
  border-color: var(--accent);
}
/* the browser's own clear button doubles up with Escape and sits crooked */
.nav-find input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

/* while searching, the shortcut row steps aside and the results move up */
.nav-pop.searching .nav-chips,
.nav-pop.searching .nav-pop-head h3 { display: none; }
.nav-pop.searching ~ .nav-cats { margin-top: 12px; padding-top: 12px; }

.nav-empty {
  margin: 14px 0 4px;
  font-size: 13.5px;
  color: var(--text-3);
}
.nav-empty[hidden] { display: none; }

.nav-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nav-chips a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px 7px 9px;
  background: var(--tint, var(--bg));
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--ink, var(--text-2));
  white-space: nowrap;
}
.nav-chips a:hover, .nav-chips a:focus-visible {
  border-color: var(--hue, var(--accent));
  text-decoration: none;
}
.nav-chips a svg { flex: none; width: 15px; height: 15px; stroke: var(--hue, var(--text-3)); }
.nav-chips a.on { border-color: var(--hue, var(--accent)); font-weight: 600; }

/* every calculator, by category, in columns so 28 of them stay scannable */
.nav-cats {
  columns: 3;
  column-gap: 24px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.nav-group { padding: 0 0 10px; break-inside: avoid; }
.nav-group a {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 0;
  font-size: 13.5px;
  color: var(--text-2);
}
.nav-group a:hover, .nav-group a:focus-visible { color: var(--ink, var(--text)); text-decoration: none; }
.nav-group a svg { flex: none; width: 16px; height: 16px; stroke: var(--hue, var(--text-3)); }
.nav-group a.on { color: var(--ink, var(--text)); font-weight: 600; }
.nav-group a.on::after {
  content: "";
  width: 5px; height: 5px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--hue, var(--accent));
}

@media (max-width: 760px) {
  /* a sheet under the header rather than a floating card */
  .nav-panel {
    top: 100%; right: 0; left: 0;
    width: auto;
    max-height: calc(100dvh - 64px);
    border-radius: 0;
    border-left: 0; border-right: 0; border-top: 0;
  }
  .nav-sheet { padding: 14px 20px 22px; }
  /* iOS zooms the page for anything under 16px */
  .nav-find input { height: 36px; font-size: 16px; }
  .nav-find { flex-basis: 150px; }
  .nav-cats { columns: 2; column-gap: 20px; }
  .nav-group a { padding: 8px 0; font-size: 14.5px; }
  body.nav-open { overflow: hidden; }
}

@media (max-width: 400px) {
  .nav-cats { columns: 1; }
  .nav-switch-text { display: none; }
  .nav-switch { padding: 0 9px; }
}

@media print { .nav-switch, .nav-panel { display: none !important; } }

/* ==========================================================================
   Above-the-fold space
   The answer must be reachable without hunting for it, so the heading block
   is kept tight and a compact bar carries the result once it scrolls away.
   ========================================================================== */
.page-head { margin: 14px 0 22px; }
.page-head h1 { font-size: clamp(26px, 3.4vw, 34px); }
.lede { margin: 10px 0 0; max-width: 72ch; font-size: 15.5px; }

/* ==========================================================================
   Compact answer bar — appears at any width once the result scrolls away
   ========================================================================== */
.mini-result {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 55;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: var(--tint, var(--accent-soft));
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -8px 24px -12px rgba(20, 28, 48, .35);
  transform: translateY(100%);
  transition: transform .22s cubic-bezier(.2, .7, .3, 1);
}
.mini-result.show { transform: none; }
.mini-result .k {
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink, var(--text-3));
  white-space: nowrap;
}
.mini-result .v {
  margin-left: auto;
  font-size: 19px; font-weight: 600; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media print { .mini-result { display: none !important; } }

/* ==========================================================================
   Theme toggle
   ========================================================================== */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  margin-left: 4px;
  padding: 0;
  color: var(--header-dim);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--header-ink); background: rgba(255, 255, 255, .7); border-color: var(--text-3); }
:root[data-theme="dark"] .theme-toggle:hover { background: rgba(255, 255, 255, .1); }
:root[data-theme="dark"] .nav-panel {
  border-color: var(--line-strong);
  box-shadow: 0 26px 60px -24px rgba(0, 0, 0, .8);
}
.theme-toggle svg { width: 17px; height: 17px; stroke: currentColor; }

/* Show the icon for the action the button performs. Both rules sit at the
   same specificity so neither can lose to the other — the previous version
   mixed :root:not(...) with an attribute selector and rendered two icons. */
.theme-toggle .i-light,
.theme-toggle .i-dark { display: none; }
:root[data-theme="light"] .theme-toggle .i-dark { display: block; }
:root[data-theme="dark"] .theme-toggle .i-light { display: block; }

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Screen-reader-only text that still gets announced. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Comfortable touch targets on small screens (WCAG 2.5.8 asks for 24px, the
   AAA target and every mobile guideline asks for ~44px). */
@media (pointer: coarse) {
  .tab { padding: 12px 4px 14px; }
  .foot-line a, .nav-group a { min-height: 44px; display: flex; align-items: center; }
  .copy-btn, .print-btn, .clear-btn, .theme-toggle, .nav-switch { min-width: 44px; min-height: 44px; }
  input[type="number"], input[type="text"], input[type="date"], select { height: 44px; }
  .faq summary, .drawer > summary, .guide-btn { min-height: 44px; }
  .calc-card { padding: 22px 20px; }
}

/* Respect a request for more contrast. */
@media (prefers-contrast: more) {
  :root {
    --line: #9aa2b1;
    --line-strong: #6b7382;
    --text-2: #33383f;
    --text-3: #4d525c;
  }
  :root[data-theme="dark"] {
    --line: #5a6170;
    --line-strong: #7b8391;
    --text-2: #d2d6de;
    --text-3: #b3b9c4;
  }
  .card, .tool, .calc-card, .result, input, select, .guide-btn { border-width: 2px; }
  .tab[aria-selected="true"]::after { height: 3px; }
  :where(a, button, summary, [tabindex]):focus-visible { outline-width: 3px; }
  .site-header { background: var(--surface); backdrop-filter: none; }
  body::before { display: none; }
}

/* Windows high-contrast mode strips colour; keep the structure readable. */
@media (forced-colors: active) {
  .calc-card, .card, .tool, .result, .guide-btn { border: 1px solid CanvasText; }
  .tab[aria-selected="true"]::after { background: Highlight; forced-color-adjust: none; }
  .logo-mark, .result::after, body::before { display: none; }
  .chart-split .seg { forced-color-adjust: none; }
}

/* Charts repeat data that is already given as text, so they are decorative to
   a screen reader — the legend and stat tiles carry the numbers. */
.chart-donut, .chart-area, .chart-gauge, .bars { pointer-events: none; }


/* ==========================================================================
   Answer and charts together
   Exactly two children — the answer and the stack of charts — so there is
   never an empty grid cell leaving a gap beside the result.
   ========================================================================== */
.outcome > .o-answer > .result { margin-top: 26px; }
.outcome > .o-visual > .viz:first-child { margin-top: 26px; }

@media (min-width: 1000px) {
  .outcome:has(.o-visual) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr);
    gap: 30px;
    align-items: start;
  }
  .outcome > .o-visual { min-width: 0; }
  /* both columns start on the same line */
  .outcome:has(.o-visual) > .o-answer > .result,
  .outcome:has(.o-visual) > .o-visual > .viz:first-child { margin-top: 26px; }
  /* the charts already sit in their own column, so they need no divider */
  .outcome:has(.o-visual) > .o-visual > .viz {
    margin-top: 22px;
    padding-top: 0;
    border-top: 0;
  }
  .outcome:has(.o-visual) > .o-visual > .viz:first-child { margin-top: 26px; }
  .outcome:has(.o-visual) .chart-area { height: 128px; }
  .outcome:has(.o-visual) .chart-donut { width: 132px; height: 132px; }
  .outcome:has(.o-visual) .viz { gap: 20px; }
}


/* ==========================================================================
   Fraction inputs — a real fraction, not two boxes in a row
   ========================================================================== */
.frac-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px 24px;
  margin-bottom: 4px;
}
.frac { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 104px; }
.frac input { text-align: center; font-size: 18px; font-weight: 600; }
.frac .bar { width: 100%; height: 2px; background: var(--hue, var(--text)); border-radius: 1px; }
.frac-op { margin-bottom: 0; min-width: 150px; }

/* triangle drawing */
.chart-tri { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto; }
.chart-tri .tri-shape { fill: var(--tint, var(--accent-soft)); stroke: var(--hue, var(--accent)); stroke-width: 2; stroke-linejoin: round; }
.chart-tri .tri-v { font: 700 12px var(--font); fill: var(--ink, var(--text)); }
.chart-tri .tri-s { font: 600 11px var(--font); fill: var(--text-2); }
.chart-tri .tri-right { fill: none; stroke: var(--hue, var(--accent)); stroke-width: 1.6; opacity: .7; }
