/* =====================================================================
   AMS base: design tokens, reset, typography.
   Every color/spacing used elsewhere must come from these variables.
   ===================================================================== */
:root {
  color-scheme: light;
  --c-bg: #f6f7fb;
  --c-surface: #ffffff;
  --c-surface-2: #f1f3f8;
  --c-border: #dde1ea;
  --c-text: #1d2433;
  --c-text-muted: #5d667a;
  --c-primary: #2f5bea;
  --c-primary-hover: #2449c4;
  --c-primary-soft: #e6ecfd;
  --c-on-primary: #ffffff;
  --c-success: #1c8a4d;
  --c-success-soft: #e3f4ea;
  --c-warning: #a86400;
  --c-warning-soft: #fdf1dc;
  --c-danger: #c8323a;
  --c-danger-soft: #fbe5e6;
  --c-info: #1f6f9f;
  --c-info-soft: #e1f0f8;
  --c-overlay: rgba(15, 20, 30, 0.45);

  --font-sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.625rem;
  --fs-2xl: 2.25rem;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.10);

  --header-h: 56px;
  --sidebar-w: 240px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-bg: #11151d;
    --c-surface: #181d27;
    --c-surface-2: #202634;
    --c-border: #2c3445;
    --c-text: #e6e9f0;
    --c-text-muted: #9aa3b5;
    --c-primary: #6d8cff;
    --c-primary-hover: #8aa3ff;
    --c-primary-soft: #232e52;
    --c-on-primary: #0d1220;
    --c-success: #4cc483;
    --c-success-soft: #18352a;
    --c-warning: #f0b252;
    --c-warning-soft: #3a2e17;
    --c-danger: #f07178;
    --c-danger-soft: #3d1f24;
    --c-info: #5bb6e8;
    --c-info-soft: #17303f;
    --c-overlay: rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #11151d;
  --c-surface: #181d27;
  --c-surface-2: #202634;
  --c-border: #2c3445;
  --c-text: #e6e9f0;
  --c-text-muted: #9aa3b5;
  --c-primary: #6d8cff;
  --c-primary-hover: #8aa3ff;
  --c-primary-soft: #232e52;
  --c-on-primary: #0d1220;
  --c-success: #4cc483;
  --c-success-soft: #18352a;
  --c-warning: #f0b252;
  --c-warning-soft: #3a2e17;
  --c-danger: #f07178;
  --c-danger-soft: #3d1f24;
  --c-info: #5bb6e8;
  --c-info-soft: #17303f;
  --c-overlay: rgba(0, 0, 0, 0.6);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.25; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; display: block; }
code, pre { font-family: var(--font-mono); font-size: var(--fs-sm); }

:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.text-muted { color: var(--c-text-muted); }
.text-sm { font-size: var(--fs-sm); }
.text-danger { color: var(--c-danger); }
.mb-4 { margin-bottom: var(--sp-4); }
.pre-line { white-space: pre-line; }
