:root {
  --primary: #0f6b3c;
  --primary-dark: #0b4f2c;
  --accent: #c5922c;
  --text: #1a202c;
  --text-secondary: #52605a;
  --bg: #ffffff;
  --bg-secondary: #f4f7f5;
  --border: #e2e8e4;
  --border-light: #eef2ef;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --transition: 0.2s ease;
  --header-height: 64px;
  --max: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg-secondary);
  line-height: 1.6;
}
img { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }

.container { width: min(var(--max), calc(100% - 2.5rem)); margin: 0 auto; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -3rem; background: var(--primary-dark);
  color: #fff; padding: 0.4rem 0.8rem; border-radius: 8px; z-index: 200;
}
.skip-link:focus { top: 0.5rem; }

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 4px rgba(0, 20, 40, 0.04);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: var(--header-height); padding: 0.5rem 0;
}
.logo { display: flex; align-items: center; }
.logo img { height: 40px; width: auto; display: block; }
.header-nav { display: flex; gap: 0.9rem; }
.header-nav a { color: var(--text); font-weight: 600; white-space: nowrap; }
.header-nav a:hover { color: var(--primary); text-decoration: none; }

.search-box { position: relative; }
.header-search { flex: 1; max-width: 420px; }
.search-box input[type="search"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 1rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}
.search-box input:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}
.search-panel {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden;
}
.search-panel ul { list-style: none; margin: 0; padding: 0.25rem; }
.search-hit {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.55rem 0.7rem; border-radius: 8px; color: var(--text);
}
.search-hit:hover, .search-hit.is-active { background: var(--bg-secondary); text-decoration: none; }
.search-hit-name { font-weight: 650; }
.search-hit-meta { color: var(--text-secondary); font-size: 0.85rem; }
.search-empty { margin: 0; padding: 0.8rem 1rem; color: var(--text-secondary); }

.breadcrumb { background: #fff; border-bottom: 1px solid var(--border-light); }
.breadcrumb-list {
  display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none;
  margin: 0; padding: 0.7rem 0; font-size: 0.92rem; color: var(--text-secondary);
}
.breadcrumb-item:not(:last-child)::after { content: "/"; margin-left: 0.35rem; color: #9aa59e; }

.hero {
  background: linear-gradient(135deg, #0b3d2e 0%, #127a45 100%);
  color: #fff;
  padding: 2.75rem 0 2.4rem;
}
.hero .kicker {
  margin: 0 0 0.4rem; letter-spacing: 0.04em; text-transform: uppercase;
  font-size: 0.78rem; font-weight: 700; color: #f3d48a;
}
.hero h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.hero .lead { max-width: 42rem; color: rgba(255, 255, 255, 0.92); font-size: 1.05rem; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
.hero-stats li {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  min-width: 7.5rem;
}
.hero-stats strong { display: block; font-size: 1.35rem; }
.hero-search { max-width: 36rem; margin-top: 1.25rem; }
.hero-search input[type="search"] { height: 52px; font-size: 1.05rem; }

.section { padding: 1.75rem 0 2.5rem; }
.section h2 { font-size: 1.35rem; }

.card-grid, .cards { display: grid; gap: 1rem; }
.card-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cards { grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); align-items: start; }
.card, .place-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 1.25rem 1.35rem;
}
.place-card { display: flex; flex-direction: column; gap: 0.15rem; color: inherit; }
.place-card:hover { border-color: var(--primary); text-decoration: none; box-shadow: var(--shadow-md); }
.place-code {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; color: var(--accent);
}
.place-card strong { font-size: 1.15rem; }
.muted { color: var(--text-secondary); }
.source-cite {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.source-cite a { color: var(--primary); }
.card h2 { font-size: 1.15rem; }
.fact-list { list-style: none; margin: 0; padding: 0; }
.fact-list li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 0; border-bottom: 1px solid var(--border-light);
}
.fact-list li:last-child { border-bottom: 0; }
.fact-list span { color: var(--text-secondary); }
.fact-list strong { text-align: right; }

.map { height: 420px; border-radius: var(--radius); background: #e7efe9; z-index: 0; }
.map-note { margin-top: 0.7rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.45rem 0.9rem; margin: 0.75rem 0 0; padding: 0; list-style: none; font-size: 0.85rem; }
.legend i { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.35rem; vertical-align: -1px; }
.place-list { list-style: none; margin: 0; padding: 0; }
.place-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--border-light); }
.place-list li:last-child { border-bottom: 0; }
.place-list .muted { display: block; }

.regional-block { margin: 0 0 1.5rem; scroll-margin-top: 84px; }
.regional-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.regional-swatch {
  display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%;
  margin-right: 0.4rem; vertical-align: middle;
}
.link-list { list-style: none; margin: 0.4rem 0 0; padding: 0; columns: 3; }
.rank-list { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.rank-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--border-light); }
.rank-list li:last-child { border-bottom: 0; }
.rank-list .area-tag { display: block; margin-top: 0.1rem; }
.link-list a { display: inline-block; padding: 0.12rem 0; }
.area-tag { color: var(--text-secondary); font-size: 0.85rem; }

.census-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.census-grid h3 { font-size: 0.95rem; margin: 0.9rem 0 0.2rem; }
.census-city { margin-top: 1rem; }
.pyramid { display: grid; gap: 0.18rem; margin: 0.4rem 0 0.8rem; }
.pyramid-row {
  display: grid;
  grid-template-columns: 3.1rem minmax(0, 1fr) 3.4rem minmax(0, 1fr) 3.1rem;
  align-items: center;
  gap: 0.28rem;
}
.pyramid-num { font-size: 0.72rem; color: var(--text-secondary); text-align: right; font-variant-numeric: tabular-nums; }
.pyramid-num.female { text-align: left; }
.pyramid-age { text-align: center; font-size: 0.72rem; font-weight: 700; }
.pyramid-side { display: flex; height: 0.62rem; border-radius: 2px; background: #e7eef6; }
.pyramid-side.male { justify-content: flex-end; }
.pyramid-side.female { justify-content: flex-start; background: #e5f2ea; }
.pyramid-side span { display: block; height: 100%; min-width: 1px; border-radius: 2px; background: #1d4e89; }
.pyramid-side.female span { background: #0f6b3c; }
.pyramid-key { font-size: 0.82rem; color: var(--text-secondary); }
.pyramid-key .swatch, .swatch {
  display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin: 0 0.2rem 0 0.55rem; vertical-align: -1px;
}
.swatch.male { background: #1d4e89; margin-left: 0; }
.swatch.female { background: #0f6b3c; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.table-scroll { overflow-x: auto; }
.rank-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.rank-table th, .rank-table td { text-align: left; padding: 0.4rem 0.15rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.rank-table th.num, .rank-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-table tr:last-child td { border-bottom: 0; }
.map-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; align-items: center; margin: 0.7rem 0 0; padding: 0; list-style: none; font-size: 0.82rem; color: var(--text-secondary); }
.map-legend i { display: inline-block; width: 0.95rem; height: 0.7rem; border-radius: 2px; margin-right: 0.3rem; vertical-align: -1px; }
.street-index { font-size: 1.05rem; margin: 0.2rem 0 0.6rem; }
.street-index strong { font-size: 1.6rem; display: block; }

.footer {
  border-top: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-size: 0.92rem;
  padding: 1.5rem 0 2rem;
}

@media (max-width: 800px) {
  .cards, .census-grid, .pair { grid-template-columns: 1fr; }
  .link-list { columns: 2; }
  .map { height: 320px; }
}
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; }
  .header-search { max-width: none; flex-basis: 100%; }
  .link-list { columns: 1; }
  .container { width: min(var(--max), calc(100% - 1.5rem)); }
}
