/* Light theme only, painted explicitly. Palette roles are declared once here
   so the chart script and the page share the same values. */
:root {
  color-scheme: light;

  --page:           #f9f9f7;
  --surface:        #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 32px 20px 48px;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 960px;
  margin: 0 auto;
}

header { margin-bottom: 24px; }

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Current weight and net change, read before the chart. */
.summary {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.summary div { display: flex; flex-direction: column; gap: 2px; }

.summary dt {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary dd {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.summary dd .unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
}

.summary dd .since {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
  text-transform: none;
}

/* Range filters sit in one row directly above the chart. */
.ranges {
  display: flex;
  gap: 6px;
  margin: 28px 0 8px;
}

.ranges button {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.ranges button:hover { border-color: var(--axis); }

.ranges button[aria-pressed="true"] {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}

.chart-card {
  padding: 16px 16px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.chart-wrap {
  position: relative;
  height: 420px;
}

/* Interventions are also listed as text, so identity never rests on color
   alone and a band too narrow for its label is still named. */
/* A four-column grid so swatch, name, dates and note line up down the list -
   with 13 interventions a ragged flex layout is unreadable. */
.key {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 9px 14px;
  align-items: baseline;
  font-size: 14px;
}

.key:empty { display: none; }

.key li { display: contents; }

.key .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  transform: translateY(1px);
}

.key .name { white-space: nowrap; }

.key .dates {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.key .note {
  color: var(--text-muted);
  font-size: 13px;
}

/* Too narrow for four columns: stack each entry instead. */
@media (max-width: 780px) {
  .key { grid-template-columns: auto 1fr; }
  .key .dates, .key .note { grid-column: 2; }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 6px 10px 6px 0;
  text-align: left;
  border-bottom: 1px solid var(--gridline);
}

th { color: var(--text-secondary); font-weight: 600; }

details { margin-top: 28px; }

summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
}

.table-scroll {
  max-height: 340px;
  overflow: auto;
  margin-top: 12px;
}

footer {
  margin-top: 32px;
  color: var(--text-muted);
  font-size: 13px;
}

footer p { margin: 0 0 4px; }

@media (max-width: 600px) {
  .chart-wrap { height: 320px; }
  .summary { gap: 20px; }
}
