:root {
  /* light theme */
  --bg: #FAFAFB;
  --bg-raise: #F2F3F5;
  --bg-deep: #E9EBEF;
  --ink: #1E1E1E; /* headings */
  --text: #33353A; /* body */
  --muted: #646A76; /* secondary */
  --line: #DFE2E7;
  --field-line: #787F8C; /* form-control boundary: 3:1+ on --bg (SC 1.4.11) */
  --line-soft: #EAECF0;
  --accent: #8B2BFF; /* brand purple, darkened for AA on light. links, buttons, active states */
  --wordmark-accent: #AD69FF; /* wordmark chevron, shared by both themes */
  --accent-ink: #6D00F1; /* hover/pressed */
  --accent-wash: #F3EAFF; /* tinted wells, tag fills */
  --accent-contrast: #FFFFFF; /* delivered verbatim */
  --ok: #157A57;
  --danger: #A93226;
  --danger-wash: #FBEBE9;
  --note-bg: #FFF6DE;
  --note-line: #EAD9A8;
  --note-text: #6B4A00;
  --selection: #E7D6FF;
  --chrome: #FFFFFF;
  --chrome-raise: #F2F3F5;
  --chrome-text: #1E1E1E;
  --chrome-muted: #5C6270;
  --chrome-line: #E3E6EB;
  --shadow: rgba(0, 0, 0, 0.10);   /* delivered verbatim: the 10% black in the identity drop */
  --term-bg: #1B1E24;
  --term-raise: #262A31;
  --term-text: #E8E6E2;
  --term-muted: #A6A29A;
  --term-line: #303540;
  --signal: #3ECF8E;

  /* v1 aliases retained for existing pages and inline declarations */
  --paper: var(--bg);
  --panel: var(--bg-raise);
  --panel-deep: var(--bg-deep);
  --brand: var(--accent);
  --brand-ink: var(--accent-ink);
  --brand-wash: var(--accent-wash);
  --signal-text: var(--accent-ink);

  /* type */
  --font-display: "Chivo", "Chivo Fallback", "Trebuchet MS", sans-serif;
  --font-body: "Source Sans 3", "Source Sans 3 Fallback", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "JetBrains Mono Fallback", "Consolas", monospace;

  /* space (scale: 4 8 12 16 24 32 48 64 96) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* radius */
  --r-ctl: 6px; --r-card: 10px; --r-frame: 12px;

  /* motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;

  /* layout */
  --max: 1200px;
  --readcol: 760px;
  --railcol: 260px;
  --header-h: 60px;
  --panel-gap: var(--s3);
  --panel-pad: var(--s5);
  --panel-media-min: 170px;
}

html[data-theme="dark"] {
  --bg: #1E1E1E;
  --bg-raise: #262629;
  --bg-deep: #2E2F33;
  --ink: #FFFFFF; /* headings */
  --text: #DCDDE0; /* body */
  --muted: #9197A1; /* secondary */
  --line: #34353A;
  --field-line: #8A909C; /* form-control boundary: 3:1+ on --bg (SC 1.4.11) */
  --line-soft: #2B2C30;
  --accent: #B578FF; /* brand purple LIFTED so it also clears AA on raised dark surfaces. links, buttons, active states */
  --accent-ink: #C799FF; /* hover/pressed */
  --accent-wash: #2A1F3A; /* tinted wells, tag fills */
  --accent-contrast: #1E1E1E; /* delivered verbatim */
  --ok: #3ECF8E;
  --danger: #E5695C;
  --danger-wash: #33201D;
  --note-bg: #2A2416;
  --note-line: #4A3D1E;
  --note-text: #E8C77D;
  --selection: #3C2A57;
  --chrome: #232326;
  --chrome-raise: #2C2C30;
  --chrome-text: #FFFFFF;
  --chrome-muted: #9EA4AF;
  --chrome-line: #3A3B40;
  --shadow: rgba(0, 0, 0, 0.45);   /* DERIVED: 10% is invisible on a dark ground */
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #1E1E1E;
    --bg-raise: #262629;
    --bg-deep: #2E2F33;
    --ink: #FFFFFF;
    --text: #DCDDE0;
    --muted: #9197A1;
    --line: #34353A;
    --field-line: #8A909C;
    --line-soft: #2B2C30;
    --accent: #B578FF;
    --accent-ink: #C799FF;
    --accent-wash: #2A1F3A;
    --accent-contrast: #1E1E1E;
    --ok: #3ECF8E;
    --danger: #E5695C;
    --danger-wash: #33201D;
    --note-bg: #2A2416;
    --note-line: #4A3D1E;
    --note-text: #E8C77D;
    --selection: #3C2A57;
    --chrome: #232326;
    --chrome-raise: #2C2C30;
    --chrome-text: #FFFFFF;
    --chrome-muted: #9EA4AF;
    --chrome-line: #3A3B40;
    --shadow: rgba(0, 0, 0, 0.45);
  }
}

/* The sticky header is 60px through 899px and 106px from 900px, where the utility row
   shows. --header-h is the one source for that height: the header, menu panel, sticky
   rails and the root scroll-padding all read it (WCAG 2.2 SC 2.4.11). */
@media (min-width: 900px) {
  :root { --header-h: 106px; }
}
