/* Somnalab shared chrome — ONE header and ONE footer on every page of somnalab.ai and psg.somnalab.ai.
   Tokens follow the SomnaLab UI / UX Design System Spec (medical-grade dark slate, AASM stage palette, sans type scale);
   the old names (--night, --paper, --trace …) are kept as aliases so page CSS keeps working.
   Markup is stamped into each page by tools/chrome.py (between <!--sl:header--> / <!--sl:footer--> markers);
   /assets/chrome.js sets the theme before paint and runs the menu drawer. */
@import url("fonts/fonts.css");
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  /* surfaces */
  --bg-app: #090e1a; --bg-head: #0d1424; --bg-notice: #101a2d; --bg-card: #0f172a; --bg-card-subtle: #131d31;
  --bg-card-active: #1a2744; --bg-input: #131c2e; --bg-waveform: #080c14; --bg-seg: #131c2e; --bg-btn: #142037;
  /* borders */
  --border-subtle: #1e293b; --border-strong: #233554; --border-highlight: #2563eb;
  /* text */
  --text-main: #f8fafc; --text-muted: #94a3b8; --text-faint: #64748b;
  /* brand + status */
  --brand: #38bdf8; --on-brand: #04111d; --eyebrow: #22d3ee;
  --status-success: #22c55e; --status-success-text: #4ade80; --status-warning: #f59e0b; --status-warning-text: #fbbf24; --status-danger: #ef4444;
  --seg-on-bg: #ffffff; --seg-on-text: #0f172a;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, .4);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg-app: #f4f7fb; --bg-head: #ffffff; --bg-notice: #eaf2fb; --bg-card: #ffffff; --bg-card-subtle: #f1f5f9;
  --bg-card-active: #e0f2fe; --bg-input: #ffffff; --bg-waveform: #fbfdff; --bg-seg: #eef2f7; --bg-btn: #f1f5f9;
  --border-subtle: #e2e8f0; --border-strong: #cbd5e1; --border-highlight: #2563eb;
  --text-main: #0f172a; --text-muted: #475569; --text-faint: #64748b;
  --brand: #0284c7; --on-brand: #ffffff; --eyebrow: #0891b2;
  --status-success: #16a34a; --status-success-text: #15803d; --status-warning: #d97706; --status-warning-text: #b45309; --status-danger: #dc2626;
  --seg-on-bg: #0f172a; --seg-on-text: #ffffff;
  --shadow-card: 0 4px 16px rgba(15, 23, 42, .08);
}
:root {
  /* AASM stage palette — fixed in both themes */
  --stage-wake: #f97316; --stage-rem: #6366f1; --stage-n1: #06b6d4; --stage-n2: #38bdf8; --stage-n3: #818cf8;
  --W: var(--stage-wake); --N1: var(--stage-n1); --N2: var(--stage-n2); --N3: var(--stage-n3); --R: var(--stage-rem);
  /* signal traces */
  --trace-eeg: #38bdf8; --trace-emg: #818cf8;
  /* radii */
  --radius-sm: 6px; --radius-md: 10px; --radius-card: 12px; --radius-lg: 16px; --radius-full: 9999px;
  /* type */
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: var(--sans);   /* one family everywhere (spec); kept so older rules resolve */
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  /* aliases for page CSS written before the spec */
  --night: var(--bg-app); --night-2: var(--bg-card); --night-3: var(--bg-card-subtle); --line: var(--border-subtle);
  --paper: var(--text-main); --muted: var(--text-muted); --trace: var(--brand); --rem: var(--stage-rem);
  --amber: var(--status-warning); --red: var(--status-danger); --green: var(--status-success);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg-app); }
body.sl { margin: 0; background: var(--bg-app); color: var(--text-main); font-family: var(--sans); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body.sl a { color: var(--brand); }
body.sl a.btn { color: var(--on-brand); text-decoration: none; } body.sl a.btn.ghost { color: var(--text-main); }   /* buttons drawn as links */
body.sl :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sl-wrap { width: min(1240px, 100% - 32px); margin: 0 auto; }
h1, h2, h3 { font-family: var(--sans); text-wrap: balance; }
h1 { font-size: 26px; font-weight: 700; line-height: 1.2; letter-spacing: -.025em; }
h2 { font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -.015em; }
h3 { font-size: 15px; font-weight: 600; line-height: 1.3; }
.eyebrow { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--eyebrow); line-height: 1.2; margin: 0 0 6px; }
.mono { font-family: var(--mono); font-size: 12px; font-weight: 500; }

/* header: 56 px sticky bar — menu + logo + theme | segmented nav | utilities */
.sl-head { position: sticky; top: 0; z-index: 30; background: var(--bg-head); border-bottom: 1px solid var(--border-subtle); }
.sl-bar { height: 56px; display: flex; align-items: center; gap: 12px; padding: 8px 16px; max-width: 1440px; margin: 0 auto; }
.sl-left, .sl-acct { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; }
.sl-acct { justify-content: flex-end; font-size: 13px; color: var(--text-muted); }
.sl-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-full); border: 1px solid var(--border-subtle); background: transparent; color: var(--text-muted); cursor: pointer; padding: 0; flex: none; }
.sl-icon:hover { color: var(--text-main); border-color: var(--border-strong); }
.sl-icon.sl-menu { border-color: transparent; border-radius: var(--radius-sm); }
.sl-icon svg, .sl-seg svg, .sl-acct svg, .sl-drawer svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sl-theme .sun { display: none; } :root[data-theme="light"] .sl-theme .sun { display: block; } :root[data-theme="light"] .sl-theme .moon { display: none; }
.sl-logo { font-size: 18px; font-weight: 700; letter-spacing: -.02em; color: var(--text-main) !important; text-decoration: none; white-space: nowrap; }
.sl-logo span { color: var(--brand); }
.sl-seg { display: flex; align-items: center; height: 36px; padding: 2px; gap: 2px; background: var(--bg-seg); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); flex: none; }
.sl-seg a { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px; border-radius: var(--radius-full); font-size: 13px; color: var(--text-muted) !important; text-decoration: none; white-space: nowrap; }
.sl-seg a:hover { color: var(--text-main) !important; }
.sl-seg a[aria-current="page"] { background: var(--seg-on-bg); color: var(--seg-on-text) !important; font-weight: 600; }
.sl-acct a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted) !important; text-decoration: none; white-space: nowrap; }
.sl-acct a:hover { color: var(--text-main) !important; }
.sl-acct a.sl-btn { color: var(--on-brand) !important; background: var(--brand); padding: 6px 14px; border-radius: var(--radius-full); font-weight: 600; }
#who { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-notice { background: var(--bg-notice); border-bottom: 1px solid var(--border-subtle); }
.sl-notice .sl-bar { height: auto; padding: 6px 16px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); gap: 8px; }
.sl-notice b { color: var(--text-main); font-weight: 700; }
.sl-beacon { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); flex: none; }

/* drawer (menu button) */
.sl-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(2, 6, 16, .55); }
.sl-drawer { position: fixed; z-index: 41; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); background: var(--bg-card); border-right: 1px solid var(--border-subtle); box-shadow: var(--shadow-card); display: flex; flex-direction: column; padding: 18px 14px; gap: 2px; overflow-y: auto; }
.sl-drawer[hidden], .sl-scrim[hidden] { display: none; }
.sl-drawer .sl-logo { font-size: 22px; padding: 0 8px; }
.sl-drawer .tag { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--text-faint); padding: 2px 8px 12px; text-transform: uppercase; }
.sl-drawer .ctx { display: flex; gap: 10px; align-items: center; padding: 10px 8px; margin-bottom: 6px; border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-muted); }
.sl-drawer .ctx b { display: block; color: var(--text-main); font-size: 13px; }
.sl-drawer a.item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-muted) !important; text-decoration: none; font-size: 14px; }
.sl-drawer a.item:hover { background: var(--bg-card-subtle); color: var(--text-main) !important; }
.sl-drawer a.item[aria-current="page"] { background: var(--bg-card-active); color: var(--text-main) !important; font-weight: 600; }
.sl-drawer a.item em { margin-left: auto; font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 1px 7px; border-radius: var(--radius-full); color: var(--brand); border: 1px solid currentColor; }
.sl-drawer hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 8px 0; width: 100%; }
.sl-drawer .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-faint); }

/* footer */
.sl-foot { border-top: 1px solid var(--border-subtle); margin-top: 56px; color: var(--text-muted); font-size: 13px; background: var(--bg-head); }
.sl-foot .sl-wrap { padding: 22px 0 30px; display: grid; gap: 6px; }
.sl-foot p { margin: 0; } .sl-foot a { color: var(--text-muted) !important; }
.sl-foot strong { color: var(--text-main); font-weight: 700; }
.sl-note { font-size: 12px; color: var(--text-faint); }

@media (max-width: 900px) { .sl-seg, .sl-acct .wide { display: none; } .sl-bar { gap: 8px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
