/* =============================================================
   DRYL Design System — Core Tokens & Primitives
   Glassmorphism · Dark · Indirect Light · Motion
   ============================================================= */

:root {
  /* Tell the browser this surface is dark — applies to native UA controls (<select> dropdowns, scrollbars, form autofill) so they don't ship light-mode defaults onto our glass. */
  color-scheme: dark;

  /* Palette — neutrals (pure black ground, layered glass) */
  --ground:        #000000;
  --bg-0:          #000000;
  --bg-1:          #07070a;
  --bg-2:          #0c0c12;
  --bg-3:          #14141c;
  --line:          rgba(255, 255, 255, 0.06);
  --line-strong:   rgba(255, 255, 255, 0.12);
  --line-soft:     rgba(255, 255, 255, 0.04);

  /* Glass surfaces */
  --glass-1:       rgba(255, 255, 255, 0.03);
  --glass-2:       rgba(255, 255, 255, 0.05);
  --glass-3:       rgba(255, 255, 255, 0.08);
  --glass-blur:    18px;

  /* Text */
  --fg:            #f4f4f7;
  --fg-muted:      rgba(244, 244, 247, 0.62);
  --fg-dim:        rgba(244, 244, 247, 0.38);
  --fg-faint:      rgba(244, 244, 247, 0.22);

  /* Accent — gradient violet → cyan */
  --accent-a:      #7c5cff;
  --accent-b:      #22d3ee;
  --accent:        var(--accent-a);
  --accent-soft:   rgba(124, 92, 255, 0.18);
  --accent-line:   rgba(124, 92, 255, 0.45);
  --accent-grad:   linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  --accent-grad-r: linear-gradient(135deg, var(--accent-b) 0%, var(--accent-a) 100%);

  /* Semantic */
  --success:       #34d399;
  --warning:       #fbbf24;
  --danger:        #f87171;
  --info:          var(--accent-b);

  /* Type */
  --font-sans:     'Inter', 'Inter Placeholder', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:     'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Scale */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Shadows / indirect light */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.35);
  --shadow-lg:  0 24px 64px rgba(0,0,0,0.55), 0 8px 16px rgba(0,0,0,0.35);
  --glow-accent: 0 0 0 1px var(--accent-line), 0 8px 32px rgba(124, 92, 255, 0.35), 0 0 64px rgba(34, 211, 238, 0.18);
  --glow-soft:   0 0 60px rgba(124, 92, 255, 0.18), 0 0 120px rgba(34, 211, 238, 0.08);

  /* Motion */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:    140ms;
  --dur-med:     240ms;
  --dur-slow:    420ms;

  /* Layering */
  --z-sticky:    5;
  --z-drawer:   50;
  --z-modal:   100;
  --z-popover: 150;
  --z-toast:   200;

  /* App chrome dimensions — consumed by .topbar / .sidebar / .app-shell.
     Overridable per layout via inline custom properties (DrylLayout.SidebarWidth). */
  --appbar-h:            60px;
  --sidebar-w:          260px;
  --sidebar-collapsed-w: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--fg);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(124, 92, 255, 0.12), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(34, 211, 238, 0.08), transparent 60%),
    radial-gradient(900px 700px at 50% 110%, rgba(124, 92, 255, 0.06), transparent 60%),
    var(--ground);
  background-attachment: fixed;
}

/* Subtle film grain over everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: var(--grain-opacity, 0.4);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Aurora — slow drifting orbs in the deep background */
.aurora {
  position: fixed;
  inset: -20vh -20vw;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  filter: blur(70px) saturate(140%);
  opacity: 0.85;
}
.aurora::before,
.aurora::after,
.aurora .orb {
  content: '';
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
}
.aurora::before {
  width: 50vw;
  height: 50vw;
  left: -10vw;
  top: 10vh;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.55), transparent 60%);
  animation: drift-a 22s ease-in-out infinite alternate;
}
.aurora::after {
  width: 45vw;
  height: 45vw;
  right: -5vw;
  top: -10vh;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.38), transparent 60%);
  animation: drift-b 28s ease-in-out infinite alternate;
}
.aurora .orb {
  width: 40vw;
  height: 40vw;
  left: 40%;
  bottom: -20vh;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.3), transparent 60%);
  animation: drift-c 34s ease-in-out infinite alternate;
}

@keyframes drift-a {
  0%   { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(15vw, 10vh, 0) scale(1.15); }
}
@keyframes drift-b {
  0%   { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(-12vw, 8vh, 0) scale(1.1); }
}
@keyframes drift-c {
  0%   { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(-8vw, -12vh, 0) scale(1.2); }
}

/* App scaffold */
#root { position: relative; z-index: 2; min-height: 100vh; }

/* ============== TYPE ============== */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 56px; line-height: 1.05; letter-spacing: -0.035em; font-weight: 700; }
h2 { font-size: 32px; line-height: 1.15; letter-spacing: -0.025em; }
h3 { font-size: 20px; line-height: 1.3; }
h4 { font-size: 15px; line-height: 1.4; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-weight: 500;
}

.mono { font-family: var(--font-mono); }

.gradient-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

p { margin: 0; color: var(--fg-muted); }
.lead { font-size: 17px; line-height: 1.55; color: var(--fg-muted); max-width: 64ch; }

a { color: var(--accent-b); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ============== GLASS PRIMITIVES ============== */
.glass {
  background: var(--glass-1);
  border: 1px solid var(--line);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  border-radius: var(--r-lg);
}

.glass-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)),
    rgba(10, 10, 14, 0.4);
  border: 1px solid var(--line);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  border-radius: var(--r-lg);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-md);
  transition: transform var(--dur-med) var(--ease-out),
              border-color var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out);
}
.glass-card::after {
  /* radial glow behind the card */
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(80% 60% at 50% 0%, rgba(124,92,255,0.0), transparent 70%);
  pointer-events: none;
  transition: background var(--dur-med) var(--ease-out);
  z-index: -1;
}
.glass-card:hover::after {
  background: radial-gradient(80% 60% at 50% 0%, rgba(124,92,255,0.18), transparent 70%);
}
.glass-card:hover {
  border-color: var(--line-strong);
}

/* Glass-card padding presets (consumed by DrylCard.CardPadding) */
.glass-card.p-0       { padding: 0; }
.glass-card.p-tight   { padding: var(--sp-4); }
.glass-card.p-default { padding: var(--sp-5); }
.glass-card.p-loose   { padding: var(--sp-6); }

/* ============== BUTTONS ============== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  font: 500 13px/1 var(--font-sans);
  letter-spacing: -0.005em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform var(--dur-med) var(--ease-spring),
              background var(--dur-med) var(--ease-out),
              border-color var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out),
              color var(--dur-med) var(--ease-out);
  isolation: isolate;
}
/* Press: drop + shrink, then spring back on release (transform easing above). */
.btn:not(:disabled):active { transform: translateY(0) scale(0.96); }

/* Glass sheen — a soft reflection sweeps across the surface on hover. Clipped by
   border-radius (no overflow:hidden, so the AI-aura ring is untouched). Not on the
   chromeless Ghost variant, and never while disabled. */
.btn:not(.btn-ghost)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 255, 255, 0.22) 50%,
    transparent 62%
  );
  background-size: 250% 100%;
  background-position: 150% 0;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.btn:not(.btn-ghost):not(:disabled):hover::after {
  opacity: 1;
  background-position: -50% 0;
  transition: background-position var(--dur-slow) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}

/* Icons spring on hover: trailing slides forward (forward affordance), leading pops,
   icon-only scales. Marker classes come from DrylButton's leading/trailing slots. */
.btn .btn-ico-lead,
.btn .btn-ico-trail { transition: transform var(--dur-med) var(--ease-spring); }
.btn:not(:disabled):hover .btn-ico-trail { transform: translateX(3px); }
.btn:not(:disabled):hover .btn-ico-lead  { transform: translateX(-1px) scale(1.06); }
.btn-icon:not(:disabled):hover .btn-ico-lead,
.btn-icon:not(:disabled):hover .btn-ico-trail { transform: scale(1.12); }

.btn-primary {
  background: var(--accent-grad);
  color: white;
  border-color: rgba(255,255,255,0.12);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.18) inset,
    0 0 0 1px rgba(124,92,255,0.25),
    0 6px 24px rgba(124,92,255,0.35),
    0 0 48px rgba(34,211,238,0.18);
}
.btn-primary:hover {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.22) inset,
    0 0 0 1px rgba(124,92,255,0.4),
    0 10px 36px rgba(124,92,255,0.5),
    0 0 64px rgba(34,211,238,0.28);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--glass-2);
  border-color: var(--line-strong);
  backdrop-filter: blur(12px);
}
.btn-secondary:hover {
  background: var(--glass-3);
  border-color: var(--accent-line);
  box-shadow: 0 0 0 1px var(--accent-line), 0 0 24px rgba(124,92,255,0.18);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
}
.btn-ghost:hover {
  background: var(--glass-2);
  color: var(--fg);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
  box-shadow: 0 0 24px rgba(248, 113, 113, 0.25);
}

.btn-icon {
  width: 38px;
  padding: 0;
}

/* Pressed / toggled state — driven by DrylButton's Pressed parameter
   (aria-pressed="true"). Accent border + glow, like a secondary on. */
.btn--active {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 1px var(--accent-line), 0 0 20px rgba(124, 92, 255, 0.18);
  color: var(--fg);
}

/* Disabled — must read clearly as inert across every variant: dimmed, flat,
   desaturated, and stripped of the accent glow that otherwise makes a primary
   look active. Hover sheen, press and icon springs are already gated behind
   :not(:disabled). */
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.5);
  transform: none;
}

.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-sm.btn-icon { width: 30px; padding: 0; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 14px; }

/* ============== BUTTON GROUP ============== */
/* Joins adjacent DrylButtons into a segmented control: inner corners are
   flattened and borders overlap by 1px so the cluster reads as one outline.
   Outer corners keep each button's own radius (so --sm / --lg are honoured). */
.btn-group { display: inline-flex; align-items: stretch; }
.btn-group--block { display: flex; width: 100%; }
.btn-group--block > .btn { flex: 1 1 0; }

.btn-group > .btn:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}
.btn-group > .btn:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
/* Raise the interacted segment so its border / glow isn't clipped by the
   neighbour overlapping it. */
.btn-group > .btn:hover,
.btn-group > .btn:focus-visible,
.btn-group > .btn.btn--active { z-index: 1; }

/* ============== SPLIT BUTTON ============== */
/* A main action joined to a caret (the caret lives inside a DrylMenu's
   popover-anchor, hence the descendant selectors for the second segment). */
.split-btn { display: inline-flex; align-items: stretch; }
.split-btn--block { display: flex; width: 100%; }
.split-btn--block > .btn { flex: 1 1 auto; }

.split-btn > .btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.split-btn > .popover-anchor { margin-left: -1px; }
.split-btn > .popover-anchor .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.split-btn > .btn:hover,
.split-btn > .btn:focus-visible,
.split-btn > .popover-anchor .btn:hover,
.split-btn > .popover-anchor .btn:focus-visible { z-index: 1; }

/* ============== INPUTS ============== */
.input,
.textarea,
.select {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-md);
  background: var(--glass-1);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  font: 400 13px/1 var(--font-sans);
  transition: border-color var(--dur-med) var(--ease-out),
              background var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--fg-dim); }
.input:hover, .textarea:hover, .select:hover { border-color: rgba(255,255,255,0.18); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent-line);
  background: var(--glass-2);
  /* 1px flush ring fuses with the border into one crisp accent edge, then a soft
     halo, then ambient glow — reads as a single confident corner, not a thin line
     with a detached block around it. */
  box-shadow: 0 0 0 1px var(--accent-line),
              0 0 0 4px rgba(124, 92, 255, 0.12),
              0 0 24px rgba(124, 92, 255, 0.18);
}
/* The global :focus-visible rule adds a bright cyan outline that clashes with the
   violet glow above. Suppress it here — the glow already satisfies WCAG focus visibility. */
.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible { outline: none; }
.textarea {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
  min-height: 96px;
}

/* Select — strip native arrow, draw our own, give <option> a real dark surface */
.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.select option {
  background: var(--bg-2);
  color: var(--fg);
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

/* Input field wrapper (label + input + icons + helper) */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* Textarea wrapper — gives <textarea> a positionable host so AI primitives
   (and future extensions) have something to layer on. Visually transparent. */
.textarea-wrapper {
  position: relative;
  display: flex;
  width: 100%;
}
.textarea-wrapper > .textarea { flex: 1; }

/* AI mode on inputs needs an explicit radius on the wrapper so .ai-aura-ring
   (which uses border-radius: inherit) traces the input's rounded corners. */
.input-wrapper.ai-aura,
.textarea-wrapper.ai-aura {
  border-radius: var(--r-md);
}

/* AI mode on the file-upload drop zone — echo the .file-drop radius (--r-lg)
   on the wrapper so the rotating ring and breathing glow trace its rounded
   corners instead of a square box. */
.file-upload-wrapper.ai-aura {
  border-radius: var(--r-lg);
}

/* AI mode on radio groups — give the wrapper a surface + radius so the
   rotating ring has rounded corners and the group reads as a contained panel. */
.radio-group-wrapper.ai-aura {
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  background: var(--glass-1);
}

/* AI mode on buttons — additive: variant's solid/glass background stays intact
   underneath, a rotating gradient ring traces the button via ::before. No
   wash, no breathing glow — at button size, the ring alone is enough signal. */
.btn.ai-aura::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from var(--ai-aura-angle, 0deg),
    var(--accent-a),
    var(--accent-b),
    var(--accent-a),
    var(--accent-b),
    var(--accent-a)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
  opacity: 0.85;
  animation: ai-aura-rotate 6s linear infinite;
}
.btn.ai-aura.ai-thinking::before  { animation-duration: 1.8s; opacity: 1; }
.btn.ai-aura.ai-streaming::before { animation-duration: 3s; }
.btn.ai-aura.ai-generated::before { animation-duration: 4s; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .btn.ai-aura::before { animation: none; opacity: 0.6; }
  .btn:not(.btn-ghost)::after { display: none; }
  .btn .btn-ico-lead,
  .btn .btn-ico-trail { transition: none; }
  .btn:hover .btn-ico-lead,
  .btn:hover .btn-ico-trail { transform: none; }
}

.input-wrapper .input-icon,
.tbl-search .input-icon {
  position: absolute;
  color: var(--fg-dim);
  pointer-events: none;
  transition: color var(--dur-med) var(--ease-out);
}
.input-wrapper:focus-within .input-icon,
.tbl-search:focus-within .input-icon { color: var(--fg-muted); }
.input-wrapper .input-icon-leading  { left: 12px; }
.input-wrapper .input-icon-trailing { right: 12px; }

.input.has-leading-icon  { padding-left: 38px; }
.input.has-trailing-icon { padding-right: 38px; }

.input.input-error,
.textarea.input-error,
.select.input-error { border-color: rgba(248, 113, 113, 0.5); }
.input.input-error:focus,
.textarea.input-error:focus,
.select.input-error:focus {
  border-color: var(--danger);
  background: var(--glass-2);
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.12), 0 0 24px rgba(248, 113, 113, 0.18);
}
.input.input-success,
.textarea.input-success,
.select.input-success { border-color: rgba(52, 211, 153, 0.5); }
.input.input-success:focus,
.textarea.input-success:focus,
.select.input-success:focus {
  border-color: var(--success);
  background: var(--glass-2);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12), 0 0 24px rgba(52, 211, 153, 0.18);
}

.input:disabled, .textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-helper {
  font-size: 12px;
  color: var(--fg-dim);
  line-height: 1.4;
}
.input-helper-error { color: var(--danger); }

/* Checkbox */
.checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--glass-1);
  border: 1px solid var(--line-strong);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
}
.checkbox:hover { border-color: var(--accent-line); }
.checkbox:checked {
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: 0 0 16px rgba(124,92,255,0.5);
}
.checkbox::after {
  content: '';
  width: 10px;
  height: 6px;
  border: 2px solid white;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  opacity: 0;
  transition: transform var(--dur-med) var(--ease-spring),
              opacity var(--dur-fast) var(--ease-out);
}
.checkbox:checked::after {
  transform: rotate(-45deg) translate(1px, -1px) scale(1);
  opacity: 1;
}

/* Toggle */
.toggle {
  appearance: none;
  width: 36px;
  height: 20px;
  border-radius: var(--r-pill);
  background: var(--glass-2);
  border: 1px solid var(--line-strong);
  position: relative;
  cursor: pointer;
  transition: background var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--fg-muted);
  transition: transform var(--dur-med) var(--ease-spring), background var(--dur-med) var(--ease-out);
}
.toggle:checked {
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(124,92,255,0.45);
}
.toggle:checked::after {
  background: white;
  transform: translateX(16px);
}

/* ============== BADGES ============== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--line-strong);
  background: var(--glass-2);
  color: var(--fg-muted);
}
.badge-accent {
  color: #d6cbff;
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.badge-success { color: var(--success); border-color: rgba(52, 211, 153, 0.3); background: rgba(52,211,153,0.1); }
.badge-warning { color: var(--warning); border-color: rgba(251, 191, 36, 0.3); background: rgba(251,191,36,0.1); }
.badge-danger  { color: var(--danger);  border-color: rgba(248, 113, 113, 0.3); background: rgba(248,113,113,0.1); }
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* ============== UTILITIES ============== */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.divider { height: 1px; background: var(--line); width: 100%; }
.divider-v { width: 1px; background: var(--line); align-self: stretch; }

.fade-in { animation: fadeIn 480ms var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.stagger > * { animation: rise 520ms var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 360ms; }
.stagger > *:nth-child(8) { animation-delay: 420ms; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* Focus ring for keyboard users.
   Do NOT force a border-radius here — modern browsers draw the outline along the
   element's own radius, and clobbering it (every component shares this rule's
   specificity) makes rounded surfaces like .input snap to square corners on focus. */
:focus-visible { outline: 2px solid var(--accent-b); outline-offset: 2px; }

/* ============== APP CHROME ============== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "drawer topbar"
    "drawer main";
  min-height: 100vh;
  transition: grid-template-columns var(--dur-med) var(--ease-in-out);
}
/* Collapsed sidebar: the grid column shrinks to icon width. DrylLayout sets
   this class from its SidebarCollapsed state so the body reflows in step with
   the sidebar's own .is-collapsed width animation. Desktop only — on mobile the
   grid is a single column and the sidebar is an overlay, so collapse is moot. */
@media (min-width: 1024px) {
  .app-shell.is-sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed-w) 1fr;
  }
}
.app-shell > .sidebar { grid-area: drawer; }
.app-shell > .topbar  { grid-area: topbar; }
.app-shell > .main    { grid-area: main; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)) ;
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  overflow: hidden;
  transition: width var(--dur-med) var(--ease-in-out),
              padding var(--dur-med) var(--ease-in-out);
}

/* Structured slots (DrylDrawer Header / Content / Footer). The content area
   scrolls; header and footer stay pinned. Purely additive — drawers that pass
   plain ChildContent never render these wrappers. */
.sidebar-header { flex: 0 0 auto; }
.sidebar-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-1); }
.sidebar-footer {
  flex: 0 0 auto;
  margin-top: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}

/* Collapsed: icon-only rail. Hide text labels but keep leading icons centred.
   No JS needed — the nav primitives already wrap labels in <span>.
   Confined to desktop so the mobile overlay (below) always shows full labels —
   the collapsed state is a desktop affordance only. */
@media (min-width: 1024px) {
  .sidebar.is-collapsed {
    width: var(--sidebar-collapsed-w);
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
  }
  .sidebar.is-collapsed .nav-item > span,
  .sidebar.is-collapsed .nav-title,
  .sidebar.is-collapsed .nav-section-toggle-label,
  .sidebar.is-collapsed .nav-section-link span,
  .sidebar.is-collapsed .nav-section-chevron,
  .sidebar.is-collapsed .sidebar-collapse-hide {
    display: none;
  }
  .sidebar.is-collapsed .nav-item,
  .sidebar.is-collapsed .nav-section-toggle { justify-content: center; }
}

/* Static mode: never becomes an overlay, stays an in-flow column at any width. */
.sidebar--static { transform: none !important; }

/* Flyout mode: always an overlay (fixed, off-canvas) regardless of viewport,
   sliding in when .is-open. Pairs with the always-rendered .sidebar-backdrop. */
.sidebar--flyout {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  height: 100vh;
  transform: translateX(-100%);
  transition: transform var(--dur-med) var(--ease-out);
  z-index: var(--z-drawer);
  border-right: 1px solid var(--line-strong);
}
.sidebar--flyout.is-open { transform: translateX(0); }

/* Desktop-visible sidebar collapse toggle (DrylAppBar ShowSidebarToggle / a
   header button). Reuses the hamburger visual but is shown at all widths. */
.sidebar-toggle {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.sidebar-toggle:hover {
  background: var(--glass-2);
  border-color: var(--line-strong);
  color: var(--fg);
}
.sidebar-toggle:focus-visible {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-out);
}
/* Flyout drawers overlay at every viewport width, so their backdrop must show
   regardless of the mobile media query below. */
.sidebar-backdrop--flyout { display: block; }
.sidebar-backdrop--flyout.is-open { opacity: 1; pointer-events: auto; }

.drawer-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.drawer-toggle:hover {
  background: var(--glass-2);
  border-color: var(--line-strong);
  color: var(--fg);
}
.drawer-toggle:focus-visible {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

@media (max-width: 1023px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .app-shell > .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--dur-med) var(--ease-out);
    z-index: 50;
    border-right: 1px solid var(--line-strong);
  }
  .app-shell > .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: block;
  }
  .sidebar-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }
  .drawer-toggle {
    display: inline-flex;
  }
  /* The collapse toggle is a desktop affordance; on mobile the hamburger
     (drawer-toggle) opens the overlay instead, so hide the collapse button. */
  .sidebar-toggle {
    display: none;
  }
  .topbar { padding: 0 16px; }
  .main   { padding: 24px 16px 64px; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-grad);
  display: grid;
  place-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: white;
  letter-spacing: -0.02em;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset, 0 8px 24px rgba(124,92,255,0.4), 0 0 32px rgba(34,211,238,0.2);
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.4) 50%, transparent 70%);
  animation: shimmer 4s ease-in-out infinite;
  z-index: 1;
  pointer-events: none;
}
.brand-mark-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 2;
  mix-blend-mode: screen;
}
@keyframes shimmer {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub  { font-size: 11px; color: var(--fg-dim); font-family: var(--font-mono); letter-spacing: 0.05em; }

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: 16px 12px 4px;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  user-select: none;
}
.nav-item:hover { background: var(--glass-2); color: var(--fg); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(124,92,255,0.18), rgba(34,211,238,0.04));
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--accent-line), inset 0 0 18px rgba(124,92,255,0.15);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-grad);
  box-shadow: 0 0 12px var(--accent-a);
}
.nav-item .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.8; }
.nav-item .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-faint);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* ── Scrollable nav area ──────────────────────────────── */
.nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: var(--sp-2);
}
.nav-scroll::-webkit-scrollbar { width: 4px; }
.nav-scroll::-webkit-scrollbar-track { background: transparent; }
.nav-scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 2px;
}

/* ── Collapsible nav-section ──────────────────────────── */

/* Header used when no Href — entire row is the toggle button */
.nav-section-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: 16px 12px 4px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
  line-height: 1;
  text-align: left;
}
.nav-section-toggle:hover { color: var(--fg-dim); }
.nav-section-toggle .ico { width: 14px; height: 14px; flex: 0 0 14px; opacity: 0.6; }
.nav-section-toggle-label { flex: 1; }

/* Header row used when Href is set — NavLink + separate chevron button */
.nav-section-header {
  display: flex;
  align-items: center;
  padding: 10px 4px 2px;
  gap: 2px;
}
.nav-section-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  user-select: none;
  min-width: 0;
  position: relative;
}
.nav-section-link:hover { background: var(--glass-2); color: var(--fg); }
.nav-section-link.active {
  background: linear-gradient(90deg, rgba(124,92,255,0.18), rgba(34,211,238,0.04));
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--accent-line), inset 0 0 18px rgba(124,92,255,0.15);
}
.nav-section-link.active::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-grad);
  box-shadow: 0 0 12px var(--accent-a);
}
.nav-section-link .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.8; }

.nav-section-chevron-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--fg-faint);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.nav-section-chevron-btn:hover { background: var(--glass-2); color: var(--fg-muted); }

/* Rotating chevron (shared by both header variants) */
.nav-section-chevron {
  display: block;
  transition: transform var(--dur-med) var(--ease-out);
  transform: rotate(0deg);
  flex: 0 0 auto;
}
.nav-section-chevron.is-open { transform: rotate(90deg); }

/* Animated collapse container — CSS grid trick (no fixed max-height) */
.nav-children {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-med) var(--ease-out);
}
.nav-children.is-open { grid-template-rows: 1fr; }
.nav-children-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 2px;
}

/* Indented sub nav-items */
.nav-item--sub {
  padding-left: 30px;
  height: 30px;
  font-size: 12.5px;
}

.topbar {
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
/* Raised elevation: lifts the bar off the content with a shadow and a denser
   glass tint. Flat (default) keeps the original flush look. */
.topbar.is-raised {
  background: var(--glass-2);
  box-shadow: var(--shadow-md);
}
/* Slotted layout (DrylAppBar Start / Center / End). Only rendered when at least
   one of those slots is used; plain ChildContent keeps the flat flex row above.
   Start and End flex equally so Center stays optically centred between them. */
.topbar-start  { display: flex; align-items: center; gap: var(--sp-3); flex: 1 1 0; min-width: 0; }
.topbar-center { display: flex; align-items: center; gap: var(--sp-3); flex: 0 1 auto; justify-content: center; min-width: 0; }
.topbar-end    { display: flex; align-items: center; gap: var(--sp-3); flex: 1 1 0; min-width: 0; justify-content: flex-end; }
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-muted);
}
.crumb .sep { color: var(--fg-faint); }
.crumb b { color: var(--fg); font-weight: 500; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: var(--glass-1);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  width: 320px;
  font-size: 13px;
  transition: all var(--dur-med) var(--ease-out);
  cursor: text;
}
.search:hover { border-color: var(--line-strong); }
.search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input { background: transparent; border: 0; outline: 0; color: var(--fg); width: 100%; font: 400 13px var(--font-sans); }
.search input::placeholder { color: var(--fg-dim); }

.main {
  padding: 40px 48px 80px;
  max-width: 1400px;
}

/* ============== KBD / CODE ============== */
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--glass-2);
  color: var(--fg-muted);
}
code, .code-inline {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--glass-2);
  border: 1px solid var(--line);
  color: #d6cbff;
}

.code-block {
  position: relative;
  border-radius: var(--r-md);
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 16px 18px;
  color: var(--fg-muted);
  overflow: auto;
  box-shadow: inset 0 0 60px rgba(124,92,255,0.05);
}
.code-block .tok-keyword { color: #c4b5fd; }
.code-block .tok-tag     { color: #67e8f9; }
.code-block .tok-attr    { color: #fbcfe8; }
.code-block .tok-string  { color: #86efac; }
.code-block .tok-comment { color: var(--fg-faint); font-style: italic; }
.code-block .tok-prop    { color: #fde68a; }

/* ============== SECTIONS ============== */
.section { margin-bottom: 56px; }
.section-head { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.section-head h2 { letter-spacing: -0.025em; }
.section-head p { max-width: 56ch; }

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.swatch {
  position: relative;
  height: 96px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  overflow: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform var(--dur-med) var(--ease-out);
  cursor: pointer;
}
.swatch:hover { transform: translateY(-2px); }
.swatch .name { font-size: 12px; font-weight: 500; }
.swatch .val { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-dim); margin-top: 2px; }

.type-row {
  display: grid;
  grid-template-columns: 140px 1fr 160px;
  gap: 24px;
  align-items: baseline;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.type-row:last-child { border-bottom: 0; }
.type-row .label { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); letter-spacing: 0.08em; text-transform: uppercase; }
.type-row .spec  { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); text-align: right; }

/* Stats / metric cards */
.metric {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 130px;
  position: relative;
  overflow: hidden;
}
.metric .label { font-size: 12px; color: var(--fg-muted); display: flex; align-items: center; gap: 8px; }
.metric .value { font-size: 32px; font-weight: 600; letter-spacing: -0.025em; line-height: 1; }
.metric .delta { font-family: var(--font-mono); font-size: 11px; }
.metric .delta.up { color: var(--success); }
.metric .delta.down { color: var(--danger); }
.metric .spark {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 96px;
  height: 32px;
  opacity: 0.7;
}

/* Tables — base (used by prototype and inline usage) */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
}
.tbl td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--fg-muted);
  vertical-align: middle;
}
.tbl tr:hover td { background: rgba(255,255,255,0.02); color: var(--fg); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .name { color: var(--fg); font-weight: 500; }

/* ============== TABLE COMPONENT (DrylTable) ============== */

/* Outer wrapper — clips overflow for rounded card corners */
.tbl-root { overflow: hidden; }

/* Sticky header — needs a semi-opaque background so content scrolls under */
.tbl-root .tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(7, 7, 10, 0.92);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

/* Horizontal scroll container */
.tbl-wrap { overflow-x: auto; }

/* Row interaction */
.tbl-root .tbl tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
.tbl-root .tbl tbody tr:hover td { background: var(--glass-2); color: var(--fg); }

/* Selected row */
.tbl-root .tbl tbody tr.tbl-row--selected td {
  background: rgba(124, 92, 255, 0.07);
}
.tbl-root .tbl tbody tr.tbl-row--selected:hover td {
  background: rgba(124, 92, 255, 0.12);
}

/* Checkbox column */
.tbl-col-check {
  width: 44px;
  padding-left: var(--sp-4);
  padding-right: 0;
}

/* Primary cell — full fg color + medium weight */
.tbl td.tbl-td-primary { color: var(--fg); font-weight: 500; }

/* Empty state row */
.tbl-root .tbl tbody tr.tbl-empty-row td {
  text-align: center;
  padding: var(--sp-8) var(--sp-5);
  color: var(--fg-dim);
  border-bottom: none;
}

/* Loading state row */
.tbl-root .tbl tbody tr.tbl-loading-row td {
  border-bottom: none;
  padding: 0;
}

/* AI-generated row — fades in with a slight rise and a brief accent flash
   that lingers for ~1.6s before settling. Composes with the table's wrapper
   .ai-aura ring/glow when those are active. */
.tbl-root .tbl tbody tr.tbl-row--ai-enter td {
  animation:
    tbl-row-ai-rise var(--dur-slow) var(--ease-out) both,
    tbl-row-ai-flash 1600ms var(--ease-out) both;
}

/* AI mode on the table wrapper — the .tbl-root has overflow:hidden so it can
   clip content to its rounded corners, which would otherwise eat the outer
   ring and glow. These overrides pull the AI signals inside the bounds:
   the ring traces the very-outermost pixel row, and the glow uses inset
   box-shadows so it lives within the clipped region too. */
.tbl-root .ai-aura-ring { inset: 0; }
.tbl-root .ai-aura-glow {
  box-shadow:
    inset 0 0 0 1px var(--accent-line),
    inset 0 0 48px rgba(124, 92, 255, 0.18),
    inset 0 0 96px rgba(34, 211, 238, 0.08);
}
/* Suppress the Generated lift on the table — visually distracting on a tall
   surface. The wash + row entry animations carry the reveal moment. */
.tbl-root.ai-aura.ai-generated { animation: none; }

@keyframes tbl-row-ai-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tbl-row-ai-flash {
  0%   { background-color: rgba(124, 92, 255, 0.16); }
  60%  { background-color: rgba(124, 92, 255, 0.06); }
  100% { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .tbl-root .tbl tbody tr.tbl-row--ai-enter td { animation: none; }
}

/* ============== TABLE KPI SUMMARY BAR ============== */

/* Grid of KPI tiles above the table header */
.tbl-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-bottom: 1px solid var(--line);
}

/* Individual KPI tile */
.tbl-kpi {
  padding: var(--sp-4) var(--sp-5);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  overflow: hidden;
}
.tbl-kpi:last-child { border-right: none; }

.tbl-kpi-label {
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tbl-kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-feature-settings: "tnum";
}

.tbl-kpi-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 34px;
}

.tbl-kpi-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
  align-self: flex-end;
}
.tbl-kpi-delta--positive { color: var(--success); }
.tbl-kpi-delta--negative { color: var(--danger); }
.tbl-kpi-delta--neutral  { color: var(--fg-muted); }

/* Sparkline */
.tbl-kpi-sparkline {
  width: 96px;
  height: 32px;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.7;
  transition: opacity var(--dur-med) var(--ease-out);
}
.tbl-kpi:hover .tbl-kpi-sparkline { opacity: 1; }
.tbl-kpi-sparkline polyline {
  stroke: var(--accent-b);
  fill: none;
}

/* ============== TABLE TOOLBAR + SORT (Phase 1) ============== */

/* Toolbar above the table — search input on the left, extras on the right.
   Sits between the optional KPI summary bar and the table header. */
.tbl-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}

/* Search wrapper — pins icon + input together, takes natural width on the left. */
.tbl-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
  max-width: 360px;
  flex: 0 1 auto;
}
.tbl-search .input { width: 100%; }
.tbl-search .input-icon-leading { left: 10px; pointer-events: none; }

/* Extras slot — pushed to the far right of the toolbar. */
.tbl-toolbar-extra {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Sortable header — click target, keyboard-focusable. */
.tbl th.tbl-th-sort {
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.tbl th.tbl-th-sort:hover { color: var(--fg-muted); }
.tbl th.tbl-th-sort:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: -1px;
}
.tbl th.tbl-th-sort[aria-sort="ascending"],
.tbl th.tbl-th-sort[aria-sort="descending"] {
  color: var(--fg);
}

/* Header inner layout — label + sort icon side-by-side. */
.tbl th.tbl-th-sort .tbl-th-label { display: inline; }
.tbl-th-sort-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  vertical-align: -2px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.tbl th.tbl-th-sort:hover .tbl-th-sort-icon { opacity: 0.5; }
.tbl-th-sort-icon.is-active { opacity: 1; }

/* Column alignment helpers */
.tbl-align-center { text-align: center; }
.tbl-align-end    { text-align: right; }

/* Header inner layout — splits the sort-click area from the filter trigger so
   clicking the filter icon does NOT trigger a sort. */
.tbl-th-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.tbl-th-clickable {
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}
.tbl th.tbl-th-sort .tbl-th-clickable {
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.tbl th.tbl-th-sort .tbl-th-clickable:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ============== TABLE FILTERS (Phase 2) ============== */

/* Tiny filter trigger button rendered in the header next to the title. */
.tbl-filter-trigger {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  color: var(--fg-dim);
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.tbl-filter-trigger:hover { color: var(--fg-muted); background: var(--glass-2); }
.tbl-filter-trigger:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: 1px;
}
.tbl-filter-trigger.is-active {
  color: var(--accent-a);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* Popover anchored to the right edge of the column header. Sits above the
   table body via z-index and the .tbl-th-inner positioning context. */
.tbl-filter-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: var(--z-drawer);
  min-width: 240px;
  max-width: 320px;
  background: var(--bg-2);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 0;
  /* The header has uppercase mono-styling — reset to normal body text inside. */
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
  animation: tbl-filter-popover-in var(--dur-med) var(--ease-out);
}
@keyframes tbl-filter-popover-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tbl-filter-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.tbl-filter-popover-title {
  font-weight: 500;
  color: var(--fg);
}
.tbl-filter-popover-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--r-xs);
  display: inline-flex;
}
.tbl-filter-popover-close:hover { color: var(--fg); }

.tbl-filter-popover-body {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-height: 280px;
  overflow-y: auto;
}
.tbl-filter-popover-body .input { width: 100%; }

.tbl-filter-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 0;
  cursor: pointer;
  color: var(--fg-muted);
}
.tbl-filter-option:hover { color: var(--fg); }
.tbl-filter-option .checkbox { flex: 0 0 auto; }

.tbl-filter-empty {
  color: var(--fg-dim);
  font-style: italic;
}

.tbl-filter-popover-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--line);
}

/* Active-filter chips shown in the toolbar. */
.tbl-filter-chips {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.tbl-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--fg);
}
.tbl-filter-chip-label { color: var(--fg-muted); }
.tbl-filter-chip-value { font-weight: 500; }
.tbl-filter-chip-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.tbl-filter-chip-close:hover { color: var(--fg); background: rgba(0,0,0,0.25); }

/* ============== TABLE FOOTER + PAGINATION (Phase 2) ============== */

.tbl-footer {
  border-top: 1px solid var(--line);
}

.tbl-pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  flex-wrap: wrap;
}
.tbl-pagination-info {
  color: var(--fg-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}
.tbl-pagination-size {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--fg-muted);
  font-size: 12px;
}
.tbl-pagination-size .select { padding-top: 4px; padding-bottom: 4px; min-width: 64px; }

.tbl-pagination-pages {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.tbl-pagination-gap {
  color: var(--fg-dim);
  font-family: var(--font-mono);
  padding: 0 6px;
  user-select: none;
}

/* ============== TABLE GROUPING / DETAIL / ACTIONS / BULK (Phase 3) ============== */

/* Group header row — sits between groups, mono uppercase label + count badge.
   Sticky under the table header when grouping + sticky-header are both active. */
.tbl-root .tbl tbody tr.tbl-group-header td {
  background: var(--glass-2);
  border-bottom: 1px solid var(--line);
  padding: 0;
}
.tbl-root .tbl tbody tr.tbl-group-header:hover td { background: var(--glass-2); }

.tbl-group-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  text-align: left;
  cursor: pointer;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color var(--dur-fast) var(--ease-out);
}
.tbl-group-toggle:hover { color: var(--fg); }
.tbl-group-toggle:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: -1px;
}

.tbl-group-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--fg-dim);
  transition: transform var(--dur-fast) var(--ease-out);
}
.tbl-group-chevron.is-collapsed { transform: rotate(-90deg); }

.tbl-group-label {
  color: var(--fg);
  flex: 1 1 auto;
}

.tbl-group-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--glass-1);
}

/* Expand column — chevron toggle on the row for DetailTemplate. */
.tbl-col-expand {
  width: 36px;
  padding-left: var(--sp-3);
  padding-right: 0;
}

.tbl-expand-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  color: var(--fg-dim);
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.tbl-expand-btn:hover { color: var(--fg); background: var(--glass-2); }
.tbl-expand-btn:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: 1px;
}
.tbl-expand-btn.is-expanded {
  color: var(--accent-a);
  transform: rotate(90deg);
}

/* Reorder grip column — leading drag handle when Reorderable is set. */
.tbl-col-grip {
  width: 32px;
  padding-left: var(--sp-3);
  padding-right: 0;
}

.tbl-grip {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  color: var(--fg-dim);
  cursor: grab;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.tbl-grip:hover { color: var(--fg); background: var(--glass-2); }
.tbl-grip:active { cursor: grabbing; }
.tbl-grip:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: 1px;
  color: var(--fg);
}
.tbl-grip:disabled {
  cursor: default;
  opacity: 0.4;
  background: transparent;
  color: var(--fg-dim);
}

/* Row being dragged — dims so the drop target reads clearly. */
.tbl-root .tbl tbody tr.tbl-row--dragging td {
  opacity: 0.45;
}

/* Drop target — an accent line traces the row the drag is hovering over. */
.tbl-root .tbl tbody tr.tbl-row--drop-target td {
  box-shadow: inset 0 2px 0 0 var(--accent-a);
}

@media (prefers-reduced-motion: reduce) {
  .tbl-grip { transition: none; }
}

/* Detail row — full-width panel that slides open under the expanded row. */
.tbl-root .tbl tbody tr.tbl-row-detail td {
  background: var(--bg-2);
  padding: 0;
  border-bottom: 1px solid var(--line);
}
.tbl-root .tbl tbody tr.tbl-row-detail:hover td {
  background: var(--bg-2);
  color: var(--fg-muted);
}
.tbl-row-detail-inner {
  padding: var(--sp-5);
  color: var(--fg-muted);
  animation: tbl-detail-in var(--dur-med) var(--ease-out);
}
@keyframes tbl-detail-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Trailing per-row actions column. */
th.tbl-col-actions,
td.tbl-col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  padding-right: var(--sp-4);
}
.tbl-row-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  justify-content: flex-end;
}

/* ============== TABLE INLINE EDITING ============== */

/* The row currently being edited gets a soft accent wash so it stands apart from
   the rest of the body, including under the hover rule. */
.tbl-root .tbl tbody tr.tbl-row--editing td,
.tbl-root .tbl tbody tr.tbl-row--editing:hover td {
  background: var(--accent-soft);
}

/* A cell hosting an inline editor sheds the text padding so the control fills the
   cell, and lets DRYL inputs stretch to the column width. */
td.tbl-td-editing {
  padding-top: var(--sp-1);
  padding-bottom: var(--sp-1);
}
td.tbl-td-editing .input,
td.tbl-td-editing .select,
td.tbl-td-editing .textarea,
td.tbl-td-editing input,
td.tbl-td-editing select {
  width: 100%;
}

/* Edit affordances in the actions column: pencil (enter), commit, cancel. */
.tbl-edit-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.tbl-edit-btn:hover {
  border-color: var(--line-strong);
  color: var(--fg);
  background: var(--glass-1);
}
.tbl-edit-btn:focus-visible {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.tbl-edit-btn--commit {
  border-color: var(--accent-line);
  color: var(--accent-a);
}
.tbl-edit-btn--commit:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-a);
}
.tbl-edit-btn--cancel:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

/* ============== TABLE COLUMN PIN / RESIZE / REORDER ============== */

/* Pinned (frozen) columns — the layout helper sets the per-column left/right offset; CSS owns
   the sticky behaviour, opaque backing and layering. */
.tbl .tbl-pin {
  position: sticky;
  z-index: 1;
  background: var(--bg-2);
}
/* Keep pinned body cells opaque through hover so scrolling content can't bleed under them. */
.tbl-root .tbl tbody tr td.tbl-pin,
.tbl-root .tbl tbody tr:hover td.tbl-pin {
  background: var(--bg-2);
}
/* Pinned header cells sit above the sticky header row and the pinned body cells. */
.tbl-root .tbl thead th.tbl-pin {
  z-index: 4;
}
/* Edge rule that separates a frozen column from the scrolling area. */
.tbl .tbl-pin-start { box-shadow: inset -1px 0 0 var(--line); }
.tbl .tbl-pin-end   { box-shadow: inset 1px 0 0 var(--line); }

/* Column resize grip — sits at the right edge of a resizable header. */
.tbl-col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}
.tbl-col-resize::after {
  content: "";
  position: absolute;
  top: 20%;
  right: 3px;
  width: 2px;
  height: 60%;
  border-radius: var(--r-pill);
  background: var(--line);
  opacity: 0;
  transition:
    opacity var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.tbl th:hover .tbl-col-resize::after { opacity: 1; }
.tbl-col-resize:hover::after { background: var(--accent-line); opacity: 1; }

/* While a resize drag is in progress, lock text selection for a clean drag. */
.tbl-resizing { user-select: none; cursor: col-resize; }

/* Reorderable headers — grab affordance + drag/drop states. */
.tbl th[draggable="true"] .tbl-th-clickable { cursor: grab; }
.tbl th.tbl-th--col-dragging { opacity: 0.5; }
.tbl th.tbl-th--col-drop-target {
  box-shadow: inset 2px 0 0 var(--accent-a);
}

/* Floating bulk-action bar — slides in from the top when a row is selected. */
.tbl-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
    var(--bg-2);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--accent-line);
  box-shadow: inset 0 -1px 0 var(--accent-line);
  animation: tbl-bulk-in var(--dur-med) var(--ease-spring);
}
@keyframes tbl-bulk-in {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.tbl-bulk-bar-info {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.tbl-bulk-bar-count {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-a);
  padding: 2px 8px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
}
.tbl-bulk-bar-label {
  color: var(--fg-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.tbl-bulk-bar-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: var(--sp-2);
}
.tbl-bulk-bar-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-xs);
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.tbl-bulk-bar-close:hover { color: var(--fg); background: var(--glass-2); }

@media (prefers-reduced-motion: reduce) {
  .tbl-bulk-bar { animation: none; }
  .tbl-row-detail-inner { animation: none; }
}

/* ============== TABLE VIRTUALIZE / STICKY / COLUMN MENU (Phase 4) ============== */

/* Scrollable body — used when Height is set or Virtualize is on. The sticky
   header (default) anchors to the top of this scroll area. */
.tbl-wrap--scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Opt-out for the sticky header — applied on the .tbl-root wrapper. */
.tbl-root.tbl-no-sticky .tbl th {
  position: static;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Column-visibility menu trigger sits in the toolbar next to extras. */
.tbl-col-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tbl-col-menu-wrap--auto { margin-left: auto; }

/* Toolbar action cluster (e.g. CSV export). When it is the first right-aligned
   element (no custom ToolbarContent), it anchors the right group. */
.tbl-toolbar-action {
  display: inline-flex;
  align-items: center;
}
.tbl-toolbar-action--auto { margin-left: auto; }

.tbl-col-menu-trigger {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  cursor: pointer;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.tbl-col-menu-trigger:hover { color: var(--fg); border-color: var(--line-strong); background: var(--glass-2); }
.tbl-col-menu-trigger:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: 1px;
}
.tbl-col-menu-trigger.is-active {
  color: var(--accent-a);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* Column-visibility popover — same surface vocabulary as the filter popover. */
.tbl-col-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: var(--z-drawer);
  min-width: 200px;
  max-width: 280px;
  background: var(--bg-2);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--fg);
  animation: tbl-filter-popover-in var(--dur-med) var(--ease-out);
}
.tbl-col-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.tbl-col-menu-title { font-weight: 500; }
.tbl-col-menu-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--r-xs);
  display: inline-flex;
}
.tbl-col-menu-close:hover { color: var(--fg); }

.tbl-col-menu-body {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-height: 280px;
  overflow-y: auto;
}
.tbl-col-menu-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 0;
  cursor: pointer;
  color: var(--fg-muted);
}
.tbl-col-menu-option:hover { color: var(--fg); }

/* Avatar */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: inline-grid;
  place-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: white;
  flex: 0 0 28px;
  box-shadow: 0 0 0 2px var(--bg-0), 0 0 12px rgba(124,92,255,0.4);
  overflow: hidden;
  user-select: none;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Sizes (base .avatar is Medium / 28px) */
.avatar--sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 10px; }
.avatar--lg { width: 40px; height: 40px; flex-basis: 40px; font-size: 15px; }
/* Square variant */
.avatar--square { border-radius: var(--r-sm); }
/* Counter ("+N") tile in a group */
.avatar--counter {
  background: var(--glass-3);
  color: var(--fg-muted);
  box-shadow: 0 0 0 2px var(--bg-0);
}

/* Wrapper that hosts the presence dot */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  flex: none;
}
.avatar-status {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-0);
}
.avatar-wrap--sm .avatar-status { width: 7px; height: 7px; }
.avatar-wrap--lg .avatar-status { width: 12px; height: 12px; }
.avatar-status--online  { background: var(--success); box-shadow: 0 0 0 2px var(--bg-0), 0 0 8px rgba(52,211,153,0.6); }
.avatar-status--busy    { background: var(--danger);  box-shadow: 0 0 0 2px var(--bg-0), 0 0 8px rgba(248,113,113,0.6); }
.avatar-status--away    { background: var(--warning); box-shadow: 0 0 0 2px var(--bg-0), 0 0 8px rgba(251,191,36,0.55); }
.avatar-status--offline { background: var(--fg-faint); }

/* Stacked group */
.avatar-group {
  display: inline-flex;
  align-items: center;
}
.avatar-group > * + * {
  margin-left: -8px;
}
.avatar-group--sm > * + * { margin-left: -6px; }
.avatar-group--lg > * + * { margin-left: -12px; }

/* ============== TOASTS (DrylToast + DrylToastProvider) ============== */

/* Fixed-position host that holds the toast stack. pointer-events:none lets
   clicks pass through the empty space; each .toast-slot re-enables them. */
.toast-host {
  position: fixed;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
  pointer-events: none;
  max-width: min(440px, calc(100vw - var(--sp-7)));
  width: max-content;
}

.toast-host.is-top-right     { top: 0;    right: 0; }
.toast-host.is-top-left      { top: 0;    left: 0; }
.toast-host.is-top-center    { top: 0;    left: 50%; transform: translateX(-50%); }
.toast-host.is-bottom-right  { bottom: 0; right: 0; flex-direction: column-reverse; }
.toast-host.is-bottom-left   { bottom: 0; left: 0; flex-direction: column-reverse; }
.toast-host.is-bottom-center { bottom: 0; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }

.toast-slot { pointer-events: auto; }

.toast {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  padding-right: 38px;          /* room for the close button */
  padding-bottom: calc(var(--sp-4) + 2px); /* room for the progress bar */
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
    rgba(10, 10, 14, 0.78);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-md);
  min-width: 280px;
  max-width: 100%;
  isolation: isolate;
  overflow: hidden;
  color: var(--fg);
  font-size: 13px;
  line-height: 1.45;
  /* Direction-aware entrance is set further down per host position. */
  animation: toast-in-right var(--dur-slow) var(--ease-spring) both;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

/* Subtle lift on hover — combined with the pause on progress this signals
   "I'm holding this open so you can read me". */
.toast:hover {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    var(--shadow-lg);
}

/* One-shot shine sweep across the toast shortly after entry. Pure delight. */
.toast::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.09) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: toast-shine 1300ms var(--ease-out) 220ms both;
  pointer-events: none;
  z-index: 3;
  mix-blend-mode: overlay;
}
@keyframes toast-shine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Direction-aware entry — slide in from the edge nearest the anchor. */
.toast-host.is-top-right .toast,
.toast-host.is-bottom-right .toast { animation-name: toast-in-right; }

.toast-host.is-top-left .toast,
.toast-host.is-bottom-left .toast  { animation-name: toast-in-left; }

.toast-host.is-top-center .toast    { animation-name: toast-in-top; }
.toast-host.is-bottom-center .toast { animation-name: toast-in-bottom; }

@keyframes toast-in-right {
  0%   { opacity: 0; transform: translateX(120%) scale(0.85); filter: blur(6px); }
  60%  { opacity: 1; transform: translateX(-3%)  scale(1.02); filter: blur(0); }
  100% { opacity: 1; transform: translateX(0)    scale(1);    filter: blur(0); }
}
@keyframes toast-in-left {
  0%   { opacity: 0; transform: translateX(-120%) scale(0.85); filter: blur(6px); }
  60%  { opacity: 1; transform: translateX(3%)    scale(1.02); filter: blur(0); }
  100% { opacity: 1; transform: translateX(0)     scale(1);    filter: blur(0); }
}
@keyframes toast-in-top {
  0%   { opacity: 0; transform: translateY(-110%) scale(0.9); filter: blur(6px); }
  60%  { opacity: 1; transform: translateY(5%)    scale(1.02); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0)     scale(1);    filter: blur(0); }
}
@keyframes toast-in-bottom {
  0%   { opacity: 0; transform: translateY(110%) scale(0.9); filter: blur(6px); }
  60%  { opacity: 1; transform: translateY(-5%)  scale(1.02); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0)    scale(1);    filter: blur(0); }
}

/* Exit keyframes — single shared animation. JS listens for `toast-out`
   animationend and tells .NET to drop the entry from the stack. The
   actual exit *rule* is defined further down so it wins over the
   direction-aware and ai-generated animation overrides. */
@keyframes toast-out {
  to { opacity: 0; transform: scale(0.92) translateY(-6px); filter: blur(3px); }
}

/* Icon chip — pops with spring after the toast itself lands. */
.toast-icon-chip {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: grid;
  place-content: center;
  background: var(--glass-2);
  color: var(--fg-muted);
  border: 1px solid var(--line-strong);
  animation: toast-icon-pop var(--dur-slow) var(--ease-spring) 120ms both;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}
@keyframes toast-icon-pop {
  0%   { opacity: 0; transform: rotate(-18deg) scale(0.3); }
  60%  { opacity: 1; transform: rotate(8deg)   scale(1.15); }
  100% { opacity: 1; transform: rotate(0)      scale(1); }
}

/* Body content column */
.toast-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  position: relative;
  z-index: 2;
}
.toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.005em;
}
.toast-body {
  font-size: 12.5px;
  color: var(--fg-muted);
  line-height: 1.5;
}
.toast-title + .toast-body { margin-top: 2px; }

/* Close button */
.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-content: center;
  border-radius: var(--r-xs);
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-dim);
  cursor: pointer;
  transition:
    color        var(--dur-fast) var(--ease-out),
    background   var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
  z-index: 5;
}
.toast-close:hover {
  color: var(--fg);
  background: var(--glass-2);
  border-color: var(--line);
}
.toast-close:focus-visible {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Progress bar — single source of truth for auto-dismiss. The CSS animation
   drives both the visual countdown and (via animationend in dryl.toast.js)
   the actual close. `animation-play-state: paused` on hover keeps the
   timer and the bar perfectly in sync. */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  transform-origin: left center;
  animation-name: toast-progress;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  pointer-events: none;
  z-index: 4;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}
.toast-progress.is-hidden { opacity: 0; }
.toast:hover .toast-progress { animation-play-state: paused; }
@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Variants — semantic accent on icon chip, colored left rail, soft glow.
   The left rail is drawn with an inset box-shadow so the radius still clips
   it cleanly. */
.toast.toast-success {
  border-color: rgba(52, 211, 153, 0.28);
  box-shadow:
    inset 3px 0 0 var(--success),
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-md),
    0 0 32px rgba(52, 211, 153, 0.18);
}
.toast.toast-success .toast-icon-chip {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.35);
}
.toast.toast-success .toast-progress {
  background: linear-gradient(90deg, var(--success), #6ee7b7);
}

.toast.toast-warning {
  border-color: rgba(251, 191, 36, 0.28);
  box-shadow:
    inset 3px 0 0 var(--warning),
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-md),
    0 0 32px rgba(251, 191, 36, 0.18);
}
.toast.toast-warning .toast-icon-chip {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.35);
}
.toast.toast-warning .toast-progress {
  background: linear-gradient(90deg, var(--warning), #fcd34d);
}

.toast.toast-error {
  border-color: rgba(248, 113, 113, 0.32);
  box-shadow:
    inset 3px 0 0 var(--danger),
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-md),
    0 0 36px rgba(248, 113, 113, 0.22);
}
.toast.toast-error .toast-icon-chip {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}
.toast.toast-error .toast-progress {
  background: linear-gradient(90deg, var(--danger), #fca5a5);
}

.toast.toast-info {
  border-color: rgba(34, 211, 238, 0.28);
  box-shadow:
    inset 3px 0 0 var(--info),
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-md),
    0 0 32px rgba(34, 211, 238, 0.18);
}
.toast.toast-info .toast-icon-chip {
  background: rgba(34, 211, 238, 0.15);
  color: var(--info);
  border-color: rgba(34, 211, 238, 0.35);
}
.toast.toast-info .toast-progress {
  background: linear-gradient(90deg, var(--info), #67e8f9);
}

/* ── AI dominance (CLAUDE.md §2.10) ── When .ai-aura is set, the rotating
   gradient ring and breathing glow take over the visual; the variant left
   rail and tinted border step back so the AI signal reads cleanly. The
   variant accent survives only on the icon chip so a user can still tell
   "AI delivered a success / warning / error". */
.toast.ai-aura {
  border-color: var(--accent-line);
}
.toast.ai-aura.toast-success,
.toast.ai-aura.toast-warning,
.toast.ai-aura.toast-error,
.toast.ai-aura.toast-info {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    var(--shadow-md);
}
/* The host has overflow:hidden so the outer ai-aura ring/glow would be
   clipped. Pull them inside the bounds — same trick as DrylTable. */
.toast.ai-aura .ai-aura-ring { inset: 0; }
.toast.ai-aura .ai-aura-glow {
  box-shadow:
    inset 0 0 0 1px var(--accent-line),
    inset 0 0 32px rgba(124, 92, 255, 0.18),
    inset 0 0 64px rgba(34, 211, 238, 0.08);
}
.toast.ai-aura .toast-progress {
  background: var(--accent-grad);
}
/* The standard ai-generated translate would conflict with the entrance lift. */
.toast.ai-aura.ai-generated { animation: none; }

/* Exit animation — placed last with .toast-host scoping so the specificity
   (0,3,0) matches the direction rules and the ai-generated override, and
   source order makes this rule win. Without this, .toast.is-leaving (0,2,0)
   would lose to those, the exit animation would never play, animationend
   would never fire for `toast-out`, and the toast would sit on screen
   forever — close button included. */
.toast-host .toast.is-leaving {
  animation: toast-out var(--dur-med) var(--ease-out) forwards;
  pointer-events: none;
}
.toast-host .toast.is-leaving::after          { animation: none; opacity: 0; }
.toast-host .toast.is-leaving .toast-progress { animation: none; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast::after,
  .toast-icon-chip,
  .toast-progress { animation: none; }
  .toast:hover { transform: none; }
}

/* Skeleton */
.skel {
  display: block;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 6px;
  height: 14px;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Spinner */
.spinner {
  display: block;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-b);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress */
.progress {
  height: 6px;
  width: 100%;
  border-radius: var(--r-pill);
  background: var(--glass-2);
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  background: var(--accent-grad);
  border-radius: var(--r-pill);
  box-shadow: 0 0 12px rgba(124,92,255,0.5);
  transition: width 600ms var(--ease-out);
}

/* DrylProgress — wrapper, label row, sizes, variants, indeterminate */
.progress-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
}
.progress-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: 12px;
  color: var(--fg-muted);
}
.progress-pct {
  font-family: var(--font-mono);
  color: var(--fg);
}
/* Aura host sits outside the track so the ring is not clipped by overflow:hidden */
.progress-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--r-pill);
}
.progress--sm { height: 4px; }
.progress--lg { height: 10px; }

.progress-bar--success { background: var(--success); box-shadow: 0 0 12px rgba(52,211,153,0.5); }
.progress-bar--warning { background: var(--warning); box-shadow: 0 0 12px rgba(251,191,36,0.5); }
.progress-bar--danger  { background: var(--danger);  box-shadow: 0 0 12px rgba(248,113,113,0.5); }

.progress--indeterminate .progress-bar {
  width: 40%;
  transition: none;
  animation: progress-indeterminate 1.4s var(--ease-in-out) infinite;
}
@keyframes progress-indeterminate {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
  .progress--indeterminate .progress-bar { animation: none; width: 100%; }
}

/* ============== TABS (DrylTabs / DrylTab) ============== */

.tabs-root {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabs {
  position: relative;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 0 var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--fg-muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  isolation: isolate;
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.tab:hover { color: var(--fg); background: var(--glass-1); }
.tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.tab.is-active { color: var(--fg); }
.tab.is-active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  background: var(--accent-grad);
  border-radius: 2px;
  box-shadow: 0 0 12px var(--accent-a);
  transform-origin: center;
  animation: tab-underline-in var(--dur-med) var(--ease-spring) both;
  z-index: 2;
}
@keyframes tab-underline-in {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

.tab.is-disabled,
.tab[disabled] {
  color: var(--fg-faint);
  cursor: not-allowed;
  pointer-events: none;
}

.tab .tab-icon {
  flex: 0 0 14px;
  opacity: 0.85;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.tab:hover .tab-icon,
.tab.is-active .tab-icon { opacity: 1; }

/* Trailing slot for badges, counters, AI indicators etc. */
.tab-trailing {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}

/* AI mode on a single tab — additive ring drawn via ::before (kept inside
   the tab's rounded bounds so the rotating gradient traces just this tab,
   not the whole tab bar). The .is-active ::after underline still wins on
   top, so an active+AI tab reads as both selected and AI-busy. */
.tab.ai-aura {
  color: #d6cbff;
  background: var(--accent-soft);
}
.tab.ai-aura::before {
  content: '';
  position: absolute;
  inset: 2px 2px 0 2px;
  border-radius: var(--r-sm);
  padding: 1px;
  background: conic-gradient(
    from var(--ai-aura-angle, 0deg),
    var(--accent-a),
    var(--accent-b),
    var(--accent-a),
    var(--accent-b),
    var(--accent-a)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
  opacity: 0.85;
  animation: ai-aura-rotate 6s linear infinite;
}
.tab.ai-aura.ai-thinking::before  { animation-duration: 1.8s; opacity: 1; }
.tab.ai-aura.ai-streaming::before { animation-duration: 3s; }
.tab.ai-aura.ai-generated::before { animation-duration: 4s; opacity: 1; }

/* Tab panel — fades in on switch via @key on the panel element */
.tab-panel {
  padding: var(--sp-5) 0 0;
  animation: tab-panel-in var(--dur-med) var(--ease-out) both;
  min-width: 0;
}
@keyframes tab-panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .tab.is-active::after,
  .tab.ai-aura::before,
  .tab-panel { animation: none; }
  .tab.ai-aura::before { opacity: 0.6; }
}

/* Dialog */
body.dryl-scroll-locked { overflow: hidden; }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  z-index: var(--z-modal);
  animation: fadeIn var(--dur-med) var(--ease-out);
}

/* Fullscreen dialogs fill the viewport — kill the backdrop padding so they
   actually reach the edges. */
.dialog-backdrop:has(.dialog-fullscreen) {
  padding: 0;
}

.dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 640px;
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(20, 20, 28, 0.95), rgba(10, 10, 14, 0.95));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg), 0 0 80px rgba(124, 92, 255, 0.25);
  animation: dialogIn var(--dur-med) var(--ease-spring);
  color: var(--fg);
}

.dialog-sm         { width: 420px; }
.dialog-md         { width: 640px; }
.dialog-lg         { width: 960px; }
.dialog-fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border: none;
}

.dialog-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.dialog-header-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--glass-2);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  flex: 0 0 auto;
}

.dialog-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  cursor: pointer;
  flex: 0 0 auto;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.dialog-close:hover {
  background: var(--glass-2);
  border-color: var(--line);
  color: var(--fg);
}
.dialog-close:focus-visible {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.dialog-body {
  padding: var(--sp-5);
  overflow-y: auto;
  flex: 1 1 auto;
  color: var(--fg-muted);
  line-height: 1.55;
}
.dialog-body > :first-child { margin-top: 0; }
.dialog-body > :last-child  { margin-bottom: 0; }

.dialog-footer {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}

.dialog-fullscreen .dialog-body { max-height: none; }

@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Tooltip */
.tt-wrap { position: relative; display: inline-flex; }
.tt {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  background: rgba(20,20,28,0.95);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-md);
  z-index: 9000;
}
.tt-wrap:hover .tt {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Tooltip — Bottom */
.tt-bottom {
  bottom: auto;
  top: calc(100% + var(--sp-2));
  transform: translateX(-50%) translateY(-4px);
}
.tt-wrap:hover .tt-bottom {
  transform: translateX(-50%) translateY(0);
}
/* Tooltip — Left */
.tt-left {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + var(--sp-2));
  transform: translateY(-50%) translateX(4px);
}
.tt-wrap:hover .tt-left {
  transform: translateY(-50%) translateX(0);
}
/* Tooltip — Right */
.tt-right {
  bottom: auto;
  top: 50%;
  left: calc(100% + var(--sp-2));
  transform: translateY(-50%) translateX(-4px);
}
.tt-wrap:hover .tt-right {
  transform: translateY(-50%) translateX(0);
}

/* Alert */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--glass-1);
  backdrop-filter: blur(12px);
}
.alert .ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-content: center;
  flex: 0 0 28px;
}
.alert.info .ico    { background: var(--accent-soft); color: #c4b5fd; }
.alert.success .ico { background: rgba(52,211,153,0.15); color: var(--success); }
.alert.warning .ico { background: rgba(251,191,36,0.15); color: var(--warning); }
.alert.danger .ico  { background: rgba(248,113,113,0.15); color: var(--danger); }
/* KI-Variante — Akzentgradient als Icon-Chip, violett-cyanfarbener Text */
.alert.ai .ico      { background: var(--accent-soft); color: #c4b5fd; }
.alert .title { font-weight: 500; font-size: 13px; margin-bottom: 2px; }
.alert .body { font-size: 12.5px; color: var(--fg-muted); }
/* Flexibler Textbereich — nimmt verbleibenden Platz ein */
.alert-content { flex: 1; min-width: 0; }
/* Schließen-Button */
.alert.is-dismissible { padding-right: var(--sp-3); }
.alert-dismiss {
  margin-left: auto;
  flex-shrink: 0;
  align-self: flex-start;
  width: 24px; height: 24px;
  display: grid; place-content: center;
  background: transparent;
  border: none;
  border-radius: var(--r-xs);
  color: var(--fg-dim);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color     var(--dur-fast) var(--ease-out);
}
.alert-dismiss:hover { background: var(--glass-3); color: var(--fg); }
.alert-dismiss:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
/* AI-Aura auf dem Alert — Rahmen weicht zurück, damit der Gradientring dominiert.
   Der alert hat kein overflow:hidden, daher funktioniert der Standard-inset -1px. */
.alert.ai-aura { border-color: var(--accent-line); }

/* Spotlight card */
.spotlight-card {
  position: relative;
  overflow: hidden;
}
.spotlight-card .spotlight-fx {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%),
              rgba(124, 92, 255, 0.18),
              rgba(34, 211, 238, 0.06) 30%,
              transparent 60%);
  transition: opacity var(--dur-med) var(--ease-out);
  z-index: 1;
}
.spotlight-card:hover .spotlight-fx { opacity: 1; }
[data-spotlights="off"] .spotlight-card:hover .spotlight-fx { opacity: 0; }
[data-spotlights="off"] .spotlight-card:hover::before { opacity: 0; }
.spotlight-card .spotlight-content { position: relative; z-index: 2; }
.spotlight-card::before {
  /* Edge light that activates on hover */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%),
              rgba(124,92,255,0.6), transparent 50%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-out);
  pointer-events: none;
  z-index: 3;
}
.spotlight-card:hover::before { opacity: 1; }

/* Chart helpers */
.chart-card { padding: 22px 24px; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--fg-muted); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ============================================================
   AI MODE — ambient signal for AI-driven surfaces
   ============================================================
   Apply alongside any existing surface class (.glass-card, .btn, .input, …).
   Implemented as child elements (not pseudos) so it composes with surfaces
   that already use ::before/::after (spotlight-card, glass-card).

     <div class="glass-card ai-aura">
       <div class="ai-aura-ring"></div>
       <div class="ai-aura-glow"></div>
       …content…
     </div>

   Modifiers on the same host:
     .ai-thinking   — accelerates the ring + glow for active tool calls
     .ai-streaming  — long-running token stream (slightly slower than thinking)
     .ai-generated  — one-shot reveal after generation completes
*/

/* Registered angle property — required so the browser can interpolate the
   conic-gradient rotation. Without @property, --ai-aura-angle would be
   treated as a string and the animation would step instead of sweep. */
@property --ai-aura-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.ai-aura {
  position: relative;
  isolation: isolate;
}

/* Rotating conic-gradient border — the box stays static; only the gradient sweeps. */
.ai-aura-ring {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from var(--ai-aura-angle, 0deg),
    var(--accent-a),
    var(--accent-b),
    var(--accent-a),
    var(--accent-b),
    var(--accent-a)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 4;
  opacity: 0.7;
  animation: ai-aura-rotate 6s linear infinite;
}

/* Breathing accent glow behind the host */
.ai-aura-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  box-shadow:
    0 0 0 1px var(--accent-line),
    0 0 24px rgba(124, 92, 255, 0.25),
    0 0 56px rgba(34, 211, 238, 0.15);
  animation: ai-aura-breathe 4s var(--ease-in-out) infinite;
}

@keyframes ai-aura-rotate { to { --ai-aura-angle: 360deg; } }
@keyframes ai-aura-breathe {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* Thinking — fast pulse */
.ai-aura.ai-thinking .ai-aura-ring  { animation-duration: 1.8s; opacity: 1; }
.ai-aura.ai-thinking .ai-aura-glow  { animation-duration: 1.4s; }

/* Streaming — slightly faster than idle, slower than thinking */
.ai-aura.ai-streaming .ai-aura-ring { animation-duration: 3s; opacity: 0.9; }
.ai-aura.ai-streaming .ai-aura-glow { animation-duration: 2.6s; }

/* Generated — one-shot reveal: subtle lift + a gradient wash sweep */
.ai-aura.ai-generated { animation: ai-generated-lift 720ms var(--ease-out) both; }
.ai-aura.ai-generated .ai-aura-ring { opacity: 1; }

@keyframes ai-generated-lift {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Optional sweep — render <div class="ai-aura-wash"></div> inside .ai-generated host.
   The wash element itself is a static clip container; ::before holds the animated
   gradient. This keeps the sweep visually inside the card's rounded bounds. */
.ai-aura-wash {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}
.ai-aura-wash::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(124, 92, 255, 0.18) 40%,
    rgba(34, 211, 238, 0.18) 60%,
    transparent 100%
  );
  transform: translateX(-100%);
  opacity: 0;
}
.ai-aura.ai-generated .ai-aura-wash::before {
  animation: ai-aura-wash 900ms var(--ease-out) both;
}
@keyframes ai-aura-wash {
  0%   { transform: translateX(-100%); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translateX(100%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-aura-ring,
  .ai-aura-glow,
  .ai-aura-wash::before,
  .ai-aura.ai-generated { animation: none; }
  .ai-aura-ring { opacity: 0.6; }
}

/* ============== EXPANSION PANELS ============== */

/*
  Stacking behaviour
  ──────────────────
  Adjacent closed panels share their border (margin-top: -1px).
  • First/last panels get rounded top/bottom corners.
  • An open panel lifts out: full border-radius + gap margin + stronger shadow.
  • The panel after an open one resets its negative margin so the gap is clean.

  Body animation
  ──────────────
  Uses the grid-template-rows: 0fr → 1fr trick.
  The inner overflow:hidden wrapper collapses to zero height while the content
  itself is never "squeezed" — it always renders at its natural size.
*/

.expansion {
  position: relative;
  background: var(--glass-1);
  border: 1px solid var(--line);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  border-radius: 0;
  z-index: 0;
  transition:
    margin         var(--dur-med) var(--ease-out),
    border-color   var(--dur-med) var(--ease-out),
    border-radius  var(--dur-med) var(--ease-out),
    box-shadow     var(--dur-med) var(--ease-out),
    z-index        0s             var(--dur-med); /* delay z-index reset until animation is done */
}

/* Collapse shared border between adjacent panels */
.expansion + .expansion { margin-top: -1px; }

/* Round top of first panel in a stack */
.expansion:first-child { border-radius: var(--r-md) var(--r-md) 0 0; }

/* Round bottom of last panel in a stack */
.expansion:last-child { border-radius: 0 0 var(--r-md) var(--r-md); }

/* Single standalone panel */
.expansion:first-child:last-child { border-radius: var(--r-md); }

/* Open state — detach from siblings */
.expansion.is-open {
  margin: var(--sp-3) 0;
  border-radius: var(--r-md);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  z-index: 1;
  transition:
    margin         var(--dur-med) var(--ease-out),
    border-color   var(--dur-med) var(--ease-out),
    border-radius  var(--dur-med) var(--ease-out),
    box-shadow     var(--dur-med) var(--ease-out);
}

/* Sibling right after an open panel: cancel the shared-border pull-up */
.expansion.is-open + .expansion { margin-top: 0; }

/* Disabled panel */
.expansion.is-disabled { pointer-events: none; }
.expansion.is-disabled .expansion-header { opacity: 0.4; cursor: not-allowed; }

/* ── Header ── */
.expansion-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  background: none;
  border: none;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  text-align: left;
  transition: color var(--dur-fast) var(--ease-out);
}

.expansion-header:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: -2px;
  border-radius: inherit;
}

.expansion-header:hover .expansion-chevron { color: var(--fg-muted); }

.expansion-icon { color: var(--fg-muted); flex-shrink: 0; }

.expansion-title { flex: 1; }

.expansion-header-trailing {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Chevron flips 180° when open */
.expansion-chevron {
  color: var(--fg-dim);
  flex-shrink: 0;
  transition: transform var(--dur-med) var(--ease-out), color var(--dur-med) var(--ease-out);
}
.expansion.is-open .expansion-chevron {
  transform: rotate(180deg);
  color: var(--fg-muted);
}

/* ── Body (grid-rows animation) ── */
.expansion-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-med) var(--ease-out);
}

.expansion.is-open .expansion-body {
  grid-template-rows: 1fr;
}

/* overflow:hidden here is what allows 0fr to fully collapse */
.expansion-body-inner {
  overflow: hidden;
}

.expansion-body-content {
  padding: 0 var(--sp-5) var(--sp-5);
  color: var(--fg-muted);
}

@media (prefers-reduced-motion: reduce) {
  .expansion,
  .expansion-body,
  .expansion-chevron { transition: none; }
}

/* ============== AI INDICATOR — small status pill ============== */
.ai-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px 0 8px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #d6cbff;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  position: relative;
  overflow: hidden;
}
.ai-indicator .ai-indicator-ico {
  flex: 0 0 12px;
  color: var(--accent-b);
  animation: ai-indicator-pulse 2.4s var(--ease-in-out) infinite;
}
.ai-indicator.is-thinking .ai-indicator-ico  { animation-duration: 1s; }
.ai-indicator.is-streaming .ai-indicator-ico { animation-duration: 1.6s; }

/* Subtle sweep across the pill background */
.ai-indicator::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: ai-indicator-shimmer 3.6s var(--ease-in-out) infinite;
  pointer-events: none;
}
.ai-indicator.is-thinking::after  { animation-duration: 1.4s; }
.ai-indicator.is-streaming::after { animation-duration: 2.2s; }

@keyframes ai-indicator-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.12); }
}
@keyframes ai-indicator-shimmer {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-indicator .ai-indicator-ico,
  .ai-indicator::after { animation: none; }
}

/* ============== MENU (DrylMenu / DrylMenuItem) ============== */

/* Positioning anchor — wraps trigger + panel together */
.menu-anchor {
  position: relative;
  display: inline-block;
}

/* Block variant: stretches the anchor full-width */
.menu-anchor--block {
  display: block;
}

/* Transparent pass-through for the trigger slot */
.menu-trigger { display: contents; }

/* Dropdown panel */
.menu-panel {
  position: absolute;
  top: calc(100% + var(--sp-1));
  left: 0;
  z-index: var(--z-drawer);
  min-width: 180px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-1) 0;
  outline: none;
  animation: menu-in var(--dur-med) var(--ease-out) both;
}

/* Placement variants */
.menu-panel--end { left: auto; right: 0; }
.menu-panel--top { top: auto; bottom: calc(100% + var(--sp-1)); }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* Individual item — rendered as <button> with role="menuitem" */
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-4);
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  font: 400 13px/1.4 var(--font-sans);
  text-align: left;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.menu-item:hover { background: var(--glass-2); color: var(--fg); }
.menu-item:focus-visible {
  outline: none;
  background: var(--glass-2);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.menu-item:disabled,
.menu-item[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Danger variant */
.menu-item--danger { color: var(--danger); }
.menu-item--danger:hover,
.menu-item--danger:focus-visible {
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
}

/* Keyboard shortcut hint — pushed to trailing edge */
.menu-item-shortcut {
  margin-left: auto;
  padding-left: var(--sp-5);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
}

/* Section separator */
.menu-separator {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: var(--sp-1) 0;
}

/* Section header */
.menu-header {
  padding: var(--sp-2) var(--sp-4) calc(var(--sp-1) / 2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  .menu-panel { animation: none; }
}

/* ============== NUMBER INPUT STEPPER (DrylInputNumber) ============== */

/* Stretch so the stepper fills the full input height */
.input-wrapper.has-stepper { align-items: stretch; }

/* Input side: take remaining space, square off the right edge */
.input-wrapper.has-stepper .input {
  flex: 1;
  min-width: 0;
  border-radius: var(--r-md) 0 0 var(--r-md);
  border-right: none;
}

/* Sync the separator to the input's border states */
.input-wrapper.has-stepper:hover .num-stepper        { border-left-color: rgba(255,255,255,0.18); }
.input-wrapper.has-stepper:focus-within .num-stepper { border-left-color: var(--accent-line); }

.num-stepper {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-left: 1px solid var(--line-strong);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  overflow: hidden;
  transition: border-left-color var(--dur-med) var(--ease-out);
}
.num-step-btn {
  flex: 1;
  display: grid;
  place-content: center;
  width: 28px;
  border: none;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0;
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.num-step-btn:hover:not(:disabled)  { color: var(--fg); background: var(--glass-2); }
.num-step-btn:active:not(:disabled) { background: var(--glass-3); color: var(--accent-a); }
.num-step-btn:first-child           { border-bottom: 1px solid var(--line); }
.num-step-btn:disabled              { opacity: 0.4; cursor: not-allowed; }
.num-step-btn:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid rgba(124, 92, 255, 0.5);
  outline-offset: -2px;
}

/* hide native number spinners — we render our own */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ============== RADIO GROUP (DrylRadioGroup / DrylRadio) ============== */

.radio-group {
  display: flex;
  gap: var(--sp-3);
}
.radio-group--vertical   { flex-direction: column; }
.radio-group--horizontal { flex-direction: row; flex-wrap: wrap; align-items: center; }

.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  user-select: none;
}
.radio-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.radio-control {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--glass-1);
  border: 1px solid var(--line-strong);
  display: grid;
  place-content: center;
  transition: border-color var(--dur-fast) var(--ease-out),
              background   var(--dur-fast) var(--ease-out),
              box-shadow   var(--dur-fast) var(--ease-out);
}
.radio-control::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: white;
  transform: scale(0);
  transition: transform var(--dur-med) var(--ease-spring);
}
.radio:hover .radio-control {
  border-color: var(--accent-line);
}
.radio-input:checked + .radio-control {
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(124, 92, 255, 0.45);
}
.radio-input:checked + .radio-control::after {
  transform: scale(1);
}
.radio:focus-within .radio-control {
  outline: 2px solid rgba(124, 92, 255, 0.5);
  outline-offset: 2px;
}
.radio-label {
  font-size: 14px;
  color: var(--fg);
  line-height: 1.4;
}
.radio--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============== CHIPS (used by DrylMultiSelect) ============== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-remove {
  flex-shrink: 0;
  display: grid;
  place-content: center;
  width: 14px;
  height: 14px;
  border: none;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0;
  border-radius: var(--r-xs);
  transition: color var(--dur-fast) var(--ease-out);
}
.chip-remove:hover { color: var(--fg); }
.chip-overflow {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--glass-2);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--fg-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.multiselect-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* ============== FILE UPLOAD (DrylFileUpload) ============== */

.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-5);
  background: var(--glass-1);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-med) var(--ease-out),
              background   var(--dur-med) var(--ease-out),
              box-shadow   var(--dur-med) var(--ease-out);
  text-align: center;
  cursor: pointer;
}
.file-drop:hover,
.file-drop--active {
  border-color: var(--accent-line);
  background: var(--glass-2);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.08), 0 0 28px rgba(124, 92, 255, 0.14);
}
.file-drop--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.file-drop-icon {
  color: var(--fg-dim);
  transition: color var(--dur-med) var(--ease-out);
}
.file-drop:hover .file-drop-icon,
.file-drop--active .file-drop-icon { color: var(--fg-muted); }
.file-drop-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
}
.file-drop-sub {
  font-size: 12px;
  color: var(--fg-dim);
}
.file-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.file-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--glass-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  min-width: 0;
}
.file-item-icon { flex-shrink: 0; color: var(--fg-dim); }
.file-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--fg);
}
.file-item-size {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
}
.file-item-remove {
  flex-shrink: 0;
  display: grid;
  place-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0;
  border-radius: var(--r-xs);
  margin-left: auto;
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.file-item-remove:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}

/* ============== SLIDER (DrylSlider) ============== */

.slider-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.slider-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.slider-value {
  font-size: 12px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

@media (prefers-reduced-motion: reduce) {
  .radio-control, .radio-control::after { transition: none; }
}

/* ─────────────────────────────────────────────────────────
   DrylMarkdown — rendered Markdown content. These rules are global
   (not component-scoped) because the HTML is injected via MarkupString
   and therefore carries no CSS-isolation attribute.
   ───────────────────────────────────────────────────────── */
.md { position: relative; }

/* In AI mode the rotating ring uses border-radius:inherit and the glow draws a
   1px outline — with a bare .md (no radius, no surface) that resolves to a sharp
   rectangle hugging the text. Give the host a glass surface + rounded corners so
   the ring frames a proper panel, mirroring DrylRating / DrylEmptyState. */
.md.ai-aura {
  background: var(--glass-1);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}

.md-content {
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.md-content > * { margin: 0; }

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4 {
  color: var(--fg);
  line-height: 1.3;
  font-weight: 600;
}
.md-content h1 { font-size: 22px; }
.md-content h2 { font-size: 18px; }
.md-content h3 { font-size: 15px; }
.md-content h4 { font-size: 14px; }

.md-content p { color: var(--fg-muted); }

.md-content a {
  color: var(--accent-b);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: color var(--dur-fast) var(--ease-out);
}
.md-content a:hover { color: var(--fg); }

.md-content strong { color: var(--fg); font-weight: 600; }

.md-content ul,
.md-content ol {
  padding-left: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.md-content li { color: var(--fg-muted); }

.md-content blockquote {
  padding: var(--sp-1) var(--sp-3);
  border-left: 2px solid var(--accent-line);
  color: var(--fg-dim);
  background: var(--glass-1);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* Inline code (fenced blocks are delegated to DrylCodeBlock). */
.md-content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.1em 0.4em;
  color: var(--fg);
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
}

.md-content hr { border: none; border-top: 1px solid var(--line); }

.md-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.md-content th,
.md-content td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.md-content th { color: var(--fg); font-weight: 600; }
.md-content td { color: var(--fg-muted); }

/* ─────────────────────────────────────────────────────────
   DrylCitation / DrylCitationList — source attribution for AI answers.
   ───────────────────────────────────────────────────────── */
.citation-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin: 0 1px;
  vertical-align: super;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  color: var(--accent-b);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.citation-chip:hover,
.citation-chip--open {
  color: var(--fg);
  background: var(--accent-grad);
}

.citation-pop {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 280px;
  padding: var(--sp-1);
}
.citation-pop-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
}
.citation-pop-title svg { color: var(--accent-b); flex: none; }
.citation-pop-snippet {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.citation-pop-link,
.citation-item-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--accent-b);
  font-size: 12px;
  text-decoration: none;
  word-break: break-all;
}
.citation-pop-link:hover,
.citation-item-link:hover { color: var(--fg); }

.citation-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.citation-list-title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.citation-list-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  counter-reset: none;
}
.citation-item {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--glass-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.citation-item-index {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-b);
  background: var(--accent-soft);
  border-radius: var(--r-xs);
}
.citation-item-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.citation-item-title { color: var(--fg); font-size: 13px; font-weight: 600; }
.citation-item-snippet { margin: 0; color: var(--fg-muted); font-size: 12.5px; line-height: 1.5; }

/* ── DrylList / DrylListItem ───────────────────────────────────
   Token-driven list. The container (.list) sets the row gap via a
   density custom property; each item (.list-item) is a flex row of
   [marker | content | end]. Markers, dividers, selected and
   interactive states are all token-driven. Counter scoping per
   .list keeps Decimal numbering correct across nested sub-lists. */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  counter-reset: dryl-list;
  --list-pad-y: var(--sp-2);
  --list-gap: var(--sp-1);
}
.list--compact     { --list-pad-y: var(--sp-1); --list-gap: 0; }
.list--default     { --list-pad-y: var(--sp-2); --list-gap: var(--sp-1); }
.list--comfortable { --list-pad-y: var(--sp-3); --list-gap: var(--sp-2); }

.list-item {
  counter-increment: dryl-list;
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
  margin-top: var(--list-gap);
  border-radius: var(--r-sm);
}
.list-item:first-child { margin-top: 0; }

/* Dividers — a hairline rule between adjacent rows (no inter-row gap). */
.list--dividers { --list-gap: 0; }
.list--dividers > .list-item { margin-top: 0; border-radius: 0; }
.list--dividers > .list-item + .list-item { border-top: 1px solid var(--line); }

/* Nested sub-list — indent and add a connector rail. */
.list .list-item .list {
  margin-top: var(--sp-1);
  padding-left: var(--sp-4);
  border-left: 1px solid var(--line);
}

/* Row body (div for static, button for interactive) — shared layout. */
.list-item-row {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--list-pad-y) var(--sp-2);
  border-radius: inherit;
  color: var(--fg-muted);
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.list-item-content { min-width: 0; flex: 1 1 auto; line-height: 1.5; }

/* Marker + leading slots — aligned to the first text line. */
.list-marker,
.list-item-icon,
.list-item-start {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.5em;
}
.list-marker { min-width: var(--sp-3); color: var(--fg-dim); }
.list-marker--default::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--fg-dim);
}
.list-marker--disc::before { content: '\2022'; font-size: 1.1em; line-height: 1; }
.list-marker--dash::before { content: '\2013'; }
.list-marker--decimal {
  color: var(--fg-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.list-marker--decimal::before { content: counter(dryl-list) '.'; }
.list-item-icon { color: var(--fg-dim); }

/* Trailing slot — pinned right, vertically centred on the row. */
.list-item-end {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding-right: var(--sp-2);
  align-self: center;
}

/* Interactive rows — button reset + hover/active affordance. */
button.list-item-row {
  width: 100%;
  font: inherit;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}
.list-item.is-interactive > .list-item-row:hover {
  background: var(--glass-1);
  border-color: var(--line);
  color: var(--fg);
}
button.list-item-row:focus-visible {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Selected — accent line + glass tint. */
.list-item.is-selected > .list-item-row {
  background: var(--glass-2);
  border-left: 2px solid var(--accent-line);
  color: var(--fg);
}
.list-item.is-selected .list-marker { color: var(--accent-b); }

/* Disabled — dim and inert. */
.list-item.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}
