/*
 * studio-kit tokens — the CANONICAL shared --wb-* token core (DESIGN-SYSTEM §1/§2).
 * This repo is the origin; consumers vendor this block verbatim between
 * KIT-TOKENS-BEGIN/END markers in their own styles.css and drift-check it with
 * scripts/kit-drift.sh (extraction rule: the two `:root { ... }` blocks below,
 * i.e. dark core + light theme, must match byte-for-byte).
 *
 * ACCENT-OVERRIDE PATTERN (per-studio, drift-exempt): a studio NEVER edits this
 * block. It appends its own `:root { ... }` / `:root[data-theme="light"] { ... }`
 * blocks AFTER the vendored copy, overriding ONLY the accent slice —
 * --wb-accent, --wb-accent-2, --wb-accent-strong, --wb-on-accent, --wb-active,
 * --wb-active-border, --wb-border-accent, --wb-border-btn, --wb-focus, and the
 * grid selection/header-active derivatives. Neutrals, status colors, type and
 * spacing arrive verbatim from here (workbook green ~160°, whiteboard blue,
 * math violet ~262°, book sepia — values live in each consumer).
 *
 * COARSE ACCENT CHANNEL (--sk-accent — consumer-written, kit-read, v0.13.0):
 * the four hue-carrying signal tokens read `var(--sk-accent, <default>)`, so a
 * consumer that wants ONE knob sets `--sk-accent` (inside each theme block if
 * the themes need different values) and --wb-accent, --wb-accent-2,
 * --wb-active-border and --wb-focus follow — accent text, sparklines, bar
 * fills, active borders and focus rings re-tint with no fork and no full slice
 * override. Unset, every default below is byte-identical to the pre-channel
 * value. The kit NEVER defines --sk-accent (a kit-side definition would stop
 * the defaults from ever binding) and kit chrome still reads only --wb-*
 * tokens, so a per-token slice override always beats the channel; both are
 * held by accent.test.ts. --wb-accent-strong + --wb-on-accent (a filled
 * control and the text on it) and the tinted surfaces/borders stay per-token
 * on purpose: one flat channel color cannot be both a mark color and a
 * readable fill behind text.
 */
:root {
  color-scheme: dark;
  --wb-bg: #080d0c;
  --wb-surface: #0b1310;
  --wb-surface-sunken: #0a110e;
  --wb-raised: #0a1512;
  --wb-active: #13241d;
  --wb-border: #1c2a25;
  --wb-border-2: #24332c;
  --wb-border-accent: #24463a;
  --wb-border-btn: #2c4b3e;
  --wb-text: #e9f0ec;
  --wb-text-2: #cfe9dd;
  --wb-text-muted: #8a998f;
  --wb-text-subtle: #70837a;
  --wb-accent: var(--sk-accent, #a7f2ce);
  --wb-accent-2: var(--sk-accent, #7fe9bb);
  --wb-accent-strong: #1c7a54;
  --wb-on-accent: #eafff5;
  --wb-active-border: var(--sk-accent, #5fe3ab);
  --wb-danger: #e0685f;
  --wb-ok: #4bd493;
  --wb-warning: #d8b24a;
  --wb-focus: var(--sk-accent, #68e0af);
  --wb-backdrop: rgb(0 0 0 / 40%);
  --wb-shadow-raised: 0 8px 24px rgb(0 0 0 / 35%);
  --wb-shadow-overlay: 0 12px 32px rgb(0 0 0 / 30%);
  --wb-shadow-modal: 0 18px 48px rgb(0 0 0 / 35%);
  --wb-shadow-focus: 0 0 0 1px var(--wb-active-border);

  --wb-grid-bg: #0a1210;
  --wb-grid-line: #16221d;
  --wb-grid-text: #dfeee8;
  --wb-grid-error: #f0a9a0;
  --wb-grid-header-bg: #0d1713;
  --wb-grid-header-line: #1d2b25;
  --wb-grid-header-text: #75857e;
  --wb-grid-header-active-bg: #15281f;
  --wb-grid-header-active-text: #8ff0c4;
  --wb-grid-selection: rgb(104 224 175 / 12%);
  --wb-grid-active-border: #5fe3ab;

  /* Spacing scale (DESIGN-SYSTEM §1.3) — the codified chrome density steps, and
     the ONLY lengths a padding, margin or gap may take. Named by value, so there
     is nothing to memorise. kit.css states its own spacing as literals on
     purpose: those bytes are what a consumer's kit-drift.sh compares and what a
     designer reads in a stylesheet, and density.test.ts reads the scale from HERE
     and fails on any kit padding/margin/gap that lands off it. The tokens are for
     STUDIO-OWNED surface CSS, which no drift check covers — a studio building its
     own canvas chrome writes var(--wb-space-8), never 9px. */
  --wb-space-2: 2px;
  --wb-space-4: 4px;
  --wb-space-6: 6px;
  --wb-space-8: 8px;
  --wb-space-10: 10px;
  --wb-space-12: 12px;
  --wb-space-16: 16px;
  --wb-space-24: 24px;
  --wb-space-32: 32px;

  /* Typography is a closed, shared chrome scale. Product content may establish
     its own editorial hierarchy; kit controls and states use only this family,
     size, weight, leading and tracking vocabulary. */
  --wb-font-sans:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --wb-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --wb-font-size-10: 10px;
  --wb-font-size-11: 11px;
  --wb-font-size-12: 12px;
  --wb-font-size-13: 13px;
  --wb-font-size-14: 14px;
  --wb-font-size-16: 16px;
  --wb-font-size-20: 20px;
  --wb-font-size-24: 24px;
  --wb-font-weight-regular: 400;
  --wb-font-weight-medium: 500;
  --wb-font-weight-semibold: 600;
  --wb-font-weight-bold: 700;
  --wb-line-height-tight: 1.15;
  --wb-line-height-compact: 1.25;
  --wb-line-height-default: 1.4;
  --wb-line-height-relaxed: 1.6;
  --wb-letter-spacing-label: 0.05em;
  --wb-letter-spacing-kicker: 0.08em;

  /* Shape, control and input ergonomics. `control-lg` is also the minimum
     coarse-pointer target; dense desktop controls may use sm/md only. */
  --wb-radius-none: 0;
  --wb-radius-sm: 4px;
  --wb-radius-md: 6px;
  --wb-radius-lg: 8px;
  --wb-radius-xl: 10px;
  --wb-radius-2xl: 12px;
  --wb-radius-full: 999px;
  --wb-control-sm: 28px;
  --wb-control-md: 36px;
  --wb-control-lg: 44px;
  --wb-touch-target: var(--wb-control-lg);

  /* One keyboard-focus contract and one stacking vocabulary. Layer names state
     purpose instead of leaking arbitrary integers into consumer CSS. */
  --wb-focus-width: 2px;
  --wb-focus-offset: 3px;
  --wb-transparent: transparent;
  --wb-layer-base: 0;
  --wb-layer-content: 1;
  --wb-layer-raised: 2;
  --wb-layer-sticky: 10;
  --wb-layer-menu: 20;
  --wb-layer-popover: 30;
  --wb-layer-modal: 40;
  --wb-layer-toast: 45;
  --wb-layer-tooltip: 50;

  /* Shared modal width and height bounds. They are semantic component tokens,
     not route-specific measurements. */
  --wb-dialog-sm: 30rem;
  --wb-dialog-md: 40rem;
  --wb-dialog-lg: 60rem;
  --wb-dialog-max-height: 80vh;

  /* Component tokens (theme-independent). Component spacing references the scale
     above (§2.1's layering), so a component knob cannot invent a step. */
  --wb-panel-pad: var(--wb-space-12);
  /* Icon sizes. icons.tsx draws every mark on a 16px grid (DESIGN-SYSTEM §3):
     sm = dense marks (table sort, chips), md = default (toolbar, close),
     lg = headers and empty/error states. */
  --wb-icon-sm: 12px;
  --wb-icon-md: 16px;
  --wb-icon-lg: 20px;
  /* The statusbar name chip's floor (kit.css .wb-status-name). In ch on purpose:
     it is a character count, not a pixel guess — the chip itself shrinks
     (.wb-status carries min-width: 0), and this is how many characters of a
     board/document name stay recognisable before the ellipsis binds. Measured in
     the whiteboard at 320x568 (suite backlog UI-055): 9ch keeps a long name
     readable while a concurrent StatusFlash still gets a legible share of the
     row. */
  --wb-status-name-min: 9ch;
  /* Chrome timing the primitives' JS reads. Declared here so the suite states
     its timings in ONE place, in the units a designer reads; TOOLTIP_DELAY_MS
     in tooltip.tsx mirrors this number and tooltip.test.ts fails if the two
     drift apart — the same JS <-> CSS contract as TOOLBAR_JOIN_PX. */
  --wb-tooltip-delay: 400ms;
  --wb-toast-duration: 4500ms;
  /* Reduced motion never auto-dismisses a completion faster than this
     (DESIGN-SYSTEM §5 item 10) — reading time, not animation. */
  --wb-toast-duration-reduced: 5000ms;
  /* Chrome motion (DESIGN-SYSTEM §1.4). The whole band is 120-180ms ease-out:
     `state` is a colour/border change on chrome already on screen, `enter` is a
     layer arriving (palette, popover, menu, panel, rail). Both sit inside the
     band, so re-timing the suite's motion cannot leave it. `rise` is how far an
     entering layer travels — one step of the §1.3 spacing scale, small enough
     that a popover clamped to a viewport edge stays inside its own 8px margin on
     the way in. kit.css states no duration, easing or distance of its own; every
     animation there reads these four, which motion.test.ts asserts along with
     the band itself. */
  --wb-motion-state: 140ms;
  --wb-motion-enter: 160ms;
  --wb-motion-ease: ease-out;
  --wb-motion-rise: 4px;

  color: var(--wb-text);
  background: var(--wb-bg);
  font-family: var(--wb-font-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="light"] {
  color-scheme: light;
  --wb-bg: #eaf0ed;
  --wb-surface: #ffffff;
  --wb-surface-sunken: #f2f6f4;
  --wb-raised: #ffffff;
  --wb-active: #dcefe4;
  --wb-border: #dbe4df;
  --wb-border-2: #cdd9d3;
  --wb-border-accent: #a4d5bd;
  --wb-border-btn: #b9d6c8;
  --wb-text: #16211d;
  --wb-text-2: #24332c;
  --wb-text-muted: #5c6d64;
  --wb-text-subtle: #617069;
  --wb-accent: var(--sk-accent, #12724e);
  --wb-accent-2: var(--sk-accent, #15855b);
  --wb-accent-strong: #1c7a54;
  --wb-on-accent: #ffffff;
  --wb-active-border: var(--sk-accent, #1c9a68);
  --wb-danger: #cf3b30;
  --wb-ok: #1f9d63;
  --wb-warning: #b07d0a;
  --wb-focus: var(--sk-accent, #1c9a68);
  --wb-backdrop: rgb(16 33 26 / 32%);
  --wb-shadow-raised: 0 8px 24px rgb(22 33 29 / 14%);
  --wb-shadow-overlay: 0 12px 32px rgb(22 33 29 / 16%);
  --wb-shadow-modal: 0 18px 48px rgb(22 33 29 / 18%);

  --wb-grid-bg: #ffffff;
  --wb-grid-line: #e7ede9;
  --wb-grid-text: #1c2622;
  --wb-grid-error: #c0392b;
  --wb-grid-header-bg: #f3f6f4;
  --wb-grid-header-line: #d8e2dd;
  --wb-grid-header-text: #6a7a72;
  --wb-grid-header-active-bg: #dcefe4;
  --wb-grid-header-active-text: #12724e;
  --wb-grid-selection: rgb(28 122 84 / 10%);
  --wb-grid-active-border: #1c9a68;
}

/* Opt-in platform presentation tokens. Existing studio tokens remain unchanged. */
.hp-surface {
  color-scheme: light;
  --wb-platform-bg: #fafbf8;
  --wb-platform-surface: #fff;
  --wb-platform-nav: #f1f3ef;
  --wb-platform-raised: #f2f5f0;
  --wb-platform-text: #23332c;
  --wb-platform-muted: #67776d;
  --wb-platform-line: #e0e6dd;
  --wb-platform-accent: #39614b;
  --wb-platform-selected: #e6eee3;
  --wb-platform-on-accent: #fff;
  --wb-platform-shadow: 0 9px 30px #15213512;
  --wb-platform-backdrop: #17233066;
  --wb-platform-danger: #a62f2f;
}
.hp-surface[data-appearance="dark"] {
  color-scheme: dark;
  --wb-platform-bg: #151d19;
  --wb-platform-surface: #1b261f;
  --wb-platform-nav: #172019;
  --wb-platform-raised: #233126;
  --wb-platform-text: #eef1e8;
  --wb-platform-muted: #a1b19f;
  --wb-platform-line: #344338;
  --wb-platform-accent: #b7d8a1;
  --wb-platform-selected: #30442e;
  --wb-platform-on-accent: #1b301d;
  --wb-platform-danger: #ffa6a6;
}
.hp-surface[data-appearance="field"] {
  --wb-platform-bg: #faf6ee;
  --wb-platform-surface: #fffcf5;
  --wb-platform-nav: #f0eadf;
  --wb-platform-raised: #f3ede1;
  --wb-platform-text: #3d3e31;
  --wb-platform-muted: #7d7968;
  --wb-platform-line: #e3dcca;
  --wb-platform-accent: #795f37;
  --wb-platform-selected: #ece2cb;
}
