/* ==========================================================================
   Reverbence — Design System
   Session 15 (visual-design-system.md) → Session 16 (key-screen-designs.md)
   ========================================================================== */

/* --- Design Tokens --- */
:root {
  /* Core Palette */
  --color-bg-primary: #F8F4EE;
  --color-bg-secondary: #F0EBE3;
  --color-bg-tertiary: #E8E2D8;
  --color-text-primary: #2A2623;
  --color-text-secondary: #6B6560;
  --color-text-tertiary: #8D8070;
  --color-accent-primary: #C4873A;
  --color-accent-primary-hover: #A8722F;
  --color-accent-primary-light: #F5E6D0;
  --color-accent-secondary: #1B5E5A;
  --color-accent-secondary-hover: #154A47;
  --color-accent-secondary-light: #D4EDEB;

  /* Supporting Palette */
  --color-coral: #D26B4E;
  --color-coral-light: #F7DDD4;
  --color-sage: #7A9680;
  --color-sage-light: #DDE8DF;
  --color-indigo: #2D3A6E;
  --color-indigo-light: #D6DAE8;

  /* Semantic Colors */
  --color-success: #7A9680;
  --color-warning: #C4873A;
  --color-error: #B85450;
  --color-error-light: #F5E0DF;
  --color-info: #1B5E5A;
  --color-border: #E8E2D8;
  --color-border-focus: #C4873A;
  --color-divider: #DDD7CF;
  --color-overlay: rgba(42, 38, 35, 0.5);

  /* Typography */
  --font-display: 'Satoshi', system-ui, -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-accent: 'Source Serif 4', Georgia, serif;
  --font-data: 'JetBrains Mono', ui-monospace, monospace;

  /* Type Scale */
  --text-display: 2.5rem;
  --text-h1: 2rem;
  --text-h2: 1.5625rem;
  --text-h3: 1.25rem;
  --text-h4: 1.125rem;
  --text-body: 1rem;
  --text-body-sm: 0.875rem;
  --text-caption: 0.8125rem;
  --text-overline: 0.75rem;
  --text-data: 1.25rem;
  --text-data-sm: 1rem;

  /* Spacing (8px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-none: none;
  --shadow-sm: 0 1px 3px rgba(42, 38, 35, 0.06);
  --shadow-md: 0 4px 12px rgba(42, 38, 35, 0.08);
  --shadow-lg: 0 8px 24px rgba(42, 38, 35, 0.12);
  --shadow-card: 0 2px 8px rgba(42, 38, 35, 0.05);
  --shadow-card-hover: 0 6px 20px rgba(42, 38, 35, 0.1);

  /* Active palette accent — overridden by time-of-day */
  --palette-accent: var(--color-accent-primary);
  --palette-bg-glow: none;
}

/* --- Time-of-Day Palettes --- */
[data-palette="dawn"] {
  --palette-accent: var(--color-accent-primary);
  --palette-bg-glow: linear-gradient(135deg, #F5E6D0 0%, var(--color-bg-primary) 40%);
}

[data-palette="day"] {
  --palette-accent: var(--color-accent-primary);
  --palette-bg-glow: none;
}

[data-palette="dusk"] {
  --color-bg-primary: #F5F1EB;
  --color-bg-secondary: #EDEAE4;
  --palette-accent: var(--color-accent-secondary);
  --palette-bg-glow: linear-gradient(135deg, #D4EDEB 0%, #F5F1EB 40%);
}

/* Context overrides */
[data-context="coach"] {
  --palette-accent: var(--color-indigo);
}

[data-context="evening"] {
  --color-bg-primary: #F5F1EB;
  --color-bg-secondary: #EDEAE4;
  --palette-accent: var(--color-accent-secondary);
  --palette-bg-glow: linear-gradient(180deg, rgba(212, 237, 235, 0.02) 0%, #F5F1EB 100%);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--color-accent-secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, button, select { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 500; line-height: 1.3; }

/* --- Typography Utilities --- */
.text-display { font-family: var(--font-display); font-size: var(--text-display); font-weight: 500; line-height: 1.2; letter-spacing: -0.02em; }
.text-h1 { font-family: var(--font-display); font-size: var(--text-h1); font-weight: 500; line-height: 1.25; letter-spacing: -0.015em; }
.text-h2 { font-family: var(--font-display); font-size: var(--text-h2); font-weight: 500; line-height: 1.3; letter-spacing: -0.01em; }
.text-h3 { font-family: var(--font-display); font-size: var(--text-h3); font-weight: 500; line-height: 1.35; letter-spacing: -0.005em; }
.text-h4 { font-family: var(--font-display); font-size: var(--text-h4); font-weight: 600; line-height: 1.4; }
.text-body { font-size: var(--text-body); line-height: 1.6; }
.text-body-sm { font-size: var(--text-body-sm); line-height: 1.5; letter-spacing: 0.005em; }
.text-caption { font-size: var(--text-caption); line-height: 1.45; letter-spacing: 0.01em; }
.text-overline { font-family: var(--font-body); font-size: var(--text-overline); font-weight: 600; line-height: 1.4; letter-spacing: 0.08em; text-transform: uppercase; }
.text-data { font-family: var(--font-data); font-size: var(--text-data); font-weight: 500; line-height: 1.0; }
.text-data-sm { font-family: var(--font-data); font-size: var(--text-data-sm); font-weight: 500; line-height: 1.0; letter-spacing: 0.02em; }
.text-accent { font-family: var(--font-accent); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-body);
  font-weight: 600;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 200ms ease, transform 150ms ease, box-shadow 200ms ease;
  min-height: 48px;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--color-border-focus); outline-offset: 2px; }

.btn-primary {
  background: var(--color-accent-primary);
  color: #FFFFFF;
}
.btn-primary:hover:not(:disabled) { background: var(--color-accent-primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active:not(:disabled) { box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--color-accent-secondary);
  color: #FFFFFF;
}
.btn-secondary:hover:not(:disabled) { background: var(--color-accent-secondary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-weight: 500;
}
.btn-ghost:hover:not(:disabled) { background: var(--color-bg-secondary); border-color: var(--color-text-tertiary); }
.btn-ghost:active:not(:disabled) { background: var(--color-bg-tertiary); }

.btn-text {
  background: none;
  border: none;
  color: var(--color-accent-primary);
  font-family: var(--font-body);
  font-weight: 500;
  padding: 8px 0;
  min-height: auto;
}
.btn-text:hover { text-decoration: underline; }

.btn-sm { padding: 10px 16px; font-size: var(--text-body-sm); min-height: 44px; }
.btn-lg { padding: 16px 36px; font-size: var(--text-h4); min-height: 56px; }
.btn-full { width: 100%; }

/* --- Cards --- */
.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms ease, transform 150ms ease;
}
.card-interactive:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card-featured {
  background: var(--color-bg-primary);
  border: 2px solid var(--color-accent-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.card-coach {
  background: rgba(214, 218, 232, 0.4);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

/* --- Form Inputs --- */
.input {
  width: 100%;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.input::placeholder { color: var(--color-text-tertiary); }
.input:focus { outline: none; border-color: var(--color-border-focus); box-shadow: 0 0 0 3px rgba(196, 135, 58, 0.12); }
.input-error { border-color: var(--color-error); box-shadow: 0 0 0 3px rgba(184, 84, 80, 0.12); }

.textarea {
  width: 100%;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  min-height: 80px;
  max-height: 200px;
  resize: vertical;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.textarea::placeholder { color: var(--color-text-tertiary); font-style: italic; }
.textarea:focus { outline: none; border-color: var(--color-border-focus); box-shadow: 0 0 0 3px rgba(196, 135, 58, 0.12); }

/* Checkbox */
.checkbox-wrap { display: flex; align-items: flex-start; gap: var(--space-3); cursor: pointer; }
.checkbox-wrap input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  margin-top: 2px;
}
.checkbox-wrap input[type="checkbox"]:checked { background: var(--color-accent-primary); border-color: var(--color-accent-primary); }
.checkbox-wrap input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* Radio */
.radio-group { display: flex; flex-direction: column; gap: var(--space-3); }
.radio-wrap { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.radio-wrap input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
}
.radio-wrap input[type="radio"]:checked { border-color: var(--color-accent-primary); }
.radio-wrap input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent-primary);
}

/* --- Navigation --- */
.nav-top {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: rgba(248, 244, 238, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 200ms ease;
  border-bottom: 1px solid transparent;
}
.nav-top.scrolled { border-bottom-color: var(--color-divider); }
.nav-wordmark { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--color-text-primary); text-decoration: none; }
.nav-top-actions { display: flex; align-items: center; gap: var(--space-4); }
.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.nav-icon-btn:hover { background: var(--color-bg-secondary); }
.nav-icon-btn svg { width: 20px; height: 20px; }

.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(248, 244, 238, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  position: relative;
  min-width: 64px;
  min-height: 48px;
}
.nav-tab svg { width: 24px; height: 24px; stroke-width: 1.5; }
.nav-tab span { font-size: 12px; font-weight: 500; }
.nav-tab.active { color: var(--color-accent-primary); }
.nav-tab.active::after {
  content: '';
  position: absolute;
  top: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-accent-primary);
}

/* --- Badges & Labels --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}
.badge-coming { background: var(--color-bg-tertiary); color: var(--color-text-secondary); }
.badge-day { background: var(--color-accent-primary-light); color: var(--color-accent-primary); font-family: var(--font-data); font-size: 13px; }

/* Step Indicators */
.step-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-bg-tertiary);
}
.step-dot.completed { background: var(--color-accent-primary); }
.step-dot.current { width: 8px; height: 8px; background: var(--color-bg-primary); box-shadow: 0 0 0 2px var(--color-accent-primary); }
.step-line { width: 24px; height: 1px; background: var(--color-border); }

/* Practice completion */
.completion-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}
.completion-dot.done { background: var(--color-sage); color: #fff; }
.completion-dot.empty { border: 1.5px solid var(--color-border); }

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--color-accent-primary); border-radius: var(--radius-full); transition: width 300ms ease; }

/* --- Modal & Overlay --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--color-bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-8) var(--space-6) var(--space-6);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 250ms ease-out;
  position: relative;
}
.modal-overlay.open .modal-content { transform: translateY(0); }
.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: 20px;
}

/* Crisis overlay */
.crisis-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--color-bg-primary);
  padding: var(--space-8) var(--space-4);
  overflow-y: auto;
  display: none;
}
.crisis-overlay.open { display: block; }

/* --- Chat Bubbles --- */
.chat-bubble {
  max-width: 85%;
  padding: var(--space-4);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  margin-bottom: var(--space-3);
}
.chat-bubble-mir {
  background: rgba(245, 230, 208, 0.5);
  align-self: flex-start;
}
.chat-bubble-user {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md);
  align-self: flex-end;
  margin-left: auto;
}
.chat-bubble-coach {
  background: rgba(214, 218, 232, 0.4);
  align-self: flex-start;
}
.chat-label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.chat-label-mir { color: var(--color-accent-primary); }
.chat-label-coach { color: var(--color-indigo); }
.chat-area { display: flex; flex-direction: column; gap: var(--space-3); }
.chat-input-area {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  margin-top: var(--space-4);
}
.chat-input-area .textarea { flex: 1; min-height: 44px; }
.chat-input-area .btn { flex-shrink: 0; }

/* --- Energy Tap --- */
.energy-tap-group { margin-bottom: var(--space-8); }
.energy-tap-label { font-family: var(--font-display); font-size: 16px; font-weight: 500; margin-bottom: var(--space-1); }
.energy-tap-sublabel { font-size: var(--text-body-sm); color: var(--color-text-secondary); margin-bottom: var(--space-3); }
.energy-tap-row {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.energy-tap-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-data);
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all 200ms ease;
}
.energy-tap-circle:hover { border-color: var(--color-text-tertiary); background: var(--color-bg-secondary); }
.energy-tap-circle.selected { border-color: var(--color-accent-primary); background: var(--color-accent-primary-light); color: var(--color-accent-primary); }
.energy-tap-circle.selected-cool { border-color: var(--color-accent-secondary); background: var(--color-accent-secondary-light); color: var(--color-accent-secondary); }
.energy-tap-anchors {
  display: flex;
  justify-content: space-between;
  padding: 0 8px;
  margin-top: var(--space-1);
  font-size: 12px;
  color: var(--color-text-tertiary);
}

/* Energy delta display */
.energy-delta {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.energy-delta-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.energy-delta-row:last-child { margin-bottom: 0; }
.energy-delta-dots { display: flex; gap: 3px; }
.energy-delta-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.energy-delta-dot.filled { background: var(--color-accent-primary); }
.energy-delta-dot.filled-cool { background: var(--color-accent-secondary); }
.energy-delta-dot.empty { background: var(--color-bg-tertiary); }

/* --- Module Tiles --- */
.module-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); padding: 0 var(--space-4); }
.module-tile {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: box-shadow 200ms ease, transform 150ms ease;
}
.module-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.module-tile.locked { opacity: 0.6; border-style: dashed; cursor: default; }
.module-tile.locked:hover { box-shadow: none; transform: none; }
.module-tile.done { border-color: var(--color-sage); }
.module-tile-icon { font-size: 24px; margin-bottom: var(--space-2); line-height: 1; }
.module-tile-title { font-family: var(--font-display); font-size: 15px; font-weight: 500; }
.module-tile-status { font-size: 13px; color: var(--color-text-secondary); margin-top: var(--space-1); }

/* --- Pull Quote --- */
.pull-quote {
  border-left: 3px solid var(--color-accent-primary);
  padding-left: var(--space-5);
  margin: var(--space-8) 0;
  font-family: var(--font-accent);
  font-size: 20px;
  font-weight: 400;
  font-style: italic;
  color: var(--color-text-primary);
  line-height: 1.5;
}

/* --- Section Label (Overline) --- */
.section-label {
  font-family: var(--font-body);
  font-size: var(--text-overline);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-4);
}

/* --- Toggle Switch --- */
.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-bg-tertiary);
  border-radius: 9px;
  cursor: pointer;
  transition: background 200ms ease;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-bg-primary);
  transition: transform 200ms ease;
}
.toggle input:checked + .toggle-track { background: var(--color-accent-primary); }
.toggle input:checked + .toggle-track::after { transform: translateX(14px); }

/* --- Reading Progress Bar --- */
.reading-progress {
  position: fixed;
  top: 56px;
  left: 0;
  height: 3px;
  background: var(--color-accent-primary);
  z-index: 99;
  transition: width 50ms linear;
}

/* --- Settings --- */
.settings-section { margin-bottom: var(--space-6); }
.settings-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  padding: var(--space-6) var(--space-4) var(--space-3);
}
.settings-group {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 0 var(--space-4);
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.settings-item:last-child { border-bottom: none; }
.settings-item-label { font-size: 15px; }
.settings-item-value { font-size: var(--text-body-sm); color: var(--color-text-secondary); }

/* --- Layout Helpers --- */
.container-spacious { max-width: 680px; margin: 0 auto; padding: 0 var(--space-4); }
.container-comfortable { max-width: 480px; margin: 0 auto; padding: 0 var(--space-4); }
.container-wide { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-4); }
.text-center { text-align: center; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-10 { margin-top: var(--space-10); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* --- Divider --- */
.divider { height: 1px; background: var(--color-divider); margin: var(--space-4) 0; }
.divider-diamond {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
.divider-diamond::before, .divider-diamond::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-divider);
}
.divider-diamond span { color: var(--color-text-tertiary); font-size: 10px; }

/* --- Loading Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-bg-tertiary);
  border-top-color: var(--color-accent-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(3, end) infinite;
}
@keyframes dots {
  0% { content: ''; }
  33% { content: '.'; }
  66% { content: '..'; }
  100% { content: '...'; }
}

/* --- Animations --- */
.fade-in { animation: fadeIn 200ms ease forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.slide-up { animation: slideUp 250ms ease-out forwards; }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* --- Landing Page Specific --- */
.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  max-width: 1200px;
  margin: 0 auto;
  background: rgba(248, 244, 238, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
.landing-nav.scrolled { border-bottom-color: var(--color-divider); }

.landing-hero {
  padding-top: 120px;
  padding-bottom: var(--space-24);
  max-width: 680px;
  margin: 0 auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.landing-section {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-24) var(--space-4) var(--space-16);
}

.landing-cards-section {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-24) var(--space-4) var(--space-16);
}

.tier-cards { display: flex; flex-direction: column; gap: var(--space-6); }

.landing-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-4);
  border-top: 1px solid var(--color-divider);
}
.landing-footer-links { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.landing-footer-links a { color: var(--color-text-secondary); font-size: var(--text-body-sm); }
.landing-footer-links a:hover { color: var(--color-text-primary); text-decoration: none; }

/* --- Chapter Page --- */
.chapter-header { padding-top: 80px; max-width: 680px; margin: 0 auto; padding-left: var(--space-4); padding-right: var(--space-4); }
.chapter-hero-visual {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-10);
  overflow: hidden;
}
.chapter-body { max-width: 680px; margin: 0 auto; padding: 0 var(--space-4); }
.chapter-body p { margin-bottom: var(--space-5); font-size: 17px; line-height: 1.7; }
.chapter-body h2 { font-family: var(--font-display); font-weight: 500; font-size: 24px; margin-top: var(--space-12); margin-bottom: var(--space-4); }
.chapter-body h3 { font-size: 18px; margin-top: var(--space-8); margin-bottom: var(--space-3); }
.chapter-nav { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-8); padding: var(--space-4) 0; }
.chapter-cta-area { margin-top: var(--space-16); padding: var(--space-10) 0; border-top: 1px solid var(--color-divider); }
.pause-notice {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin: var(--space-8) 0;
}
.pause-notice p { font-style: italic; color: var(--color-text-secondary); font-size: 15px; line-height: 1.6; margin-bottom: 0; }
.pause-notice p + p { margin-top: var(--space-2); }
.pause-notice .icon { color: var(--color-accent-secondary); margin-right: var(--space-2); }

/* Drift Cycle stages */
.drift-stages {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-8);
  padding-left: var(--space-4);
  border-left: 2px solid var(--color-accent-primary);
}
.drift-stage {
  font-size: 16px;
  line-height: 1.6;
  padding: var(--space-2) 0;
}
.drift-stage strong {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--color-accent-primary);
}

/* Workshop pitch (end of Chapter 3) */
.workshop-pitch {
  margin-top: var(--space-12);
  padding: var(--space-8) var(--space-6);
  background: linear-gradient(135deg, rgba(43, 58, 110, 0.04), rgba(27, 94, 90, 0.04));
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
}
.workshop-pitch p { font-size: 16px; line-height: 1.7; margin-bottom: var(--space-4); }
.workshop-pitch p:last-child { margin-bottom: 0; }

/* --- App Auth Screen --- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
}
.auth-screen .btn {
  gap: var(--space-3);
}
.google-icon { width: 20px; height: 20px; }

/* --- App Content Area --- */
.app-body {
  padding-top: 56px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + var(--space-4));
  min-height: 100vh;
}

/* --- Dashboard --- */
.dashboard-greeting { padding: var(--space-6) var(--space-4) var(--space-4); }
.dashboard-greeting h2 { font-size: 24px; }
.dashboard-greeting .date { font-size: var(--text-body-sm); color: var(--color-text-secondary); margin-top: var(--space-1); }

.coach-review-banner {
  background: rgba(214, 218, 232, 0.4);
  border-left: 3px solid var(--color-indigo);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: var(--space-3) var(--space-4) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.coach-review-banner p { font-size: 15px; font-weight: 500; color: var(--color-indigo); }

/* --- Morning Review Card --- */
.mrc-card {
  margin: var(--space-4) var(--space-4) var(--space-2);
  padding: var(--space-5) var(--space-5) var(--space-4);
  background: linear-gradient(135deg, var(--color-accent-primary-light) 0%, var(--color-bg-secondary) 100%);
  border: 1px solid rgba(196, 135, 58, 0.2);
  border-radius: var(--radius-lg);
}
.mrc-label {
  font-family: var(--font-data);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-primary);
  margin-bottom: var(--space-2);
}
.mrc-archetype {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.3;
}
.mrc-descriptor {
  font-size: var(--text-body-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
  line-height: 1.5;
}
.mrc-insight {
  font-family: var(--font-accent);
  font-size: 15px;
  font-style: italic;
  color: var(--color-text-primary);
  border-left: 2px solid var(--color-accent-primary);
  padding-left: var(--space-4);
  margin: var(--space-4) 0;
  line-height: 1.5;
}
.mrc-notes {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.mrc-note {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-secondary);
}
.mrc-note-label {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.mrc-note-label.coach { color: var(--color-indigo); }
.mrc-note-label.friend { color: var(--color-accent-primary); }

.take-breath {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--space-8) auto var(--space-6);
  padding: 12px 24px;
  border: 1px dashed var(--color-text-tertiary);
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  font-style: italic;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.take-breath:hover { border-style: solid; background: var(--color-bg-tertiary); }

/* --- Awareness Notebook --- */
.awareness-input-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin: var(--space-6) var(--space-4) 0;
}

.drop-card {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-divider);
}
.drop-card:last-child { border-bottom: none; }
.drop-timestamp { font-family: var(--font-data); font-size: 12px; color: var(--color-text-tertiary); }
.drop-text { font-size: var(--text-body); line-height: 1.5; margin-top: var(--space-2); }
.drop-mir-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent-primary);
}
.drop-mir-divider::before, .drop-mir-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-divider); }
.drop-mir-response { font-size: 15px; color: var(--color-text-secondary); line-height: 1.5; }
.drop-closing-line { font-size: var(--text-body-sm); font-style: italic; color: var(--color-text-tertiary); margin-top: var(--space-2); }

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-4);
  max-width: 320px;
  margin: 0 auto;
}
.empty-state-icon { font-size: 24px; color: var(--color-text-tertiary); margin-bottom: var(--space-4); }
.empty-state h3 { font-family: var(--font-display); font-size: 18px; font-weight: 500; color: var(--color-text-secondary); margin-bottom: var(--space-3); }
.empty-state p { font-size: 15px; color: var(--color-text-tertiary); line-height: 1.5; }

/* --- History & Trends --- */
.history-range-toggle {
  display: flex;
  gap: var(--space-1);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
  margin-bottom: var(--space-5);
}
.history-range-btn {
  flex: 1;
  background: none;
  border: none;
  border-radius: var(--radius-full);
  padding: 8px 0;
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}
.history-range-btn:hover { color: var(--color-text-primary); }
.history-range-btn.active {
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.history-stat-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}
.history-stat-value {
  font-size: var(--text-data);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}
.history-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-tertiary);
  letter-spacing: 0.02em;
}

.history-section {
  margin-bottom: var(--space-8);
}
.history-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  margin-bottom: var(--space-4);
}

.history-chart-container {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  height: 240px;
  position: relative;
}
.history-chart-container canvas { height: 100% !important; }

.history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: var(--text-body-sm);
  color: var(--color-text-tertiary);
  font-style: italic;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: var(--space-4);
}
.history-empty p { font-size: var(--text-body-sm); color: var(--color-text-secondary); }

/* Calendar */
.history-calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.history-calendar-month {
  font-family: var(--font-display);
  font-size: var(--text-body);
  font-weight: 500;
}

.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: var(--space-1);
}
.cal-day-label {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  padding: var(--space-1) 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  position: relative;
  gap: 2px;
}
.cal-empty { visibility: hidden; }
.cal-day-num {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--color-text-secondary);
}
.cal-dots {
  display: flex;
  gap: 2px;
  min-height: 6px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.cal-dot-morning { background: var(--color-accent-primary); }
.cal-dot-evening { background: var(--color-accent-secondary); }
.cal-dot-drop { background: var(--color-coral); }

.cal-today {
  background: var(--color-accent-primary-light);
  border-radius: var(--radius-sm);
}
.cal-today .cal-day-num { color: var(--color-accent-primary); font-weight: 500; }
.cal-future { opacity: 0.3; }
.cal-full { background: var(--color-sage-light); }

.history-legend {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  margin-top: var(--space-3);
}
.history-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 12px;
  color: var(--color-text-tertiary);
}
.history-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.history-legend-morning { background: var(--color-accent-primary); }
.history-legend-evening { background: var(--color-accent-secondary); }
.history-legend-drop { background: var(--color-coral); }

/* --- Ritual Flow --- */
.ritual-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--color-bg-primary);
}
.ritual-header-title { font-size: var(--text-overline); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-tertiary); }
.ritual-header-step { font-size: var(--text-caption); color: var(--color-text-secondary); }
.ritual-content { max-width: 480px; margin: 0 auto; padding: var(--space-6) var(--space-4); }

/* Timer */
.timer-container { text-align: center; padding: var(--space-6) 0; }
.timer-ring {
  width: 200px;
  height: 200px;
  margin: 0 auto var(--space-4);
  position: relative;
}
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring-track { fill: none; stroke: var(--color-bg-tertiary); stroke-width: 4; }
.timer-ring-fill { fill: none; stroke: var(--color-accent-primary); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-time {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-data);
  font-size: 40px;
  font-weight: 500;
}
.timer-status { font-size: var(--text-body-sm); font-style: italic; color: var(--color-text-secondary); margin-top: var(--space-4); }

/* --- Onboarding --- */
.onboarding-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  max-width: 400px;
  margin: 0 auto;
}
.onboarding-dots { display: flex; gap: var(--space-2); margin-bottom: var(--space-12); }

/* --- Focus Styles (A11y) --- */
.nav-icon-btn:focus-visible,
.nav-tab:focus-visible,
.energy-tap-circle:focus-visible,
.module-tile:focus-visible,
.history-range-btn:focus-visible,
.modal-close:focus-visible,
.take-breath:focus-visible,
.btn-text:focus-visible,
.checkbox-wrap input:focus-visible,
.radio-wrap input:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

/* --- Skip Link (A11y) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-accent-primary);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-size: var(--text-body-sm);
  font-weight: 500;
  text-decoration: none;
}
.skip-link:focus {
  top: var(--space-2);
}

/* --- Toast Notifications --- */
.toast {
  position: fixed;
  bottom: calc(var(--space-8) + 60px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-text-primary);
  color: var(--color-bg-primary);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.4;
  max-width: 360px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  pointer-events: none;
}
.toast.toast-error {
  background: var(--color-error);
  color: #fff;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Reduced Motion (A11y) --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .spinner { animation: none; border-top-color: var(--color-accent-primary); }
}

/* --- Responsive --- */
@media (max-width: 639px) {
  .text-display { font-size: 2rem; }
  .text-h1 { font-size: 1.625rem; }
  .text-h2 { font-size: 1.375rem; }
  .landing-hero { text-align: left; }
}

@media (min-width: 640px) {
  .container-comfortable { max-width: 640px; }
  .tier-cards { flex-direction: row; }
  .tier-cards .card { flex: 1; }
}

@media (min-width: 1024px) {
  .landing-hero { text-align: center; }
  .landing-nav { left: 50%; transform: translateX(-50%); }
  .modal-content { border-radius: var(--radius-xl); max-width: 420px; }
  .modal-overlay { align-items: center; }
}

/* --- Quiz Funnel --- */
.quiz-option:hover { border-color: var(--color-accent-primary) !important; background: var(--color-accent-primary-light) !important; }
.quiz-option:focus-visible { outline: 2px solid var(--color-accent-primary); outline-offset: 2px; }
