: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;

  /* Category colors */
  --cat-heart: #f472b6;
  --cat-heart-dim: rgba(244, 114, 182, 0.12);
  --cat-sleep: #a78bfa;
  --cat-sleep-dim: rgba(167, 139, 250, 0.12);
  --cat-activity: #fbbf24;
  --cat-activity-dim: rgba(251, 191, 36, 0.12);
  --cat-body: #60a5fa;
  --cat-body-dim: rgba(96, 165, 250, 0.12);
  --cat-labs: #fb7185;
  --cat-labs-dim: rgba(251, 113, 133, 0.12);
  --cat-other: #5eead4;
  --cat-other-dim: rgba(94, 234, 212, 0.10);
}

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

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 vignette — soft glow from top-center */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 0%, rgba(94, 234, 212, 0.04) 0%, transparent 55%);
  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) {
  .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;
  }
  .mobile-panels::-webkit-scrollbar {
    display: none;
  }
}

.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: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text-secondary); }
.nugget-icon { font-size: 0.85rem; flex-shrink: 0; }
.nugget-text { line-height: 1.35; }

/* ── Dashboard dropzone ────────────────────────────── */
.upload-results {
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.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; }
[data-category] .trend-badge.up { color: var(--tile-color); }

.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,
.lab-panel .lab-marker.flag-critical {
  background: rgba(251, 113, 133, 0.08);
  border-left: 2px solid var(--cat-labs);
  padding-left: 6px;
}
.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-spectrum {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.lab-spectrum-bar {
  display: block;
  width: 36px;
  height: 3px;
  border-radius: 2px;
  position: relative;
}
.lab-spectrum-dot {
  position: absolute;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(255,255,255,0.8);
  transform: translateX(-50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.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(--cat-labs); background: var(--cat-labs-dim); }
.lab-panel .lab-marker-flag.flag-critical { color: #fca5a5; background: rgba(239, 68, 68, 0.18); }
.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 .trend-badge.stable {
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
}
.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;
}

/* HealthOMeter */
.hometer-tile { cursor: pointer; }
.hometer-row {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 12px;
  padding: 8px 0;
}
/* HealthGauge styles → design-language/HealthGauge.jsx */
.hometer-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-visible);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hometer-detail-section h5 {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 1px;
  font-weight: 600;
}
.hometer-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hometer-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  font-size: 0.78rem;
  color: var(--text);
  border: 1px solid var(--border-visible);
  white-space: nowrap;
}
.hometer-pill.has-flagged { border-color: var(--cat-labs); }
.hometer-pill.rating-strong { border-color: var(--success); }
.hometer-pill.rating-moderate { border-color: var(--accent); }
.hometer-pill.rating-limited { border-color: var(--warning); }
.hometer-pill em { color: var(--cat-labs); font-style: normal; }

.stack-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
}
.stack-gauge-wrap .supp-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: 1.65rem;
  font-weight: 700;
  line-height: 1.2;
}
.metric-tile .tile-unit {
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.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.7;
}

.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: slideDown 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%;
}
.metric-tile .tile-smoothing {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.smooth-chip {
  padding: 0.25rem 0.6rem;
  font-size: 0.73rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 500;
}
.smooth-chip:hover { border-color: var(--border-visible); color: var(--text); }
.smooth-chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.2);
  font-weight: 600;
}

.trend-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}
.trend-badge.up { color: var(--success); background: rgba(52, 211, 153, 0.10); }
.trend-badge.down { color: var(--danger); background: rgba(248, 113, 113, 0.10); }
.trend-badge.stable { color: var(--text-muted); background: rgba(255, 255, 255, 0.04); }

/* 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: fadeIn 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;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 400px; }
}

/* ── Document groups (expandable list → card grid) ─────────────────── */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}
.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: rgba(255,255,255,0.12);
  transition: background 0.2s;
  position: relative;
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(14px);
}
.toggle-count {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-weight: 600;
  line-height: 1.3;
}
.doc-delete-all {
  font-size: 0.76rem;
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}
.doc-delete-all:hover {
  opacity: 1;
  color: var(--danger);
}

.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-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.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;
}

@keyframes spin { to { transform: rotate(360deg); } }
.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) ─────────────────────────────── */
.supp-add-card {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  position: relative;
  z-index: 100;
}
.supp-add-card h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.supp-add-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.supp-add-form input { flex: 1; min-width: 140px; }
.supp-add-form select { width: 140px; flex-shrink: 0; }
.supp-add-form button { flex-shrink: 0; }
.supp-add-form .btn-small { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

/* ── Autocomplete ── */
.autocomplete-wrap {
  position: relative;
  flex: 1;
  min-width: 140px;
}
.autocomplete-wrap input {
  width: 100%;
  box-sizing: border-box;
}
.autocomplete-spinner {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border-visible);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 9999;
  max-height: 420px;
  overflow-y: auto;
  animation: slideDown 0.12s ease;
}
.autocomplete-item {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.1s, border-left-color 0.15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item.has-rating {
  background: color-mix(in srgb, var(--item-rating) 8%, transparent);
}
.autocomplete-item.active,
.autocomplete-item:hover {
  background: var(--surface-raised);
}
.autocomplete-item.has-rating.active,
.autocomplete-item.has-rating:hover {
  background: color-mix(in srgb, var(--item-rating) 14%, var(--surface-raised));
}
.autocomplete-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.autocomplete-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.autocomplete-rating {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.autocomplete-unresearched {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  background: var(--surface-raised);
  color: var(--text-muted);
  text-transform: uppercase;
}
.autocomplete-aliases {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  font-style: italic;
}
.autocomplete-summary {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.autocomplete-meta {
  padding: 0.35rem 0.75rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  text-align: right;
}

.meta-chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-secondary);
}
.meta-chip.warning {
  background: rgba(var(--warning-rgb, 255 193 7), 0.15);
  color: var(--warning);
}
.meta-chip.muted { opacity: 0.6; }

/* 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 */

/* Job toast cards — bottom of screen, one per file/job */
.job-toast-container {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 420px;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.job-toast {
  background: rgba(18, 25, 45, 0.8);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-visible);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
  pointer-events: auto;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.job-toast.done {
  border-left: 3px solid var(--success);
  opacity: 0.85;
}
.job-toast.failed {
  border-left: 3px solid var(--danger);
}
.job-toast.active {
  border-left: 3px solid var(--accent);
}
.job-toast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  gap: 0.75rem;
}
.job-toast-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
}
.job-toast-stage {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
}
.job-toast.done .job-toast-stage { color: var(--success); }
.job-toast.failed .job-toast-stage { color: var(--danger); }
.job-toast-bar {
  height: 3px;
  background: var(--surface-raised);
  border-radius: 999px;
  overflow: hidden;
}
.job-toast-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.5s ease;
}
.job-toast-fill.done { background: var(--success); }
.job-toast-fill.failed { background: var(--danger); }

/* Toast colour variants */
.job-toast.toast-success { border-left-color: var(--success); }
.job-toast.toast-success .job-toast-stage { color: var(--success); }
.job-toast.toast-success .job-toast-fill { background: var(--success); }
.job-toast.toast-error { border-left-color: var(--danger); }
.job-toast.toast-error .job-toast-stage { color: var(--danger); }
.job-toast.toast-error .job-toast-fill { background: var(--danger); }
.job-toast.toast-warning { border-left-color: var(--warning); }
.job-toast.toast-warning .job-toast-stage { color: var(--warning); }
.job-toast.toast-warning .job-toast-fill { background: var(--warning); }
.job-toast.toast-info { border-left-color: var(--accent); }
.job-toast.toast-info .job-toast-stage { color: var(--accent); }
.job-toast.toast-info .job-toast-fill { background: var(--accent); }

.job-toast.toast-flash {
  animation: slideUp 0.25s ease, fadeAway 0.5s ease 5.5s forwards;
}
.job-toast.grouped {
  padding-bottom: 0.65rem;
}
.job-toast-children {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.job-toast-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 18px;
}
.job-toast-row-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.76rem;
  color: var(--text-secondary);
}
.job-toast-row-stage {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.job-toast-row.active .job-toast-row-stage { color: var(--accent); }
.job-toast-row.done .job-toast-row-stage { color: var(--success); }
.job-toast-row.failed .job-toast-row-stage { color: var(--danger); }
.job-toast-row.overflow {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
}
@keyframes fadeAway {
  to { opacity: 0; transform: translateY(-8px); }
}


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

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

/* Delete button reveal — chat-specific cascade */
.conv-item:hover .btn-delete-icon,
.run-meta:hover .btn-delete-icon { opacity: 1; }

.conv-item { position: relative; }
.conv-delete {
  position: absolute;
  right: 0.5rem;
  top: 0.6rem;
}

.run-meta .btn-delete-icon { margin-left: 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);
}

/* Accent badge — SSOT for pills, chips, and status indicators */
.badge {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.75rem;
}

/* Rating badge — colored by rating, dashed outline when from autocomplete */
.badge.research-badge {
  background: var(--rating-color, var(--text-muted));
  color: #000;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}
.badge.research-badge[data-source="autocomplete"] {
  background: transparent;
  color: var(--rating-color, var(--text-muted));
  border: 1px dashed var(--rating-color, var(--text-muted));
}
.badge.research-badge.researching {
  background: var(--text-muted);
  color: var(--text);
  letter-spacing: 0;
}
.supp-source-count {
  color: var(--text-muted);
  font-size: 0.72rem;
}
.badge.supply-badge {
  align-items: center;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  display: inline-flex;
  gap: 0.25rem;
  letter-spacing: 0;
  margin-top: 0.15rem;
  width: fit-content;
}
.badge.supply-badge.ok { color: var(--success); }
.badge.supply-badge.soon { color: var(--warning); }
.badge.supply-badge.low,
.badge.supply-badge.out { color: var(--danger); }

.hometer-pill-source {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  opacity: 0.7;
}
.hometer-pill-source.rating-source-research { color: var(--success); opacity: 0.9; }
.hometer-pill-source.rating-source-autocomplete { color: var(--text-muted); }

/* 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 ────────────────────────────────────────── */
.source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(18, 25, 45, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: help;
}
.source-chip .source-icon {
  font-size: 1rem;
}
.source-chip .source-label {
  font-weight: 500;
}

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

/* ── Run meta type badge ───────────────────────────────── */
.run-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── 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 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%;
  padding-right: 1.5rem;
}
.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); }

/* ── System message banner ────────────────────── */
.chat-system-msg {
  display: flex;
  justify-content: center;
  padding: 0.5rem 1rem;
  margin: 0.25rem 0;
  animation: fadeIn 0.3s ease;
}
.chat-system-msg span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 600px;
  line-height: 1.45;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(94, 234, 212, 0.06);
  border: 1px solid rgba(94, 234, 212, 0.12);
}

.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: shimmerSlide 1.4s ease-in-out infinite;
}
@keyframes shimmerSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.message-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.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;
}
.chat-input-bar {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  background: rgba(18, 25, 45, 0.4);
}
.chat-input-bar input { flex: 1; }

.chat-mic-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-mic-btn:hover { 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: 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-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); }
.breath-row { margin: 2px 0; }
.breath-row .message-bubble.breath-bubble {
  background: none; border: none; padding: 1px 14px; box-shadow: none;
}
.breath-indicator { font-size: 0.85rem; opacity: 0.55; animation: breathFade 1.5s ease forwards; pointer-events: none; display: inline-block; }
@keyframes breathFade { 0% { opacity: 0.6; } 50% { opacity: 0.35; } 100% { opacity: 0; } }
.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: 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; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
.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-content {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: #c4b5fd;
  white-space: pre-wrap;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

.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 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;
}
.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-intent,
.context-roadmap {
  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);
}

.tool-indicator {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.tool-chip {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  animation: chipIn 0.2s ease;
}
.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-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;
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 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: fabGlow 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);
}

@keyframes fabGlow {
  0%, 100% { box-shadow: 0 4px 24px rgba(94, 234, 212, 0.3), 0 0 0 0 rgba(94, 234, 212, 0.4); }
  50% { box-shadow: 0 4px 28px rgba(94, 234, 212, 0.4), 0 0 0 6px 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: slideUp 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: fadeIn 0.2s ease;
}
/* 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; }

.source-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  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);
  }

  /* Job toast container — full width */
  .job-toast-container {
    width: calc(100vw - 1rem);
    max-width: 420px;
  }

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

  /* Source chips — icons only */
  .source-chip .source-label { display: none; }
  .source-chip { padding: 0.35rem 0.55rem; }

  /* 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,
  .job-toast-container,
  .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); }
