/*
 * tokens.css — "Calm Precision" design tokens for the dewee Customer Control Plane.
 *
 * Three tiers:
 *   1. Primitives  (--iris-500, --gray-200 …)   raw palette, never used in components
 *   2. Semantic    (--bg, --text, --accent …)    what components consume
 *   3. Component   (--control-h, --sidebar-w …)  sizing contracts shared by many components
 *
 * Light is default. Dark is applied by html[data-theme="dark"], or by the
 * system preference when html[data-theme="system"].
 * Rule: components never reference primitives or raw hex — only semantic tokens.
 */

:root {
  /* ─────────────── 1. Primitives ─────────────── */

  /* Neutral — cool porcelain, slightly blue-biased to sit next to iris */
  --gray-0: #ffffff;
  --gray-25: #fbfbfc;
  --gray-50: #f6f7f9;
  --gray-100: #eff0f3;
  --gray-150: #e7e9ed;
  --gray-200: #dfe2e7;
  --gray-300: #cdd1d8;
  --gray-400: #a3a9b4;
  --gray-500: #7a808c;
  --gray-600: #5b616d;
  --gray-700: #434852;
  --gray-800: #2a2e36;
  --gray-900: #171a20;
  --gray-950: #0d0f13;

  /* Iris — the brand accent, sampled from the logo blob's blue-violet core */
  --iris-50: #f2f2ff;
  --iris-100: #e6e6ff;
  --iris-200: #cfceff;
  --iris-300: #aeabff;
  --iris-400: #8b85ff;
  --iris-500: #6a61f8;
  --iris-600: #5446e8;
  --iris-700: #4536c7;
  --iris-800: #382ea0;
  --iris-900: #2c2779;

  /* Aura — logo gradient stops. Reserved for agent/AI presence only. */
  --aura-pink: #f38bf1;
  --aura-violet: #9a5cff;
  --aura-iris: #5446e8;
  --aura-blue: #1f7bf2;

  --green-50: #e8f7ef; --green-200: #a8e1c4; --green-500: #12a26a; --green-700: #067049;
  --amber-50: #fdf4e3; --amber-200: #f4d197; --amber-500: #de8a0c; --amber-700: #92500a;
  --red-50: #fdeded;   --red-200: #f5b9b9;   --red-500: #e5484d;   --red-700: #b3261e;
  --sky-50: #e8f3fd;   --sky-200: #a9d3f7;   --sky-500: #1d8ae5;   --sky-700: #0b5fa6;
  --violet-50: #f5edff; --violet-500: #9a5cff; --violet-700: #6c33c9;

  /* ─────────────── 2. Semantic (light) ─────────────── */
  color-scheme: light;

  /* Surfaces */
  --bg: var(--gray-50);                 /* app canvas behind everything */
  --surface: var(--gray-0);             /* cards, tables, panels */
  --surface-2: var(--gray-25);          /* subtle alt rows, headers inside surfaces */
  --surface-sunken: var(--gray-100);    /* wells: code, inputs-on-surface, tracks */
  --surface-raised: var(--gray-0);      /* popovers, menus, dialogs */
  --surface-inverse: var(--gray-900);   /* tooltips, toasts */
  --overlay: rgba(13, 15, 19, 0.36);    /* dialog/sheet scrim */

  /* Borders */
  --border: var(--gray-150);
  --border-strong: var(--gray-200);
  --border-control: var(--gray-300);    /* input outlines need 3:1 against surface */

  /* Text */
  --text: var(--gray-950);
  --text-2: var(--gray-700);            /* body copy */
  --text-3: var(--gray-600);            /* captions, meta — 5.9:1 on white */
  --text-4: var(--gray-500);            /* placeholder, disabled — decorative only */
  --text-inverse: var(--gray-25);
  --text-on-accent: #ffffff;

  /* Accent */
  --accent: var(--iris-600);
  --accent-hover: var(--iris-700);
  --accent-active: var(--iris-800);
  --accent-soft: var(--iris-50);
  --accent-soft-2: var(--iris-100);
  --accent-line: var(--iris-200);
  --accent-text: var(--iris-700);       /* links, active nav text — 7.4:1 */

  /* Status (fg = text-safe, solid = dots/bars, soft = fills, line = borders) */
  --success: var(--green-700);  --success-solid: var(--green-500);  --success-soft: var(--green-50);  --success-line: var(--green-200);
  --warning: var(--amber-700);  --warning-solid: var(--amber-500);  --warning-soft: var(--amber-50);  --warning-line: var(--amber-200);
  --danger: var(--red-700);     --danger-solid: var(--red-500);     --danger-soft: var(--red-50);     --danger-line: var(--red-200);
  --info: var(--sky-700);       --info-solid: var(--sky-500);       --info-soft: var(--sky-50);       --info-line: var(--sky-200);
  --neutral-solid: var(--gray-400);

  /* Data-viz categorical ramp (ordered; colour-blind-aware, first = accent) */
  --viz-1: var(--iris-600);
  --viz-2: #0fa3a3;
  --viz-3: #e0892b;
  --viz-4: #c2479b;
  --viz-5: #4f9d3a;
  --viz-6: #8a94a6;
  --viz-grid: var(--gray-150);

  /* Brand aura */
  --aura: linear-gradient(135deg, var(--aura-pink) 0%, var(--aura-violet) 34%, var(--aura-iris) 66%, var(--aura-blue) 100%);
  --aura-soft: linear-gradient(135deg, rgba(243, 139, 241, 0.16), rgba(84, 70, 232, 0.12) 55%, rgba(31, 123, 242, 0.14));
  --aura-glow: 0 0 0 1px rgba(84, 70, 232, 0.18), 0 8px 28px -6px rgba(154, 92, 255, 0.35);

  /* Focus */
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--iris-500);
  --focus-ring-inset: inset 0 0 0 2px var(--iris-500);

  /* Elevation — cool, layered, low-contrast */
  --shadow-xs: 0 1px 1px rgba(16, 18, 27, 0.04);
  --shadow-sm: 0 1px 2px rgba(16, 18, 27, 0.06), 0 1px 1px rgba(16, 18, 27, 0.03);
  --shadow-md: 0 4px 12px -2px rgba(16, 18, 27, 0.08), 0 2px 4px -2px rgba(16, 18, 27, 0.05);
  --shadow-lg: 0 16px 36px -8px rgba(16, 18, 27, 0.16), 0 4px 10px -4px rgba(16, 18, 27, 0.06);
  --shadow-xl: 0 28px 64px -12px rgba(16, 18, 27, 0.26), 0 8px 20px -8px rgba(16, 18, 27, 0.10);
  --ring-hairline: 0 0 0 1px var(--border);

  /* ─────────────── Typography ─────────────── */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* size / line-height pairs — 14px is the UI body size */
  --fs-2xs: 11px;  --lh-2xs: 14px;
  --fs-xs: 12px;   --lh-xs: 16px;
  --fs-sm: 13px;   --lh-sm: 18px;
  --fs-md: 14px;   --lh-md: 20px;
  --fs-lg: 16px;   --lh-lg: 24px;
  --fs-xl: 18px;   --lh-xl: 26px;
  --fs-2xl: 22px;  --lh-2xl: 28px;
  --fs-3xl: 28px;  --lh-3xl: 34px;
  --fs-4xl: 36px;  --lh-4xl: 42px;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  --tracking-tight: -0.022em;  /* ≥ 22px headings */
  --tracking-snug: -0.011em;   /* 16–20px */
  --tracking-normal: 0;
  --tracking-caps: 0.06em;     /* overline / eyebrow labels */

  /* ─────────────── Space (4-pt) ─────────────── */
  --s-0: 0;
  --s-px: 1px;
  --s-0-5: 2px;
  --s-1: 4px;
  --s-1-5: 6px;
  --s-2: 8px;
  --s-2-5: 10px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  /* ─────────────── Radius ─────────────── */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;    /* controls */
  --r-lg: 12px;   /* cards, panels */
  --r-xl: 16px;   /* dialogs, sheets */
  --r-2xl: 22px;  /* hero surfaces, composer */
  --r-full: 999px;

  /* ─────────────── Motion ─────────────── */
  --dur-instant: 80ms;   /* press feedback */
  --dur-fast: 120ms;     /* hover, colour */
  --dur-base: 180ms;     /* popovers, tabs, toggles */
  --dur-slow: 280ms;     /* dialogs, sheets, drawers */
  --dur-slower: 420ms;   /* page-level choreography, charts */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);        /* default for entering */
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);        /* exiting */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);    /* moving between two states */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1); /* tiny pops only (≤ 8px travel) */
  --stagger: 28ms;

  /* ─────────────── Layers ─────────────── */
  --z-base: 0;
  --z-sticky: 20;
  --z-sidebar: 30;
  --z-topbar: 40;
  --z-drawer: 60;
  --z-dialog: 80;
  /* Popovers (select, menu, date picker) open from inside dialogs and sheets, so they sit above them. */
  --z-popover: 85;
  --z-toast: 90;
  --z-tooltip: 100;

  /* ─────────────── 3. Component contracts ─────────────── */
  --control-h-sm: 28px;
  --control-h: 34px;
  --control-h-lg: 40px;
  --touch-min: 44px;
  --icon-sm: 14px;
  --icon: 16px;
  --icon-lg: 20px;

  --topbar-h: 56px;
  --bottom-bar-h: 0px;  /* mobile tab bar height (48 + padding + hairline); full-height tools subtract it */
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 64px;
  --content-max: 1320px;
  --content-narrow: 880px;
  --gutter: var(--s-8);
  --sheet-w: min(640px, 100vw);
  --sheet-w-wide: min(960px, 100vw);
}

/* ─────────────── Dark: "Midnight" ─────────────── */
html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0b0e;
  --surface: #111317;
  --surface-2: #14161b;
  --surface-sunken: #0d0e12;
  --surface-raised: #181a20;
  --surface-inverse: #eceef2;
  --overlay: rgba(0, 0, 0, 0.58);

  --border: #1f2229;
  --border-strong: #2a2e37;
  --border-control: #363b46;

  --text: #eef0f4;
  --text-2: #bfc3cc;
  --text-3: #9095a1;
  --text-4: #666b77;
  --text-inverse: #111317;
  --text-on-accent: #ffffff;

  --accent: #6d64ff;
  --accent-hover: #8079ff;
  --accent-active: #948eff;
  --accent-soft: rgba(109, 100, 255, 0.12);
  --accent-soft-2: rgba(109, 100, 255, 0.2);
  --accent-line: rgba(139, 133, 255, 0.36);
  --accent-text: #aeabff;

  --success: #5fd49c;  --success-solid: #2fbf7c;  --success-soft: rgba(47, 191, 124, 0.12);  --success-line: rgba(47, 191, 124, 0.32);
  --warning: #f3b85c;  --warning-solid: #e79a24;  --warning-soft: rgba(231, 154, 36, 0.12);  --warning-line: rgba(231, 154, 36, 0.32);
  --danger: #ff8a86;   --danger-solid: #f0575c;   --danger-soft: rgba(240, 87, 92, 0.12);    --danger-line: rgba(240, 87, 92, 0.34);
  --info: #7cc0ff;     --info-solid: #3d9df0;     --info-soft: rgba(61, 157, 240, 0.12);     --info-line: rgba(61, 157, 240, 0.32);
  --neutral-solid: #5b616d;

  --viz-1: #8079ff;
  --viz-2: #2cc3c3;
  --viz-3: #f0a14a;
  --viz-4: #e070bd;
  --viz-5: #74c05c;
  --viz-6: #7d8699;
  --viz-grid: #1f2229;

  --aura-soft: linear-gradient(135deg, rgba(243, 139, 241, 0.14), rgba(109, 100, 255, 0.14) 55%, rgba(31, 123, 242, 0.14));
  --aura-glow: 0 0 0 1px rgba(139, 133, 255, 0.3), 0 10px 32px -6px rgba(154, 92, 255, 0.45);

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px #8b85ff;
  --focus-ring-inset: inset 0 0 0 2px #8b85ff;

  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-lg: 0 18px 40px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-xl: 0 30px 70px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Compact density: tighter controls and rows for power users (Preferences → Density) */
html[data-density="compact"] {
  --control-h: 30px;
  --control-h-lg: 36px;
  --row-pad-y: 6px;
}

@media (pointer: coarse) {
  :root { --control-h: 40px; --control-h-sm: 34px; }
}

@media (max-width: 1023px) {
  :root { --gutter: var(--s-6); }
}
@media (max-width: 719px) {
  :root { --gutter: var(--s-4); --topbar-h: 52px; --bottom-bar-h: calc(57px + env(safe-area-inset-bottom)); }
}
/* base.css — reset, document typography, focus and scrollbar defaults. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-md);
  font-weight: var(--fw-regular);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  color: var(--text);
  font-weight: var(--fw-semibold);
  text-wrap: balance;
}
h1 { font-size: var(--fs-2xl); line-height: var(--lh-2xl); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--fs-lg); line-height: var(--lh-lg); letter-spacing: var(--tracking-snug); }
h3 { font-size: var(--fs-md); line-height: var(--lh-md); }
h4 { font-size: var(--fs-sm); line-height: var(--lh-sm); }

p { margin: 0; text-wrap: pretty; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
strong, b { font-weight: var(--fw-semibold); color: var(--text); }
small { font-size: var(--fs-xs); }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }
img, svg, video, canvas { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; border-spacing: 0; width: 100%; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
input, textarea { margin: 0; }
textarea { resize: vertical; }

[hidden] { display: none !important; }

::selection { background: var(--accent-soft-2); color: var(--text); }

/* Focus: only keyboard focus gets the ring. Components never remove it without a replacement. */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

/* Numbers in data read better tabular */
.num, td, .tabular { font-variant-numeric: tabular-nums; }

/* Scrollbars — thin and quiet */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: var(--text-4); }
*::-webkit-scrollbar-track { background: transparent; }

/* Utility classes kept deliberately small — layout lives in components */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.mono { font-family: var(--font-mono); font-size: 0.93em; }
.muted { color: var(--text-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-8); }
.row { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.row-wrap { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.grid-2 { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--s-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--s-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
/* The sidebar takes ~240px, so a 1024–1279px viewport leaves only ~690–930px of content: too narrow for three or four cards. */
@media (max-width: 1279px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 719px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* Keyboard hints disappear on touch */
@media (hover: none) { .hint-kbd, kbd.kbd { display: none !important; } }

/* Inputs never zoom on iOS */
@media (max-width: 719px) {
  input, textarea, select { font-size: 16px !important; }
}

/* Text tone helpers and inline icons sized to the surrounding text. */
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.icon-inline { width: 14px; height: 14px; flex: none; vertical-align: -2px; }
/*
 * motion.css — shared keyframes and choreography helpers.
 * Every animation here has a job: feedback, orientation (where did it come from)
 * or continuity (what changed). Decorative motion is not allowed.
 */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(0.985); } }
@keyframes sheet-in-right { from { transform: translateX(100%); } to { transform: none; } }
@keyframes sheet-out-right { from { transform: none; } to { transform: translateX(100%); } }
@keyframes sheet-in-left { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes sheet-out-left { from { transform: none; } to { transform: translateX(-100%); } }
@keyframes sheet-in-bottom { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(24px); } }
@keyframes shimmer { from { background-position: -240px 0; } to { background-position: calc(240px + 100%) 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes aura-breathe { 0%, 100% { transform: scale(1); filter: saturate(1); } 50% { transform: scale(1.04); filter: saturate(1.15); } }
@keyframes aura-rotate { to { transform: rotate(360deg); } }
@keyframes caret-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes typing-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }
@keyframes check-draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@keyframes highlight-row { from { background: var(--accent-soft-2); } to { background: transparent; } }
@keyframes bar-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes draw-line { from { stroke-dashoffset: var(--len, 1000); } to { stroke-dashoffset: 0; } }
@keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* Page entrance: children of .page-enter rise in with a short stagger */
.page-enter > * {
  animation: rise-in var(--dur-slow) var(--ease-out) both;
}
.page-enter > *:nth-child(1) { animation-delay: 0ms; }
.page-enter > *:nth-child(2) { animation-delay: calc(var(--stagger) * 1); }
.page-enter > *:nth-child(3) { animation-delay: calc(var(--stagger) * 2); }
.page-enter > *:nth-child(4) { animation-delay: calc(var(--stagger) * 3); }
.page-enter > *:nth-child(5) { animation-delay: calc(var(--stagger) * 4); }
.page-enter > *:nth-child(n + 6) { animation-delay: calc(var(--stagger) * 5); }

/* Newly inserted rows flash once so the user sees where their change landed */
.is-new { animation: highlight-row 1.6s var(--ease-out) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  animation-delay: 0ms !important;
  transition-duration: 1ms !important;
}
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: none !important; }
/* controls.css — buttons, fields, toggles, segmented control, combobox trigger. */

/* ───────── Button ───────── */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-control);
  --btn-bg-hover: var(--surface-2);
  --btn-shadow: var(--shadow-xs);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1-5);
  height: var(--control-h);
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--btn-shadow);
  user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-instant) var(--ease-out);
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--btn-bg-hover); text-decoration: none; }
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(0.5px) scale(0.985); }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn svg { width: var(--icon); height: var(--icon); flex: none; }

.btn--primary {
  --btn-bg: var(--accent);
  --btn-bg-hover: var(--accent-hover);
  --btn-fg: var(--text-on-accent);
  --btn-border: transparent;
  --btn-shadow: 0 1px 2px rgba(40, 30, 160, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn--primary:active:not(:disabled) { background: var(--accent-active); }
.btn--secondary { /* defaults */ }
.btn--ghost {
  --btn-bg: transparent;
  --btn-bg-hover: var(--surface-sunken);
  --btn-border: transparent;
  --btn-fg: var(--text-2);
  --btn-shadow: none;
}
.btn--ghost:hover:not(:disabled) { color: var(--text); }
.btn--danger {
  --btn-bg: var(--danger-solid);
  --btn-bg-hover: var(--danger);
  --btn-fg: #fff;
  --btn-border: transparent;
  --btn-shadow: 0 1px 2px rgba(179, 38, 30, 0.25);
}
.btn--danger-ghost {
  --btn-bg: transparent;
  --btn-bg-hover: var(--danger-soft);
  --btn-border: transparent;
  --btn-fg: var(--danger);
  --btn-shadow: none;
}
.btn--link {
  --btn-bg: transparent; --btn-bg-hover: transparent; --btn-border: transparent; --btn-shadow: none;
  --btn-fg: var(--accent-text);
  height: auto; padding: 0;
}
.btn--link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.btn--aura {
  /* Both slots carry the gradient so the shared .btn:hover rule can never swap in a light surface. */
  --btn-bg: var(--aura);
  --btn-bg-hover: var(--aura);
  --btn-fg: #fff;
  --btn-border: transparent;
  --btn-shadow: var(--aura-glow);
  background-size: 160% 160%;
  background-position: 0% 50%;
  text-shadow: 0 1px 1px rgba(20, 10, 80, 0.28);
  transition: background-position var(--dur-slower) var(--ease-out), transform var(--dur-instant) var(--ease-out), box-shadow var(--dur-fast);
}
.btn.btn--aura:hover:not(:disabled):not([aria-disabled="true"]) { background-size: 160% 160%; background-position: 100% 50%; }
.btn.btn--aura:focus-visible { box-shadow: var(--focus-ring), var(--aura-glow); }

.btn--sm { height: var(--control-h-sm); padding: 0 var(--s-2-5); font-size: var(--fs-sm); gap: var(--s-1); }
.btn--sm svg { width: var(--icon-sm); height: var(--icon-sm); }
.btn--lg { height: var(--control-h-lg); padding: 0 var(--s-4); font-size: var(--fs-md); }
.btn--block { width: 100%; }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--icon.btn--sm { width: var(--control-h-sm); }
.btn--icon.btn--lg { width: var(--control-h-lg); }
.btn[data-loading="true"] { color: transparent !important; pointer-events: none; }
.btn[data-loading="true"] > .btn__spinner { position: absolute; inset: 0; margin: auto; color: var(--btn-fg); }

.btn-group { display: inline-flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.btn-group--attached { gap: 0; }
.btn-group--attached > .btn { border-radius: 0; }
.btn-group--attached > .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.btn-group--attached > .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group--attached > .btn + .btn { margin-left: -1px; }

@media (pointer: coarse) {
  .btn--icon { min-width: var(--touch-min); min-height: var(--touch-min); }
}

/* ───────── Spinner ───────── */
.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  opacity: 0.8;
  flex: none;
}
.spinner--sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner--lg { width: 22px; height: 22px; }

/* ───────── Field ───────── */
.field { display: flex; flex-direction: column; gap: var(--s-1-5); min-width: 0; }
.field__label {
  display: flex; align-items: baseline; gap: var(--s-1-5);
  color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: var(--lh-sm);
}
.field__required { color: var(--danger); }
.field__optional { color: var(--text-4); font-weight: var(--fw-regular); font-size: var(--fs-xs); }
.field__hint { color: var(--text-3); font-size: var(--fs-xs); line-height: var(--lh-xs); }
.field__error { display: flex; gap: var(--s-1); align-items: center; color: var(--danger); font-size: var(--fs-xs); line-height: var(--lh-xs); animation: drop-in var(--dur-base) var(--ease-out); }
.field__error svg { width: 13px; height: 13px; flex: none; }
.field-row { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 719px) { .field-row { grid-template-columns: minmax(0, 1fr); } }
.form-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.form-section { display: flex; flex-direction: column; gap: var(--s-4); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.form-section:first-child { padding-top: 0; border-top: 0; }
.form-section__title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text); }
.form-section__desc { font-size: var(--fs-xs); color: var(--text-3); margin-top: calc(var(--s-3) * -1); }

/* ───────── Input / Textarea ───────── */
.input {
  display: flex; align-items: center; gap: var(--s-2);
  height: var(--control-h);
  padding: 0 var(--s-2-5);
  border: 1px solid var(--border-control);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
  min-width: 0;
}
.input:hover { border-color: var(--text-4); }
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
.input[data-invalid="true"] { border-color: var(--danger-solid); }
.input[data-invalid="true"]:focus-within { box-shadow: 0 0 0 3px var(--danger-soft); }
.input[data-disabled="true"] { background: var(--surface-sunken); color: var(--text-4); cursor: not-allowed; box-shadow: none; }
.input > input, .input > textarea {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font-size: var(--fs-md);
  color: inherit;
}
.input > input::placeholder, .input > textarea::placeholder { color: var(--text-4); }
.input > input:focus-visible { box-shadow: none; }
.input__affix { color: var(--text-3); display: inline-flex; align-items: center; font-size: var(--fs-sm); flex: none; }
.input__affix svg { width: var(--icon); height: var(--icon); }
.input__affix--unit { font-family: var(--font-mono); font-size: var(--fs-xs); padding-left: var(--s-2); border-left: 1px solid var(--border); height: 60%; }
.input__clear { color: var(--text-4); display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: var(--r-xs); }
.input__clear:hover { color: var(--text); background: var(--surface-sunken); }
.input--sm { height: var(--control-h-sm); font-size: var(--fs-sm); }
.input--lg { height: var(--control-h-lg); }
.input--mono > input { font-family: var(--font-mono); font-size: var(--fs-sm); }
.input--textarea { height: auto; padding: var(--s-2) var(--s-2-5); align-items: stretch; }
.input--textarea > textarea { min-height: 80px; line-height: var(--lh-md); resize: vertical; padding: 0; }
.input__count { font-size: var(--fs-2xs); color: var(--text-4); align-self: flex-end; font-variant-numeric: tabular-nums; }
.textarea-wrap { display: flex; flex-direction: column; gap: var(--s-1); }

/* Number stepper */
.stepper-btn { display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--r-xs); color: var(--text-3); }
.stepper-btn:hover { background: var(--surface-sunken); color: var(--text); }
.stepper-btn svg { width: 14px; height: 14px; }

/* ───────── Switch ───────── */
.switch { display: inline-flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; min-width: 0; }
.switch[data-disabled="true"] { cursor: not-allowed; opacity: 0.55; }
.switch__track {
  position: relative; flex: none;
  width: 34px; height: 20px; margin-top: 1px;
  border-radius: var(--r-full);
  background: var(--border-control);
  transition: background-color var(--dur-base) var(--ease-out), box-shadow var(--dur-fast);
}
.switch__thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform var(--dur-base) var(--ease-spring), width var(--dur-fast) var(--ease-out);
}
.switch:active .switch__thumb { width: 19px; }
.switch[data-checked="true"] .switch__track { background: var(--accent); }
.switch[data-checked="true"] .switch__thumb { transform: translateX(14px); }
.switch[data-checked="true"]:active .switch__thumb { transform: translateX(11px); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus-ring); }
.switch__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch__label { color: var(--text); font-size: var(--fs-md); font-weight: var(--fw-medium); line-height: var(--lh-md); }
.switch__desc { color: var(--text-3); font-size: var(--fs-xs); line-height: var(--lh-xs); }
.switch--sm .switch__track { width: 28px; height: 16px; }
.switch--sm .switch__thumb { width: 12px; height: 12px; }
.switch--sm[data-checked="true"] .switch__thumb { transform: translateX(12px); }

/* Setting row: label/description left, control right */
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-6);
  padding: var(--s-4) 0; border-top: 1px solid var(--border);
}
.setting-row:first-child { border-top: 0; padding-top: 0; }
.setting-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-row__label { color: var(--text); font-weight: var(--fw-medium); display: flex; gap: var(--s-2); align-items: center; }
.setting-row__desc { color: var(--text-3); font-size: var(--fs-sm); }
.setting-row__control { flex: none; display: flex; align-items: center; gap: var(--s-2); }
@media (max-width: 719px) {
  .setting-row { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .setting-row__control { justify-content: flex-start; }
}

/* ───────── Checkbox & Radio ───────── */
.check { display: inline-flex; align-items: flex-start; gap: var(--s-2-5); cursor: pointer; min-width: 0; }
.check[data-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.check__box {
  flex: none; display: grid; place-items: center;
  width: 16px; height: 16px; margin-top: 2px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-control);
  background: var(--surface);
  color: #fff;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.check__box svg { width: 12px; height: 12px; stroke-width: 3; stroke-dasharray: 24; stroke-dashoffset: 24; }
.check[data-checked="true"] .check__box, .check[data-indeterminate="true"] .check__box { background: var(--accent); border-color: var(--accent); }
.check[data-checked="true"] .check__box svg, .check[data-indeterminate="true"] .check__box svg { animation: check-draw var(--dur-base) var(--ease-out) forwards; }
.check:hover .check__box { border-color: var(--accent); }
.check input:focus-visible + .check__box { box-shadow: var(--focus-ring); }
.check__radio { border-radius: 50%; }
.check__radio::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; transform: scale(0); transition: transform var(--dur-base) var(--ease-spring); }
.check[data-checked="true"] .check__radio::after { transform: scale(1); }
.check__text { display: flex; flex-direction: column; gap: 2px; }
.check__label { color: var(--text); font-size: var(--fs-md); line-height: var(--lh-md); }
.check__desc { color: var(--text-3); font-size: var(--fs-xs); }
.check-list { display: flex; flex-direction: column; gap: var(--s-3); }

/* Choice cards (radio-group variant="card") */
.choice-grid { display: grid; gap: var(--s-2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.choice {
  position: relative; display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-3-5, 14px);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); cursor: pointer; text-align: left;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
}
.choice:hover { border-color: var(--text-4); }
.choice[data-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.choice:focus-visible { box-shadow: var(--focus-ring); }
.choice[data-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.choice__icon { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--surface-sunken); color: var(--text-2); }
.choice[data-checked="true"] .choice__icon { background: var(--surface); color: var(--accent-text); }
.choice__icon svg { width: 18px; height: 18px; }
.choice__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice__title { color: var(--text); font-weight: var(--fw-medium); }
.choice__desc { color: var(--text-3); font-size: var(--fs-xs); line-height: var(--lh-xs); }
.choice__check { position: absolute; top: 10px; right: 10px; color: var(--accent); opacity: 0; transform: scale(0.6); transition: opacity var(--dur-fast), transform var(--dur-base) var(--ease-spring); }
.choice[data-checked="true"] .choice__check { opacity: 1; transform: none; }
.choice__check svg { width: 16px; height: 16px; }

/* ───────── Segmented control ───────── */
.segmented {
  position: relative; display: inline-flex; align-items: stretch;
  padding: 2px; gap: 2px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  isolation: isolate;
  max-width: 100%;
  overflow-x: auto;
}
.segmented__indicator {
  position: absolute; z-index: -1; top: 2px; bottom: 2px; left: 0;
  border-radius: calc(var(--r-md) - 2px);
  background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  transition: transform var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out);
}
.segmented__item {
  display: inline-flex; align-items: center; gap: var(--s-1-5);
  height: calc(var(--control-h) - 6px);
  padding: 0 var(--s-3);
  border-radius: calc(var(--r-md) - 2px);
  color: var(--text-3);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: color var(--dur-fast);
}
.segmented__item:hover { color: var(--text); }
.segmented__item[aria-checked="true"] { color: var(--text); }
.segmented__item svg { width: 14px; height: 14px; }
.segmented__item:disabled { opacity: 0.45; }
.segmented--sm .segmented__item { height: calc(var(--control-h-sm) - 6px); padding: 0 var(--s-2); font-size: var(--fs-xs); }

/* ───────── Select trigger (used by Combobox) ───────── */
.select-trigger {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; height: var(--control-h);
  padding: 0 var(--s-2) 0 var(--s-2-5);
  border: 1px solid var(--border-control); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs);
  text-align: left; font-size: var(--fs-md);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  min-width: 0;
}
.select-trigger:hover:not(:disabled) { border-color: var(--text-4); }
.select-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
.select-trigger:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
.select-trigger[data-invalid="true"] { border-color: var(--danger-solid); }
.select-trigger:disabled { background: var(--surface-sunken); color: var(--text-4); cursor: not-allowed; }
.select-trigger__value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: var(--s-2); }
.select-trigger__placeholder { color: var(--text-4); }
.select-trigger__chevron { color: var(--text-3); flex: none; transition: transform var(--dur-base) var(--ease-out); }
.select-trigger[aria-expanded="true"] .select-trigger__chevron { transform: rotate(180deg); }
.select-trigger svg { width: var(--icon); height: var(--icon); }
.select-trigger--sm { height: var(--control-h-sm); font-size: var(--fs-sm); }
.select-trigger--chips { height: auto; min-height: var(--control-h); padding-top: 3px; padding-bottom: 3px; flex-wrap: wrap; }
.select-trigger--inline { width: auto; border-style: dashed; box-shadow: none; }

/* Filter chip trigger (FilterBar) */
.filter-chip {
  display: inline-flex; align-items: center; gap: var(--s-1-5);
  height: var(--control-h-sm); padding: 0 var(--s-2-5);
  border: 1px dashed var(--border-control); border-radius: var(--r-full);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  background: transparent; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.filter-chip:hover { background: var(--surface); border-color: var(--text-4); color: var(--text); }
.filter-chip[data-active="true"] { border-style: solid; border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.filter-chip svg { width: 14px; height: 14px; }
.filter-chip__value { color: var(--text); font-weight: var(--fw-semibold); max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.filter-chip[data-active="true"] .filter-chip__value { color: var(--accent-text); }
.filter-chip__sep { width: 1px; height: 12px; background: var(--accent-line); }

/* Inline form footer (forms that live inside a card or sheet body rather than a dialog footer). */
.form-actions { display: flex; justify-content: flex-end; gap: var(--s-2); padding-top: var(--s-2); }
/* display.css — badges, avatars, cards, stats, banners, states, code, tabs, breadcrumbs, stepper, timeline. */

/* ───────── Badge ───────── */
.badge {
  --b-bg: var(--surface-sunken); --b-fg: var(--text-2); --b-line: var(--border); --b-dot: var(--neutral-solid);
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px;
  border-radius: var(--r-sm);
  background: var(--b-bg); color: var(--b-fg);
  box-shadow: inset 0 0 0 1px var(--b-line);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1;
  white-space: nowrap; vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.badge svg { width: 12px; height: 12px; flex: none; }
.badge--pill { border-radius: var(--r-full); }
.badge--lg { height: 24px; padding: 0 9px; font-size: var(--fs-sm); }
.badge--accent { --b-bg: var(--accent-soft); --b-fg: var(--accent-text); --b-line: var(--accent-line); --b-dot: var(--accent); }
.badge--success { --b-bg: var(--success-soft); --b-fg: var(--success); --b-line: var(--success-line); --b-dot: var(--success-solid); }
.badge--warning { --b-bg: var(--warning-soft); --b-fg: var(--warning); --b-line: var(--warning-line); --b-dot: var(--warning-solid); }
.badge--danger { --b-bg: var(--danger-soft); --b-fg: var(--danger); --b-line: var(--danger-line); --b-dot: var(--danger-solid); }
.badge--info { --b-bg: var(--info-soft); --b-fg: var(--info); --b-line: var(--info-line); --b-dot: var(--info-solid); }
.badge--outline { --b-bg: transparent; }
.badge--solid-accent { --b-bg: var(--accent); --b-fg: #fff; --b-line: transparent; }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--b-dot); flex: none; color: var(--b-dot); }
.badge__dot--pulse { animation: pulse-dot 1.8s var(--ease-out) infinite; }
.count-badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--accent); color: #fff;
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.count-badge--quiet { background: var(--surface-sunken); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--border); }
.count-badge--danger { background: var(--danger-solid); }

/* Status dot (standalone) */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--neutral-solid); color: var(--neutral-solid); }
.status-dot--success { background: var(--success-solid); color: var(--success-solid); }
.status-dot--warning { background: var(--warning-solid); color: var(--warning-solid); }
.status-dot--danger { background: var(--danger-solid); color: var(--danger-solid); }
.status-dot--info { background: var(--info-solid); color: var(--info-solid); }
.status-dot--accent { background: var(--accent); color: var(--accent); }
.status-dot--pulse { animation: pulse-dot 1.8s var(--ease-out) infinite; }

/* Tag chip (removable) */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 4px 0 8px;
  border-radius: var(--r-sm);
  background: var(--surface-sunken); color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  max-width: 100%;
  animation: scale-in var(--dur-base) var(--ease-out);
}
.tag--static { padding-right: 8px; }
.tag__x { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 3px; color: var(--text-3); }
.tag__x:hover { background: var(--border); color: var(--text); }
.tag__x svg { width: 11px; height: 11px; }

/* ───────── Avatar ───────── */
.avatar {
  --av: 28px;
  position: relative; flex: none;
  display: inline-grid; place-items: center;
  width: var(--av); height: var(--av);
  border-radius: 50%;
  background: var(--av-bg, var(--surface-sunken));
  color: var(--av-fg, var(--text-2));
  font-size: calc(var(--av) * 0.38); font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { --av: 18px; }
.avatar--sm { --av: 22px; }
.avatar--lg { --av: 36px; }
.avatar--xl { --av: 48px; }
.avatar--square { border-radius: 28%; }
/* Agents carry the aura: a soft brand-gradient body with a face-like glyph */
.avatar--agent { background: var(--aura); color: #fff; box-shadow: inset 0 -2px 6px rgba(20, 10, 80, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.25); border-radius: 46% 46% 42% 42% / 52% 52% 40% 40%; }
.avatar--agent[data-hue="1"] { filter: hue-rotate(28deg); }
.avatar--agent[data-hue="2"] { filter: hue-rotate(-32deg); }
.avatar--agent[data-hue="3"] { filter: hue-rotate(62deg) saturate(0.9); }
.avatar--agent[data-hue="4"] { filter: hue-rotate(-70deg); }
.avatar__status { position: absolute; right: -1px; bottom: -1px; width: 30%; height: 30%; min-width: 7px; min-height: 7px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
.avatar-group { display: inline-flex; flex: none; }
.avatar-group > .avatar { flex: none; }
.avatar-group > .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-group > .avatar + .avatar { margin-left: -3px; }

/* ───────── Kbd ───────── */
.kbd {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 4px;
  background: var(--surface); color: var(--text-3);
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 0 var(--border-strong);
  font-family: var(--font-sans); font-size: var(--fs-2xs); font-weight: var(--fw-medium);
  line-height: 1;
}
.kbd-combo { display: inline-flex; gap: 3px; align-items: center; }

/* ───────── Card / Panel ───────── */
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.card--flush > .card__body { padding: 0; }
.card--interactive { cursor: pointer; transition: border-color var(--dur-fast), box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); text-align: left; color: inherit; }
.card--interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); text-decoration: none; }
.card--interactive:active { transform: scale(0.995); }
.card--interactive:focus-visible { box-shadow: var(--focus-ring); }
.card--selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card--sunken { background: var(--surface-2); box-shadow: none; }
.card--dashed { border-style: dashed; background: transparent; box-shadow: none; }
.card--aura { border-color: transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--aura) border-box; border: 1px solid transparent; }
.card__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5) 0;
}
.card__header--bordered { padding-bottom: var(--s-4); border-bottom: 1px solid var(--border); }
.card__titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); display: flex; align-items: center; gap: var(--s-2); }
.card__desc { font-size: var(--fs-sm); color: var(--text-3); }
.card__actions { display: flex; gap: var(--s-1); align-items: center; flex: none; }
.card__body { padding: var(--s-4) var(--s-5) var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; flex: 1; }
.card__footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: var(--fs-sm); color: var(--text-3);
}
@media (max-width: 719px) {
  .card__header { padding: var(--s-4) var(--s-4) 0; }
  .card__body { padding: var(--s-3) var(--s-4) var(--s-4); }
  .card__footer { padding: var(--s-3) var(--s-4); }
}

/* ───────── Stat ───────── */
.stat-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.stat-strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.stat-strip > .stat { border: 0; border-radius: 0; box-shadow: none; }
.stat-strip > .stat + .stat { border-left: 1px solid var(--border); }
/* Six or more KPIs cannot share one row beside the sidebar; wrap them into rows of four. */
@media (min-width: 720px) and (max-width: 1279px) {
  .stat-strip:has(> .stat:nth-child(6)) { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-strip:has(> .stat:nth-child(6)) > .stat + .stat { border-left: 0; }
  .stat-strip:has(> .stat:nth-child(6)) > .stat:not(:nth-child(4n + 1)) { border-left: 1px solid var(--border); }
  .stat-strip:has(> .stat:nth-child(6)) > .stat:nth-child(n + 5) { border-top: 1px solid var(--border); }
}
@media (max-width: 719px) {
  .stat-strip { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > .stat + .stat { border-left: 0; }
  .stat-strip > .stat:nth-child(even) { border-left: 1px solid var(--border); }
  .stat-strip > .stat:nth-child(n + 3) { border-top: 1px solid var(--border); }
}
.stat {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.stat__label { display: flex; align-items: center; gap: var(--s-1-5); color: var(--text-3); font-size: var(--fs-sm); }
.stat__label svg { width: 14px; height: 14px; }
.stat__value { color: var(--text); font-size: var(--fs-2xl); line-height: var(--lh-2xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: var(--s-1-5); min-width: 0; }
.stat__unit { font-size: var(--fs-sm); color: var(--text-3); font-weight: var(--fw-medium); letter-spacing: 0; }
.stat__foot { display: flex; align-items: center; gap: var(--s-2); color: var(--text-3); font-size: var(--fs-xs); min-height: 16px; }
.stat__delta { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-medium); }
.stat__delta svg { width: 12px; height: 12px; }
.stat__delta--up { color: var(--success); }
.stat__delta--down { color: var(--danger); }
.stat__spark { margin-top: var(--s-1); height: 28px; }
.stat--compact { padding: var(--s-3) var(--s-4); }
.stat--compact .stat__value { font-size: var(--fs-xl); line-height: var(--lh-xl); }

/* ───────── Banner / Callout ───────── */
.banner {
  --bn-bg: var(--info-soft); --bn-line: var(--info-line); --bn-fg: var(--info);
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  background: var(--bn-bg);
  box-shadow: inset 0 0 0 1px var(--bn-line);
  color: var(--text-2);
  animation: drop-in var(--dur-base) var(--ease-out);
}
.banner__icon { color: var(--bn-fg); flex: none; margin-top: 1px; }
.banner__icon svg { width: 18px; height: 18px; }
.banner__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.banner__title { color: var(--text); font-weight: var(--fw-semibold); }
.banner__text { font-size: var(--fs-sm); color: var(--text-2); }
.banner__actions { display: flex; gap: var(--s-2); align-items: center; flex: none; flex-wrap: wrap; }
.banner--success { --bn-bg: var(--success-soft); --bn-line: var(--success-line); --bn-fg: var(--success); }
.banner--warning { --bn-bg: var(--warning-soft); --bn-line: var(--warning-line); --bn-fg: var(--warning); }
.banner--danger { --bn-bg: var(--danger-soft); --bn-line: var(--danger-line); --bn-fg: var(--danger); }
.banner--neutral { --bn-bg: var(--surface-2); --bn-line: var(--border); --bn-fg: var(--text-3); }
.banner--aura { --bn-bg: transparent; --bn-line: var(--accent-line); --bn-fg: var(--accent-text); background: var(--aura-soft); }
@media (max-width: 719px) { .banner { flex-wrap: wrap; } .banner__actions { width: 100%; padding-left: 30px; } }

/* ───────── Progress / Meter ───────── */
.progress { position: relative; height: 6px; border-radius: var(--r-full); background: var(--surface-sunken); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.progress__bar { height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--dur-slower) var(--ease-out); }
.progress--success .progress__bar { background: var(--success-solid); }
.progress--warning .progress__bar { background: var(--warning-solid); }
.progress--danger .progress__bar { background: var(--danger-solid); }
.progress--aura .progress__bar { background: var(--aura); }
.progress--indeterminate .progress__bar { width: 40% !important; animation: indeterminate 1.2s var(--ease-in-out) infinite; }
.progress--sm { height: 4px; }
.meter { display: flex; flex-direction: column; gap: var(--s-1-5); }
.meter__row { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-sm); }
.meter__label { color: var(--text-2); }
.meter__value { color: var(--text); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.ring { transform: rotate(-90deg); }
.ring__track { stroke: var(--surface-sunken); }
.ring__bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset var(--dur-slower) var(--ease-out); }

/* ───────── Skeleton ───────── */
.skeleton {
  display: block;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-sunken) 0, var(--border) 50%, var(--surface-sunken) 100%) var(--surface-sunken);
  background-size: 240px 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.3s linear infinite;
  min-height: 12px;
}
.skeleton--text { height: 12px; }
.skeleton--circle { border-radius: 50%; }

/* ───────── Empty / Error states ───────── */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3);
  padding: var(--s-12) var(--s-6);
  text-align: center;
  animation: rise-in var(--dur-slow) var(--ease-out);
}
.state--compact { padding: var(--s-8) var(--s-4); }
.state__art {
  position: relative; display: grid; place-items: center;
  width: 56px; height: 56px; margin-bottom: var(--s-1);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--border);
  color: var(--text-3);
}
.state__art::before {
  content: ""; position: absolute; inset: -14px; z-index: -1;
  border-radius: 24px;
  background: radial-gradient(closest-side, var(--accent-soft-2), transparent);
  opacity: 0.8;
}
.state__art svg { width: 24px; height: 24px; }
.state__art--danger { color: var(--danger); }
.state__art--danger::before { background: radial-gradient(closest-side, var(--danger-soft), transparent); }
.state__art--aura { background: var(--aura); color: #fff; box-shadow: var(--aura-glow); border-radius: 46% 46% 42% 42% / 52% 52% 40% 40%; }
.state__title { color: var(--text); font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-snug); }
.state__text { max-width: 440px; color: var(--text-3); font-size: var(--fs-md); }
.state__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; margin-top: var(--s-2); }

/* ───────── Description list ───────── */
.dl { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: 0; margin: 0; }
.dl > dt, .dl > dd { padding: var(--s-2-5) 0; border-top: 1px solid var(--border); margin: 0; font-size: var(--fs-md); }
.dl > dt:first-of-type, .dl > dt:first-of-type + dd { border-top: 0; }
.dl > dt { color: var(--text-3); padding-right: var(--s-4); }
.dl > dd { color: var(--text); min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.dl--compact > dt, .dl--compact > dd { padding: var(--s-1-5) 0; font-size: var(--fs-sm); }
.dl--stacked { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: var(--s-4) var(--s-6); }
.dl--stacked > div { display: flex; flex-direction: column; gap: 2px; }
.dl--stacked dt { color: var(--text-3); font-size: var(--fs-xs); }
.dl--stacked dd { margin: 0; color: var(--text); font-weight: var(--fw-medium); overflow-wrap: anywhere; }
@media (max-width: 519px) {
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl > dd { border-top: 0; padding-top: 0; }
  .dl > dt { padding-bottom: 2px; }
}

/* ───────── Code ───────── */
.code-inline { font-family: var(--font-mono); font-size: 0.86em; padding: 1px 5px; border-radius: 4px; background: var(--surface-sunken); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); overflow-wrap: anywhere; }
.code-block {
  position: relative;
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
  min-width: 0;
}
.code-block__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-1-5) var(--s-2) var(--s-1-5) var(--s-3); border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-3); }
.code-block pre {
  margin: 0; padding: var(--s-3) var(--s-4);
  overflow: auto; max-height: var(--code-max-h, 420px);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; color: var(--text);
  tab-size: 2;
}
.code-block__copy { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity var(--dur-fast); }
.code-block:hover .code-block__copy, .code-block:focus-within .code-block__copy { opacity: 1; }
.code-block__head + pre + .code-block__copy { display: none; }
@media (hover: none) { .code-block__copy { opacity: 1; } }
.tok-key { color: var(--accent-text); }
.tok-str { color: var(--success); }
.tok-num { color: var(--warning); }
.tok-bool { color: var(--viz-4); }
.tok-null { color: var(--text-4); }
.tok-com { color: var(--text-4); font-style: italic; }

.copy-btn[data-copied="true"] { color: var(--success) !important; }
.copy-inline { display: inline-flex; align-items: center; gap: var(--s-1); max-width: 100%; min-width: 0; }
.copy-inline__btn { opacity: 0; transition: opacity var(--dur-fast); }
.copy-inline:hover .copy-inline__btn, .copy-inline:focus-within .copy-inline__btn, tr:hover .copy-inline__btn { opacity: 1; }
@media (hover: none) { .copy-inline__btn { opacity: 1; } }

/* ───────── Tabs ───────── */
.tabs { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.tablist {
  position: relative; display: flex; gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
  min-width: 0;
}
.tablist::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--s-1-5);
  height: 38px; padding: 0 var(--s-2-5);
  color: var(--text-3);
  font-size: var(--fs-md); font-weight: var(--fw-medium);
  white-space: nowrap;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: color var(--dur-fast);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab:disabled { opacity: 0.4; }
.tab:focus-visible { box-shadow: var(--focus-ring-inset); }
.tab svg { width: 15px; height: 15px; }
.tab .count-badge { height: 17px; min-width: 17px; }
.tablist__indicator {
  position: absolute; bottom: -1px; left: 0; height: 2px;
  background: var(--text);
  border-radius: 2px 2px 0 0;
  transition: transform var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out);
}
.tabpanel { min-width: 0; animation: fade-in var(--dur-base) var(--ease-out); }
.tabpanel:focus-visible { box-shadow: none; }
.tablist--pill { border-bottom: 0; gap: 2px; }
.tablist--pill .tab { height: 30px; border-radius: var(--r-md); padding: 0 var(--s-2-5); font-size: var(--fs-sm); }
.tablist--pill .tab[aria-selected="true"] { background: var(--surface-sunken); }
.tablist--pill .tablist__indicator { display: none; }

/* ───────── Breadcrumbs ───────── */
.crumbs { display: flex; align-items: center; gap: var(--s-1); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-3); min-width: 0; }
.crumbs a { color: var(--text-3); border-radius: var(--r-xs); padding: 1px 3px; margin: -1px -3px; }
.crumbs a:hover { color: var(--text); text-decoration: none; background: var(--surface-sunken); }
.crumbs__sep { color: var(--text-4); display: inline-flex; }
.crumbs__sep svg { width: 13px; height: 13px; }
.crumbs [aria-current="page"] { color: var(--text-2); font-weight: var(--fw-medium); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── Stepper (wizard) ───────── */
.steps { display: flex; gap: 0; align-items: flex-start; counter-reset: step; }
.step { flex: 1; display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; position: relative; padding-right: var(--s-3); text-align: left; }
.step__rail { display: flex; align-items: center; gap: var(--s-2); }
.step__dot {
  flex: none; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); color: var(--text-3);
  box-shadow: inset 0 0 0 1.5px var(--border-control);
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
  transition: background var(--dur-base), box-shadow var(--dur-base), color var(--dur-base);
}
.step__dot svg { width: 12px; height: 12px; stroke-width: 3; }
.step__line { flex: 1; height: 1.5px; background: var(--border-strong); border-radius: 2px; overflow: hidden; }
.step__line::after { content: ""; display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--dur-slower) var(--ease-out); }
.step:last-child .step__line { display: none; }
.step__label { font-size: var(--fs-sm); color: var(--text-3); font-weight: var(--fw-medium); }
.step__desc { font-size: var(--fs-xs); color: var(--text-4); }
.step[data-state="current"] .step__dot { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft-2); }
.step[data-state="current"] .step__label { color: var(--text); }
.step[data-state="done"] .step__dot { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--accent-line); }
.step[data-state="done"] .step__line::after { width: 100%; }
.step[data-state="done"] .step__label { color: var(--text-2); }
.step[data-state="failed"] .step__dot { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger-line); }
button.step:not(:disabled):hover .step__label { color: var(--text); }
button.step:disabled { cursor: default; }
.steps-compact { display: none; flex-direction: column; gap: var(--s-2); }
.steps-compact__label { font-size: var(--fs-sm); color: var(--text-2); }
.steps-compact__label b { color: var(--text); }
@media (max-width: 719px) {
  .steps--collapsible .steps { display: none; }
  .steps--collapsible .steps-compact { display: flex; }
}

/* ───────── Timeline ───────── */
.timeline { position: relative; display: flex; flex-direction: column; }
.timeline__item { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s-3); padding-bottom: var(--s-4); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before { content: ""; position: absolute; left: 11.5px; top: 22px; bottom: -2px; width: 1px; background: var(--border-strong); }
.timeline__item:last-child::before { display: none; }
.timeline__marker { position: relative; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--text-3); }
.timeline__marker svg { width: 13px; height: 13px; }
.timeline__marker--success { color: var(--success); box-shadow: inset 0 0 0 1px var(--success-line); background: var(--success-soft); }
.timeline__marker--danger { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-line); background: var(--danger-soft); }
.timeline__marker--warning { color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning-line); background: var(--warning-soft); }
.timeline__marker--accent { color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); background: var(--accent-soft); }
.timeline__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 2px; }
.timeline__title { color: var(--text); font-size: var(--fs-md); }
.timeline__meta { color: var(--text-3); font-size: var(--fs-xs); display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

/* ───────── Disclosure / Accordion ───────── */
.disclosure { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.disclosure + .disclosure { margin-top: var(--s-2); }
.disclosure--plain { border: 0; background: transparent; border-radius: 0; }
.disclosure__trigger {
  display: flex; align-items: center; gap: var(--s-2); width: 100%;
  padding: var(--s-3) var(--s-4);
  color: var(--text); font-weight: var(--fw-medium); text-align: left;
  border-radius: var(--r-lg);
}
.disclosure--plain .disclosure__trigger { padding: var(--s-2) 0; color: var(--text-2); font-size: var(--fs-sm); }
.disclosure__trigger:hover { color: var(--text); }
.disclosure__chev { color: var(--text-3); transition: transform var(--dur-base) var(--ease-out); flex: none; }
.disclosure__chev svg { width: 15px; height: 15px; }
.disclosure[data-open="true"] > .disclosure__trigger .disclosure__chev { transform: rotate(90deg); }
.disclosure__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-slow) var(--ease-out); }
.disclosure[data-open="true"] > .disclosure__panel { grid-template-rows: 1fr; }
.disclosure__inner { overflow: hidden; min-height: 0; }
.disclosure__content { padding: 0 var(--s-4) var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.disclosure--plain .disclosure__content { padding: var(--s-1) 0 var(--s-2); }

/* ───────── Tooltip ───────── */
.tooltip {
  position: fixed; z-index: var(--z-tooltip);
  max-width: 280px; padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-inverse); color: var(--text-inverse);
  font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: var(--fw-medium);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  animation: fade-in var(--dur-fast) var(--ease-out);
}
.tooltip kbd { margin-left: 6px; background: transparent; color: inherit; opacity: 0.7; box-shadow: inset 0 0 0 1px currentColor; }
/* overlays.css — dialog, sheet, popover, menu, toast, combobox, date picker, command palette. */

/* ───────── Scrim ───────── */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-dialog);
  background: var(--overlay);
  backdrop-filter: blur(2px);
  animation: fade-in var(--dur-slow) var(--ease-out);
}
.scrim[data-state="closing"] { animation: fade-out var(--dur-base) var(--ease-in) forwards; }

/* ───────── Dialog — top-anchored so height changes never make it jump ───────── */
.dialog-wrap {
  position: fixed; inset: 0; z-index: var(--z-dialog);
  display: flex; justify-content: center; align-items: flex-start;
  padding: min(12vh, 96px) var(--s-4) var(--s-4);
  overflow-y: auto;
}
.dialog {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; max-width: var(--dialog-w, 520px);
  max-height: calc(100dvh - min(12vh, 96px) - var(--s-4));
  background: var(--surface-raised);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl), var(--ring-hairline);
  animation: dialog-in var(--dur-slow) var(--ease-out);
}
.dialog[data-state="closing"] { animation: dialog-out var(--dur-base) var(--ease-in) forwards; }
.dialog--sm { --dialog-w: 420px; }
.dialog--lg { --dialog-w: 680px; }
.dialog--xl { --dialog-w: 880px; }
.dialog__header { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-3); }
.dialog__icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.dialog__icon svg { width: 18px; height: 18px; }
.dialog__icon--danger { background: var(--danger-soft); color: var(--danger); }
.dialog__icon--warning { background: var(--warning-soft); color: var(--warning); }
.dialog__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 2px; }
.dialog__title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold); color: var(--text); letter-spacing: var(--tracking-snug); }
.dialog__desc { color: var(--text-3); font-size: var(--fs-md); }
.dialog__close { flex: none; margin: -4px -6px 0 0; }
.dialog__body { padding: var(--s-2) var(--s-5) var(--s-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-4); min-height: 0; }
.dialog__footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.dialog__footer-start { margin-right: auto; display: flex; gap: var(--s-2); align-items: center; font-size: var(--fs-sm); color: var(--text-3); }
@media (max-width: 719px) {
  .dialog-wrap { padding: 0; align-items: flex-end; }
  .dialog { max-width: 100%; max-height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; animation: sheet-in-bottom var(--dur-slow) var(--ease-out); padding-bottom: env(safe-area-inset-bottom); }
  .dialog[data-state="closing"] { animation: sheet-out-bottom var(--dur-base) var(--ease-in) forwards; }
  .dialog::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto -4px; }
  .dialog__footer { border-radius: 0; flex-direction: column-reverse; align-items: stretch; }
  .dialog__footer .btn { width: 100%; }
  .dialog__footer-start { margin: 0; justify-content: center; }
}
@keyframes sheet-out-bottom { from { transform: none; } to { transform: translateY(100%); } }
.confirm-phrase { font-family: var(--font-mono); font-size: 0.92em; color: var(--text); background: var(--surface-sunken); padding: 1px 5px; border-radius: 4px; user-select: all; }

/* ───────── Sheet (side panel) ───────── */
.sheet {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: var(--z-dialog);
  display: flex; flex-direction: column;
  width: min(var(--sheet-w), 100vw);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl), var(--ring-hairline);
  animation: sheet-in-right var(--dur-slow) var(--ease-out);
}
.sheet[data-state="closing"] { animation: sheet-out-right var(--dur-base) var(--ease-in) forwards; }
.sheet--wide { width: min(var(--sheet-w-wide), 100vw); }
.sheet--left { right: auto; left: 0; animation-name: sheet-in-left; }
.sheet--left[data-state="closing"] { animation-name: sheet-out-left; }
.sheet--bottom { top: auto; left: 0; width: 100%; max-height: 88dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; animation-name: sheet-in-bottom; padding-bottom: env(safe-area-inset-bottom); }
.sheet--bottom[data-state="closing"] { animation-name: sheet-out-bottom; }
.sheet__header { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); flex: none; }
.sheet__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sheet__eyebrow { font-size: var(--fs-xs); color: var(--text-3); display: flex; gap: var(--s-2); align-items: center; }
.sheet__title { font-size: var(--fs-lg); line-height: var(--lh-lg); color: var(--text); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-snug); overflow-wrap: anywhere; }
.sheet__header-actions { display: flex; gap: var(--s-1); flex: none; }
.sheet__body { flex: 1; overflow-y: auto; padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-5); min-height: 0; }
.sheet__body--flush { padding: 0; gap: 0; }
.sheet__footer { flex: none; display: flex; gap: var(--s-2); justify-content: flex-end; padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); background: var(--surface-2); }
.sheet__section { display: flex; flex-direction: column; gap: var(--s-3); }
.sheet__section-title { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
@media (max-width: 719px) {
  .sheet:not(.sheet--left) { width: 100vw; }
  .sheet__footer { padding-bottom: calc(var(--s-3) + env(safe-area-inset-bottom)); }
}

/* ───────── Popover / Menu surfaces ───────── */
.popover {
  position: fixed; z-index: var(--z-popover);
  min-width: 200px; max-width: min(420px, calc(100vw - 16px));
  background: var(--surface-raised);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), var(--ring-hairline);
  animation: drop-in var(--dur-base) var(--ease-out);
  transform-origin: top left;
  overflow: hidden;
}
.popover[data-side="top"] { animation-name: rise-in; }
.popover[data-state="closing"] { animation: fade-out var(--dur-fast) var(--ease-in) forwards; }
.popover__header { padding: var(--s-3) var(--s-4) var(--s-2); display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.popover__title { font-weight: var(--fw-semibold); color: var(--text); font-size: var(--fs-md); }
.popover__body { padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.popover__footer { padding: var(--s-2) var(--s-3); border-top: 1px solid var(--border); display: flex; gap: var(--s-2); justify-content: flex-end; background: var(--surface-2); }

.menu { padding: var(--s-1); display: flex; flex-direction: column; max-height: min(420px, 70vh); overflow-y: auto; }
.menu__item {
  display: flex; align-items: center; gap: var(--s-2-5);
  min-height: 32px; padding: 0 var(--s-2-5);
  border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--fs-md); text-align: left;
  width: 100%;
  cursor: pointer;
  user-select: none;
}
.menu__item svg { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.menu__item:hover, .menu__item[data-active="true"] { background: var(--surface-sunken); color: var(--text); text-decoration: none; }
.menu__item:focus-visible { box-shadow: var(--focus-ring-inset); }
.menu__item[aria-disabled="true"], .menu__item:disabled { opacity: 0.45; pointer-events: none; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger svg { color: var(--danger); }
.menu__item--danger:hover, .menu__item--danger[data-active="true"] { background: var(--danger-soft); color: var(--danger); }
.menu__item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu__item-desc { display: block; font-size: var(--fs-xs); color: var(--text-3); white-space: normal; }
.menu__item-meta { margin-left: auto; color: var(--text-4); font-size: var(--fs-xs); display: flex; gap: 3px; align-items: center; }
.menu__check { width: 15px; flex: none; color: var(--accent); }
.menu__sep { height: 1px; background: var(--border); margin: var(--s-1) calc(var(--s-1) * -1); }
.menu__label { padding: var(--s-2) var(--s-2-5) var(--s-1); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-4); }
@media (pointer: coarse) { .menu__item { min-height: 40px; } }

/* ───────── Toasts ───────── */
.toaster {
  position: fixed; z-index: var(--z-toast);
  right: var(--s-4); bottom: var(--s-4);
  display: flex; flex-direction: column-reverse; gap: var(--s-2);
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--s-2-5);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-3-5, 14px);
  border-radius: var(--r-lg);
  background: var(--surface-inverse); color: var(--text-inverse);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-slow) var(--ease-out);
  position: relative; overflow: hidden;
}
.toast[data-state="closing"] { animation: toast-out var(--dur-base) var(--ease-in) forwards; }
.toast__icon { flex: none; margin-top: 1px; }
.toast__icon svg { width: 17px; height: 17px; }
.toast--success .toast__icon { color: #5ad19a; }
.toast--danger .toast__icon { color: #ff8a8a; }
.toast--warning .toast__icon { color: #ffc56b; }
.toast--info .toast__icon { color: #8fc1ff; }
.toast__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toast__title { font-weight: var(--fw-medium); font-size: var(--fs-md); color: inherit; }
.toast__text { font-size: var(--fs-sm); opacity: 0.72; }
.toast__action { flex: none; align-self: center; color: #b9b3ff; font-weight: var(--fw-medium); font-size: var(--fs-sm); padding: 4px 6px; border-radius: var(--r-sm); }
.toast__action:hover { background: rgba(255, 255, 255, 0.08); }
.toast__close { flex: none; color: inherit; opacity: 0.5; width: 22px; height: 22px; display: grid; place-items: center; border-radius: var(--r-sm); }
.toast__close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.toast__close svg { width: 14px; height: 14px; }
.toast__timer { position: absolute; left: 0; bottom: 0; height: 2px; background: rgba(255, 255, 255, 0.28); transform-origin: left; animation: toast-timer linear forwards; }
.toast:hover .toast__timer { animation-play-state: paused; }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
html[data-theme="dark"] .toast { background: var(--gray-800); box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
@media (max-width: 719px) {
  .toaster { left: var(--s-3); right: var(--s-3); bottom: calc(64px + env(safe-area-inset-bottom)); width: auto; }
}

/* ───────── Combobox listbox ───────── */
.listbox { padding: var(--s-1); max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; }
.listbox__search { padding: var(--s-2); border-bottom: 1px solid var(--border); }
.option {
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 32px; padding: 4px var(--s-2-5);
  border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer;
  user-select: none;
}
.option[data-active="true"] { background: var(--surface-sunken); color: var(--text); }
.option[aria-selected="true"] { color: var(--text); font-weight: var(--fw-medium); }
.option[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.option__check { margin-left: auto; color: var(--accent); flex: none; }
.option__check svg { width: 15px; height: 15px; }
.option__desc { font-size: var(--fs-xs); color: var(--text-3); font-weight: var(--fw-regular); }
.option__main { display: flex; flex-direction: column; min-width: 0; }
.option mark { background: transparent; color: var(--accent-text); font-weight: var(--fw-semibold); }
.listbox__empty { padding: var(--s-6) var(--s-3); text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.listbox__group { padding: var(--s-2) var(--s-2-5) 2px; font-size: var(--fs-2xs); color: var(--text-4); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
@media (pointer: coarse) { .option { min-height: 40px; } }

/* ───────── Date range picker ───────── */
.drp { display: grid; grid-template-columns: 150px auto; }
.drp__presets { display: flex; flex-direction: column; padding: var(--s-2); border-right: 1px solid var(--border); gap: 1px; }
.drp__preset { text-align: left; padding: 6px var(--s-2-5); border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-sm); }
.drp__preset:hover { background: var(--surface-sunken); color: var(--text); }
.drp__preset[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-medium); }
.drp__cal { padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.cal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.cal__month { font-weight: var(--fw-semibold); color: var(--text); font-size: var(--fs-md); }
.cal__grid { display: grid; grid-template-columns: repeat(7, 34px); gap: 2px 0; }
.cal__dow { font-size: var(--fs-2xs); color: var(--text-4); text-align: center; padding: 4px 0; font-weight: var(--fw-medium); }
.cal__day { height: 32px; font-size: var(--fs-sm); color: var(--text-2); border-radius: var(--r-sm); position: relative; font-variant-numeric: tabular-nums; }
.cal__day:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }
.cal__day[data-outside="true"] { color: var(--text-4); }
.cal__day:disabled { color: var(--text-4); opacity: 0.5; cursor: not-allowed; }
.cal__day[data-today="true"]::after { content: ""; position: absolute; bottom: 4px; left: 50%; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--accent); }
.cal__day[data-in-range="true"] { background: var(--accent-soft); color: var(--accent-text); border-radius: 0; }
.cal__day[data-start="true"], .cal__day[data-end="true"] { background: var(--accent); color: #fff; font-weight: var(--fw-semibold); }
.cal__day[data-start="true"] { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.cal__day[data-end="true"] { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.cal__day[data-start="true"][data-end="true"] { border-radius: var(--r-sm); }
.drp__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }
@media (max-width: 519px) {
  .drp { grid-template-columns: 1fr; }
  .drp__presets { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .cal__grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

/* ───────── Command palette ───────── */
.cmdk-wrap { position: fixed; inset: 0; z-index: var(--z-dialog); display: flex; justify-content: center; align-items: flex-start; padding: min(14vh, 120px) var(--s-4) var(--s-4); }
.cmdk {
  width: 100%; max-width: 640px;
  background: var(--surface-raised);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl), var(--ring-hairline);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: min(560px, 76dvh);
  animation: dialog-in var(--dur-slow) var(--ease-out);
}
.cmdk[data-state="closing"] { animation: dialog-out var(--dur-base) var(--ease-in) forwards; }
.cmdk__search { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); height: 54px; border-bottom: 1px solid var(--border); flex: none; }
.cmdk__search svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.cmdk__input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: var(--fs-lg); color: var(--text); }
.cmdk__input::placeholder { color: var(--text-4); }
.cmdk__input:focus-visible { box-shadow: none; }
.cmdk__scope { font-size: var(--fs-xs); }
.cmdk__list { flex: 1; overflow-y: auto; padding: var(--s-2); min-height: 0; }
.cmdk__group { padding: var(--s-2) var(--s-2-5) var(--s-1); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-4); }
.cmdk__item { display: flex; align-items: center; gap: var(--s-3); min-height: 42px; padding: 0 var(--s-2-5); border-radius: var(--r-md); cursor: pointer; color: var(--text-2); width: 100%; text-align: left; }
.cmdk__item[data-active="true"] { background: var(--surface-sunken); color: var(--text); }
.cmdk__item-icon { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--text-3); }
.cmdk__item[data-active="true"] .cmdk__item-icon { color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); background: var(--accent-soft); }
.cmdk__item-icon svg { width: 15px; height: 15px; }
.cmdk__item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cmdk__item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk__item-title mark { background: transparent; color: var(--accent-text); font-weight: var(--fw-semibold); }
.cmdk__item-desc { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk__item-meta { flex: none; color: var(--text-4); font-size: var(--fs-xs); display: flex; align-items: center; gap: var(--s-2); }
.cmdk__enter { opacity: 0; transition: opacity var(--dur-fast); }
.cmdk__item[data-active="true"] .cmdk__enter { opacity: 1; }
.cmdk__foot { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-3); flex: none; }
.cmdk__foot span { display: inline-flex; align-items: center; gap: var(--s-1); }
@media (max-width: 719px) {
  .cmdk-wrap { padding: var(--s-2); }
  .cmdk { max-height: calc(100dvh - 16px); }
  .cmdk__foot { display: none; }
}

/* Multi-select option checkbox */
.option .check__box { display: grid; place-items: center; flex: none; border-radius: 4px; border: 1.5px solid var(--border-control); background: var(--surface); color: #fff; transition: background var(--dur-fast), border-color var(--dur-fast); }
.option .check__box[data-checked="true"] { background: var(--accent); border-color: var(--accent); }
.option .check__box svg { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
.listbox:focus-visible { box-shadow: none; }

/* Flush sheets: tabs pinned under the header, padded tab panels below. */
.sheet__tabs { position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 0 var(--s-5); border-bottom: 1px solid var(--border); }
.sheet__tabs .tabs { border-bottom: 0; }
.sheet__pad { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-5); animation: fade-in var(--dur-base) var(--ease-out); }
/* Panels receive programmatic focus on open (see use-focus-trap); they are not interactive targets themselves. */
.dialog:focus, .sheet:focus { outline: none; }
/* data.css — page header, sections, toolbar, filter bar, data table, pagination, tree, charts, list rows. */

/* ───────── Page layout ───────── */
.page { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s-6) var(--gutter) var(--s-16); display: flex; flex-direction: column; gap: var(--s-6); min-width: 0; }
.page--narrow { max-width: calc(var(--content-narrow) + var(--gutter) * 2); }
.page--full { max-width: none; }
.page--flush { padding: 0; gap: 0; max-width: none; height: calc(100dvh - var(--topbar-h)); }
.page-header { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.page-header__row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.page-header__titles { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; flex: 1 1 320px; }
.page-header__title { display: flex; align-items: center; gap: var(--s-2-5); flex-wrap: wrap; font-size: var(--fs-2xl); line-height: var(--lh-2xl); letter-spacing: var(--tracking-tight); }
.page-header__desc { color: var(--text-3); font-size: var(--fs-md); max-width: 720px; }
.page-header__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.page-header__meta { display: flex; gap: var(--s-4); flex-wrap: wrap; color: var(--text-3); font-size: var(--fs-sm); align-items: center; }
.page-header__meta > span { display: inline-flex; align-items: center; gap: var(--s-1-5); }
.page-header__meta svg { width: 14px; height: 14px; }
@media (max-width: 719px) {
  .page { padding: var(--s-4) var(--gutter) calc(var(--s-16) + 40px); gap: var(--s-5); }
  .page-header__title { font-size: var(--fs-xl); line-height: var(--lh-xl); }
  .page-header__actions { width: 100%; }
  .page-header__actions > .btn--primary { flex: 1; }
  /* Icon-only actions (e.g. a lone ⋯ menu) stay beside the title instead of wrapping onto an empty row. */
  .page-header__row:has(> .page-header__actions .btn--icon):not(:has(> .page-header__actions .btn:not(.btn--icon))) { flex-wrap: nowrap; }
  .page-header__row:has(> .page-header__actions .btn--icon):not(:has(> .page-header__actions .btn:not(.btn--icon))) .page-header__titles { flex-basis: 0; }
  .page-header__actions:not(:has(.btn:not(.btn--icon))) { width: auto; flex-shrink: 0; }
}

.section { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.section__head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.section__titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.section__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); display: flex; align-items: center; gap: var(--s-2); }
.section__desc { font-size: var(--fs-sm); color: var(--text-3); }
.eyebrow { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-3); }

/* Two-pane page: settings nav + content, or list + detail */
.split { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.split__nav { position: sticky; top: calc(var(--topbar-h) + var(--s-6)); display: flex; flex-direction: column; gap: 1px; }
.split__nav a, .split__nav button { display: flex; align-items: center; gap: var(--s-2); padding: 6px var(--s-2-5); border-radius: var(--r-md); color: var(--text-2); font-size: var(--fs-md); text-align: left; }
.split__nav a:hover, .split__nav button:hover { background: var(--surface-sunken); color: var(--text); text-decoration: none; }
.split__nav [aria-current="true"], .split__nav [aria-current="page"] { background: var(--surface); color: var(--text); font-weight: var(--fw-medium); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border); }
.split__nav svg { width: 15px; height: 15px; color: var(--text-3); }
@media (max-width: 1023px) {
  .split { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .split__nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: var(--s-1); padding-bottom: 2px; }
  .split__nav a, .split__nav button { white-space: nowrap; }
}

/* ───────── Toolbar / FilterBar ───────── */
.toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; min-width: 0; }
.toolbar__search { flex: 1 1 240px; max-width: 360px; min-width: 0; }
.toolbar__end { margin-left: auto; display: flex; gap: var(--s-2); align-items: center; }
.filterbar { display: flex; flex-direction: column; gap: var(--s-2); }
.filterbar__row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.filterbar__mobile { display: none; }
.filterbar__active { display: flex; align-items: center; gap: var(--s-1-5); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-3); }
@media (max-width: 719px) {
  .filterbar__desktop { display: none; }
  .filterbar__mobile { display: flex; flex-wrap: wrap; gap: var(--s-2); }
  .filterbar__mobile .toolbar__search { flex: 1 1 0; max-width: none; }
  /* Sort / page-size controls get their own row so search keeps its width */
  .filterbar__mobile-end { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-width: 0; }
  .filterbar__mobile-end > :last-child:not(.result-count) { margin-left: auto; }
  .toolbar__search { max-width: none; }
}
.result-count { font-size: var(--fs-sm); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ───────── Data table ───────── */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); overflow: hidden; min-width: 0; position: relative; }
.table-scroll { overflow-x: auto; }
.dt { width: 100%; font-size: var(--fs-md); }
.dt th {
  position: sticky; top: 0; z-index: 1;
  height: 36px; padding: 0 var(--s-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-3); font-size: var(--fs-xs); font-weight: var(--fw-medium);
  text-align: left; white-space: nowrap;
}
.dt th[data-align="right"], .dt td[data-align="right"] { text-align: right; }
.dt th[data-align="center"], .dt td[data-align="center"] { text-align: center; }
.dt td { height: 48px; padding: var(--row-pad-y, 8px) var(--s-3); border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
html[data-density="compact"] .dt td { height: 38px; }
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr { transition: background var(--dur-fast); }
.dt tbody tr[data-clickable="true"] { cursor: pointer; }
.dt tbody tr:hover { background: var(--surface-2); }
.dt tbody tr[data-selected="true"] { background: var(--accent-soft); }
.dt tbody tr[data-active="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.dt tbody tr:focus-visible { box-shadow: var(--focus-ring-inset); border-radius: 0; }
.dt__check { width: 40px; padding-right: 0 !important; }
.dt__actions { width: 48px; text-align: right; }
.dt__row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0.0; transition: opacity var(--dur-fast); }
.dt tbody tr:hover .dt__row-actions, .dt tbody tr:focus-within .dt__row-actions, .dt__row-actions[data-open="true"] { opacity: 1; }
@media (hover: none) { .dt__row-actions { opacity: 1; } }
.sort-btn { display: inline-flex; align-items: center; gap: 4px; color: inherit; font: inherit; margin: 0 -4px; padding: 2px 4px; border-radius: var(--r-xs); }
.sort-btn:hover { color: var(--text); }
.sort-btn:hover svg, .sort-btn:focus-visible svg { opacity: 0.5; }
.sort-btn svg { width: 12px; height: 12px; opacity: 0; transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-fast); }
.sort-btn[data-dir] svg { opacity: 1; color: var(--text); }
.sort-btn[data-dir="desc"] svg { transform: rotate(180deg); }
.cell-primary { display: flex; align-items: center; gap: var(--s-2-5); min-width: 0; }
.cell-primary__text { display: flex; flex-direction: column; min-width: 0; }
.cell-primary__title { color: var(--text); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-primary__sub { color: var(--text-3); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* An auto-layout table sizes a nowrap cell to its full text; let a primary cell with a sub line absorb the spare width and ellipsize instead. */
.dt td:has(.cell-primary__sub) { max-width: 0; width: 100%; }
.cell-muted { color: var(--text-3); white-space: nowrap; }
.cell-num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }

/* Bulk action bar floats in on selection */
.bulkbar {
  position: sticky; bottom: var(--s-4); z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s-2);
  width: fit-content; max-width: calc(100% - 16px);
  margin: var(--s-3) auto 0;
  padding: var(--s-1-5) var(--s-1-5) var(--s-1-5) var(--s-4);
  border-radius: var(--r-full);
  background: var(--surface-inverse); color: var(--text-inverse);
  box-shadow: var(--shadow-xl);
  animation: toast-in var(--dur-slow) var(--ease-out);
  font-size: var(--fs-sm);
}
.bulkbar .btn { --btn-fg: var(--text-inverse); }
.bulkbar .btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }
.bulkbar__count { font-weight: var(--fw-medium); white-space: nowrap; margin-right: var(--s-2); font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .bulkbar { background: var(--gray-800); box-shadow: var(--shadow-xl), inset 0 0 0 1px rgba(255, 255, 255, 0.08); }

/* Stacked rows on mobile — the table becomes a list of cards */
.dt-stack { display: none; }
@media (max-width: 719px) {
  .table-card[data-stack="true"] .table-scroll { display: none; }
  .table-card[data-stack="true"] .dt-stack { display: flex; flex-direction: column; }
}
.stack-row { display: flex; flex-direction: column; gap: var(--s-1-5); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); text-align: left; width: 100%; color: inherit; }
.stack-row:last-child { border-bottom: 0; }
.stack-row[data-clickable="true"]:active { background: var(--surface-2); }
.stack-row__top { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; min-width: 0; }
.stack-row__meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); color: var(--text-3); font-size: var(--fs-xs); }
.stack-row__meta b { color: var(--text-2); font-weight: var(--fw-medium); }

/* ───────── Pagination ───────── */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-3); flex-wrap: wrap; }
.pagination__pages { display: flex; align-items: center; gap: 2px; }
.page-btn { min-width: 28px; height: 28px; padding: 0 6px; border-radius: var(--r-sm); color: var(--text-2); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.page-btn:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }
.page-btn[aria-current="page"] { background: var(--surface-sunken); color: var(--text); font-weight: var(--fw-semibold); box-shadow: inset 0 0 0 1px var(--border-strong); }
.page-btn:disabled { opacity: 0.4; }
.page-btn svg { width: 14px; height: 14px; margin: 0 auto; }
@media (max-width: 519px) { .pagination__num { display: none; } }

/* ───────── List (non-tabular rows) ───────── */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); min-width: 0; color: inherit; text-align: left; width: 100%; transition: background var(--dur-fast); }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, button.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row__title { color: var(--text); font-weight: var(--fw-medium); display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.list-row__sub { color: var(--text-3); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__end { flex: none; display: flex; align-items: center; gap: var(--s-2); color: var(--text-3); font-size: var(--fs-sm); }
.icon-tile { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.icon-tile svg { width: 16px; height: 16px; }
.icon-tile--lg { width: 40px; height: 40px; border-radius: 11px; }
.icon-tile--lg svg { width: 20px; height: 20px; }
.icon-tile--accent { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); }
.icon-tile--success { background: var(--success-soft); color: var(--success); box-shadow: inset 0 0 0 1px var(--success-line); }
.icon-tile--warning { background: var(--warning-soft); color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning-line); }
.icon-tile--danger { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-line); }

/* ───────── Tree ───────── */
.tree { display: flex; flex-direction: column; font-size: var(--fs-md); }
.tree__item { display: flex; align-items: center; gap: var(--s-1-5); min-height: 30px; padding: 0 var(--s-2) 0 calc(var(--s-2) + var(--depth, 0) * 16px); border-radius: var(--r-sm); color: var(--text-2); cursor: pointer; user-select: none; width: 100%; text-align: left; }
.tree__item:hover { background: var(--surface-sunken); color: var(--text); }
.tree__item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-medium); }
.tree__item:focus-visible { box-shadow: var(--focus-ring-inset); }
.tree__chev { width: 16px; height: 16px; display: grid; place-items: center; color: var(--text-4); flex: none; transition: transform var(--dur-base) var(--ease-out); }
.tree__chev svg { width: 13px; height: 13px; }
.tree__item[aria-expanded="true"] .tree__chev { transform: rotate(90deg); }
.tree__icon { color: var(--text-3); flex: none; }
.tree__icon svg { width: 15px; height: 15px; }
.tree__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree__meta { color: var(--text-4); font-size: var(--fs-xs); flex: none; }

/* ───────── Charts ───────── */
.chart { position: relative; width: 100%; min-width: 0; }
.chart svg { overflow: visible; width: 100%; height: 100%; }
.chart__grid line { stroke: var(--viz-grid); stroke-width: 1; }
.chart__axis text { fill: var(--text-4); font-size: 10.5px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; animation: draw-unit 900ms var(--ease-out) both; }
@keyframes draw-unit { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.chart__area { opacity: 0.14; animation: fade-in 700ms var(--ease-out) both; }
.chart__bar { transform-box: fill-box; transform-origin: bottom; animation: bar-grow 520ms var(--ease-out) both; }
.chart__bar:hover { filter: brightness(1.08); }
.chart__cursor { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart__dot { stroke: var(--surface); stroke-width: 2; }
.chart__tip {
  position: absolute; z-index: 2; pointer-events: none;
  min-width: 140px; padding: var(--s-2) var(--s-2-5);
  border-radius: var(--r-md);
  background: var(--surface-raised); box-shadow: var(--shadow-lg), var(--ring-hairline);
  font-size: var(--fs-xs); color: var(--text-2);
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap;
  transition: left 60ms linear, top 60ms linear;
}
.chart__tip-title { color: var(--text-3); margin-bottom: 4px; }
.chart__tip-row { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; }
.chart__tip-row b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-1-5) var(--s-4); font-size: var(--fs-xs); color: var(--text-3); }
.legend__item { display: inline-flex; align-items: center; gap: var(--s-1-5); }
.legend__item button { display: inline-flex; align-items: center; gap: var(--s-1-5); color: inherit; }
.legend__item[data-off="true"] { opacity: 0.4; }
.legend__swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.donut__seg { transition: opacity var(--dur-fast), stroke-width var(--dur-base) var(--ease-out); }
.donut:hover .donut__seg:not(:hover) { opacity: 0.45; }
.donut__center { font-size: var(--fs-xl); font-weight: var(--fw-semibold); fill: var(--text); font-family: var(--font-sans); }
.donut__center-sub { font-size: 10.5px; fill: var(--text-3); font-family: var(--font-sans); }
.spark { width: 100%; height: 100%; overflow: visible; }
.spark__line { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.spark__area { opacity: 0.12; }
.hbar { display: flex; flex-direction: column; gap: var(--s-2-5); }
.hbar__row { display: grid; grid-template-columns: minmax(80px, 32%) minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; font-size: var(--fs-sm); }
.hbar__label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__track { height: 8px; border-radius: 4px; background: var(--surface-sunken); overflow: hidden; }
.hbar__fill { height: 100%; border-radius: 4px; background: var(--viz-1); transform-origin: left; animation: hbar-grow 620ms var(--ease-out) both; }
.hbar__value { color: var(--text); font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); min-width: 48px; text-align: right; }
@keyframes hbar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.heat { display: grid; gap: 3px; }
.heat__cell { aspect-ratio: 1; border-radius: 3px; background: var(--accent); }
@media (max-width: 1023px) { .dt .hide-below-lg { display: none; } }
@media (max-width: 859px) { .dt .hide-below-md { display: none; } }
/* forms-advanced.css — secret field, key/value editor, dropzone, schedule builder, aura presence, chat composer bits. */

/* Key/value editor */
.kv { display: flex; flex-direction: column; gap: var(--s-2); }
.kv__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: var(--s-2); align-items: center; animation: rise-in var(--dur-base) var(--ease-out); }
.kv__head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 34px; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-3); }
@media (max-width: 519px) {
  .kv__head { display: none; }
  .kv__row { grid-template-columns: minmax(0, 1fr) auto; padding-bottom: var(--s-2); border-bottom: 1px dashed var(--border); }
  .kv__row > :nth-child(2) { grid-column: 1; grid-row: 2; }
  .kv__row > :nth-child(3) { grid-row: 1 / span 2; grid-column: 2; }
}

/* Dropzone */
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-8) var(--s-4);
  border: 1.5px dashed var(--border-control); border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text-3); text-align: center;
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-base) var(--ease-out);
}
.dropzone:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.dropzone:focus-visible { box-shadow: var(--focus-ring); }
.dropzone[data-drag="true"] { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.dropzone__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); color: var(--accent-text); }
.dropzone__icon svg { width: 20px; height: 20px; }
.dropzone__title { color: var(--text); font-weight: var(--fw-medium); }
.dropzone__title u { color: var(--accent-text); text-decoration: none; }
.file-list { display: flex; flex-direction: column; gap: var(--s-2); }
.file-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); animation: rise-in var(--dur-base) var(--ease-out); }
.file-item__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.file-item__name { color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item__meta { color: var(--text-3); font-size: var(--fs-xs); }

/* Schedule builder */
.schedule { display: flex; flex-direction: column; gap: var(--s-3); }
.schedule__days { display: flex; gap: 4px; flex-wrap: wrap; }
.day-toggle { width: 36px; height: 32px; border-radius: var(--r-md); border: 1px solid var(--border-control); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-instant); }
.day-toggle:active { transform: scale(0.95); }
.day-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.schedule__preview { display: flex; flex-direction: column; gap: var(--s-1-5); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); }
.schedule__human { color: var(--text); font-weight: var(--fw-medium); }
.schedule__runs { display: flex; flex-direction: column; gap: 2px; color: var(--text-3); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

/* Aura — agent presence. Only for agents / AI activity. */
.aura-orb {
  --orb: 40px;
  position: relative; flex: none;
  width: var(--orb); height: var(--orb);
  border-radius: 46% 46% 42% 42% / 52% 52% 40% 40%;
  background: var(--aura);
  box-shadow: inset 0 -3px 8px rgba(20, 10, 80, 0.3), inset 0 3px 6px rgba(255, 255, 255, 0.3), var(--aura-glow);
  display: grid; place-items: center;
}
.aura-orb[data-state="thinking"] { animation: aura-breathe 1.6s var(--ease-in-out) infinite; }
.aura-orb[data-state="idle"] { box-shadow: inset 0 -3px 8px rgba(20, 10, 80, 0.3), inset 0 3px 6px rgba(255, 255, 255, 0.3); }
.aura-orb svg { width: 60%; height: 60%; }
.aura-orb__eye { transform-origin: center; animation: blink 5s infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
.aura-text { background: var(--aura); -webkit-background-clip: text; background-clip: text; color: transparent; }
.typing { display: inline-flex; gap: 3px; align-items: center; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: typing-dot 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.caret { display: inline-block; width: 2px; height: 1em; background: var(--accent); vertical-align: text-bottom; margin-left: 1px; animation: caret-blink 1s steps(1) infinite; }

/* Secret field reveal */
.secret-dots { letter-spacing: 0.12em; }
/* content.css — markdown renderer and viewer, file browser, access grants, activity log. */

/* ───────── Markdown ───────── */
.md { display: flex; flex-direction: column; gap: var(--s-3); color: var(--text); line-height: var(--lh-md); min-width: 0; overflow-wrap: anywhere; }
.md__h { margin: var(--s-2) 0 0; font-weight: var(--fw-semibold); letter-spacing: -0.01em; line-height: 1.3; }
.md > .md__h:first-child, .md__meta + .md__h { margin-top: 0; }
.md__h1 { font-size: var(--fs-xl); }
.md__h2 { font-size: var(--fs-lg); padding-bottom: var(--s-1-5); border-bottom: 1px solid var(--border); }
.md__h3, .md__h4, .md__h5, .md__h6 { font-size: var(--fs-md); }
.md__p { margin: 0; }
.md__list { margin: 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-1); list-style: disc; }
ol.md__list { list-style: decimal; }
.md__list li::marker { color: var(--text-3); }
.md__task { list-style: none; margin-left: calc(var(--s-5) * -1); display: flex; gap: var(--s-2); align-items: baseline; }
.md__check { flex: none; width: 14px; height: 14px; border-radius: var(--r-xs); border: 1px solid var(--border-control); transform: translateY(2px); }
.md__task[data-done="true"] .md__check { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--surface); }
.md__task[data-done="true"] { color: var(--text-3); text-decoration: line-through; }
.md__quote { margin: 0; padding: var(--s-2) var(--s-3); border-left: 3px solid var(--accent-line); background: var(--surface-2); border-radius: 0 var(--r-md) var(--r-md) 0; color: var(--text-2); }
.md__hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-1) 0; }
.md a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.md__table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.md__table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.md__table th, .md__table td { padding: var(--s-2) var(--s-3); text-align: left; border-bottom: 1px solid var(--border); }
.md__table th { background: var(--surface-2); font-weight: var(--fw-semibold); }
.md__table tr:last-child td { border-bottom: 0; }
.md__meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-1) var(--s-4); margin: 0; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-xs); }
.md__meta div { display: contents; }
.md__meta dt { color: var(--text-3); font-family: var(--font-mono); }
.md__meta dd { margin: 0; font-family: var(--font-mono); overflow-wrap: anywhere; }

/* ───────── Markdown viewer (Rendered / Plain) ───────── */
.md-view { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; min-width: 0; }
.md-view__bar { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1-5) var(--s-2) var(--s-1-5) var(--s-3); border-bottom: 1px solid var(--border); background: var(--surface-2); min-height: 44px; flex-wrap: wrap; }
.md-view__title { flex: 1 1 12ch; min-width: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-view__meta { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.md-view__body { padding: var(--s-4) var(--s-5); overflow-y: auto; animation: fade-in var(--dur-fast) var(--ease-out); }
.md-view__source { display: block; width: 100%; margin: 0; padding: var(--s-4); border: 0; resize: vertical; background: var(--surface); color: var(--text); font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; overflow-y: auto; tab-size: 2; animation: fade-in var(--dur-fast) var(--ease-out); }
.md-view__source:focus-visible { box-shadow: var(--focus-ring-inset); outline: none; }
.md-view__source--read { background: var(--surface-sunken); }
@media (max-width: 719px) { .md-view__meta { display: none; } .md-view__body { padding: var(--s-3); } }

/* ───────── File browser ───────── */
.file-browser { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: var(--s-4); align-items: start; min-width: 0; }
.file-browser__tree { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-2); background: var(--surface); position: sticky; top: var(--s-4); max-height: 640px; overflow-y: auto; }
.file-browser__toolbar { display: flex; gap: var(--s-1); padding: 0 0 var(--s-2); margin-bottom: var(--s-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.file-browser__file { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
@media (max-width: 719px) { .file-browser { grid-template-columns: 1fr; } .file-browser__tree { position: static; } }

/* ───────── Access grants ───────── */
.grants { display: flex; flex-direction: column; gap: var(--s-3); }
.grants__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; }
.grants__list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.grants__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-2-5) var(--s-3); min-height: 56px; animation: fade-in var(--dur-base) var(--ease-out); }
.grants__row + .grants__row { border-top: 1px solid var(--border); }
.grants__row:hover { background: var(--surface-2); }
.grants__end { display: flex; align-items: center; gap: var(--s-1); flex: none; }
.grants__end .select-trigger { width: 136px; }
.grants__pick { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-2); }
.grants__pick-group { display: flex; align-items: center; gap: var(--s-1-5); padding: var(--s-1) var(--s-1); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-4); }
.grants__pick-group svg { width: 13px; height: 13px; }
.grants__pick-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2); border-radius: var(--r-md); cursor: pointer; transition: background-color var(--dur-fast); }
.grants__pick-row:hover { background: var(--surface-2); }
.grants__pick-row[data-checked="true"] { background: var(--accent-soft); }
@media (max-width: 719px) { .grants__row { flex-wrap: wrap; } .grants__end { width: 100%; justify-content: flex-end; } }

/* ───────── Activity log ───────── */
.activity-log { display: flex; flex-direction: column; gap: var(--s-4); }
.activity-log__bar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.activity-log__bar .toolbar__search, .activity-log__bar .search { flex: 1 1 220px; }
.activity-log__bar .select-trigger { width: 160px; }
.activity-log__count { margin-left: auto; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.activity-log__day { display: flex; flex-direction: column; gap: var(--s-1); }
.activity-log__date { margin: 0; font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-4); position: sticky; top: 0; background: var(--bg); padding: var(--s-1) 0; z-index: 1; }
.activity-log__list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.activity-log__row { display: grid; grid-template-columns: 96px 12px 1fr auto; align-items: start; gap: var(--s-2); padding: var(--s-2) var(--s-3); animation: fade-in var(--dur-base) var(--ease-out); }
.activity-log__row + .activity-log__row { border-top: 1px solid var(--border); }
.activity-log__row[data-open="true"] { background: var(--surface-2); }
.activity-log__time { white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); line-height: 26px; font-variant-numeric: tabular-nums; }
.activity-log__dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 9px; background: var(--text-4); }
.activity-log__row[data-tone="success"] .activity-log__dot { background: var(--success-solid); }
.activity-log__row[data-tone="danger"] .activity-log__dot { background: var(--danger-solid); }
.activity-log__row[data-tone="warning"] .activity-log__dot { background: var(--warning-solid); }
.activity-log__row[data-tone="accent"] .activity-log__dot, .activity-log__row[data-tone="info"] .activity-log__dot { background: var(--accent); }
.activity-log__main { min-width: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.activity-log__line { display: flex; align-items: center; gap: var(--s-2); min-height: 26px; padding: 0; border: 0; background: none; color: var(--text-2); text-align: left; font-size: var(--fs-sm); cursor: pointer; }
.activity-log__line:disabled { cursor: default; }
.activity-log__line:not(:disabled):hover { color: var(--text); }
.activity-log__line b { color: var(--text); font-weight: var(--fw-medium); }
.activity-log__target { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text); background: var(--surface-sunken); padding: 1px var(--s-1-5); border-radius: var(--r-xs); }
.activity-log__sys { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-3); border: 1px solid var(--border); border-radius: var(--r-xs); padding: 1px var(--s-1); }
.activity-log__detail { animation: drop-in var(--dur-base) var(--ease-out); }
.activity-log__end { display: flex; align-items: center; gap: var(--s-2); min-height: 26px; font-size: var(--fs-xs); }
@media (max-width: 719px) {
  .activity-log__row { grid-template-columns: 12px 1fr; }
  .activity-log__time { display: none; }
  .activity-log__end { grid-column: 2; }
}
/* shell.css — app frame: sidebar, top bar, mobile drawer + bottom bar, auth layout. */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-current, var(--sidebar-w)) minmax(0, 1fr);
  min-height: 100dvh;
  transition: grid-template-columns var(--dur-slow) var(--ease-out);
}
.app[data-collapsed="true"] { --sidebar-current: var(--sidebar-w-collapsed); }
@media (max-width: 1023px) and (min-width: 720px) { .app { --sidebar-current: var(--sidebar-w-collapsed); } }
@media (max-width: 719px) { .app { grid-template-columns: minmax(0, 1fr); } }
/* Focused chrome (e.g. onboarding): no sidebar is rendered, so the app is a single column. */
.app[data-focused="true"] { grid-template-columns: minmax(0, 1fr); }

.skip-link { position: fixed; left: 12px; top: -48px; z-index: var(--z-toast); padding: 8px 12px; border-radius: var(--r-md); background: var(--surface-inverse); color: var(--text-inverse); transition: top var(--dur-base) var(--ease-out); }
.skip-link:focus { top: 12px; }

/* ───────── Sidebar ───────── */
.sidebar {
  position: sticky; top: 0; z-index: var(--z-sidebar);
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  min-width: 0;
}
@media (max-width: 719px) { .app > .sidebar { display: none; } }
.sidebar__head { height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-3) 0 var(--s-4); flex: none; }
.brand { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text); border-radius: var(--r-sm); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand__icon { width: 26px; height: 26px; flex: none; }
.brand__wordmark {
  display: block; width: 76px; height: 22px; flex: none;
  background: currentColor;
  -webkit-mask: url("/dewee-wordmark-360.png") left center / contain no-repeat;
  mask: url("/dewee-wordmark-360.png") left center / contain no-repeat;
  transition: opacity var(--dur-base), width var(--dur-slow) var(--ease-out);
}
.sidebar__collapse { margin-left: auto; }
.sidebar__scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--s-1) var(--s-2) var(--s-4); scrollbar-width: none; }
.sidebar__scroll::-webkit-scrollbar { display: none; }
.nav-section { display: flex; flex-direction: column; gap: 1px; padding-top: var(--s-3); }
.nav-section__label {
  display: flex; align-items: center; gap: var(--s-1);
  height: 26px; padding: 0 var(--s-2-5);
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--text-4);
  border-radius: var(--r-sm);
  width: 100%; text-align: left;
}
.nav-section__label:hover { color: var(--text-3); }
.nav-section__label svg { width: 12px; height: 12px; transition: transform var(--dur-base) var(--ease-out); opacity: 0; }
.nav-section__label:hover svg, .nav-section__label:focus-visible svg { opacity: 1; }
.nav-section[data-collapsed="true"] .nav-section__label svg { transform: rotate(-90deg); opacity: 1; }
.nav-section__items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--dur-slow) var(--ease-out); }
.nav-section[data-collapsed="true"] .nav-section__items { grid-template-rows: 0fr; }
.nav-section__inner { overflow: hidden; display: flex; flex-direction: column; gap: 1px; min-height: 0; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: var(--s-2-5);
  height: 32px; padding: 0 var(--s-2-5);
  border-radius: var(--r-md);
  color: var(--text-2); font-size: var(--fs-md); font-weight: var(--fw-regular);
  white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item svg { width: 16px; height: 16px; flex: none; color: var(--text-3); transition: color var(--dur-fast); }
.nav-item:hover { background: var(--surface-sunken); color: var(--text); text-decoration: none; }
.nav-item:hover svg { color: var(--text-2); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: var(--fw-medium); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border); }
.nav-item[aria-current="page"] svg { color: var(--accent); }
.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; transition: opacity var(--dur-base); }
.nav-item .count-badge { transition: opacity var(--dur-base); }
@media (pointer: coarse) { .nav-item { height: 40px; } }

.sidebar__foot { flex: none; padding: var(--s-2) var(--s-2) var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); border-top: 1px solid var(--border); }
.setup-hint { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border); }
.setup-hint__title { color: var(--text); font-weight: var(--fw-medium); font-size: var(--fs-sm); display: flex; justify-content: space-between; }
.sidebar__meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 0 var(--s-2); font-size: var(--fs-xs); color: var(--text-4); white-space: nowrap; }
.sidebar__meta a { color: var(--text-3); }

/* Collapsed rail */
.app[data-collapsed="true"] .sidebar, .sidebar[data-rail="true"] { --rail: 1; }
@media (min-width: 720px) {
  .app[data-collapsed="true"] .brand__wordmark { width: 0; opacity: 0; }
  .app[data-collapsed="true"] .nav-item__label, .app[data-collapsed="true"] .nav-item .count-badge { opacity: 0; width: 0; }
  .app[data-collapsed="true"] .nav-item { justify-content: center; padding: 0; }
  .app[data-collapsed="true"] .nav-item .count-badge { position: absolute; }
  .app[data-collapsed="true"] .nav-item[data-badge="true"]::after { content: ""; position: absolute; top: 6px; right: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
  .app[data-collapsed="true"] .nav-section__label { justify-content: center; font-size: 0; height: 12px; }
  .app[data-collapsed="true"] .nav-section__label::before { content: ""; width: 16px; height: 1px; background: var(--border-strong); }
  .app[data-collapsed="true"] .nav-section__label svg { display: none; }
  .app[data-collapsed="true"] .nav-section[data-collapsed="true"] .nav-section__items { grid-template-rows: 1fr; }
  .app[data-collapsed="true"] .setup-hint, .app[data-collapsed="true"] .sidebar__meta { display: none; }
  .app[data-collapsed="true"] .sidebar__head { padding: 0; justify-content: center; flex-direction: column; gap: 0; }
  .app[data-collapsed="true"] .sidebar__collapse { margin: 0; position: absolute; top: calc(var(--topbar-h) - 6px); left: calc(var(--sidebar-w-collapsed) - 12px); width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); opacity: 0; transition: opacity var(--dur-fast); }
  .app[data-collapsed="true"] .sidebar:hover .sidebar__collapse, .app[data-collapsed="true"] .sidebar__collapse:focus-visible { opacity: 1; }
}
@media (max-width: 1023px) and (min-width: 720px) {
  .app .brand__wordmark { width: 0; opacity: 0; }
  .app .nav-item__label, .app .nav-item .count-badge { opacity: 0; width: 0; }
  .app .nav-item { justify-content: center; padding: 0; }
  .app .nav-item[data-badge="true"]::after { content: ""; position: absolute; top: 6px; right: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
  .app .nav-section__label { justify-content: center; font-size: 0; height: 12px; }
  .app .nav-section__label::before { content: ""; width: 16px; height: 1px; background: var(--border-strong); }
  .app .nav-section__label svg { display: none; }
  .app .nav-section .nav-section__items { grid-template-rows: 1fr !important; }
  .app .setup-hint, .app .sidebar__meta, .app .sidebar__collapse { display: none; }
  .app .sidebar__head { padding: 0; justify-content: center; }
}

/* ───────── Main + top bar ───────── */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s-2);
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.topbar[data-scrolled="true"] { border-bottom-color: var(--border); }
.topbar--focused { justify-content: space-between; }
.topbar__mobile-brand { display: none; }
@media (max-width: 719px) {
  .topbar { padding: 0 var(--s-2) 0 var(--s-2); gap: var(--s-1); }
  .topbar__mobile-brand { display: inline-flex; }
}
.ws-switch {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-2) 0 4px;
  border-radius: var(--r-md);
  color: var(--text); font-weight: var(--fw-medium);
  max-width: 260px; min-width: 0;
}
.ws-switch:hover { background: var(--surface-sunken); }
.ws-switch[aria-expanded="true"] { background: var(--surface-sunken); }
.ws-switch__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-switch__plan { font-size: var(--fs-2xs); color: var(--text-3); font-weight: var(--fw-medium); padding: 1px 6px; border-radius: var(--r-full); box-shadow: inset 0 0 0 1px var(--border-strong); }
.ws-switch svg { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.topbar__sep { width: 1px; height: 18px; background: var(--border-strong); flex: none; }
.search-trigger {
  display: inline-flex; align-items: center; gap: var(--s-2);
  flex: 0 1 380px; min-width: 0;
  height: 34px; padding: 0 var(--s-1-5) 0 var(--s-2-5);
  margin: 0 auto;
  border-radius: var(--r-md);
  background: var(--surface); color: var(--text-4);
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border-control);
  font-size: var(--fs-md);
  transition: box-shadow var(--dur-fast), color var(--dur-fast);
}
.search-trigger:hover { color: var(--text-3); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--text-4); }
.search-trigger svg { width: 16px; height: 16px; flex: none; }
.search-trigger__label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__actions { display: flex; align-items: center; gap: 2px; flex: none; }
.runtime-chip {
  display: inline-flex; align-items: center; gap: var(--s-1-5);
  height: 28px; padding: 0 var(--s-2-5);
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  margin-right: var(--s-1);
}
.runtime-chip:hover { background: var(--surface-sunken); }
.bell { position: relative; }
.bell__dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger-solid); color: #fff; font-size: 10px; font-weight: var(--fw-semibold); display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); animation: scale-in var(--dur-base) var(--ease-spring); }
.avatar-btn { border-radius: 50%; padding: 3px; margin-left: var(--s-1); }
.avatar-btn:hover { background: var(--surface-sunken); }
@media (max-width: 1023px) { .runtime-chip__label { display: none; } .runtime-chip { padding: 0 9px; } .topbar__whats-new { display: none; } }
@media (max-width: 719px) {
  .search-trigger { flex: 0 0 auto; width: 36px; padding: 0; justify-content: center; margin: 0 0 0 auto; background: transparent; box-shadow: none; color: var(--text-2); }
  .search-trigger__label, .search-trigger .kbd-combo { display: none; }
  .ws-switch { max-width: 44vw; }
  .ws-switch__plan, .runtime-chip, .topbar__sep { display: none; }
}

.content { flex: 1; min-width: 0; }
.content:focus-visible { box-shadow: none; }

/* ───────── Notifications ───────── */
.notif { display: flex; flex-direction: column; max-height: min(480px, 70vh); }
.notif__list { overflow-y: auto; }
.notif__item { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); position: relative; text-align: left; width: 100%; color: inherit; }
.notif__item:hover { background: var(--surface-2); text-decoration: none; }
.notif__item[data-unread="true"]::before { content: ""; position: absolute; left: 7px; top: 20px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.notif__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); }
.notif__title { color: var(--text); }
.notif__time { color: var(--text-4); font-size: var(--fs-xs); }
.changelog__item { display: flex; flex-direction: column; gap: 4px; padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); font-size: var(--fs-sm); }

/* ───────── Mobile drawer + bottom bar ───────── */
.drawer .sidebar { position: static; height: 100%; border-right: 0; background: var(--surface-raised); }
.drawer .brand__wordmark, .drawer .nav-item__label, .drawer .nav-item .count-badge { opacity: 1 !important; width: auto !important; }
.bottom-bar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-topbar);
  padding: 4px var(--s-2) calc(4px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
@media (max-width: 719px) { .bottom-bar { display: grid; grid-template-columns: repeat(5, 1fr); } }
.bottom-bar__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 48px; border-radius: var(--r-md); color: var(--text-3); font-size: 10.5px; font-weight: var(--fw-medium); }
.bottom-bar__item svg { width: 20px; height: 20px; transition: transform var(--dur-base) var(--ease-spring); }
.bottom-bar__item:hover { text-decoration: none; color: var(--text); }
.bottom-bar__item[aria-current="page"] { color: var(--accent-text); }
.bottom-bar__item[aria-current="page"] svg { transform: translateY(-1px); }
.bottom-bar__item .count-badge { position: absolute; top: 4px; left: calc(50% + 6px); height: 16px; min-width: 16px; font-size: 10px; }

/* ───────── Auth / setup layout ───────── */
.auth {
  min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  background: var(--bg);
}
.auth__panel { display: flex; flex-direction: column; padding: var(--s-6) var(--s-10); gap: var(--s-8); }
.auth__form { width: 100%; max-width: 380px; margin: auto; display: flex; flex-direction: column; gap: var(--s-6); animation: rise-in var(--dur-slower) var(--ease-out); }
.auth__title { font-size: var(--fs-3xl); line-height: var(--lh-3xl); letter-spacing: var(--tracking-tight); }
.auth__sub { color: var(--text-3); font-size: var(--fs-md); margin-top: var(--s-2); }
.auth__divider { display: flex; align-items: center; gap: var(--s-3); color: var(--text-4); font-size: var(--fs-xs); }
.auth__divider::before, .auth__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth__foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); color: var(--text-4); font-size: var(--fs-xs); flex-wrap: wrap; }
.auth__art {
  position: relative; overflow: hidden;
  margin: var(--s-3); border-radius: var(--r-2xl);
  background: radial-gradient(120% 90% at 20% 10%, #2a1f7a 0%, #140f3d 45%, #0b0a1f 100%);
  color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: var(--s-10);
  isolation: isolate;
}
.auth__glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(70px); opacity: 0.75; z-index: -1; animation: aura-drift 18s var(--ease-in-out) infinite alternate; }
.auth__glow--a { background: #9a5cff; top: -140px; right: -120px; }
.auth__glow--b { background: #1f7bf2; bottom: -200px; left: -120px; animation-delay: -6s; opacity: 0.55; }
.auth__glow--c { background: #f38bf1; top: 30%; left: 40%; width: 280px; height: 280px; opacity: 0.35; animation-delay: -12s; }
@keyframes aura-drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-40px, 30px) scale(1.12); } }
.auth__grid { position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(70% 60% at 60% 40%, #000, transparent); }
.auth__quote { font-size: var(--fs-2xl); line-height: 1.3; letter-spacing: var(--tracking-tight); font-weight: var(--fw-medium); max-width: 520px; color: #fff; }
.auth__points { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-6); color: rgba(255,255,255,0.72); font-size: var(--fs-md); }
.auth__points li { display: flex; gap: var(--s-2); align-items: center; }
.auth__points svg { width: 16px; height: 16px; color: #b9b3ff; }
.auth__preview { position: absolute; top: 12%; left: 10%; right: 10%; display: flex; flex-direction: column; gap: var(--s-3); }
.auth__bubble { align-self: flex-start; max-width: 78%; padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); backdrop-filter: blur(8px); font-size: var(--fs-sm); color: rgba(255,255,255,0.9); animation: rise-in 600ms var(--ease-out) both; }
.auth__bubble--me { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: rgba(154, 92, 255, 0.35); }
@media (max-width: 1023px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__art { display: none; }
  .auth__panel { padding: var(--s-5) var(--s-5); }
}

/* ───────── Floating chat launcher ───────── */
.floating-chat-fab {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-topbar);
  width: 52px; height: 52px; border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--surface-raised); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--border);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast);
}
.floating-chat-fab:hover { transform: scale(1.05); box-shadow: var(--shadow-xl), inset 0 0 0 1px var(--border); }
.floating-chat-fab__badge { position: absolute; width: 16px; height: 16px; right: 4px; bottom: 4px; padding: 2px; border-radius: 50%; background: var(--accent); color: var(--text-on-accent); box-shadow: 0 0 0 2px var(--surface-raised); }
.floating-chat-fab__dot { position: absolute; top: 2px; right: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--danger-solid); box-shadow: 0 0 0 2px var(--surface-raised); animation: scale-in var(--dur-base) var(--ease-spring); }
@media (max-width: 719px) { .floating-chat-fab { bottom: calc(var(--bottom-bar-h) + var(--s-3)); right: var(--s-3); } }

.floating-chat { display: flex; flex-direction: column; height: 460px; max-height: 70dvh; min-height: 0; animation: scale-in var(--dur-base) var(--ease-out); transform-origin: bottom right; }
.floating-chat__head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2-5) var(--s-3); border-bottom: 1px solid var(--border); flex: none; }
.floating-chat__agent-select { flex: 1; min-width: 0; }
.floating-chat__context { display: flex; align-items: center; gap: var(--s-1-5); padding: var(--s-1-5) var(--s-3); font-size: var(--fs-xs); color: var(--text-3); background: var(--surface-sunken); border-bottom: 1px solid var(--border); flex: none; }
.floating-chat__context svg { width: 13px; height: 13px; flex: none; }
.floating-chat__context span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.floating-chat__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2-5); }
.floating-chat__empty { padding: var(--s-2); }
.floating-chat__msg { display: flex; max-width: 90%; }
.floating-chat__msg--me { align-self: flex-end; }
.floating-chat__bubble { background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-xs); padding: var(--s-2) var(--s-2-5); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.floating-chat__msg--me .floating-chat__bubble { background: var(--accent-soft); border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg); }
.floating-chat__composer { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2-5) var(--s-3); border-top: 1px solid var(--border); flex: none; }
.floating-chat__input { flex: 1; height: 34px; padding: 0 var(--s-2-5); border-radius: var(--r-md); border: 1px solid var(--border-control); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-md); }
.floating-chat__input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* pages.css — page-specific layouts that are not reusable components. Page builders append here under a comment per page. */

/* ── Agents ─────────────────────────────────────────────── */
.agent-hero { display: flex; gap: var(--s-4); align-items: flex-start; padding: var(--s-5) var(--s-5) var(--s-4); }
.agent-hero__text { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.stack-row__main { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-width: 0; }
.grant-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.grant-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); min-height: 52px; }
.grant-row + .grant-row { border-top: 1px solid var(--border); }
.grant-row__name { flex: 1; min-width: 0; font-weight: var(--fw-medium); }
.grant-row .select-trigger { width: 144px; flex: none; }
.tpl-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.tpl-card {
  display: flex; flex-direction: column; gap: var(--s-2); text-align: left; padding: var(--s-4); border-radius: var(--r-lg);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.tpl-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.tpl-card:active { transform: none; }
.tpl-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tpl-card--blank { border-style: dashed; background: transparent; }
.tpl-card__head { display: flex; align-items: center; gap: var(--s-2); }
.tpl-card__head svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.tpl-card__name { font-weight: var(--fw-semibold); flex: 1; }
.tpl-card__desc { color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.tpl-card__meta { color: var(--text-3); font-size: var(--fs-xs); margin-top: auto; }

/* Session transcript: rendered messages use the DS markdown flow; plain keeps the raw text. */
.md.session-msg__content { white-space: normal; color: var(--text); }
.session-msg__content--plain { font-family: var(--font-mono); font-size: var(--fs-sm); background: var(--surface-sunken); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); overflow-wrap: anywhere; }
.ticket-msg__body { margin-top: var(--s-1); }
/* Page styles for the auth-overview-chat group. Page-only layout; no DS overrides. */

/* ── Overview ─────────────────────────────────────────────── */
.tpl-card[data-state="selected"] { border-color: var(--border-strong); }

/* ── Chat ─────────────────────────────────────────────────── */
.chat-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--surface);
}

.chat-shell__list, .chat-shell__thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-shell__list { border-right: 1px solid var(--border); background: var(--bg); }

.chat-shell__list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2); }
.chat-shell__title { font-size: var(--fs-lg); line-height: var(--lh-lg); }

.chat-sidebar { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-sidebar__head { display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-3) var(--s-3); }
.chat-sidebar__head > :first-child { flex: 1; min-width: 0; }
.chat-sidebar__list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 0 var(--s-2) var(--s-3); }

.chat-session-row { display: flex; align-items: center; gap: var(--s-1); border-radius: var(--r-md); padding-right: var(--s-1); }
.chat-session-row:hover { background: var(--surface-sunken); }
.chat-session-row[data-active="true"] { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.chat-session-row__btn { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: var(--s-2) var(--s-2-5); text-align: left; }
.chat-session-row__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.chat-session-row__meta { font-size: var(--fs-2xs); color: var(--text-4); }

.chat-thread__head { display: flex; align-items: center; gap: var(--s-2-5); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); flex: none; }
.chat-thread__back { display: none; }
.chat-thread__agent { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chat-thread__agent-name { font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--s-1-5); }
.chat-thread__agent-model { font-size: var(--fs-xs); }
.chat-thread__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-4); }

/* ── Chat: agent picker (super agent pinned + grouped) ───────────────── */
.agent-picker-trigger {
  display: flex; align-items: center; gap: var(--s-2); width: 100%;
  height: 34px; padding: 0 var(--s-2-5); border-radius: var(--r-md);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-control);
  font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--text);
}
.agent-picker-trigger:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.agent-picker-trigger__name { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-picker-trigger svg { width: 14px; height: 14px; color: var(--text-4); flex: none; }
.agent-picker { display: flex; flex-direction: column; padding: var(--s-2); gap: var(--s-1); max-height: 420px; overflow-y: auto; }
.agent-picker__search { height: 32px; padding: 0 var(--s-2-5); border-radius: var(--r-md); border: 1px solid var(--border-control); background: var(--surface); color: var(--text); font-size: var(--fs-sm); }
.agent-picker__search:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.agent-picker__group { display: flex; flex-direction: column; gap: 1px; padding-top: var(--s-1); }
.agent-picker__group-label { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-4); padding: var(--s-1) var(--s-2); }
.agent-picker__row { display: flex; align-items: center; gap: var(--s-2-5); padding: var(--s-2) var(--s-2); border-radius: var(--r-md); text-align: left; }
.agent-picker__row:hover { background: var(--surface-sunken); }
.agent-picker__row[data-active="true"] { background: var(--accent-soft); }
.agent-picker__row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.agent-picker__row-name { display: flex; align-items: center; gap: var(--s-1-5); font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.agent-picker__row-desc { font-size: var(--fs-2xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Chat: delegation system card ─────────────────────────────────── */
.chat-system-card {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  margin: var(--s-3) auto; padding: var(--s-1-5) var(--s-3); max-width: 90%;
  border-radius: var(--r-full); background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--fs-xs); color: var(--text-3); text-align: center;
}
.chat-system-card svg { width: 13px; height: 13px; color: var(--accent); flex: none; }

.chat-msg { display: flex; gap: var(--s-2-5); align-items: flex-start; max-width: 86%; }
.chat-msg + .chat-msg { margin-top: var(--s-4); }
.chat-msg--me { flex-direction: row-reverse; margin-left: auto; }
.chat-msg__col { display: flex; flex-direction: column; gap: var(--s-1-5); min-width: 0; }
.chat-msg--me .chat-msg__col { align-items: flex-end; }
.chat-msg__time { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-2xs); color: var(--text-4); padding: 0 var(--s-1); }

.chat-bubble { background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-xs); padding: var(--s-2-5) var(--s-3); font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text); max-width: 100%; }
.chat-bubble--me { background: var(--accent-soft); color: var(--text); border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg); }
.chat-bubble--error { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-line); }
.chat-markdown pre { margin: 0; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: var(--s-1-5); margin-bottom: var(--s-2); }

.composer { border-top: 1px solid var(--border); padding: var(--s-3); flex: none; display: flex; flex-direction: column; gap: var(--s-2); }
.composer__row { display: flex; align-items: flex-end; gap: var(--s-2); }
.composer__textarea {
  flex: 1; resize: none; min-height: 36px; max-height: 160px; padding: 8px 10px;
  border-radius: var(--r-md); border: 1px solid var(--border-control); background: var(--surface);
  color: var(--text); font: inherit; font-size: var(--fs-md); line-height: var(--lh-md);
}
.composer__textarea:focus-visible { outline: none; box-shadow: var(--focus-ring); }

@media (max-width: 719px) {
  .chat-shell { grid-template-columns: minmax(0, 1fr); border-radius: var(--r-lg); }
  .chat-shell__list, .chat-shell__thread { display: none; }
  .chat-shell[data-mobile-pane="list"] .chat-shell__list { display: flex; }
  .chat-shell[data-mobile-pane="thread"] .chat-shell__thread { display: flex; }
  .chat-thread__back { display: inline-flex; }
  .chat-msg { max-width: 94%; }
}

/* ── Onboarding wizard + Nova setup chat ─────────────────────────────── */
.onboarding-shell { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s-6); align-items: start; padding-bottom: var(--s-8); }
.onboarding-wizard { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; max-width: 760px; width: 100%; justify-self: center; }
.onboarding-step-body { background: var(--surface); border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--border); padding: var(--s-5); }
.onboarding-chat-pane { position: sticky; top: calc(var(--topbar-h) + var(--s-4)); height: calc(100dvh - var(--topbar-h) - var(--s-8)); min-height: 480px; border-radius: var(--r-xl); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); overflow: hidden; background: var(--surface); }
.provider-picker { display: flex; flex-direction: column; gap: var(--s-3); }
.provider-picker__controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.provider-picker__controls > :first-child { flex: 1 1 220px; min-width: 0; }
.provider-picker__categories { display: flex; flex-wrap: wrap; gap: var(--s-1-5); }
.provider-picker__count { margin: 0; font-size: var(--fs-xs); }
/* 31 providers: keep the list scrollable so the key / OAuth form below stays in view. */
.provider-picker__list { max-height: 360px; overflow-y: auto; padding: 2px; overscroll-behavior: contain; }
@media (max-width: 719px) {
  .provider-picker__categories { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .provider-picker__chip { flex: none; }
  .provider-picker__list { max-height: 320px; }
}
.provider-picker__chip {
  height: 28px; padding: 0 var(--s-2-5); border-radius: var(--r-full);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-control);
  color: var(--text-2); font-size: var(--fs-xs); font-weight: var(--fw-medium);
}
.provider-picker__chip:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.provider-picker__chip[data-active="true"] { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); }
.onboarding-qr { width: 140px; height: 140px; display: grid; place-items: center; border-radius: var(--r-lg); background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border); color: var(--text-3); }
.onboarding-qr svg { width: 64px; height: 64px; }
.onboarding-done-hero { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-1); }
.onboarding-done-hero svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: var(--s-1); }

.onboarding-ask-nova {
  position: fixed; right: var(--s-4); bottom: calc(var(--bottom-bar-h) + var(--s-3));
  z-index: var(--z-topbar);
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 44px; padding: 0 var(--s-4);
  border-radius: var(--r-full); background: var(--surface-raised); color: var(--text);
  font-weight: var(--fw-medium); box-shadow: var(--shadow-md), inset 0 0 0 1px var(--border);
}

@media (max-width: 1279px) {
  .onboarding-shell { grid-template-columns: minmax(0, 1fr); }
  .onboarding-chat-pane { display: none; }
}
@media (max-width: 719px) {
  .onboarding-wizard { max-width: none; }
}

.nova-chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.nova-chat__head { display: flex; align-items: center; gap: var(--s-2-5); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); flex: none; }
.nova-chat__name { font-weight: var(--fw-semibold); }
.nova-chat__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.nova-chat__msg { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); max-width: 92%; }
.nova-chat__msg--me { align-self: flex-end; align-items: flex-end; }
.nova-chat__bubble { background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-xs); padding: var(--s-2-5) var(--s-3); font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text); }
.nova-chat__msg--me .nova-chat__bubble { background: var(--accent-soft); border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg); }
.nova-chat__quick-replies { display: flex; flex-wrap: wrap; gap: var(--s-1-5); }
.nova-chat__composer { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3); border-top: 1px solid var(--border); flex: none; }
.nova-chat__input { flex: 1; height: 36px; padding: 0 var(--s-3); border-radius: var(--r-full); border: 1px solid var(--border-control); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-md); }
.nova-chat__input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* Page styles for the Overview operator dashboard. Page-only layout; no DS overrides. */

/* ── Overview ── */
.overview-page__footnote { margin-top: var(--s-2); }

.setup-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.setup-checklist__item { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-2); }
.setup-checklist__item svg { width: 16px; height: 16px; flex: none; color: var(--text-4); }
.setup-checklist__item[data-done="true"] { color: var(--text-3); text-decoration: line-through; }
.setup-checklist__item[data-done="true"] svg { color: var(--success-solid); }

.overview-charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.overview-charts-grid__wide { grid-column: 1 / -1; }
@media (max-width: 959px) { .overview-charts-grid { grid-template-columns: 1fr; } }

.overview-live-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
@media (max-width: 959px) { .overview-live-grid { grid-template-columns: 1fr; } }
/* Page styles for the workspace-ops group. Page-only layout; no DS overrides. */

/* ── Session detail ── */
.session-detail__grid { display: grid; grid-template-columns: 1fr 320px; gap: var(--s-6); align-items: start; }
.session-detail__aside { position: sticky; top: var(--s-6); display: flex; flex-direction: column; gap: var(--s-6); min-width: 0; }
.session-detail__traces { list-style: none; margin: 0; padding: 0; }
.session-detail__trace-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
.session-detail__trace-row:last-child { border-bottom: 0; }
.session-msg__content { margin: var(--s-1) 0 var(--s-2); color: var(--text-2); white-space: pre-wrap; }
@media (max-width: 860px) {
  .session-detail__grid { grid-template-columns: 1fr; }
  .session-detail__aside { position: static; }
}

/* ── Teams ── */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); }
.team-card { gap: var(--s-4); padding: var(--s-5); cursor: pointer; text-align: left; }
.team-card__title { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-1); min-width: 0; }
.team-card__title .card__title { max-width: 100%; }
.team-card__people { display: inline-flex; align-items: center; gap: var(--s-2); flex: none; }
.team-card__agents { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.team-card__agent-list { display: flex; flex-wrap: wrap; gap: var(--s-2); min-width: 0; margin-left: auto; }
.team-card__agent { display: inline-flex; align-items: center; gap: 6px; max-width: 140px; padding: 2px 8px 2px 2px; border-radius: var(--r-full, 999px); background: var(--surface-2); color: var(--text-2); }
.team-card--skeleton { min-height: 220px; background: var(--surface-sunken); cursor: default; }
.team-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.team-card__desc { margin: 0; flex: 1; }
.team-card__meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-width: 0; }
.team-card__meta > :first-child { min-width: 0; }
.team-preset-grid .card { cursor: pointer; height: 100%; }

/* ── Team detail: kanban board ── */
.kanban-board { display: flex; gap: var(--s-3); overflow-x: auto; padding-bottom: var(--s-2); scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.kanban-col { flex: 0 0 260px; display: flex; flex-direction: column; gap: var(--s-2); background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-3); scroll-snap-align: start; transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.kanban-col--over { background: var(--accent-soft); border-color: var(--accent-line); }
.kanban-col__head { display: flex; align-items: center; justify-content: space-between; font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--text-2); padding: 0 var(--s-1); }
.kanban-col__body { display: flex; flex-direction: column; gap: var(--s-2); min-height: 40px; }
.kanban-col__empty { text-align: center; padding: var(--s-3) 0; margin: 0; font-size: var(--fs-sm); }
.kanban-card { display: flex; flex-direction: column; gap: var(--s-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3); cursor: grab; transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.kanban-card:hover { box-shadow: var(--shadow-sm); }
.kanban-card:active { cursor: grabbing; }
.kanban-card--enter { animation: kanban-enter 0.32s var(--ease-out); }
.kanban-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.kanban-card__title { margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.kanban-card__desc { margin: 0; color: var(--text-3); font-size: var(--fs-xs); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kanban-card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-3); }
@keyframes kanban-enter { from { transform: scale(0.94); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .kanban-card--enter { animation: none; }
}
html[data-motion="reduced"] .kanban-card--enter { animation: none; }

/* ── Tasks & approvals ── */
.approval-card__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.approval-card__action { font-weight: var(--fw-medium); margin: var(--s-2) 0 0; }

/* ── Agent detail: settings save bar ── */
.save-bar {
  position: sticky; bottom: var(--s-4); z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  margin-top: var(--s-6); padding: var(--s-3) var(--s-4); border-radius: var(--r-lg);
  background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-md);
}
@media (max-width: 719px) { .save-bar { flex-direction: column; align-items: stretch; } }

/* ── Agent detail: profile emoji picker ── */
.emoji-pick {
  width: var(--control-h); height: var(--control-h); display: grid; place-items: center;
  font-size: var(--fs-lg); border: 1px solid var(--border-control); border-radius: var(--r-md); background: var(--surface);
  cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.emoji-pick:hover { border-color: var(--border-strong); }
.emoji-pick[data-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }
.emoji-pick:disabled { cursor: not-allowed; opacity: 0.5; }

/* ── Agent detail: model fallback chain editor ── */
.fallback-list { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.fallback-list__row { display: flex; align-items: center; gap: var(--s-2); }
.fallback-list__row > .select-trigger { flex: 1; }

/* ── Agent detail: evolution proposal diff ── */
.evolution-diff { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-3); }
.evolution-diff pre { margin: 0; padding: var(--s-3); border-radius: var(--r-md); font-size: var(--fs-xs); white-space: pre-wrap; max-height: 220px; overflow: auto; }
.evolution-diff__before { background: var(--danger-soft); border: 1px solid var(--danger-line); }
.evolution-diff__after { background: var(--success-soft); border: 1px solid var(--success-line); }
@media (max-width: 719px) { .evolution-diff { grid-template-columns: 1fr; } }

/* ── Agent detail: super-agent identity ── */
.agent-hero__avatar--super, .page-header__title .aura-orb { filter: drop-shadow(0 0 8px var(--aura-glow)); }
/* Page styles for the capabilities group. Page-only layout; no DS overrides. */

/* ── Voice ── */
.range {
  appearance: none;
  width: 100%;
  height: var(--control-h);
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: var(--r-full); background: var(--surface-sunken); }
.range::-moz-range-track { height: 4px; border-radius: var(--r-full); background: var(--surface-sunken); }
.range::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px; margin-top: -6px;
  border-radius: var(--r-full);
  background: var(--accent);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out);
}
.range::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: var(--r-full); background: var(--accent); box-shadow: var(--shadow-sm); }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }
.range:active::-webkit-slider-thumb { transform: scale(1.1); }

.waveform { display: flex; align-items: center; gap: var(--s-3); }
.waveform__bars {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
  min-width: 0;
}
.waveform__bar {
  flex: 1;
  min-width: 2px;
  max-width: 5px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  transition: background var(--dur-base) var(--ease-out);
}
.waveform__bar[data-active="true"] { background: var(--accent); }
.waveform__bars[data-playing="true"] .waveform__bar { animation: waveform-pulse 900ms var(--ease-in-out) infinite alternate; }

@keyframes waveform-pulse {
  from { transform: scaleY(0.6); }
  to { transform: scaleY(1); }
}

/* ── Sticky save bar (Voice) ── */
.save-bar {
  position: sticky;
  bottom: var(--s-4);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
@media (max-width: 640px) {
  .save-bar { flex-direction: column; align-items: stretch; }
}

/* ── Runtime Packages: install stage track ── */
.status-dot[data-state] { width: 8px; height: 8px; border-radius: var(--r-full); display: inline-block; }

/* ── MCP tool grants & built-in tool rows: the Select's own 100% width otherwise
   crowds out the name column in a flex row, so pin it and let the name truncate. ── */
.grant-row .select-trigger { width: 168px; flex: none; }
.grant-row__name { display: flex; flex-wrap: wrap; column-gap: var(--s-1); align-items: baseline; }
/* Page styles for Skills, Hooks and Schedules. Page-only layout; no DS overrides. */

/* ── Skills: marketplace search sits next to the category segmented control ── */
.marketplace-search { flex: 1; min-width: 220px; max-width: 360px; }

/* ── Skill detail: evolution proposal cards ── */
.evolution-card { display: flex; flex-direction: column; gap: var(--s-3); }

/* ── Skill detail: version diff view ── */
.diff-view {
  margin: 0;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
}
.diff-view__line { padding: 0 var(--s-1); border-radius: var(--r-xs); }
.diff-view__line--add { background: var(--success-soft); color: var(--success); }
.diff-view__line--del { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; }

/* ── Skill detail Settings: danger zone card gets a warning border to set it apart ── */
.danger-zone { border-color: var(--danger-line); }
/* Page styles for the automation group. Page-only layout; no DS overrides. */

/* ── Versions panel ── */
.version-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
}
.version-row:last-child { border-bottom: none; }

/* ── Workflow editor: validation & recent runs ── */
.validation-row {
  display: flex; align-items: flex-start; gap: var(--s-2); width: 100%; text-align: left;
  padding: var(--s-2); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface);
  font: inherit; color: var(--text-2); cursor: pointer;
}
.validation-row:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.validation-row:disabled { cursor: default; }

.recent-run-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding: var(--s-2); border-radius: var(--r-md); border: 1px solid var(--border); text-decoration: none; color: inherit;
}
.recent-run-row:hover { border-color: var(--border-strong); background: var(--surface-2); }

/* ── Workflow editor page shell ── */
.wf-editor-page { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-h) - var(--bottom-bar-h)); padding: 0; gap: 0; }

.wf-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--border); background: var(--surface); flex: none;
}
.wf-toolbar__left, .wf-toolbar__right { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.wf-toolbar__name, .wf-toolbar__name-input {
  font-size: var(--fs-lg); font-weight: var(--fw-semibold); background: none; border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 2px 6px; color: var(--text); max-width: 40vw; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.wf-toolbar__name { cursor: text; }
.wf-toolbar__name:hover { border-color: var(--border); }
.wf-toolbar__name-input { border-color: var(--accent); outline: none; }
.wf-toolbar__validation { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }

.wf-mobile-banner { display: none; margin: var(--s-2) var(--s-4) 0; }

.wf-editor-body { flex: 1; display: grid; grid-template-columns: 220px 1fr 300px; min-height: 0; }

.wf-panel { border-inline: 1px solid var(--border); background: var(--surface); padding: var(--s-3); overflow-y: auto; }
.wf-panel--left { border-left: none; }
.wf-panel--right { border-right: none; }

.wf-canvas-wrap { position: relative; min-width: 0; }
.wf-canvas {
  position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1px);
  background-size: 22px 22px;
}
.wf-canvas--panning { cursor: grabbing; }
.wf-canvas__world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.wf-canvas__edges { position: absolute; top: 0; left: 0; width: 4000px; height: 2400px; max-width: none; overflow: visible; pointer-events: none; }

.wf-edge { stroke: var(--text-4); stroke-width: 1.5; }
.wf-edge__arrow { fill: var(--text-4); }
.wf-edge--running { stroke: var(--accent); stroke-dasharray: 6 5; animation: wf-dash 900ms linear infinite; }
.wf-edge__label { fill: var(--text-3); font-size: var(--fs-2xs); font-family: var(--font-mono); }
@keyframes wf-dash { to { stroke-dashoffset: -22; } }

.wf-node {
  position: absolute; top: 0; left: 0; display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-lg); border: 1px solid var(--border-strong);
  background: var(--surface-raised); box-shadow: var(--shadow-sm); cursor: grab; user-select: none;
}
.wf-node:active { cursor: grabbing; }
.wf-canvas--readonly .wf-node, .wf-canvas--readonly .wf-node:active { cursor: pointer; }
.wf-node--selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-line); }
.wf-node--issue { border-color: var(--warning-solid); }
.wf-node__icon {
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--r-md); flex: none;
  background: var(--accent-soft); color: var(--accent-text);
}
.wf-node--success .wf-node__icon { background: var(--success-soft); color: var(--success); }
.wf-node--warning .wf-node__icon { background: var(--warning-soft); color: var(--warning); }
.wf-node--danger .wf-node__icon { background: var(--danger-soft); color: var(--danger); }
.wf-node__text { display: flex; flex-direction: column; min-width: 0; }
.wf-node__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-node__subtitle { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-node__port { position: absolute; top: 50%; width: 8px; height: 8px; border-radius: 999px; background: var(--border-strong); transform: translateY(-50%); }
.wf-node__port--in { left: -4px; }
.wf-node__port--out { right: -4px; }

.wf-palette { display: flex; flex-direction: column; gap: var(--s-0-5); }
.wf-palette__title { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); padding: var(--s-1) var(--s-2) var(--s-2); }
.wf-palette__item {
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r-md); text-align: left; min-height: var(--touch-min);
  transition: background var(--dur-fast) var(--ease-out);
}
.wf-palette__item:hover { background: var(--surface-sunken); }
.wf-palette__item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wf-palette__item:active { transform: scale(0.98); }
.wf-palette__item .wf-node__icon { width: 28px; height: 28px; }
.wf-palette__text { display: flex; flex-direction: column; min-width: 0; }
.wf-palette__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.wf-palette__hint { font-size: var(--fs-xs); color: var(--text-3); }

.wf-canvas__zoom { position: absolute; right: var(--s-3); bottom: var(--s-3); display: flex; gap: var(--s-1); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-1); box-shadow: var(--shadow-sm); }
.wf-canvas__notice { position: absolute; top: var(--s-3); left: var(--s-3); right: var(--s-3); z-index: 1; }
.wf-mobile-actions { display: none; position: absolute; left: var(--s-3); bottom: var(--s-3); gap: var(--s-2); }

@media (max-width: 1023px) {
  .wf-mobile-banner { display: flex; }
  .wf-editor-body { grid-template-columns: 1fr; }
  .wf-panel--left, .wf-panel--right { display: none; }
  .wf-mobile-actions { display: flex; }
  .wf-canvas__zoom { bottom: calc(var(--s-3) + var(--control-h-lg) + var(--s-2)); }
  .wf-toolbar { flex-wrap: wrap; }
  .wf-toolbar__left { flex-wrap: wrap; row-gap: var(--s-1); }
  .wf-toolbar__name, .wf-toolbar__name-input { max-width: 46vw; }
}
/* Page styles for the connect-data group. Page-only layout; no DS overrides. */

/* ── Channels ───────────────────────────────────────────── */
.context-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.context-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); min-height: 52px; }
.context-row + .context-row { border-top: 1px solid var(--border); }
.context-row__icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--surface-2); color: var(--text-2); flex: none; }
.context-row__icon svg { width: 16px; height: 16px; }
.context-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.context-row__name { font-weight: var(--fw-medium); }

/* ── Pending messages ───────────────────────────────────── */
.two-pane { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: var(--s-4); min-height: 60vh; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.queue-list { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-width: 0; }
.queue-list__search { padding: var(--s-3); border-bottom: 1px solid var(--border); }
.queue-list__items { overflow-y: auto; flex: 1; }
.queue-item { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); width: 100%; padding: var(--s-3); border: none; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; color: inherit; }
.queue-item:hover { background: var(--surface-2); }
.queue-item--active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.queue-item__meta { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-1); flex: none; }
.queue-detail { display: flex; flex-direction: column; min-width: 0; }
.queue-detail--empty { align-items: center; justify-content: center; }
.queue-detail__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); border-bottom: 1px solid var(--border); }
.queue-detail__back { display: none; }
.queue-detail__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.queue-detail__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin: 0; }
.queue-detail__body { flex: 1; overflow-y: auto; padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.queue-msg { max-width: 70%; padding: var(--s-3); border-radius: var(--r-lg); background: var(--surface-2); align-self: flex-start; }
.queue-msg[data-from="agent"] { align-self: flex-end; background: var(--accent-soft); }
.queue-msg__text { margin: 0 0 var(--s-1); white-space: pre-wrap; }
.queue-msg__time { font-size: var(--fs-xs); color: var(--text-3); }

@media (max-width: 720px) {
  .two-pane { grid-template-columns: 1fr; }
  .queue-list { border-right: none; }
  .queue-list[data-hide-mobile] { display: none; }
  .queue-detail__back { display: inline-flex; }
}

/* ── Memory ──────────────────────────────────────────────── */
.memory-agent-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.memory-agent-bar > .select-trigger { min-width: 220px; }
.memory-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.memory-result { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.memory-result__title { margin: 0; font-weight: var(--fw-medium); }
.memory-result__text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-result__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-3); }
.memory-search-form { display: flex; align-items: flex-end; gap: var(--s-2); }
.memory-search-form > :first-child { flex: 1; min-width: 0; }

/* ── Knowledge base — graph ─────────────────────────────── */
.graph-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.graph-toolbar > :first-child { min-width: 220px; flex: 1; }
.graph-toolbar > .select-trigger { width: 132px; flex: none; margin-left: auto; }
.graph-canvas { position: relative; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); overflow: hidden; }
.graph-canvas__toolbar { position: absolute; top: var(--s-3); right: var(--s-3); z-index: 1; display: flex; gap: var(--s-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-1); box-shadow: var(--shadow-sm); }
.graph-canvas__svg { width: 100%; height: min(560px, 70vh); display: block; touch-action: none; cursor: grab; }
.graph-canvas__svg:active { cursor: grabbing; }
.graph-edge { stroke: var(--border-strong); stroke-width: 1.5; transition: opacity var(--dur-fast) var(--ease-out); }
.graph-edge--dim { opacity: 0.15; }
.graph-node { cursor: pointer; transition: opacity var(--dur-fast) var(--ease-out); }
.graph-node--dim { opacity: 0.25; }
.graph-node circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.graph-node text { font-size: var(--fs-2xs); fill: var(--text-2); font-family: var(--font-sans); }
.graph-node--selected circle { stroke: var(--text); stroke-width: 3; }
.graph-node.n-person circle { fill: var(--accent); }
.graph-node.n-org circle { fill: var(--info-solid); }
.graph-node.n-product circle { fill: var(--warning-solid); }
.graph-node.n-topic circle { fill: var(--success-solid); }
.graph-node.n-location circle { fill: var(--danger-solid); }

.graph-node.n-doc-note circle { fill: var(--info-solid); }
.graph-node.n-doc-context circle { fill: var(--success-solid); }
.graph-node.n-doc-memory circle { fill: var(--warning-solid); }
.graph-node.n-doc-skill circle { fill: var(--danger-solid); }
.graph-node.n-doc-episodic circle, .graph-node.n-doc-media circle { fill: var(--text-3); }

/* ── Knowledge base — vault views ───────────────────────── */
.kb-view-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.kb-enrichment { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.kb-enrichment__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.kb-enrichment__text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 200px; }
.kb-enrichment__count { display: inline-flex; gap: var(--s-2); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.kb-enrichment__errors { color: var(--danger); }
.kb-enrichment__last-error { margin: 0; font-size: var(--fs-xs); color: var(--text-3); overflow-wrap: anywhere; }
.kb-links { display: flex; flex-direction: column; gap: var(--s-2); }
.kb-links__heading { display: flex; align-items: center; gap: var(--s-1); margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.kb-links__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.kb-links__item { display: flex; align-items: flex-start; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r-md); }
.kb-links__item:hover { background: var(--surface-2); }
.kb-links__body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.kb-links__context { font-size: var(--fs-xs); overflow-wrap: anywhere; }

/* ── Storage ─────────────────────────────────────────────── */
.storage-layout { display: grid; grid-template-columns: 220px 1fr; gap: var(--s-5); align-items: start; }
.storage-layout__tree { display: flex; flex-direction: column; gap: var(--s-4); position: sticky; top: var(--s-4); }
.storage-layout__main { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
@media (max-width: 900px) {
  .storage-layout { grid-template-columns: 1fr; }
  .storage-layout__tree { position: static; }
}
/* Page styles for the monitor group. Page-only layout; no DS overrides. */

/* ── Usage ── */
.usage-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-2); }
.usage-controls__agent { width: 200px; max-width: 100%; }
.usage-range-error { margin: calc(var(--s-2) * -1) 0 var(--s-2); font-size: var(--fs-sm); }
.usage-chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); margin-bottom: var(--s-4); }
.usage-freshness { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-3); font-size: var(--fs-sm); }
.dt-totals {
  display: grid; grid-template-columns: 1fr repeat(6, minmax(64px, auto)); gap: var(--s-2);
  padding: var(--s-2-5) var(--s-4); border-top: 1px solid var(--border-strong); background: var(--surface-2);
  font-weight: var(--fw-semibold); font-size: var(--fs-sm);
}
.dt-totals span:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 719px) { .dt-totals { grid-template-columns: 1fr 1fr; } .dt-totals span:nth-child(n+4) { display: none; } }

/* ── Activity ── */
.activity-feed { display: flex; flex-direction: column; gap: var(--s-6); }
.activity-day__head { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-3); margin: 0 0 var(--s-2); }
.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.activity-row { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); }
.activity-row + .activity-row { border-top: 1px solid var(--border); }
.activity-row__body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: var(--s-1); }
.activity-row__text { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.activity-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); font-size: var(--fs-xs); color: var(--text-3); }
.activity-chip {
  display: inline-flex; align-items: center; gap: var(--s-1); padding: 2px var(--s-2); border-radius: var(--r-full);
  border: 1px solid var(--border); color: var(--text-2); text-decoration: none; font-size: var(--fs-xs);
}
.activity-chip:hover { border-color: var(--accent-line); color: var(--accent-text); background: var(--accent-soft); }
.activity-chip svg { width: 12px; height: 12px; }

/* ── Traces ── */
.traces-thresholds { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-end; max-width: 420px; margin: var(--s-2) 0; }
.traces-thresholds > * { flex: 1 1 160px; }
.traces-refresh { display: flex; align-items: center; gap: var(--s-3); margin: var(--s-2) 0 var(--s-3); }
.trace-duration { position: relative; display: inline-flex; align-items: center; justify-content: flex-end; min-width: 88px; padding: 2px 0; isolation: isolate; }
.trace-duration__bar { position: absolute; right: 0; top: 50%; height: 4px; transform: translateY(-50%); background: var(--accent-soft-2); border-radius: var(--r-full); z-index: 0; }
.trace-duration__value { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }

/* ── Span waterfall (traces sheet + trace detail) ── */
.span-waterfall { display: flex; flex-direction: column; gap: var(--s-1); }
.span-waterfall__row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.4fr) 64px; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-2); border-radius: var(--r-md); border: 1px solid transparent; background: none; text-align: left; cursor: pointer;
}
.span-waterfall__row:hover { background: var(--surface-2); }
.span-waterfall__row[data-selected] { border-color: var(--accent-line); background: var(--accent-soft); }
.span-waterfall__row[data-nested] .span-waterfall__label { padding-left: var(--s-5); }
.span-waterfall__row[data-ancillary] { opacity: 0.65; }
.span-waterfall__label { display: flex; align-items: center; gap: var(--s-2); min-width: 0; font-size: var(--fs-sm); }
.span-waterfall__text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.span-waterfall__summary { font-size: var(--fs-xs); color: var(--text-3); }
.span-waterfall__row[data-error] .span-waterfall__name { color: var(--danger); }
.span-waterfall__tokens { flex: none; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.span-waterfall__icon { display: inline-flex; flex: none; }
.span-waterfall__icon svg { width: 14px; height: 14px; }
.span-waterfall__redacted { font-size: var(--fs-xs); color: var(--text-4); letter-spacing: 1px; }
.span-waterfall__track { position: relative; height: 8px; background: var(--surface-sunken); border-radius: var(--r-full); }
.span-waterfall__bar { position: absolute; top: 0; height: 100%; border-radius: var(--r-full); }
.span-waterfall__dur { font-size: var(--fs-xs); color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 719px) {
  .span-waterfall__row { grid-template-columns: 1fr; row-gap: var(--s-1); }
  .span-waterfall__track { order: 3; }
  .span-waterfall__dur { order: 2; text-align: left; }
}

/* ── Trace detail page ── */
.trace-detail__spans { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--s-5); align-items: start; }
.trace-detail__span-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); min-width: 0; }
/* On the side-by-side layout the record scrolls on its own so the waterfall stays in view. */
@media (min-width: 960px) { .trace-detail__spans .trace-detail__span-panel { position: sticky; top: var(--s-4); max-height: calc(100vh - var(--s-8)); overflow: auto; } }
.trace-token-foot { display: flex; flex-wrap: wrap; gap: 0 var(--s-2); }

/* ── Span record (trace detail) ── */
.span-section__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; }
.span-section__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.span-section__meta { font-size: var(--fs-xs); }
.span-section__label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-2); }
.span-truncated { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--warning); }
.span-truncated svg { width: 12px; height: 12px; flex: none; }
.span-errors { margin: 0; padding-left: var(--s-4); display: flex; flex-direction: column; gap: var(--s-1); word-break: break-word; }
.span-meta-value { font-family: var(--font-mono); font-size: var(--fs-xs); word-break: break-all; }
.span-attempts { margin: 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); font-size: var(--fs-sm); }
.span-attempts__row { display: flex; flex-direction: column; gap: 2px; }
.span-attempts__head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.span-attempts__detail { font-size: var(--fs-xs); word-break: break-word; }
.span-tool-requests { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.span-tool-requests__row { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); min-width: 0; }
.span-tool-requests__row .truncate { flex: 1; min-width: 0; }
.span-tool-result--error { border-left: 3px solid var(--danger); padding-left: var(--s-2); }
.trace-conversation { display: flex; flex-direction: column; gap: var(--s-2); }
.trace-msg { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); background: var(--surface); min-width: 0; }
.trace-msg[data-role="user"] { border-left: 3px solid var(--info); }
.trace-msg[data-role="assistant"] { border-left: 3px solid var(--accent); }
.trace-msg[data-role="tool"] { border-left: 3px solid var(--warning); }
.trace-msg[data-error] { border-left-color: var(--danger); }
.trace-msg--omitted { border-style: dashed; font-size: var(--fs-xs); text-align: center; }
.trace-msg__head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; font-size: var(--fs-xs); }
.trace-msg__body { max-height: 320px; overflow: auto; font-size: var(--fs-sm); }
.trace-msg__body--thinking { color: var(--text-3); }
.trace-conversation-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
@media (max-width: 959px) { .trace-conversation-card { grid-template-columns: 1fr; } }
.trace-detail__footnote { margin-top: var(--s-2); }
@media (max-width: 959px) { .trace-detail__spans { grid-template-columns: 1fr; } }

.hook-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-2) 0; font-size: var(--fs-sm); }
.hook-row .muted { flex: 1; min-width: 120px; }

.eval-row { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); }
.eval-row__head { display: flex; align-items: center; gap: var(--s-2); }

/* ── Runtime health ── */
.runtime-health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.runtime-health-grid__wide { grid-column: 1 / -1; }
@media (max-width: 719px) { .runtime-health-grid { grid-template-columns: 1fr; } }

/* ── Quotas & limits ── */
.limits-quota-grid { display: flex; flex-direction: column; gap: var(--s-4); }
.limits-quota-row { display: grid; grid-template-columns: minmax(120px, 160px) repeat(3, minmax(0, 1fr)); gap: var(--s-4); align-items: end; padding-bottom: var(--s-3); border-bottom: 1px solid var(--border); }
.limits-quota-row:last-child { border-bottom: none; padding-bottom: 0; }
.limits-quota-row__name { font-weight: var(--fw-medium); align-self: center; }
@media (max-width: 719px) { .limits-quota-row { grid-template-columns: 1fr; gap: var(--s-2); } .limits-quota-row__name { padding-bottom: var(--s-1); } }
/* Page styles for the admin group. Page-only layout; no DS overrides. */

/* ── Roles: permission matrix ── */
.permission-matrix { overflow-x: auto; }
.permission-matrix__head, .permission-matrix__row { display: grid; grid-template-columns: minmax(160px, 1fr) repeat(3, 64px); align-items: center; min-width: 420px; }
.permission-matrix__head { padding: 0 var(--s-3) var(--s-2); color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.02em; }
.permission-matrix__group { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; margin-bottom: var(--s-2); min-width: 420px; }
.permission-matrix__group-head { background: var(--surface-sunken); padding: var(--s-2) var(--s-3); font-weight: var(--fw-medium); }
.permission-matrix__row { padding: var(--s-2) var(--s-3); border-top: 1px solid var(--border); }
.permission-matrix__row-label { color: var(--text-2); }

/* ── Settings: section picker (phone) vs. left nav (desktop) ── */
.settings-section-select { display: none; }
@media (max-width: 719px) {
  .split__nav { display: none; }
  .settings-section-select { display: block; margin-bottom: var(--s-4); }
}

/* ── Settings: inherited-from-master / reset-to-default row under a field ── */
.override-field__status { justify-content: space-between; margin-top: var(--s-1); }
.override-field__note { font-size: var(--fs-xs); }

/* ── Settings: sticky dirty save bar ── */
.save-bar {
  position: sticky; bottom: var(--s-4); z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  margin-top: var(--s-6); padding: var(--s-3) var(--s-4); border-radius: var(--r-lg);
  background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-md);
}

/* ── Import / export: resource-type picker (chip grid on desktop, Select on phone) ── */
.ie-type-picker { display: flex; flex-direction: column; gap: var(--s-3); }
.ie-type-picker__chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ie-type-picker__select { display: none; }
.ie-type-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); cursor: pointer; transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.ie-type-chip:hover { background: var(--surface-2); }
.ie-type-chip[data-active] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
@media (max-width: 719px) {
  .ie-type-picker__chips { display: none; }
  .ie-type-picker__select { display: block; }
}
/* Page styles for the design-system group. Page-only layout; no DS overrides. */

/* ── Design System gallery ─────────────────────────────────── */

.ds-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "topbar topbar" "toc main";
  min-height: 100dvh;
  background: var(--bg);
}

.ds-topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: var(--topbar-h);
  padding: var(--s-2) var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.ds-topbar__title { font-weight: var(--fw-semibold); color: var(--text); white-space: nowrap; }
.ds-topbar__controls { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.ds-topbar__cta { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; }
.ds-topbar__cta svg { width: var(--icon-sm); height: var(--icon-sm); }

.ds-toc {
  grid-area: toc;
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-4) var(--s-3);
  border-right: 1px solid var(--border);
}
.ds-toc__link {
  padding: var(--s-1-5) var(--s-2);
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: var(--fs-sm);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ds-toc__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.ds-toc__link[data-active] { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-medium); }

.ds-main {
  grid-area: main;
  min-width: 0;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-8) var(--gutter) var(--s-20);
  display: flex;
  flex-direction: column;
  gap: var(--s-16);
}

.ds-section { scroll-margin-top: calc(var(--topbar-h) + var(--s-4)); min-width: 0; }
.ds-section__head { margin-bottom: var(--s-4); max-width: 760px; }
.ds-section__title { font-size: var(--fs-2xl); letter-spacing: var(--tracking-tight); }
.ds-section__blurb { color: var(--text-2); margin-top: var(--s-1); }

.ds-example { min-width: 0; }
.ds-example__stage { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.ds-example__note { color: var(--text-3); font-size: var(--fs-sm); margin: var(--s-2) 0 0; }

.ds-dodont { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.ds-dodont__card { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-lg); border: 1px solid var(--border); }
.ds-dodont__card--do { border-color: var(--success-line); background: var(--success-soft); }
.ds-dodont__card--dont { border-color: var(--danger-line); background: var(--danger-soft); }
.ds-dodont__icon { flex: none; width: 20px; height: 20px; display: grid; place-items: center; }
.ds-dodont__card--do .ds-dodont__icon { color: var(--success-solid); }
.ds-dodont__card--dont .ds-dodont__icon { color: var(--danger-solid); }
.ds-dodont__label { display: block; font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--text); }
.ds-dodont__card p { margin: var(--s-1) 0 0; font-size: var(--fs-sm); color: var(--text-2); }
@media (max-width: 560px) { .ds-dodont { grid-template-columns: minmax(0, 1fr); } }

.ds-token-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ds-token-row { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.ds-token-row__text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.ds-token-row__value { font-size: var(--fs-xs); }
.ds-swatch { display: inline-block; width: 32px; height: 32px; border-radius: var(--r-md); border: 1px solid var(--border); flex: none; }
.ds-swatch[data-shape="circle"] { border-radius: 999px; }
.ds-swatch--aura { width: 48px; height: 48px; border-radius: var(--r-lg); border: none; }

.ds-type-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }

.ds-scale-row { display: flex; align-items: center; gap: var(--s-3); }
.ds-scale-bar { height: 12px; min-width: 4px; background: var(--accent); border-radius: var(--r-xs); flex: none; }

.ds-radius-grid, .ds-shadow-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.ds-radius-sample, .ds-shadow-sample { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; min-width: 0; }
.ds-radius-box { width: 56px; height: 56px; background: var(--accent-soft-2); border: 1px solid var(--accent-line); flex: none; }
.ds-shadow-box { width: 56px; height: 56px; background: var(--surface); border-radius: var(--r-md); flex: none; }

.ds-motion-row { display: flex; align-items: center; gap: var(--s-3); }
.ds-motion-track { position: relative; flex: 1; min-width: 0; height: 8px; background: var(--surface-sunken); border-radius: 999px; overflow: hidden; }
.ds-motion-dot {
  position: absolute; top: 50%; left: 0; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
  background: var(--accent); animation-name: ds-motion-run; animation-fill-mode: forwards;
}
@keyframes ds-motion-run { from { left: 0; } to { left: calc(100% - 8px); } }

.ds-matrix-label { width: 92px; flex: none; }

.ds-tree-demo { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-2); min-width: 0; }

.ds-anatomy { display: flex; flex-direction: column; gap: var(--s-4); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); padding: var(--s-4); min-width: 0; }

@media (max-width: 900px) {
  .ds-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "topbar" "toc" "main"; }
  .ds-toc {
    position: sticky; top: var(--topbar-h); height: auto; flex-direction: row; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--border); padding: var(--s-2) var(--gutter);
  }
  .ds-toc__link { white-space: nowrap; }
}

@media (max-width: 719px) {
  .ds-main { gap: var(--s-12); }
  .ds-topbar__controls { width: 100%; justify-content: flex-start; }
}
/*
 * Astro wraps each React island in <astro-island style="display:contents">.
 * Layout still works (display:contents keeps the sidebar a grid item of .app),
 * but child combinators written for the prototype's flat DOM no longer match.
 * These rules restate them for the island wrapper; the ported stylesheets stay verbatim.
 */
@media (max-width: 719px) { .app > astro-island > .sidebar { display: none; } }
