:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #1d1f1e;
  --muted: #5d625f;
  --line: #e2ded4;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --good: #15803d;
  --watch: #b45309;
  --replace: #b91c1c;
  --zone: #fde7c7;
  --r-year: #dbeafe; --r-year-ink: #1e40af;
  --r-month: #dcfce7; --r-month-ink: #166534;
  --r-week: #dcfce7; --r-week-ink: #166534;
  --r-plant: #ede9e3; --r-plant-ink: #57534e;
  --radius: 14px;
  --shadow: none;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615; --surface: #1d201f; --ink: #ecebe7; --muted: #a4a8a5; --line: #303432;
    --accent: #60a5fa; --accent-ink: #06122b; --good: #4ade80; --watch: #fbbf24; --replace: #f87171;
    --zone: #4a3415;
    --r-year: #1e3a8a; --r-year-ink: #dbeafe; --r-month: #14532d; --r-month-ink: #dcfce7;
    --r-week: #14532d; --r-week-ink: #dcfce7; --r-plant: #33302c; --r-plant-ink: #d6d3d1;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.6 var(--font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}
h1, h2, h3 { font-family: var(--font-display, inherit); }
a { color: var(--accent); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
header.site { border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 800; color: var(--ink); text-decoration: none; letter-spacing: -.01em; font-size: 18px; }
.logo b { color: var(--accent); }
nav.top a { color: var(--muted); text-decoration: none; margin-left: 16px; font-size: 15px; }
nav.top a:hover { color: var(--ink); }
main { padding: 28px 0 56px; }
h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; letter-spacing: -.02em; margin: 8px 0 10px; }
h2 { font-size: 23px; line-height: 1.25; margin: 40px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 18px; margin: 24px 0 6px; }
.lede { color: var(--muted); font-size: 19px; margin: 0 0 22px; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }

.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.tool form { display: grid; gap: 14px; }
.field label, .serial-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.tool select, .tool input {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-height: 48px;
}
.tool input.code { font-family: var(--mono); letter-spacing: .04em; }
.tool input::placeholder { letter-spacing: 0; font-family: inherit; }
.tool select:focus, .tool input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
button {
  font: inherit; font-weight: 700; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  padding: 0 22px; min-height: 48px; cursor: pointer;
}
button:hover { filter: brightness(1.07); }
.hint { font-size: 14px; color: var(--muted); margin: 0; }

.result { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.result-error { margin: 0; color: var(--replace); font-weight: 600; }
.eyebrow { font-size: 14px; color: var(--muted); font-weight: 600; }
.result-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.result-date { font-size: 28px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.result-age { text-align: right; }
.result-age-val { font-size: 28px; font-weight: 800; line-height: 1.2; }
.v-good .result-age-val { color: var(--good); }
.v-watch .result-age-val { color: var(--watch); }
.v-replace .result-age-val { color: var(--replace); }
.verdict { font-weight: 600; margin: 10px 0 0; }

.life { margin-top: 16px; }
.life-track { position: relative; height: 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.life-zone { position: absolute; top: 0; bottom: 0; background: var(--zone); }
.life-mark { position: absolute; top: -5px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); }
.life-cap { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }

.how { margin-top: 18px; background: var(--bg); border-radius: 10px; padding: 14px; }
.serial-hl { font-family: var(--mono); font-size: 22px; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 2px; }
.ch { padding: 2px 4px; border-radius: 4px; }
.r-year { background: var(--r-year); color: var(--r-year-ink); font-weight: 700; }
.r-month, .r-week { background: var(--r-month); color: var(--r-month-ink); font-weight: 700; }
.r-plant { background: var(--r-plant); color: var(--r-plant-ink); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.fmt { margin: 8px 0 0; font-size: 15px; }
.meta, .alt { font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; }
.c-high { color: var(--good); } .c-medium { color: var(--watch); } .c-low { color: var(--replace); }
.cta { display: block; margin-top: 16px; text-align: center; background: var(--ink); color: var(--bg); padding: 12px; border-radius: 10px; font-weight: 700; text-decoration: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--accent); }
.card strong { display: block; font-size: 17px; }
.card span { color: var(--muted); font-size: 14px; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 0; list-style: none; }
.brand-grid a { display: block; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); font-size: 15px; }
.brand-grid a:hover { border-color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0; }
.table-scroll { overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 14px; font-weight: 600; color: var(--muted); }
td code, p code, li code { font-family: var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: .92em; }
.letters { font-family: var(--mono); font-size: 14px; }
.letters td, .letters th { padding: 4px 8px; text-align: center; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 8px 0; }
summary { font-weight: 600; cursor: pointer; }
details p { margin: 8px 0 0; }

.ad-slot { margin: 28px 0; min-height: 100px; }
footer.site { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 14px; }
footer.site a { color: var(--muted); margin-right: 14px; }
@media (max-width: 520px) {
  .row { grid-template-columns: 1fr; }
  .result-age { text-align: left; }
  nav.top a { margin: 0 14px 0 0; }
}

/* ---- shared additions for calculator sites ---- */
nav.top a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.tool textarea { width: 100%; font: 14px/1.5 var(--mono); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 160px; }
.tool input[type=number], .tool input.num { font-family: inherit; text-transform: none; letter-spacing: 0; }
.unit { font-size: 13px; color: var(--muted); font-weight: 400; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; color: var(--ink); border-radius: 0; min-height: 40px; padding: 0 14px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); min-height: 40px; padding: 0 14px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: var(--bg); border-radius: 10px; padding: 12px; }
.stat .v { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat.hero { background: var(--accent); color: var(--accent-ink); }
.stat.hero .k { color: inherit; opacity: .85; }
.out { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.warn { color: var(--watch); font-weight: 600; }
.err { color: var(--replace); font-weight: 600; }
.small { font-size: 14px; color: var(--muted); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.best td { font-weight: 700; }
/* number inputs: no spinners (they steal width on small fields) */
.tool input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.tool input[type=number]::-webkit-inner-spin-button, .tool input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* nav: never break a link across lines; scroll sideways on narrow screens */
nav.top { display: flex; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
nav.top a { white-space: nowrap; }

/* keyboard focus + reduced motion (quality floor) */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Related-tool links: a plain list, not a grid of cards. */
.cards { display: block; columns: 2 240px; column-gap: 28px; margin-top: 8px; }
.card { display: block; break-inside: avoid; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 8px 0; color: var(--accent); }
.card:hover { border-color: var(--line); text-decoration: underline; }
.card strong { font-size: 17px; }
