/* Demo palette. Dark is the default and html[data-theme=dark]. Light is html[data-theme=light].
   Border and ring fall back to a solid color, then color-mix where the browser supports it. */
:root,
html[data-theme=dark] {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-raised: #131c31;
  --bg-subtle: #172033;
  --surface: #1c2940;
  --surface-solid: #1e2c44;
  --surface-hover: #203049;
  --fg: #e8eef7;
  --fg-muted: #94a3b8;
  --fg-subtle: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-fg: #f8fafc;
  --accent-soft: #3b82f624;
  --ok: #10b981;
  --ok-soft: #10b98124;
  --warn: #f59e0b;
  --warn-soft: #f59e0b24;
  --danger: #ef4444;
  --danger-soft: #ef444424;
  --info: #38bdf8;
  --info-soft: #38bdf824;
  --border: var(--fg);
  --border-strong: var(--fg);
  --shadow-border: 0 0 0 1px #ffffff14;
  --shadow-border-hover: 0 0 0 1px #ffffff24;
  --shadow-lg: 0 24px 60px -24px #0000008c;
  --glass: blur(16px) saturate(1.2);
  --sidebar: 260px;
  --sidebar-sm: 76px;
  --topbar: 60px;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --motion-micro: 80ms;
  --motion-quick: .15s;
  --motion-fast: .25s;
  --motion-slow: .4s;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ring: 0 0 0 3px var(--accent);
}

@supports (color: color-mix(in lab, red, red)) {
  :root,
  html[data-theme=dark] {
    --border: color-mix(in oklab, var(--fg) 12%, transparent);
    --border-strong: color-mix(in oklab, var(--fg) 22%, transparent);
    --ring: 0 0 0 3px color-mix(in oklab, var(--accent) 45%, transparent);
  }
}

html[data-theme=light],
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e5ebf3;
  --bg-raised: #f7f9fc;
  --bg-subtle: #e8eef6;
  --surface: #ffffff;
  --surface-solid: #fff;
  --surface-hover: #f1f5f9;
  --fg: #0f172a;
  --fg-muted: #475569;
  --fg-subtle: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-fg: #fff;
  --accent-soft: #2563eb1a;
  --border: var(--fg);
  --border-strong: var(--fg);
  --shadow-border: 0 0 0 1px #0f172a0f, 0 1px 2px -1px #0f172a0f, 0 2px 8px 0 #0f172a0a;
  --shadow-border-hover: 0 0 0 1px #0f172a1a, 0 8px 24px -12px #0f172a2e;
  --shadow-lg: 0 24px 50px -20px #0f172a38;
  --glass: blur(18px) saturate(1.4);
}

@supports (color: color-mix(in lab, red, red)) {
  html[data-theme=light],
  :root[data-theme="light"] {
    --border: color-mix(in oklab, var(--fg) 10%, transparent);
    --border-strong: color-mix(in oklab, var(--fg) 18%, transparent);
  }
}

/* Chrome sizes stay on the --nx-* names. Color names point at the demo tokens. */
:root {
  --nx-bg: var(--bg);
  --nx-bg-raised: var(--surface-solid);
  --nx-sidebar: var(--bg-raised);
  --nx-border: var(--border);
  --nx-text: var(--fg);
  --nx-muted: var(--fg-muted);
  --nx-accent: var(--accent);
  --nx-accent-soft: var(--accent-soft);
  --nx-hover: var(--surface-hover);
  --nx-shadow: var(--shadow-lg);
  --nx-danger: var(--danger);
  --nx-font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --nx-mono: "IBM Plex Mono", ui-monospace, monospace;
  --nx-sidebar-w: 16.5rem;
  --nx-topbar-h: 3.5rem;
  --nx-radius: 10px;
  --nx-icon: 1.125rem;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--nx-bg);
  color: var(--nx-text);
  font-family: var(--nx-font);
  font-size: 0.9375rem;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--nx-accent);
  outline-offset: 2px;
}

.nx-icon {
  width: var(--nx-icon);
  height: var(--nx-icon);
  display: block;
  flex: none;
}

/* Card surface metrics; theme colors continue to use the shared palette. */
:root {
  --card-max-width: 640px;
  --card-space: 16px;
  --card-space-large: 20px;
  --card-space-compact: 12px;
  --card-space-review: 16px 18px 6px;
  --card-status-edge: 45%;
}

/* Reusable control and heading metrics. */
:root {
  --control-height: 40px;
  --control-height-sm: 32px;
  --control-radius: 10px;
  --control-radius-sm: 8px;
  --control-gap: 8px;
  --control-font-weight: 550;
  --control-active-scale: .96;
  --control-step-width: 120px;
  --icon-control-size: 36px;
  --icon-control-square: 40px;
  --icon-control-sm: 32px;
  --icon-control-xs: 24px;
  --card-heading-size: 13.5px;
  --card-heading-weight: 600;
}

/* Form, table and authentication component metrics. */
:root {
  --field-gap: 6px;
  --field-gap-tight: 4px;
  --field-padding: 0 12px;
  --field-textarea-padding: 10px 12px;
  --table-min-width: 40rem;
  --table-fixed-min-width: 900px;
  --table-cell-padding: .6rem .75rem;
  --table-demo-cell-padding: 10px 12px;
  --table-scroll-height: 480px;
  --auth-control-height: 44px;
  --auth-control-font: 15px;
  --auth-password-space: 44px;
  --auth-card-space: 32px;
  --auth-card-radius: 24px;
  --auth-card-shadow: inset 0 1px 0 0 #ffffff14, 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent), 0 28px 64px -24px #0000008c, 0 40px 80px -40px color-mix(in srgb, var(--accent) 20%, transparent);
}
:root[data-theme="light"] { --auth-card-shadow: var(--shadow-border), var(--shadow-lg); }
@media (width < 720px) {
  :root {
    --auth-control-height: 48px;
    --auth-control-font: 16px;
    --auth-password-space: 52px;
    --auth-card-space: 24px;
    --auth-card-radius: 16px;
    --auth-card-shadow: inset 0 1px 0 0 #ffffff14, 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent), 0 40px 80px -40px color-mix(in srgb, var(--accent) 20%, transparent);
  }
  :root[data-theme="light"] { --auth-card-shadow: var(--shadow-border); }
}

/* Shared specialized control metrics. */
:root {
  --badge-height: 22px;
  --badge-fixed-width: 96px;
  --avatar-size: 32px;
  --avatar-size-sm: 24px;
  --avatar-size-lg: 48px;
  --switch-width: 40px;
  --switch-height: 22px;
  --switch-thumb-size: 16px;
  --chip-height: 32px;
}
