/* ═══════════════════════════════════════════════════════════════
   AI Personal Trainer — Design System
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ─────────────────────────────────────────── */

:root {
  /* Primary palette */
  --color-primary: #D4560F;
  --color-primary-hover: #B64809;
  --color-primary-light: #FEF0E7;
  --color-primary-muted: #F9C4A0;

  /* Status */
  --color-success: #059669;
  --color-success-light: #d1fae5;
  --color-success-border: #059669;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-danger-border: #dc2626;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-warning-border: #d97706;
  --color-in-progress: #3b82f6;

  /* Foreground (text) */
  --color-fg: #1C1A18;
  --color-fg-primary: #1C1A18;
  --color-fg-secondary: #6B655D;
  --color-fg-on-primary: #ffffff;

  /* Surfaces */
  --color-surface: #F3F1ED;
  --color-surface-alt: #E8E5DF;
  --color-muted: #8A837A;

  /* Typography */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.85rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  /* Borders & radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
  --border-color: #DDD9D2;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.07), 0 0 0 1px rgba(0, 0, 0, 0.03);

  /* Session type colors */
  --color-strength: #92400e;
  --color-strength-bg: #fef3c7;
  --color-cardio: #1e40af;
  --color-cardio-bg: #dbeafe;
  --color-endurance: #065f46;
  --color-endurance-bg: #d1fae5;
  --color-speed-work: #9d174d;
  --color-speed-work-bg: #fce7f3;
  --color-recovery: #3730a3;
  --color-recovery-bg: #e0e7ff;
  --color-flexibility: #6b21a8;
  --color-flexibility-bg: #f3e8ff;
  --color-rest: #4b5563;
  --color-rest-bg: #f3f4f6;
}

/* ── 2. Base Overrides ────────────────────────────────────────── */

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--color-surface);
}

.metric-value,
.snapshot-card__value,
.physio-card__value,
.pr-card__pace,
.health-metric-num {
  font-variant-numeric: tabular-nums;
}

footer {
  margin-top: var(--space-8);
  padding: var(--space-6) 0;
  text-align: center;
  border-top: 1px solid var(--muted-border-color);
}

/* ── 3. Layout Utilities ──────────────────────────────────────── */

.section {
  margin-bottom: var(--space-6);
}

.section-header {
  margin-bottom: var(--space-4);
}

/* ── 4. Status Indicators ─────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

.setup-step-actions .badge {
  padding: var(--space-1) var(--space-3);
  line-height: 1;
  font-size: var(--font-size-xs);
}

.setup-step-actions .badge--connection {
  padding: 0.75rem var(--space-3);
  line-height: 1.5;
  border: 1px solid var(--color-success-border);
  font-size: var(--font-size-sm);
  display: inline-flex;
  align-items: center;
}

.badge--success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge--danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge--warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge--info {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge--muted {
  background: var(--color-surface-alt);
  color: var(--color-muted);
}

.badge--connection {
  background: var(--color-success-light);
  color: var(--color-success);
  padding: 0.75rem var(--space-3);
  line-height: 1.5;
  border: 1px solid var(--color-success-border);
  font-size: var(--font-size-sm);
  display: inline-flex;
  align-items: center;
}

.connected {
  color: var(--color-success);
  font-weight: 600;
}

.disconnected {
  color: var(--color-danger);
  font-weight: 600;
}

.in-progress {
  color: var(--color-in-progress);
  font-weight: 600;
}

/* ── 5. Session Type Badges ───────────────────────────────────── */

.session-type {
  font-size: var(--font-size-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  font-weight: 600;
}

.session-type--strength  { background: var(--color-strength-bg);  color: var(--color-strength); }
.session-type--cardio    { background: var(--color-cardio-bg);    color: var(--color-cardio); }
.session-type--endurance { background: var(--color-endurance-bg); color: var(--color-endurance); }
.session-type--speed-work { background: var(--color-speed-work-bg); color: var(--color-speed-work); }
.session-type--recovery  { background: var(--color-recovery-bg);  color: var(--color-recovery); }
.session-type--flexibility { background: var(--color-flexibility-bg); color: var(--color-flexibility); }
.session-type--rest      { background: var(--color-rest-bg);      color: var(--color-rest); }
.session-type--active    { background: var(--color-success-light);  color: var(--color-success); }

/* ── 6a. Button System ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s, box-shadow 0.15s;
  line-height: 1.4;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.4);
  color: #fff;
  text-decoration: none;
}

.btn--secondary {
  background: var(--color-surface-alt);
  color: var(--color-fg-primary);
  border: 1px solid var(--border-color);
}

.btn--secondary:hover {
  background: var(--border-color);
  color: var(--color-fg-primary);
  text-decoration: none;
}

/* ── 6. Cards ─────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-5);
  border: none;
  margin-bottom: var(--space-4);
}

.card--session {
  background: #fff;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-5);
}

.card--session.completed {
  opacity: 0.85;
  border-left: 4px solid var(--color-success);
}

.card--message {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

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

.card--observation {
  background: var(--color-primary-light);
  border-left: 4px solid var(--color-primary);
  padding: var(--space-4);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.card--observation p {
  margin-bottom: var(--space-1);
}

.card--setup-step {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  opacity: 0.6;
}

.card--setup-step.active {
  opacity: 1;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.card--setup-step.in-progress {
  opacity: 1;
  border-color: var(--color-primary);
}

.card--setup-step.complete {
  opacity: 0.85;
  border-left: 4px solid var(--color-success);
}

.setup-step-actions {
  min-height: 2.5rem;
}

.messaging-connection-card {
  min-height: 2.5rem;
}

/* ── 7. Rationale Toggles (consolidated) ──────────────────────── */

.rationale-details {
  margin-top: var(--space-3);
  padding: var(--space-2);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

.rationale-details summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.rationale-details summary::-webkit-details-marker {
  color: var(--color-primary);
}

.rationale-details[open] summary::-webkit-details-marker {
  /* native marker handles rotation */
}

.rationale-icon {
  font-size: var(--font-size-md);
}

.rationale-content {
  padding: var(--space-2) 0 0 var(--space-5);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

/* ── 8. Dashboard Components ──────────────────────────────────── */

/* Two-card grid replacing gradient hero */
.dashboard-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  container-type: inline-size;
  container-name: dashboard-cards;
}

@media (max-width: 768px) {
  .dashboard-cards-grid {
    grid-template-columns: 1fr;
  }
}

@container dashboard-cards (max-width: 480px) {
  .card--today,
  .card--health {
    grid-column: 1 / -1;
  }
}

/* Today card — inherits .card base */
.card--today {
  background: #fff;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-5);
}

.card--today--strength  { background-color: var(--color-strength-bg); }
.card--today--cardio    { background-color: var(--color-cardio-bg); }
.card--today--endurance { background-color: var(--color-endurance-bg); }
.card--today--speed-work { background-color: var(--color-speed-work-bg); }
.card--today--recovery  { background-color: var(--color-recovery-bg); }
.card--today--flexibility { background-color: var(--color-flexibility-bg); }
.card--today--rest      { background-color: #fff; }
.card--today--completed { background-color: #fff; }

.card--today h2 {
  margin-bottom: var(--space-1);
}

.card--today .today-date {
  color: var(--color-fg-secondary, var(--color-muted));
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-3);
}

.today-badge {
  display: inline-block;
  background: var(--color-primary);
  color: var(--color-fg-on-primary);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm, 4px);
  vertical-align: middle;
  margin-left: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card--today .today-next {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-bottom: var(--space-4);
}

.card--today .today-actions {
  margin-top: var(--space-4);
}

/* Today card — redesigned hero layout */

.today-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.today-header-row .today-date {
  margin-bottom: 0;
}

.today-header-badges {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.today-title {
  margin: 0 0 var(--space-4) 0;
  font-size: var(--font-size-xl);
  line-height: 1.2;
}

.today-metrics-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.today-metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.today-metric-num {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-fg-primary);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.today-metric-unit {
  font-size: var(--font-size-xs);
  color: var(--color-fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 3px;
  text-align: center;
  white-space: nowrap;
}

.today-metric-sep {
  width: 1px;
  height: 2rem;
  background: rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.today-equipment-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.today-equipment-chip {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--color-fg-secondary);
  text-transform: capitalize;
}


.today-cta {
  color: var(--color-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.today-cta:hover {
  text-decoration: underline;
}

/* Health snapshot card — inherits .card base */
.card--health {
  background: #fff;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-5);
}

.card--health h2 {
  margin-bottom: var(--space-4);
}

/* ── Health card header ─────────────────────────────────── */
.health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.health-header h2 {
  margin: 0;
}

.health-rec-badge {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.health-rec--high  { background: #fef3c7; color: #b45309; }
.health-rec--mid   { background: #dbeafe; color: #1d4ed8; }
.health-rec--low   { background: #dcfce7; color: #15803d; }

/* ── Metric rows ────────────────────────────────────────── */
.health-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.health-metric-row {}

.health-metric-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 5px;
}

.health-metric-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  font-weight: 600;
}

.health-metric-right {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.health-metric-num {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-fg-primary, inherit);
  line-height: 1;
}

.health-metric-unit {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: var(--color-muted);
}

.health-qual-tag {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.health-qual--high { background: #dcfce7; color: #15803d; }
.health-qual--mid  { background: #fef9c3; color: #92400e; }
.health-qual--low  { background: #fee2e2; color: #b91c1c; }

.health-trend-icon {
  font-size: var(--font-size-xs);
  line-height: 1;
}
.health-trend--up   { color: var(--color-success); }
.health-trend--down { color: var(--color-danger); }
.health-trend--stable { color: var(--color-muted); }

/* ── Fill bar ───────────────────────────────────────────── */
.health-metric-bar-track {
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary, #f0f0f0);
  overflow: hidden;
}

.health-metric-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.health-metric-bar-fill.health-qual--high { background: #22c55e; }
.health-metric-bar-fill.health-qual--mid  { background: #f59e0b; }
.health-metric-bar-fill.health-qual--low  { background: #ef4444; }

/* ── Garmin nudge ───────────────────────────────────────── */
.health-garmin-nudge {
  margin-top: var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  text-align: right;
}
.health-garmin-nudge a {
  color: var(--color-primary);
  text-decoration: none;
}

/* Health CTA bar */
.health-cta-bar {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
}

.health-cta-bar p {
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.health-cta-bar .cta-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Weekly overview bar */
.week-overview {
  margin-bottom: var(--space-6);
}

.week-bar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  container-type: inline-size;
  container-name: weekbar;
}

@container weekbar (max-width: 420px) {
  .week-bar {
    gap: var(--space-1);
  }
  .week-day .day-type {
    display: none;
  }
}

.week-day {
  text-align: center;
  padding: var(--space-3) var(--space-1);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.week-day:hover {
  background-color: var(--color-surface-alt);
  border-color: var(--color-primary-muted);
}

.week-day.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-muted);
}

.week-day .day-label {
  font-weight: 600;
  margin-bottom: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-muted);
}

.week-day .day-type {
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.week-day.completed {
  background: var(--color-success-light);
  border-color: var(--color-success);
}

.week-day.today {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-muted);
}

.week-day.upcoming {
  background: transparent;
}

.week-day.rest {
  background: var(--color-surface);
  border-style: dashed;
}

/* 4-state day status variants */
.week-day--followed {
  background: var(--color-success-light);
  border-color: var(--color-success);
}

.week-day--swapped {
  background: var(--color-warning-light);
  border-color: var(--color-warning);
}

.week-day--missed {
  background: var(--color-danger-light);
  border-color: var(--color-danger);
}

.week-day--today {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-muted);
}

.week-day--upcoming {
  background: transparent;
}

.week-day--rest {
  background: var(--color-surface);
  border-style: dashed;
}

.week-day--active {
  background: var(--color-success-light);
  border-color: var(--color-success);
  border-style: solid;
}

.day-status-icon {
  font-size: 0.85rem;
  line-height: 1;
  margin-top: 2px;
}

.status-followed {
  color: var(--color-success);
}

.status-swapped {
  color: var(--color-warning);
  font-weight: 700;
}

.status-missed {
  color: var(--color-danger);
  font-weight: 700;
  font-size: 1rem;
}

.status-today {
  color: var(--color-primary);
}

.status-active {
  color: var(--color-success);
  font-weight: 700;
}

/* Inline panel below week bar */
.week-day-panel {
  margin-top: var(--space-3);
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  animation: panelSlideIn 0.2s ease-out;
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.week-day-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.week-day-panel .panel-day-label {
  font-weight: 600;
  font-size: var(--font-size-md);
}

.week-day-panel .panel-close {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: var(--font-size-lg);
  padding: 0;
  line-height: 1;
}

.week-day-panel .panel-close:hover {
  color: var(--color-fg-primary, inherit);
}

.week-day-panel .panel-session-info {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.week-day-panel .panel-session-info span::before {
  content: '\00B7';
  margin-right: var(--space-2);
  color: var(--color-muted);
}

.week-day-panel .panel-session-info span:first-child::before {
  content: '';
  margin-right: 0;
}

.week-day-panel .panel-description {
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
}

.week-day-panel .panel-rest-message {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
}

.week-day-panel .panel-details {
  margin-top: var(--space-3);
}

.week-day-panel .panel-details p {
  margin-bottom: var(--space-1);
  font-size: var(--font-size-sm);
}

.completed-badge {
  color: var(--color-success);
  font-weight: 600;
  font-size: var(--font-size-sm);
}

/* Session header (used in session cards and week panel) */
.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.session-day {
  font-weight: 600;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.session-details p {
  margin-bottom: var(--space-1);
}

/* Message list */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.message-type {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

/* Observations list */
.observations-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-4);
}

/* Section headings within dashboard */
.dashboard-section {
  margin-top: var(--space-6);
  margin-bottom: var(--space-4);
}

.help-text {
  color: var(--color-muted);
  margin-bottom: var(--space-4);
}

/* Help section */
.help-section {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.help-section summary {
  font-weight: 500;
  cursor: pointer;
}

.help-content {
  padding-top: var(--space-4);
}

.help-content p {
  margin-bottom: var(--space-2);
}

/* Quick actions */
.quick-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* ── 9. Settings Components ───────────────────────────────────── */

.settings-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: var(--space-4);
}

.settings-section h2 {
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.settings-section h2 .section-icon {
  font-size: var(--font-size-lg);
}

.settings-submit {
  margin-top: var(--space-6);
  text-align: right;
}

/* Equipment tag chips */
.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-muted);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.chip .chip-remove {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--font-size-md);
  line-height: 1;
  padding: 0;
  margin-left: var(--space-1);
  opacity: 0.7;
}

.chip .chip-remove:hover {
  opacity: 1;
}

.chip-add {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  cursor: pointer;
  background: none;
}

.chip-add:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chip-add-form {
  display: inline-flex;
  gap: var(--space-1);
}

.chip-add-form input {
  width: 140px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
}

/* Cross-training activity builder */
.activity-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.activity-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.activity-row input {
  flex: 1;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.activity-row select {
  width: 130px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  background: var(--pico-background-color, #fff);
}

.activity-row .remove-btn {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: var(--font-size-lg);
  line-height: 1;
  padding: 0 var(--space-1);
  opacity: 0.6;
}

.activity-row .remove-btn:hover {
  opacity: 1;
}

.add-activity-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-primary);
  cursor: pointer;
  background: none;
  border: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: var(--space-1) 0;
}

.add-activity-btn:hover {
  text-decoration: underline;
}

/* Linked accounts */
.linked-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.linked-account:last-child {
  margin-bottom: 0;
}

.linked-account-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.linked-account-icon {
  font-size: var(--font-size-xl);
}

.linked-account-name {
  font-weight: 600;
}

.linked-account-status {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.linked-account-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.linked-account-actions button,
.linked-account-actions a[role="button"] {
  margin-bottom: 0;
}

/* Inline panels for OAuth/linking */
.inline-panel {
  background: var(--color-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-2);
  margin-bottom: var(--space-3);
}

.inline-panel[hidden] {
  display: none;
}

/* Expandable linked account (Telegram) */
.linked-account-expandable {
  flex-direction: column;
  align-items: stretch;
}

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

.toggle-arrow {
  cursor: pointer;
  font-size: var(--font-size-lg);
  color: inherit;
  padding: var(--space-1) var(--space-2);
  user-select: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toggle-arrow:hover {
  opacity: 0.7;
}

.toggle-arrow::after {
  display: inline-block;
}

/* Chevron matching native <select> arrow */
.toggle-arrow-down::after {
  content: '';
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* Close icon — CSS-drawn X, same 8×8 box, no layout shift */
.toggle-arrow-close::after {
  content: '';
  width: 8px;
  height: 8px;
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), currentColor calc(50% - 1px), currentColor calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to bottom right, transparent calc(50% - 1px), currentColor calc(50% - 1px), currentColor calc(50% + 1px), transparent calc(50% + 1px));
}

.linked-account-panel {
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.linked-account-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 0 0 var(--space-3) 0;
}

/* Radio group for risk tolerance */
.radio-group {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.radio-group label input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.radio-group label:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

/* Fieldset grouping */
.form-fieldset {
  margin-bottom: var(--space-4);
}

.form-fieldset legend {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

/* ── 10. Generation Method Badges ─────────────────────────────── */

.generation-method {
  margin-top: var(--space-2);
}

.method-badge {
  display: inline-block;
  font-size: var(--font-size-xs);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-weight: 500;
}

.method-badge.llm             { background: var(--color-primary-muted);  color: var(--color-cardio); }
.method-badge.llm-validated   { background: var(--color-success-light);  color: var(--color-success); }
.method-badge.rules           { background: var(--color-surface-alt);    color: var(--color-muted); }
.method-badge.rules-adaptation { background: var(--color-warning-light);  color: var(--color-warning); }

/* ── 11. Exercises ────────────────────────────────────────────── */

.exercises-section {
  margin-top: var(--space-2);
}

.exercise-list {
  list-style: none;
  padding-left: 0;
  margin: var(--space-1) 0;
}

.exercise-list li {
  padding: var(--space-1) 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: baseline;
}

.exercise-name {
  font-weight: 500;
}

.exercise-detail {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.exercise-detail::before {
  content: '\00B7';
  margin-right: var(--space-1);
}

.exercise-notes {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  font-style: italic;
}

/* ── 12. Scientific References ────────────────────────────────── */

.references-section {
  margin-top: var(--space-6);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.references-section header h3 {
  margin: 0 0 var(--space-2) 0;
}

.references-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.reference-item {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-color);
}

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

.reference-item p {
  margin: 0;
}

.reference-meta {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.reference-summary {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-top: var(--space-1) !important;
}

/* ── 13. Landing Page ─────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: var(--space-6) 0;
}

.hero h1 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-4);
}

.features {
  margin-top: var(--space-8);
}

.features h2 {
  text-align: center;
  margin-bottom: var(--space-6);
}

/* ── 14. Flash Messages ───────────────────────────────────────── */

.flash-message {
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-sm);
}

.flash-message.success {
  background-color: var(--color-success-light);
  border: 1px solid var(--color-success-border);
  color: #065f46;
}

.flash-message.error {
  background-color: var(--color-danger-light);
  border: 1px solid var(--color-danger-border);
  color: #991b1b;
}

/* ── 15. Form Improvements ────────────────────────────────────── */

form small {
  color: var(--color-muted);
  font-size: var(--font-size-xs);
}

.form-error {
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  margin-top: var(--space-1);
}

.form-section-error {
  background: var(--color-danger-light);
  border: 1px solid var(--color-danger);
  color: #991b1b;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
}

/* ── 15b. Form Validation States ───────────────────────────────── */

/* Error messages hidden by default, shown on :user-invalid */
.error-msg {
  display: none;
  color: var(--color-danger);
  font-size: var(--font-size-xs);
  margin-top: var(--space-1);
}

/* Deferred validation: only show errors after user interaction */
input:user-invalid,
select:user-invalid,
textarea:user-invalid {
  border-color: var(--color-danger);
  background-color: var(--color-danger-light);
}

/* Reveal adjacent error message when field is user-invalid */
input:user-invalid + .error-msg,
select:user-invalid + .error-msg,
textarea:user-invalid + .error-msg {
  display: block;
}

/* Focus ring for invalid fields — red instead of blue */
input:user-invalid:focus,
select:user-invalid:focus,
textarea:user-invalid:focus {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* Success state after interaction */
input:user-valid,
select:user-valid,
textarea:user-valid {
  border-color: var(--color-success);
}

/* Highlight hint/rules text when field is in error state */
.field:has(input:user-invalid) .hint,
.field:has(input:user-invalid) .rules-list {
  color: var(--color-danger);
  font-weight: 600;
}

/* ── 16. QR Code ──────────────────────────────────────────────── */

img[alt="QR Code for Telegram Bot"] {
  border-radius: var(--space-2);
  box-shadow: var(--shadow-md);
}

/* ── 17. Misc ─────────────────────────────────────────────────── */

.hidden {
  display: none;
}

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

.text-center {
  text-align: center;
}

/* ── 18. Enhanced Navigation ──────────────────────────────────── */

.nav-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 1rem;
  margin: 0;
  background-color: #0f172a;
  border-bottom: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  gap: var(--space-3);
  flex-wrap: wrap;
  line-height: 1;
}

.nav-main ul {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
  line-height: 1;
}

.nav-main li {
  margin: 0;
  padding: 0;
  line-height: 1;
}

.nav-main a {
  line-height: 1;
  margin: 0;
}

/* Brand */
.nav-brand {
  display: flex;
  align-items: center;
}

.nav-brand a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  font-weight: 700;
  font-size: var(--font-size-md);
  color: #f8fafc;
  padding: 0.2rem 0;
}

.nav-brand a:hover {
  text-decoration: none;
  opacity: 0.85;
}

.nav-brand-icon {
  font-size: 1.3rem;
  line-height: 1;
}

/* Nav links */
.nav-link {
  position: relative;
  padding: 0.2rem var(--space-3);
  color: rgba(248, 250, 252, 0.65);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--font-size-sm);
  transition: color 0.15s;
  border-radius: var(--radius-sm);
}

.nav-link:hover {
  color: #f8fafc;
  text-decoration: none;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: var(--space-3);
  right: var(--space-3);
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.nav-link:hover::after {
  transform: scaleX(0.4);
}

.nav-link--active {
  color: #f8fafc;
  font-weight: 600;
}

.nav-link--active::after {
  transform: scaleX(1);
}

/* Settings icon */
.nav-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-fg-secondary, var(--color-muted));
  text-decoration: none;
  font-size: 1.2rem;
  border-radius: var(--radius-full);
  transition: background-color 0.15s, color 0.15s;
}

.nav-icon-link:hover {
  background-color: var(--color-surface-alt);
  color: var(--color-fg-primary, inherit);
  text-decoration: none;
}

/* Avatar pill */
.nav-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.nav-avatar:hover {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.nav-avatar-initials {
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1;
}

/* User dropdown menu */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-2);
  min-width: 160px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  padding: var(--space-1) 0;
}

.nav-dropdown.open .nav-dropdown-menu,
.nav-avatar[aria-expanded="true"] + .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  color: #e2e8f0;
  text-decoration: none;
  white-space: nowrap;
}

.nav-dropdown-menu a:hover {
  background: #334155;
  color: #f8fafc;
  text-decoration: none;
}

/* CTA button in nav */
.nav-cta {
  font-size: var(--font-size-sm);
  padding: 0.15rem 0.5rem;
}

/* Mobile responsiveness */
@media (max-width: 576px) {
  .nav-main {
    gap: var(--space-2);
  }

  .nav-main .nav-links {
    order: 3;
    width: 100%;
    justify-content: center;
    padding-top: var(--space-2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav-link {
    padding: 0.2rem 0.25rem;
    font-size: var(--font-size-xs);
  }

  .nav-brand-text {
    display: none;
  }
}

@media (max-width: 360px) {
  .nav-main {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-main .nav-brand-group {
    justify-content: center;
  }

  .nav-main .nav-actions {
    justify-content: center;
  }
}

/* ── 19. History Calendar ───────────────────────────────────── */

.history-header h1 {
  margin-bottom: var(--space-1);
}

/* Empty state */
.history-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.history-empty-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: var(--space-4);
}

.history-empty p {
  color: var(--color-muted);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-md);
}

/* Month navigation */
.history-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding: var(--space-3) 0;
}

.month-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--pico-background-color, #fff);
  color: var(--color-fg-primary, inherit);
  text-decoration: none;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.month-nav-btn:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary-muted);
  text-decoration: none;
}

.month-nav-btn--disabled {
  opacity: 0.3;
  cursor: default;
}

.month-label {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
  min-width: 180px;
  text-align: center;
}

/* Calendar grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: var(--space-5);
}

.calendar-dow {
  text-align: center;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-muted);
  padding: var(--space-2) 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-day {
  min-height: 72px;
  padding: var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--pico-background-color, #fff);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-day:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary-muted);
}

.calendar-day--other-month {
  opacity: 0.3;
  cursor: default;
  border-style: dashed;
}

.calendar-day--other-month:hover {
  background: var(--pico-background-color, #fff);
  border-color: var(--border-color);
}

.calendar-day--today {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.calendar-day-number {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-muted);
  line-height: 1;
}

.calendar-day--today .calendar-day-number {
  color: var(--color-primary);
}

.calendar-day-status-icon {
  font-size: 0.85rem;
  line-height: 1;
  align-self: flex-end;
}

.calendar-day--rest-icon {
  opacity: 0.5;
}

.calendar-day--planned-icon {
  opacity: 0.3;
  color: var(--color-primary);
}

.calendar-day-type {
  font-size: 0.6rem !important;
  padding: 1px 3px !important;
  align-self: flex-start;
}

/* Calendar day status backgrounds */
.calendar-day--completed {
  background: var(--color-success-light);
  border-color: var(--color-success-border);
}

.calendar-day--completed:hover {
  background: var(--color-success-light);
  border-color: var(--color-success);
}

.calendar-day--missed {
  background: var(--color-danger-light);
  border-color: var(--color-danger-border);
}

.calendar-day--missed:hover {
  background: var(--color-danger-light);
  border-color: var(--color-danger);
}

.calendar-day--swapped {
  background: var(--color-warning-light);
  border-color: var(--color-warning-border);
}

.calendar-day--swapped:hover {
  background: var(--color-warning-light);
  border-color: var(--color-warning);
}

.calendar-day--rest {
  background: var(--color-surface);
  border-style: dashed;
}

.calendar-day--planned {
  background: var(--color-primary-light);
}

.calendar-day--planned:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary-muted);
}

.calendar-day--no-data {
  background: var(--pico-background-color, #fff);
}

/* History day detail panel */
.history-day-panel {
  margin-top: var(--space-3);
  margin-bottom: var(--space-5);
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  animation: panelSlideIn 0.2s ease-out;
}

/* Legend */
.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-color);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--color-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.legend-dot--completed { background: var(--color-success); }
.legend-dot--missed { background: var(--color-danger); }
.legend-dot--swapped { background: var(--color-warning); }
.legend-dot--planned { background: var(--color-primary); }
.legend-dot--rest { background: var(--color-muted); }

@media (max-width: 768px) {
  .calendar-day {
    min-height: 56px;
    padding: var(--space-1);
  }

  .calendar-day-type {
    display: none;
  }

  .calendar-day-status-icon {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .calendar-day {
    min-height: 44px;
    padding: 2px;
  }

  .calendar-day-number {
    font-size: 0.65rem;
  }

  .calendar-day-status-icon {
    font-size: 0.65rem;
  }
}

/* ── 20. Evolution Metrics ──────────────────────────────────── */

.evolution-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.evolution-header h1 {
  margin-bottom: 0;
}

.evolution-subtitle {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  margin-top: 0;
  margin-bottom: var(--space-5);
}

/* Empty state */
.evolution-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.evolution-empty-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: var(--space-4);
}

.evolution-empty p {
  color: var(--color-muted);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-md);
}

.evolution-empty-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-4);
}

/* Time window selector */
.evolution-window-selector {
  display: flex;
  gap: var(--space-1);
  background: var(--color-surface);
  border-radius: var(--radius-full);
  padding: 3px;
}

.window-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
  min-width: 60px;
}

.window-btn:hover {
  color: var(--color-fg-primary, inherit);
  text-decoration: none;
}

.window-btn--active {
  background: var(--pico-background-color, #fff);
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Metrics grid */
.evolution-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

@media (max-width: 900px) {
  .evolution-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .evolution-metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* Metric card */
.metric-card {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: box-shadow 0.15s;
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
}

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

.metric-card-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-muted);
}

.metric-trend-badge {
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.metric-trend-badge--up {
  background: var(--color-success-light);
  color: var(--color-success);
}

.metric-trend-badge--down {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.metric-trend-badge--stable {
  background: var(--color-surface-alt);
  color: var(--color-muted);
}

.metric-card-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-fg-primary, inherit);
  margin-bottom: var(--space-3);
}

.metric-unit {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-muted);
}

/* Sparkline */
.metric-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 48px;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-color);
}

.sparkline-bar {
  flex: 1;
  min-width: 3px;
  background: var(--color-primary);
  border-radius: 1px 1px 0 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.sparkline-bar:hover {
  opacity: 1;
}

/* ── 20b. Evolution Dashboard Redesign ──────────────────────── */

/* Connect CTA */
.connect-cta {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  background: var(--pico-background-color, #fff);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
}

.connect-cta__icon {
  font-size: 3rem;
  opacity: 0.4;
  margin-bottom: var(--space-3);
}

.connect-cta__title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.connect-cta__text {
  color: var(--color-muted);
  margin-bottom: var(--space-4);
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.connect-cta__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-fg-on-primary);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s;
}

.connect-cta__btn:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
}

/* Snapshot grid */
.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

@media (max-width: 900px) {
  .snapshot-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .snapshot-grid {
    grid-template-columns: 1fr;
  }
}

/* Snapshot card */
.snapshot-card {
  background: #fff;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-4);
  transition: box-shadow 0.2s, transform 0.2s;
}

.snapshot-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

/* Metric card tints */
.snapshot-card--readiness { background-color: #ede9fe; }
.snapshot-card--sleep     { background-color: #f0fdfa; }
.snapshot-card--health    { background-color: #f0fdf4; }
.snapshot-card--fatigue   { background-color: #fffbeb; }

.snapshot-card--empty {
  opacity: 0.65;
  padding: var(--space-3) var(--space-4);
}

.snapshot-card--empty .snapshot-card__value {
  font-size: var(--font-size-xl);
  color: var(--color-muted);
}

.snapshot-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.snapshot-card__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-muted);
}

.snapshot-card__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-fg-primary, inherit);
  margin-bottom: var(--space-2);
  line-height: 1.2;
}

.snapshot-card__unit {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-muted);
  margin-left: 2px;
}

/* Snapshot sparkline */
.snapshot-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-color);
}

.snapshot-sparkline__bar {
  flex: 1;
  min-width: 3px;
  background: var(--color-primary);
  border-radius: 1px 1px 0 0;
  opacity: 0.55;
  transition: opacity 0.15s;
}

.snapshot-sparkline__bar:hover {
  opacity: 1;
}

/* Trend badges */
.snapshot-trend {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.snapshot-trend--up {
  background: var(--color-success-light);
  color: var(--color-success);
}

.snapshot-trend--down {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.snapshot-trend--stable {
  background: var(--color-surface-alt);
  color: var(--color-muted);
}

/* Source badge */
.source-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.source-badge--garmin { background: #1e88e5; color: var(--color-fg-on-primary); }
.source-badge--strava { background: #fc4c02; color: var(--color-fg-on-primary); }

/* Evolution section (shared) */
.evolution-section {
  margin-bottom: var(--space-6);
}

.evolution-section__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-fg-primary, inherit);
}

/* Physio grid */
.physio-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

@media (max-width: 480px) {
  .physio-grid {
    grid-template-columns: 1fr;
  }
}

.physio-card {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: box-shadow 0.2s;
}

.physio-card:hover {
  box-shadow: var(--shadow-md);
}

.physio-card__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

.physio-card__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-fg-primary, inherit);
  margin-bottom: var(--space-1);
}

.physio-card__unit {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-muted);
  margin-left: 2px;
}

.physio-card__delta {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.physio-card__delta--positive {
  color: var(--color-success);
}

.physio-card__delta--negative {
  color: var(--color-danger);
}

.physio-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 48px;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-color);
}

/* Comparisons */
.comparisons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: var(--space-4);
}

.comparison-card {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: box-shadow 0.2s;
}

.comparison-card:hover {
  box-shadow: var(--shadow-md);
}

.comparison-card__title {
  font-size: var(--font-size-md);
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-fg-primary, inherit);
}

/* Sport filter */
.sport-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.sport-filter__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  background: var(--color-surface);
  border: 1px solid var(--border-color);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.sport-filter__btn:hover {
  color: var(--color-fg-primary, inherit);
  text-decoration: none;
  border-color: var(--color-primary-muted);
}

.sport-filter__btn--active {
  background: var(--color-primary);
  color: var(--color-fg-on-primary);
  border-color: var(--color-primary);
  font-weight: 600;
}

.sport-filter__btn--active:hover {
  color: var(--color-fg-on-primary);
}

/* Comparison table */
.comparison-table {
  width: 100%;
  font-size: var(--font-size-sm);
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  padding: var(--space-2) var(--space-2);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.comparison-table th {
  font-weight: 600;
  color: var(--color-muted);
  background: var(--color-surface-alt);
}

.comparison-table__label {
  text-align: left;
  font-weight: 600;
  color: var(--color-muted);
}

.comparison-table__year--anchor {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.comparison-table__anchor {
  background: var(--color-primary-light);
  font-weight: 700;
}

.comparison-table__delta-row td {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

.comparison-table__delta {
  font-size: var(--font-size-xs);
}

/* Delta badges */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
}

.delta--positive { color: var(--color-success); }
.delta--negative { color: var(--color-danger); }
.delta--caution { color: var(--color-warning); }
.delta--anchor {
  color: var(--color-primary);
  font-weight: 700;
}

/* Non-distance */
.nondistance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

.nondistance-card {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: box-shadow 0.2s;
}

.nondistance-card:hover {
  box-shadow: var(--shadow-md);
}

.nondistance-card__label {
  font-size: var(--font-size-md);
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-fg-primary, inherit);
}

.trend-mini-table {
  width: 100%;
  font-size: var(--font-size-sm);
  border-collapse: collapse;
}

.trend-mini-table th,
.trend-mini-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.trend-mini-table th {
  font-weight: 600;
  color: var(--color-muted);
  background: var(--color-surface-alt);
}

/* Report */
.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.report-date {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  font-weight: 500;
}

.report-content {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.report-markdown h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
  color: var(--color-fg-primary, inherit);
}

.report-markdown h3:first-child {
  margin-top: 0;
}

.report-markdown h4 {
  font-size: var(--font-size-md);
  font-weight: 700;
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
  color: var(--color-fg-primary, inherit);
}

.report-markdown p {
  margin-bottom: var(--space-2);
  line-height: 1.6;
  color: var(--color-fg-primary, inherit);
}

.report-markdown ul {
  margin-bottom: var(--space-3);
  padding-left: var(--space-5);
}

.report-markdown li {
  margin-bottom: var(--space-1);
  line-height: 1.5;
}

.report-highlights,
.report-areas {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.report-highlights h3,
.report-areas h3 {
  font-size: var(--font-size-md);
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: var(--color-fg-primary, inherit);
}

.report-highlights ul,
.report-areas ul {
  padding-left: var(--space-5);
  margin-bottom: 0;
}

.report-highlights li,
.report-areas li {
  margin-bottom: var(--space-1);
  line-height: 1.5;
}

/* Key Highlights callout box — subtle tint with left accent */
.report-highlights-callout {
  background: var(--color-surface-hover, #f8fafc);
  border-left: 3px solid var(--color-primary, #2563eb);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
}

.report-highlights-callout h3 {
  margin-top: 0;
}

/* New markdown elements not previously handled by regex renderer */
.report-markdown h1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
  color: var(--color-fg-primary, inherit);
}

.report-markdown h1:first-child {
  margin-top: 0;
}

.report-markdown h2 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
  color: var(--color-fg-primary, inherit);
}

.report-markdown ol {
  margin-bottom: var(--space-3);
  padding-left: var(--space-5);
}

.report-markdown hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-5) 0;
}

.report-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
}

.report-markdown th,
.report-markdown td {
  border: 1px solid var(--border-color);
  padding: var(--space-1) var(--space-2);
  text-align: left;
}

.report-markdown th {
  background: var(--color-surface-hover, #f8fafc);
  font-weight: 600;
}

.report-markdown blockquote {
  border-left: 3px solid var(--color-muted);
  margin: var(--space-3) 0;
  padding: var(--space-2) var(--space-3);
  color: var(--color-muted);
  font-style: italic;
}

.report-markdown code {
  background: var(--color-surface-hover, #f1f5f9);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.report-markdown pre {
  background: var(--color-surface-hover, #f1f5f9);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-3);
}

.report-markdown pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.report-error {
  background: var(--color-danger-light);
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.report-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

#refresh-report-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.refresh-status {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.refresh-status--error {
  color: var(--color-danger);
}

/* ── 21. History Page (Activity View) ───────────────────────── */

/* Stats cards */
.history-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  container-type: inline-size;
  container-name: history-stats;
}

@media (max-width: 900px) {
  .history-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .history-stats-grid {
    grid-template-columns: 1fr;
  }
}

@container history-stats (max-width: 500px) {
  .history-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@container history-stats (max-width: 300px) {
  .history-stats-grid {
    grid-template-columns: 1fr;
  }
}

.history-stat-card {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: box-shadow 0.15s;
}

.history-stat-card:hover {
  box-shadow: var(--shadow-md);
}

.history-stat-card--running { border-left: 4px solid #059669; }
.history-stat-card--cycling { border-left: 4px solid #2563eb; }
.history-stat-card--strength { border-left: 4px solid #d97706; }
.history-stat-card--overall { border-left: 4px solid #7c3aed; }

.history-stat-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.history-stat-icon {
  font-size: var(--font-size-xl);
}

.history-stat-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-muted);
}

.history-stat-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.history-stat-metric {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
}

.history-stat-metric .metric-value {
  font-weight: 600;
}

.history-stat-metric .metric-label {
  color: var(--color-muted);
}

/* Activity list */
.history-activity-list {
  margin-bottom: var(--space-6);
}

.history-date-header {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-muted);
  padding: var(--space-3) 0 var(--space-2);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-2);
  margin-top: var(--space-4);
}

.history-date-header:first-child {
  margin-top: 0;
}

.activity-item {
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.activity-item:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary-muted);
}

.activity-item.expanded {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.activity-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  flex-wrap: wrap;
}

.activity-icon {
  font-size: var(--font-size-lg);
  flex-shrink: 0;
}

.activity-type {
  font-weight: 600;
  font-size: var(--font-size-sm);
  flex-shrink: 0;
  min-width: 100px;
}

.activity-time {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  flex-shrink: 0;
}

.activity-metric {
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-left: auto;
}

.activity-pace {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-left: var(--space-2);
}

.activity-expand-indicator {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  transition: transform 0.2s;
  margin-left: var(--space-2);
}

.activity-item.expanded .activity-expand-indicator {
  transform: rotate(180deg);
}

/* Activity detail panel */
.activity-detail-panel {
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--border-color);
  animation: panelSlideIn 0.2s ease-out;
}

.activity-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  padding-top: var(--space-3);
}

@media (max-width: 480px) {
  .activity-detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.activity-detail-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.activity-detail-label {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.activity-detail-value {
  font-size: var(--font-size-md);
  font-weight: 600;
}

/* Yearly summary */
.history-year-summary {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.history-year-summary summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-size-md);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.history-year-summary summary::-webkit-details-marker {
  color: var(--color-primary);
}

.history-year-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.history-year-stat-type {
  padding: var(--space-3);
  background: var(--pico-background-color, #fff);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.history-year-stat-type h4 {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.history-year-stat-type .year-metric {
  font-size: var(--font-size-sm);
  display: flex;
  justify-content: space-between;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border-color);
}

.history-year-stat-type .year-metric:last-child {
  border-bottom: none;
}

/* Empty state for activities */
.history-empty-activities {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.history-empty-activities-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: var(--space-4);
}

.history-empty-activities h1 {
  margin-bottom: var(--space-2);
}

.history-empty-activities p {
  color: var(--color-muted);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-md);
}

/* ── 22. Calendar History View ──────────────────────────────── */

/* Year summary bar */
.year-summary-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  cursor: pointer;
  transition: background-color 0.15s;
}

.year-summary-bar:hover {
  background: var(--color-surface-alt);
}

.year-summary-label {
  font-weight: 700;
  font-size: var(--font-size-lg);
  color: var(--color-primary);
}

.year-summary-totals {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  flex: 1;
}

.year-summary-chevron {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  transition: transform 0.2s;
}

/* Year detail (expanded) */
.year-detail {
  margin-bottom: var(--space-5);
  animation: panelSlideIn 0.2s ease-out;
}

/* Heatmap */
.heatmap {
  margin-bottom: var(--space-4);
}

.heatmap-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 2px;
}

.heatmap-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-muted);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.heatmap-bar {
  flex: 1;
  height: 16px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
}

.heatmap-segment {
  min-width: 2px;
  transition: opacity 0.15s;
}

.heatmap-segment:hover {
  opacity: 0.8;
}

.heatmap-segment--running { background: #059669; }
.heatmap-segment--cycling { background: #2563eb; }
.heatmap-segment--strength { background: #d97706; }
.heatmap-segment--walking { background: #6b7280; }
.heatmap-segment--swimming { background: #0891b2; }
.heatmap-segment--trail-running { background: #d4a574; }
.heatmap-segment--hiking { background: #27ae60; }
.heatmap-segment--rowing { background: #2980b9; }
.heatmap-segment--elliptical { background: #8e44ad; }
.heatmap-segment--flexibility { background: #16a085; }
.heatmap-segment--yoga { background: #f39c12; }
.heatmap-segment--pilates { background: #c0392b; }
/* Color palette for unmapped activity types */
.heatmap-segment--other-0 { background: #e74c3c; }
.heatmap-segment--other-1 { background: #e67e22; }
.heatmap-segment--other-2 { background: #f1c40f; }
.heatmap-segment--other-3 { background: #2ecc71; }
.heatmap-segment--other-4 { background: #1abc9c; }
.heatmap-segment--other-5 { background: #9b59b6; }
.heatmap-segment--other-6 { background: #e91e63; }
.heatmap-segment--other-7 { background: #3498db; }
.heatmap-segment--other-8 { background: #e84393; }
.heatmap-segment--other-9 { background: #00b894; }
.heatmap-segment--other-10 { background: #6c5ce7; }
.heatmap-segment--other-11 { background: #fd79a8; }

.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-left: 40px;
}

.heatmap-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-muted);
}

.heatmap-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.heatmap-legend-dot--running { background: #059669; }
.heatmap-legend-dot--cycling { background: #2563eb; }
.heatmap-legend-dot--strength { background: #d97706; }
.heatmap-legend-dot--walking { background: #6b7280; }
.heatmap-legend-dot--swimming { background: #0891b2; }
.heatmap-legend-dot--trail-running { background: #d4a574; }
.heatmap-legend-dot--hiking { background: #27ae60; }
.heatmap-legend-dot--rowing { background: #2980b9; }
.heatmap-legend-dot--elliptical { background: #8e44ad; }
.heatmap-legend-dot--flexibility { background: #16a085; }
.heatmap-legend-dot--yoga { background: #f39c12; }
.heatmap-legend-dot--pilates { background: #c0392b; }
.heatmap-legend-dot--other-0 { background: #e74c3c; }
.heatmap-legend-dot--other-1 { background: #e67e22; }
.heatmap-legend-dot--other-2 { background: #f1c40f; }
.heatmap-legend-dot--other-3 { background: #2ecc71; }
.heatmap-legend-dot--other-4 { background: #1abc9c; }
.heatmap-legend-dot--other-5 { background: #9b59b6; }
.heatmap-legend-dot--other-6 { background: #e91e63; }
.heatmap-legend-dot--other-7 { background: #3498db; }
.heatmap-legend-dot--other-8 { background: #e84393; }
.heatmap-legend-dot--other-9 { background: #00b894; }
.heatmap-legend-dot--other-10 { background: #6c5ce7; }
.heatmap-legend-dot--other-11 { background: #fd79a8; }

/* Year highlights */
.year-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.highlight-item {
  padding: var(--space-3);
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

/* Activity pills in calendar cells */
.activity-pill {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-pill--running  { background: #6ee7b7; color: #064e3b; }
.activity-pill--cycling  { background: #bfdbfe; color: #1e3a8a; }
.activity-pill--strength { background: #fde68a; color: #78350f; }
.activity-pill--walking  { background: #e5e7eb; color: #374151; }
.activity-pill--swimming { background: #a5f3fc; color: #164e63; }
.activity-pill--other    { background: #e5e7eb; color: #374151; }

.activity-pill-icon {
  font-size: 0.5rem;
  flex-shrink: 0;
}

.activity-pill-metric {
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-pill-more {
  font-size: 0.5rem;
  color: var(--color-muted);
  text-align: center;
  padding: 1px 0;
}

/* Day detail panel */
.day-detail-panel {
  margin-top: var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--pico-background-color, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  animation: panelSlideIn 0.2s ease-out;
}

.day-detail-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.day-detail-panel .panel-date-label {
  font-weight: 600;
  font-size: var(--font-size-md);
}

.day-detail-panel .panel-close {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: var(--font-size-lg);
  padding: 0;
  line-height: 1;
}

.panel-activity-item {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-color);
}

.panel-activity-item:last-of-type {
  border-bottom: none;
}

.panel-activity-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.panel-activity-icon {
  font-size: var(--font-size-md);
}

.panel-activity-type {
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.panel-activity-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.panel-activity-metrics span::before {
  content: '\00B7';
  margin-right: var(--space-1);
  color: var(--color-muted);
}

.panel-activity-metrics span:first-child::before {
  content: '';
  margin-right: 0;
}

.panel-day-total {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-primary);
}

/* Calendar grid overrides for history page */
.history-page .calendar-grid {
  margin-bottom: var(--space-4);
}

.history-page .calendar-day {
  min-height: 80px;
  padding: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-page .calendar-day-number {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-muted);
  line-height: 1;
  margin-bottom: 2px;
}

.history-page .calendar-day--today .calendar-day-number {
  color: var(--color-primary);
}

.history-page .calendar-day--other-month {
  opacity: 0.3;
}

/* Responsive */
@media (max-width: 768px) {
  .history-page .calendar-day {
    min-height: 60px;
  }

  .activity-pill {
    font-size: 0.5rem;
  }

  .activity-pill-icon {
    display: none;
  }

  .year-highlights {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .history-page .calendar-day {
    min-height: 48px;
    padding: 1px;
  }

  .activity-pill {
    display: none;
  }

  .history-page .calendar-day--has-activities::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
    margin: 2px auto 0;
  }
}

/* ══════════════════════════════════════════════════════════════ */
/* DAY DETAIL PANEL — ACTUAL, ADHERENCE, RECOVERY             */
/* ══════════════════════════════════════════════════════════════ */

/* Panel section headers */
.panel-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.panel-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}
.panel-section-header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}
.panel-section-header--planned { background: #e0e7ff; color: #3730a3; }
.panel-section-header--actual { background: #dcfce7; color: #166534; }
.panel-section-header--adherence { background: #fef3c7; color: #92400e; }
.panel-section-header--recovery { background: #e0e7ff; color: #4338ca; }

/* Status badges within section headers */
.planned-status-badge {
  font-size: 0.55rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.planned-status-badge--missed { background: #fee2e2; color: #dc2626; }
.actual-unscheduled-badge {
  font-size: 0.55rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  background: #dbeafe;
  color: #2563eb;
}

/* Pending analysis message */
.panel-pending-message {
  font-size: 0.8rem;
  color: #9ca3af;
  font-style: italic;
  margin: 0;
  padding: 0.25rem 0;
}

/* Actual activity block */
.actual-activity {
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--border, #e5e7eb);
  border-radius: 0 6px 6px 0;
  background: #f9fafb;
}
.actual-activity--matched {
  border-left-color: #22c55e;
  background: #f0fdf4;
}
.actual-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.actual-type {
  font-weight: 600;
  text-transform: capitalize;
  font-size: 0.85rem;
}
.actual-source {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.source-badge--garmin { background: #1e88e5; color: var(--color-fg-on-primary); }
.source-badge--strava { background: #fc4c02; color: var(--color-fg-on-primary); }
.actual-matched-badge {
  font-size: 0.75rem;
  opacity: 0.7;
}
.actual-metrics {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #4b5563;
  flex-wrap: wrap;
}

/* Adherence metrics */
.adherence-metrics {
  margin-bottom: 0.75rem;
}
.adherence-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.82rem;
}
.adherence-label {
  font-weight: 600;
  min-width: 70px;
  color: #374151;
}
.adherence-value {
  color: #6b7280;
}
.adherence-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  flex-shrink: 0;
}
.adherence-icon--good { background: #dcfce7; color: #16a34a; }
.adherence-icon--warn { background: #fef3c7; color: #d97706; }
.adherence-icon--fast { background: #dbeafe; color: #2563eb; }
.adherence-icon--na { background: #f3f4f6; color: #9ca3af; }

/* Adherence commentary */
.adherence-commentary {
  background: #f8fafc;
  border-left: 3px solid #6366f1;
  padding: 0.75rem 1rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #374151;
  font-style: italic;
}

/* Recovery metrics */
.recovery-metrics {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.recovery-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f8fafc;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  min-width: 70px;
}
.recovery-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 0.15rem;
}

/* Responsive */
@media (max-width: 640px) {
  .actual-metrics { gap: 0.5rem; }
  .adherence-row { font-size: 0.78rem; }
  .adherence-label { min-width: 60px; }
  .recovery-metrics { gap: 0.5rem; }
  .recovery-metric { padding: 0.4rem 0.5rem; min-width: 60px; }
}

/* ── Interval breakdown ──────────────────────────────────── */
.interval-breakdown {
  margin-top: 0.5rem;
}
.interval-breakdown-header {
  font-size: 0.72rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.4rem;
}
.interval-summary {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}
.interval-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.interval-consistency {
  font-weight: 600;
  color: #4338ca;
}
.consistency-bar {
  margin-bottom: 0.5rem;
}
.consistency-bar-track {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}
.consistency-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Split rows */
.interval-splits {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.split-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}
.split-row--consistent { background: #f0fdf4; }
.split-row--fast { background: #eff6ff; }
.split-row--slow { background: #fffbeb; }
.split-num {
  font-weight: 600;
  width: 28px;
  color: #6b7280;
}
.split-time {
  font-weight: 600;
  min-width: 50px;
}
.split-hr {
  font-size: 0.7rem;
  color: #9ca3af;
}
.split-bar {
  flex: 1;
  height: 4px;
  background: #f3f4f6;
  border-radius: 2px;
  overflow: hidden;
}
.split-bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
}
.split-row--consistent .split-bar-fill { background: #22c55e; }
.split-row--fast .split-bar-fill { background: #3b82f6; }
.split-row--slow .split-bar-fill { background: #f59e0b; }

@media (max-width: 640px) {
  .interval-summary { gap: 0.4rem; font-size: 0.72rem; }
  .split-row { gap: 0.3rem; padding: 0.2rem 0.3rem; }
  .split-num { width: 22px; font-size: 0.7rem; }
  .split-time { min-width: 40px; font-size: 0.72rem; }
}

/* ── Evolution Cluster Dashboard ─────────────────────────────── */

/* PR Cards */
.pr-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (max-width: 900px) {
  .pr-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .pr-grid {
    grid-template-columns: 1fr;
  }
}

.pr-card {
  background: #fff;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-4);
  text-align: center;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.pr-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.pr-card__trophy {
  font-size: 2rem;
  margin-bottom: var(--space-2);
  line-height: 1;
}

.pr-card__label {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.pr-card__pace {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-fg-primary, inherit);
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.pr-card__unit {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-muted);
}

.pr-card__date {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
}

.pr-card__meta {
  margin-top: var(--space-2);
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  flex-wrap: wrap;
}

.pr-card__meta span::after {
  content: '·';
  margin-left: var(--space-2);
}

.pr-card__meta span:last-child::after {
  content: '';
}

/* Cluster Sections */
.cluster-section {
  margin-bottom: var(--space-8);
  padding-top: var(--space-4);
  border-top: 2px solid var(--border-color);
}

.cluster-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.cluster-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
}

.cluster-header__icon {
  font-size: var(--font-size-xl);
  line-height: 1;
}

.cluster-header__label {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-fg-primary, inherit);
}

.cluster-header__count {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  font-weight: 500;
}

.cluster-header__delta {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-success-light);
  color: var(--color-success);
  margin-left: auto;
}

/* Cluster Charts Grid */
.cluster-charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

@media (max-width: 1100px) {
  .cluster-charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .cluster-charts-grid {
    grid-template-columns: 1fr;
  }
}

.cluster-chart {
  background: #fff;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-5);
  transition: box-shadow 0.25s ease, transform 0.2s ease;
}

.cluster-chart:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.cluster-chart__title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.cluster-chart canvas {
  max-width: 100% !important;
}

/* Noscript fallback */
.noscript-clusters {
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.noscript-clusters p {
  margin-bottom: var(--space-2);
}

.noscript-clusters p:last-child {
  margin-bottom: 0;
}

/* ── 22. Password Strength Indicator ──────────────────────────── */

/* Use data-password-strength to avoid fighting :user-invalid styles */
.password-strength-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--color-surface-alt);
  margin-top: var(--space-1);
  overflow: hidden;
}

.password-strength-bar::after {
  content: '';
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

[data-password-strength="0"] ~ .password-strength-bar::after,
[data-password-strength="1"] ~ .password-strength-bar::after { width: 20%; background: var(--color-danger); }
[data-password-strength="2"] ~ .password-strength-bar::after { width: 40%; background: orange; }
[data-password-strength="3"] ~ .password-strength-bar::after { width: 60%; background: var(--color-warning); }
[data-password-strength="4"] ~ .password-strength-bar::after { width: 80%; background: var(--color-primary); }
[data-password-strength="5"] ~ .password-strength-bar::after { width: 100%; background: var(--color-success); }

/* ── 23. Toast / Popover Notifications ─────────────────────────── */

/* Toast popover — positioned at top-right, in Top Layer */
.flash-message[popover] {
  position: fixed;
  inset: auto;
  top: 1rem;
  right: 1rem;
  left: auto;
  bottom: auto;
  margin: 0;
  max-width: 380px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: var(--font-size-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  /* Entry animation */
  animation: toastSlideIn 0.3s ease-out;
  /* Allow discrete transition for exit */
  transition: opacity 0.3s ease, transform 0.3s ease, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}

/* Exit animation when being hidden */
.flash-message[popover]:not(:popover-open) {
  opacity: 0;
  transform: translateX(1rem);
}

/* Stacking via sibling-index() */
.flash-message[popover]:popover-open:nth-child(1 of :popover-open) { top: 1rem; }
.flash-message[popover]:popover-open:nth-child(2 of :popover-open) { top: 4.5rem; }
.flash-message[popover]:popover-open:nth-child(3 of :popover-open) { top: 8rem; }

/* Fallback for browsers without sibling-index() */
.flash-message[popover] + .flash-message[popover] {
  top: 4.5rem;
}

/* Success popover */
.flash-message.success[popover] {
  background-color: var(--color-success-light);
  border-color: var(--color-success-border);
  color: #065f46;
}

/* Error popover */
.flash-message.error[popover] {
  background-color: var(--color-danger-light);
  border-color: var(--color-danger-border);
  color: #991b1b;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Close button for toasts */
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
  padding: 0 0 0 var(--space-2);
  margin-left: auto;
  float: right;
}

.toast-close:hover {
  opacity: 1;
}

/* Non-popover fallback: keep existing article styling */
.flash-message:not([popover]) {
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-sm);
}

.flash-message.success:not([popover]) {
  background-color: var(--color-success-light);
  border: 1px solid var(--color-success-border);
  color: #065f46;
}

.flash-message.error:not([popover]) {
  background-color: var(--color-danger-light);
  border: 1px solid var(--color-danger-border);
  color: #991b1b;
}

/* ═══════════════════════════════════════════════════════════════
   Accessibility: Skip Link
   ═══════════════════════════════════════════════════════════════ */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  background: var(--color-primary, #3b82f6);
  color: var(--color-fg-on-primary);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
  transition: top 0.2s;
}

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

/* ═══════════════════════════════════════════════════════════════
   Accessibility: Screen Reader Only
   ═══════════════════════════════════════════════════════════════ */

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

/* ═══════════════════════════════════════════════════════════════
   Accessibility: Calendar Button Styling
   ═══════════════════════════════════════════════════════════════ */

.calendar-day[role="gridcell"] {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.calendar-day[role="gridcell"]:focus-visible {
  outline: 2px solid var(--color-primary, #3b82f6);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   Mobile: Calendar Activity Icons
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .history-page .calendar-day .activity-pill {
    display: none;
  }

  .history-page .calendar-day--has-activities::after {
    content: attr(data-first-icon);
    font-size: 1.1rem;
    display: block;
    text-align: center;
    margin-top: 2px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Mobile: Stack Risk Tolerance Radios
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .risk-tolerance-options,
  .training-risk-tolerance {
    flex-direction: column !important;
    gap: var(--space-3) !important;
  }

  .risk-tolerance-options label,
  .training-risk-tolerance label {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Mobile: Touch Target Sizes
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  button,
  a[role="button"],
  input[type="submit"],
  .chip-remove,
  .send-button,
  .panel-close {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Chat Widget (extracted from chat-widget.ejs inline styles)
   ═══════════════════════════════════════════════════════════════ */

.chat-widget {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--card-border-color, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-background-color, #fff);
  margin-bottom: 1.5rem;
}

.chat-widget--collapsible .chat-widget__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: #f3f4f6;
  border-bottom: 1px solid var(--card-border-color, #e5e7eb);
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-widget__toggle {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  color: var(--color-fg-primary);
}

.chat-widget__body {
  display: flex;
  flex-direction: column;
  height: 400px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.assistant {
  align-self: flex-start;
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.chat-message.assistant p { margin: 0; }
.chat-message.assistant p + p { margin-top: 0.5rem; }
.chat-message.assistant ol, .chat-message.assistant ul { margin: 0; padding-left: 1.25rem; }
.chat-message.assistant li { margin-bottom: 0.25rem; }
.chat-message.assistant li:last-child { margin-bottom: 0; }
.chat-message.assistant strong { font-weight: 600; color: #111827; }

.chat-message.user {
  align-self: flex-end;
  background: #3b82f6;
  color: var(--color-fg-on-primary);
  border-bottom-right-radius: 4px;
}

.chat-message.user p { margin: 0; }
.chat-message.user p + p { margin-top: 0.5rem; }
.chat-message.user ol, .chat-message.user ul { margin: 0; padding-left: 1.25rem; }
.chat-message.user li { margin-bottom: 0.25rem; }
.chat-message.user li:last-child { margin-bottom: 0; }
.chat-message.user strong { font-weight: 600; }

.chat-message__time {
  display: block;
  font-size: 0.65rem;
  margin-top: 0.35rem;
  text-align: right;
  opacity: 0.55;
}

.chat-message.typing {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
}

.chat-message.typing .dot {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: cw-bounce 1.4s infinite ease-in-out;
}
.chat-message.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-message.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cw-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.chat-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--card-border-color, #e5e7eb);
  background: #f9fafb;
}

.message-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.message-form .message-input {
  flex: 1;
  width: auto;
  min-width: 0;
  padding: 0.6rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  margin-bottom: 0rem !important;
}

.message-form .message-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.message-form .send-button {
  flex-shrink: 0;
  width: 36px !important;
  height: 36px;
  padding: 0;
  background: #3b82f6;
  color: var(--color-fg-on-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  margin-bottom: 0rem !important;
}

.message-form .send-button:hover { background: #4338ca; }
.message-form .send-button:active { transform: scale(0.95); }
.message-form .message-input:disabled { opacity: 0.6; cursor: not-allowed; }
.message-form .send-button:disabled { opacity: 0.6; cursor: not-allowed; background: #93c5fd !important; width: 36px !important; }

.chat-completion {
  padding: 2rem;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   Error Page
   ═══════════════════════════════════════════════════════════════ */

.error-page {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  max-width: 480px;
  margin: 0 auto;
}

.error-page__icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
}

.error-page__status {
  font-size: 4rem;
  font-weight: 700;
  color: var(--color-muted, #6b7280);
  margin: 0 0 var(--space-2);
  line-height: 1;
}

.error-page__title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 var(--space-3);
  color: var(--color-text, #1f2937);
}

.error-page__message {
  font-size: 1rem;
  color: var(--color-muted, #6b7280);
  margin: 0 0 var(--space-6);
  line-height: 1.6;
}

.error-page__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════════════ */
/* WORKOUT STEPS VISUALIZATION                                   */
/* ══════════════════════════════════════════════════════════════ */

/* Section wrapper */
.workout-steps-section {
  margin-top: var(--space-3, 0.75rem);
}

/* ─── Segmented summary bar ─── */
.workout-segmented-bar {
  display: flex;
  border-radius: var(--radius-full);
  overflow: hidden;
  height: 8px;
  gap: 2px;
  margin-bottom: var(--space-2, 0.5rem);
}

.workout-segmented-bar__segment {
  transition: flex-basis 0.3s ease, opacity 0.15s;
}

.workout-segmented-bar__segment:hover {
  opacity: 0.75;
}

/* ─── Segment colors ─── */
.segment--warmup   { background: #6ee7b7; }
.segment--steady   { background: #93c5fd; }
.segment--interval { background: #fca5a5; }
.segment--cooldown { background: #c4b5fd; }
.segment--strength { background: #fde68a; }
.segment--recovery { background: #5eead4; }
.segment--rest     { background: #d1d5db; }

/* ─── Legend row ─── */
.workout-segmented-legend {
  display: flex;
  gap: var(--space-2) var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-3, 0.75rem);
  font-size: var(--font-size-xs);
  color: var(--color-fg-secondary);
}

.workout-segmented-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.workout-segmented-legend__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Step card ─── */
.step-card {
  border-left: 3px solid;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 0 6px 6px 0;
}

.step-card summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  cursor: pointer;
}

.step-card summary::-webkit-details-marker {
  color: var(--color-muted, #9ca3af);
}

/* Non-expandable step */
.step-card--static {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-left: 3px solid;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 0 6px 6px 0;
}

/* ─── Step card color variants ─── */
.step-card--warmup     { border-color: #6ee7b7; background: #f0fdf4; }
.step-card--steady     { border-color: #93c5fd; background: #eff6ff; }
.step-card--interval   { border-color: #fca5a5; background: #fef2f2; }
.step-card--cooldown   { border-color: #c4b5fd; background: #f5f3ff; }
.step-card--strength   { border-color: #fde68a; background: #fffbeb; }
.step-card--recovery   { border-color: #5eead4; background: #f0fdfa; }
.step-card--rest       { border-color: #d1d5db; background: #f9fafb; }
.step-card--implied    { border-left-style: dashed; background: transparent; }

/* ─── Step type badge ─── */
.step-type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1.5;
}

.step-type-badge--warmup   { background: #d1fae5; color: #065f46; }
.step-type-badge--steady   { background: #dbeafe; color: #1e40af; }
.step-type-badge--interval { background: #fee2e2; color: #991b1b; }
.step-type-badge--cooldown { background: #ede9fe; color: #6b21a8; }
.step-type-badge--strength { background: #fef3c7; color: #92400e; }
.step-type-badge--recovery { background: #ccfbf1; color: #115e59; }
.step-type-badge--rest     { background: #f3f4f6; color: #374151; }

/* ─── Duration ─── */
.step-duration {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text, #1f2937);
  flex-shrink: 0;
}

/* ─── Detail text (exercise, sets, etc.) ─── */
.step-detail {
  font-size: 0.8rem;
  color: var(--color-muted, #6b7280);
}

/* ─── Target badge ─── */
.step-target {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--pico-muted-background, #f3f4f6);
  color: var(--color-muted, #6b7280);
  flex-shrink: 0;
  line-height: 1.5;
}

/* ─── Repeat count badge ─── */
.step-repeat {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary, #4f46e5);
  flex-shrink: 0;
}

/* ─── Commentary text ─── */
.step-commentary {
  display: block;
  font-size: 0.8rem;
  color: var(--color-muted, #6b7280);
  font-style: italic;
  padding-top: 0.5rem;
  line-height: 1.5;
}

/* ─── Substeps (repeat block children) ─── */
.workout-substeps-list {
  list-style: none;
  padding-left: var(--space-4, 1rem);
  margin: 0.5rem 0 0 0;
  border-left: 2px solid var(--border-color, #e5e7eb);
}

/* ─── Expand/collapse all toggle ─── */
.step-toggle-all {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--color-primary, #4f46e5);
  background: none;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.step-toggle-all:hover {
  background: var(--pico-muted-background, #f3f4f6);
}

/* ── Daily Check-in Widget ── */

.checkin-widget {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
}

.checkin-widget-prompt {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-fg-primary, #111);
  margin-bottom: var(--space-3);
}

.checkin-scales {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: var(--space-3);
}

.checkin-scale {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.checkin-scale-label {
  width: 156px;
  height: 28px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-fg-secondary, #555);
  white-space: nowrap;
}

.checkin-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
}

.checkin-dot {
  width: 28px;
  height: 28px;
  margin: 0;
  border: 2px solid var(--dot-color, var(--color-border, #ddd));
  border-radius: 50%;
  background: color-mix(in srgb, var(--dot-color, transparent) 10%, #fff);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.12s ease;
}

.checkin-dot[data-value="1"] { --dot-color: #ef4444; }
.checkin-dot[data-value="2"] { --dot-color: #f97316; }
.checkin-dot[data-value="3"] { --dot-color: #eab308; }
.checkin-dot[data-value="4"] { --dot-color: #84cc16; }
.checkin-dot[data-value="5"] { --dot-color: #22c55e; }

.checkin-dot:hover {
  background: color-mix(in srgb, var(--dot-color) 28%, #fff);
  transform: scale(1.15);
}

.checkin-dot.selected {
  background: var(--dot-color);
  border-color: var(--dot-color);
}

.checkin-dots-hints {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--color-text-muted, #888);
}

.checkin-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.checkin-save-btn {
  padding: 6px 16px;
  font-size: var(--font-size-sm);
}

.checkin-save-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.checkin-dismiss-link {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-decoration: none;
  padding: 0;
}

.checkin-dismiss-link:hover {
  color: var(--color-fg-secondary, #666);
}

/* ══════════════════════════════════════════════════════════════
   VISUAL REFRESH — Typography, section signatures, card hierarchy
   ══════════════════════════════════════════════════════════════ */

/* Space Grotesk for headings — geometric, precise, athletic */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

/* Keep nav brand in Inter so it stays compact */
.nav-brand a {
  font-family: 'Inter', system-ui, sans-serif;
}

/* Section title signature: left accent bar */
.dashboard-section > h2,
.evolution-section__title {
  position: relative;
  padding-left: 0.875rem;
}

.dashboard-section > h2::before,
.evolution-section__title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 3px;
  background: var(--color-primary);
  border-radius: 2px;
}

/* Card shadows — more depth, softer ambient shadow */
.card,
.card--today,
.card--health {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
}

.snapshot-card,
.pr-card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* PR cards — pace number reads as race data, not a greeting card */
.pr-card__trophy {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  opacity: 0.4;
}

.pr-card__pace {
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.pr-card__label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--color-primary);
  font-weight: 700;
}

/* Snapshot cards — left-border color coding instead of rainbow pastels */
.snapshot-card--readiness,
.snapshot-card--sleep,
.snapshot-card--health,
.snapshot-card--fatigue {
  background: #fff;
  border-left: 3px solid transparent;
}

.snapshot-card--readiness { border-left-color: var(--color-primary); }
.snapshot-card--sleep     { border-left-color: #6B9BB8; }
.snapshot-card--health    { border-left-color: var(--color-success); }
.snapshot-card--fatigue   { border-left-color: #C89B2A; }

.health-metric-num {
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

/* Calendar completed cells — reduce background noise; activity bars carry meaning */
.calendar-day--completed {
  background: rgba(5, 150, 105, 0.05);
  border-color: rgba(5, 150, 105, 0.3);
}

.calendar-day--completed:hover {
  background: rgba(5, 150, 105, 0.09);
  border-color: var(--color-success);
}

/* Week day label — tighter tracking */
.week-day .day-label {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}
