:root {
  color-scheme: dark;
  /* UX palette lock (logo + Pages). Soft: --color-brand is large/UI only on dark (≈3.9:1) — never body text. */
  --color-brand: #0066FC;
  --color-signal: #00D9FB;
  --color-bg: #0B0F1A;
  --color-text: #F4F7FB;
  --color-text-muted: #9AA8C7;
  --color-border: #243049;
  --color-error: #F04438;

  /* Legacy aliases → UX tokens */
  --surface: var(--color-bg);
  --fg: var(--color-text);
  --muted: var(--color-text-muted);
  --border: var(--color-border);
  --accent: var(--color-brand);
  --code-panel: #070b14;
  --code-fg: var(--color-text);
  --code-border: var(--color-border);
  --inline-code-bg: #12182a;
  --max: 42rem;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --surface: #F4F7FB;
    --fg: #0B0F1A;
    --muted: #4A5A7A;
    --border: #C5D0E6;
    --accent: var(--color-brand);
    --code-panel: #0B0F1A;
    --code-fg: #F4F7FB;
    --code-border: #243049;
    --inline-code-bg: #E8EEF8;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: var(--color-bg);
  --fg: var(--color-text);
  --muted: var(--color-text-muted);
  --border: var(--color-border);
  --accent: var(--color-brand);
  --code-panel: #070b14;
  --code-fg: var(--color-text);
  --code-border: var(--color-border);
  --inline-code-bg: #12182a;
}

:root[data-theme="light"] {
  color-scheme: light;
  --surface: #F4F7FB;
  --fg: #0B0F1A;
  --muted: #4A5A7A;
  --border: #C5D0E6;
  --accent: var(--color-brand);
  --code-panel: #0B0F1A;
  --code-fg: #F4F7FB;
  --code-border: #243049;
  --inline-code-bg: #E8EEF8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--fg);
}

main, footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1rem 0;
}

header { margin-bottom: 1rem; }

.title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.5rem;
}

.title-row h1 {
  margin: 0;
  flex: 1;
}

.theme-toggle {
  flex-shrink: 0;
  margin-left: auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1.3;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  color: var(--color-text);
  border-color: var(--color-signal);
  outline: 2px solid var(--color-signal);
  outline-offset: 2px;
}

.seal {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: block;
  border-radius: 4px;
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--fg);
}

h2 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
  color: var(--fg);
}

h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

.one-liner {
  margin: 0;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
}

nav a:hover {
  color: var(--accent);
}

nav a:focus-visible {
  color: var(--color-text);
  outline: 2px solid var(--color-signal);
  outline-offset: 2px;
}

/* Links = UI chrome (brand). Body copy stays --fg / --color-text. */
a { color: var(--accent); }

a:hover { text-decoration: underline; }

a:focus-visible {
  outline: 2px solid var(--color-signal);
  outline-offset: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

th { font-weight: 600; }

.swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 0.4rem;
}

.palette-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.fail-closed {
  color: var(--color-error);
  font-weight: 600;
}

/* Dark code panels for highlighted blocks (stay dark in both themes) */
pre,
pre[class*="language-"] {
  background: var(--code-panel);
  color: var(--code-fg);
  border: 1px solid var(--code-border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 2;
  margin: 0.75rem 0 1rem;
}

code {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

p code, td code, li code, h1 code, h2 code, h3 code, nav code {
  background: var(--inline-code-bg);
  color: var(--fg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

pre code,
pre[class*="language-"] code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
  border-radius: 0;
}

/* Prism token tweaks on dark panel — brand/signal blues (no teal) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #9AA8C7;
}

.token.punctuation {
  color: #C5D0E6;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
  color: #7EB6FF;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #00D9FB;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #A5B4FC;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #0066FC;
}

.token.function,
.token.class-name {
  color: #fcd34d;
}

.token.regex,
.token.important,
.token.variable {
  color: #F04438;
}

ul {
  padding-left: 1.25rem;
}

ul.checklist {
  list-style: none;
  padding-left: 0;
}

li { margin: 0.35rem 0; }

ol {
  padding-left: 1.25rem;
}

footer {
  margin-top: 2.5rem;
  padding-bottom: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

footer p { margin: 1rem 0 0; }

footer a { color: var(--accent); }
