:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-soft: #f2f4f8;
  --fg: #111418;
  --fg-muted: #4a5058;
  --border: #111418;
  --border-soft: #bfc4cc;
  --accent: #0a47c2;
  --accent-fg: #ffffff;
  --focus: #ffbf00;
  --max-w: 70rem;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-soft: #141820;
  --fg: #f1f3f7;
  --fg-muted: #c3c9d2;
  --border: #f1f3f7;
  --border-soft: #3a414b;
  --accent: #9fc3ff;
  --accent-fg: #0b0d10;
  --focus: #ffd34d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d10;
    --bg-soft: #141820;
    --fg: #f1f3f7;
    --fg-muted: #c3c9d2;
    --border: #f1f3f7;
    --border-soft: #3a414b;
    --accent: #9fc3ff;
    --accent-fg: #0b0d10;
    --focus: #ffd34d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
}

.skip-links {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip-links:focus-within {
  position: static;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--fg);
}
.skip-links a {
  color: var(--bg);
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--fg);
}
.skip-links a:focus-visible {
  outline-color: var(--bg);
  box-shadow: none;
}

.site-header {
  border-bottom: 2px solid var(--border);
}
.site-header .shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.9rem 1rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
}
.site-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.site-title a {
  color: var(--fg);
  text-decoration: none;
}
.site-title a:hover,
.site-title a:focus-visible { text-decoration: underline; }
.tagline {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.top-nav {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
}
.top-nav .shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.25rem 1rem;
}
.top-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.5rem;
}
.top-nav a {
  display: inline-block;
  min-height: 2.5rem;
  padding: 0.6rem 0.85rem;
  line-height: 1.3;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 3px;
}
.top-nav a[aria-current] {
  background: var(--accent);
  color: var(--accent-fg);
  text-decoration: none;
  font-weight: 700;
}

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

main h1 {
  font-size: 2rem;
  margin: 0 0 0.75rem;
  line-height: 1.2;
}
main h2 { font-size: 1.3rem; margin-top: 1.75rem; }
main h3 { font-size: 1.1rem; margin-top: 1.25rem; }
main > h1 + p {
  max-width: 55ch;
  font-size: 1.15rem;
  color: var(--fg-muted);
}
p { margin: 0.6rem 0; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.crumbs { font-size: 0.9rem; color: var(--fg-muted); margin-bottom: 0.75rem; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.crumbs li + li::before { content: "›"; margin-right: 0.25rem; }
.crumbs [aria-current="page"] { font-weight: 600; color: var(--fg); }

.panel {
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
}
.panel > h2:first-child,
.panel > h3:first-child { margin-top: 0; }

.button {
  display: inline-block;
  min-height: 2.75rem;
  padding: 0.7rem 1.15rem;
  line-height: 1.3;
  background: var(--accent);
  color: var(--accent-fg);
  border: 2px solid var(--accent);
  border-radius: 3px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover,
.button:focus-visible {
  background: var(--bg);
  color: var(--accent);
  text-decoration: underline;
}

ul.clean { padding-left: 1.25rem; }
ul.clean li { margin: 0.25rem 0; }

.meta {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.stats {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
}
.stats[hidden] { display: none; }
.stats li {
  padding: 0.75rem 1rem;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
}
.stats strong {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}

.site-footer {
  flex-shrink: 0;
  margin-top: 2rem;
  background: var(--bg-soft);
  border-top: 2px solid var(--border);
  color: var(--fg-muted);
}
.site-footer .shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.25rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.site-footer p { margin: 0; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
}
.toolbar > div {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.toolbar label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
}
.toolbar select {
  min-height: 2.25rem;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
}
.copyright {
  width: 100%;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 40rem) {
  .site-header .shell {
    flex-direction: column;
    align-items: flex-start;
  }
  .top-nav ul {
    flex-direction: column;
    align-items: stretch;
  }
  .top-nav a { display: block; }
  main h1 { font-size: 1.7rem; }
}

@media (forced-colors: active) {
  .button, .panel, .stats li, .site-header, .top-nav, .site-footer {
    border-color: CanvasText;
  }
}
