/* Shared design system. Page styles own layout, never a second palette. */
:root {
  color-scheme: light;
  --bg: #f5f7f5;
  --surface: #ffffff;
  --surface-soft: #eef2ef;
  --ink: #18251d;
  --muted: #5e6c63;
  --line: #d9e2dc;
  --line-strong: #b8c7bd;
  --accent: #176a38;
  --accent-deep: #0d572c;
  --accent-soft: #e5f3e9;
  --selection: #c7e6d1;
  --warning: #926000;
  --syntax-built-in: #bc4c00;
  --syntax-section: #005cc5;
  --shadow: 0 2px 12px rgb(23 49 32 / 4%);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --text-body: 1rem;
  --text-label: 0.875rem;
  --text-meta: 0.75rem;
  --radius-panel: 1rem;
  --radius-control: 0.625rem;
  --radius-small: 0.375rem;
  --radius-pill: 999px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --page-gutter: clamp(16px, 3vw, 32px);
  --control-height: 44px;
  --header-height: 72px;
  font: 100%/1.5 var(--font-sans);
  font-synthesis: none;
}

/* CSS-only: system changes apply immediately, even before scripts have loaded. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1512;
    --surface: #151f19;
    --surface-soft: #1f2c23;
    --ink: #e4ede6;
    --muted: #a4b3a8;
    --line: #304136;
    --line-strong: #46604e;
    --accent: #87dca4;
    --accent-deep: #aaeabd;
    --accent-soft: #203e2a;
    --selection: #28583b;
    --warning: #e7bd6a;
    --syntax-built-in: #ffa657;
    --syntax-section: #79c0ff;
    --shadow: 0 2px 12px rgb(0 0 0 / 12%);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: 0.2em; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
::selection { background: var(--selection); color: var(--ink); }

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  transform: translateY(-160%);
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--surface);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
}
.skip-link:focus { transform: none; }

.site-topbar {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  min-height: var(--control-height);
  align-items: center;
  gap: var(--space-3);
  border-radius: var(--radius-control);
  font-size: var(--text-label);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand:hover { color: var(--accent); }
.brand-avatar {
  display: block;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  object-fit: cover;
}
.brand-name { overflow-wrap: anywhere; }
.surface {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ui-button {
  display: inline-flex;
  min-height: var(--control-height);
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: var(--space-2) var(--space-3);
  color: var(--ink);
  font-size: var(--text-label);
  font-weight: 550;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.ui-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-soft);
  color: var(--accent);
}
.ui-button--primary,
.ui-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.ui-button--primary:hover:not(:disabled),
.ui-button[aria-pressed="true"]:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.ui-button:disabled { opacity: 0.5; cursor: default; }
.ui-icon-button { width: var(--control-height); flex: 0 0 var(--control-height); padding: 0; }
.stroke-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.eyebrow, .section-kicker {
  margin: 0;
  color: var(--accent);
  font: 600 var(--text-meta)/1.5 var(--font-mono);
  letter-spacing: 0.06em;
}
.noscript {
  position: fixed;
  inset: auto var(--space-4) var(--space-4);
  z-index: 100;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: var(--space-4);
  color: var(--ink);
  box-shadow: var(--shadow);
}
@media (max-width: 680px) {
  .brand-name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
