/*
 * Cairn design tokens.
 *
 * Light values live on :root. The dark values apply when the user picked dark
 * (html[data-theme="dark"]) or when the system prefers dark and the user did
 * not pick light (html without data-theme="light"). The two dark blocks at the
 * bottom must stay identical.
 *
 * Reading the color families
 *   --accent        brand fill (primary buttons, checked controls) and accent-colored text / icons
 *   --accent-hover  the fill while hovered or pressed
 *   --accent-soft   tinted background for selected / highlighted areas (pair with --accent or --text)
 *   --accent-text   text and icons placed ON an --accent fill
 *   --success / --warning / --danger / --info        text, icons and small fills
 *   --*-soft        tinted background for the matching status color
 * Every text color meets WCAG AA (4.5:1) on --bg, --surface, --surface-2,
 * --surface-3 and --accent-soft (selected rows); each status color also meets
 * it on its own soft background. --border-strong outlines the controls (inputs,
 * checkboxes, the switch track) and --focus draws the focus ring: both keep
 * 3:1 against --bg, --surface and --surface-2. tests/web/kit.test.js checks
 * these numbers, so adjust a pair together.
 */

:root {
  color-scheme: light;

  /* Surfaces and lines */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eff2f5;
  --surface-3: #e2e7ed;
  --border: #dbe1e8;
  --border-strong: #7f8d9d;

  /* Text */
  --text: #16202b;
  --text-muted: #465463;
  --text-faint: #5b6979;

  /* Accent: deep teal-green */
  --accent: #0b6b5d;
  --accent-hover: #09594d;
  --accent-soft: #dcf1ed;
  --accent-text: #ffffff;

  /* Status */
  --success: #17753f;
  --success-soft: #dff3e6;
  --warning: #8f5400;
  --warning-soft: #fbefd3;
  --danger: #b93227;
  --danger-hover: #9f2a20;
  --danger-soft: #fbe6e3;
  --danger-text: #ffffff;
  --info: #215cae;
  --info-soft: #e1ecfa;

  --focus: #14907f;
  --overlay: rgba(16, 24, 32, 0.48);
  --selection: #c5e8e1;

  /*
   * Charts: seven categorical hues in a fixed order plus a neutral (slot 8,
   * also the color of a folded "Other"). Each is at least 3:1 against
   * --surface, and neighbours in the order stay apart for normal and
   * color-blind vision (OKLab distance >= 15, >= 6 simulated). The dark theme
   * has its own, darker steps of the same hues: do not derive one from the other.
   */
  --chart-1: #0f8a7a;
  --chart-2: #3b76d6;
  --chart-3: #c9821a;
  --chart-4: #8460d6;
  --chart-5: #d6567a;
  --chart-6: #5a9e3a;
  --chart-7: #2a9cbc;
  --chart-8: #505c6a;

  /* Spacing: 4px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.06), 0 1px 1px rgba(16, 24, 32, 0.04);
  --shadow-md: 0 4px 14px rgba(16, 24, 32, 0.09), 0 1px 3px rgba(16, 24, 32, 0.06);
  --shadow-lg: 0 18px 44px rgba(16, 24, 32, 0.18), 0 4px 12px rgba(16, 24, 32, 0.08);

  /* Layout */
  --sidebar-width: 232px;
  --topbar-height: 52px;
  --control-height: 32px;
  --control-height-sm: 26px;

  /* Layers */
  --z-dropdown: 1000;
  --z-drawer: 1100;
  --z-modal: 1200;
  --z-toast: 1300;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --duration-fast: 120ms;
  --duration: 180ms;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0e141a;
    --surface: #151c24;
    --surface-2: #1b242e;
    --surface-3: #26323e;
    --border: #2a3643;
    --border-strong: #5f7182;

    --text: #e6ebf0;
    --text-muted: #a5b1be;
    --text-faint: #8d9baa;

    --accent: #3fbfab;
    --accent-hover: #5fd0bd;
    --accent-soft: #12332f;
    --accent-text: #04231f;

    --success: #4cc27a;
    --success-soft: #12301f;
    --warning: #e0a63a;
    --warning-soft: #33270e;
    --danger: #f0756b;
    --danger-hover: #f6958c;
    --danger-soft: #3a1917;
    --danger-text: #2b0906;
    --info: #6ea8f2;
    --info-soft: #14263f;

    --focus: #5fd0bd;
    --overlay: rgba(0, 0, 0, 0.62);
    --selection: #1d5a52;

    --chart-1: #1ca995;
    --chart-2: #437cc2;
    --chart-3: #c28908;
    --chart-4: #9e80e4;
    --chart-5: #c25878;
    --chart-6: #6ca84f;
    --chart-7: #1e95b1;
    --chart-8: #aab6c4;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.35);
  }
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e141a;
  --surface: #151c24;
  --surface-2: #1b242e;
  --surface-3: #26323e;
  --border: #2a3643;
  --border-strong: #5f7182;

  --text: #e6ebf0;
  --text-muted: #a5b1be;
  --text-faint: #8d9baa;

  --accent: #3fbfab;
  --accent-hover: #5fd0bd;
  --accent-soft: #12332f;
  --accent-text: #04231f;

  --success: #4cc27a;
  --success-soft: #12301f;
  --warning: #e0a63a;
  --warning-soft: #33270e;
  --danger: #f0756b;
  --danger-hover: #f6958c;
  --danger-soft: #3a1917;
  --danger-text: #2b0906;
  --info: #6ea8f2;
  --info-soft: #14263f;

  --focus: #5fd0bd;
  --overlay: rgba(0, 0, 0, 0.62);
  --selection: #1d5a52;

  --chart-1: #1ca995;
  --chart-2: #437cc2;
  --chart-3: #c28908;
  --chart-4: #9e80e4;
  --chart-5: #c25878;
  --chart-6: #6ca84f;
  --chart-7: #1e95b1;
  --chart-8: #aab6c4;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.35);
}
