:root {
  color-scheme: light;
  --page:           #f9f9f9;
  --surface-1:      #ffffff;
  --text-primary:   #191919;
  --text-secondary: #666666;
  --series-1:       #257de0;
  --series-1-wash:  rgba(37, 125, 224, 0.10);
  --gridline:       #e7e7e7;
  --baseline:       #c2c2c2;
  --border:         rgba(11, 11, 11, 0.10);
  --link:           #1b64be;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:           #0b0b0b;
    --surface-1:      #191919;
    --text-primary:   #efefef;
    --text-secondary: #9c9c9c;
    --series-1:       #338ced;
    --series-1-wash:  rgba(51, 140, 237, 0.16);
    --gridline:       #303030;
    --baseline:       #474747;
    --border:         rgba(255, 255, 255, 0.10);
    --link:           #6aabf1;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #0b0b0b;
  --surface-1:      #191919;
  --text-primary:   #efefef;
  --text-secondary: #9c9c9c;
  --series-1:       #338ced;
  --series-1-wash:  rgba(51, 140, 237, 0.16);
  --gridline:       #303030;
  --baseline:       #474747;
  --border:         rgba(255, 255, 255, 0.10);
  --link:           #6aabf1;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.5;
}
a { color: var(--link); }
.wrap { max-width: 960px; margin: 0 auto; padding: 32px 16px 48px; }
header.site { margin-bottom: 24px; }
header.site a.home { color: var(--text-secondary); text-decoration: none; font-size: 14px; }
header.site a.home:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.2; margin: 8px 0 4px; }
.lede { color: var(--text-secondary); margin: 0; }

/* Landing */
.countries { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.countries a {
  display: block; padding: 20px; border-radius: 12px; text-decoration: none;
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text-primary);
}
.countries a:hover, .countries a:focus-visible { border-color: var(--series-1); outline: none; }
.countries .name { font-size: 20px; font-weight: 600; display: block; }
.countries .meta { color: var(--text-secondary); font-size: 14px; }

/* Chart page */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 16px 0; }
.stat .label { color: var(--text-secondary); font-size: 13px; display: block; }
.stat .value { font-size: 24px; font-weight: 600; }
.stat .when { color: var(--text-secondary); font-size: 13px; margin-left: 4px; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; }
.presets button {
  font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text-primary);
}
.presets button:hover { background: var(--series-1-wash); }
.presets button[aria-pressed="true"] { border-color: var(--series-1); background: var(--series-1-wash); font-weight: 600; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); }
.range select {
  font: inherit; font-size: 14px; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
#chart { width: 100%; height: 440px; }
@media (max-width: 600px) { #chart { height: 340px; } h1 { font-size: 24px; } }

details.table-view { margin-top: 16px; }
details.table-view summary { cursor: pointer; color: var(--link); }
.table-scroll { max-height: 360px; overflow: auto; margin-top: 8px; }
table { border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 4px 16px 4px 0; border-bottom: 1px solid var(--gridline); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 500; position: sticky; top: 0; background: var(--surface-1); }

.source { color: var(--text-secondary); font-size: 14px; margin-top: 24px; }
.source p { margin: 4px 0; }
.error { color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
