/* ═══════════════════════════════════════════════════════════════════════════════
   ADAPTIVE DYNAMICS - Restraint-First UI
   ═══════════════════════════════════════════════════════════════════════════════

   Core Principles:
   1. No dashboards as default - direction, not scores
   2. Time > numbers - temporal and directional
   3. Silence is a first-class UI state

   This UI should feel closer to:
   - A navigation instrument
   - A weather system
   - A clinical observation window

   NOT a fitness tracker.

   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   ROOT VARIABLES - Adaptive Dynamics Theme
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  /* Calm palette - no bright alerts by default */
  --ad-void: #08080c;
  --ad-deep: #0c0c12;
  --ad-surface: #101018;
  --ad-elevated: #161620;
  --ad-muted: #1e1e2a;

  /* Neutral text - nothing screams */
  --ad-text-primary: #c8c8d0;
  --ad-text-secondary: #8888a0;
  --ad-text-tertiary: #5a5a70;
  --ad-text-whisper: #3a3a4a;

  /* Accent - single, calm accent */
  --ad-accent: #667788;
  --ad-accent-glow: rgba(102, 119, 136, 0.15);
  --ad-accent-soft: rgba(102, 119, 136, 0.08);

  /* Direction states - subtle, not alarming */
  --ad-stable: #4a6a5a;
  --ad-transition: #6a6a4a;
  --ad-seeking: #5a5a6a;

  /* Observation mode overlay */
  --ad-observation-overlay: rgba(8, 8, 12, 0.4);

  /* Spacing - generous, breathing room */
  --ad-space-xs: 8px;
  --ad-space-sm: 16px;
  --ad-space-md: 24px;
  --ad-space-lg: 40px;
  --ad-space-xl: 64px;

  /* Typography */
  --ad-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --ad-font-size-whisper: 11px;
  --ad-font-size-caption: 12px;
  --ad-font-size-body: 14px;
  --ad-font-size-lead: 16px;
  --ad-font-size-title: 20px;

  /* Transitions - slow, intentional */
  --ad-transition-slow: 800ms cubic-bezier(0.4, 0, 0.2, 1);
  --ad-transition-medium: 500ms cubic-bezier(0.4, 0, 0.2, 1);
  --ad-transition-fast: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────────────────────────────────────
   BASE CONTAINER
   ───────────────────────────────────────────────────────────────────────────── */

.ad-container {
  min-height: 100%;
  background: var(--ad-void);
  color: var(--ad-text-primary);
  font-family: var(--ad-font);
  padding: var(--ad-space-lg);
  overflow-x: hidden;
}

.ad-container * {
  box-sizing: border-box;
}

/* ─────────────────────────────────────────────────────────────────────────────
   HEADER
   ───────────────────────────────────────────────────────────────────────────── */

.ad-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--ad-void);
  padding-bottom: var(--ad-space-md);
  margin-bottom: var(--ad-space-md);
  border-bottom: 1px solid var(--ad-muted);
}

.ad-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--ad-space-sm);
}

.ad-header-title h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ad-text-primary);
}

.ad-header-subtitle {
  margin: 4px 0 0 0;
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-secondary);
}

.ad-header-controls {
  display: flex;
  gap: var(--ad-space-sm);
  align-items: center;
}

.ad-patient-selector {
  display: flex;
  align-items: center;
  gap: var(--ad-space-sm);
  margin-bottom: var(--ad-space-sm);
}

.ad-patient-selector label {
  font-size: var(--ad-font-size-body);
  color: var(--ad-text-secondary);
  font-weight: 500;
}

.ad-patient-selector select {
  background: var(--ad-surface);
  border: 1px solid var(--ad-text-whisper);
  color: var(--ad-text-primary);
  font-size: var(--ad-font-size-body);
  padding: var(--ad-space-xs) var(--ad-space-sm);
  border-radius: 6px;
  cursor: pointer;
  min-width: 200px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a5a70' d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.ad-patient-selector select:hover {
  border-color: var(--ad-accent);
}

.ad-patient-selector select:focus {
  outline: none;
  border-color: var(--ad-accent);
  box-shadow: 0 0 0 2px var(--ad-accent-soft);
}

.ad-explainer {
  background: var(--ad-elevated);
  border-radius: 8px;
  padding: var(--ad-space-sm) var(--ad-space-md);
  border-left: 3px solid var(--ad-accent);
}

.ad-explainer p {
  margin: 0;
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-secondary);
  line-height: 1.5;
}

.ad-explainer strong {
  color: var(--ad-text-primary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   1. DIRECTION VIEW - Physiological Attractor
   "The centerpiece, not a tab" - ENHANCED VISUALIZATION
   ───────────────────────────────────────────────────────────────────────────── */

.ad-direction {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: var(--ad-space-xl) var(--ad-space-lg);
}

/* The Basin - SVG container */
.ad-basin {
  position: relative;
  width: 100%;
  max-width: 450px;
  aspect-ratio: 1;
  margin-bottom: var(--ad-space-lg);
}

.ad-basin svg {
  width: 100%;
  height: 100%;
}

/* Outer atmosphere ring - subtle glow */
.ad-atmosphere-ring {
  fill: none;
  stroke: rgba(99, 102, 241, 0.08);
  stroke-width: 25;
  opacity: 0.5;
}

/* Basin fill - gravitational well effect */
.ad-basin-fill {
  opacity: 0.8;
  transition: opacity var(--ad-transition-slow);
}

/* Contour rings - depth perception lines */
.ad-basin-edge {
  fill: none;
  stroke-width: 1;
  transition: all var(--ad-transition-slow);
}

.ad-ring-1 {
  stroke: rgba(56, 189, 248, 0.15);
}

.ad-ring-2 {
  stroke: rgba(99, 102, 241, 0.18);
}

.ad-ring-3 {
  stroke: rgba(139, 92, 246, 0.22);
}

.ad-ring-4 {
  stroke: rgba(168, 85, 247, 0.25);
}

.ad-ring-5 {
  stroke: rgba(192, 132, 252, 0.3);
}

/* Animate rings subtly */
.ad-contour-rings circle {
  animation: ringPulse 8s ease-in-out infinite;
}

.ad-ring-1 { animation-delay: 0s; }
.ad-ring-2 { animation-delay: 0.5s; }
.ad-ring-3 { animation-delay: 1s; }
.ad-ring-4 { animation-delay: 1.5s; }
.ad-ring-5 { animation-delay: 2s; }

@keyframes ringPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Attractor glow - breathing animation */
.ad-attractor-glow {
  opacity: 0.8;
  animation: attractorBreathe 4s ease-in-out infinite;
  transform-origin: center;
}

@keyframes attractorBreathe {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.9;
  }
}

/* Attractor center - stable core */
.ad-attractor-center {
  fill: rgba(56, 189, 248, 0.9);
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
}

/* Basin labels */
.ad-basin-title {
  font-size: 11px;
  font-weight: 600;
  fill: var(--ad-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.ad-attractor-label {
  font-size: 9px;
  font-weight: 500;
  fill: rgba(56, 189, 248, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-basin-edge-label {
  font-size: 9px;
  font-weight: 400;
  fill: var(--ad-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Stability zone indicator */
.ad-stability-zone {
  fill: none;
  stroke: rgba(74, 222, 128, 0.2);
  stroke-width: 2;
  stroke-dasharray: 6, 4;
  opacity: 0.5;
  animation: stabilityRotate 30s linear infinite;
  transform-origin: center;
}

@keyframes stabilityRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* State glow - outer halo around current position */
.ad-state-glow {
  fill: rgba(56, 189, 248, 0.3);
  opacity: 0.7;
  animation: stateGlowPulse 2s ease-in-out infinite;
}

@keyframes stateGlowPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

/* Current state dot - main indicator */
.ad-state-dot {
  transition: all var(--ad-transition-medium);
  cursor: pointer;
}

.ad-state-dot:hover {
  transform: scale(1.2);
}

.ad-state-dot.stable .ad-state-glow {
  fill: rgba(74, 222, 128, 0.4);
}

.ad-state-dot.transition .ad-state-glow {
  fill: rgba(250, 204, 21, 0.4);
}

.ad-state-dot.seeking .ad-state-glow {
  fill: rgba(168, 85, 247, 0.4);
}

/* Trajectory trail - path showing recent movement */
.ad-trajectory-trail {
  stroke: url(#trailGradient);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}

/* Position history dots */
.ad-position-history circle {
  fill: rgba(56, 189, 248, 0.5);
  transition: opacity 0.3s ease;
}

/* Energy particles */
.ad-energy-particles circle {
  fill: rgba(192, 132, 252, 0.6);
  animation: particleFloat 6s ease-in-out infinite;
}

@keyframes particleFloat {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 0.7; transform: translateY(-3px); }
}

/* Direction arrow - enhanced */
.ad-direction-arrow {
  stroke: rgba(56, 189, 248, 0.6);
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
  opacity: 0.8;
  stroke-dasharray: 6, 4;
  animation: arrowFlow 1.5s linear infinite;
}

@keyframes arrowFlow {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -10; }
}

/* State label */
.ad-state-label {
  font-size: 10px;
  fill: var(--ad-text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ad-basin:hover .ad-state-label {
  opacity: 1;
}

/* Coherence arc overlay */
.ad-coherence-arc {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 105%;
  height: 105%;
  pointer-events: none;
}

.ad-coherence-arc-svg {
  width: 100%;
  height: 100%;
}

.ad-coherence-arc-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 3;
}

.ad-coherence-arc-fill {
  fill: none;
  stroke: rgba(56, 189, 248, 0.4);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 974; /* 2 * PI * 155 */
  stroke-dashoffset: 974;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 1s ease-out, stroke 0.5s ease;
}

/* Direction text - minimal */
.ad-direction-label {
  text-align: center;
  max-width: 400px;
}

.ad-direction-title {
  font-size: var(--ad-font-size-caption);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ad-text-tertiary);
  margin-bottom: var(--ad-space-sm);
}

.ad-direction-message {
  font-size: var(--ad-font-size-lead);
  line-height: 1.6;
  color: var(--ad-text-secondary);
}

/* Reveal layers - tap to expand */
.ad-reveal {
  margin-top: var(--ad-space-md);
  text-align: center;
}

.ad-reveal-trigger {
  background: var(--ad-surface);
  border: 1px solid var(--ad-text-tertiary);
  border-radius: 100px;
  color: var(--ad-text-secondary);
  font-size: 12px;
  cursor: pointer;
  padding: 6px 16px;
  transition: color var(--ad-transition-fast), border-color var(--ad-transition-fast), background var(--ad-transition-fast);
}

.ad-reveal-trigger:hover {
  color: var(--ad-text-primary);
  border-color: var(--ad-accent);
  background: rgba(56, 189, 248, 0.05);
}

.ad-reveal-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--ad-transition-medium);
}

.ad-reveal-content.expanded {
  max-height: 200px;
}

.ad-reveal-details {
  padding-top: var(--ad-space-md);
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-whisper);
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. SYSTEM COHERENCE INDEX - Prominent indicator
   "Reflects how coordinated bioelectric signaling appears across systems"
   ───────────────────────────────────────────────────────────────────────────── */

.ad-coherence {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ad-space-xs);
  padding: var(--ad-space-md) var(--ad-space-lg);
  background: var(--ad-surface);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin: var(--ad-space-lg) auto;
  max-width: 320px;
  cursor: pointer;
  transition: opacity var(--ad-transition-slow), transform var(--ad-transition-base);
}

.ad-coherence:hover {
  transform: scale(1.02);
  opacity: 1;
}

.ad-coherence-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--ad-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.ad-coherence-content {
  display: flex;
  align-items: center;
  gap: var(--ad-space-sm);
}

/* Wave visualization - smooth vs jagged */
.ad-coherence-wave {
  width: 80px;
  height: 32px;
}

.ad-coherence-wave path {
  fill: none;
  stroke: var(--ad-accent);
  stroke-width: 2;
  stroke-linecap: round;
}

.ad-coherence-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ad-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-coherence-description {
  font-size: 10px;
  color: var(--ad-text-tertiary);
  text-align: center;
  max-width: 280px;
  margin-top: 4px;
  line-height: 1.4;
}

/* Hidden during observation mode */
.ad-observation-active .ad-coherence {
  opacity: 0;
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   3. ADAPTIVE RESPONSE LAB - Opt-in Space
   "Lab not coach"
   ───────────────────────────────────────────────────────────────────────────── */

.ad-lab {
  display: none;
  padding: var(--ad-space-lg);
  background: var(--ad-deep);
  border-radius: 16px;
  margin-top: var(--ad-space-lg);
}

.ad-lab.visible {
  display: block;
  animation: adFadeIn 0.5s ease-out;
}

@keyframes adFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ad-lab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ad-space-md);
}

.ad-lab-title {
  font-size: var(--ad-font-size-caption);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ad-text-tertiary);
}

.ad-lab-close {
  background: none;
  border: none;
  color: var(--ad-text-whisper);
  cursor: pointer;
  font-size: 18px;
  padding: var(--ad-space-xs);
}

/* Before / After comparison */
.ad-lab-comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--ad-space-md);
  align-items: stretch;
}

.ad-lab-state {
  padding: var(--ad-space-md);
  background: var(--ad-surface);
  border-radius: 12px;
  text-align: center;
}

.ad-lab-state-label {
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-whisper);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--ad-space-sm);
}

.ad-lab-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ad-text-whisper);
}

.ad-lab-divider-line {
  width: 1px;
  flex: 1;
  background: var(--ad-text-whisper);
  opacity: 0.2;
}

.ad-lab-divider-label {
  font-size: var(--ad-font-size-whisper);
  padding: var(--ad-space-xs) 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Uncertainty band */
.ad-lab-uncertainty {
  margin-top: var(--ad-space-md);
  padding: var(--ad-space-sm);
  background: var(--ad-muted);
  border-radius: 8px;
  text-align: center;
}

.ad-lab-uncertainty-text {
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-tertiary);
  font-style: italic;
}

/* Input selector */
.ad-lab-input-selector {
  margin-bottom: var(--ad-space-md);
}

.ad-lab-question {
  font-size: var(--ad-font-size-body);
  color: var(--ad-text-secondary);
  margin-bottom: var(--ad-space-sm);
}

.ad-lab-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ad-space-xs);
}

.ad-lab-input-pill {
  padding: var(--ad-space-xs) var(--ad-space-sm);
  background: var(--ad-surface);
  border: 1px solid var(--ad-text-whisper);
  border-radius: 100px;
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-secondary);
  cursor: pointer;
  transition: all var(--ad-transition-fast);
}

.ad-lab-input-pill:hover,
.ad-lab-input-pill.selected {
  background: var(--ad-accent-soft);
  border-color: var(--ad-accent);
  color: var(--ad-text-primary);
}

/* Results delayed notice */
.ad-lab-pending {
  text-align: center;
  padding: var(--ad-space-lg);
  color: var(--ad-text-tertiary);
}

.ad-lab-pending-icon {
  font-size: 32px;
  margin-bottom: var(--ad-space-sm);
  opacity: 0.5;
}

.ad-lab-pending-text {
  font-size: var(--ad-font-size-body);
}

.ad-lab-pending-note {
  font-size: var(--ad-font-size-caption);
  margin-top: var(--ad-space-xs);
  color: var(--ad-text-whisper);
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. TIMELINE - Trajectory Recontextualization
   "Hidden by default"
   ───────────────────────────────────────────────────────────────────────────── */

.ad-timeline {
  display: none;
  padding: var(--ad-space-lg);
}

.ad-timeline.visible {
  display: block;
}

.ad-timeline-header {
  margin-bottom: var(--ad-space-md);
}

.ad-timeline-title {
  font-size: var(--ad-font-size-caption);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ad-text-tertiary);
}

.ad-timeline-track {
  position: relative;
  padding-left: var(--ad-space-md);
  border-left: 1px solid var(--ad-text-whisper);
}

.ad-timeline-point {
  position: relative;
  padding: var(--ad-space-sm) 0;
  margin-left: var(--ad-space-sm);
}

.ad-timeline-point::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--ad-space-md) - var(--ad-space-sm) - 4px);
  top: calc(var(--ad-space-sm) + 6px);
  width: 8px;
  height: 8px;
  background: var(--ad-surface);
  border: 1px solid var(--ad-text-whisper);
  border-radius: 50%;
}

.ad-timeline-point.current::before {
  background: var(--ad-text-secondary);
  border-color: var(--ad-text-secondary);
}

.ad-timeline-date {
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-whisper);
  margin-bottom: 4px;
}

.ad-timeline-label {
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-tertiary);
}

/* Recontextualized points */
.ad-timeline-point.recontextualized .ad-timeline-label {
  text-decoration: line-through;
  opacity: 0.5;
}

.ad-timeline-recontextualized-label {
  display: block;
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-secondary);
  margin-top: 4px;
  font-style: italic;
}

.ad-timeline-recontextualized-reason {
  display: block;
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-whisper);
  margin-top: 4px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. OBSERVATION MODE - Silence State
   "Everywhere—and nowhere"
   ───────────────────────────────────────────────────────────────────────────── */

.ad-observation-mode {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--ad-void);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ad-transition-slow);
}

.ad-observation-mode.active {
  opacity: 1;
  pointer-events: auto;
}

.ad-observation-content {
  text-align: center;
  max-width: 320px;
  padding: var(--ad-space-lg);
}

.ad-observation-title {
  font-size: var(--ad-font-size-caption);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ad-text-whisper);
  margin-bottom: var(--ad-space-md);
}

.ad-observation-message {
  font-size: var(--ad-font-size-lead);
  line-height: 1.7;
  color: var(--ad-text-tertiary);
}

.ad-observation-dismiss {
  margin-top: var(--ad-space-xl);
  background: none;
  border: 1px solid var(--ad-text-whisper);
  color: var(--ad-text-whisper);
  font-size: var(--ad-font-size-caption);
  padding: var(--ad-space-xs) var(--ad-space-md);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--ad-transition-fast);
  opacity: 0.5;
}

.ad-observation-dismiss:hover {
  opacity: 1;
  border-color: var(--ad-text-tertiary);
  color: var(--ad-text-tertiary);
}

/* Soften everything during observation mode */
.ad-container.observation-active {
  filter: brightness(0.7) contrast(0.95);
  transition: filter var(--ad-transition-slow);
}

/* ─────────────────────────────────────────────────────────────────────────────
   CLINICIAN TOGGLE - Numeric Layer
   ───────────────────────────────────────────────────────────────────────────── */

.ad-clinician-toggle {
  display: flex;
  align-items: center;
  gap: var(--ad-space-xs);
  padding: 6px 12px;
  background: var(--ad-surface);
  border: 1px solid var(--ad-text-tertiary);
  border-radius: 100px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity var(--ad-transition-fast), border-color var(--ad-transition-fast);
}

.ad-clinician-toggle:hover {
  opacity: 1;
  border-color: var(--ad-accent);
}

.ad-clinician-toggle.active {
  opacity: 1;
  border-color: var(--ad-accent);
  background: rgba(56, 189, 248, 0.1);
}

.ad-clinician-toggle-label {
  font-size: 11px;
  color: var(--ad-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-clinician-toggle-indicator {
  width: 8px;
  height: 8px;
  background: var(--ad-text-whisper);
  border-radius: 50%;
  transition: background var(--ad-transition-fast);
}

.ad-clinician-toggle.active .ad-clinician-toggle-indicator {
  background: var(--ad-accent);
}

/* Clinician-only data */
.ad-clinician-data {
  display: none;
  margin-top: var(--ad-space-sm);
  padding: var(--ad-space-sm);
  background: var(--ad-muted);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-whisper);
}

.ad-clinician-mode .ad-clinician-data {
  display: block;
}

.ad-clinician-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.ad-clinician-row:last-child {
  border-bottom: none;
}

.ad-clinician-label {
  color: var(--ad-text-whisper);
}

.ad-clinician-value {
  color: var(--ad-text-tertiary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   NAVIGATION - Minimal
   ───────────────────────────────────────────────────────────────────────────── */

.ad-nav {
  position: fixed;
  bottom: var(--ad-space-lg);
  right: var(--ad-space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--ad-space-xs);
  opacity: 0.3;
  transition: opacity var(--ad-transition-fast);
}

.ad-nav:hover {
  opacity: 0.8;
}

.ad-nav-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ad-surface);
  border: 1px solid var(--ad-text-whisper);
  border-radius: 8px;
  color: var(--ad-text-tertiary);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--ad-transition-fast);
}

.ad-nav-item:hover,
.ad-nav-item.active {
  background: var(--ad-elevated);
  border-color: var(--ad-accent);
  color: var(--ad-text-primary);
}

.ad-nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 8px);
  white-space: nowrap;
  padding: 4px 8px;
  background: var(--ad-elevated);
  border-radius: 4px;
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-secondary);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ad-transition-fast);
}

.ad-nav-item:hover[data-tooltip]::after {
  opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   LOADING & EMPTY STATES
   ───────────────────────────────────────────────────────────────────────────── */

.ad-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  color: var(--ad-text-whisper);
}

.ad-loading-pulse {
  width: 40px;
  height: 40px;
  border: 2px solid var(--ad-text-whisper);
  border-radius: 50%;
  animation: adPulse 2s ease-in-out infinite;
}

@keyframes adPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.ad-loading-text {
  margin-top: var(--ad-space-md);
  font-size: var(--ad-font-size-caption);
  letter-spacing: 0.05em;
}

.ad-empty {
  text-align: center;
  padding: var(--ad-space-xl);
  color: var(--ad-text-whisper);
}

.ad-empty-message {
  font-size: var(--ad-font-size-body);
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .ad-container {
    padding: var(--ad-space-md);
  }

  .ad-basin {
    max-width: 280px;
  }

  .ad-direction-message {
    font-size: var(--ad-font-size-body);
  }

  .ad-coherence {
    max-width: calc(100vw - 2 * var(--ad-space-md));
    margin: var(--ad-space-md) auto;
  }

  .ad-coherence-description {
    display: none;
  }

  .ad-nav {
    right: var(--ad-space-md);
    bottom: calc(var(--ad-space-lg) + 60px);
  }

  .ad-lab-comparison {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .ad-lab-divider {
    flex-direction: row;
  }

  .ad-lab-divider-line {
    width: auto;
    flex: 1;
    height: 1px;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   ANIMATION UTILITIES
   ───────────────────────────────────────────────────────────────────────────── */

.ad-fade-in {
  animation: adFadeIn 0.8s ease-out;
}

.ad-fade-out {
  animation: adFadeOut 0.5s ease-out forwards;
}

@keyframes adFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Breathing animation for stable state */
.ad-breathe {
  animation: adBreathe 4s ease-in-out infinite;
}

@keyframes adBreathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.8; }
}

/* Drift animation for direction arrow */
.ad-drift {
  animation: adDrift 3s ease-in-out infinite;
}

@keyframes adDrift {
  0%, 100% { stroke-dashoffset: 0; }
  50% { stroke-dashoffset: 8; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   ACTION BUTTONS
   ───────────────────────────────────────────────────────────────────────────── */

.ad-actions {
  display: flex;
  gap: var(--ad-space-sm);
  margin-top: var(--ad-space-lg);
  justify-content: center;
}

.ad-action-btn {
  padding: var(--ad-space-xs) var(--ad-space-md);
  border-radius: 100px;
  font-size: var(--ad-font-size-caption);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ad-transition-fast);
  border: 1px solid transparent;
}

.ad-action-secondary {
  background: var(--ad-surface);
  border-color: var(--ad-text-whisper);
  color: var(--ad-text-tertiary);
}

.ad-action-secondary:hover {
  border-color: var(--ad-accent);
  color: var(--ad-text-secondary);
  background: var(--ad-elevated);
}

/* ─────────────────────────────────────────────────────────────────────────────
   CLINICIAN DATA GRID
   ───────────────────────────────────────────────────────────────────────────── */

.ad-clinician-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--ad-space-sm);
}

.ad-clinician-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ad-clinician-metric-label {
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-whisper);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-clinician-metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-tertiary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   TIMELINE FOOTER & LEGEND
   ───────────────────────────────────────────────────────────────────────────── */

.ad-timeline-footer {
  margin-top: var(--ad-space-md);
  padding-top: var(--ad-space-sm);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.ad-timeline-legend {
  display: flex;
  gap: var(--ad-space-md);
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-whisper);
}

.ad-timeline-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ad-timeline-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ad-text-whisper);
}

.ad-timeline-legend-recontextualized .ad-timeline-legend-dot {
  background: var(--ad-accent);
}

/* ─────────────────────────────────────────────────────────────────────────────
   LAB MINI BASIN
   ───────────────────────────────────────────────────────────────────────────── */

.ad-lab-mini-basin {
  width: 80px;
  height: 80px;
  margin: var(--ad-space-sm) auto;
}

.ad-lab-state-message {
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-tertiary);
  margin-top: var(--ad-space-xs);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SELF-INFLUENCE DAMPENING
   When observer effect is detected, reduce precision to discourage chasing
   ═══════════════════════════════════════════════════════════════════════════════ */

.ad-container.self-influence-detected .ad-state-dot {
  filter: blur(2px);
  transition: filter var(--ad-transition-slow);
}

.ad-container.self-influence-detected .ad-coherence-wave path {
  opacity: 0.4;
}

.ad-container.self-influence-detected .ad-direction-arrow {
  opacity: 0.2;
}

.ad-container.self-influence-detected .ad-clinician-metric-value {
  /* Replace exact values with ranges */
  letter-spacing: 0.1em;
  opacity: 0.6;
}

.ad-self-influence-notice {
  display: none;
  text-align: center;
  padding: var(--ad-space-sm);
  margin-top: var(--ad-space-md);
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-whisper);
  font-style: italic;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.ad-container.self-influence-detected .ad-self-influence-notice {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CHAOS / GRIEF MODE
   When system detects vulnerable period, reduce to pure presence
   ═══════════════════════════════════════════════════════════════════════════════ */

.ad-container.chaos-mode .ad-basin {
  opacity: 0.15;
  filter: blur(4px);
  transition: all var(--ad-transition-slow);
}

.ad-container.chaos-mode .ad-direction-arrow {
  display: none;
}

.ad-container.chaos-mode .ad-coherence {
  opacity: 0;
  pointer-events: none;
}

.ad-container.chaos-mode .ad-actions {
  opacity: 0.3;
}

.ad-container.chaos-mode .ad-clinician-data {
  display: none !important;
}

.ad-container.chaos-mode .ad-direction-title {
  color: var(--ad-text-whisper);
}

.ad-chaos-presence {
  display: none;
  text-align: center;
  padding: var(--ad-space-lg);
  max-width: 320px;
  margin: 0 auto;
}

.ad-container.chaos-mode .ad-chaos-presence {
  display: block;
}

.ad-chaos-presence-message {
  font-size: var(--ad-font-size-lead);
  line-height: 1.8;
  color: var(--ad-text-tertiary);
}

.ad-chaos-presence-note {
  margin-top: var(--ad-space-md);
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-whisper);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   GRADUATION SIGNALS
   Rare, gentle messages that build trust
   ═══════════════════════════════════════════════════════════════════════════════ */

.ad-graduation-signal {
  display: none;
  text-align: center;
  padding: var(--ad-space-md);
  margin-top: var(--ad-space-lg);
  background: var(--ad-accent-soft);
  border-radius: 12px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.ad-graduation-signal.visible {
  display: block;
  animation: adFadeIn 1s ease-out;
}

.ad-graduation-message {
  font-size: var(--ad-font-size-body);
  color: var(--ad-text-secondary);
  line-height: 1.6;
}

.ad-graduation-dismiss {
  margin-top: var(--ad-space-sm);
  background: none;
  border: none;
  color: var(--ad-text-whisper);
  font-size: var(--ad-font-size-whisper);
  cursor: pointer;
  padding: var(--ad-space-xs);
}

.ad-graduation-dismiss:hover {
  color: var(--ad-text-tertiary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   EPISTEMIC FEEDBACK
   Simple, non-interrogative accuracy check
   ═══════════════════════════════════════════════════════════════════════════════ */

.ad-feedback {
  display: none;
  margin-top: var(--ad-space-lg);
  text-align: center;
}

.ad-feedback.visible {
  display: block;
}

.ad-feedback-prompt {
  font-size: var(--ad-font-size-caption);
  color: var(--ad-text-whisper);
  margin-bottom: var(--ad-space-sm);
}

.ad-feedback-options {
  display: flex;
  justify-content: center;
  gap: var(--ad-space-xs);
}

.ad-feedback-btn {
  padding: var(--ad-space-xs) var(--ad-space-sm);
  background: var(--ad-surface);
  border: 1px solid var(--ad-text-whisper);
  border-radius: 100px;
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-tertiary);
  cursor: pointer;
  transition: all var(--ad-transition-fast);
}

.ad-feedback-btn:hover {
  border-color: var(--ad-accent);
  color: var(--ad-text-secondary);
}

.ad-feedback-btn.selected {
  background: var(--ad-accent-soft);
  border-color: var(--ad-accent);
}

.ad-feedback-thanks {
  display: none;
  font-size: var(--ad-font-size-whisper);
  color: var(--ad-text-whisper);
  margin-top: var(--ad-space-sm);
}

.ad-feedback.submitted .ad-feedback-options {
  display: none;
}

.ad-feedback.submitted .ad-feedback-thanks {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   Respect user preferences, reduce cognitive load
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Reduced motion - disable all animations */
@media (prefers-reduced-motion: reduce) {
  .ad-state-dot,
  .ad-direction-arrow,
  .ad-coherence-wave path,
  .ad-basin-gradient,
  .ad-reveal-content,
  .ad-observation-mode,
  .ad-lab,
  .ad-graduation-signal {
    animation: none !important;
    transition: none !important;
  }

  .ad-drift {
    animation: none !important;
  }

  .ad-breathe {
    animation: none !important;
  }

  .ad-loading-pulse {
    animation: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --ad-text-primary: #ffffff;
    --ad-text-secondary: var(--gray-200);
    --ad-text-tertiary: #b0b0b0;
    --ad-text-whisper: #808080;
    --ad-accent: #88aacc;
  }

  .ad-basin-edge {
    stroke-width: 2;
    opacity: 0.6;
  }

  .ad-state-dot {
    stroke: #ffffff;
    stroke-width: 1;
  }
}

/* Color-blind friendly states */
.ad-state-dot.stable {
  /* Green replaced with pattern + shape hint */
  fill: var(--ad-stable);
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 2;
}

.ad-state-dot.transition {
  /* Yellow/amber with dashed stroke */
  fill: var(--ad-transition);
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 1;
  stroke-dasharray: 2, 2;
}

.ad-state-dot.seeking {
  /* Neutral with different shape indicator via filter */
  fill: var(--ad-seeking);
  filter: drop-shadow(0 0 4px rgba(90, 90, 106, 0.6));
}

/* Low-light / tired user mode - increase contrast, simplify */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .ad-direction-message {
    font-size: var(--ad-font-size-title);
    line-height: 1.8;
  }

  .ad-reveal-trigger {
    font-size: var(--ad-font-size-body);
    padding: var(--ad-space-sm);
  }
}

/* Focus indicators for keyboard navigation */
.ad-action-btn:focus-visible,
.ad-reveal-trigger:focus-visible,
.ad-feedback-btn:focus-visible,
.ad-lab-input-pill:focus-visible,
.ad-clinician-toggle:focus-visible {
  outline: 2px solid var(--ad-accent);
  outline-offset: 2px;
}

/* Skip to content (screen readers) */
.ad-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--ad-surface);
  color: var(--ad-text-primary);
  padding: var(--ad-space-sm);
  z-index: 100;
  transition: top 0.3s;
}

.ad-skip-link:focus {
  top: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   EXPLANATORY MODALS
   Clickable info popups to explain concepts
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Info icon on clickable elements */
.ad-info-trigger {
  position: relative;
  cursor: pointer;
}

.ad-info-trigger::after {
  content: 'ⓘ';
  position: absolute;
  top: -4px;
  right: -16px;
  font-size: 12px;
  color: var(--ad-accent);
  opacity: 0.5;
  transition: opacity var(--ad-transition-base);
}

.ad-info-trigger:hover::after {
  opacity: 1;
}

/* Modal overlay */
.ad-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ad-space-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ad-transition-base), visibility var(--ad-transition-base);
}

.ad-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modal content */
.ad-modal {
  background: var(--ad-deep);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform var(--ad-transition-base);
}

.ad-modal-overlay.active .ad-modal {
  transform: translateY(0);
}

.ad-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ad-space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ad-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--ad-text-primary);
}

.ad-modal-close {
  background: none;
  border: none;
  color: var(--ad-text-tertiary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--ad-transition-base);
}

.ad-modal-close:hover {
  color: var(--ad-text-primary);
}

.ad-modal-body {
  padding: var(--ad-space-lg);
}

.ad-modal-body p {
  margin: 0 0 var(--ad-space-md) 0;
  color: var(--ad-text-secondary);
  line-height: 1.6;
}

.ad-modal-body p:last-child {
  margin-bottom: 0;
}

.ad-modal-body h4 {
  color: var(--ad-text-primary);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 var(--ad-space-sm) 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-modal-body ul {
  margin: 0 0 var(--ad-space-md) 0;
  padding-left: var(--ad-space-lg);
  color: var(--ad-text-secondary);
}

.ad-modal-body li {
  margin-bottom: var(--ad-space-xs);
  line-height: 1.5;
}

/* Scientific reference styling */
.ad-modal-reference {
  margin-top: var(--ad-space-lg);
  padding-top: var(--ad-space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: var(--ad-text-tertiary);
  font-style: italic;
}

/* Clickable areas - add subtle highlight */
.ad-basin-wrapper.ad-info-trigger::after,
.ad-coherence.ad-info-trigger::after,
.ad-clinician.ad-info-trigger::after {
  top: 8px;
  right: 8px;
}

.ad-direction.ad-info-trigger::after {
  top: 0;
  right: 0;
}
