:root {
  --bg: #120f14;
  --panel: #1c1620;
  --ink: #f0e9e6;
  --ink-dim: #b8a9a5;
  --ink-faint: #7a6a68;
  --line: #332830;
  --groom: #6f93b8;
  --bride: #cf6f6f;
  --highlight: #e0a458;
  --cell-empty: #241c22;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --wrap: 760px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 22px; }

.top { padding: 16px 22px; font-size: 14px; }
.top a { color: var(--ink-faint); text-decoration: none; }
.top a:hover { color: var(--highlight); }

.masthead { padding-top: 8px; padding-bottom: 12px; }
.kicker {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--highlight);
  margin: 0 0 16px;
}
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 50px;
  line-height: 1.1;
  margin: 0 0 18px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.deck {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink-dim);
  margin: 0 0 6px;
  font-weight: 500;
  font-style: italic;
}

article { padding-bottom: 8px; }
p { margin: 0 0 22px; color: var(--ink); }
p.lede { font-size: 19px; }
a { color: var(--highlight); }
strong { color: var(--ink); font-weight: 600; }

h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 25px;
  margin: 34px 0 14px;
  color: var(--ink);
}

.langbar { margin: 18px 0 6px; font-size: 14px; color: var(--ink-faint); }
.langbar a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px solid var(--line); }
.langbar a:hover { color: var(--highlight); border-color: var(--highlight); }
.langbar .current { color: var(--highlight); }

/* --- Grid instrument --- */
.instrument {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 18px 22px;
  margin: 8px 0 30px;
}

.instrument-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
}
.instrument-head .year {
  font-family: var(--serif);
  font-size: 30px;
  color: var(--highlight);
  font-weight: 600;
}

.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-area {
  display: grid;
  grid-template-columns: 40px repeat(10, minmax(22px, 1fr));
  grid-template-rows: auto repeat(10, 1fr);
  gap: 2px;
  width: 100%;
}
.axis-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
}
.axis-corner { visibility: hidden; }
.axis-top { padding-bottom: 2px; }
.axis-left { justify-content: flex-end; padding-right: 5px; }
.cell {
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: var(--cell-empty);
  transition: background-color 0.25s ease;
  position: relative;
}
.cell.diag::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(240, 233, 230, 0.28);
  border-radius: 2px;
  pointer-events: none;
}
.cell.peak::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid var(--highlight);
  border-radius: 4px;
  pointer-events: none;
}

.axis-caption {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  text-align: center;
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.axis-caption.side {
  writing-mode: vertical-rl;
  text-align: center;
  position: absolute;
}

.controls { margin-top: 18px; }
input[type="range"] {
  width: 100%;
  accent-color: var(--highlight);
  height: 28px;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 2px;
}

.readout {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 16px;
  color: var(--ink-dim);
}
.readout strong { color: var(--highlight); }

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 4px 0 28px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.stat .num {
  font-family: var(--serif);
  font-size: 32px;
  color: var(--bride);
  font-weight: 600;
  line-height: 1;
  margin-bottom: 6px;
}
.stat .lbl {
  font-size: 13.5px;
  color: var(--ink-faint);
}

.method {
  font-size: 15px;
  color: var(--ink-dim);
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 6px;
}
.method p { margin-bottom: 16px; }

footer {
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding: 22px 0 40px;
  font-size: 13.5px;
  color: var(--ink-faint);
}
footer a { color: var(--ink-dim); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 480px) {
  h1 { font-size: 36px; }
  .deck { font-size: 18px; }
  .stat-row { grid-template-columns: 1fr; }
  .instrument-head .year { font-size: 24px; }
  .instrument { padding: 16px 12px 18px; }
  .axis-label { font-size: 8.5px; }
}

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