/* ==========================================================================
   Names by State — design system (Phases 2–3)
   Tokens from the master redesign prompt. Mobile first, no framework,
   no heavy gradients, no floating cards, no baby-pink/blue clichés.
   Desktop content container: 1200px (1240px incl. padding).
   ========================================================================== */
:root {
  /* Brand tokens */
  --primary: #253b72;
  --primary-dark: #17264c;
  --primary-soft: #e8ebf5;
  --accent: #6d68d9;
  --accent-dark: #5753c7;
  --accent-soft: #eeedff;
  --teal: #2b9d91;
  --teal-dark: #1f7d73;
  --teal-soft: #e7f5f2;
  --bg: #f7f8fc;
  --surface: #ffffff;
  --text: #20283a;
  --muted: #758096;
  --muted-dark: #4d576e;
  --border: #e7eaf1;
  --border-strong: #d3d9e6;
  --danger: #d95f67;
  --danger-soft: #fdf0f1;
  --good: #1f7d73;
  /* Type */
  --font-head: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Shape / motion */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --header-h: 64px;
  --header-h-mobile: 60px;
  --shadow: 0 1px 2px rgba(23, 38, 76, 0.06), 0 4px 14px rgba(23, 38, 76, 0.06);
  --shadow-lift: 0 2px 6px rgba(23, 38, 76, 0.08), 0 12px 28px rgba(23, 38, 76, 0.12);
  --shadow-panel: 0 8px 30px rgba(23, 38, 76, 0.18);
  --ease: 150ms ease;
  --ease-med: 220ms ease;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.25;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
}
h1 { font-size: 1.9rem; font-weight: 800; margin: 0.3rem 0 0.6rem; }
h2 { font-size: 1.35rem; font-weight: 700; margin: 2rem 0 0.6rem; }
h3 { font-size: 1.1rem; font-weight: 700; margin: 1.4rem 0 0.4rem; }
h4 { font-size: 1rem; font-weight: 700; margin: 1.2rem 0 0.35rem; }
p { margin: 0.5rem 0 0.9rem; }
a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.lead { font-size: 1.08rem; color: var(--muted-dark); }
.small { font-size: 0.88rem; }
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; padding: 12px 22px; min-height: 48px;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  border-radius: var(--radius); font-family: var(--font-head);
  font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: background-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--primary); }
.btn-secondary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--primary); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
.btn-sm { min-height: 40px; padding: 8px 16px; font-size: 0.92rem; margin-top: 0; }
.btn-cta { margin-top: 0; min-height: 42px; padding: 9px 18px; font-size: 0.92rem; white-space: nowrap; }
/* Header CTA must match the header search box exactly (both 44px, same
   radius). This is an <a>, so plain .btn-cta loses to a.btn on specificity
   (0,1,1 beats 0,1,0) — that was the bug: the button rendered at the base
   48px height next to a 42px input. The a.btn prefix here is deliberate. */
a.btn.header-cta {
  min-height: 44px; height: 44px; padding: 0 18px; margin-top: 0;
  border-radius: 10px; font-size: 0.94rem; align-self: center;
}

/* ---------- Badges, chips, trend indicators ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.badge-rank { background: var(--primary-soft); color: var(--primary-dark); }
.badge-girl { background: var(--accent-soft); color: var(--accent-dark); }
.badge-boy { background: var(--teal-soft); color: var(--teal-dark); }
.badge-trend-up { background: var(--teal-soft); color: var(--teal-dark); }
.badge-trend-down { background: var(--danger-soft); color: var(--danger); }
.badge-soon { background: var(--bg); color: var(--muted); border: 1px dashed var(--border-strong); }
.chip {
  display: inline-flex; align-items: center; padding: 6px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; font-size: 0.88rem; font-weight: 600; color: var(--text);
  text-decoration: none; transition: border-color var(--ease), background-color var(--ease);
}
a.chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--primary-dark); }
.trend-up { color: var(--good); font-weight: 700; }
.trend-down { color: var(--danger); font-weight: 700; }
.trend-flat { color: var(--muted); font-weight: 700; }
.up { color: var(--good); font-weight: 700; }
.down { color: var(--danger); font-weight: 700; }
.same { color: var(--muted); }

/* ---------- Cards, alerts, empty states, skeletons ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
}
.alert {
  border-radius: var(--radius); padding: 14px 18px; margin: 16px 0;
  border: 1px solid var(--border); background: var(--surface); font-size: 0.95rem;
}
.alert p { margin: 0.25rem 0; }
.alert-note { background: var(--accent-soft); border-color: #d9d7fb; }
.alert-error { background: var(--danger-soft); border-color: #f3c8cb; color: var(--text); }
.alert-error strong { color: var(--danger); }
.empty-state {
  text-align: center; padding: 32px 20px; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.skeleton {
  border-radius: var(--radius-sm); background: var(--primary-soft);
  min-height: 1rem; animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- Forms ---------- */
.form-control, input[type="text"], input[type="search"], input[type="email"], select, textarea {
  font-family: var(--font-body); font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 12px; min-height: 48px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
input[type="text"]:focus, input[type="search"]:focus, input[type="email"]:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
label { font-weight: 600; color: var(--primary-dark); }
select { cursor: pointer; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: 16px 0; }
.tab {
  border: 0; background: transparent; padding: 10px 16px; min-height: 44px;
  font-family: var(--font-head); font-size: 0.95rem; font-weight: 700; color: var(--muted);
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
  transition: color var(--ease), border-color var(--ease);
}
.tab:hover { color: var(--primary-dark); }
.tab[aria-selected="true"], .tab.is-active { color: var(--primary-dark); border-bottom-color: var(--accent); }

/* ---------- Year picker (trend pages: year selector + time range) ---------- */
.year-picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0 4px; }
.year-picker-label { font-weight: 700; color: var(--primary-dark); margin-right: 2px; }
.year-picker a, .year-picker span[aria-current="page"] {
  display: inline-flex; align-items: center; padding: 6px 14px; min-height: 36px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  text-decoration: none; color: var(--text); background: var(--surface);
}
.year-picker a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--primary-dark); }
.year-picker span[aria-current="page"] { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

/* ==========================================================================
   Header — desktop: sticky, one row, never wraps.
   Mobile (<=720px): NON-sticky (scrolls away, never covers content),
   one compact row: brand, search toggle, hamburger.
   ========================================================================== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 60;
}
.header-inner {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 10px;
  min-height: var(--header-h-mobile);
  padding-top: 6px; padding-bottom: 6px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--primary-dark); font-family: var(--font-head);
  font-weight: 800; font-size: 1.05rem; text-decoration: none;
  letter-spacing: -0.01em; white-space: nowrap; flex: 0 0 auto;
  min-height: 44px; border-radius: var(--radius-sm);
}
.brand:hover { color: var(--primary-dark); }
.brand-mark {
  display: inline-flex; flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 10px;
}
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand .brand-word-accent { color: var(--accent); font-weight: 800; }
.brand-sub { display: none; }

/* Icon buttons (search toggle, hamburger) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--primary-dark); cursor: pointer; flex: 0 0 auto;
  transition: background-color var(--ease);
}
.icon-btn:hover { background: var(--primary-soft); }
.icon-btn svg { width: 22px; height: 22px; }
.search-toggle { margin-left: auto; }
.nav-toggle { margin-left: 0; }
.nav-toggle[aria-expanded="true"] { background: var(--primary-soft); }

/* Desktop nav: hidden on mobile, dropdown drawer instead (see below). */
.main-nav { display: none; }
.btn.header-cta { display: none; }
.header-search { display: none; }

/* Mobile drawer: absolute panel under the bar, white surface. */
.main-nav.open {
  display: flex; flex-direction: column;
  position: absolute; top: 100%; left: 0; right: 0;
  margin: 0; padding: 8px 16px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-panel); z-index: 61;
}
.main-nav.open a {
  color: var(--text); text-decoration: none; font-family: var(--font-head);
  font-size: 1.02rem; font-weight: 700; padding: 13px 12px; min-height: 48px;
  display: flex; align-items: center;
  border-top: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: background-color var(--ease);
}
.main-nav.open a:first-child { border-top: 0; }
.main-nav.open a:hover { background: var(--accent-soft); color: var(--primary-dark); }
.main-nav.open a[aria-current="page"] { color: var(--accent-dark); background: var(--accent-soft); }
.main-nav.open a.nav-cta {
  margin-top: 10px; justify-content: center;
  background: var(--accent); color: #fff; border-top: 0;
}
.main-nav.open a.nav-cta:hover { background: var(--accent-dark); color: #fff; }
.nav-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(23, 38, 76, 0.45);
  border: 0; padding: 0; cursor: pointer;
}
.nav-overlay[hidden] { display: none; }

/* Mobile search row: expands below the bar, inside the (non-sticky) header. */
.mobile-search { display: none; border-top: 1px solid var(--border); background: var(--surface); }
.mobile-search.open { display: block; }
.mobile-search .wrap { padding-top: 12px; padding-bottom: 14px; }
.mobile-search .search-field { width: 100%; }

/* ---------- Search + autocomplete ---------- */
.search-field { position: relative; display: flex; align-items: center; }
.search-field > svg.search-icon {
  position: absolute; left: 12px; width: 18px; height: 18px; flex: 0 0 auto;
  color: var(--muted); pointer-events: none; z-index: 1;
}
.search-field input[type="text"], .search-field input[type="search"] {
  width: 100%; min-height: 46px; padding: 9px 40px 9px 40px;
  font-size: 1rem; border-radius: 10px;
}
.search-field input[type="text"]::placeholder { color: var(--muted); }
.search-clear {
  position: absolute; right: 6px; z-index: 1;
  display: none; align-items: center; justify-content: center;
  width: 32px; height: 32px; min-height: 32px; padding: 0;
  background: transparent; border: 0; border-radius: 50%;
  color: var(--muted); font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.search-clear:hover { background: var(--primary-soft); color: var(--primary-dark); }
.search-field.has-value .search-clear { display: inline-flex; }
.search-panel {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  min-width: 280px; max-height: 340px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-panel); z-index: 70;
  padding: 6px;
}
/* Header search sits near the right viewport edge: right-anchor its panel
   so suggestions are never clipped by the viewport. */
.header-search .search-panel {
  left: auto; right: 0; width: 360px; max-width: calc(100vw - 32px);
}
.search-panel.open { display: block; }
.search-panel ul { list-style: none; margin: 0; padding: 0; }
.search-option {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px;
  padding: 10px 12px; min-height: 48px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.98rem;
}
.search-option .opt-name { font-family: var(--font-head); font-weight: 700; color: var(--primary-dark); }
.search-option .opt-name mark { background: transparent; color: var(--accent-dark); font-weight: 800; }
.search-option .opt-meta { margin-left: auto; text-align: right; font-size: 0.8rem; color: var(--muted); }
.search-option.is-active, .search-option:hover { background: var(--accent-soft); }
.search-status { padding: 12px 14px; margin: 0; font-size: 0.92rem; color: var(--muted); }
.search-status:empty { display: none; }

/* Header search (desktop, 1024px and up). At tablet widths (721–1023px)
   the header keeps brand + nav + a search icon that opens the search row,
   so the single row never wraps or overflows. */
@media (min-width: 721px) {
  html { scroll-padding-top: calc(var(--header-h) + 14px); }
  .site-header { position: sticky; top: 0; box-shadow: 0 1px 0 rgba(23, 38, 76, 0.04), 0 6px 18px rgba(23, 38, 76, 0.07); }
  .header-inner { min-height: var(--header-h); gap: 10px; }
  .nav-toggle { display: none; }
  .search-toggle { display: inline-flex; margin-left: auto; }
  .main-nav {
    display: flex; position: static; flex-direction: row; flex-wrap: nowrap;
    align-items: center; gap: 2px; margin: 0 auto; padding: 0; flex: 0 0 auto; min-width: 0;
  }
  .main-nav a {
    color: var(--muted-dark); text-decoration: none; font-family: var(--font-head);
    font-size: 0.85rem; font-weight: 700; padding: 9px 7px; min-height: 44px;
    display: inline-flex; align-items: center; white-space: nowrap;
    border-radius: var(--radius-sm); transition: color var(--ease), background-color var(--ease);
  }
  .main-nav a:hover { color: var(--primary-dark); background: var(--accent-soft); }
  .main-nav a[aria-current="page"] { color: var(--accent-dark); background: var(--accent-soft); }
  .main-nav a.nav-cta { display: none; }
}
@media (min-width: 1024px) {
  .search-toggle { display: none; }
  .mobile-search { display: none; }
  .header-inner { gap: 12px; }
  .main-nav a { font-size: 0.92rem; padding: 9px 10px; }
  .header-search { display: flex; align-items: center; flex: 1 1 240px; max-width: 300px; min-width: 150px; margin-left: auto; }
  .header-search .search-field { width: 100%; }
  .header-search input[type="text"] { height: 44px; min-height: 44px; font-size: 0.94rem; background: var(--bg); border-color: var(--border); padding-left: 36px; padding-right: 34px; }
  .header-search input[type="text"]:focus { background: var(--surface); }
}
@media (min-width: 1280px) {
  .header-search input[type="text"] { padding-left: 40px; padding-right: 40px; }
}
@media (min-width: 1280px) {
  .main-nav a { font-size: 0.92rem; padding: 9px 8px; }
  .header-search { max-width: 260px; }
  .brand { font-size: 1.02rem; }
  .brand-mark { width: 32px; height: 32px; }
  .btn.header-cta { display: inline-flex; flex: 0 0 auto; }
}
@media (min-width: 721px) and (max-width: 900px) {
  .main-nav a { font-size: 0.82rem; padding: 9px 6px; }
  .brand { font-size: 1.05rem; }
  .brand-mark { width: 34px; height: 34px; }
}
/* Narrowest tablet band: fallback fonts run wider than Plus Jakarta Sans,
   so tighten further here (this block must come after the 721–900 block). */
@media (min-width: 721px) and (max-width: 800px) {
  .main-nav a { font-size: 0.78rem; padding: 9px 4px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 32px; height: 32px; }
  .header-inner { gap: 8px; }
  .site-header .wrap { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 1023px) {
  .site-header .wrap { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Hero band (full width) ---------- */
.page-hero {
  background: var(--primary);
  color: #fff;
  border-bottom: 4px solid var(--accent);
}
.page-hero .wrap { padding-top: 40px; padding-bottom: 38px; }
.page-hero h1 { color: #fff; font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0.5rem 0 0.7rem; }
.page-hero .lead { color: #c7d2e8; font-size: 1.15rem; max-width: 780px; margin-bottom: 0.4rem; }
.page-hero a { color: #dcd9ff; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin: 16px 0 0; }
.crumbs a { color: var(--muted); }
.crumbs-hero { margin: 0 0 4px; color: #a9bed6; }
.crumbs-hero a { color: #a9bed6; }

/* Stat chips row (hero + cards) */
.stat-row {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 22px 0 4px; list-style: none; padding: 0;
}
.stat {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius); padding: 12px 18px; min-width: 150px;
}
.stat b {
  display: block; font-size: 1.45rem; line-height: 1.2; color: #fff;
  font-family: var(--font-head); font-weight: 800; font-variant-numeric: tabular-nums;
}
.stat span { font-size: 0.82rem; color: #c3d3e6; }

/* Hero search (homepage) */
.hero-search {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px; margin: 22px 0 6px;
  max-width: 640px; box-shadow: var(--shadow-lift);
}
.hero-search label { display: block; margin: 0 0 6px; font-weight: 700; color: var(--primary-dark); }
.hero-search .search-row { display: flex; gap: 10px; }
.hero-search .search-field { flex: 1 1 auto; min-width: 0; }
.hero-search .search-field input[type="text"] { min-height: 50px; font-size: 1.05rem; }
.hero-search .btn { margin-top: 0; flex: 0 0 auto; }
.hero-search .search-facets { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.hero-search .facet { flex: 1 1 140px; min-width: 0; }
.hero-search .facet label { font-size: 0.85rem; margin-bottom: 4px; }
.hero-search .facet select { width: 100%; }

/* ---------- Page body ---------- */
main.wrap { padding-top: 8px; padding-bottom: 8px; }
.section-head { margin: 2rem 0 0.4rem; }
.section-head h2 { margin: 0 0 4px; }
.section-head p { margin: 0; color: var(--muted); }
.answer-box {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: var(--radius);
  padding: 16px 18px; margin: 18px 0; box-shadow: var(--shadow);
}
.answer-box p { margin: 0.3rem 0; }
.verdict { font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); font-family: var(--font-head); }

/* Two-column content grid (state pages) */
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 8px; }
.content-side { display: flex; flex-direction: column; gap: 18px; }
.side-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.side-card h2 { margin-top: 0; font-size: 1.15rem; }
.glance-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--border);
}
.glance-row:first-of-type { border-top: 0; }
.glance-row .k { color: var(--muted); font-size: 0.92rem; }
.glance-row .v { font-weight: 800; color: var(--primary-dark); text-align: right; font-variant-numeric: tabular-nums; }
.side-card .btn { margin-top: 6px; }

/* Two-column table pair (unique / movers pages) */
.two-col { display: grid; grid-template-columns: 1fr; gap: 0 28px; }
.two-col > div { min-width: 0; }

/* Section bands + cards on the homepage */
.home-section { margin: 34px 0; }
.home-section > h2 { font-size: 1.5rem; margin-bottom: 4px; }
.home-section .section-note { color: var(--muted); margin-top: 0; }
.band-card {
  background: var(--teal-soft); border: 1px solid #cfe8e3;
  border-radius: var(--radius); padding: 20px 22px;
}
.band-card h2 { margin-top: 0; }
.mini-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.mini-card h3 { margin-top: 0; }
.mini-card ul { margin: 0.4rem 0; padding-left: 1.1rem; }
.mini-card li { margin: 0.45rem 0; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
.feature-card .verdict { margin-top: 0; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.stat-card b {
  display: block; font-family: var(--font-head); font-size: 1.7rem; font-weight: 800;
  color: var(--primary-dark); line-height: 1.2; font-variant-numeric: tabular-nums;
}
.stat-card span { font-size: 0.88rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto; margin: 12px 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
caption { text-align: left; font-weight: 700; color: var(--primary-dark); padding: 12px 14px 4px; background: var(--surface); font-family: var(--font-head); }
th, td { padding: 9px 12px; text-align: left; border-top: 1px solid var(--border); }
thead th {
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em;
  font-family: var(--font-head); position: sticky; top: 0;
}
tbody tr:nth-child(even) td { background: #fafbfe; }
tbody tr:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.rank { font-weight: 700; color: var(--primary); }
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 800; font-size: 0.9rem; font-family: var(--font-head);
}
tr.top-row td.rank .rank-badge { background: var(--accent); color: #fff; }
tr.extra-row { display: none; }
table.expanded tr.extra-row { display: table-row; }
.show-all {
  display: block; width: 100%; margin: 12px 0 4px; padding: 12px;
  background: var(--surface); color: var(--primary); border: 2px solid var(--primary);
  border-radius: var(--radius); font-family: var(--font-head);
  font-size: 1rem; font-weight: 700; cursor: pointer; min-height: 48px;
  transition: background-color var(--ease), color var(--ease);
}
.show-all:hover { background: var(--primary); color: #fff; }

/* Filter + segmented toggle */
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.filter-row label { font-weight: 600; }
.filter-row input[type="search"], .filter-row input[type="text"] {
  flex: 1 1 200px; min-height: 48px; padding: 8px 14px; font-size: 1rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.seg { display: inline-flex; border: 1px solid var(--primary); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.seg button {
  border: 0; background: var(--surface); color: var(--primary); padding: 10px 22px;
  font-family: var(--font-head); font-size: 1rem; font-weight: 700; cursor: pointer; min-height: 48px;
  transition: background-color var(--ease), color var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.no-match { display: none; color: var(--muted); padding: 12px 0; }
section[data-sex-section] > h2 { border-left: 4px solid var(--accent); padding-left: 12px; }
section[data-sex-section="M"] > h2 { border-left-color: var(--teal); }

/* ---------- Tool card ---------- */
.tool-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin: 18px 0; background: var(--surface); box-shadow: var(--shadow);
}
.tool-card label { display: block; font-weight: 600; margin: 12px 0 4px; }
.tool-card input[type="text"], .tool-card select {
  width: 100%; min-height: 48px; padding: 8px 12px; font-size: 1rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.tool-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.result-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin: 18px 0; background: var(--surface); box-shadow: var(--shadow);
}
.result-card .verdict { margin-top: 0; font-size: 1.45rem; }
.vs-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 16px 0; }
.vs-cell {
  background: var(--bg); border: 1px solid var(--border);
  border-top: 4px solid var(--accent); border-radius: var(--radius); padding: 16px 18px;
}
.vs-cell + .vs-cell { border-top-color: var(--teal); }
.vs-cell h3 { margin-top: 0; }
.vs-cell .big { font-size: 1.9rem; font-weight: 800; color: var(--primary-dark); margin: 0.2rem 0; font-family: var(--font-head); }
.note { font-size: 0.92rem; color: var(--muted); }
.error-box { border-left: 4px solid var(--danger); background: var(--danger-soft); }

/* ---------- State picker grid ---------- */
.state-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  list-style: none; margin: 14px 0; padding: 0;
}
.state-grid a {
  display: block; padding: 14px; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; font-weight: 700;
  color: var(--primary-dark); min-height: 44px; background: var(--surface); box-shadow: var(--shadow);
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}
.state-grid a span { display: block; font-size: 0.82rem; font-weight: 600; color: var(--accent-dark); margin-top: 2px; }
.state-grid a:hover { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow-lift); }
.state-grid li.soon {
  padding: 14px; color: var(--muted); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); background: var(--bg);
}

/* ---------- Try this next ---------- */
.next-block { border-top: 2px solid var(--border); margin-top: 2.5rem; padding-top: 0.6rem; }
.next-list {
  list-style: none; margin: 0.8rem 0 0; padding: 0;
  display: grid; grid-template-columns: 1fr; gap: 10px;
}
.next-list li { margin: 0; }
.next-list a {
  display: block; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; font-weight: 700; color: var(--primary-dark); box-shadow: var(--shadow);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.next-list a:hover { border-color: var(--accent); color: var(--accent-dark); box-shadow: var(--shadow-lift); }

/* ---------- Source line ---------- */
.source-line {
  font-size: 0.88rem; color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-top: 2.5rem; padding: 12px 16px;
}

/* ---------- Definition / method boxes ---------- */
.def-box { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; }
.def-box p { margin: 0.3rem 0; }
.def-box h2 { margin-top: 0; }

/* ---------- Journey timeline (name profiles, Batch 3) ---------- */
.journey li { margin: 0.4rem 0; }

/* ---------- Charts ---------- */
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin: 16px 0;
}
.chart { width: 100%; height: auto; display: block; margin: 10px 0; }
.chart .axis { stroke: #9aa5ad; stroke-width: 1; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .line-a { stroke: var(--accent); stroke-width: 2.5; fill: none; }
.chart .line-b { stroke: var(--teal); stroke-width: 2.5; fill: none; }
.chart .dot-b { fill: var(--teal); }
.chart .dot { fill: var(--accent); }
.chart text { font-size: 12px; fill: var(--muted); font-family: var(--font-body), sans-serif; }
.chart .ylabel { font-size: 12px; fill: var(--primary-dark); font-weight: 700; }

/* ---------- Prose card (trust pages) ---------- */
.prose-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 28px; margin: 18px 0; max-width: 820px;
}
.prose-card h2 { margin-top: 1.6rem; }
.prose-card h2:first-child { margin-top: 0; }

/* ---------- Footer ---------- */
.site-footer { background: var(--primary-dark); color: #c7d2e8; margin-top: 4rem; }
.site-footer .wrap { padding-top: 44px; padding-bottom: 0; font-size: 0.95rem; }
.footer-grid {
  display: grid; grid-template-columns: 1fr; gap: 28px; padding-bottom: 28px;
}
.footer-col h3 {
  color: #fff; font-family: var(--font-head); font-size: 0.85rem;
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin: 7px 0; }
.footer-col a { color: #c7d2e8; text-decoration: none; }
.footer-col a:hover { color: #fff; text-decoration: underline; }
.footer-col p { color: #a9bed6; margin: 0.4rem 0; }
.footer-brand {
  color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 1.15rem;
  text-decoration: none; display: inline-flex; align-items: center; gap: 10px;
}
.footer-brand:hover { color: #fff; }
.footer-brand .brand-mark { width: 32px; height: 32px; }
.footer-attribution { font-size: 0.88rem; color: #a9bed6; margin-top: 14px; }
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding: 18px 0 22px; font-size: 0.88rem; color: #a9bed6;
  display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between;
}
.footer-bottom p { margin: 0; }

/* ---------- Mobile polish (<=720px) ---------- */
@media (max-width: 720px) {
  .page-hero .wrap { padding-top: 28px; padding-bottom: 28px; }
  .page-hero .lead { font-size: 1.05rem; }
  main.wrap { padding-top: 14px; }
  .tool-card, .result-card, .side-card { padding: 18px; }
  .stat-row { gap: 10px; }
  .stat { padding: 10px 14px; }
  .home-section { margin: 28px 0; }
  th, td { padding: 9px 10px; }
  .hero-search .search-row { flex-direction: column; }
  .hero-search .btn { width: 100%; }
  .search-panel { min-width: 0; }
  .brand { font-size: 1.05rem; }
}

/* ---------- Breakpoints ---------- */
@media (min-width: 640px) {
  h1 { font-size: 2.2rem; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .state-grid { grid-template-columns: repeat(4, 1fr); }
  .vs-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .next-list { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .state-grid { grid-template-columns: repeat(5, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .content-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr; }
}

/* Homepage search: label above a full-width input (kept for the hero form). */
#home-search label { display: block; margin: 0 0 6px; font-weight: 600; }
#home-search input[type="text"] {
  min-height: 48px; padding: 8px 14px 8px 40px; font-size: 1.05rem;
  border: 1px solid var(--border-strong); border-radius: 10px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}


/* ==========================================================================
   Phases 4–5: homepage + states directory
   ========================================================================== */

/* ---------- Homepage hero ---------- */
.hero-grid { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: start; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; }
.hero-ctas .btn { margin-top: 0; }
.btn-hero-alt { background: transparent; color: #fff; border: 2px solid rgba(255, 255, 255, 0.65); }
.btn-hero-alt:hover { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: #fff; }
.hero-hint { font-size: 0.9rem; color: var(--muted); margin: 10px 0 0; }
.hero-visual { display: flex; flex-direction: column; gap: 12px; }
.hv-card {
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius); padding: 16px 18px;
}
.hv-label {
  display: block; font-size: 0.78rem; color: #c3d3e6;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
}
.hv-name {
  display: block; font-family: var(--font-head); font-size: 1.5rem;
  font-weight: 800; color: #fff; line-height: 1.25;
}
.hv-meta { display: block; font-size: 0.92rem; color: #c3d3e6; }
.hv-note { margin: 0; }
.hv-note a { color: #dcd9ff; }
@media (min-width: 1024px) { .hero-grid { grid-template-columns: 1.15fr 0.85fr; } }

/* ---------- Trust stats strip ---------- */
.trust-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 900px) { .trust-strip { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Tile-grid US map ---------- */
.map-wrap { margin: 18px 0 8px; }
.us-map {
  display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px;
  list-style: none; margin: 0; padding: 0;
}
.us-map li { margin: 0; min-width: 0; }
.map-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; padding: 6px 2px;
  border-radius: 8px; font-family: var(--font-head); font-weight: 800; font-size: 0.85rem;
  line-height: 1.2; text-decoration: none; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--primary-dark);
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}
.map-tile.live { background: var(--accent-soft); border-color: #c9c6f7; }
.map-tile.live:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.map-tile.soon { background: var(--bg); color: var(--muted); border-style: dashed; }
.map-tile.soon:hover { background: var(--primary-soft); color: var(--muted-dark); }
.map-name { display: none; font-size: 0.68rem; font-weight: 600; line-height: 1.2; text-align: center; }
@media (min-width: 900px) {
  .map-name { display: block; }
  .map-tile { min-height: 58px; }
}
.map-status {
  font-size: 0.92rem; color: var(--muted-dark); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin: 12px 0 8px;
}
.map-legend { font-size: 0.88rem; color: var(--muted); margin: 4px 0 0; }
.legend-live, .legend-soon {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  font-weight: 700; font-size: 0.8rem;
}
.legend-live { background: var(--accent-soft); color: var(--accent-dark); }
.legend-soon { background: var(--bg); color: var(--muted); border: 1px dashed var(--border-strong); }

/* ---------- State search + alphabetical directory ---------- */
.state-search { margin: 20px 0 4px; }
.state-search label { display: block; margin-bottom: 6px; }
.state-search input[type="search"] { width: 100%; max-width: 520px; }
.dir-count { font-size: 0.9rem; color: var(--muted); }
.dir-empty {
  background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); padding: 16px 18px; color: var(--muted);
}
.letter-jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.letter-chip { min-width: 40px; min-height: 40px; justify-content: center; padding: 6px 10px; }
.dir-groups { display: grid; grid-template-columns: 1fr; gap: 0 28px; }
@media (min-width: 640px) { .dir-groups { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .dir-groups { grid-template-columns: 1fr 1fr 1fr; } }
.dir-group h3 { margin: 1.2rem 0 0.4rem; padding-bottom: 4px; border-bottom: 2px solid var(--accent); }
.dir-group ul { list-style: none; margin: 0; padding: 0; }
.dir-group li { margin: 0; }
.dir-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px; min-height: 48px;
  border-bottom: 1px solid var(--border); text-decoration: none;
  color: var(--text); font-weight: 600;
}
a.dir-link:hover { background: var(--accent-soft); }
.dir-link .dir-name { flex: 1 1 auto; min-width: 0; }
.dir-abbr { color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.dir-soon { color: var(--muted); }

/* ---------- Rising name cards ---------- */
.rising-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .rising-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .rising-grid { grid-template-columns: repeat(3, 1fr); } }
.rise-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
  transition: box-shadow var(--ease), border-color var(--ease);
}
.rise-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lift); }
.rise-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rise-name {
  font-family: var(--font-head); font-size: 1.25rem; font-weight: 800;
  color: var(--primary-dark); text-decoration: none;
}
.rise-name:hover { color: var(--accent-dark); text-decoration: underline; }
.rise-change { font-size: 1.05rem; margin: 0.4rem 0 0.2rem; }
.rise-meta { color: var(--muted); font-size: 0.92rem; margin: 0; }

/* ---------- Popular names (two-column editorial) ---------- */
.pop-grid { display: grid; grid-template-columns: 1fr; gap: 0 40px; }
@media (min-width: 900px) { .pop-grid { grid-template-columns: 1fr 1fr; } }
.pop-list { list-style: none; margin: 0; padding: 0; }
.pop-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border); min-height: 48px;
}
.pop-list a {
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  color: var(--primary-dark); text-decoration: none;
}
.pop-list a:hover { color: var(--accent-dark); text-decoration: underline; }
.pop-count { margin-left: auto; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

/* ---------- Discovery collections ---------- */
.collections-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .collections-grid { grid-template-columns: 1fr 1fr; } }
.collection-card {
  background: var(--surface); border: 1px solid var(--border);
  border-top: 4px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.collection-card h3 { margin-top: 0; }
.coll-rising { border-top-color: var(--teal); }
.coll-falling { border-top-color: var(--danger); }
.coll-compare { border-top-color: var(--primary); }
.coll-examples { font-size: 0.92rem; color: var(--muted-dark); }
.collection-card .btn { margin-top: 6px; }

/* ---------- Compare preview ---------- */
.compare-preview {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px;
}
.compare-preview .verdict { margin-top: 0; }
.compare-preview .btn { margin-right: 8px; }

/* ---------- How it works ---------- */
.steps-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-family: var(--font-head); font-weight: 800;
}
.step-card h3 { margin: 0.6rem 0 0.3rem; }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .map-tile { font-size: 0.72rem; min-height: 44px; }
  .hero-ctas .btn { flex: 1 1 auto; }
}

/* Phase 4–5 fix: author display rules must never override [hidden]
   (rising-tab panels, letter groups, letter-jump, empty states). */
[hidden] { display: none !important; }
@media (max-width: 720px) {
  .stat-card b { font-size: 1.35rem; }
}

/* ==========================================================================
   Phases 6–7–9: state pages, name detail page, trending/discovery pages
   ========================================================================== */

/* ---------- Key-stat grid (state pages, Klarity overview) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 900px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } .stat-grid-4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .stat-grid { grid-template-columns: repeat(5, 1fr); } .stat-grid-4 { grid-template-columns: repeat(4, 1fr); } }
.stat-grid .stat-card b { font-size: 1.35rem; }

/* ---------- Top 5 panels ---------- */
.top5-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.top5-grid > * { min-width: 0; }
@media (min-width: 640px) { .top5-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.top5-panel { border-top: 4px solid var(--accent); }
.top5-panel.top5-boys { border-top-color: var(--teal); }
.top5-panel h3 { margin-top: 0; }
.top5-list { list-style: none; margin: 0; padding: 0; }
.top5-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border); min-height: 48px;
}
.top5-list li:last-child { border-bottom: 0; }
.top5-list a {
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  color: var(--primary-dark); text-decoration: none;
}
.top5-list a:hover { color: var(--accent-dark); text-decoration: underline; }
.top5-count { margin-left: auto; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

/* ---------- In-state search ---------- */
.state-search-panel label { display: block; margin-bottom: 6px; }
.state-search-panel input[type="search"] { width: 100%; max-width: 520px; }
.state-search-panel .btn { margin-top: 12px; }
.state-search-hint { font-size: 0.92rem; color: var(--muted); margin: 8px 0 0; }
.state-search-results { list-style: none; margin: 12px 0 0; padding: 0; }
.state-search-results li {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  padding: 11px 4px; border-top: 1px solid var(--border); min-height: 48px;
}
.state-search-results li:first-child { border-top: 0; }
.state-search-results a {
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  color: var(--primary-dark); text-decoration: none;
}
.state-search-results a:hover { color: var(--accent-dark); text-decoration: underline; }
.state-search-meta { margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.state-search-more { color: var(--muted); font-size: 0.9rem; }

/* ---------- Sortable table headers ---------- */
.sort-btn {
  background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
  min-height: 32px; text-align: left; border-radius: 4px;
}
.sort-btn:hover { color: var(--accent-dark); text-decoration: underline; }
th.num .sort-btn { text-align: right; width: 100%; }
th[aria-sort="ascending"] .sort-btn, th[aria-sort="descending"] .sort-btn { color: var(--accent-dark); }

/* ---------- Tables on small screens: fit the viewport, never scroll ---------- */
/* Rank + name stay visible; births and change sit in compact columns. The
   560px min-width that used to force sideways scrolling is gone. */
.table-scroll table { min-width: 0; }
@media (max-width: 720px) {
  .table-scroll { -webkit-overflow-scrolling: touch; }
  .table-wrap table { font-size: 0.86rem; }
  /* Tighter cell padding on phones. (Specificity 0,2,1: the base
     .mini-table rule below (0,1,1) comes later in the file and would
     otherwise override this at the same specificity.) */
  .table-wrap .mini-table th, .table-wrap .mini-table td { padding: 6px 7px; }
  .table-wrap .rank-badge { min-width: 26px; height: 26px; font-size: 0.85rem; }
  .table-wrap .sort-btn { padding: 2px 0; }
  .table-wrap caption { padding: 10px 8px 2px; }
  /* Least-essential column on the widest tables: hidden on phones, where
     the name links to the profile that shows the national rank. */
  .hide-sm { display: none; }
  /* Decade hub: the 6-column side-by-side table becomes two 3-column
     tables (girls, then boys) on phones. */
  .decade-wide { display: none; }
  .decade-split { display: block; }
  /* Report tables: the same split for the two 5-column report tables. */
  .report-split-wide { display: none; }
  .report-split-narrow { display: block; }
  /* Name lists: let the count wrap instead of pushing the page wide. */
  .pop-list li { flex-wrap: wrap; }
  .pop-count { white-space: normal; text-align: right; }
}
@media (min-width: 721px) {
  /* On wider screens the split tables stay hidden; the wide table shows.
     (These must NOT be plain base rules after the max-width block above:
     a later base rule would override the max-width block's display:block
     at the same specificity and hide the split tables on phones too.) */
  .decade-split { display: none; }
  .report-split-narrow { display: none; }
}
@media (min-width: 721px) {
  .table-scroll table.rank-table { min-width: 520px; }
}

/* ---------- Swipeable charts on small screens ---------- */
/* A chart keeps a readable width and swipes inside its own box; the page
   itself never scrolls sideways. The exact numbers sit in a table below. */
@media (max-width: 720px) {
  .chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0; }
  .chart-scroll .chart { min-width: 560px; }
}

/* ---------- Sticky gender filter on trend pages (mobile) ---------- */
/* On phones the header scrolls away, so the All / Girls / Boys tabs stick
   to the top of the viewport while the long name lists scroll under them. */
@media (max-width: 720px) {
  .tabs-sticky {
    position: sticky; top: 0; z-index: 5;
    background: var(--surface); padding-top: 4px;
    box-shadow: 0 1px 0 var(--border);
  }
  /* Cards are roomy on desktop; on phones tighter padding leaves the
     tables inside them (state-page mover tables) room to fit. */
  .card { padding: 16px 14px; }
}

/* ---------- Rising / falling panels (state pages) ---------- */
.mover-panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.mover-panels > * { min-width: 0; }
@media (min-width: 900px) { .mover-panels { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.mover-card { border-top: 4px solid var(--teal); }
.mover-card.mover-falling { border-top-color: var(--danger); }
.mover-card h3 { margin-top: 0; }
.mover-card .table-wrap { box-shadow: none; border: 0; margin: 0; }
.mini-table { font-size: 0.95rem; }
.mini-table td, .mini-table th { padding: 9px 10px; }

/* ---------- Map highlight + rank tiers ---------- */
.map-tile.is-highlight {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 4px var(--accent);
}
.map-tile.is-highlight:hover { background: var(--accent-dark); color: #fff; }
.map-tile.live-rank { border-color: #c9c6f7; }
.map-tile.map-tier-1 { background: var(--accent); color: #fff; border-color: var(--accent); }
.map-tile.map-tier-1:hover { background: var(--accent-dark); color: #fff; }
.map-tile.map-tier-2 { background: #c9c6f7; color: var(--primary-dark); }
.map-tile.map-tier-2:hover { background: var(--accent); color: #fff; }
.map-tile.map-tier-3 { background: var(--accent-soft); color: var(--primary-dark); }
.map-tile.map-tier-3:hover { background: var(--accent); color: #fff; }
.legend-highlight, .legend-tier-1, .legend-tier-2, .legend-tier-3 {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  font-weight: 700; font-size: 0.8rem;
}
.legend-highlight, .legend-tier-1 { background: var(--accent); color: #fff; }
.legend-tier-2 { background: #c9c6f7; color: var(--primary-dark); }
.legend-tier-3 { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- Related discoveries ---------- */
.related-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.related-chips .chip { min-height: 44px; }

/* ---------- Tab panels used by trending / unique pages ---------- */
[data-tab-panel] > h2 { border-left: 4px solid var(--accent); padding-left: 12px; }
[data-tab-panel="boys"] > h2 { border-left-color: var(--teal); }

/* ---------- Klarity page ---------- */
#klarity-search { margin-top: 0; }

/* ==========================================================================
   Phases 8 / 10 / 11 / 12 / 15 / 16: compare tool, trust pages,
   micro-interactions, responsive polish, accessibility
   ========================================================================== */

/* ---------- Micro-interactions (§11) ----------
   Subtle 150–250ms feedback everywhere. All disabled under
   prefers-reduced-motion (see the reduced-motion block at the end). */
.card, .mini-card, .collection-card, .step-card, .stat-card, .feature-card,
.rise-card, .top5-panel, .mover-card, .compare-preview, .tool-card,
.result-card, .side-card {
  transition: box-shadow var(--ease-med), border-color var(--ease-med),
    transform var(--ease-med);
}
.card:hover, .mini-card:hover, .collection-card:hover, .step-card:hover,
.feature-card:hover, .top5-panel:hover, .mover-card:hover,
.compare-preview:hover, .side-card:hover {
  box-shadow: var(--shadow-lift);
  border-color: #d3d9e6;
}
.stat-card:hover { box-shadow: var(--shadow-lift); border-color: var(--accent); }
.btn:active, .show-all:active, .seg button:active, .chip:active,
.next-list a:active { transform: translateY(1px); }
.icon-btn:active { transform: scale(0.94); }
.search-option { transition: background-color var(--ease); }
.search-panel {
  opacity: 0; transform: translateY(-4px);
  transition: opacity var(--ease), transform var(--ease);
}
.search-panel.open { opacity: 1; transform: translateY(0); }
.main-nav.open { animation: drawer-in 200ms ease; }
@keyframes drawer-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.mobile-search.open { animation: drawer-in 200ms ease; }
.chart .dot { transition: r var(--ease); }
.chart .dot:hover { r: 5.5; }
.vs-cell, .compare-card { transition: box-shadow var(--ease-med), border-color var(--ease-med); }
.vs-cell:hover { box-shadow: var(--shadow-lift); }
.tab { transition: color var(--ease), border-color var(--ease); }
a, .dir-link, .pop-list a, .top5-list a, .rise-name {
  transition: color var(--ease), background-color var(--ease);
}

/* ---------- Compare tool (§8) ---------- */
.compare-tool { padding: 24px; }
.compare-tool .compare-intro { color: var(--muted); margin-top: 0; }
.compare-fields { display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
.compare-field { min-width: 0; }
.compare-field label { display: block; margin: 14px 0 6px; }
.compare-field .search-field input[type="text"] { min-height: 52px; font-size: 1.05rem; }
/* .tool-card input padding (12px) would otherwise override the
   .search-field icon padding — keep the icon clear of the text. */
.tool-card .search-field input[type="text"],
.tool-card .search-field input[type="search"] {
  padding-left: 40px; padding-right: 40px;
}
.compare-field select { width: 100%; }
.field-hint { font-size: 0.88rem; color: var(--muted); margin: 6px 0 0; }
.compare-states { display: grid; grid-template-columns: 1fr; gap: 0; }
.compare-vs {
  display: flex; align-items: center; justify-content: center;
  padding: 12px 0 2px;
}
/* Keep the result clear of the sticky desktop header when scrolled to. */
#compare-result { scroll-margin-top: 16px; }
.compare-vs span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-family: var(--font-head); font-weight: 800; font-size: 0.85rem;
  letter-spacing: 0.05em;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--border);
}
.compare-error {
  margin: 14px 0 0; padding: 12px 16px;
  background: var(--danger-soft); border: 1px solid #f3c8cb;
  border-left: 4px solid var(--danger); border-radius: var(--radius);
  color: var(--text); font-size: 0.95rem;
}
.compare-submit { width: 100%; margin-top: 20px; min-height: 52px; font-size: 1.05rem; }
.compare-note { font-size: 0.9rem; color: var(--muted); margin: 12px 0 0; text-align: center; }
.compare-examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; align-items: center; }
.compare-examples .examples-label { font-size: 0.92rem; color: var(--muted); font-weight: 600; }
.compare-empty { margin: 18px 0; padding: 36px 22px; }
.compare-empty h2 { margin-top: 0; color: var(--primary-dark); }
.compare-empty p { max-width: 560px; margin-left: auto; margin-right: auto; }
.compare-empty .compare-examples { justify-content: center; }
.compare-loading { margin: 18px 0; }
.compare-loading .skeleton { display: block; margin: 12px 0; }
.compare-loading .sk-verdict { height: 28px; width: 70%; }
.compare-loading .sk-line { height: 16px; width: 90%; }
.compare-loading .sk-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.compare-loading .sk-card { height: 120px; }
.compare-verdict {
  font-family: var(--font-head); font-size: 1.4rem; font-weight: 800;
  line-height: 1.3; color: var(--primary-dark); margin: 0 0 0.6rem;
}
.compare-verdict .verdict-name { color: var(--accent-dark); }
.compare-summary { font-size: 1.02rem; color: var(--text); }
.diff-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px;
  background: var(--teal-soft); color: var(--teal-dark);
  font-size: 0.85rem; font-weight: 700; white-space: nowrap;
}
.vs-grid .vs-cell { position: relative; }
.vs-cell.vs-winner { border-color: var(--accent); box-shadow: var(--shadow-lift); }
.vs-winner-tag {
  position: absolute; top: -12px; right: 14px;
  padding: 3px 12px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 0.78rem; font-weight: 800; font-family: var(--font-head);
  letter-spacing: 0.02em; white-space: nowrap;
}
.vs-cell .vs-share { color: var(--muted-dark); font-size: 0.95rem; }
.vs-bars { margin: 18px 0 4px; }
.vs-bar-row { margin: 10px 0; }
.vs-bar-label {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 0.9rem; font-weight: 700; color: var(--primary-dark);
}
.vs-bar-label .vs-bar-count { color: var(--muted); font-weight: 600; }
.vs-bar-track {
  height: 12px; border-radius: 999px; background: var(--primary-soft);
  margin-top: 5px; overflow: hidden;
}
.vs-bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.vs-bar-fill.bar-b { background: var(--teal); }
.vs-bar-note { font-size: 0.88rem; color: var(--muted); margin: 4px 0 0; }
.compare-top-states { margin: 18px 0 0; }
.compare-top-states ol { margin: 0.4rem 0; padding-left: 1.3rem; }
.compare-top-states li { margin: 0.45rem 0; }
.compare-top-states li strong { color: var(--primary-dark); }
.compare-chart-title { margin-top: 1.6rem; }
.compare-copy { margin-top: 18px; }
.compare-copy .btn { margin-top: 0; }
.compare-copy .btn.is-copied { background: var(--teal-dark); }
@media (min-width: 640px) {
  .compare-submit { width: auto; min-width: 220px; }
  .compare-states { grid-template-columns: 1fr auto 1fr; gap: 0 4px; align-items: end; }
  .compare-vs { padding: 0 0 4px; }
  .compare-vs span { width: 40px; height: 40px; }
}
@media (min-width: 900px) {
  .compare-fields { grid-template-columns: 1.4fr 1fr; align-items: start; }
  .compare-field-name { grid-column: 1; }
  .compare-states { grid-column: 1 / -1; }
  .compare-field-year { grid-column: 2; grid-row: 1; }
}

/* ---------- Trust pages (§10) ---------- */
.prose-card { max-width: 820px; }
.prose-legal { max-width: 760px; }
.prose-legal h2 { font-size: 1.2rem; margin-top: 1.8rem; }
.prose-legal p { line-height: 1.75; }
.fact-strip {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin: 4px 0 20px;
}
@media (min-width: 640px) { .fact-strip { grid-template-columns: repeat(4, 1fr); } }
.fact-strip .fact {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.fact-strip .fact b {
  display: block; font-family: var(--font-head); font-size: 1.15rem;
  color: var(--primary-dark); line-height: 1.25;
}
.fact-strip .fact span { font-size: 0.85rem; color: var(--muted); }
.source-card {
  background: var(--teal-soft); border: 1px solid #cfe8e3;
  border-radius: var(--radius); padding: 16px 18px; margin: 0 0 20px;
}
.source-card h2 { margin-top: 0; font-size: 1.1rem; }
.source-card p { margin: 0.35rem 0; }
.source-card p:last-child { margin-bottom: 0; }
.prose-methodology { counter-reset: method; }
.prose-methodology h2 { position: relative; padding-left: 44px; }
.prose-methodology h2::before {
  counter-increment: method;
  content: counter(method, decimal-leading-zero);
  position: absolute; left: 0; top: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-family: var(--font-head); font-size: 0.82rem; font-weight: 800;
}
.prose-methodology h2:first-of-type { margin-top: 0.4rem; }
.about-points {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  margin: 18px 0 4px; list-style: none; padding: 0;
}
@media (min-width: 640px) { .about-points { grid-template-columns: repeat(3, 1fr); } }
.about-points li {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  font-size: 0.94rem; font-weight: 600; color: var(--primary-dark);
}
.about-points li span { display: block; font-weight: 400; color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.contact-card {
  background: var(--accent-soft); border: 1px solid #d9d7fb;
  border-radius: var(--radius); padding: 18px 20px; margin: 0 0 18px;
  text-align: center;
}
.contact-card .contact-email {
  font-family: var(--font-head); font-size: 1.25rem; font-weight: 800;
  color: var(--primary-dark); text-decoration: none; overflow-wrap: break-word;
}
.contact-card .contact-email:hover { color: var(--accent-dark); text-decoration: underline; }
.contact-card p { margin: 0.35rem 0; }
.corrections-steps {
  list-style: none; margin: 18px 0; padding: 0; counter-reset: fix;
  display: grid; grid-template-columns: 1fr; gap: 10px;
}
@media (min-width: 640px) { .corrections-steps { grid-template-columns: repeat(3, 1fr); } }
.corrections-steps li {
  background: var(--bg); border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius); padding: 16px 18px; font-size: 0.95rem;
}
.corrections-steps li::before {
  counter-increment: fix;
  content: "Step " counter(fix);
  display: block; font-family: var(--font-head); font-weight: 800;
  font-size: 0.85rem; color: var(--accent-dark); margin-bottom: 6px;
}
.author-card {
  display: flex; flex-direction: column; gap: 16px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin: 0 0 18px;
}
@media (min-width: 640px) { .author-card { flex-direction: row; align-items: flex-start; } }
.author-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 50%; flex: 0 0 auto;
  background: var(--primary); color: #fff;
  font-family: var(--font-head); font-size: 2rem; font-weight: 800;
}
.author-card .author-role {
  font-family: var(--font-head); font-weight: 800; color: var(--primary-dark);
  font-size: 1.1rem; margin: 0 0 4px;
}
.author-card p { margin: 0.3rem 0; }
.author-does { list-style: none; margin: 10px 0 0; padding: 0; }
.author-does li { margin: 0.4rem 0; padding-left: 22px; position: relative; }
.author-does li::before {
  content: ""; position: absolute; left: 2px; top: 0.55em;
  width: 8px; height: 8px; border-radius: 50%; background: var(--teal);
}

/* ---------- Climber stat-card: never split "Name · +N" (§16 polish) ---------- */
.stat-card b.stat-climber { white-space: nowrap; font-size: 1.25rem; }
@media (max-width: 480px) {
  .stat-card b.stat-climber { font-size: 1.08rem; }
  .stat-grid .stat-card b { font-size: 1.2rem; }
}
.stat-card { min-width: 0; }
.stat-card b { overflow-wrap: break-word; }

/* ---------- Responsive polish (§12) ---------- */
img, svg.chart { max-width: 100%; }
@media (max-width: 480px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .page-hero .wrap { padding-top: 24px; padding-bottom: 24px; }
  .stat-row .stat { min-width: 0; flex: 1 1 calc(50% - 6px); }
  .stat-row .stat b { font-size: 1.2rem; }
  .tool-card, .result-card, .compare-tool { padding: 18px 16px; }
  .prose-card { padding: 20px 18px; }
  .compare-verdict { font-size: 1.2rem; }
  .fact-strip { grid-template-columns: 1fr 1fr; }
  .map-tile { min-height: 44px; }
}
@media (min-width: 1440px) {
  .page-hero .wrap { padding-top: 52px; padding-bottom: 48px; }
}
@media (min-width: 1920px) {
  .wrap { max-width: 1280px; }
}

/* ---------- Reduced motion (§11 / §15) ---------- */
@media (prefers-reduced-motion: reduce) {
  .search-panel { opacity: 1; transform: none; }
  .main-nav.open, .mobile-search.open { animation: none; }
  .chart .dot { transition: none; }
}

/* ---------- Batch 6 tools (ChatGPT §7) ---------- */
.legend-tier-1, .legend-tier-2, .legend-tier-3 { display: inline-block; padding: 1px 10px; border-radius: 999px; font-weight: 600; }
.legend-tier-1 { background: var(--accent); color: #fff; }
.legend-tier-2 { background: #c9c6f7; color: var(--primary-dark); }
.legend-tier-3 { background: var(--accent-soft); color: var(--primary-dark); }
.btn-save { background: var(--surface); color: var(--primary); border: 2px solid var(--primary); }
.btn-save:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
.btn-save.is-saved { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-save.is-saved:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
@media (min-width: 640px) { .tool-grid { grid-template-columns: 1fr 1fr; } }
#namemap-sex { margin-top: 12px; }
#namemap-sex button[disabled] { opacity: 0.45; cursor: not-allowed; }
#vsname-chart .chart { margin-top: 8px; }
