:root {
  --bg: #070b14;
  --surface: rgba(18, 25, 45, 0.65);
  --surface-raised: rgba(30, 40, 65, 0.7);
  --surface-hover: rgba(45, 60, 90, 0.5);
  --border: rgba(255, 255, 255, 0.06);
  --border-visible: rgba(255, 255, 255, 0.08);
  --text: #ecedee;
  --text-secondary: #a1aab4;
  --text-muted: #5d6570;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --accent: #5eead4;
  --accent-dim: rgba(94, 234, 212, 0.12);
  --accent-hover: #2dd4bf;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  /* Alert surface/border/text tokens */
  --danger-surface: rgba(248, 113, 113, 0.08);
  --danger-border: rgba(248, 113, 113, 0.15);
  --danger-text: #fca5a5;
  --warning-surface: rgba(251, 191, 36, 0.08);
  --warning-border: rgba(251, 191, 36, 0.15);
  --warning-text: #fcd34d;
  --info-surface: rgba(96, 165, 250, 0.08);
  --info-border: rgba(96, 165, 250, 0.15);
  --info-text: #93c5fd;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #root, .layout {
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
[contenteditable="true"],
.doc-viewer-modal .modal-body,
.doc-viewer-modal .modal-body * {
  -webkit-user-select: text;
  user-select: text;
}

button,
svg,
img {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html, body, #root { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Global Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-visible);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.14);
}
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-visible) transparent;
}

/* Subtle radial vignettes — soft glow from top-center, cool counterlight from bottom */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(94, 234, 212, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

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

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  background: var(--accent);
  color: #071012;
  font-weight: 600;
  transition: all var(--transition);
}
button:hover { background: var(--accent-hover); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

input, select, textarea {
  user-select: text;
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-visible);
  background: rgba(18, 25, 45, 0.5);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
select { color-scheme: dark; }
select option {
  background-color: #0f1729;
  color: var(--text);
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

label {
  display: block;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

/* ── Layout ─────────────────────────────────────────── */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* ── Mobile panel system (scroll-snap) ────────────── */
.mobile-panels {
  display: none;
}
.mobile-panel {
  flex: 0 0 100vw;
  height: 100%;
  scroll-snap-align: start;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

@media (max-width: 768px) {
  html,
  body,
  #root,
  .layout {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .layout > .main-content {
    display: none;
  }
  .mobile-panels {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    touch-action: pan-x pan-y;
  }
  .mobile-panel {
    height: 100%;
    min-height: 0;
  }
  #panel-main {
    overflow-y: auto;
    overscroll-behavior-x: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-x pan-y;
  }
  .mobile-panels::-webkit-scrollbar {
    display: none;
  }
  #panel-chat,
  #panel-history,
  #panel-scratchpad {
    overflow: hidden;
    touch-action: pan-x pan-y;
  }
  .mobile-chat-shell,
  .mobile-history-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .mobile-history-shell {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-chat-shell {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-chat-scroll {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .mobile-chat-scroll .chat-messages {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-x: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-x pan-y;
  }
  .mobile-chat-shell .chat-input-bar,
  .mobile-chat-shell .chat-voice-error {
    flex-shrink: 0;
    touch-action: manipulation;
  }
  .mobile-history-shell .btn-new-chat {
    flex-shrink: 0;
    touch-action: manipulation;
  }
  .mobile-history-shell .chat-sidebar.embedded {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .mobile-history-shell .chat-conversations {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-x: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-x pan-y;
  }
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn-ghost:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.main-content {
  flex: 1;
  padding: 2rem;
}

/* ── Page basics ────────────────────────────────────── */
.page {
  max-width: 1400px;
  margin: 0 auto;
}
.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
}
.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}


.loading {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}
.empty-state {
  background: rgba(18, 25, 45, 0.2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.empty-state p { margin-bottom: 0.5rem; }
.empty-state p:last-child { margin-bottom: 0; }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error {
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}
.alert-warning {
  background: var(--warning-surface);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}
.alert-info {
  background: var(--info-surface);
  border: 1px solid var(--info-border);
  color: var(--info-text);
}
.alert-success-msg {
  background: var(--success-dim, rgba(52,211,153,0.08));
  border: 1px solid var(--success);
  color: var(--success);
}

/* ── Login ──────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: radial-gradient(ellipse at 50% 0%, rgba(94, 234, 212, 0.06) 0%, transparent 60%);
}
.login-card {
  background: rgba(18, 25, 45, 0.6);
  backdrop-filter: blur(24px);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.login-card h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-card h1 .brand-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
  -webkit-text-fill-color: var(--accent);
}
.login-card .subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}
.login-card form > * + * { margin-top: 0.75rem; }

/* Field wrapper */
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Real-time validation states */
.field input.valid { border-color: var(--success); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.08); }
.field input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.08); }

.field-hint {
  font-size: 0.75rem;
  transition: color 0.2s;
}
.field-hint.ok { color: var(--success); }
.field-hint.warn { color: var(--danger); }

/* Password strength bar */
.strength-bar {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.15rem;
}
.strength-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease, background 0.4s ease;
}
.strength-fill.weak { background: var(--danger); }
.strength-fill.okay { background: var(--warning); }
.strength-fill.good { background: var(--accent); }
.strength-fill.strong { background: var(--success); }

.login-error {
  color: var(--danger-text);
  font-size: 0.85rem;
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}
.login-card .toggle {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.login-card .link {
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
}
/* ── Health Nuggets ────────────────────────────────── */
.nugget-rows { padding: 0.25rem 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.15rem; }
.nugget-row { display: flex; align-items: baseline; gap: 0.35rem; font-size: 0.78rem; color: var(--text-secondary); }
.nugget-icon { font-size: 0.85rem; flex-shrink: 0; display: inline-flex; align-items: center; }
.nugget-text { line-height: 1.4; }
.nugget-key { font-weight: 600; color: var(--text); }
.nugget-detail { color: var(--text-muted); }

/* ── First-run welcome ─────────────────────────────── */
.dashboard-welcome {
  position: relative;
  margin-bottom: 1rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(94, 234, 212, 0.07) 0%, rgba(20, 28, 50, 0.55) 45%);
  overflow: hidden;
  animation: ls-slide-up 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.dashboard-welcome h2 {
  font-size: 1.3rem;
  margin-bottom: 0.35rem;
}
.dashboard-welcome > p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 580px;
  margin-bottom: 1.1rem;
}
.welcome-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.welcome-step {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
  text-align: left;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform 0.12s ease;
}
.welcome-step:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: rgba(94, 234, 212, 0.05);
  transform: translateY(-1px);
}
.welcome-step svg { color: var(--accent); }
.welcome-step strong { color: var(--text); font-size: 0.9rem; }
.welcome-step span { font-size: 0.75rem; color: var(--text-muted); line-height: 1.35; }
@media (max-width: 768px) {
  .welcome-steps { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .dashboard-welcome { animation: none; }
  .welcome-step:hover { transform: none; }
}

/* ── Dashboard dropzone ────────────────────────────── */
.dashboard-dropzone {
  border: 2px dashed var(--border-visible);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  background: rgba(18, 25, 45, 0.35);
  backdrop-filter: blur(8px);
}
.dashboard-dropzone:hover,
.dashboard-dropzone.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 40px rgba(94, 234, 212, 0.06);
}
.dashboard-dropzone.uploading {
  cursor: default;
  border-color: var(--accent);
  border-style: solid;
}
.dropzone-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.dropzone-icon { font-size: 1.25rem; }
.dropzone-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-left: 0.5rem;
}

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--accent);
  margin: 2rem;
  border-radius: var(--radius-lg);
}
.drag-overlay-content {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

/* Accordion styles → design-language/AccordionSection.jsx */


/* ── Metric tiles ───────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* Metric tile internals — scoped under .metric-tile to avoid collision with .tile */
.metric-tile .tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem 0 1rem;
  user-select: none;
}
.metric-tile .tile-header h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}
.metric-tile .tile-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Sparkline + trend colours — driven by --tile-color from unified theme */
[data-category] .tile-sparkline svg .recharts-line-curve { stroke: var(--tile-color) !important; }

.lab-panel .lab-marker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.lab-panel .lab-marker {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  font-size: 0.85rem;
}
.lab-panel.expanded .lab-marker {
  grid-template-columns: 1.4fr auto auto auto;
}
.lab-panel .lab-marker.flag-high,
.lab-panel .lab-marker.flag-low {
  background: var(--warning-surface);
  border-left: 2px solid var(--warning);
  padding-left: 6px;
}
.lab-panel .lab-marker.flag-critical {
  background: var(--danger-surface);
  border-left: 2px solid var(--danger);
  padding-left: 6px;
}
.lab-panel .lab-marker.flag-critical .lab-marker-val { color: var(--danger-text); }
.lab-panel .lab-marker-name {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-panel .lab-marker-val {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.lab-panel .lab-marker-pctile {
  font-size: 0.65rem;
  font-weight: 600;
  margin-left: 0.3rem;
}
.lab-panel .lab-marker-unit {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
}
.lab-panel .lab-marker-ref {
  color: var(--text-muted);
  font-size: 0.7rem;
  white-space: nowrap;
}
.lab-panel .lab-marker-flag {
  font-size: 0.65rem;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.lab-panel .lab-marker-flag.flag-high,
.lab-panel .lab-marker-flag.flag-low { color: var(--warning-text); background: var(--warning-surface); }
.lab-panel .lab-marker-flag.flag-critical { color: var(--danger-text); background: var(--danger-surface); }
.lab-panel .more-row {
  background: transparent;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  font-size: 0.78rem;
  border-left: none;
  padding-left: 8px;
}
.lab-panel-full {
  display: flex;
  gap: 1.5rem;
  padding: 0.3rem 1rem 0.75rem;
  align-items: flex-start;
}
.lab-marker-cols {
  flex: 1;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 4px 1.2rem;
  margin-top: 0 !important;
}
.lab-summary-card {
  flex: 0 0 240px;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--panel-color, #8b5cf6) 8%, transparent) 0%, color-mix(in srgb, var(--panel-color, #8b5cf6) 3%, transparent) 100%);
  border: 1px solid color-mix(in srgb, var(--panel-color, #8b5cf6) 16%, transparent);
  line-height: 1.55;
}
.lab-summary-text {
  margin: 0;
  font-size: 0.68rem;
  font-style: italic;
  color: var(--panel-color, #8b5cf6);
  opacity: 0.6;
}

.hometer { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0.9rem; }
.hometer-header { width: 100%; display: flex; justify-content: center; }
.hometer-header h4 { font-size: 0.85rem; display: flex; align-items: center; gap: 0.35rem; }
.hometer-detail-section { width: 100%; margin-top: 0.35rem; }
.hometer-detail-section h5 {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 1px;
  font-weight: 600;
}
.stack-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
}
.stack-gauge-wrap .tracked-name {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.metric-tile .tile-body {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem 0.75rem 1rem;
  min-height: 100px;
}
.metric-tile .tile-value {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.metric-tile .tile-number {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-shadow: 0 0 26px color-mix(in srgb, var(--tile-color, #5eead4) 30%, transparent);
  animation: ls-number-settle 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.metric-tile .tile-unit {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}
.metric-tile .tile-detail {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-left: 0.25rem;
}
.metric-tile .tile-sparkline {
  width: 100px;
  flex-shrink: 0;
  opacity: 0.85;
}
@media (max-width: 768px) {
  .metric-tile .tile-number { font-size: 1.55rem; }
}
@media (prefers-reduced-motion: reduce) {
  .metric-tile .tile-number { animation: none; }
}

.metric-tile .tile-detail-row {
  padding: 0 1rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
}

.metric-tile .tile-detail-chip {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.metric-tile .tile-detail-chip strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.metric-tile .tile-chart {
  padding: 0 0.75rem 0.75rem 0.75rem;
  animation: ls-slide-down 0.25s ease;
}
.metric-tile .tile-legend {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
  padding: 0 0.25rem;
}
.metric-tile .legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.metric-tile .legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
/* Tile tooltip */
.tile-tooltip {
  position: fixed;
  z-index: 100;
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: ls-fade-in 0.15s ease;
}
.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  padding: 0.15rem 0;
}
.tooltip-label {
  color: var(--text-muted);
  text-transform: capitalize;
}
.tooltip-val {
  color: var(--text);
  font-weight: 600;
}


/* ── Document groups (expandable list → card grid) ─────────────────── */
.doc-delete-all {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, background 0.15s;
}
.doc-delete-all:hover {
  opacity: 1;
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-surface);
}
.doc-section-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 0;
  max-width: 100%;
}
.doc-section-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
}

.doc-groups {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.doc-group {
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.doc-group.open {
  border-color: rgba(255,255,255,0.1);
}
.doc-group-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}
.doc-group-header:hover {
  background: rgba(255,255,255,0.025);
}
.doc-group-icon {
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.doc-group-name {
  font-size: 0.85rem;
  color: #e2e8f0;
  font-weight: 500;
  flex: 1;
}
.doc-group-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.doc-group .tile-grid {
  border-top: 1px solid rgba(255,255,255,0.05);
  padding: 0.75rem;
}

.summary {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Extracted section styles → design-language/DocumentViewer.jsx */

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Markdown-rendered tables */
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 0.5rem 0;
}
.md-table th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.md-table td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #cbd5e1;
}
.md-table tr:last-child td {
  border-bottom: 0;
}
/* Flag styles → design-language/DocumentViewer.jsx */

/* Pills */
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.pill {
  background: rgba(30, 40, 65, 0.5);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pill strong { color: var(--text); }
.pill span { color: var(--text-muted); font-size: 0.8rem; }

/* Diagnosis list + patient info → design-language/DocumentViewer.jsx */

/* ── Buttons ────────────────────────────────────────── */
.btn-secondary {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-primary {
  background: var(--accent);
  color: #071012;
  border: none;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }

/* ── Stack (redesigned) ─────────────────────────────── */
.tracked-add-card {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  position: relative;
  z-index: 100;
}
.tracked-add-card h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.tracked-add-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.tracked-add-form input { flex: 1; min-width: 140px; }
.tracked-add-form select { width: 140px; flex-shrink: 0; }
.tracked-add-form button { flex-shrink: 0; }
.tracked-add-form .btn-small { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

/* TriggerTile + supp card styles → design-language/TriggerTile.jsx */

/* Integrations page — tile/component styles → design-language/IntegrationTile.jsx */
.integrations-page { max-width: 800px; }
.integrations-page h1,
.integrations-embedded h1 { margin-bottom: 1.5rem; }
/* Category badge + order styles → design-language/DocumentViewer.jsx */


/* DocThumbnail styles → design-language/DocThumbnail.jsx */

/* Doc viewer thumbnail styles → design-language/DocumentViewer.jsx */

/* Delete button reveal — chat-specific cascade */
.conv-item { position: relative; }
.conv-delete {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
}
.conv-item:hover .conv-delete,
.conv-item:focus-within .conv-delete {
  opacity: 1;
  pointer-events: auto;
}


/* Tile styles → design-language/Tile.jsx */

/* ── Shared Primitives ────────────────────────────────── */

/* Glass-morphism card — deprecated, prefer <Tile>. Kept for section containers (forms, panels). */
.card-glass {
  background: rgba(18, 25, 45, 0.45);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tracked-source-count {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* Mono tool chip — SSOT for code-style tool name indicators */
.tool-chip-mono {
  display: inline-block;
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.45rem;
  color: var(--text-secondary);
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
}

/* Memory + raw JSON styles → design-language/DocumentViewer.jsx */
.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}
.btn-small.btn-icon {
  padding: 0.4rem;
  line-height: 1;
  min-width: unset;
}
/* ── Confirm Dialog ──────────────────────────────────── */
/* Accordion animation → design-language/AccordionSection.jsx */

/* ── Settings ────────────────────────────────────────── */
/* TypeSelector styles → design-language/TypeSelector.jsx */
/* GeneratingIndicator styles → design-language/BaseModal.jsx */


/* ── Chat ────────────────────────────────────────────── */
.chat-layout {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}
.chat-sidebar {
  width: 260px;
  background: rgba(18, 25, 45, 0.5);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.75rem;
}
.btn-new-chat {
  width: 100%;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(94, 234, 212, 0.2);
  padding: 0.6rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.btn-new-chat:hover {
  background: var(--accent);
  color: #071012;
}
.chat-conversations {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  flex: 1;
}
.conv-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.6rem 2.1rem 0.6rem 0.75rem;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  border: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s;
}
.conv-item:hover { background: rgba(255, 255, 255, 0.03); }
.conv-item.active {
  background: rgba(94, 234, 212, 0.06);
  border-left: 3px solid var(--accent);
}
.conv-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.conv-date { font-size: 0.75rem; color: var(--text-muted); }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.chat-empty {
  margin: auto;
  text-align: center;
  max-width: 480px;
  color: var(--text-secondary);
}
.chat-empty h2 { color: var(--text); margin-bottom: 0.5rem; }
.chat-examples {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-examples button {
  background: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
}
.chat-examples button:hover { border-color: var(--accent); color: var(--accent); }
.chat-message { display: flex; }
.chat-message.user { justify-content: flex-end; }
.chat-message.assistant { justify-content: flex-start; }
.chat-message.boss { justify-content: center; }
.chat-message.boss .message-bubble.boss-bubble {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.18), rgba(180, 83, 9, 0.10));
  border: 1px dashed rgba(217, 119, 6, 0.45);
  max-width: 620px;
}
.chat-message.boss .method-badge {
  color: rgb(251, 191, 36);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}
.message-bubble {
  max-width: 720px;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-lg);
  background: rgba(30, 40, 65, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
}
.chat-message.user .message-bubble {
  background: rgba(94, 234, 212, 0.10);
  border-color: rgba(94, 234, 212, 0.2);
}
.chat-message.error .message-bubble { border-color: var(--danger); }
.chat-stream-turn {
  display: grid;
  justify-items: start;
  gap: 0.45rem;
  max-width: 720px;
}
.stream-turn-header {
  width: min(100%, 720px);
  padding: 0 0.25rem;
}

.chat-attachments-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.chat-file-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  background: rgba(94, 234, 212, 0.05);
  border: 1px solid rgba(94, 234, 212, 0.1);
  border-radius: 8px;
  max-width: 340px;
}
.chat-file-card:hover {
  border-color: rgba(94, 234, 212, 0.25);
  background: rgba(94, 234, 212, 0.08);
}
.chat-file-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.chat-file-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-file-cat {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.upload-bubble-container { justify-content: flex-end; }
.upload-bubble {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 220px;
  max-width: 340px;
  flex-wrap: wrap;
}
.upload-bubble-badge {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 15%, rgba(18,25,45,0.5));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.upload-bubble-badge .doc-thumb {
  width: 100% !important;
  height: 100% !important;
  border: 0;
  border-radius: 8px;
  background: transparent;
}
.upload-bubble-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}
.upload-bubble-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-bubble-pct {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.upload-progress-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  flex-basis: 100%;
}
.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
  position: absolute;
  left: 0;
  top: 0;
}
.upload-progress-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.12) 50%, transparent 100%);
  animation: ls-shimmer 1.4s ease-in-out infinite;
}

.message-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 1.25rem;
}
.message-content {
  user-select: text;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}
.message-content .markdown-content {
  white-space: normal;
}
.message-content .markdown-content h2 { font-size: 1.15rem; font-weight: 700; margin: 0.75rem 0 0.4rem; color: var(--text); }
.message-content .markdown-content h3 { font-size: 1.05rem; font-weight: 600; margin: 0.6rem 0 0.3rem; color: var(--text); }
.message-content .markdown-content h4 { font-size: 0.95rem; font-weight: 600; margin: 0.5rem 0 0.25rem; color: var(--text-secondary); }
.message-content .markdown-content p { margin: 0.25rem 0; }
.message-content .markdown-content ul { margin: 0.35rem 0; padding-left: 1.25rem; }
.message-content .markdown-content li { margin: 0.15rem 0; }
.message-content .markdown-content strong { font-weight: 700; }
.method-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chat-message.voice .message-bubble {
  border-left: 2px solid rgba(251, 191, 36, 0.35);
}
.chat-message.text .message-bubble {
  border-left: 2px solid transparent;
}
.tool-calls {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.tool-calls summary { cursor: pointer; color: var(--accent); margin-bottom: 0; }
.tool-calls pre {
  background: var(--bg);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}
.tool-calls code {
  background: var(--bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}
.tool-args {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-width: 100%;
  min-width: 0;
  vertical-align: middle;
}
.tool-arg {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.chat-input-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  background: rgba(18, 25, 45, 0.4);
}
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.chat-input-row input { flex: 1; min-width: 0; }
.chat-pending-attachments {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}
.chat-pending-attachment {
  position: relative;
  display: grid;
  grid-template-columns: 2.15rem minmax(0, 1fr) 1.5rem;
  align-items: center;
  gap: 0.5rem;
  min-width: min(15rem, 100%);
  max-width: 18rem;
  padding: 0.45rem 0.45rem 0.45rem 0.55rem;
  border: 1px solid rgba(94, 234, 212, 0.16);
  border-radius: var(--radius);
  background: rgba(94, 234, 212, 0.06);
  overflow: hidden;
}
.chat-pending-attachment.error {
  border-color: rgba(239, 68, 68, 0.24);
  background: rgba(239, 68, 68, 0.08);
}
.chat-pending-thumb {
  width: 2.15rem;
  height: 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, currentColor 14%, rgba(18,25,45,0.58));
  overflow: hidden;
}
.chat-pending-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-pending-info {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}
.chat-pending-name {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-pending-status {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: capitalize;
}
.chat-pending-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255,255,255,0.08);
}
.chat-pending-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.chat-pending-remove {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.chat-pending-remove:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}
.chat-pending-remove:disabled {
  cursor: wait;
  opacity: 0.35;
}

.chat-mic-btn,
.chat-composer-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-composer-btn {
  color: var(--text-secondary);
}
.chat-mic-btn.record {
  touch-action: none;
}
.chat-mic-btn:hover,
.chat-composer-btn:hover {
  background: var(--surface-raised);
  border-color: var(--accent);
  color: var(--accent);
}
.chat-mic-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.chat-mic-btn.recording { background: rgba(239, 68, 68, 0.15); border-color: var(--danger); color: var(--danger); animation: ls-pulse 1.5s ease infinite; }
.chat-mic-btn.connecting { border-color: var(--warning); color: var(--warning); animation: pulse 1s ease infinite; }
.chat-mic-btn.enabled { background: var(--accent-dim); }
.chat-mic-btn.error { border-color: var(--danger); color: var(--danger); }
.chat-send-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #071012;
}
.chat-send-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #071012;
}
.chat-voice-error {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; margin: 4px 8px; border-radius: 6px;
  background: rgba(239, 68, 68, 0.12); border: 1px solid var(--danger);
  color: var(--danger); font-size: 0.85em;
}
.chat-voice-error-action {
  background: transparent; border: 1px solid var(--danger); color: var(--danger);
  padding: 2px 10px; border-radius: 4px; cursor: pointer; font-size: 0.85em;
}
.chat-voice-error-action:hover { background: rgba(239, 68, 68, 0.18); }
.typing-indicator {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  height: 1.5rem;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: ls-bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

.muted { color: var(--text-muted); font-size: 0.875rem; }

/* Chat enhancements */

.thinking-block {
  margin-bottom: 0.5rem;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}
.thinking-block summary {
  cursor: pointer;
  color: #a855f7;
  font-size: 0.8rem;
  font-weight: 600;
}
.thinking-block summary strong {
  color: #c4b5fd;
  font-weight: 700;
  margin-left: 0.4rem;
  animation: ls-thinking-title-in 0.22s ease;
}
.thinking-content {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: #c4b5fd;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}
.thinking-content p,
.thinking-content ul,
.thinking-content ol {
  margin: 0.35rem 0;
}
.thinking-content strong {
  color: #ddd6fe;
}

.context-intelligence {
  margin-bottom: 0.5rem;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}
.context-intelligence.compact {
  margin: 0 0 0 auto;
  padding: 0;
  position: relative;
  background: transparent;
  border: 0;
  border-radius: 0;
  line-height: 1;
}
.context-intelligence summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  list-style: none;
}
.context-intelligence.compact summary {
  min-width: 1.85rem;
  min-height: 1.35rem;
  padding: 0.1rem 0.25rem;
  justify-content: center;
  gap: 0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.26);
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.context-intelligence.compact summary:hover {
  border-color: rgba(94, 234, 212, 0.34);
  background: rgba(20, 184, 166, 0.09);
  transform: translateY(-1px);
}
.context-intelligence summary::-webkit-details-marker { display: none; }
.context-debug {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.4rem;
}
.context-intelligence.compact .context-debug {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 25;
  width: min(22rem, 72vw);
  max-height: min(24rem, 52vh);
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  text-transform: none;
  letter-spacing: 0;
}
.context-debug-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 0.35fr) 1fr;
  gap: 0.6rem;
  font-size: 0.78rem;
  line-height: 1.4;
}
.context-debug-label {
  color: var(--text-muted);
  font-weight: 700;
}
.context-debug-value {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.context-thinking {
  display: grid;
  gap: 0.3rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.context-thinking .thinking-content {
  max-height: 14rem;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.context-raw {
  margin-top: 0.25rem;
}
.context-raw summary {
  justify-content: flex-start;
  color: var(--text-muted);
  font-size: 0.72rem;
}
.context-raw pre {
  margin: 0.4rem 0 0;
  padding: 0.5rem;
  max-height: 12rem;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.28);
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.context-source {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
.context-source.hit { color: var(--success); }
.context-source.live { color: var(--warning); }
.context-source.checking { color: var(--text-muted); }
.context-source.skipped { color: var(--warning); }
.context-route-icons {
  display: inline-flex;
  align-items: end;
  gap: 0.22rem;
  color: var(--text-muted);
}
.context-route-icon {
  flex: 0 0 auto;
  stroke-width: 2.2;
}
.context-route-icon.hit { color: var(--success); }
.context-route-icon.live { color: var(--warning); }
.context-route-icon.checking { color: var(--text-muted); animation: ls-pulse 1.2s ease-in-out infinite; }
.context-route-icon.boss { color: rgb(251, 191, 36); }
.context-route-icon.thinking { color: #c084fc; }
.context-route-icon.tools-off { color: var(--text-muted); opacity: 0.75; }
.context-level-bars {
  display: inline-flex;
  align-items: end;
  gap: 2px;
  height: 12px;
  padding: 0 1px;
}
.context-level-bars span {
  width: 3px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.3);
}
.context-level-bars span:nth-child(1) { height: 4px; }
.context-level-bars span:nth-child(2) { height: 7px; }
.context-level-bars span:nth-child(3) { height: 10px; }
.context-level-bars.low span.active { background: #67e8f9; }
.context-level-bars.medium span.active { background: var(--accent); }
.context-level-bars.high span.active { background: #c084fc; }
.context-intent {
  margin-top: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
}
.context-tool-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.tool-chip.context-tool {
  background: rgba(20, 184, 166, 0.1);
  color: var(--accent);
}

.message-stream-events {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  width: min(100%, 720px);
}
.stream-event-row {
  display: flex;
  justify-content: flex-start;
}
.stream-event-bubble {
  max-width: 720px;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-lg);
  background: rgba(30, 40, 65, 0.5);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.16s ease;
}
.stream-text-segment {
  min-width: 0;
}
.stream-text-segment.message-content,
.stream-speech-segment.message-content {
  margin: 0;
}
.stream-speech-segment {
  min-width: 0;
  border-color: rgba(94, 234, 212, 0.22);
  background: rgba(30, 40, 65, 0.46);
}
.stream-thinking-segment.thinking-block {
  margin: 0;
  max-width: min(32rem, 100%);
  padding: 0.5rem 0.7rem;
  animation: ls-thinking-card-in 0.22s ease;
}
.stream-tool-card {
  padding: 0.45rem 0.55rem;
  max-width: min(36rem, 100%);
}
.stream-tool-card summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.stream-tool-card summary::-webkit-details-marker { display: none; }
.stream-tool-detail {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.55rem;
}
.stream-tool-detail-row {
  display: grid;
  gap: 0.35rem;
}
.stream-tool-detail pre {
  margin: 0;
  max-height: 12rem;
  overflow: auto;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.28);
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@keyframes ls-thinking-card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ls-thinking-title-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
.tool-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  animation: ls-chip-in 0.2s ease;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.tool-chip.running {
  background: rgba(94, 234, 212, 0.1);
  color: var(--accent);
}
.tool-chip.done {
  background: rgba(94, 234, 212, 0.05);
  color: var(--success);
}
.tool-chip.failed {
  background: rgba(248, 113, 113, 0.08);
  color: #f87171;
}
.tool-chip.compressed {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  opacity: 0.6;
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.2);
  text-decoration-thickness: 1px;
}
.tool-chip.compressed:hover {
  opacity: 0.85;
}
.tool-error {
  font-size: 0.78rem;
  color: #f87171;
  background: rgba(248, 113, 113, 0.06);
  border: 1px solid rgba(248, 113, 113, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.5rem;
}
.tool-error-msg {
  display: block;
  font-size: 0.68rem;
  opacity: 0.8;
  margin-top: 0.15rem;
}


/* ── Floating Chat Widget ───────────────────────────── */
.chat-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #2dd4bf);
  color: #071012;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(94, 234, 212, 0.3), 0 0 0 0 rgba(94, 234, 212, 0.4);
  border: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  animation: ls-fab-glow 3s ease-in-out infinite;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(94, 234, 212, 0.5), 0 0 0 8px rgba(94, 234, 212, 0);
}



.chat-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  width: 420px;
  height: 560px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 6rem);
  background: color-mix(in srgb, var(--panel-mood, transparent), rgba(18, 25, 45, 0.8));
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-visible);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ls-slide-up 0.25s ease;
  transition: background 0.4s ease;
}
.chat-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.chat-panel-actions {
  display: flex;
  gap: 0.35rem;
}
.chat-panel-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1.1rem;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1;
}
.chat-panel-btn:hover { background: var(--surface-raised); color: var(--text); }

.chat-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.chat-panel-body .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-panel-body .chat-input-bar {
  padding: 0.75rem;
}
.chat-panel-body .message-bubble { max-width: 100%; }
.chat-panel-body .message-content { font-size: 0.9rem; }
.chat-panel-body .chat-empty h2 { font-size: 1.1rem; }
.chat-panel-body .chat-empty p { font-size: 0.85rem; }
.chat-panel-body .chat-examples button { font-size: 0.8rem; padding: 0.5rem 0.75rem; }

.chat-minimize-btn {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

/* Fullscreen chat overlay */
.chat-fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  animation: ls-fade-in 0.2s ease;
  transition: left 0.36s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.36s ease;
}
.chat-fullscreen-overlay.scratchpad-open {
  left: min(460px, 92vw);
  box-shadow: -18px 0 42px rgba(0,0,0,0.28);
}
/* Embedded components (inside accordions) */
.insights-embedded .page-header,
.stack-embedded .page-header { display: none; }
.insights-embedded { padding-top: 0.25rem; }
.stack-embedded { padding-top: 0.25rem; }
.integrations-embedded { padding-top: 0.25rem; }
.integrations-embedded h1 { display: none; }

/* Metric category within accordion */
.metric-category { margin-bottom: 1.5rem; }
.metric-category:last-child { margin-bottom: 0; }

/* ── Health Correlation ─────────────────────────────────────────────── */
.correlation-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.correlation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
  justify-content: center;
  margin-top: 0.75rem;
}

.correlation-legend label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.02);
  transition: var(--transition);
}
.correlation-legend label:has(input:checked) {
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}
.correlation-legend label input { display: none; }

.toggle-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--dot-color, var(--accent));
  flex-shrink: 0;
}

.correlation-chart-container {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 1rem 1rem 0.5rem;
}

/* ── Legend trays ──────────────────────────────────────────────────── */
.legend-tray {
  margin-top: 0.35rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.legend-tray .correlation-legend {
  margin: 0;
}

/* ── Rug tooltip (floating over chart) ─────────────────────────────── */
.rug-tooltip {
  position: absolute;
  z-index: 20;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-visible);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  min-width: 200px;
  max-width: 340px;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.rug-tooltip-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 0.3rem;
}
.rug-tooltip-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.15rem 0;
}
.rug-tooltip-icon { flex-shrink: 0; font-size: 0.75rem; line-height: 1.3; }
.rug-tooltip-body { min-width: 0; }
.rug-tooltip-cat {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.rug-tooltip-detail {
  font-size: 0.78rem;
  color: #e2e8f0;
  line-height: 1.4;
  margin-top: 0.05rem;
}

/* ScratchPad styles → design-language/ScratchPad.jsx */

/* ── Reports ────────────────────────────────────────── */
.report-body {
  user-select: text;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}
.report-body h2 { font-size: 1.2rem; margin: 1rem 0 0.5rem; color: var(--text); }
.report-body h3 { font-size: 1.05rem; margin: 0.85rem 0 0.4rem; color: var(--text); }
.report-body h4 { font-size: 0.9rem; margin: 0.6rem 0 0.3rem; color: var(--text-secondary); }
.report-body p { margin: 0.35rem 0; color: var(--text-secondary); }
.report-body ul { padding-left: 1.5rem; margin: 0.35rem 0; }
.report-body li { color: var(--text-secondary); margin: 0.15rem 0; }
.report-body strong { color: var(--text); }
.report-body table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.85rem; }
.report-body td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.report-body tr:first-child td { color: var(--text); font-weight: 600; }

/* ── Mobile (≤768px) ──────────────────────────────── */

@media (max-width: 768px) {
  /* Layout & safe areas */
  .layout {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .main-content {
    padding: 1rem;
    padding-left: calc(1rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  }
  .page {
    max-width: 100%;
  }

  /* Fluid typography */
  .page-header h2 {
    font-size: clamp(1.2rem, 5vw, 1.75rem);
  }
  .page-header .subtitle {
    font-size: clamp(0.8rem, 3vw, 0.95rem);
  }


  /* Smooth scrolling for iOS */
  .chat-messages,
  .chat-conversations,
  .sp-body {
    -webkit-overflow-scrolling: touch;
  }

  .doc-section-actions {
    gap: 0.45rem;
  }
  /* Upload dropzone — compact */
  .dashboard-dropzone {
    padding: 1rem 0.75rem;
  }
  .dropzone-content {
    gap: 0.35rem;
  }
  .dropzone-hint {
    display: none;
  }
}

@media print {
  body::before { display: none; }
  .accordion-section,
  .chat-fab,
  .sp-fab,
  .page-header,
  .run-selector,
  .alert,
  .generating-indicator,
  .empty-state { display: none !important; }
  .modal-overlay {
    position: static;
    background: none;
    backdrop-filter: none;
    padding: 0;
  }
  .modal-content {
    box-shadow: none;
    border: none;
    max-width: 100%;
    background: none;
    backdrop-filter: none;
  }
  .modal-header { position: static; }
  .modal-header button { display: none; }
  .report-body { color: #000; }
  .report-body p, .report-body li, .report-body td { color: #222; }
  .report-body h2, .report-body h3, .report-body h4 { color: #000; }
  .memory-content {
    background: none;
    border: none;
    padding: 0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
    max-height: none;
    overflow: visible;
  }
}

/* ---- Device Tester ---- */
.device-tester {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.375rem;
}
.device-tester-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.device-tester-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 75ms ease-out;
  background: linear-gradient(to right, #a855f7, #3b82f6, #22d3ee);
}
.btn-tiny {
  font-size: 0.6875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
}
.tester-active { color: #c4b5fd; background: rgba(168,85,247,0.15); }
