/* SurgX design tokens — light + dark themes */
:root, [data-theme="light"] {
  color-scheme: light;

  /* Typography — Font Families */
  --font-display: "Schibsted Grotesk", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-ui: "Hanken Grotesk", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-serif: "IBM Plex Serif", "Source Serif 4", Georgia, serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Typography — Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.625rem;
  --text-3xl: clamp(2rem, 1.4rem + 2.2vw, 2.75rem);

  /* Typography — Line Heights */
  --lh-xs: 1.35;
  --lh-sm: 1.4;
  --lh-base: 1.5;
  --lh-md: 1.5;
  --lh-lg: 1.3;
  --lh-xl: 1.2;
  --lh-2xl: 1.15;
  --lh-3xl: 1.08;

  /* Typography — Weights & Tracking */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;
  --tracking-normal: 0em;
  --tracking-lg: -0.01em;
  --tracking-xl: -0.012em;
  --tracking-2xl: -0.015em;

  /* Typography — Numeric & OpenType Feature Hints */
  --font-numeric-tabular: tabular-nums;
  --font-feature-ui: "cv11";
  --font-feature-mono: "zero", "ss01";

  /* Color — Surfaces & Lines */
  --bg: #EEF1F4;
  --surface: #FFFFFF;
  --surface-2: #F7F9FB;
  --surface-3: #EFF3F6;
  --line: #E2E8ED;
  --line-2: #7A8999;
  --line-strong: #64748B;

  /* Color — Ink (WCAG AA >= 4.5:1 on --bg and --surface) */
  --ink-900: #0C1722;
  --ink-700: #2B3A47;
  --ink-600: #43525F;
  --ink-500: #5B6B7A;
  --ink-400: #8B99A6;
  --ink-300: #AEBAC5;

  /* Color — Clinical Accent */
  --accent-700: #093A5A;
  --accent-600: #0B4A72;
  --accent-500: #0E5A8A;
  --accent-300: #6FA6C6;
  --accent-100: #D5E6F0;
  --accent-50: #EAF2F7;
  --on-accent: #FFFFFF;

  /* Color — Semantic Status */
  --status-live: #177255;
  --status-live-bg: #E4F4EE;
  --status-live-line: #B8E1D2;
  --status-warn: #8A5A18;
  --status-warn-bg: #FBF3E4;
  --status-warn-line: #E9D3A8;
  --status-danger: #B91C1C;
  --status-danger-bg: #FEE2E2;
  --status-danger-line: #FECACA;

  /* Spacing & Layout */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --tap-min: 44px;
  --control-h: 48px;
  --nav-h: 58px;
  --container-narrow: 620px;
  --container-wide: 1120px;
  --container-max: 1260px;
  --gutter-mobile: 16px;
  --gutter-desktop: 24px;

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Elevation & Focus */
  --shadow-none: none;
  --shadow-xs: 0 1px 2px rgba(12, 23, 34, 0.05);
  --shadow-sm: 0 1px 2px rgba(12, 23, 34, 0.06), 0 4px 14px rgba(12, 23, 34, 0.05);
  --shadow-md: 0 6px 20px -8px rgba(12, 23, 34, 0.16), 0 2px 6px -2px rgba(12, 23, 34, 0.08);
  --shadow-lg: 0 20px 48px -16px rgba(12, 23, 34, 0.28), 0 6px 16px -8px rgba(12, 23, 34, 0.12);
  --shadow-dark: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  /* Bottom sheets (.surgx-drawer-panel) cast their shadow upward: main's 0 -8px 32px at 10%,
     in the shadow ink above. DESIGN.md has no sheet token yet (gategoat3 on #5066). */
  --shadow-sheet: 0 -8px 32px rgba(12, 23, 34, 0.10);
  --focus-ring-color: var(--accent-600);
  --ring: 0 0 0 3px var(--accent-100);

  /* Legacy PDP & role tokens */
  --verified: #177255;
  --verified-bg: #E4F4EE;
  --info: #1C6E9C;
  --role-surg: #9E2B3B;
  --role-cst: #0E5A8A;
  --role-fa: #0B6B6A;
  --role-rn: #5E54C4;
  --role-anes: #A8456E;
  --role-rep: #8A5A18;
  --role-spd: #177255;
  --density: 1;
  --s1: calc(4px * var(--density));
  --s2: calc(8px * var(--density));
  --s3: calc(12px * var(--density));
  --s4: calc(16px * var(--density));
  --s5: calc(20px * var(--density));
  --s6: calc(24px * var(--density));
  --s8: calc(32px * var(--density));
  --s10: calc(40px * var(--density));
  --s12: calc(48px * var(--density));

  --page-bg: #F6F7F9;
  --card-bg: #FFFFFF;
  --card-bg-soft: #FAFAFB;
  --hairline: #E5E7EB;
  --hairline-strong: #D1D5DB;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #5B6B7A;
  --text-mono: #1E293B;
  --accent: #0E5A8A;
  --accent-soft: rgba(14, 90, 138, 0.08);
  --accent-border: rgba(14, 90, 138, 0.32);
  --success: #059669;
  --success-bg: #ECFDF5;
  --warn: #B45309;
  --warn-bg: #FEF3C7;
  --warn-border: #FCD34D;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --shell-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --inset-shadow: inset 0 0 0 1px var(--hairline);
  --scrim-bg: rgba(15, 23, 42, 0.32);
}

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

  --bg: #091018;
  --surface: #101A26;
  --surface-2: #162332;
  --surface-3: #1D2D40;
  --line: #253549;
  --line-2: #60748D;
  --line-strong: #7086A2;

  --ink-900: #EEF2FA;
  --ink-700: #C8D3E3;
  --ink-600: #B0BED1;
  --ink-500: #8D9BB8;

  /* Note: dark --accent-700 (4.41:1 on --surface) is for borders/strokes only, never text */
  --accent-700: #209070;
  --accent-600: #46C8A0;
  --accent-500: #7DBDE8;
  --accent-100: #1B3B56;
  --accent-50: #12283A;
  --on-accent: #091018;

  --status-live: #4CC39A;
  --status-live-bg: #12302A;
  --status-live-line: #1F5247;
  --status-warn: #E3B462;
  --status-warn-bg: #2B2314;
  --status-warn-line: #4A3A1C;
  --status-danger: #F87171;
  --status-danger-bg: #3A1414;
  --status-danger-line: #692323;

  --shadow-none: none;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-dark: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.5);
  --focus-ring-color: var(--accent-600);

  --verified: #4CC39A;
  --verified-bg: #12302A;
  --role-surg: #FB7185;
  --role-cst: #7DBDE8;
  --role-fa: #4CC39A;
  --role-rn: #A5B4FC;
  --role-anes: #F472B6;
  --role-rep: #E3B462;
  --role-spd: #46C8A0;
  --page-bg: #07090D;
  --card-bg: #10141B;
  --card-bg-soft: #141923;
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: #60748D;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #8D9BB8;
  --text-mono: #CBD5E1;
  --accent: #22D3EE;
  --accent-soft: rgba(34, 211, 238, 0.10);
  --accent-border: rgba(34, 211, 238, 0.32);
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.10);
  --warn: #F59E0B;
  --warn-bg: rgba(245, 158, 11, 0.10);
  --warn-border: rgba(245, 158, 11, 0.35);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.10);
  --shell-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
  --inset-shadow: inset 0 0 0 1px var(--hairline);
  --scrim-bg: rgba(0, 0, 0, 0.55);
}

.surgx-shell {
  font-family: var(--font-ui), system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  background: var(--page-bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.mono { font-family: var(--font-mono), 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-feature-settings: 'zero', 'ss01'; }
