:root {
  --bg: #E8F0F5;
  --surface: #FFFFFF;
  --ink: #12263A;
  --muted: #4F6376;
  --line: #C5D5E0;
  --track: #D2E0EA;
  --accent: #F0B02A;
  --font-display: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1A26;
    --surface: #15283A;
    --ink: #EAF2F7;
    --muted: #9DB2C3;
    --line: #274058;
    --track: #21394F;
    --accent: #F4BC3E;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1A26;
  --surface: #15283A;
  --ink: #EAF2F7;
  --muted: #9DB2C3;
  --line: #274058;
  --track: #21394F;
  --accent: #F4BC3E;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

html { scroll-padding-top: env(safe-area-inset-top, 0px); }
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1.25rem; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Header */
.site-header { padding: 1.1rem 0 0.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.brand svg { display: block; }

/* Ads */
.ad { margin: 1.5rem 0; min-height: 100px; border: 1px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 0.8rem; }
@media (min-width: 48rem) { .ad { min-height: 90px; } }

/* Hero */
h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(2rem, 7.5vw, 3.25rem); line-height: 1.04; letter-spacing: -0.025em; margin: 1rem 0 0.6rem; max-width: 18ch; }
.sub { margin: 0 0 1.5rem; color: var(--muted); max-width: 34rem; }

/* Converter */
.converter { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 1.25rem; }
.modes { display: flex; gap: 4px; padding: 4px; background: var(--track); border-radius: 999px; }
.modes button { flex: 1; font: inherit; font-weight: 600; font-size: 0.95rem; padding: 0.6rem 0.5rem; border: 0; border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.modes.animals button { font-size: 1.05rem; padding: 0.7rem 0.5rem; }
.modes.sub { margin-top: 0.7rem; background: transparent; border: 1px solid var(--line); }
.modes.sub button { font-size: 0.9rem; padding: 0.5rem; }
.modes.sub button[aria-pressed="true"] { background: var(--track); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }

.sizes { margin-top: 1.1rem; }
.sizes[hidden] { display: none; }
.field-label { font-size: 0.9rem; color: var(--muted); margin: 0 0 0.3rem; }
.size-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.size-btns button { font: inherit; font-weight: 600; font-size: 0.95rem; padding: 0.6rem 0.25rem; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); cursor: pointer; }
.size-btns button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.hint { margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--muted); }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin-top: 1.1rem; }
.fields[hidden] { display: none; }
.fields.single { grid-template-columns: 1fr; }
.field label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.3rem; }
.field input { width: 100%; font: inherit; font-weight: 600; font-size: 1.5rem; padding: 0.55rem 0.8rem; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 12px; }
.field input:focus { border-color: var(--ink); }

.result { margin-top: 1.4rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.msg { margin: 0; color: var(--muted); min-height: 7rem; display: flex; align-items: center; }
.msg[hidden] { display: none; }
.lead { margin: 0; color: var(--muted); }
.big { font-family: var(--font-display); font-weight: 800; font-size: clamp(5.5rem, 27vw, 9rem); line-height: 0.92; letter-spacing: -0.045em; margin: 0.15rem 0 0.2rem; font-variant-numeric: tabular-nums; }
.after { margin: 0; font-size: 1.15rem; font-weight: 600; }

.stage { margin-top: 1.4rem; }
.stage-name { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: -0.01em; }
.stage-range { color: var(--muted); margin-left: 0.4rem; font-size: 0.95rem; }
.stage-text { margin: 0.3rem 0 0; max-width: 34rem; }

.track-wrap { padding: 0 13px; margin-top: 1.4rem; }
.track { position: relative; height: 12px; background: var(--track); border-radius: 999px; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.7s cubic-bezier(.2,.8,.2,1); }
.notches { position: absolute; inset: 0; display: grid; }
.notches span + span { border-left: 3px solid var(--surface); }
.marker { position: absolute; top: 50%; left: 0; width: 22px; height: 34px; margin: -17px 0 0 -11px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); transition: left 0.7s cubic-bezier(.2,.8,.2,1); }
.marker::after { content: ""; position: absolute; left: 50%; top: 14%; bottom: 14%; width: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--ink); }
.marker[data-animal="dog"] { width: 28px; height: 28px; margin: -14px 0 0 -14px; }
.marker[data-animal="dog"]::after { top: 50%; bottom: auto; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; }
.ends { display: flex; justify-content: space-between; margin-top: 0.7rem; font-size: 0.85rem; color: var(--muted); }

.share { margin-top: 1.3rem; font: inherit; font-weight: 600; padding: 0.65rem 1.1rem; border-radius: 999px; border: 2px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }

/* Content */
section.content { margin-top: 3rem; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 0.8rem; }
h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.01em; margin: 1.6rem 0 0.4rem; }
section.content p { max-width: 38rem; margin: 0 0 0.9rem; }
p.note { color: var(--muted); font-size: 0.9rem; margin-top: 0.7rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
td:nth-child(2) { font-weight: 600; }
table.dogs td:nth-child(n+2) { font-weight: 400; }
table.dogs td:first-child { font-weight: 600; }

dl.stages { margin: 0; }
dl.stages > div { display: grid; grid-template-columns: 8rem 1fr; gap: 0.2rem 1rem; padding: 0.9rem 0; border-top: 1px solid var(--line); }
dl.stages dt { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
dl.stages dt span { display: block; font-family: var(--font-body); font-weight: 400; font-size: 0.9rem; color: var(--muted); }
dl.stages dd { margin: 0; }
@media (max-width: 30rem) { dl.stages > div { grid-template-columns: 1fr; } }

details { border-top: 1px solid var(--line); }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; list-style: none; padding: 0.9rem 2rem 0.9rem 0; font-weight: 600; position: relative; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 0.25rem; top: 0.75rem; font-size: 1.4rem; line-height: 1.2; }
details[open] summary::after { content: "\2013"; }
details p { margin: 0 0 1rem; max-width: 38rem; }

footer { margin-top: 3rem; padding: 1.5rem 0 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
footer p { margin: 0; max-width: 38rem; }

@media (prefers-reduced-motion: reduce) {
  .fill, .marker { transition: none; }
}

/* Multi-page additions */
a { color: var(--ink); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.nav { display: flex; gap: 1.2rem; font-weight: 600; }
.nav a { text-decoration: none; padding: 0.4rem 0; }
.nav a:hover { text-decoration: underline; }
.crumbs { font-size: 0.875rem; color: var(--muted); margin: 1rem 0 0; }
.crumbs a { color: var(--muted); }
.answer { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 1.25rem; margin-top: 1rem; }
.answer .big { font-size: clamp(4.5rem, 20vw, 6.5rem); }
.answer .big.range { font-size: clamp(3rem, 15vw, 4.75rem); }
.answer .stage { margin-top: 1rem; }
.answer .track-wrap { margin-top: 1.2rem; }
.conv-h { margin-top: 3rem; }
.converter { margin-top: 1.5rem; }
h1 + .converter, .sub + .converter { margin-top: 0; }
h1 { max-width: 22ch; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.chips a { display: inline-block; padding: 0.4rem 0.8rem; border: 2px solid var(--line); border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 0.95rem; background: var(--surface); }
.chips a:hover { border-color: var(--ink); }
.chips a[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.pager a { font-weight: 600; }
ul.care { padding-left: 1.2rem; max-width: 38rem; margin: 0 0 1rem; }
ul.care li { margin-bottom: 0.4rem; }
table a { font-weight: 600; }
@media (max-width: 22rem) { .brand { font-size: 1.05rem; } .nav { gap: 0.8rem; } }
.foot-nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-bottom: 1rem; }
.foot-nav a { color: var(--muted); }
section.content h2 + p.note { margin-top: 0; }
