/* ==========================================================================
   Paw Charts — "The Clinic Chart"
   Veterinary-record aesthetic: paper white, ink navy, one warm amber accent.
   Tabular numerals everywhere numbers matter. Triage colours are RESERVED for
   urgency states — never decorative.
   No frameworks. No webfonts. Mobile-first. Light + dark.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces — paper */
  --paper:      #ffffff;
  --paper-2:    #f6f8fb;
  --paper-3:    #eef2f7;
  --paper-sunk: #e7ecf3;

  /* Ink */
  --ink:        #0f2039;
  --ink-2:      #1d3352;
  --ink-muted:  #4e6076;
  --ink-faint:  #78889c;

  /* Rules — the chart grid */
  --rule:       #d7dfe9;
  --rule-soft:  #e9eef4;
  --rule-hard:  #b9c5d4;

  /* Accent — warm amber, used sparingly */
  --amber:      #b56f0d;
  --amber-2:    #96590a;
  --amber-tint: #fdf4e6;
  --amber-line: #edd6ab;

  /* Triage — RESERVED. Never use for decoration. */
  --ok:         #14663f;
  --ok-bg:      #e9f6ef;
  --ok-line:    #a9d8c1;
  --warn:       #8a5200;
  --warn-bg:    #fdf1e0;
  --warn-line:  #eec894;
  --danger:     #a41f16;
  --danger-bg:  #fdeceb;
  --danger-line:#f0b6b1;

  --focus:      #1f6feb;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --maxw: 74rem;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(15, 32, 57, .06), 0 8px 24px -12px rgba(15, 32, 57, .18);
  --shadow-pop:  0 8px 32px -8px rgba(15, 32, 57, .28);
  --header-h: 4.25rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:      #0d1521;
  --paper-2:    #121c2b;
  --paper-3:    #182436;
  --paper-sunk: #0a1119;

  --ink:        #e9eff7;
  --ink-2:      #d3dded;
  --ink-muted:  #a2b3c8;
  --ink-faint:  #7d8ea4;

  --rule:       #26374d;
  --rule-soft:  #1d2c3f;
  --rule-hard:  #3a4e68;

  --amber:      #e5a13f;
  --amber-2:    #f0b761;
  --amber-tint: #1f1a10;
  --amber-line: #4a3a1c;

  --ok:         #63c795;
  --ok-bg:      #0f2119;
  --ok-line:    #27503c;
  --warn:       #e0a busy;
  --warn:       #e6a busy;
  --warn:       #e3a955;
  --warn-bg:    #221a0d;
  --warn-line:  #54401d;
  --danger:     #f08b82;
  --danger-bg:  #241111;
  --danger-line:#5c2822;

  --focus:      #6ea8ff;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-pop:  0 8px 32px -8px rgba(0, 0, 0, .7);
}

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

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

body {
  background: var(--paper-2);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
svg { fill: currentColor; }

::selection { background: var(--amber-line); color: var(--ink); }

:where(a, button, input, select, textarea, summary, details):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--ink); color: var(--paper);
  padding: .75rem 1.25rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Typography ---------- */

h1, h2, h3, h4 {
  color: var(--ink);
  line-height: 1.22;
  letter-spacing: -0.015em;
  font-weight: 650;
  text-wrap: balance;
}
h1 { font-size: clamp(1.85rem, 4.6vw, 2.9rem); letter-spacing: -0.025em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 2.75rem 0 .9rem; }
h3 { font-size: clamp(1.13rem, 2.2vw, 1.32rem); margin: 2rem 0 .6rem; font-weight: 640; }
h4 { font-size: 1.03rem; margin: 1.4rem 0 .4rem; font-weight: 650; }
h2, h3, h4 { scroll-margin-top: calc(var(--header-h) + 1rem); }

p { margin: 0 0 1.1rem; }
p, li { color: var(--ink-muted); }
strong, b { color: var(--ink); font-weight: 640; }

a { color: var(--amber-2); text-decoration: underline; text-underline-offset: 2.5px; text-decoration-thickness: 1px; text-decoration-color: var(--amber-line); }
a:hover { color: var(--amber); text-decoration-color: currentColor; }
:root[data-theme="dark"] a { color: var(--amber); }
:root[data-theme="dark"] a:hover { color: var(--amber-2); }

ul, ol { padding-left: 1.3rem; margin: 0 0 1.1rem; }
li { margin-bottom: .4rem; }

blockquote {
  border-left: 3px solid var(--amber);
  padding: .25rem 0 .25rem 1.15rem;
  margin: 1.5rem 0;
  color: var(--ink);
}
blockquote p:last-child { margin-bottom: 0; }

code, kbd, .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
code {
  background: var(--paper-3);
  border: 1px solid var(--rule-soft);
  border-radius: 4px;
  padding: .1em .35em;
  font-size: .9em;
  color: var(--ink);
}

.linkish {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--amber-2); text-decoration: underline; text-underline-offset: 2.5px;
}

/* ---------- Layout ---------- */

.wrap        { max-width: var(--maxw); margin: 0 auto; padding: 0 1.15rem; }
.wrap-narrow { max-width: 47rem;  margin: 0 auto; padding: 0 1.15rem; }
main { display: block; }
.section { padding: 2.5rem 0; }

.divider {
  border: 0; height: 1px; margin: 3rem auto; max-width: var(--maxw);
  background: var(--rule);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--rule);
}
@supports not (backdrop-filter: blur(1px)) { .site-header { background: var(--paper); } }

.header-inner {
  display: flex; align-items: center; gap: .75rem;
  min-height: var(--header-h);
}

.brand {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none; color: var(--ink); margin-right: auto;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
/* The favicon file IS the header logo — same asset, so the two can never drift.
   The mark carries its own ink-navy tile, which reads crisply on the light
   header but sits almost on top of the dark one. A hairline ring at the tile's
   own corner radius (13/64 of the viewBox = 6px at 30px) gives the edge back
   without recolouring the artwork or forking the file. */
.brand-mark {
  width: 30px; height: 30px; flex-shrink: 0; display: block;
  border-radius: 6px;
}
:root[data-theme="dark"] .brand-mark {
  box-shadow: 0 0 0 1px var(--rule-hard);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 1.08rem; letter-spacing: -0.02em; color: var(--ink); }
.brand-tag { font-size: .68rem; color: var(--ink-faint); letter-spacing: .01em; }

.nav-list { list-style: none; display: flex; align-items: center; gap: .15rem; margin: 0; padding: 0; }

.nav-group { position: relative; }
.nav-group-btn, .nav-flat {
  display: inline-flex; align-items: center; gap: .3rem;
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .93rem; font-weight: 550;
  color: var(--ink-muted);
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  text-decoration: none; white-space: nowrap;
}
.nav-group-btn:hover, .nav-flat:hover { color: var(--ink); background: var(--paper-3); text-decoration: none; }
.nav-flat[aria-current="page"] { color: var(--amber-2); }
.chev { width: 9px; height: 6px; transition: transform .18s ease; opacity: .7; }
.nav-group-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

.nav-sub {
  list-style: none; margin: 0; padding: .4rem;
  position: absolute; top: calc(100% + .4rem); left: 0; z-index: 110;
  min-width: 15rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.nav-group:hover .nav-sub,
.nav-group-btn[aria-expanded="true"] + .nav-sub {
  opacity: 1; visibility: visible; transform: none;
}
.nav-sub li { margin: 0; }
.nav-sub a {
  display: block; padding: .5rem .65rem; border-radius: var(--radius-sm);
  color: var(--ink-muted); font-size: .9rem; text-decoration: none;
}
.nav-sub a:hover { background: var(--paper-3); color: var(--ink); }
.nav-sub a[aria-current="page"] { color: var(--amber-2); font-weight: 600; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex-shrink: 0;
  background: none; border: 1px solid var(--rule); border-radius: var(--radius-sm);
  color: var(--ink-muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); background: var(--paper-3); }
.theme-toggle svg { width: 17px; height: 17px; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun  { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

.nav-toggle {
  display: none;
  width: 38px; height: 38px; flex-shrink: 0;
  background: none; border: 1px solid var(--rule); border-radius: var(--radius-sm);
  color: var(--ink); cursor: pointer;
  align-items: center; justify-content: center;
}
.nav-toggle-bars { display: block; width: 17px; }
.nav-toggle-bars i {
  display: block; height: 1.8px; background: currentColor; border-radius: 2px;
  margin: 3.2px 0; transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; order: 3; }
  .theme-toggle { order: 2; }
  /* Touch targets: 44px minimum on anything thumb-operated. */
  .nav-toggle, .theme-toggle { width: 44px; height: 44px; }
  .seg button { min-height: 44px; }
  .site-nav {
    order: 4; flex-basis: 100%;
    display: none; padding: .5rem 0 1rem;
    border-top: 1px solid var(--rule); margin-top: .25rem;
    max-height: 70vh; overflow-y: auto;
  }
  .site-nav.open { display: block; }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-group-btn, .nav-flat {
    width: 100%; justify-content: space-between;
    padding: .8rem .5rem; font-size: 1rem; min-height: 44px;
  }
  .nav-sub {
    position: static; opacity: 1; visibility: visible; transform: none;
    box-shadow: none; border: 0; border-left: 2px solid var(--rule);
    border-radius: 0; margin: 0 0 .4rem .5rem; padding: 0 0 0 .6rem;
    display: none; min-width: 0;
  }
  .nav-group-btn[aria-expanded="true"] + .nav-sub { display: block; }
  .nav-group:hover .nav-sub { opacity: 1; visibility: visible; }
  .nav-group:hover .nav-group-btn[aria-expanded="false"] + .nav-sub { display: none; }
  .nav-sub a { padding: .65rem .5rem; min-height: 44px; display: flex; align-items: center; }
}

/* ---------- Breadcrumbs ---------- */

.breadcrumbs { padding: 1rem 0 0; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; font-size: .82rem; }
.breadcrumbs li { margin: 0; display: flex; align-items: center; gap: .4rem; color: var(--ink-faint); }
.breadcrumbs li:not(:last-child)::after { content: "/"; color: var(--rule-hard); }
.breadcrumbs a { color: var(--ink-faint); text-decoration: none; }
.breadcrumbs a:hover { color: var(--amber-2); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--ink-muted); }

/* ---------- Hero ---------- */

.hero { padding: 1.5rem 0 .5rem; }
.hero h1 { margin-bottom: .6rem; }
.hero-lede { font-size: 1.12rem; color: var(--ink-muted); max-width: 44rem; }
.hero-lede strong { color: var(--ink); }

/* ---------- The chart card (calculator) ---------- */

.calc-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin: 1.5rem 0;
}

/* Chart header — the manila-tab look */
.calc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem 1rem; flex-wrap: wrap;
  padding: .8rem 1.15rem;
  background: var(--paper-3);
  border-bottom: 1px solid var(--rule);
}
.calc-head h2, .calc-head .calc-title {
  margin: 0; font-size: .78rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint);
}

/* Pages with TWO unit toggles (weight + oz/g) overflow a 375px header.
   .calc-card clips rather than scrolls, so an unwrapped header silently hides
   the "g" button — unreachable on a phone. Let the title take its own line and
   the toggles sit together beneath it. */
@media (max-width: 460px) {
  .calc-head { justify-content: flex-start; }
  .calc-head h2, .calc-head .calc-title { flex: 1 0 100%; }
  .calc-head .unit-toggle { flex: 0 1 auto; }
}
.calc-body { padding: 1.15rem; }

@media (min-width: 780px) {
  .calc-body { padding: 1.5rem; }
}

/* Fields */
.field-row {
  display: grid; gap: .9rem;
  grid-template-columns: 1fr;
  margin-bottom: .9rem;
}
@media (min-width: 620px) {
  .field-row.two { grid-template-columns: 1fr 1fr; }
  .field-row.three { grid-template-columns: 1fr 1fr 1fr; }
}

.field { display: flex; flex-direction: column; gap: .32rem; min-width: 0; }
.field label, .field .field-label {
  font-size: .8rem; font-weight: 620; color: var(--ink);
  letter-spacing: .01em;
}
.field-hint { font-size: .74rem; color: var(--ink-faint); line-height: 1.45; }
.calc-optional { color: var(--ink-faint); font-weight: 400; }

input[type="text"], input[type="number"], input[type="email"], select, textarea {
  width: 100%; min-height: 44px;
  padding: .55rem .7rem;
  background: var(--paper);
  border: 1px solid var(--rule-hard);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit; font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
input[type="number"] { font-family: var(--mono); }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%234e6076' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 11px;
  padding-right: 2.1rem;
}
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23a2b3c8' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
input::placeholder { color: var(--ink-faint); }

/* Unit toggle (lb/kg, oz/g) */
.unit-toggle {
  display: inline-flex; flex-shrink: 0;
  border: 1px solid var(--rule-hard); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--paper-3);
}
.unit-toggle button {
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 620;
  color: var(--ink-faint);
  padding: 0 .7rem; min-height: 44px; min-width: 44px;
}
.unit-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.unit-toggle button:not([aria-pressed="true"]):hover { color: var(--ink); }

.input-with-unit { display: flex; gap: .4rem; align-items: stretch; }
.input-with-unit input { flex: 1; min-width: 0; }

/* Segmented control (species/mode) */
.seg {
  display: flex; gap: .3rem; padding: .28rem;
  background: var(--paper-3); border: 1px solid var(--rule);
  border-radius: var(--radius-sm); margin-bottom: 1.15rem;
  flex-wrap: wrap;
}
.seg button {
  flex: 1 1 auto; min-width: 5.5rem; min-height: 40px;
  background: none; border: 0; border-radius: 5px; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 600; color: var(--ink-muted);
  padding: .35rem .7rem;
}
.seg button[aria-pressed="true"] {
  background: var(--paper); color: var(--ink);
  box-shadow: 0 1px 2px rgba(15,32,57,.12);
}
:root[data-theme="dark"] .seg button[aria-pressed="true"] { box-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* Buttons */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 46px; padding: .6rem 1.3rem;
  border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-size: .97rem; font-weight: 640;
  text-decoration: none; border: 1px solid transparent;
}
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); width: 100%; }
.btn-primary:hover { background: var(--ink-2); color: var(--paper); text-decoration: none; }
:root[data-theme="dark"] .btn-primary { background: var(--amber); color: #16202e; border-color: var(--amber); }
:root[data-theme="dark"] .btn-primary:hover { background: var(--amber-2); color: #16202e; }
.btn-ghost {
  background: var(--paper); color: var(--ink); border-color: var(--rule-hard);
  font-size: .87rem; min-height: 44px; padding: .45rem .85rem;
}
.btn-ghost:hover { background: var(--paper-3); color: var(--ink); text-decoration: none; }
.btn-primary[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Results — the patient chart ---------- */

.result {
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 1.15rem;
}
@media (min-width: 780px) { .result { padding: 1.5rem; } }
.result[hidden] { display: none; }

.patient-line {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem;
  font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: .7rem; margin-bottom: 1rem;
  border-bottom: 1px dashed var(--rule);
}
.patient-line .pl-sep { color: var(--rule-hard); }
.patient-line strong { color: var(--ink); font-weight: 700; }

.result-headline {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.1rem, 7vw, 3.1rem);
  font-weight: 700; line-height: 1.05; letter-spacing: -0.035em;
  color: var(--ink); margin: 0;
}
.result-headline .rh-unit { font-size: .42em; font-weight: 600; color: var(--ink-faint); letter-spacing: 0; }
.result-sub { font-size: .95rem; color: var(--ink-muted); margin: .3rem 0 0; }

.formula-line {
  font-family: var(--mono); font-size: .82rem;
  color: var(--ink-faint);
  background: var(--paper-3); border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem; margin: 1rem 0 0;
  overflow-x: auto; white-space: nowrap;
}

.result-grid {
  display: grid; gap: .7rem; margin: 1.15rem 0 0;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}
.stat {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius-sm); padding: .7rem .8rem;
}
.stat-k { font-size: .7rem; font-weight: 640; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); }
.stat-v {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 1.32rem; font-weight: 700; color: var(--ink); line-height: 1.3;
}
.stat-n { font-size: .75rem; color: var(--ink-faint); }

.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.15rem; }

.next-step {
  margin: 1.15rem 0 0; padding: .8rem .9rem;
  background: var(--amber-tint); border: 1px solid var(--amber-line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  font-size: .92rem; color: var(--ink-2);
}
.next-step p:last-child { margin-bottom: 0; }
.next-step strong { color: var(--ink); }

/* ---------- Triage — RESERVED urgency states ---------- */

.triage {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: 1rem 1.05rem; margin: 0 0 1.15rem;
  border: 1px solid; border-left-width: 4px;
  border-radius: var(--radius-sm);
}
.triage-icon { font-size: 1.25rem; line-height: 1.3; flex-shrink: 0; }
.triage-body { min-width: 0; }
.triage-state {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
  margin: 0 0 .2rem; line-height: 1.3;
}
.triage p { margin: 0 0 .5rem; font-size: .93rem; }
.triage p:last-child { margin-bottom: 0; }
.triage ul { margin: .4rem 0 .5rem; padding-left: 1.15rem; font-size: .91rem; }
.triage li { margin-bottom: .25rem; }

.triage.is-monitor   { background: var(--ok-bg);     border-color: var(--ok-line);     border-left-color: var(--ok); }
.triage.is-monitor   .triage-state { color: var(--ok); }
.triage.is-vet       { background: var(--warn-bg);   border-color: var(--warn-line);   border-left-color: var(--warn); }
.triage.is-vet       .triage-state { color: var(--warn); }
.triage.is-emergency { background: var(--danger-bg); border-color: var(--danger-line); border-left-color: var(--danger); }
.triage.is-emergency .triage-state { color: var(--danger); }
.triage.is-emergency .triage-icon { animation: pulse 1.9s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- Emergency strip ---------- */

.emergency-strip {
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1.25rem 0;
}
.es-lead { margin: 0 0 .6rem; color: var(--ink); font-size: .97rem; }
.es-nums { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
@media (min-width: 760px) { .es-nums { grid-template-columns: repeat(3, 1fr); } }
.es-nums li {
  margin: 0; display: flex; flex-direction: column; gap: .1rem;
  background: var(--paper); border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm); padding: .6rem .7rem;
}
.es-nums a { color: var(--danger); font-weight: 650; text-decoration: none; font-size: .95rem; }
.es-nums a:hover { text-decoration: underline; }
.es-org { color: var(--ink); font-weight: 650; font-size: .95rem; }
.es-note { font-size: .72rem; color: var(--ink-faint); }
.es-foot { margin: .7rem 0 0; font-size: .82rem; color: var(--ink-muted); }

/* ---------- Verified badge & accuracy strip ---------- */

.verified-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--ok-bg); border: 1px solid var(--ok-line);
  border-radius: 100px; padding: .2rem .6rem .2rem .45rem;
  font-size: .72rem; font-weight: 620; letter-spacing: .01em;
  color: var(--ok); text-decoration: none; white-space: nowrap;
}
.verified-badge:hover { color: var(--ok); text-decoration: underline; }
.verified-badge svg { width: 11px; height: 11px; flex-shrink: 0; }

.accuracy-strip {
  font-size: .78rem; color: var(--ink-faint); line-height: 1.55;
  margin: .7rem 0 0; padding: .6rem .75rem;
  background: var(--paper-3); border-radius: var(--radius-sm);
  border: 1px solid var(--rule-soft);
}
.accuracy-strip a { color: var(--ink-muted); }

.calc-disclaimer {
  font-size: .78rem; color: var(--ink-faint);
  margin: .55rem 0 0; text-align: center;
}
.calc-note { font-size: .84rem; color: var(--ink-faint); margin-top: .8rem; }

/* ---------- Chart (SVG growth curve) ---------- */

.chart-wrap {
  margin: 1.15rem 0 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: .8rem .6rem .4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chart-wrap svg { display: block; width: 100%; min-width: 280px; height: auto; }
.chart-caption { font-size: .76rem; color: var(--ink-faint); text-align: center; margin: .3rem 0 .2rem; }

.pc-grid    { stroke: var(--rule-soft); stroke-width: 1; }
.pc-axis    { stroke: var(--rule-hard); stroke-width: 1; }
.pc-tick    { fill: var(--ink-faint); font-size: 10px; font-family: var(--mono); }
.pc-label   { fill: var(--ink-muted); font-size: 10.5px; font-weight: 600; }
.pc-curve   { fill: none; stroke: var(--ink-faint); stroke-width: 1.6; }
.pc-curve-active { fill: none; stroke: var(--amber); stroke-width: 2.4; }
.pc-band    { fill: var(--amber); opacity: .09; }
.pc-point   { fill: var(--amber); stroke: var(--paper); stroke-width: 2; }
.pc-point-label { fill: var(--ink); font-size: 10.5px; font-weight: 700; font-family: var(--mono); }
.pc-legend  { fill: var(--ink-muted); font-size: 10px; }

/* ---------- Callouts ---------- */

.callout {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem; margin: 1.5rem 0;
}
.callout p:last-child { margin-bottom: 0; }
.callout h3, .callout h4 { margin-top: 0; }
.callout.is-warning { border-left-color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.callout.is-danger  { border-left-color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.callout.is-contrarian { border-left-color: var(--ink); }
.callout-k {
  font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-faint); display: block; margin-bottom: .25rem;
}

/* ---------- Article ---------- */

.article { padding: 1rem 0 2rem; }
.article > p:first-of-type { font-size: 1.1rem; color: var(--ink-2); }
.article h2 + p, .article h3 + p { margin-top: 0; }

.featured-img {
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
  background: var(--paper-3);
}
.featured-img img { width: 100%; height: auto; }
.featured-img figcaption { font-size: .76rem; color: var(--ink-faint); padding: .5rem .7rem; text-align: center; }

.byline {
  display: flex; align-items: center; gap: .7rem;
  padding: .8rem 0; margin: .5rem 0 0;
  border-top: 1px solid var(--rule-soft); border-bottom: 1px solid var(--rule-soft);
}
.byline-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
}
:root[data-theme="dark"] .byline-avatar { background: var(--amber); color: #16202e; }
.byline-text { display: flex; flex-direction: column; font-size: .84rem; line-height: 1.45; min-width: 0; }
.byline-text > a { color: var(--ink); text-decoration: none; }
.byline-text > a:hover { text-decoration: underline; }
.byline-sub { color: var(--ink-faint); font-size: .77rem; }

/* Tables — the data chart */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 1.25rem 0;
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  background: var(--paper);
}
table { border-collapse: collapse; width: 100%; font-size: .89rem; min-width: 30rem; }
caption {
  caption-side: top; text-align: left;
  font-size: .78rem; font-weight: 650; color: var(--ink-faint);
  padding: .6rem .8rem; border-bottom: 1px solid var(--rule);
  letter-spacing: .02em;
}
th, td {
  padding: .55rem .8rem; text-align: left;
  border-bottom: 1px solid var(--rule-soft);
  font-variant-numeric: tabular-nums;
}
th {
  background: var(--paper-3); color: var(--ink);
  font-weight: 650; font-size: .78rem;
  letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
td { color: var(--ink-muted); }
td:first-child { color: var(--ink); font-weight: 550; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--paper-2); }
td.num, th.num { font-family: var(--mono); text-align: right; }
.table-credit { font-size: .72rem; color: var(--ink-faint); font-style: italic; margin: -.9rem 0 1.5rem; }

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

.faq { margin: 2.75rem 0; }
.faq details {
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  background: var(--paper); margin-bottom: .55rem;
  overflow: hidden;
}
.faq summary {
  cursor: pointer; list-style: none;
  padding: .85rem 2.4rem .85rem 1rem; position: relative;
  font-weight: 620; color: var(--ink); font-size: .98rem;
  min-height: 44px; display: flex; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 1rem; top: 50%;
  width: 9px; height: 9px; margin-top: -6px;
  border-right: 1.8px solid var(--ink-faint); border-bottom: 1.8px solid var(--ink-faint);
  transform: rotate(45deg); transition: transform .18s ease;
}
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.faq summary:hover { background: var(--paper-3); }
.faq-a { padding: 0 1rem 1rem; border-top: 1px solid var(--rule-soft); padding-top: .8rem; }
.faq-a p:last-child { margin-bottom: 0; }

/* ---------- Hub / spoke cards ---------- */

.spoke-grid {
  display: grid; gap: .8rem; margin: 1.5rem 0;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .spoke-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .spoke-grid { grid-template-columns: repeat(3, 1fr); } }

.spoke-card {
  display: flex; flex-direction: column; gap: .3rem;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1rem;
  text-decoration: none; color: var(--ink);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.spoke-card:hover {
  border-color: var(--amber); text-decoration: none;
  transform: translateY(-2px); box-shadow: var(--shadow-card);
}
.spoke-card h3 { margin: 0; font-size: 1.02rem; color: var(--ink); }
.spoke-card p { margin: 0; font-size: .85rem; color: var(--ink-muted); line-height: 1.55; }
.spoke-k {
  font-size: .66rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--amber-2);
}
:root[data-theme="dark"] .spoke-k { color: var(--amber); }

/* ---------- Related ---------- */

.related {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1.1rem 1.15rem; margin: 2.5rem 0 0;
}
.related h2 { margin: 0 0 .7rem; font-size: 1.05rem; }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.related li { margin: 0; display: flex; flex-direction: column; }
.related a { font-weight: 600; font-size: .95rem; text-decoration: none; }
.related a:hover { text-decoration: underline; }
.related-note { font-size: .78rem; color: var(--ink-faint); }

/* ---------- TOC ---------- */

.toc {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius-sm); padding: .7rem .95rem; margin: 1.5rem 0;
}
.toc summary {
  cursor: pointer; font-weight: 650; color: var(--ink); font-size: .88rem;
  letter-spacing: .02em; list-style: none; min-height: 30px; display: flex; align-items: center;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before { content: "☰"; margin-right: .5rem; color: var(--ink-faint); }
.toc ol { margin: .6rem 0 .2rem; padding-left: 1.2rem; font-size: .87rem; }
.toc li { margin-bottom: .25rem; }
.toc a { color: var(--ink-muted); text-decoration: none; }
.toc a:hover { color: var(--amber-2); text-decoration: underline; }

/* ---------- Inline CTA ---------- */

.cta-inline {
  background: var(--ink); border-radius: var(--radius);
  padding: 1.15rem 1.2rem; margin: 2rem 0;
  display: flex; flex-direction: column; gap: .6rem;
}
.cta-inline h3 { color: #fff; margin: 0; font-size: 1.08rem; }
.cta-inline p { color: rgba(255,255,255,.78); margin: 0; font-size: .9rem; }
.cta-inline .btn-primary {
  background: var(--amber); border-color: var(--amber); color: #16202e; width: auto; align-self: flex-start;
}
.cta-inline .btn-primary:hover { background: var(--amber-2); color: #16202e; }

/* ---------- Ad slots — reserved, no CLS ---------- */

.ad-slot {
  display: block; width: 100%;
  background: var(--paper-3);
  border: 1px dashed var(--rule);
  border-radius: var(--radius-sm);
  margin: 2rem 0;
}
.ad-result { min-height: 280px; }
.ad-mid    { min-height: 280px; }
.ad-footer { min-height: 250px; }
@media (min-width: 780px) {
  .ad-result { min-height: 280px; }
  .ad-mid    { min-height: 280px; }
}
.ad-slot:empty::after {
  content: "";
  display: block;
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 2.25rem 0 1.5rem;
  margin-top: 3rem;
}
.footer-disclaimer {
  font-size: .84rem; color: var(--ink-muted); line-height: 1.6;
  background: var(--paper-3); border: 1px solid var(--rule-soft);
  border-radius: var(--radius-sm); padding: .8rem .9rem;
  margin-bottom: 1.75rem;
}
.footer-disclaimer strong { color: var(--ink); }

.footer-cols {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(2, 1fr);
  padding-bottom: 1.5rem;
}
@media (min-width: 700px)  { .footer-cols { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1000px) { .footer-cols { grid-template-columns: repeat(7, 1fr); } }
.footer-h {
  font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 .55rem;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: .35rem; }
.footer-col a, .footer-col .linkish {
  font-size: .84rem; color: var(--ink-muted); text-decoration: none; line-height: 1.5;
}
.footer-col a:hover, .footer-col .linkish:hover { color: var(--amber-2); text-decoration: underline; }

.footer-bottom {
  border-top: 1px solid var(--rule); padding-top: 1.15rem;
  font-size: .8rem; color: var(--ink-faint);
}
.footer-bottom p { margin: 0 0 .35rem; font-size: .8rem; color: var(--ink-faint); }
.footer-bottom strong { color: var(--ink-muted); }
.footer-legal { color: var(--ink-faint); }

/* ---------- Scroll to top ---------- */

.to-top {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 90;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule-hard); border-radius: 50%;
  box-shadow: var(--shadow-card); cursor: pointer;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--amber); color: var(--amber-2); }
.to-top svg { width: 17px; height: 17px; }
@media (min-width: 780px) { .to-top { right: 1.5rem; bottom: 1.5rem; } }

/* ---------- Reading progress ---------- */

.progress-bar {
  position: fixed; top: 0; left: 0; z-index: 120;
  height: 2px; width: 0;
  background: var(--amber);
  transition: width .08s linear;
}

/* ---------- Cookie banner ---------- */

.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
  background: var(--paper); border-top: 1px solid var(--rule);
  box-shadow: 0 -6px 24px -12px rgba(15,32,57,.3);
  padding: 1rem 0;
}
.cookie-inner { display: flex; flex-direction: column; gap: .8rem; }
@media (min-width: 780px) { .cookie-inner { flex-direction: row; align-items: center; justify-content: space-between; } }
.cookie-banner p { margin: 0; font-size: .85rem; color: var(--ink-muted); }
.cookie-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.cookie-actions .btn-primary { width: auto; }

/* ---------- Print — the vet handout ---------- */

@media print {
  :root {
    --paper: #fff; --paper-2: #fff; --paper-3: #fff; --paper-sunk: #fff;
    --ink: #000; --ink-2: #111; --ink-muted: #222; --ink-faint: #444;
    --rule: #999; --rule-soft: #ccc; --rule-hard: #666;
    --ok: #000; --warn: #000; --danger: #000;
    --ok-bg: #fff; --warn-bg: #fff; --danger-bg: #fff;
  }
  html[data-theme="dark"] { --paper: #fff; --ink: #000; }

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

  .site-header, .site-footer, .to-top, .theme-toggle, .nav-toggle, .site-nav,
  .ad-slot, .cookie-banner, .progress-bar, .toc, .related, .faq, .breadcrumbs,
  .result-actions, .cta-inline, .spoke-grid, .featured-img, .byline-avatar,
  .seg, .unit-toggle, .calc-head { display: none !important; }

  /* Print only the chart card + result. */
  .article > p, .article > h2, .article > h3, .article > ul, .article > ol,
  .article > .callout, .article > .table-scroll, .article > blockquote { display: none; }
  .print-keep, .print-keep * { display: revert; }

  .calc-card, .result, .chart-wrap, .triage {
    border: 1px solid #666 !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .calc-card { margin: 0; }
  .result { background: #fff; }

  .print-header {
    display: block !important;
    border-bottom: 2px solid #000; padding-bottom: .4rem; margin-bottom: .8rem;
  }
  .print-header h1 { font-size: 15pt; margin: 0; }
  .print-header .ph-sub { font-size: 9pt; color: #444; }

  .print-only { display: block !important; }
  .triage-icon { animation: none !important; }
  .triage.is-emergency .triage-state::before { content: "EMERGENCY — "; }
  .result-headline { font-size: 24pt; }

  .emergency-strip { border: 2px solid #000 !important; }
  .es-nums { grid-template-columns: 1fr 1fr 1fr; }
  .es-nums a { color: #000 !important; }

  a[href^="http"]::after, a[href^="/"]::after { content: ""; }
  .print-foot {
    display: block !important;
    margin-top: 1rem; padding-top: .5rem; border-top: 1px solid #999;
    font-size: 8.5pt; color: #444;
  }
  @page { margin: 1.5cm; }
}

.print-only, .print-header, .print-foot { display: none; }

/* ---------- Motion ---------- */

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