/* ==========================================================================
   我的運動歷程 — Modern Editorial Athletic Design System
   ========================================================================== */

:root {
  --bg: #f5f7fb;
  --bg-subtle: #eef2f8;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e5eaf2;
  --border-strong: #d1d9e6;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --primary-border: rgba(37, 99, 235, 0.25);

  --run: #10b981;
  --run-soft: rgba(16, 185, 129, 0.12);
  --bike-in: #f97316;
  --bike-in-soft: rgba(249, 115, 22, 0.12);
  --bike-out: #0284c7;
  --bike-out-soft: rgba(2, 132, 199, 0.12);
  --badminton: #8b5cf6;
  --badminton-soft: rgba(139, 92, 246, 0.12);
  --walk: #64748b;
  --walk-soft: rgba(100, 116, 139, 0.12);
  --rest: #06b6d4;
  --rest-soft: rgba(6, 182, 212, 0.1);
  --meal: #ec4899;
  --meal-soft: rgba(236, 72, 153, 0.12);

  --good: #059669;
  --good-soft: rgba(5, 150, 105, 0.12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --alert: #dc2626;
  --alert-soft: rgba(220, 38, 38, 0.12);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.07), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px -12px rgba(15, 23, 42, 0.18);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111827;
  --surface: #131c2e;
  --surface-elevated: #182338;
  --surface-hover: #1c2942;
  --border: #23314c;
  --border-strong: #324468;

  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --primary: #60a5fa;
  --primary-soft: rgba(96, 165, 250, 0.16);
  --primary-border: rgba(96, 165, 250, 0.32);

  --run: #34d399;
  --run-soft: rgba(52, 211, 153, 0.15);
  --bike-in: #fb923c;
  --bike-in-soft: rgba(251, 146, 60, 0.16);
  --bike-out: #38bdf8;
  --bike-out-soft: rgba(56, 189, 248, 0.16);
  --badminton: #a78bfa;
  --badminton-soft: rgba(167, 139, 250, 0.16);
  --walk: #94a3b8;
  --walk-soft: rgba(148, 163, 184, 0.15);
  --rest: #22d3ee;
  --rest-soft: rgba(34, 211, 238, 0.14);
  --meal: #f472b6;
  --meal-soft: rgba(244, 114, 182, 0.16);

  --good: #34d399;
  --good-soft: rgba(52, 211, 153, 0.15);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.15);
  --alert: #f87171;
  --alert-soft: rgba(248, 113, 113, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 28px -6px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { width: 17px; height: 17px; flex-shrink: 0; }

/* Header / Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark { width: 34px; height: 34px; }
.brand-mark svg { width: 100%; height: 100%; display: block; }

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.view-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.tab-btn:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s ease;
  font-size: 15px;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }

[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }

/* Container & Cards */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Hero Grid */
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
}

.goal-card {
  padding: 24px 26px;
  background:
    radial-gradient(600px circle at 100% 0%, color-mix(in srgb, var(--primary) 11%, transparent), transparent 60%),
    var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.goal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.kicker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-phase { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-alert { background: var(--alert-soft); color: var(--alert); }

.goal-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.28;
}

.countdown-box {
  flex-shrink: 0;
  text-align: center;
  background: linear-gradient(145deg, #2563eb, #0284c7);
  color: #ffffff;
  border-radius: 16px;
  padding: 12px 18px;
  min-width: 102px;
  box-shadow: 0 10px 20px -8px rgba(37, 99, 235, 0.55);
}

.countdown-num {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.countdown-label {
  font-size: 11.5px;
  opacity: 0.9;
  margin-top: 4px;
  font-weight: 600;
}

.goal-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.goal-meta-item .label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.goal-meta-item .value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.goal-baseline {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.secondary-goal-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.secondary-goal-strip strong { color: var(--text); }

/* Fitness Card */
.fitness-card {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.fitness-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
}

.kpi-box .kpi-name {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-box .kpi-val {
  font-size: 20px;
  font-weight: 800;
  margin-top: 3px;
  letter-spacing: -0.02em;
}

.kpi-box .kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.week-tss-progress {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
}

.progress-head strong { font-size: 15px; color: var(--text); }

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #10b981);
  transition: width 0.4s ease;
}

.trend-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trend-header {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
}

.trend-legend { display: flex; gap: 12px; }
.trend-legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }

.trend-svg { width: 100%; height: 64px; display: block; }

/* Coach Brief Banner */
.coach-brief {
  padding: 20px 24px;
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.coach-brief-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.coach-avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.coach-pill {
  background: var(--primary);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.coach-brief h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 750;
  letter-spacing: -0.015em;
}

.coach-brief p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.focus-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.focus-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 12.8px;
  color: var(--text-secondary);
}

/* Section Toolbar & Views */
.view-section { display: none; flex-direction: column; gap: 16px; }
.view-section.active { display: flex; }

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-title {
  margin: 0;
  min-width: 132px;
  text-align: center;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.btn-ghost {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.btn-pill {
  border: 1px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  margin-left: 6px;
}
.btn-pill:hover { background: var(--primary); color: #fff; }

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot-run { background: var(--run); }
.dot-bike-in { background: var(--bike-in); }
.dot-bike-out { background: var(--bike-out); }
.dot-badminton { background: var(--badminton); }
.dot-meal { background: var(--meal); }
.dot-plan { border: 1.5px dashed var(--primary); background: var(--primary-soft); }

/* Calendar Grid (7 days + Weekly Summary column) */
.calendar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) 136px;
}

.cal-head {
  padding: 11px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.cal-head:last-child { border-right: none; }

.cal-cell {
  min-height: 132px;
  padding: 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  transition: background 0.14s ease;
  position: relative;
}
.cal-cell:hover { background: var(--surface-hover); }
.cal-cell.outside { opacity: 0.44; background: color-mix(in srgb, var(--bg-subtle) 55%, transparent); }
.cal-cell.today {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
  box-shadow: inset 0 0 0 2px var(--primary);
}
.cal-cell.race-day {
  background: color-mix(in srgb, var(--run) 9%, var(--surface));
  box-shadow: inset 0 0 0 2px var(--run);
}

.cal-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}

.cal-day-num {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cal-cell.today .cal-day-num {
  color: var(--primary);
  font-weight: 800;
}

.today-tag {
  font-size: 10px;
  background: var(--primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
}

.cal-day-tss {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.cal-event {
  border-radius: 8px;
  padding: 5px 7px;
  font-size: 11.5px;
  line-height: 1.3;
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-event.sport-running { background: var(--run-soft); border-left-color: var(--run); }
.cal-event.sport-cycling_indoor { background: var(--bike-in-soft); border-left-color: var(--bike-in); }
.cal-event.sport-cycling_outdoor { background: var(--bike-out-soft); border-left-color: var(--bike-out); }
.cal-event.sport-badminton { background: var(--badminton-soft); border-left-color: var(--badminton); }
.cal-event.sport-walking { background: var(--walk-soft); border-left-color: var(--walk); }
.cal-event.sport-rest { background: var(--rest-soft); border-left-color: var(--rest); }

.cal-event.is-plan {
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-left: 3px dashed var(--primary);
}

.cal-event-title {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-event-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.grade-mini {
  font-size: 10px;
  font-weight: 800;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.cal-week-col {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-subtle) 65%, var(--surface));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.week-tss-big {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

.week-tss-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.week-note-mini {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.38;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* List View */
.list-toolbar { gap: 12px; }

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text); }
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-selects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.select-input {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
}

.list-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.week-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.week-group-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.week-group-summary {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 760px;
}

.week-group-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.stat-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.workout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.workout-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.workout-card.is-planned-only {
  border-style: dashed;
  background: color-mix(in srgb, var(--primary) 2.5%, var(--surface));
}

.wc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.wc-left {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.sport-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.sport-badge.sport-running { background: var(--run-soft); color: var(--run); }
.sport-badge.sport-cycling_indoor { background: var(--bike-in-soft); color: var(--bike-in); }
.sport-badge.sport-cycling_outdoor { background: var(--bike-out-soft); color: var(--bike-out); }
.sport-badge.sport-badminton { background: var(--badminton-soft); color: var(--badminton); }
.sport-badge.sport-walking { background: var(--walk-soft); color: var(--walk); }
.sport-badge.sport-rest { background: var(--rest-soft); color: var(--rest); }

.wc-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wc-title {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 750;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tss-compare {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tss-box {
  text-align: right;
  padding: 6px 12px;
  border-radius: 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.tss-box .tss-num { font-size: 17px; font-weight: 800; line-height: 1.1; }
.tss-box .tss-lbl { font-size: 11px; color: var(--text-muted); font-weight: 600; }

.tss-box.planned { border-style: dashed; background: var(--primary-soft); border-color: var(--primary-border); }
.tss-box.planned .tss-num { color: var(--primary); }

.metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-subtle);
  font-size: 13px;
}

.metric-item { display: inline-flex; align-items: baseline; gap: 5px; }
.metric-item .m-lbl { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.metric-item .m-val { font-weight: 700; color: var(--text); }

.review-box {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.grade-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
}
.grade-badge.grade-S { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.grade-badge.grade-A { background: #10b981; }

.review-verdict { font-size: 14px; font-weight: 750; color: var(--text); }
.review-summary { margin: 0; font-size: 13.5px; color: var(--text-secondary); }

.wc-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.action-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
  cursor: pointer;
}
.btn-link:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.btn-link.intervals {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}
.btn-link.intervals:hover { background: var(--primary); color: #fff; }

.btn-link.trainerday {
  border-color: rgba(249, 115, 22, 0.35);
  background: var(--bike-in-soft);
  color: var(--bike-in);
}
.btn-link.trainerday:hover { background: var(--bike-in); color: #fff; }

/* Cycling Workout Library */
.section-heading { margin: 0; font-size: 19px; font-weight: 800; }
.section-desc { margin: 4px 0 0; font-size: 13.5px; color: var(--text-secondary); }

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 18px;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tpl-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.tpl-title { margin: 4px 0 2px; font-size: 19px; font-weight: 800; }
.tpl-sub { margin: 0; font-size: 13px; color: var(--text-secondary); }

.profile-chart-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 8px;
}

.profile-svg { width: 100%; height: 106px; display: block; }

.zone-bar {
  display: flex;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  gap: 2px;
}

.zone-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
}

.structure-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-box {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--bg-subtle);
  font-size: 12.5px;
  flex-wrap: wrap;
}

/* Detail Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 60;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 70;
  display: flex;
  flex-direction: column;
}
.detail-drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-kicker { font-size: 12px; font-weight: 700; color: var(--primary); }
.drawer-title { margin: 2px 0 0; font-size: 19px; font-weight: 800; }

.drawer-body {
  padding: 18px 22px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-section {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-section h4 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
}

.bullet-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.wellness-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.w-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.w-mini .wl { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.w-mini .wv { font-size: 15px; font-weight: 800; margin-top: 2px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.footer {
  text-align: center;
  padding: 18px 20px 36px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loading-box {
  padding: 28px 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* Secondary Goal & Weight / Nutrition Progress */
.secondary-goals-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
}

.secondary-goal-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.secondary-goal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-goal-row strong { color: var(--text); }

.weight-nutrition-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.mini-progress-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mini-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--text-muted);
  gap: 6px;
}

.mini-progress-top strong {
  font-size: 13.5px;
  color: var(--text);
}

.mini-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.mini-fill-weight {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0ea5e9, #10b981);
}

.mini-fill-meal {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ec4899, #f97316);
}

/* Calendar Meal Pill */
.cal-meal-pill {
  margin-top: auto;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--meal-soft);
  color: var(--meal);
  display: flex;
  justify-content: space-between;
  gap: 4px;
  white-space: nowrap;
}

/* Meals View */
.meals-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.meal-day-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-day-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meal-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.meal-day-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
}

.macro-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  gap: 2px;
  background: var(--border);
}

.macro-p { background: #10b981; }
.macro-c { background: #3b82f6; }
.macro-f { background: #f59e0b; }

.meals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}

.meal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.meal-photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg-subtle);
  overflow: hidden;
  cursor: zoom-in;
}

.meal-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.22s ease;
}

.meal-photo-wrap:hover img { transform: scale(1.03); }

.meal-type-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(15, 23, 42, 0.76);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.meal-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.meal-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.meal-card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 750;
}

.meal-kcal-badge {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 9px;
  background: var(--meal-soft);
  color: var(--meal);
}

.meal-macros-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.meal-items-list {
  list-style: none;
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}

.meal-items-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-secondary);
}

.meal-ai-note {
  margin: 0;
  font-size: 12.8px;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
  border-left: 3px solid var(--primary);
  padding: 7px 10px;
  border-radius: 0 8px 8px 0;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 28, 0.88);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  z-index: 100;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: min(92vw, 960px);
  max-height: 78vh;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.lightbox-caption {
  color: #e2e8f0;
  font-size: 14px;
  text-align: center;
}

@media (max-width: 720px) {
  .weight-nutrition-strip { grid-template-columns: 1fr; }
  .meals-grid { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 1120px) {
  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .brand-subtitle { display: none; }
  .tab-btn { padding: 6px 11px; font-size: 13px; }
}

@media (max-width: 1024px) {
  .hero-grid { grid-template-columns: 1fr; }
  .focus-pills { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-head-week, .cal-week-col { display: none; }
}

@media (max-width: 720px) {
  .topbar-inner { padding: 10px 14px; }
  .container { padding: 14px 14px 36px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wellness-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-grid { grid-template-columns: 1fr; }
  .cal-cell { min-height: 92px; padding: 5px; }
  .cal-event { padding: 3px 5px; font-size: 10.5px; }
  .goal-header { flex-direction: column; }
  .countdown-box { width: 100%; display: flex; align-items: baseline; justify-content: center; gap: 10px; padding: 10px 14px; }
}
