/* Copybook.page-inspired Editorial Precision Design Tokens (Single Source of Truth) */
:root {
  color-scheme: light dark;

  /* Surfaces & Ink (Light default) */
  --bg: #fafaf9;
  --bg-2: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --well: #f6f6f4;
  --hover: rgba(17, 17, 19, 0.043);
  --pressed: rgba(17, 17, 19, 0.09);

  --ink: #111113;
  --ink-2: #5f5f68;
  --ink-3: #83838d;
  --hairline: #e2e2de;
  --line-3: #c8c8c2;

  /* Single Editorial Vermilion Accent */
  --accent: #b8381b;
  --accent-text: #b8381b;
  --accent-soft: #fdede9;
  --ring: rgba(184, 56, 27, 0.24);
  --inv: #111113;
  --on-inv: #ffffff;

  /* Restrained Semantic Status */
  --ok: #1b6b3a;
  --ok-soft: #ebf7ef;
  --warn: #9a5b0c;
  --warn-soft: #fdf5e6;
  --danger: #b8381b;
  --danger-soft: #fdede9;

  /* Code / Diagnostic Console Surface */
  --code-bg: #111113;
  --code-line: #27272c;
  --code-text: #ececee;
  --code-dim: #9c9ca6;

  /* Elevation & Overlay */
  --sh-1: none;
  --sh-2: none;
  --sh-3: 0 4px 12px rgba(17, 17, 19, 0.08), 0 24px 56px -16px rgba(17, 17, 19, 0.28);
  --scrim: rgba(17, 17, 19, 0.32);

  /* Radii & Spacing */
  --r-1: 6px;
  --r-2: 8px;
  --r-3: 10px;
  --r-4: 12px;
  --r-pill: 999px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  /* Layout Rhythm */
  --side-w: 256px;
  --bar-h: 56px;
  --gutter: 40px;
  --container: 1200px;

  /* Typography */
  --font-sans: "Geist", "Inter", "PingFang SC", "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --t1: 0.8125rem;
  --t2: 0.9375rem;
  --t3: 1.0625rem;
  --t4: 1.375rem;
  --t5: 1.75rem;
  --t6: 2.25rem;

  /* Taut Motion */
  --d1: 120ms;
  --d2: 200ms;
  --e-out: cubic-bezier(0.16, 1, 0.3, 1);
  accent-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0a0b;
    --bg-2: #0d0d0f;
    --surface: #131315;
    --surface-2: #18181b;
    --well: #0f0f11;
    --hover: rgba(255, 255, 255, 0.045);
    --pressed: rgba(255, 255, 255, 0.11);
    --ink: #ededef;
    --ink-2: #9a9aa3;
    --ink-3: #71717a;
    --hairline: #26262b;
    --line-3: #3b3b41;
    --accent: #b8381b;
    --accent-text: #ff9479;
    --accent-soft: #2b1510;
    --ring: rgba(184, 56, 27, 0.4);
    --inv: #ededef;
    --on-inv: #0a0a0b;
    --ok: #5cd68d;
    --ok-soft: #102618;
    --warn: #f0b254;
    --warn-soft: #291e0c;
    --danger: #ff9479;
    --danger-soft: #2b1510;
    --code-bg: #141418;
    --code-line: #26262b;
    --code-text: #ececee;
    --code-dim: #8a8a96;
    --sh-3: 0 4px 12px rgba(0, 0, 0, 0.5), 0 28px 64px -16px rgba(0, 0, 0, 0.85);
    --scrim: rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-2: #0d0d0f;
  --surface: #131315;
  --surface-2: #18181b;
  --well: #0f0f11;
  --hover: rgba(255, 255, 255, 0.045);
  --pressed: rgba(255, 255, 255, 0.11);
  --ink: #ededef;
  --ink-2: #9a9aa3;
  --ink-3: #71717a;
  --hairline: #26262b;
  --line-3: #3b3b41;
  --accent: #b8381b;
  --accent-text: #ff9479;
  --accent-soft: #2b1510;
  --ring: rgba(184, 56, 27, 0.4);
  --inv: #ededef;
  --on-inv: #0a0a0b;
  --ok: #5cd68d;
  --ok-soft: #102618;
  --warn: #f0b254;
  --warn-soft: #291e0c;
  --danger: #ff9479;
  --danger-soft: #2b1510;
  --code-bg: #141418;
  --code-line: #26262b;
  --code-text: #ececee;
  --code-dim: #8a8a96;
  --sh-3: 0 4px 12px rgba(0, 0, 0, 0.5), 0 28px 64px -16px rgba(0, 0, 0, 0.85);
  --scrim: rgba(0, 0, 0, 0.55);
}

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

@media (max-width: 768px) {
  :root {
    --gutter: 16px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Native <dialog> modal scroll containment (modern-web-guidance: dialog) */
dialog:modal {
  overscroll-behavior: contain;
  border: 1px solid var(--hairline);
  border-radius: var(--r-4);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-3);
  padding: var(--s5);
  max-width: min(520px, calc(100vw - 32px));
  width: 100%;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--scrim);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
