/* ==========================================================================
   Instrument — design tokens (plain CSS, no framework)

   Every value is a CSS custom property. Use them directly
   (`color: var(--foreground)`) or map them into whatever you build with —
   see adapters/ for Tailwind. The reasons behind each value are in README.md.

   Theming:
     - Light is the default.
     - Dark follows the OS automatically.
     - <html data-theme="light"> or <html data-theme="dark"> forces one.
       adapters/theme.js manages that attribute and the user's stored choice.
   ========================================================================== */

:root {
  /* ---- Type ------------------------------------------------------------ */
  /* One family for everything, including numbers and IDs. */
  --font-sans: InterVariable, Inter, ui-sans-serif, system-ui, sans-serif;

  --text-2xs: 0.625rem;  /* 10px  counters only */
  --text-xs: 0.75rem;    /* 12px  labels, badges, metadata */
  --text-sm: 0.875rem;   /* 14px  body, rows, controls — the product's default */
  --text-base: 1rem;     /* 16px  titles; inputs on touch screens */
  --text-2xl: 1.5rem;    /* 24px  the one big number on a stat */

  --leading-xs: 1rem;
  --leading-sm: 1.25rem;
  --leading-snug: 1.375;
  --leading-relaxed: 1.625;

  --weight-regular: 400;
  --weight-medium: 500;   /* anything that leads */
  --weight-semibold: 600; /* stat numbers, display headlines only */

  --tracking-body: -0.01em;    /* display/marketing body */
  --tracking-display: -0.025em; /* display headlines */

  /* ---- Space (4px grid) ------------------------------------------------ */
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* ---- Sizes ----------------------------------------------------------- */
  --control-xs: 24px;
  --control-sm: 28px;
  --control-md: 32px;   /* default height for buttons, inputs, selects */
  --control-lg: 36px;
  --bar-pane: 40px;     /* pane/list header */
  --bar-filter: 48px;   /* chip row */
  --bar-app: 56px;      /* sidebar head / mobile top row */
  --sidebar-width: 256px;
  --icon-sm: 14px;      /* nav, small buttons */
  --icon-md: 16px;      /* buttons, menus */
  --icon-xs: 12px;      /* inside badges */
  --hairline: 0.5px;

  /* ---- Radius (one base, everything a ratio of it) --------------------- */
  --radius: 10px;
  --radius-sm: calc(var(--radius) * 0.6);   /*  6px */
  --radius-md: calc(var(--radius) * 0.8);   /*  8px  menu items, tooltips */
  --radius-lg: var(--radius);               /* 10px  controls, rows, menus */
  --radius-nav: 12px;                       /*       sidebar items */
  --radius-xl: calc(var(--radius) * 1.4);   /* 14px  cards, dialogs, panel */
  --radius-full: 9999px;                    /*       badges, chips, counters */

  /* ---- Motion ---------------------------------------------------------- */
  /* Entrances: leaves hard, settles long. */
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  /* Drawers, sheets, panels: strong ease-out, no bounce. */
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --duration-instant: 100ms; /* popovers, menus, dialogs */
  --duration-fast: 200ms;    /* indicators, tab panels, sub-page */
  --duration-base: 300ms;    /* page/section change */
  --duration-hero: 1000ms;   /* marketing entrance only */
  --rise-sm: 4px;
  --rise-md: 8px;
  --rise-lg: 12px;

  /* ---- Layering -------------------------------------------------------- */
  --z-overlay: 50;

  /* ======================================================================
     Light colour — chroma-zero neutrals, near-black primary
     ====================================================================== */
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  /* Primary as ink: split from the fill if the primary ever becomes a
     colour that isn't legible as text. */
  --primary-ink: var(--primary);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);             /* passive surfaces */
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.955 0 0);           /* the row you are on — deeper than muted */
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --sidebar: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.955 0 0);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --deliberate-dark: oklch(0.205 0 0);  /* floating toolbars, terminals: dark in both themes */

  /* Status: a 15% tint of the hue as fill, a deep shade as ink. */
  --status-success-fill: oklch(0.696 0.17 162.48 / 0.15);
  --status-success-ink: oklch(0.508 0.118 165.612);
  --status-warning-fill: oklch(0.769 0.188 70.08 / 0.2);
  --status-warning-ink: oklch(0.473 0.137 46.201);
  --status-danger-fill: oklch(0.645 0.246 16.439 / 0.15);
  --status-danger-ink: oklch(0.514 0.222 16.935);
  --status-info-fill: oklch(0.685 0.169 237.323 / 0.15);
  --status-info-ink: oklch(0.5 0.134 242.749);
  --status-neutral-fill: var(--muted);
  --status-neutral-ink: var(--muted-foreground);
  /* Warning banner */
  --banner-warning-bg: oklch(0.987 0.022 95.277);
  --banner-warning-border: oklch(0.879 0.169 91.605);
  --banner-warning-ink: oklch(0.414 0.112 45.904);

  /* ---- Depth (light) --------------------------------------------------- */
  /* Each recipe: a 0.5px spread ring (the edge — drawn as shadow so it hugs
     the radius and never shifts layout), a 1px contact shadow, and a soft
     ambient lift. Warm near-black tone: grey shadow on white reads as dirt,
     warm reads as light. */
  --shadow-tone: 61 59 53;
  --depth-raised:
    0 0 0 0.5px rgb(var(--shadow-tone) / 0.1), 0 1px 1px 0 rgb(0 0 0 / 0.1),
    0 1px 5px 0 rgb(var(--shadow-tone) / 0.05);
  --depth-raised-hover:
    0 0 0 0.5px rgb(var(--shadow-tone) / 0.1), 0 1px 1px 0 rgb(0 0 0 / 0.1),
    0 2px 4px 0 rgb(var(--shadow-tone) / 0.07), 0 4px 10px 0 rgb(var(--shadow-tone) / 0.05);
  /* Solid fills: cast only — no ring, no white top highlight. */
  --depth-raised-fill:
    0 1px 1px 0 rgb(0 0 0 / 0.12), 0 2px 6px 0 rgb(var(--shadow-tone) / 0.14);
  --depth-raised-fill-hover:
    0 1px 1px 0 rgb(0 0 0 / 0.12), 0 4px 10px 0 rgb(var(--shadow-tone) / 0.16);
  --depth-floating:
    0 0 0 0.5px rgb(var(--shadow-tone) / 0.1), 0 1px 1px 0 rgb(0 0 0 / 0.06),
    0 4px 8px -2px rgb(var(--shadow-tone) / 0.08), 0 12px 24px -6px rgb(var(--shadow-tone) / 0.1);
  /* The main content panel: a doubling ladder of faint layers. */
  --depth-panel:
    0 0 0 0.5px rgb(var(--shadow-tone) / 0.1),
    0 1px 1px -0.5px rgb(var(--shadow-tone) / 0.03),
    0 2px 2px -1px rgb(var(--shadow-tone) / 0.03),
    0 4px 4px -2px rgb(var(--shadow-tone) / 0.03),
    0 8px 8px -4px rgb(var(--shadow-tone) / 0.025),
    0 16px 16px -8px rgb(var(--shadow-tone) / 0.02);
  /* Marketing showcase frames only. */
  --depth-showcase:
    0 0 0 1px rgb(0 0 0 / 0.05), 0 1px 1px -0.5px rgb(0 0 0 / 0.05),
    0 3px 3px -1.5px rgb(0 0 0 / 0.05), 0 6px 6px -3px rgb(0 0 0 / 0.05),
    0 12px 12px -6px rgb(0 0 0 / 0.05), 0 24px 24px -12px rgb(0 0 0 / 0.05),
    0 48px 48px -24px rgb(0 0 0 / 0.05);

  /* ---- Component tokens -------------------------------------------------
     The few places light and dark differ in kind, not just in value, so that
     components.css never needs a dark selector of its own. */
  --control-bg: var(--background);          /* outline buttons */
  --control-bg-hover: var(--muted);
  --control-border: var(--border);
  --field-bg: transparent;                  /* inputs, textareas */
  --field-bg-disabled: color-mix(in oklch, var(--input) 50%, transparent);
  --ghost-hover: var(--muted);
  --destructive-tint: color-mix(in oklch, var(--destructive) 10%, transparent);
  --destructive-tint-hover: color-mix(in oklch, var(--destructive) 20%, transparent);
  --segment-active-bg: var(--background);   /* active segment in a tab track */
  --segment-active-border: transparent;
  --focus-ring: color-mix(in oklch, var(--ring) 50%, transparent);
  --invalid-ring: color-mix(in oklch, var(--destructive) 20%, transparent);

  color-scheme: light;
}

/* ==========================================================================
   Dark colour — every neutral carries a whisper of blue (chroma ~0.005, hue
   ~260). Elevation is lightness: background 0.16 → card 0.196 → popover 0.23.
   Hairlines are low-alpha white. Applied when the OS prefers dark (unless
   forced light) or when forced dark. The two blocks below are identical.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: oklch(0.16 0.005 260);
    --foreground: oklch(0.97 0.002 250);
    --card: oklch(0.196 0.005 260);
    --card-foreground: oklch(0.97 0.002 250);
    --popover: oklch(0.23 0.006 262);
    --popover-foreground: oklch(0.97 0.002 250);
    --primary: oklch(0.94 0.003 250);
    --primary-foreground: oklch(0.18 0.004 260);
    --secondary: oklch(0.245 0.005 260);
    --secondary-foreground: oklch(0.97 0.002 250);
    --muted: oklch(0.235 0.005 260);
    --muted-foreground: oklch(0.68 0.012 252);
    --accent: oklch(0.275 0.006 260);
    --accent-foreground: oklch(0.97 0.002 250);
    --destructive: oklch(0.65 0.19 25);
    --destructive-foreground: oklch(0.98 0 0);
    --border: oklch(1 0 0 / 9%);
    --input: oklch(1 0 0 / 13%);
    --ring: oklch(0.58 0.02 260);
    --sidebar: oklch(0.16 0.005 260);
    --sidebar-accent: oklch(0.275 0.006 260);
    --chart-1: oklch(0.3 0.006 260);
    --chart-2: oklch(0.45 0.008 258);
    --chart-3: oklch(0.58 0.01 255);
    --chart-4: oklch(0.72 0.012 252);
    --chart-5: oklch(0.86 0.008 250);
    --status-warning-fill: oklch(0.769 0.188 70.08 / 0.15);
    --status-success-ink: oklch(0.845 0.143 164.978);
    --status-warning-ink: oklch(0.879 0.169 91.605);
    --status-danger-ink: oklch(0.81 0.117 11.638);
    --status-info-ink: oklch(0.828 0.111 230.318);
    --banner-warning-bg: oklch(0.769 0.188 70.08 / 0.1);
    --banner-warning-border: oklch(0.769 0.188 70.08 / 0.25);
    --banner-warning-ink: oklch(0.924 0.12 95.746);
    --depth-raised: 0 0 0 0.5px rgb(255 255 255 / 0.06), 0 1px 1px 0 rgb(0 0 0 / 0.4);
    --depth-raised-hover: 0 0 0 0.5px rgb(255 255 255 / 0.1), 0 1px 1px 0 rgb(0 0 0 / 0.4);
    --depth-raised-fill: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --depth-raised-fill-hover: 0 1px 3px 0 rgb(0 0 0 / 0.5);
    --depth-floating:
      0 0 0 0.5px rgb(255 255 255 / 0.08), 0 4px 8px -2px rgb(0 0 0 / 0.5),
      0 12px 24px -6px rgb(0 0 0 / 0.6);
    --depth-panel:
      0 0 0 0.5px rgb(255 255 255 / 0.07), 0 2px 4px -1px rgb(0 0 0 / 0.3),
      0 8px 16px -4px rgb(0 0 0 / 0.35);
    --depth-showcase:
      0 0 0 1px rgb(255 255 255 / 0.09), 0 8px 16px -4px rgb(0 0 0 / 0.5),
      0 24px 48px -12px rgb(0 0 0 / 0.6);
    /* component tokens */
    --control-bg: oklch(1 0 0 / 4%);
    --control-bg-hover: oklch(1 0 0 / 6.5%);
    --control-border: var(--input);
    --field-bg: oklch(1 0 0 / 4%);
    --field-bg-disabled: oklch(1 0 0 / 10%);
    --ghost-hover: color-mix(in oklch, var(--muted) 50%, transparent);
    --destructive-tint: color-mix(in oklch, var(--destructive) 20%, transparent);
    --destructive-tint-hover: color-mix(in oklch, var(--destructive) 30%, transparent);
    --segment-active-bg: oklch(1 0 0 / 4%);
    --segment-active-border: var(--input);
    --invalid-ring: color-mix(in oklch, var(--destructive) 40%, transparent);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --background: oklch(0.16 0.005 260);
  --foreground: oklch(0.97 0.002 250);
  --card: oklch(0.196 0.005 260);
  --card-foreground: oklch(0.97 0.002 250);
  --popover: oklch(0.23 0.006 262);
  --popover-foreground: oklch(0.97 0.002 250);
  --primary: oklch(0.94 0.003 250);
  --primary-foreground: oklch(0.18 0.004 260);
  --secondary: oklch(0.245 0.005 260);
  --secondary-foreground: oklch(0.97 0.002 250);
  --muted: oklch(0.235 0.005 260);
  --muted-foreground: oklch(0.68 0.012 252);
  --accent: oklch(0.275 0.006 260);
  --accent-foreground: oklch(0.97 0.002 250);
  --destructive: oklch(0.65 0.19 25);
  --destructive-foreground: oklch(0.98 0 0);
  --border: oklch(1 0 0 / 9%);
  --input: oklch(1 0 0 / 13%);
  --ring: oklch(0.58 0.02 260);
  --sidebar: oklch(0.16 0.005 260);
  --sidebar-accent: oklch(0.275 0.006 260);
  --chart-1: oklch(0.3 0.006 260);
  --chart-2: oklch(0.45 0.008 258);
  --chart-3: oklch(0.58 0.01 255);
  --chart-4: oklch(0.72 0.012 252);
  --chart-5: oklch(0.86 0.008 250);
  --status-warning-fill: oklch(0.769 0.188 70.08 / 0.15);
  --status-success-ink: oklch(0.845 0.143 164.978);
  --status-warning-ink: oklch(0.879 0.169 91.605);
  --status-danger-ink: oklch(0.81 0.117 11.638);
  --status-info-ink: oklch(0.828 0.111 230.318);
  --banner-warning-bg: oklch(0.769 0.188 70.08 / 0.1);
  --banner-warning-border: oklch(0.769 0.188 70.08 / 0.25);
  --banner-warning-ink: oklch(0.924 0.12 95.746);
  --depth-raised: 0 0 0 0.5px rgb(255 255 255 / 0.06), 0 1px 1px 0 rgb(0 0 0 / 0.4);
  --depth-raised-hover: 0 0 0 0.5px rgb(255 255 255 / 0.1), 0 1px 1px 0 rgb(0 0 0 / 0.4);
  --depth-raised-fill: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --depth-raised-fill-hover: 0 1px 3px 0 rgb(0 0 0 / 0.5);
  --depth-floating:
    0 0 0 0.5px rgb(255 255 255 / 0.08), 0 4px 8px -2px rgb(0 0 0 / 0.5),
    0 12px 24px -6px rgb(0 0 0 / 0.6);
  --depth-panel:
    0 0 0 0.5px rgb(255 255 255 / 0.07), 0 2px 4px -1px rgb(0 0 0 / 0.3),
    0 8px 16px -4px rgb(0 0 0 / 0.35);
  --depth-showcase:
    0 0 0 1px rgb(255 255 255 / 0.09), 0 8px 16px -4px rgb(0 0 0 / 0.5),
    0 24px 48px -12px rgb(0 0 0 / 0.6);
  /* component tokens */
  --control-bg: oklch(1 0 0 / 4%);
  --control-bg-hover: oklch(1 0 0 / 6.5%);
  --control-border: var(--input);
  --field-bg: oklch(1 0 0 / 4%);
  --field-bg-disabled: oklch(1 0 0 / 10%);
  --ghost-hover: color-mix(in oklch, var(--muted) 50%, transparent);
  --destructive-tint: color-mix(in oklch, var(--destructive) 20%, transparent);
  --destructive-tint-hover: color-mix(in oklch, var(--destructive) 30%, transparent);
  --segment-active-bg: oklch(1 0 0 / 4%);
  --segment-active-border: var(--input);
  --invalid-ring: color-mix(in oklch, var(--destructive) 40%, transparent);
  color-scheme: dark;
}

/* ==========================================================================
   Optional base — the few global rules the language relies on.
   ========================================================================== */
html {
  font-family: var(--font-sans);
  font-feature-settings: "liga" 1, "calt" 1;
  font-optical-sizing: auto;
  background: var(--background);
  color: var(--foreground);
}
*, ::before, ::after {
  box-sizing: border-box;
  border-color: var(--border);
}
body { margin: 0; }
/* No scrollbars inside the app's own panes; the document keeps its own. */
*:not(html):not(body) { scrollbar-width: none; }
*:not(html):not(body)::-webkit-scrollbar { width: 0; height: 0; }
