:root {
  --ink: #1c1612;
  --muted: #5e534a;
  --paper: #f6f1e8;
  --card: #fffdf8;
  --line: #e4d8c8;
  --ember: #b84314;
  --ember-dark: #8a3010;
  --header: #241c16;
  --header-text: #f6f1e8;
  --sample: #f3e2c4;
  --live: #e3efe4;
  --focus: #9a3412;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.5 "Segoe UI", Helvetica, Arial, sans-serif;
}

a { color: var(--ember-dark); }

h1, h2, h3 {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 600;
  line-height: 1.2;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--header);
  color: var(--header-text);
}

.brand {
  color: var(--header-text);
  font-weight: 650;
  text-decoration: none;
  letter-spacing: 0.01em;
}

nav { display: flex; gap: 1rem; }

nav a {
  color: #f0e4d4;
  text-decoration: none;
}

nav a[aria-current="page"] {
  color: white;
  border-bottom: 2px solid #e7a15a;
}

main {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 3rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--ember);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 { margin: 0 0 0.6rem; font-size: 2.1rem; }

.lede { max-width: 42rem; font-size: 1.08rem; }

.banner {
  margin: 1.25rem 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--sample);
}

.banner[data-source="r2"] { background: var(--live); }

.actions, .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin: 1rem 0 1.25rem;
}

.card-link, button, .button {
  display: inline-block;
  padding: 0.65rem 0.95rem;
  border: 1px solid var(--ember-dark);
  border-radius: 8px;
  background: var(--ember);
  color: white;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary, button.secondary {
  background: transparent;
  color: var(--ember-dark);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

select {
  min-width: 12rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.panel {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.panel h2 { margin: 0 0 0.35rem; font-size: 1.35rem; }

.stat { margin: 0.2rem 0; }

.muted { color: var(--muted); }

.scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
}

th, td { padding: 0.2rem; text-align: center; }

th {
  position: sticky;
  top: 0;
  background: #fbf7f1;
  font-size: 0.78rem;
  font-weight: 600;
}

th.year, td.year {
  text-align: right;
  padding-right: 0.55rem;
  font-variant-numeric: tabular-nums;
}

.cell {
  width: 100%;
  min-width: 3.1rem;
  min-height: 2.5rem;
  padding: 0.3rem 0.15rem;
  border: 2px solid transparent;
  border-radius: 4px;
  font: 0.72rem/1.2 ui-monospace, Consolas, monospace;
  cursor: pointer;
}

.cell[aria-pressed="true"] {
  border-color: var(--ink);
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.swatch {
  width: 1.6rem;
  height: 0.8rem;
  border-radius: 2px;
}

canvas {
  width: 100%;
  height: 220px;
  display: block;
}

.sms {
  white-space: pre-wrap;
  margin: 0.5rem 0 0;
  padding: 0.9rem 1rem;
  background: #241c16;
  color: #f6f1e8;
  border-radius: 8px;
  font-family: Georgia, Palatino, serif;
  font-size: 1.05rem;
}

.keys {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

.keys code, p code, li code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
}

ol.steps li { margin: 0.45rem 0; }

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

.stats { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.8rem 0; }
.stat-card {
  flex: 1 1 16rem;
  max-width: 22rem;
  padding: 0.75rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.stat-card span { display: block; color: var(--muted); font-size: 0.78rem; }
.stat-card strong { display: block; margin: 0.15rem 0; font-size: 1.25rem; }
.stat-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.metric { margin: 0.4rem 0 0; }
.metric div { margin: 0 0 0.9rem; }
.metric dt { font-weight: 650; }
.metric dt a, .stat-card span a, h2 a, h3 a { color: inherit; }
a.badge { color: var(--ink); text-decoration: none; }
a.badge:hover { text-decoration: underline; }

.glossary article { scroll-margin-top: 0.75rem; }
.glossary h2 { margin: 1.6rem 0 0.6rem; font-size: 1.35rem; }
.glossary article h3 { margin: 0 0 0.3rem; font-size: 1.15rem; }
.glossary article p, .glossary article li { margin: 0.35rem 0; }
.glossary-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin: 0.5rem 0 0.25rem;
}
.metric-value { margin: 0.1rem 0; font-size: 1.15rem; color: var(--ink); }
.metric .metric-value { margin: 0.1rem 0; color: var(--ink); font-size: 1.15rem; }
.metric .metric-help { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.92rem; }

.badge {
  display: inline-block;
  margin: 0 0.35rem 0.35rem 0;
  padding: 0.12rem 0.5rem;
  border-radius: 99px;
  background: var(--sample);
  font-size: 0.75rem;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(16rem, 0.7fr);
  gap: 1rem;
  align-items: start;
}
#map {
  height: 520px;
  border-radius: 10px;
  background: #e7e0d4;
  border: 1px solid var(--line);
}
.leaflet-container { font: inherit; }

.season {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.25rem;
}
.season span {
  text-align: center;
  font-size: 0.72rem;
  padding: 0.4rem 0;
  border-radius: 4px;
  background: #efe6d8;
}
.season .in { background: #f3d7a1; }
.season .peak { background: #b84314; color: #fff8f0; }

.ratio {
  display: grid;
  grid-template-columns: 2.2rem 1fr 3rem;
  gap: 0.4rem;
  align-items: center;
  margin: 0.25rem 0;
  font-size: 0.85rem;
}
.ratio i {
  display: block;
  height: 0.7rem;
  background: #e8a04a;
  border-radius: 3px;
}

.cards { display: grid; gap: 0.75rem; }
.analog {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

@media (max-width: 800px) {
  .map-layout { grid-template-columns: 1fr; }
  #map { height: 380px; }
  .season { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 640px) {
  h1 { font-size: 1.7rem; }
  .bar { align-items: flex-start; flex-direction: column; }
}
