/* LoanCalc Lab - single stylesheet for the whole site.
   Covers: light/dark tokens, layout, forms, results, tables, print, a11y states.
   Layout works fluidly from 320px; explicit breakpoints at 380 / 560 / 640 / 900 / 1000
   (spec §15.1 asks for 320/375/414/768/1024/1440 checks, which these cover by flow).
*/

:root {
  color-scheme: light dark;
  /* text colour used on top of --brand (buttons, brand mark); dark themes override it */
  --on-brand: #ffffff;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-alt: #eef1f6;
  --border: #d6dbe4;
  --border-strong: #8a94a3;
  --text: #151a21;
  --text-muted: #4c5666;
  --brand: #0f4c81;
  --brand-strong: #0a3355;
  --brand-soft: #e3edf7;
  --accent: #0b6b53;
  --warn-bg: #fff4d6;
  --warn-border: #b8860b;
  --warn-text: #5c4400;
  --error: #a4232b;
  --focus: #1a5fb4;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 10px;
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141a;
    --surface: #171d26;
    --surface-alt: #1e2732;
    --border: #2f3a48;
    --border-strong: #7d8b9e;
    --text: #e8edf4;
    --text-muted: #a9b5c4;
    --brand: #7fb4e8;
    --brand-strong: #b9d8f5;
    --brand-soft: #1b2a3c;
    --accent: #6fd3b2;
    --warn-bg: #37290a;
    --warn-border: #b8860b;
    --warn-text: #ffe9a8;
    --error: #ff9aa2;
    --focus: #8cc4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

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

a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-strong); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  z-index: 20;
}
.skip-link:focus { left: 8px; top: 8px; }

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

.visually-hidden {
  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;
}

/* ---------- header / footer ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 60px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:hover { background: var(--surface-alt); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--brand); font-weight: 600; }

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-footer .wrap { padding-top: 24px; padding-bottom: 28px; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.footer-links a { display: inline-block; min-height: 44px; line-height: 44px; color: var(--text-muted); }
.footer-meta { margin: 0; }

/* ---------- page body ---------- */

main { display: block; padding-top: 20px; }

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--border); }

h1 {
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

h2 { font-size: 1.3rem; margin: 36px 0 12px; line-height: 1.3; }
h3 { font-size: 1.05rem; margin: 24px 0 8px; }

.lede {
  font-size: 1.02rem;
  color: var(--text-muted);
  margin: 0 0 20px;
  max-width: 68ch;
}

.prose { max-width: 72ch; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 8px; }

.section { margin-top: 36px; }
.section > h2 { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.answer-bar {
  background: var(--brand-soft);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 22px;
  font-size: 1rem;
}

.answer-bar p { margin: 0; }

.trust-bar {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 20px 0;
}

.trust-bar p { margin: 0; }

/* ---------- calculator ---------- */

.calc-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 900px) {
  .calc-layout { grid-template-columns: minmax(320px, 1fr) minmax(340px, 1.1fr); }
}

.calc-form {
  padding: 18px;
}

.calc-form h2 { font-size: 1.05rem; margin: 0 0 4px; }

.form-note { font-size: 0.86rem; color: var(--text-muted); margin: 0 0 14px; }

.field { margin-bottom: 12px; display: flex; flex-direction: column; }

.field label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.field .hint {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-muted);
}

.field input:not([type="checkbox"]),
.field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  margin-top: auto;
}

.field input:not([type="checkbox"]):focus,
.field select:focus {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.field input[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }

.field-error {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--error);
}

.field-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 12px;
  min-height: 44px;
}

.field-check input { width: 20px; height: 20px; margin-top: 4px; flex: none; }
.field-check label { font-size: 0.92rem; font-weight: 600; }

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

@media (min-width: 560px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

.actions { margin-top: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  min-width: 44px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

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

.btn-primary {
  width: 100%;
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }

/* the primary-button contrast is handled by --on-brand in the token blocks; a
   media-query override here is exactly what broke the explicit-dark path once. */

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.9rem;
}

/* ---------- results ---------- */

.result {
  padding: 18px;
}

.result-empty {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.result-headline {
  margin: 0 0 2px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-main {
  margin: 0 0 4px;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

@media (min-width: 640px) {
  .result-main { font-size: 2.5rem; }
}

.result-sub {
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.result-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 0 0 16px;
  padding: 0;
  border-top: 1px solid var(--border);
}

.result-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.result-list dt { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
.result-list dd { margin: 0; font-weight: 600; text-align: right; }

.result-callout {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-alt);
  font-size: 0.95rem;
}

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- tables ---------- */

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

caption {
  text-align: left;
  padding: 10px 14px 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

th, td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th {
  background: var(--surface-alt);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}

tbody tr:last-child td { border-bottom: 0; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

tbody tr.is-total td { font-weight: 700; background: var(--surface-alt); }

.table-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* CSS-only bar chart, no chart library (spec §2.1) */

.bar-chart { display: grid; gap: 10px; margin: 16px 0; }

.bar-row { display: grid; grid-template-columns: 8.5rem 1fr; gap: 10px; align-items: center; }

.bar-label { font-size: 0.85rem; color: var(--text-muted); }

.bar-track { background: var(--surface-alt); border-radius: 6px; height: 18px; overflow: hidden; }

.bar-fill { height: 100%; background: var(--brand); border-radius: 6px; }
.bar-fill.is-alt { background: var(--accent); }

/* ---------- FAQ ---------- */

.faq details {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 14px;
  margin-bottom: 10px;
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.faq summary::-webkit-details-marker { display: none; }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq .faq-body { padding: 12px 0; font-size: 0.95rem; }
.faq .faq-body p { margin: 0 0 10px; }

/* ---------- cards grid ---------- */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1000px) {
  .card-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 100%;
}

.tool-card h3 { margin: 0; font-size: 1rem; }
.tool-card p { margin: 0; font-size: 0.9rem; color: var(--text-muted); flex: 1; }
.tool-card a { font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.tool-card a:hover { text-decoration: underline; }

/* ---------- ads ---------- */

.ad-slot {
  margin: 22px 0;
  padding: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.ad-slot[hidden] { display: none !important; }

.ad-slot[data-slot="ad-top"] { min-height: 0; }
.ad-slot[data-slot="ad-mid"] { min-height: 0; }
.ad-slot[data-slot="ad-bottom"] { min-height: 0; }

.ad-slot .ad-label {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.ad-slot .adsbygoogle { display: block; width: 100%; }

.advertiser-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}

/* ---------- keep / utility ---------- */

.disclaimer {
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.byline {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin: -4px 0 18px;
}

.todo-verify { background: var(--warn-bg); color: var(--warn-text); padding: 0 4px; border-radius: 3px; }

.noscript-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
}

code, .mono { font-family: var(--mono); font-size: 0.9em; }

.formula {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
  margin: 0 0 14px;
  white-space: pre-wrap;
}

/* ---------- 404 ---------- */

.error-page { text-align: left; padding: 40px 0; }
.error-page .code { font-size: 3rem; font-weight: 700; color: var(--brand); margin: 0; }

/* ---------- print (spec §15.3) ---------- */

@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #ffffff;
    --text: #000000;
    --text-muted: #222222;
    --border: #666666;
    --shadow: none;
  }

  body { font-size: 11pt; background: #fff; color: #000; }

  .site-header, .site-footer, .ad-slot, .advertiser-note,
  .result-actions, .table-actions, .skip-link, .breadcrumb,
  .btn, .btn-primary, .trust-bar, .faq summary::after { display: none !important; }

  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; }

  .card, .table-wrap, .calc-form, .result {
    border: 1px solid #000;
    box-shadow: none;
    break-inside: avoid;
  }

  table { font-size: 9pt; }
  th, td { white-space: normal; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }

  .faq details { break-inside: avoid; }
  .faq details:not([open]) .faq-body { display: block; }

  .result-main { font-size: 20pt; }
  .calc-layout { display: block; }
  .calc-layout > * + * { margin-top: 12pt; }
  .bar-row { grid-template-columns: 1fr; }
  .ad-slot[hidden] { display: none !important; }
}

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

@media (max-width: 380px) {
  body { font-size: 16px; }
  h1 { font-size: 1.45rem; }
  .result-main { font-size: 2rem; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .wrap { padding: 0 12px; }
}

/* ============================================================================
   v2 — visual + interaction layer. Appended after the original rules so every
   existing selector keeps working; this block only refines and adds.
   No new external assets: icons are inline SVG, themes are plain CSS variables.
   ========================================================================== */

:root {
  /* spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  /* radii + elevation */
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-pill: 999px;
  --e-1: 0 1px 2px rgba(16, 24, 40, .05);
  --e-2: 0 2px 6px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .08);
  --e-3: 0 24px 60px rgba(16, 24, 40, .14);
  /* semantic colours */
  --ok: #0b6b53;
  --ok-soft: #e6f4ef;
  --danger: #a4232b;
  --danger-soft: #fdecec;
  --ring: color-mix(in srgb, var(--focus) 35%, transparent);
  --hero-grad: radial-gradient(1200px 380px at 12% -10%, #dbe9f8 0%, transparent 60%),
               radial-gradient(900px 320px at 92% 0%, #e8f1ea 0%, transparent 55%);
  --sheen: linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,0));
}

/* explicit theme choice beats the media query (higher specificity) */
:root[data-theme="light"] {
  color-scheme: light;
  --muted-2: #4a5a68;
  --bg: #f7f8fa; --surface: #ffffff; --surface-alt: #eef1f6;
  --border: #d6dbe4; --border-strong: #8a94a3;
  --text: #151a21; --text-muted: #4c5666;
  --brand: #0f4c81; --brand-strong: #0a3355; --brand-soft: #e3edf7;
  --focus: #1a5fb4;
  --hero-grad: radial-gradient(1200px 380px at 12% -10%, #dbe9f8 0%, transparent 60%),
               radial-gradient(900px 320px at 92% 0%, #e8f1ea 0%, transparent 55%);
  --sheen: linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,0));
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117; --surface: #161c25; --surface-alt: #1e2732;
  --border: #2f3a48; --border-strong: #7d8b9e;
  --text: #e8edf4; --text-muted: #a9b5c4;
  --brand: #8fc3f2; --brand-strong: #b9d8f5; --brand-soft: #17283c;
  --focus: #8cc4ff;
  --ok: #6fd3b2; --ok-soft: #10322a;
  --danger: #ff9aa2; --danger-soft: #33161a;
  --hero-grad: radial-gradient(1200px 380px at 12% -10%, #14263a 0%, transparent 60%),
               radial-gradient(900px 320px at 92% 0%, #10281f 0%, transparent 55%);
  --sheen: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0));
}

/* ---------- header: sticky, glassy, with theme switch ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: saturate(140%) blur(10px);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap { gap: var(--s-2) var(--s-4); }

.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(160deg, var(--brand), var(--brand-strong));
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, var(--e-1);
  font-size: .78rem; letter-spacing: .02em;
}

.site-nav a { border-radius: var(--r-pill); }
.site-nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn[data-theme-state="dark"] { color: var(--brand); border-color: var(--brand); }

/* ---------- hero ---------- */

.hero {
  position: relative;
  margin: 0 0 var(--s-6);
  padding: var(--s-7) 0 var(--s-6);
  background-image: var(--hero-grad);
  background-repeat: no-repeat;
}

.hero h1 {
  font-size: clamp(1.9rem, 1.2rem + 2.2vw, 3rem);
  line-height: 1.1;
  letter-spacing: -.02em;
  margin-bottom: var(--s-3);
  max-width: 22ch;
}

.hero .lede {
  font-size: clamp(1rem, .95rem + .35vw, 1.18rem);
  max-width: 60ch;
  margin-bottom: var(--s-5);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: 0 0 var(--s-4);
  padding: 0;
  list-style: none;
}

.hero-badges li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-muted);
  box-shadow: var(--e-1);
}

.hero-badges svg { width: 14px; height: 14px; color: var(--ok); }

/* the "answer bar" becomes a card with a thin accent edge */
.answer-bar {
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--brand-soft) 55%, var(--surface));
  box-shadow: var(--e-1);
  padding: var(--s-4) var(--s-5);
  font-size: .98rem;
}

/* ---------- calculator shell ---------- */

.calc-form,
.result {
  border-radius: var(--r-lg);
  border-color: var(--border);
  box-shadow: var(--e-2);
}

.calc-form { position: relative; }

.calc-form h2 {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 1.02rem;
  letter-spacing: -.01em;
}

.calc-form h2::before {
  content: "";
  width: 3px; height: 1.05em;
  border-radius: 2px;
  background: var(--brand);
}

.field label { letter-spacing: -.01em; }

.field input:not([type="checkbox"]),
.field select {
  border-radius: var(--r-sm);
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

.field input:not([type="checkbox"]):hover,
.field select:hover { border-color: var(--brand); }

.field input:not([type="checkbox"]):focus,
.field select:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 4px var(--ring);
}

.field input[aria-invalid="true"] { box-shadow: 0 0 0 4px var(--danger-soft); }

/* ---------- result card ---------- */

/* sticky behaviour was removed in v2.2: the action row must never sit under the card */


.result-headline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  letter-spacing: .08em;
  color: var(--brand);
}

.result-headline::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}

.result-main {
  font-size: clamp(2rem, 1.4rem + 2.4vw, 3.1rem);
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.result-list {
  gap: var(--s-2);
  border-top: 0;
}

.result-list > div {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  background: var(--surface);
}

@media (min-width: 560px) {
  .result-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .result-list > div:first-child,
  .result-list > div:nth-child(2) { grid-column: span 1; }
}

.result-list dt { font-size: .84rem; }
.result-list dd { font-variant-numeric: tabular-nums; }

.result-callout {
  border-left: 3px solid var(--ok);
  background: var(--ok-soft);
  font-size: .93rem;
}

/* ---------- buttons + icons ---------- */

.btn {
  gap: 8px;
  border-radius: var(--r-pill);
  transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { box-shadow: var(--e-1); }
.btn:active { transform: translateY(1px) scale(.995); }
.btn-primary { border-radius: var(--r-pill); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 28%, transparent); }

.result-actions { padding: 0; gap: 10px; flex-wrap: wrap; }
.result-actions .btn { font-size: .9rem; padding: 9px 16px; min-height: 44px; }

/* mobile action bar: copy / print / share always within thumb reach */
.action-bar { display: none; }

@media (max-width: 640px) {
  .action-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: flex;
    gap: 8px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(8px);
  }
  .action-bar .btn {
    flex: 1 1 0;
    justify-content: center;
    min-height: 46px;
    font-size: .86rem;
    padding: 0 8px;
  }
  
  .action-bar .btn svg { width: 20px; height: 20px; }
  body { padding-bottom: 76px; }
  .result-actions { display: none; }
}

/* ---------- tables ---------- */

.table-wrap {
  border-radius: var(--r-md);
  box-shadow: var(--e-1);
}

thead th {
  background:
    linear-gradient(180deg, var(--surface-alt), color-mix(in srgb, var(--surface-alt) 70%, #ffffff));
  letter-spacing: .05em;
}

tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-alt) 55%, transparent); }
tbody tr:hover td { background: color-mix(in srgb, var(--brand) 7%, transparent); }
tbody tr.is-total td { background: var(--brand-soft); color: var(--text); }

/* ---------- cards ---------- */

.tool-card {
  border-radius: var(--r-lg);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.tool-card:hover,
.tool-card:focus-within {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  box-shadow: var(--e-2);
}

.tool-card a { color: var(--brand); }
.tool-card a::after {
  content: "→";
  margin-left: 6px;
  transition: transform .16s ease;
}
.tool-card:hover a::after { transform: translateX(3px); }

/* ---------- FAQ ---------- */

.faq details {
  border-radius: var(--r-md);
  box-shadow: var(--e-1);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.faq details[open] {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
  box-shadow: var(--e-1);
}

.faq summary { position: relative; padding-right: 34px; list-style: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  color: var(--brand);
  background: var(--brand-soft);
}
.faq details[open] summary::after { content: "−"; }

/* ---------- trust / ads / footer ---------- */

.trust-bar {
  border: 1px dashed color-mix(in srgb, var(--ok) 55%, var(--border));
  background: var(--ok-soft);
  border-radius: var(--r-md);
  color: var(--text);
}

.ad-label { opacity: .75; }

.site-footer { background: var(--surface); border-top: 1px solid var(--border); }
.footer-links a { border-radius: var(--r-sm); }
.footer-links a:hover { background: var(--surface-alt); color: var(--text); }

/* ---------- motion ---------- */

.result[data-flash="1"] .result-main { animation: pop .35s ease; }
@keyframes pop {
  0% { transform: scale(.97); opacity: .6; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- print: keep the new chrome out of the paper ---------- */

@media print {
  .site-header, .action-bar, .icon-btn { display: none !important; }
  .result { position: static; box-shadow: none; }
  .result-list { grid-template-columns: 1fr 1fr; }
  .hero { background: none; padding: 0; }
}

/* theme switch: one icon per state */
.icon-btn svg { display: none; }
.icon-btn[data-theme-state="system"] .i-auto,
.icon-btn[data-theme-state="light"] .i-sun,
.icon-btn[data-theme-state="dark"] .i-moon { display: inline-block; }

/* hero spacing on guides (they have no badges) */
.hero .answer-bar { margin-bottom: 0; }
@media (max-width: 640px) {
  .hero { padding: var(--s-6) 0 var(--s-4); }
  .hero h1 { max-width: none; }
}

/* the action row is a sibling of the two cards (it must stay outside the live region),
   so pin it to the result column on wide screens */
@media (min-width: 900px) {
  .calc-layout > .result-actions {
    grid-column: 2;
    margin-top: calc(var(--s-3) * -1);
    padding: 0 18px;
  }
}

/* full-bleed hero gradient, faded at the bottom so it never shows a hard edge */
.hero { position: relative; background-image: none; }
.hero::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -60px -60vw -24px;
  background-image: var(--hero-grad);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 58%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 58%, transparent 100%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
html, body { overflow-x: clip; }

/* the v2 semantic tokens must also exist for the system-dark path (no explicit data-theme) */
@media (prefers-color-scheme: dark) {
  :root {
    --on-brand: #0a1420;
    --ok: #6fd3b2; --ok-soft: #10322a;
    --danger: #ff9aa2; --danger-soft: #33161a;
    --hero-grad: radial-gradient(1200px 380px at 12% -10%, #14263a 0%, transparent 60%),
                 radial-gradient(900px 320px at 92% 0%, #10281f 0%, transparent 55%);
    --sheen: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0));
  }
}

/* two-column metric cards only when the card is actually wide enough */
@media (max-width: 1199px) {
  .result-list { grid-template-columns: 1fr; }
}
@media (min-width: 1200px) {
  .result-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.result-list > div { align-items: flex-start; }
.result-list dt { max-width: 62%; }

/* stacked metric tiles: label above value, so long labels never fight the number */
@media (min-width: 1200px) {
  .result-list > div { display: block; }
  .result-list dt { max-width: none; margin-bottom: 2px; }
  .result-list dd { text-align: left; font-size: 1.06rem; }
}

/* ============================================================================
   v2.1 — review fixes. One token set per theme; media query is only the fallback.
   ========================================================================== */


/* explicit light must reset *every* semantic token, including the ones the dark
   media block sets, otherwise a dark-OS visitor who picks light gets dark callouts */
:root[data-theme="light"] {
  --ok: #0b6b53; --ok-soft: #e6f4ef;
  --danger: #a4232b; --danger-soft: #fdecec;
  --accent: #0b6b53;
  --warn-bg: #fff4d6; --warn-border: #b8860b; --warn-text: #5c4400;
  --error: #a4232b;
  --on-brand: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

/* explicit dark uses the same palette as the system-dark fallback (no colour jump) */
:root[data-theme="dark"] {
  --bg: #10141a; --surface: #171d26; --surface-alt: #1e2732;
  --border: #2f3a48; --border-strong: #7d8b9e;
  --text: #e8edf4; --text-muted: #a9b5c4;
  --brand: #7fb4e8; --brand-strong: #b9d8f5; --brand-soft: #1b2a3c;
  --focus: #8cc4ff;
  --ok: #6fd3b2; --ok-soft: #10322a; --accent: #6fd3b2;
  --danger: #ff9aa2; --danger-soft: #33161a; --error: #ff9aa2;
  --warn-bg: #37290a; --warn-border: #b8860b; --warn-text: #ffe9a8;
  --on-brand: #0a1420;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --hero-grad: radial-gradient(1200px 380px at 12% -10%, #16283c 0%, transparent 62%),
               radial-gradient(900px 320px at 92% 0%, #122a20 0%, transparent 58%);
}

/* primary button + brand mark read on both palettes */
.btn-primary,
.btn-primary:hover { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.brand-mark { color: var(--on-brand); }

/* thead: no hard-coded white, so the dark gradient stays dark */
thead th { background: var(--surface-alt); }

/* focus stays a real ring; the halo is additive only */
.field input:not([type="checkbox"]):focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--ring);
}

/* table actions: buttons must not stretch into ovals, and the fieldset needs styling */
.table-actions { align-items: flex-start; }
.table-actions .btn { align-self: flex-start; }
.calc-form fieldset,
.calc-layout fieldset {
  min-inline-size: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  margin: 0 0 var(--s-2);
}
.calc-form fieldset legend,
.calc-layout fieldset legend { padding: 0 4px; font-size: .82rem; color: var(--text-muted); }

/* a scrolled table gets a working sticky head instead of a decorative one */
.table-wrap { max-height: 78vh; overflow: auto; }
thead th { top: 0; }

/* phone header: compact and not sticky, so it stops eating a third of the screen */
@media (max-width: 640px) {
  .site-header { position: static; }
  .site-header .wrap { min-height: 0; padding-top: 8px; padding-bottom: 8px; gap: 6px 10px; }
  .site-nav ul { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .site-nav a { min-height: 40px; padding: 0 8px; font-size: .9rem; }
  .brand { min-height: 40px; }
  .icon-btn { min-height: 40px; min-width: 40px; padding: 0 8px; }
}

/* bottom padding only where an action bar actually exists */
body { padding-bottom: 0; }
@media (max-width: 640px) {
  body:has(> .action-bar) { padding-bottom: 76px; }
}

/* action-bar labels exist for screen readers even when visually hidden */
.action-bar .btn span { 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; }

/* breadcrumb links are not inline prose: give them a real touch target */
.breadcrumb a { display: inline-flex; align-items: center; min-height: 44px; }

/* result card: keep it usable on tall forms, never taller than the viewport */

/* hero: make the gradient actually visible */
.hero::before {
  background-image:
    radial-gradient(760px 300px at 8% -20%, color-mix(in srgb, var(--brand) 22%, transparent) 0%, transparent 62%),
    radial-gradient(680px 280px at 96% -10%, color-mix(in srgb, var(--ok) 16%, transparent) 0%, transparent 60%);
}

/* print: two columns, no sticky chrome */
@media print {
  .result-list { grid-template-columns: 1fr 1fr !important; }
  .table-wrap { max-height: none; overflow: visible; }
  thead th { position: static; background: #fff; }
}

/* phone header: brand + theme on the first row, nav on the second, nothing else */
@media (max-width: 640px) {
  .site-header .wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 6px 10px;
  }
  .brand { grid-column: 1; grid-row: 1; margin-right: 0; }
  .icon-btn { grid-column: 2; grid-row: 1; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .site-nav ul { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .site-nav ul::-webkit-scrollbar { display: none; }
  .breadcrumb a { min-height: 32px; }
  .breadcrumb { margin-bottom: 6px; }
}

/* ============================================================================
   v2.2 — action reachability: nothing may overlap the action row, and it must be
   bound even though the bar sits after the scripts.
   ========================================================================== */
.result { position: static; max-height: none; overflow: visible; }
@media (min-width: 900px) {
  .calc-layout > .result-actions {
    grid-column: 1 / -1;
    margin-top: var(--s-3);
    padding: 0;
  }
}

/* ============================================================================
   v2.3 — final polish from the second review
   ========================================================================== */

/* browsers without :has() still get the bottom padding (set by core.js) */
body.has-action-bar { padding-bottom: 0; }
@media (max-width: 640px) {
  body.has-action-bar { padding-bottom: 76px; }
}

/* tap targets: 44px minimum, visually compact via padding + negative margin */
@media (max-width: 640px) {
  .site-nav a { min-height: 44px; padding: 0 10px; }
  .icon-btn { min-height: 44px; min-width: 44px; }
  .brand { min-height: 44px; }
  .breadcrumb a { min-height: 44px; margin-block: -6px; }
}

/* the hero gradient needs to sit inside the viewport to be seen at all */
.hero::before {
  background-image:
    radial-gradient(900px 320px at 50% -6%, color-mix(in srgb, var(--brand) 26%, transparent) 0%, transparent 72%),
    radial-gradient(620px 260px at 88% 4%, color-mix(in srgb, var(--ok) 18%, transparent) 0%, transparent 70%);
}

/* print tokens must beat the theme blocks (same specificity trap as the CTA) */
@media print {
  :root, :root[data-theme] {
    --bg: #ffffff; --surface: #ffffff; --surface-alt: #ffffff;
    --border: #666666; --text: #000000; --text-muted: #333333;
    --brand: #0f4c81; --on-brand: #ffffff;
  }
}

/* order-immune: the dark-media value must win over any later unconditional :root */
@media (prefers-color-scheme: dark) {
  :root { --on-brand: #0a1420; } /* order-immune */
  :root:not([data-theme="light"]) { --on-brand: #0a1420; }
  :root[data-theme="light"] { --on-brand: #ffffff; }
}

/* ============================================================================
   v3 — Deepsee-inspired design language.
   Tokens measured from deepseecommerce.com (see docs/12-设计语言-v3-Deepsee.md):
   #1aacc0 accent, #0c0f16 / #151823 surfaces, Barlow-like sans body,
   large tight-tracking serif display, pill buttons, hairline section rules.

   This layer supersedes the v2 look but keeps every structural class, so the
   markup, the calculators and the gates keep working.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --muted-2: #b8ccda;

  --bg: #0c0f16;
  --surface: #151823;
  --surface-alt: #1b2030;
  --text: #e9f0f5;
  --text-muted: #819aab;
  --border: rgba(184, 204, 218, .14);
  --border-strong: rgba(184, 204, 218, .34);

  --brand: #1aacc0;
  --brand-strong: #71d4ff;
  --brand-soft: rgba(26, 172, 192, .12);
  --on-brand: #00141a;
  --focus: #71d4ff;

  --ok: #35d0a4;
  --ok-soft: rgba(53, 208, 164, .12);
  --danger: #ff8a8a;
  --danger-soft: rgba(255, 138, 138, .12);

  --ring: rgba(26, 172, 192, .28);
  --ease: cubic-bezier(.165, .84, .44, 1);
  --ease-io: cubic-bezier(.76, 0, .24, 1);

  --font-sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --shell: 1180px;
  --hero-grad: radial-gradient(820px 420px at 12% -12%, rgba(26, 172, 192, .22), transparent 68%),
               radial-gradient(680px 360px at 92% 4%, rgba(113, 212, 255, .12), transparent 66%),
               radial-gradient(1200px 620px at 50% 120%, rgba(26, 172, 192, .08), transparent 70%);
}

/* light is an explicit choice only: the brand defaults to the dark sea */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-alt: #eaf0f4;
  --text: #0c0f16;
  --text-muted: #4a5a68;
  --border: rgba(12, 15, 22, .12);
  --border-strong: rgba(12, 15, 22, .3);

  --brand: #0e7180;
  --brand-strong: #0b5a66;
  --brand-soft: rgba(14, 113, 128, .09);
  --on-brand: #ffffff;
  --focus: #0e7180;

  --ok: #0b6b53;
  --ok-soft: #e6f4ef;
  --danger: #a4232b;
  --danger-soft: #fdecec;

  --ring: rgba(14, 113, 128, .22);
  --hero-grad: radial-gradient(820px 420px at 12% -12%, rgba(14, 113, 128, .12), transparent 68%),
               radial-gradient(680px 360px at 92% 4%, rgba(14, 113, 128, .07), transparent 66%);
}

/* ---------- page shell: deep water, not a flat dark theme ---------- */

body {
  background-color: var(--bg);
  background-image: var(--hero-grad);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--shell); }

/* ---------- header: hairline, uppercase, no glass ---------- */

.site-header {
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(120%);
}

.brand {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: .98rem;
  letter-spacing: .01em;
  color: var(--text);
  text-transform: none;
}

.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--brand);
  color: var(--on-brand);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .02em;
  box-shadow: none;
}

.site-nav a {
  font-size: .74rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 14px;
  border-radius: 999px;
  transition: color .3s var(--ease);
}

.site-nav a:hover { color: var(--text); background: transparent; }

.site-nav a[aria-current="page"] {
  color: var(--brand);
  background: transparent;
  box-shadow: inset 0 -1px 0 0 var(--brand);
}

.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  transition: color .3s var(--ease), border-color .3s var(--ease);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); background: transparent; }

/* ---------- hero: serif statement + numbered eyebrow ---------- */

.hero { padding: clamp(56px, 9vw, 116px) 0 clamp(32px, 5vw, 64px); }
.hero::before { background-image: none; }   /* the glow now lives on body */

.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: .98;
  letter-spacing: -.03em;
  max-width: 18ch;
  margin-bottom: clamp(16px, 2vw, 24px);
}

.hero .lede {
  font-size: clamp(1rem, .96rem + .3vw, 1.14rem);
  line-height: 1.62;
  color: var(--text-muted);
  max-width: 62ch;
}

.hero-badges { gap: 10px; margin-bottom: 28px; }
.hero-badges li {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  box-shadow: none;
}
.hero-badges svg { color: var(--brand); width: 13px; height: 13px; }

/* the lede paragraph that used to be an "answer bar" */
.answer-bar {
  background: transparent;
  border: 0;
  border-left: 1px solid var(--brand);
  border-radius: 0;
  padding: 2px 0 2px 20px;
  color: var(--text-muted);
  font-size: .98rem;
  line-height: 1.64;
  box-shadow: none;
}

/* ---------- section rhythm ---------- */

main > section:not(.hero),
main > .section:not(.hero),
main > .wrap > section,
main > .wrap > .section {
  border-top: 1px solid var(--border);
  padding-block: clamp(40px, 6vw, 76px);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: clamp(20px, 3vw, 34px);
}

.section-index {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .16em;
  color: var(--brand);
  padding-top: .2em;
}

.section-label {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

h2 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.95rem);
  letter-spacing: -.02em;
  line-height: 1.18;
}

h3 { font-weight: 500; letter-spacing: -.01em; }


.section-head h2 { margin: 0; }

/* ---------- calculator shell ---------- */

.calc-layout { gap: clamp(18px, 2.4vw, 28px); }

.calc-form,
.result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: none;
  padding: clamp(20px, 2.4vw, 30px);
}

.calc-form h2 {
  font-size: .74rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.calc-form h2::before {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.result { background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--brand) 5%, var(--surface))); }

.result-headline {
  font-size: .7rem;
  letter-spacing: .2em;
  color: var(--text-muted);
}
.result-headline::before { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

.result-main {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.3rem, 1.6rem + 3vw, 3.6rem);
  line-height: 1;
  letter-spacing: -.025em;
  color: var(--text);
}

.result-list { display: block; margin-top: 22px; border-top: 1px solid var(--border); }
.result-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 11px 0;
}
.result-list dt {
  max-width: 62%;
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--text-muted);
}
.result-list dd {
  font-size: .98rem;
  text-align: right;
  color: var(--text);
}

.result-callout {
  margin-top: 20px;
  background: var(--ok-soft);
  border: 0;
  border-left: 1px solid var(--ok);
  border-radius: 0;
  padding: 12px 0 12px 16px;
  color: var(--text);
  font-size: .92rem;
}

/* ---------- form controls ---------- */

.field label {
  font-size: .78rem;
  letter-spacing: .02em;
  color: var(--text-muted);
  font-weight: 500;
}

.field input:not([type="checkbox"]),
.field select {
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}

.field input:not([type="checkbox"]):hover,
.field select:hover { border-color: var(--border-strong); }

.field input:not([type="checkbox"]):focus-visible,
.field select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}

/* ---------- buttons ---------- */

.btn {
  border-radius: 999px;
  font-weight: 500;
  font-size: .84rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 13px 22px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  transition: color .3s var(--ease), border-color .3s var(--ease), background .3s var(--ease), transform .3s var(--ease);
  box-shadow: none;
}

.btn:hover { border-color: var(--brand); color: var(--brand); transform: none; box-shadow: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  letter-spacing: .1em;
}
.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: var(--on-brand);
}
.btn-primary:active { transform: translateY(1px); }

.result-actions { margin-top: 20px; }
.result-actions .btn { font-size: .76rem; padding: 11px 18px; }

/* ---------- cards ---------- */

.card,
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: none;
  transition: border-color .35s var(--ease), background .35s var(--ease), transform .35s var(--ease);
}

.tool-card:hover,
.tool-card:focus-within {
  border-color: var(--brand);
  transform: translateY(-3px);
  box-shadow: none;
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
}

.tool-card h3 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 1.02rem;
  letter-spacing: -.01em;
}

.tool-card a {
  font-size: .74rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--brand);
}
.tool-card a::after { content: "→"; margin-left: 8px; }

/* ---------- tables ---------- */

.table-wrap { border: 1px solid var(--border); border-radius: 12px; box-shadow: none; }

thead th {
  background: var(--surface-alt);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

tbody td { border-bottom: 1px solid var(--border); }
tbody tr:nth-child(even) td { background: transparent; }
tbody tr:hover td { background: color-mix(in srgb, var(--brand) 7%, transparent); }
tbody tr.is-total td { background: var(--brand-soft); }

/* ---------- FAQ ---------- */

.faq details {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: 18px 0;
  box-shadow: none;
}
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq details[open] { border-color: var(--border); box-shadow: none; }
.faq summary { font-weight: 500; letter-spacing: -.01em; }
.faq summary::after {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--border);
  border-radius: 50%;
}

/* ---------- misc chrome ---------- */

.breadcrumb {
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand); }

.trust-bar {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
}

.notice,
.disclaimer {
  border-left: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
}

.site-footer {
  background: #080a10;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .8rem;
}
:root[data-theme="light"] .site-footer { background: var(--surface-alt); }

.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--brand); background: transparent; }

.action-bar {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.action-bar .btn { font-size: .72rem; padding: 0 8px; }

/* ---------- motion: reveal on scroll, disabled when the user asks ---------- */

/* scroll reveal was removed: content must never depend on JS to become visible */


/* ---------- print: white paper regardless of the theme ---------- */

@media print {
  body { background: #fff; color: #111; }
  body::before { display: none; }
  .section-index, .hero-badges { display: none; }
  .calc-form, .result, .card, .tool-card, .table-wrap { border-color: #bbb; background: #fff; }
}

/* v3.polish — page titles share the display face; the nav marks the current item with a rule */
h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.1rem, 1.4rem + 2.4vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -.025em;
  margin-bottom: 18px;
}

.hero h1 { max-width: 20ch; }

.site-nav a[aria-current="page"] {
  color: var(--brand);
  background: transparent;
  box-shadow: none;
  border-bottom: 1px solid var(--brand);
  border-radius: 0;
  padding-bottom: 10px;
}

/* a touch more depth behind the headline */
.hero::after {
  content: "";
  position: absolute;
  z-index: 0;
  right: -6%;
  top: -30%;
  width: min(52vw, 720px);
  height: min(52vw, 720px);
  background: radial-gradient(circle at 50% 50%, rgba(26, 172, 192, .16), transparent 62%);
  filter: blur(6px);
  pointer-events: none;
}
.hero { position: relative; overflow: visible; }

@media (max-width: 900px) {
  .hero::after { display: none; }
}

/* ============================================================================
   v3.1 — review fixes. Type hierarchy mirrors the reference: sans for headings,
   the serif face reserved for the hero statement and the headline number.
   ========================================================================== */

/* headings: sans, large, tight — the reference sets section titles in Barlow 500 */
h1 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: clamp(2rem, 1.3rem + 2.6vw, 3.2rem);
  line-height: 1.04;
  letter-spacing: -.03em;
}

/* the hero statement keeps the display face, like the reference's giant wordmark */
.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 1.8rem + 3.6vw, 4.4rem);
  line-height: .98;
  letter-spacing: -.025em;
}

/* micro labels sit close to the reference: small caps-ish, minimal tracking */
.section-label,
.calc-form h2,
.result-headline,
.breadcrumb,
.site-nav a,
.hero-badges li,
.tool-card a,
.btn {
  letter-spacing: .02em;
}

.section-label { font-size: .8rem; }
.section-index {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--muted-2, #b8ccda);
}

/* nav: mixed case like the reference, and it must fit at 375px */
.site-nav a {
  text-transform: none;
  font-size: .86rem;
  padding: 0 12px;
}

@media (max-width: 430px) {
  .site-nav a { font-size: .8rem; padding: 0 7px; letter-spacing: 0; }
  .site-nav ul { gap: 0; }
}

/* header: transparent bar with a soft blur, no hard rule */
.site-header {
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  border-bottom: 0;
  backdrop-filter: blur(14px) saturate(120%);
}

/* cards: 10px, closer to the reference content blocks */
.card,
.tool-card,
.calc-form,
.result {
  border-radius: 10px;
}

/* more visible depth behind the hero */
body {
  background-image:
    radial-gradient(1100px 560px at 18% -18%, rgba(26, 172, 192, .30), transparent 66%),
    radial-gradient(900px 480px at 88% -6%, rgba(113, 212, 255, .16), transparent 64%),
    radial-gradient(1400px 700px at 50% 118%, rgba(26, 172, 192, .12), transparent 72%);
}

.hero::after {
  background: radial-gradient(circle at 50% 50%, rgba(26, 172, 192, .26), transparent 60%);
  right: -4%;
  top: -34%;
  width: min(60vw, 820px);
  height: min(60vw, 820px);
}

:root[data-theme="light"] body {
  background-image:
    radial-gradient(900px 460px at 18% -18%, rgba(14, 113, 128, .08), transparent 66%),
    radial-gradient(760px 380px at 88% -6%, rgba(14, 113, 128, .05), transparent 64%);
}
:root[data-theme="light"] .hero::after { background: radial-gradient(circle at 50% 50%, rgba(14, 113, 128, .12), transparent 62%); }

/* a faint horizon so the first screen reads as "water", not a flat panel */
main > section, main > .section { position: relative; }
main > section::before,
main > .section::before,
main > .wrap > section::before,
main > .wrap > .section::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* table affordance at narrow widths */
@media (max-width: 640px) {
  .table-wrap { position: relative; }
  .table-wrap::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(270deg, var(--surface), transparent);
  }
}

/* no theme attribute yet (before core.js runs): follow the OS immediately */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --muted-2: #4a5a68;
    --bg: #f4f7f9;
    --surface: #ffffff;
    --surface-alt: #eaf0f4;
    --text: #0c0f16;
    --text-muted: #4a5a68;
    --border: rgba(12, 15, 22, .12);
    --border-strong: rgba(12, 15, 22, .3);
    --brand: #0e7180;
    --brand-strong: #0b5a66;
    --brand-soft: rgba(14, 113, 128, .09);
    --on-brand: #ffffff;
    --focus: #0e7180;
    --ok: #0b6b53;
    --ok-soft: #e6f4ef;
    --danger: #a4232b;
    --danger-soft: #fdecec;
    --ring: rgba(14, 113, 128, .22);
  }
  :root:not([data-theme]) body {
    background-image:
      radial-gradient(900px 460px at 18% -18%, rgba(14, 113, 128, .08), transparent 66%),
      radial-gradient(760px 380px at 88% -6%, rgba(14, 113, 128, .05), transparent 64%);
  }
}

/* v3.2 */
.hero { padding: clamp(64px, 11vw, 150px) 0 clamp(40px, 6vw, 84px); }
.hero h1 { font-size: clamp(2.6rem, 1.6rem + 4.6vw, 5.2rem); max-width: 16ch; }
.hero .lede { max-width: 58ch; }

/* ============================================================================
   v3.3 — the stage. Content stays inside .wrap, the scene does not.
   ========================================================================== */

/* first screen breaks the container so the statement owns the viewport */
.hero {
  position: relative;
  padding-inline: max(16px, calc(50% - 590px));
  padding-block: clamp(72px, 13vh, 168px) clamp(48px, 9vh, 104px);
  min-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.hero > * { position: relative; z-index: 1; }

/* the scene: a water line plus a low silhouette, no WebGL, no images */
.hero-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hero-stage::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 48%;
  background:
    linear-gradient(180deg, rgba(26, 172, 192, .12), rgba(26, 172, 192, 0) 74%);
}

.hero-stage::after {
  content: "";
  position: absolute;
  left: -6%; right: -6%; bottom: -1px;
  height: 30%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 30%, transparent), transparent 84%);
  clip-path: polygon(0 100%, 0 58%, 7% 44%, 14% 52%, 22% 36%, 31% 50%, 40% 32%, 50% 48%, 59% 36%, 68% 52%, 77% 42%, 86% 56%, 94% 44%, 100% 54%, 100% 100%);
  opacity: .5;
}

:root[data-theme="light"] .hero-stage::after { opacity: .3; }

/* left-hand section index, in the margin, above 1320px only */
.section-rail { display: none; }

@media (min-width: 1440px) {
  .section-rail {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: fixed;
    left: clamp(20px, calc(50% - 697px), 220px);
    top: 44vh;
    z-index: 20;
    font-size: .76rem;
    letter-spacing: .02em;
  }

  .section-rail a {
    display: flex;
    align-items: baseline;
    gap: 10px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color .3s var(--ease);
  }

  .section-rail a .n {
    font-variant-numeric: tabular-nums;
    color: var(--muted-2);
    transition: color .3s var(--ease);
  }

  .section-rail a:hover { color: var(--brand); }
  .section-rail a.is-current { color: var(--text); }
  .section-rail a.is-current .n { color: var(--text); }
}

/* the header is part of the scene until you scroll */
.site-header {
  background: transparent;
  border-bottom: 0;
  backdrop-filter: none;
  transition: background .3s var(--ease), border-color .3s var(--ease), backdrop-filter .3s var(--ease);
}

.site-header.is-scrolled {
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(120%);
}

@media print {
  .hero-stage, .section-rail { display: none !important; }
  .hero { margin-inline: 0; padding-inline: 0; min-height: 0; }
}

/* v3.3b — the scene must never reduce text contrast */
.hero-stage::before {
  height: 42%;
  background: linear-gradient(180deg,
    rgba(26, 172, 192, 0) 0%,
    rgba(26, 172, 192, .10) 48%,
    rgba(26, 172, 192, 0) 100%);
}

.hero-stage::after {
  height: 22%;
  bottom: -2px;
  opacity: .38;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 26%, transparent), transparent 88%);
}

:root[data-theme="light"] .hero-stage::before {
  background: linear-gradient(180deg,
    rgba(14, 113, 128, 0) 0%,
    rgba(14, 113, 128, .07) 48%,
    rgba(14, 113, 128, 0) 100%);
}
:root[data-theme="light"] .hero-stage::after { opacity: .18; }

/* rail lives in the outer margin, never beside the headline */
@media (min-width: 1320px) {
  .section-rail {
    left: clamp(20px, calc(50% - 697px), 220px);
    top: 36vh;
    gap: 14px;
  }
  .section-rail a { font-size: .72rem; }
}

/* ============================================================================
   v3.4 — stage review fixes
   ========================================================================== */

/* 1. the rail only exists where the margin is really free (>=1430px) */
@media (max-width: 1429px) {
  .section-rail { display: none !important; }
}

@media (min-width: 1430px) {
  .section-rail { left: clamp(20px, calc(50% - 700px), 220px); }
  .section-rail a { min-height: 24px; padding-block: 3px; align-items: center; }
  .section-rail a .n { display: inline-block; min-width: 2ch; }
}

/* 2. the glow must not be clipped by the hero box: clip only the scene layer */
.hero { overflow: visible; }
.hero-stage { overflow: hidden; }

/* 6. a real first screen: the reference uses height:100svh, so do we (no cap) */
.hero { min-height: 100vh; min-height: 100svh; }

/* 3. a top scrim keeps the transparent header readable over the glow */
.site-header {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg) 80%, transparent) 0%,
    color-mix(in srgb, var(--bg) 34%, transparent) 62%,
    transparent 100%);
}

/* 8. no 1px jump when the bar appears: constant box, colour-only change */
.site-header { border-bottom: 0; box-shadow: none; }
.site-header.is-scrolled {
  border-bottom: 0;
  box-shadow: inset 0 -1px 0 0 var(--border);
}

/* 11. reduced motion also covers the header transition */
@media (prefers-reduced-motion: reduce) {
  .site-header { transition: none; }
  .section-rail a, .section-rail a .n { transition: none; }
}

/* 12. the silhouette sits lower, so no text can ever ride its brightest edge */
.hero-stage::after { height: 20%; bottom: -6%; opacity: .28; }
:root[data-theme="light"] .hero-stage::after { opacity: .14; }

/* 13. the current nav item underlines without nudging its baseline */
.site-nav a[aria-current="page"] {
  border-bottom: 0;
  padding-bottom: 0;
  position: relative;
}
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -9px;
  height: 1px;
  background: var(--brand);
}

/* 7. printing: keep a margin and drop the decorative glow */
@media print {
  .hero { padding-inline: 18px; }
  .hero::after { display: none; }
  .hero-stage { display: none; }
}

/* ============================================================================
   v3.5 — final stage polish
   ========================================================================== */

:root { --hero-offset: 84px; }          /* header 64 + main padding 20 */
@media (max-width: 640px) { :root { --hero-offset: 118px; } }

@media screen {
  .hero {
    min-height: calc(100vh - var(--hero-offset));
    min-height: calc(100svh - var(--hero-offset));
  }
}

/* ============ printing: the first screen is a screen device, not a page ============ */
@media print {
  .hero {
    min-height: 0 !important;
    padding-block: 0 18px !important;
    padding-inline: 18px !important;
  }
}

/* the silhouette reads as a shape again, and sits behind no text */
.hero-stage::after {
  height: 26%;
  bottom: 0;
  opacity: .45;
}
:root[data-theme="light"] .hero-stage::after { opacity: .2; }

/* keep the copy clear of the silhouette band */
.hero { padding-block: clamp(56px, 11vh, 150px) clamp(96px, 16vh, 190px); }

/* phones: the first screen must not cut a sentence in half */
@media (max-width: 640px) {
  .hero {
    padding-block: 40px 84px;
    min-height: calc(100svh - var(--hero-offset));
  }
  .hero h1 { font-size: clamp(2rem, 8.6vw, 2.6rem); }
  .hero .lede { font-size: .95rem; line-height: 1.55; }
  .hero-badges { margin-bottom: 0; }
}

@media (max-height: 640px) {
  .hero-badges { display: none; }
  .hero h1 { font-size: clamp(1.8rem, 7vw, 2.2rem); }
}

/* ============================================================================
   v3.6 — consistency layer. The reference site's stage stays on the home page;
   everything that is a tool or a document falls back to plain reading rules.
   ========================================================================== */

/* prose pages share one centred reading column */
main.reading {
  max-width: 780px;
  margin-inline: auto;
  padding-inline: 16px;
}

main.reading .prose { max-width: none; }

main.reading .page-head,
main.reading > h1 { margin-bottom: clamp(14px, 2vw, 22px); }

/* headings inside a document get a hairline rhythm instead of cards */
main.reading h2 {
  margin-top: 2.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  font-size: clamp(1.2rem, 1rem + .5vw, 1.45rem);
  letter-spacing: -.015em;
}

main.reading .prose > h2:first-of-type { margin-top: 1.2rem; }

main.reading h3 {
  margin-top: 1.6rem;
  font-size: 1.05rem;
}

/* the meta line under a document title */
.meta-line {
  margin: 0 0 1.4rem;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* calculator pages: one head block, breadcrumb never wraps */
.page-head { margin-bottom: clamp(18px, 2.6vw, 30px); }
.page-head h1 { margin-bottom: 12px; }
.page-head .answer-bar { margin: 0; }

.breadcrumb ol {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
}

.breadcrumb li { white-space: nowrap; }
.breadcrumb li:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumb ol li[aria-current="page"] { color: var(--text-muted); }

/* prose inside a reading column keeps a comfortable measure without its own width */
main.reading p,
main.reading li { max-width: 72ch; }

@media print {
  main.reading { max-width: none; }
  main.reading h2 { border-top: 1px solid #bbb; }
}

/* reading pages: no stage → guides and legal share one document language */
main.reading .hero {
  min-height: 0;
  margin: 0;
  padding: 0 0 24px;
  display: block;
  overflow: visible;
}
main.reading .hero::before,
main.reading .hero::after,
main.reading .hero-stage,
main.reading .hero-badges { display: none; }
main.reading .hero h1 {
  font-family: var(--font-sans);
  font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -.03em;
  max-width: none;
}
main.reading .hero .lede { font-size: 1rem; }

/* ============================================================================
   v3.7 — final review fixes
   ========================================================================== */

/* 1. reading pages need air under the sticky header (the .wrap padding was eating it) */
main.reading { padding-top: clamp(24px, 4vw, 44px); }

/* 2. one title weight and one ceiling for every document page */
main.reading .hero h1 {
  font-weight: 500;
  font-size: clamp(1.9rem, 1.4rem + 1.6vw, 3.2rem);
}

/* 3. the hero column lines up with the body column: add the .wrap inline padding back */
.hero { padding-inline: max(16px, calc(50% - 590px + 16px)); }

/* 4. phone hero offset matches the real header height (110 + 20) */
@media (max-width: 640px) {
  :root { --hero-offset: 130px; }
}

/* 5. one breakpoint for the section rail: no positioning without display */
@media (min-width: 1430px) and (max-width: 1439px) {
  .section-rail { left: clamp(20px, calc(50% - 700px), 220px); }
}

/* 6. no orphan rule above the first section of a document */
main.reading section:first-of-type::before,
main.reading .prose > h2:first-of-type::before { display: none; }

/* 7. a slightly stronger scrim keeps the transparent header clear of the glow */
.site-header {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg) 86%, transparent) 0%,
    color-mix(in srgb, var(--bg) 40%, transparent) 62%,
    transparent 100%);
}

/* ============================================================================
   v3.8 — loose ends
   ========================================================================== */

/* 1. one formula for every document title: guides and legal render the same size */
main.reading h1,
main.reading .hero h1 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: clamp(2rem, 1.3rem + 2.6vw, 3.2rem);
  line-height: 1.06;
  letter-spacing: -.03em;
}

/* 2. no orphan rule above the first section of a document (the border lives on the
      section, not on the ::before decoration) */
main.reading section:first-of-type,
main.reading .prose > h2:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

/* the author line under a document title: a role, not a credential */
.author-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--text);
}

/* AdSense marks each unit with data-ad-status once it knows whether it filled.
   An unfilled unit must not leave a 280px hole in the page. */
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) {
  display: none !important;
}
.ad-slot ins.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
}
.ad-slot:has(ins.adsbygoogle[data-ad-status="filled"]) {
  min-height: 0;
}
/* reserve space only while a unit is still resolving, and only a modest amount */
.ad-slot:not(:has(ins.adsbygoogle)) { min-height: 0; }

/* The label is part of the ad, not part of the page: it only exists once a unit filled.
   An unfilled slot therefore collapses to nothing instead of showing a floating caption. */
.ad-slot .ad-label { display: none; margin: 0; }
.ad-slot:has(ins.adsbygoogle[data-ad-status="filled"]) .ad-label { display: block; }
.ad-slot:not(:has(ins.adsbygoogle[data-ad-status="filled"])) {
  margin: 12px 0;
  min-height: 0;
}

/* a route to the hub page at the end of a home section */
.section-more {
  margin: 26px 0 0;
  font-size: .95rem;
}
.section-more a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
}
.section-more a:hover { border-bottom-color: var(--accent); }

/* ============================================================================
v3.9 — the hero is not a full screen on a phone
   `min-height: 100svh` with centered content left ~200px of empty stage above the
   headline and ~150px below the badges on a 390x844 phone. On small screens the hero
   becomes a normal block: content first, decoration clipped to a short band.
   ========================================================================== */
@media (max-width: 640px) {
  .hero {
    min-height: 0;
    padding-top: 28px;
    padding-bottom: 36px;
    justify-content: flex-start;
  }
  .hero-stage {
    position: absolute;
    inset: 0;
    height: 100%;
    min-height: 0;
  }
}
