/* ==========================================================================
   Xboard Theme — Magpie-Inspired Precision Monochrome Tokens (V6)
   Pure Application Workspace · Crisp Neutral Light & Obsidian Dark
   ========================================================================== */

:root {
  /* Typography: Magpie System-Native + Geist + Noto Sans SC */
  --xb-font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Geist", "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --xb-font-mono: ui-monospace, "SF Mono", "Geist Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Detent Harmonious Radius Scale */
  --xb-radius-xs: 7px;
  --xb-radius-sm: 10px;
  --xb-radius-md: 12px;
  --xb-radius-lg: 16px;

  /* Strict Layout & Control Geometry (Detent Spacious Desktop Measure) */
  --xb-topbar-h: 64px;
  --xb-ctrl-h: 34px;
  --xb-stage-max-w: 1360px;
  --xb-stage-px: 28px;

  /* ── transitions-dev Shared Motion Tokens ────────────────────────── */
  --duration-stagger: 40ms;
  --duration-micro: 80ms;
  --duration-quick: 150ms;
  --duration-fast: 250ms;
  --duration-medium: 350ms;
  --duration-slow: 400ms;
  --duration-very-slow: 500ms;

  --ease-detent: cubic-bezier(0.2, 0.9, 0.25, 1);
  --ease-apple-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-smooth-out: cubic-bezier(0.2, 0.9, 0.25, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.2, 0.9, 0.25, 1);
  --ease-linear: linear;
  --ease-bounce: cubic-bezier(0.22, 1.08, 0.36, 1);

  --distance-micro: 4px;
  --distance-small: 6px;
  --distance-base: 8px;
  --distance-medium: 12px;

  --scale-large: 0.96;
  --scale-medium: 0.97;
  --scale-small: 0.98;
  --scale-tiny: 0.99;

  --blur-small: 2px;
  --blur-medium: 3px;

  /* transitions-dev Component Tokens */
  --tabs-dur: 250ms;
  --tabs-ease: cubic-bezier(0.22, 1, 0.36, 1);

  --dropdown-open-dur: 250ms;
  --dropdown-close-dur: 150ms;
  --dropdown-pre-scale: 0.97;
  --dropdown-closing-scale: 0.99;
  --dropdown-ease: cubic-bezier(0.22, 1, 0.36, 1);

  --modal-open-dur: 180ms;
  --modal-close-dur: 130ms;
  --modal-scale: 0.96;
  --modal-scale-close: 0.96;
  --modal-ease: cubic-bezier(0.22, 1, 0.36, 1);

  --toast-open: 350ms;
  --toast-close: 250ms;
  --toast-distance: 16px;
  --toast-blur: 2px;
  --toast-scale: 0.97;
  --toast-ease: cubic-bezier(0.22, 1, 0.36, 1);

  --toggle-dur: 350ms;
  --toggle-travel: 16px;
  --toggle-ov1: 1.5px;
  --toggle-ov2: 0.5px;
  --toggle-track: 160ms;
  --toggle-ease: cubic-bezier(0.34, 1.35, 0.64, 1);

  /* Legacy aliases synced to transitions-dev scale */
  --xb-ease: var(--ease-smooth-out);
  --xb-dur-fast: var(--duration-quick);
  --xb-dur-mid: var(--duration-fast);

  /* Surgical Detent Cobalt + Semantic Accents (WCAG AA >= 4.5:1 calibrated) */
  --xb-accent: #3b57e0;
  --xb-accent-hover: #2f49cc;
  --xb-accent-soft: #eef1fe;
  --xb-sage: #15803d;
  --xb-ochre: #925800;
  --xb-teal: #15803d;
  --xb-ok: #15803d;
  --xb-ok-soft: rgba(21, 128, 61, 0.10);
  --xb-warn: #925800;
  --xb-danger: #c83237;

  /* Default: Detent Pure White Canvas + Warm Stone (#f1f0ed) Mount Bezels */
  color-scheme: light;
  --xb-bg: #ffffff;
  --xb-bg-2: #f7f6f3;
  --xb-mount: #f1f0ed;
  --xb-rail-bg: #f1f0ed;
  --xb-surface: #ffffff;
  --xb-surface-2: #f7f6f3;
  --xb-surface-elevated: #ffffff;
  --xb-surface-hover: #f4f3ef;
  --xb-surface-active: #ebe9e4;
  --xb-mark-ink: #ffffff;

  --xb-border: rgba(24, 24, 27, 0.085);
  --xb-border-strong: rgba(24, 24, 27, 0.15);
  --xb-border-subtle: rgba(24, 24, 27, 0.06);
  --xb-border-elevated: rgba(24, 24, 27, 0.09);

  /* Detent Recessed Warm-Stone Pill Track */
  --xb-nav-tray: #f1f0ed;
  --xb-nav-pill: #ffffff;
  --xb-nav-pill-border: rgba(24, 24, 27, 0.08);

  --xb-ink: #18181b;
  --xb-ink-2: #3f3f46;
  --xb-muted: #5c5c66;
  --xb-faint: #6b6b76;

  --xb-btn-solid-bg: #18181b;
  --xb-btn-solid-hover: #27272a;
  --xb-btn-solid-ink: #ffffff;

  --xb-track-bg: rgba(24, 24, 27, 0.08);
  --xb-bar-muted: rgba(24, 24, 27, 0.14);
  --xb-bar-hover: rgba(24, 24, 27, 0.28);
  --xb-bar-ramp-1: #3f3f46;
  --xb-bar-ramp-2: #62626c;
  --xb-bar-ramp-3: #83838e;
  --xb-bar-ramp-4: #a4a4ae;
  --xb-bar-ramp-5: #c4c4cc;

  /* ── Detent Exact Machined Elevation System (Light) ───────────────── */
  --xb-elev-border: 0 0 0 1px rgba(0, 0, 0, 0.075);
  --xb-elev-raised:
    0 0 0 1px rgba(0, 0, 0, 0.065),
    0 1px 2px rgba(0, 0, 0, 0.055),
    0 2px 6px -2px rgba(0, 0, 0, 0.045);
  --xb-elev-raised-hover:
    0 0 0 1px rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.07);
  --xb-elev-float:
    0 0 0 1px rgba(0, 0, 0, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 12px -6px rgba(0, 0, 0, 0.08),
    0 20px 36px -14px rgba(0, 0, 0, 0.16);
  --xb-elev-modal:
    0 0 0 1px rgba(0, 0, 0, 0.06),
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 12px 24px -8px rgba(0, 0, 0, 0.10),
    0 32px 64px -16px rgba(0, 0, 0, 0.24);

  --xb-shadow-sm: var(--xb-elev-raised);
  --xb-shadow-md: var(--xb-elev-float);
  --xb-shadow-lg: var(--xb-elev-modal);
  --xb-shadow-panel: var(--xb-elev-raised);
  --xb-shadow-pill: var(--xb-elev-raised);
  --xb-shadow-popover: var(--xb-elev-float);
  --xb-shadow-modal: var(--xb-elev-modal);
  --xb-logo-filter: none;
}

[data-theme="dark"] {
  /* Detent Dusk Slate-Obsidian Canvas & Mount Hierarchy */
  color-scheme: dark;
  --xb-bg: #0b0c10;
  --xb-bg-2: #111319;
  --xb-mount: #1d2029;
  --xb-rail-bg: #1d2029;
  --xb-surface: #111319;
  --xb-surface-2: #191c25;
  --xb-surface-elevated: #20232e;
  --xb-surface-hover: #262a37;
  --xb-surface-active: #2e3242;
  --xb-mark-ink: #0b0c10;

  --xb-border: rgba(200, 210, 255, 0.09);
  --xb-border-strong: rgba(200, 210, 255, 0.16);
  --xb-border-subtle: rgba(200, 210, 255, 0.065);
  --xb-border-elevated: rgba(200, 210, 255, 0.14);

  /* Detent Dark Segmented Pill Track */
  --xb-nav-tray: #181a21;
  --xb-nav-pill: #252834;
  --xb-nav-pill-border: rgba(200, 210, 255, 0.12);

  --xb-ink: #eef0f6;
  --xb-ink-2: #c2c7da;
  --xb-muted: #a4abc0;
  --xb-faint: #8e95ad;

  --xb-btn-solid-bg: #eef0f6;
  --xb-btn-solid-hover: #ffffff;
  --xb-btn-solid-ink: #0d0e12;

  --xb-accent: #5b84ff;
  --xb-accent-hover: #7095ff;
  --xb-accent-soft: rgba(91, 132, 255, 0.15);
  --xb-ok: #34c759;
  --xb-ok-soft: rgba(52, 199, 89, 0.14);
  --xb-warn: #e0a838;
  --xb-danger: #f2686d;
  --xb-track-bg: rgba(200, 210, 255, 0.10);
  --xb-bar-muted: rgba(200, 210, 255, 0.18);
  --xb-bar-hover: rgba(200, 210, 255, 0.34);
  --xb-bar-ramp-1: #9aa0b8;
  --xb-bar-ramp-2: #80869e;
  --xb-bar-ramp-3: #6a7086;
  --xb-bar-ramp-4: #565b6e;
  --xb-bar-ramp-5: #464a5b;

  /* ── Detent Exact Machined Elevation System (Dark Dusk) ───────────── */
  --xb-elev-border:
    inset 0 1px 0 rgba(220, 228, 255, 0.04),
    0 0 0 1px rgba(200, 210, 255, 0.09);
  --xb-elev-raised:
    inset 0 1px 0 rgba(220, 228, 255, 0.06),
    0 0 0 1px rgba(200, 210, 255, 0.11),
    0 1px 2px rgba(0, 0, 8, 0.50);
  --xb-elev-raised-hover:
    inset 0 1px 0 rgba(220, 228, 255, 0.08),
    0 0 0 1px rgba(200, 210, 255, 0.18),
    0 2px 6px rgba(0, 0, 8, 0.58);
  --xb-elev-float:
    inset 0 1px 0 rgba(220, 228, 255, 0.08),
    0 0 0 1px rgba(200, 210, 255, 0.14),
    0 4px 10px -2px rgba(0, 0, 8, 0.56),
    0 20px 44px -10px rgba(0, 0, 8, 0.82);
  --xb-elev-modal:
    inset 0 1px 0 rgba(220, 228, 255, 0.08),
    0 0 0 1px rgba(200, 210, 255, 0.15),
    0 16px 40px -12px rgba(0, 0, 8, 0.88);

  --xb-shadow-sm: var(--xb-elev-raised);
  --xb-shadow-md: var(--xb-elev-float);
  --xb-shadow-lg: var(--xb-elev-modal);
  --xb-shadow-panel: var(--xb-elev-raised);
  --xb-shadow-pill: var(--xb-elev-raised);
  --xb-shadow-popover: var(--xb-elev-float);
  --xb-shadow-modal: var(--xb-elev-modal);
  --xb-logo-filter: brightness(0) invert(1);
}

/* ==========================================================================
   Base Reset
   ========================================================================== */

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--xb-bg);
  color: var(--xb-ink);
  font-family: var(--xb-font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(79, 110, 247, 0.18);
  color: var(--xb-ink);
}

[data-theme="dark"] ::selection {
  background: rgba(91, 132, 255, 0.28);
  color: var(--xb-ink);
}

input,
textarea {
  caret-color: var(--xb-accent);
}

input::placeholder,
textarea::placeholder {
  color: var(--xb-faint);
  opacity: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
[role="button"],
[role="tab"],
.chart-col,
.xb-switch {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 1.5px solid var(--xb-ink);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--xb-border-strong);
  border-radius: 999px;
}

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

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

.xb-icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  display: block;
}

.xb-icon--sm {
  width: 13.5px;
  height: 13.5px;
}

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