/* ============================================
   VOEDINGSDAGBOEK - Coaching Notebook Design System
   ============================================ */

/* --------------------------------------------
   1. CSS Variables (Design Tokens)
   -------------------------------------------- */
:root {
  /* Typography */
  --font-display: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  /* Background layers */
  --bg-page: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-card-elevated: #FFFFFF;
  --bg-input: #F5F5F3;

  /* Text hierarchy */
  --text-primary: #1A1A1A;
  --text-secondary: #5C5C5C;
  --text-muted: #8C8C8C;
  --text-inverse: #FFFFFF;

  /* Accent (primary action, links) */
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: #EFF6FF;

  /* Status colors — softer, not harsh */
  --status-success: #059669;
  --status-success-bg: #ECFDF5;
  --status-warning: #D97706;
  --status-warning-bg: #FFFBEB;
  --status-danger: #DC2626;
  --status-danger-bg: #FEF2F2;

  /* Sleep stage colors */
  --sleep-deep: #1E3A5F;
  --sleep-rem: #7C3AED;
  --sleep-core: #60A5FA;
  --sleep-awake: #FCD34D;

  /* Weight gradient */
  --weight-current: #F59E0B;
  --weight-goal: #10B981;
  --weight-ema: #2563EB;

  /* Chart colors */
  --chart-protein: #2563EB;
  --chart-calories: #8B5CF6;
  --chart-hr: #EF4444;
  --chart-hrv: #06B6D4;
  --chart-steps: #22C55E;

  /* VO2 Max fitness bands (male, 40-49 age group) */
  --vo2-band-below: #FEE2E2;    /* Below average (31-38): soft red */
  --vo2-band-above: #D1FAE5;    /* Above average (38-47): soft green */
  --vo2-band-high: #A7F3D0;     /* High (47+): stronger green */

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Borders */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.12);

  /* Motion */
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Layout */
  --header-height: 60px;
  --tab-bar-height: 56px;
  --max-width: 720px;
}

/* --------------------------------------------
   2. Base Reset & Defaults
   -------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-page);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------
   3. Typography
   -------------------------------------------- */
.page-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.section-header {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.data-value-lg {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
}

.data-value-md {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.data-value-sm {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
}

.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --------------------------------------------
   4. Password Overlay
   -------------------------------------------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  padding: var(--space-md);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.auth-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.auth-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-input {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-md);
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 2px solid var(--bg-input);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-input::placeholder {
  color: var(--text-muted);
}

/* Numeric PIN input - larger centered digits */
.auth-input--numeric {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.5em;
  text-align: center;
  padding-left: var(--space-lg);
}

.auth-button {
  width: 100%;
  height: 52px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-inverse);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.auth-button:hover {
  background: var(--accent-hover);
}

.auth-button:active {
  transform: scale(0.98);
}

.auth-error {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--status-danger);
  background: var(--status-danger-bg);
  border-radius: var(--radius-sm);
}

.auth-error[hidden] {
  display: none;
}

.auth-footer {
  margin-top: var(--space-xl);
  font-size: 13px;
  color: var(--text-muted);
}

/* Shake animation for wrong password */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.auth-card.shake {
  animation: shake 0.3s ease-in-out;
}

/* --------------------------------------------
   5. App Shell Layout
   -------------------------------------------- */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom));
}

.app-shell[hidden] {
  display: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-md);
  padding-top: env(safe-area-inset-top);
  background: var(--bg-page);
}

.last-updated {
  font-size: 12px;
  color: var(--text-muted);
}

.app-content {
  padding: var(--space-md);
  padding-left: max(var(--space-md), env(safe-area-inset-left));
  padding-right: max(var(--space-md), env(safe-area-inset-right));
  max-width: var(--max-width);
  margin: 0 auto;
}

/* --------------------------------------------
   6. Bottom Tab Bar
   -------------------------------------------- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  height: calc(var(--tab-bar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-card);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  text-decoration: none;
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease-out);
}

.tab-item[aria-selected="true"] {
  color: var(--accent);
}

.tab-icon {
  font-size: 22px;
  line-height: 1;
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
}

/* --------------------------------------------
   7. Cards
   -------------------------------------------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

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

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

/* Card appear animation */
@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: cardAppear var(--duration-normal) var(--ease-out) both;
}

.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 50ms; }
.card:nth-child(3) { animation-delay: 100ms; }
.card:nth-child(4) { animation-delay: 150ms; }
.card:nth-child(5) { animation-delay: 200ms; }
.card:nth-child(6) { animation-delay: 250ms; }
.card:nth-child(7) { animation-delay: 300ms; }
.card:nth-child(8) { animation-delay: 350ms; }

/* Streak card special styling */
.card--streak {
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  border: 1px solid #FCD34D;
}

.streak-value {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.streak-icon {
  font-size: 24px;
}

/* Weekly Health Pulse card (AI analysis) */
.card--pulse {
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border: 1px solid #93C5FD;
}

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

.pulse-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

@media (max-width: 520px) {
  .pulse-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pulse-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-sm);
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
}

.pulse-item .status-dot {
  width: 10px;
  height: 10px;
}

.pulse-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.pulse-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.pulse-summary {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  padding-top: var(--space-sm);
  border-top: 1px solid rgba(147, 197, 253, 0.3);
}

/* --------------------------------------------
   8. Status Pills & Indicators
   -------------------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.status-pill--success {
  color: var(--status-success);
  background: var(--status-success-bg);
}

.status-pill--warning {
  color: var(--status-warning);
  background: var(--status-warning-bg);
}

.status-pill--danger {
  color: var(--status-danger);
  background: var(--status-danger-bg);
}

/* Status dot indicator */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot--success { background: var(--status-success); }
.status-dot--warning { background: var(--status-warning); }
.status-dot--danger { background: var(--status-danger); }
.status-dot--neutral { background: var(--bg-input); }

/* --------------------------------------------
   9. Summary Grid (Daily Totals)
   -------------------------------------------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
}

.summary-item {
  text-align: center;
  padding: var(--space-sm);
  background: var(--bg-page);
  border-radius: var(--radius-sm);
}

.summary-item--highlight {
  background: var(--accent-soft);
}

.summary-item--success {
  background: var(--status-success-bg);
}

.summary-item--warning {
  background: var(--status-warning-bg);
}

.summary-item--danger {
  background: var(--status-danger-bg);
}

.summary-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.summary-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Secondary row for fiber/sugar */
.summary-secondary {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.summary-secondary-item {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --------------------------------------------
   10. Period Selector
   -------------------------------------------- */
.period-selector {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping for 4-button selectors on narrow screens */
  gap: var(--space-xs);
  background: var(--bg-page);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.period-btn {
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.period-btn:hover {
  color: var(--text-primary);
}

.period-btn[aria-pressed="true"] {
  color: var(--text-primary);
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------
   11. Charts
   -------------------------------------------- */
.chart-container {
  position: relative;
  height: 200px;
  margin-top: var(--space-md);
}

.chart-container--small {
  height: 160px;
}

.chart-container--sparkline {
  height: 40px;
}

/* Chart legend inline */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--text-secondary);
}

.chart-legend-color {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

/* --------------------------------------------
   12. Date Navigator
   -------------------------------------------- */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.date-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 18px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.date-nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-input);
}

.date-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.date-nav-current {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.date-nav-adjacent {
  font-size: 13px;
  color: var(--text-muted);
}

/* --------------------------------------------
   13. Meal Timeline (Food Diary)
   -------------------------------------------- */
.meal-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.meal-group {
  border-left: 2px solid var(--bg-input);
  padding-left: var(--space-md);
}

.meal-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.meal-item {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.meal-item:last-child {
  border-bottom: none;
}

.meal-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.meal-macros {
  font-size: 13px;
  color: var(--text-secondary);
}

.meal-macros-expanded {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------
   14. Meal Timing Heatmap
   -------------------------------------------- */
.timing-heatmap {
  margin-top: var(--space-md);
}

.timing-heatmap-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.timing-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
}

.timing-heatmap-grid--17 {
  grid-template-columns: repeat(17, 1fr);
  gap: 2px;
}

.timing-bin {
  height: 24px;
  background: var(--bg-input);
  border-radius: 3px;
  transition: background var(--duration-fast) var(--ease-out);
}

.timing-bin--active {
  background: var(--accent);
}

.timing-bin--intense {
  background: var(--accent-hover);
}

.timing-hours {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.timing-hours--17 {
  /* 6 labels across 17 bins: position at bins 0, 3, 6, 9, 12, 15 */
  justify-content: space-between;
  padding: 0 2px;
}

/* --------------------------------------------
   15. Sleep View Components
   -------------------------------------------- */
.sleep-overview {
  text-align: center;
  padding: var(--space-lg) 0;
}

.sleep-icon {
  font-size: 32px;
  margin-bottom: var(--space-sm);
}

.sleep-hours {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 700;
}

.sleep-times {
  margin-top: var(--space-sm);
  font-size: 15px;
  color: var(--text-secondary);
}

/* Sleep stages stacked bar */
.sleep-stages-bar {
  display: flex;
  height: 24px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: var(--space-md) 0;
}

.sleep-stage-segment {
  transition: flex var(--duration-normal) var(--ease-out);
}

.sleep-stage-segment--deep { background: var(--sleep-deep); }
.sleep-stage-segment--rem { background: var(--sleep-rem); }
.sleep-stage-segment--core { background: var(--sleep-core); }
.sleep-stage-segment--awake { background: var(--sleep-awake); }

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

.sleep-stage-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
}

.sleep-stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.sleep-stage-dot--deep { background: var(--sleep-deep); }
.sleep-stage-dot--rem { background: var(--sleep-rem); }
.sleep-stage-dot--core { background: var(--sleep-core); }
.sleep-stage-dot--awake { background: var(--sleep-awake); }

/* Weekly sleep schedule */
.sleep-schedule {
  margin-top: var(--space-md);
}

.sleep-schedule-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.sleep-schedule-day {
  width: 28px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.sleep-schedule-bar-container {
  flex: 1;
  height: 16px;
  background: var(--bg-input);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.sleep-schedule-bar {
  position: absolute;
  top: 2px;
  bottom: 2px;
  background: var(--accent);
  border-radius: 3px;
}

.sleep-schedule-times {
  width: 90px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
}

/* --------------------------------------------
   16. Accordion
   -------------------------------------------- */
.accordion {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-md);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: var(--space-md);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}

.accordion-icon {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-out);
}

.accordion[data-open="true"] .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 0 var(--space-md) var(--space-md);
}

.accordion[data-open="true"] .accordion-content {
  display: block;
}

/* --------------------------------------------
   17. Toggle Switch
   -------------------------------------------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
}

.toggle-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.toggle[aria-checked="true"] {
  background: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--bg-card);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform var(--duration-fast) var(--ease-out);
}

.toggle[aria-checked="true"]::after {
  transform: translateX(18px);
}

/* --------------------------------------------
   18. Annotation
   -------------------------------------------- */
.annotation {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  margin-top: var(--space-md);
}

.annotation-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.annotation-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
}

/* --------------------------------------------
   19. Loading & Empty States
   -------------------------------------------- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-input);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.empty-state-message {
  font-size: 14px;
  color: var(--text-secondary);
}

/* --------------------------------------------
   20. Toast / Delight Messages
   -------------------------------------------- */
.toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom) + var(--space-lg));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-md);
  pointer-events: none;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: var(--max-width);
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  pointer-events: auto;
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center bottom;
}

.toast--success {
  border-left: 3px solid var(--status-success);
}

.toast--warning {
  border-left: 3px solid var(--status-warning);
}

.toast--coach {
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 5%, var(--bg-card)) 100%);
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-message {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.toast-submessage {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.toast-close:hover {
  background: var(--bg-input);
  color: var(--text-secondary);
}

.toast.toast--exiting {
  animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
  .toast.toast--exiting {
    animation: none;
    opacity: 0;
  }
}

/* --------------------------------------------
   21. Utility Classes
   -------------------------------------------- */
.text-success { color: var(--status-success); }
.text-warning { color: var(--status-warning); }
.text-danger { color: var(--status-danger); }
.text-muted { color: var(--text-muted); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
