/* ==========================================================================
   Tidy Cache — design system
   Warm paper + ink + vermilion. Editorial serif display, system sans body.
   ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */
:root {
  /* surfaces */
  --paper: #faf7f2;
  --paper-2: #f3eee4;
  --paper-3: #ece5d8;
  --surface: #ffffff;
  --surface-2: #fdfbf7;

  /* ink */
  --ink: #14181e;
  --ink-2: #2c333d;
  --ink-3: #4a525e;
  --muted: #6f6a61;
  --muted-2: #8b857a;

  /* lines */
  --line: #e5ddcf;
  --line-2: #d8cebc;
  --line-strong: #c4b8a2;

  /* brand */
  --accent: #b23b18;
  --accent-hover: #96300f;
  --accent-soft: #fbeee7;
  --accent-line: #efd3c6;
  --teal: #0e5e52;
  --teal-soft: #e6f1ee;
  --gold: #a97c25;
  --gold-soft: #f8f0dc;

  /* semantic */
  --ok: #146c43;
  --ok-soft: #e7f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf1dd;
  --err: #a42222;
  --err-soft: #fbeaea;

  /* type */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* rhythm */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 88px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  --shadow-1: 0 1px 2px rgba(20, 24, 30, 0.05);
  --shadow-2: 0 2px 6px rgba(20, 24, 30, 0.06), 0 12px 28px -18px rgba(20, 24, 30, 0.18);
  --shadow-3: 0 4px 10px rgba(20, 24, 30, 0.07), 0 24px 48px -24px rgba(20, 24, 30, 0.24);

  --wrap: 1160px;
  --wrap-narrow: 760px;
  --header-h: 66px;
}

/* --- 2. Reset ------------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 18px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.14;
  margin: 0 0 var(--sp-3);
  font-variation-settings: "SOFT" 0, "WONK" 0;
}

h1 { font-size: clamp(2rem, 1.35rem + 2.2vw, 3.05rem); letter-spacing: -0.028em; }
h2 { font-size: clamp(1.45rem, 1.15rem + 1vw, 1.95rem); }
h3 { font-size: clamp(1.12rem, 1rem + 0.4vw, 1.28rem); }

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

img, svg, canvas { max-width: 100%; height: auto; display: block; }
ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.35em; }
li { margin-bottom: var(--sp-2); }
li::marker { color: var(--muted-2); }
strong { font-weight: 650; color: var(--ink); }
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1em 0.36em;
}
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-7) 0; }
::selection { background: var(--accent); color: #fff; }

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

/* --- 3. Layout ----------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--sp-5);
}
.wrap-narrow { max-width: var(--wrap-narrow); }
.section { padding-block: var(--sp-8); }
.section-tight { padding-block: var(--sp-6); }
.stack > * + * { margin-top: var(--sp-4); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* --- 4. Header ----------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(250, 247, 242, 0.88);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--ink);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  box-shadow: var(--shadow-1);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.16rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand-name span { color: var(--accent); }

.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 0.925rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  font-family: inherit;
}
.nav-link:hover { background: var(--paper-2); color: var(--ink); }
.nav-link[aria-current="page"] { color: var(--accent); }
.nav-caret { width: 9px; height: 9px; transition: transform 0.18s ease; }
.nav-link[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }

.header-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: var(--sp-3);
  padding: 9px 15px;
  border-radius: var(--r-full);
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 550;
  text-decoration: none;
  border: 1px solid var(--ink);
  transition: background 0.16s ease, transform 0.16s ease;
}
.header-cta:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* mega menu */
.mega {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  top: calc(var(--header-h) - 4px);
  width: min(1060px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: var(--sp-5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}
.mega[data-open="true"] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.mega-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-5) var(--sp-5);
}
.mega-col h3 {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--sp-2);
}
.mega-col ul { list-style: none; margin: 0; padding: 0; }
.mega-col li { margin: 0; }
.mega-col a {
  display: block;
  padding: 5px 8px;
  margin-left: -8px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--ink-2);
  text-decoration: none;
  overflow-wrap: break-word;
}
.mega-col a:hover { background: var(--accent-soft); color: var(--accent-hover); }
.mega-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--muted);
}

/* mobile nav */
.nav-toggle {
  display: none;
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  cursor: pointer;
  place-items: center;
}
.nav-toggle span {
  display: block;
  width: 17px;
  height: 1.8px;
  background: var(--ink);
  border-radius: 2px;
  position: relative;
}
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 17px;
  height: 1.8px;
  background: var(--ink);
  border-radius: 2px;
}
.nav-toggle span::before { top: -5.5px; }
.nav-toggle span::after { top: 5.5px; }
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after { transition: transform 0.18s ease, top 0.18s ease, background 0.18s ease; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { top: 0; transform: rotate(-45deg); }

.mobile-panel {
  display: none;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  max-height: calc(100vh - var(--header-h));
  overflow: auto;
}
.mobile-panel[data-open="true"] { display: block; }
.mobile-panel .wrap { padding-block: var(--sp-4); }
.mobile-panel a {
  display: block;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.95rem;
}
.mobile-panel .mob-head {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  padding: var(--sp-4) 0 var(--sp-2);
}

/* --- 5. Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 550;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(178, 59, 24, 0.25), 0 10px 22px -14px rgba(178, 59, 24, 0.6);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; border-color: #000; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); border-color: transparent; }
.btn-sm { padding: 7px 13px; font-size: 0.855rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

/* --- 6. Badges & pills --------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 550;
  color: var(--ink-3);
  text-decoration: none;
  line-height: 1.4;
}
.pill-accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-hover); }
.pill-teal { background: var(--teal-soft); border-color: #cfe3de; color: var(--teal); }
.pill-gold { background: var(--gold-soft); border-color: #ecdcb5; color: var(--gold); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-3);
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 1.5px;
  background: var(--accent);
  display: block;
}

/* --- 7. Cards ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--sp-5); }
.card-hover { transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease; }
.card-hover:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-2px); }

/* --- 8. Hero ------------------------------------------------------------- */
.hero {
  position: relative;
  padding-block: var(--sp-7) var(--sp-6);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(20, 24, 30, 0.09) 1px, transparent 0);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 20%, transparent 75%);
  pointer-events: none;
}
.hero > .wrap { position: relative; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: var(--sp-7);
  align-items: start;
}
.hero h1 { margin-bottom: var(--sp-3); }
.hero-lede {
  font-size: 1.06rem;
  color: var(--ink-3);
  max-width: 56ch;
  margin-bottom: var(--sp-5);
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

/* breadcrumbs */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: var(--sp-4);
  list-style: none;
  padding: 0;
}
.crumbs li { margin: 0; display: inline-flex; align-items: center; gap: 7px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--line-strong); }
.crumbs [aria-current] { color: var(--ink-3); }

/* --- 9. Calculator shell ------------------------------------------------- */
.calc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 13px var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.calc-head h2, .calc-head h3 {
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.calc-head .dots { display: flex; gap: 5px; }
.calc-head .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); display: block; }
.calc-head .dots i:first-child { background: var(--accent); }

.calc-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.94fr);
}
.calc-inputs { padding: var(--sp-5); }
.calc-inputs, .calc-result { min-width: 0; }
.calc-result {
  padding: var(--sp-5);
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface));
}

/* segmented control (radio group) */
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  gap: 2px;
}
.seg label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: 0.87rem;
  font-weight: 550;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  white-space: nowrap;
}
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:hover { color: var(--ink); }
.seg input:checked + span,
.seg label:has(input:checked) {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* tabs */
.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}
.tabs button {
  flex: 1;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.tabs button:hover { color: var(--ink); }

/* fields */
.field { margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: 0.855rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field-label .unit { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.field-hint { font-size: 0.79rem; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.input, .select, textarea.input {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}
.input::placeholder { color: var(--muted-2); font-family: var(--font-body); }
.input:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(178, 59, 24, 0.12);
}
.select {
  font-family: var(--font-body);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%236f6a61' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
  cursor: pointer;
}
.input[aria-invalid="true"] { border-color: var(--err); background: var(--err-soft); }
.field-error { font-size: 0.8rem; color: var(--err); margin-top: 5px; display: none; }
.field-error[data-show="true"] { display: block; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }

/* range */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--paper-3) var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-1);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--paper-3); }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}

/* result panel */
.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.result-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.result-value {
  font-family: var(--font-mono);
  font-size: clamp(1.85rem, 1.3rem + 1.7vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
  word-break: break-word;
}
.result-value small { font-size: 0.5em; color: var(--muted); font-weight: 500; margin-left: 4px; }
.result-sub { font-size: 0.88rem; color: var(--ink-3); margin-top: 6px; }
.result-rows { margin-top: var(--sp-4); border-top: 1px solid var(--line); }
.result-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.result-row > * { min-width: 0; overflow-wrap: anywhere; }
.result-row:last-child { border-bottom: 0; }
.result-row dt { color: var(--muted); margin: 0; }
.result-row dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--ink);
  text-align: right;
  word-break: break-word;
}
.result-row dd.is-strong { font-weight: 600; }
.result-empty { color: var(--muted); font-size: 0.9rem; padding: var(--sp-4) 0; }
.result-note {
  margin-top: var(--sp-4);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  font-size: 0.83rem;
  color: var(--accent-hover);
  line-height: 1.55;
}
.result-note.is-warn { background: var(--warn-soft); border-color: #f0dcb6; color: var(--warn); }
.result-note.is-err { background: var(--err-soft); border-color: #f0c9c9; color: var(--err); }
.result-note.is-ok { background: var(--ok-soft); border-color: #c9e5d4; color: var(--ok); }

.copy-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  flex: 0 0 auto;
  padding: 0;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.copy-btn svg { width: 13px; height: 13px; }

/* steps */
.steps { counter-reset: step; margin: var(--sp-4) 0 0; padding: 0; list-style: none; }
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 30px;
  font-size: 0.875rem;
  color: var(--ink-3);
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 0.68rem;
  display: grid;
  place-items: center;
  font-family: var(--font-body);
  font-weight: 700;
}

/* --- 10. Prose / content sections --------------------------------------- */
.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--sp-7); scroll-margin-top: calc(var(--header-h) + 20px); }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: var(--sp-5); }
.prose > p { color: var(--ink-2); }
.prose ul, .prose ol { color: var(--ink-2); }
.prose li { margin-bottom: 9px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.section-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
  padding-top: 3px;
}

.lede { font-size: 1.06rem; color: var(--ink-3); }

/* formula block */
.formula {
  margin: var(--sp-4) 0;
  padding: var(--sp-4) var(--sp-5);
  background: var(--ink);
  color: #f4efe6;
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.7;
  overflow-x: auto;
  position: relative;
}
.formula .k { color: #ffb08a; }
.formula .m { color: #9fd8c9; }
.formula-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a49c8e;
  margin-bottom: 6px;
}

/* callout */
.callout {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin: var(--sp-4) 0;
  font-size: 0.93rem;
  color: var(--ink-2);
}
.callout .ic {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.8rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--ink); }
.callout-warn { background: var(--warn-soft); border-color: #f0dcb6; }
.callout-warn .ic { background: #f7e2bc; color: var(--warn); }
.callout-teal { background: var(--teal-soft); border-color: #cfe3de; }
.callout-teal .ic { background: #d3e8e2; color: var(--teal); }

.chart-slot { margin-top: var(--sp-4); }
.chart-slot:empty { display: none; }
.chart-slot canvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

/* --- 11. Tables ---------------------------------------------------------- */
.table-wrap {
  margin: var(--sp-5) 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: auto;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: min(460px, 100%);
}
caption {
  caption-side: top;
  text-align: left;
  padding: 12px var(--sp-4);
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
th, td {
  padding: 10px var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--line);
}
thead th {
  background: var(--paper-2);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: var(--surface-2); }
td.num, th.num { font-family: var(--font-mono); font-size: 0.86rem; white-space: nowrap; }
tbody tr[data-value] { cursor: pointer; transition: background 0.12s ease; }
tbody tr[data-value]:hover { background: var(--accent-soft); }
tbody tr[data-value]:hover td:first-child::after {
  content: "↗";
  margin-left: 6px;
  color: var(--accent);
  font-size: 0.8em;
}

/* --- 12. Tool grid ------------------------------------------------------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: var(--sp-4);
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: var(--sp-4) var(--sp-4) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  position: relative;
}
.tool-card p, .tool-card .eg { overflow-wrap: anywhere; }
.tool-card:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  color: inherit;
}
.tool-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.tool-glyph {
  width: auto;
  min-width: 34px;
  padding: 0 7px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  color: var(--ink-2);
  font-weight: 600;
}
.tool-card:hover .tool-glyph { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.tool-card h3 {
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.tool-card p {
  margin: 0;
  font-size: 0.845rem;
  color: var(--muted);
  line-height: 1.5;
}
.tool-card .eg {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-3);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- 13. FAQ ------------------------------------------------------------- */
.faq-list { display: grid; gap: var(--sp-2); margin-top: var(--sp-4); }
.faq {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.16s ease;
}
.faq[open] { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.faq summary {
  cursor: pointer;
  padding: 15px var(--sp-4);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  font-family: var(--font-body);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--muted);
  flex: 0 0 auto;
  line-height: 1;
  transition: transform 0.2s ease;
}
.faq[open] summary::after { transform: rotate(45deg); color: var(--accent); }
.faq-body { padding: 0 var(--sp-4) var(--sp-4); font-size: 0.93rem; color: var(--ink-3); }
.faq-body p:last-child { margin-bottom: 0; }

/* --- 14. Footer ---------------------------------------------------------- */
.site-footer {
  margin-top: var(--sp-8);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  padding-block: var(--sp-7) var(--sp-5);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: var(--sp-6) var(--sp-5);
}
.footer-brand p { font-size: 0.9rem; color: var(--muted); max-width: 34ch; margin-top: var(--sp-3); }
.footer-col h4 {
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--sp-3);
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin: 0; }
.footer-col a {
  display: block;
  padding: 4px 0;
  font-size: 0.85rem;
  color: var(--ink-3);
  text-decoration: none;
}
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-bottom p { margin: 0; }
.footer-legal { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.footer-legal a { color: var(--muted); text-decoration: none; }
.footer-legal a:hover { color: var(--accent); text-decoration: underline; }

/* --- 15. Blog ------------------------------------------------------------ */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-5); }
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
.post-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-2px); color: inherit; }
.post-card-body { padding: var(--sp-5); display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-card h3 { font-size: 1.12rem; margin: 0; line-height: 1.3; }
.post-card p { font-size: 0.9rem; color: var(--muted); margin: 0; }
.post-meta { display: flex; align-items: center; gap: 10px; font-size: 0.78rem; color: var(--muted); margin-top: auto; padding-top: var(--sp-3); }
.post-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

.article { max-width: 74ch; margin-inline: auto; }
.article-header h1 { font-size: clamp(1.85rem, 1.25rem + 1.7vw, 2.55rem); max-width: 22ch; }
.article-header { margin-bottom: var(--sp-6); }
.article-meta { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; font-size: 0.82rem; color: var(--muted); margin-top: var(--sp-3); }
.article-body h2 { margin-top: var(--sp-7); }
.article-body h3 { margin-top: var(--sp-5); }
.article-body p, .article-body li { color: var(--ink-2); }
.article-body blockquote {
  margin: var(--sp-5) 0;
  padding: var(--sp-4) var(--sp-5);
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--ink-2);
}
.article-body blockquote p { margin: 0; }

.toc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-5);
  font-size: 0.9rem;
}
.toc strong { display: block; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: var(--sp-2); }
.toc ol { margin: 0; padding-left: 1.2em; }
.toc li { margin-bottom: 4px; }
.toc a { color: var(--ink-3); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* --- 16. Misc blocks ----------------------------------------------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-4);
  margin: var(--sp-5) 0;
}
.stat {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}
.stat span { font-size: 0.8rem; color: var(--muted); display: block; margin-top: 4px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); align-items: start; }

.note-inline {
  font-size: 0.85rem;
  color: var(--muted);
  border-left: 2px solid var(--line-2);
  padding-left: var(--sp-3);
  margin: var(--sp-4) 0;
}

.canvas-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--sp-4);
  margin: var(--sp-4) 0;
}
.canvas-card canvas { width: 100%; height: auto; border-radius: 6px; }
.canvas-legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); font-size: 0.78rem; color: var(--muted); margin-top: var(--sp-2); }
.canvas-legend i { display: inline-block; width: 14px; height: 2px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 11px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.14s ease;
}
.chip:hover, .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.related-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.related-strip a {
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--r-full);
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  text-decoration: none;
}
.related-strip a:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-hover); }

.cta-band {
  margin-top: var(--sp-7);
  padding: var(--sp-6);
  border-radius: var(--r-xl);
  background: var(--ink);
  color: #f3eee4;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  align-items: center;
  justify-content: space-between;
}
.cta-band h2 { color: #fff; margin: 0 0 6px; font-size: 1.4rem; }
.cta-band p { margin: 0; color: #c3bcaf; font-size: 0.92rem; max-width: 52ch; }
.cta-band .btn-primary { flex: 0 0 auto; }

.ad-slot {
  margin: var(--sp-6) 0;
  min-height: 90px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: var(--surface-2);
}

/* --- 16b. Document layout with side table of contents -------------------- */
.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: var(--sp-7);
  align-items: start;
}
.doc-grid > .prose { max-width: none; }
.toc-side {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  font-size: 0.86rem;
}
.toc-side .toc { padding: var(--sp-4); }
.toc-side .toc ol { padding-left: 1.15em; }
.toc-side .toc a { display: block; padding: 3px 0; line-height: 1.4; }
.toc-side .toc li { margin-bottom: 2px; }

.page-home .hero-grid {
  grid-template-columns: minmax(0, 0.84fr) minmax(0, 1.16fr);
  gap: var(--sp-6);
}
.page-home .hero .calc-head h2 { letter-spacing: 0.06em; }

/* the directory band sits outside the prose column so cards get full width */
.directory {
  margin-top: var(--sp-7);
  padding-top: var(--sp-7);
  border-top: 1px solid var(--line);
}
.directory > section + section { margin-top: var(--sp-7); }
.directory .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* the header mega menu truncates to keep its panel tidy; the page directory wraps instead */
.directory .mega-col a { white-space: normal; overflow: visible; text-overflow: clip; }
@media (max-width: 960px) {
  .directory .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .directory .tool-grid { grid-template-columns: minmax(0, 1fr); }
}

/* tool pages: the calculator needs more room than the prose column */
.page-tool .hero-grid { grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr); }
.page-tool .calc-body { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
.page-tool .calc-inputs, .page-tool .calc-result { padding: var(--sp-4) var(--sp-4) var(--sp-5); }

/* --- 17. Responsive ------------------------------------------------------ */
@media (max-width: 1080px) {
  .mega-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: 1.4fr repeat(2, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
  .doc-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); }
  .toc-side { display: none; }
  .page-home .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .page-tool .hero-grid { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
}

@media (max-width: 960px) {
  .hero-grid, .page-tool .hero-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); }
  .calc-body, .page-tool .calc-body { grid-template-columns: minmax(0, 1fr); }
  .calc-result { border-left: 0; border-top: 1px solid var(--line); }
  .page-tool .calc-inputs, .page-tool .calc-result { padding: var(--sp-5); }
  .split { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
  .nav { display: none; }
  .header-cta { display: none; }
  .nav-toggle { display: grid; }
  .section { padding-block: var(--sp-7); }
  .cta-band { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .wrap { padding-inline: var(--sp-4); }
  .mega { display: none !important; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { padding-block: var(--sp-5) var(--sp-5); }
  .calc-inputs, .calc-result { padding: var(--sp-4); }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .tabs button { font-size: 0.8rem; padding: 7px 6px; }
  .faq summary { padding: 13px var(--sp-4); font-size: 0.92rem; }
}

@media (max-width: 420px) {
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .seg label { padding: 6px 10px; font-size: 0.82rem; }
}

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

@media print {
  .site-header, .site-footer, .calc, .cta-band, .ad-slot, .nav-toggle { display: none !important; }
  body { background: #fff; }
  .prose { max-width: none; }
}
