/* iOS-Look (Liquid Glass, iOS 26+) — translucente Materialien, SF-Typo, Systemfarben */
:root {
  --bg:          #F2F2F7;                     /* systemGroupedBackground */
  --surface:     rgba(255,255,255,0.78);      /* Glass-Material */
  --surface-op:  #FFFFFF;                     /* opake Variante (Popups, Menüs) */
  --surface-2:   rgba(120,120,128,0.10);      /* iOS Fill */
  --fill:        rgba(120,120,128,0.14);
  --border:      rgba(60,60,67,0.14);         /* Hairline */
  --border-2:    rgba(60,60,67,0.08);
  --text-1:      #1C1C1E;
  --text-2:      rgba(60,60,67,0.62);
  --text-3:      rgba(60,60,67,0.36);
  --accent:      #FF3B30;                     /* systemRed */
  --accent-dk:   #D70015;
  --tint:        #007AFF;                     /* systemBlue — interaktive Elemente */
  --blue:        #007AFF;
  --blue-dk:     #0062CC;
  --blue-lt:     rgba(0,122,255,0.12);
  --green:       #34C759;
  --green-lt:    rgba(52,199,89,0.12);
  --teal:        #30B0C7;
  --teal-lt:     rgba(48,176,199,0.12);
  --orange:      #FF9500;
  --orange-lt:   rgba(255,149,0,0.12);
  --red:         #FF3B30;
  --red-lt:      rgba(255,59,48,0.12);
  --shadow:      0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-md:   0 2px 6px rgba(0,0,0,0.06), 0 16px 40px rgba(0,0,0,0.12);
  --blur:        saturate(180%) blur(22px);
  --r:           12px;                        /* kleine Elemente */
  --r-card:      20px;                        /* Karten (continuous corners) */
  --r-pill:      999px;
}

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

html { font-size: 16px; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
               'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
}

/* Hintergrund-Gradient als fixe Ebene — background-attachment: fixed
   funktioniert auf iOS Safari nicht (Scroll-Jank / wird ignoriert) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(0,122,255,0.10), transparent 60%),
    radial-gradient(1000px 700px at -10% 30%, rgba(255,59,48,0.07), transparent 55%),
    radial-gradient(900px 700px at 60% 110%, rgba(48,176,199,0.08), transparent 60%);
}

button, .btn, .rpe-dot, .filter-chip, .chart-tab, .zoom-chip, .burger-item {
  touch-action: manipulation;
}

/* ── LOGIN ─────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 0.5px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-md);
  padding: 56px 48px 48px;
  width: 380px;
  text-align: center;
}

.login-logo {
  width: 40px;
  height: 48px;
  margin: 0 auto 24px;
  display: block;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.login-sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 40px;
}

#google-btn-container {
  display: flex;
  justify-content: center;
}

/* ── HEADER ─────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: calc(60px + env(safe-area-inset-top, 0px));
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px)
           calc(24px + env(safe-area-inset-right, 0px))
           0
           calc(24px + env(safe-area-inset-left, 0px));
  overflow: visible;
}

/* ── BURGER MENU ─────────────────────────────────── */
.burger-anchor {
  position: relative;
}

#burger-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface-op);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  min-width: 210px;
  z-index: 400;
  display: none;
  box-shadow: var(--shadow-md);
}
#burger-menu.open { display: block; }

.burger-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  color: var(--text-1);
  user-select: none;
  transition: background 0.12s;
}
.burger-item:hover { background: var(--fill); }
.burger-state { font-size: 11px; font-weight: 500; color: var(--text-2); }
.burger-actions { display: flex; gap: 6px; padding: 4px; }
.burger-act {
  flex: 1;
  padding: 7px 10px;
  border: 0.5px solid var(--border);
  border-radius: 9px;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  cursor: pointer;
  white-space: nowrap;
}
.burger-act:hover { background: var(--fill); }
#burger-menu { max-height: min(70vh, 560px); overflow-y: auto; min-width: 250px; }
.burger-divider {
  height: 0.5px;
  background: var(--border);
  margin: 5px 8px;
}

/* ── CHAT FAB ────────────────────────────────────── */

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
}

.logo-icon {
  width: 20px;
  height: 24px;
  display: block;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

/* ── LAYOUT ─────────────────────────────────────── */
.main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 56px;
  padding-right: calc(360px + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── CARDS ─────────────────────────────────────── */
.card {
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 0.5px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 0.5px solid var(--border-2);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-1);
}

.card-body { padding: 16px 20px; }

/* ── METRIC CARDS ─────────────────────────────── */
.metrics-row {
  display: grid;
  /* 5 Spalten auf großen Bildschirmen: zwei saubere Reihen
     (HRV · RHR · Schlaf×2 · Readiness / Body Battery×2 · VO2max · Gewicht · Wetter).
     "dense" füllt Lücken, die durch die breiten Kacheln entstehen. */
  /* Desktop: 6 kompakte Kacheln in einer Reihe, darunter Schlaf + Body Battery je halbe Breite */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-flow: row dense;
  gap: 12px;
}
.metric { min-width: 0; }

/* Wetter-Kachel: kompakt, gleiche Höhe wie die anderen Vitalwerte */
.metric-weather .wx-now { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.metric-weather .wx-icon { font-size: 26px; line-height: 1; }
.metric-weather .metric-val { margin-bottom: 0; }
.metric-weather .metric-sub,
.metric-weather .metric-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-fc { display: flex; gap: 6px; margin-top: 8px; }
.wx-day {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 2px; border-radius: 8px; background: var(--fill);
  font-size: 10px; line-height: 1.25; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.wx-day-name { font-weight: 600; color: var(--text-1); }

/* Belastung & Verletzungsschutz */
.ls-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; padding: 4px 16px 16px;
}
.ls-tile { min-width: 0; display: flex; flex-direction: column; gap: 6px;
           padding: 12px; border-radius: 12px; background: var(--surface-2); }
.ls-head { display: flex; align-items: baseline; gap: 8px; }
.ls-head .metric-val { margin: 0; font-size: 30px; }
.ls-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--fill); color: var(--text-2); }
.ls-chip.good { color: var(--green); } .ls-chip.warn { color: var(--orange); } .ls-chip.bad { color: var(--red); }
.ls-bar { position: relative; height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.ls-band { position: absolute; top: 0; bottom: 0; background: rgba(142,142,147,0.35); }
.ls-fill { position: relative; height: 100%; border-radius: 4px; background: var(--blue); opacity: 0.9; }
.ls-fill.good { background: var(--green); } .ls-fill.warn { background: var(--orange); } .ls-fill.bad { background: var(--red); }
.ls-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-2); margin-top: 2px; }
.ls-num { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-1); }
.ls-num.good { color: var(--green); } .ls-num.warn { color: var(--orange); } .ls-num.bad { color: var(--red); }
.ls-spark { position: relative; height: 54px; display: flex; align-items: flex-end; gap: 4px; margin: 4px 0; }
.ls-spark-line { position: absolute; left: 0; right: 0; bottom: 66.6%; border-top: 1px dashed var(--text-3); }
.ls-spark-bar { flex: 1 1 0; border-radius: 3px 3px 0 0; background: var(--green); opacity: 0.85; }
.ls-spark-bar.warn { background: var(--orange); } .ls-spark-bar.bad { background: var(--red); }
@media (max-width: 1200px) { .ls-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .ls-grid { grid-template-columns: 1fr; padding: 4px 12px 12px; } }
.wx-day-icon { font-size: 13px; }
.wx-day-rain { color: var(--blue); }

/* Body Battery — große Karte mit Ladebalken */
.metric-battery { grid-column: span 3; }
.metric-battery .metric-val { font-size: 44px; margin-bottom: 0; }
.bb-big {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 6px 0 8px;
}
.bb-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--text-2);
  padding-bottom: 4px;
  white-space: nowrap;
}
.bb-stats b { color: var(--text-1); font-weight: 600; }
.bb-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--fill);
  overflow: hidden;
  margin-bottom: 6px;
}
.bb-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--green);
  transition: width 0.4s ease;
}
.bb-fill.warn { background: var(--orange); }
.bb-fill.bad  { background: var(--red); }

/* Schlaf-Karte (analog Body Battery, span 2) */
.metric-sleep { grid-column: span 3; }
.metric-sleep .metric-val { font-size: 44px; margin-bottom: 0; }
.sl-trend { font-size: 13px; font-weight: 600; margin-left: 6px; vertical-align: middle; }
.sl-trend.up   { color: var(--green); }
.sl-trend.down { color: var(--red); }
.sl-trend.flat { color: var(--text-2); }
.sleep-bar {
  display: flex; height: 10px; border-radius: 5px;
  background: var(--fill); overflow: hidden; margin: 10px 0 8px;
}
.sleep-bar .seg { height: 100%; }
.sleep-bar .seg-deep  { background: #007AFF; }
.sleep-bar .seg-rem   { background: #5E5CE6; }
.sleep-bar .seg-light { background: #30B0C7; }
.sleep-bar .seg-awake { background: #FF9500; }
.sleep-legend {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 12px; color: var(--text-2); margin-bottom: 4px;
}
.sleep-legend .sl-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  margin-right: 5px; vertical-align: middle;
}
.sl-dot.deep  { background: #007AFF; }
.sl-dot.rem   { background: #5E5CE6; }
.sl-dot.light { background: #30B0C7; }
.sl-dot.awake { background: #FF9500; }
.sleep-rows {
  margin-top: 9px; padding-top: 8px;
  border-top: 1px solid var(--border, rgba(60,60,67,0.12));
  display: flex; flex-direction: column; gap: 6px;
}
.sleep-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.sleep-k { color: var(--text-2); flex: 0 0 auto; }
.sleep-v { color: var(--text-1); text-align: right; font-weight: 500; }

.metric {
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 0.5px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  position: relative;
  cursor: default;
  overflow: hidden;
}

.metric::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
}

.metric.good::after { background: var(--green); }
.metric.warn::after { background: var(--orange); }
.metric.bad::after  { background: var(--red); }

.metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 8px;
}

.metric-val {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-1);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.metric-val.good { color: var(--green); }
.metric-val.warn { color: var(--orange); }
.metric-val.bad  { color: var(--red); }

.metric-unit {
  display: inline;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-2);
}

.metric-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
  line-height: 1.4;
}

.metric-rec {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  margin-top: 5px;
  line-height: 1.3;
}

/* ── RPE ─────────────────────────────────────────── */
.rpe-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 0.5px solid var(--border-2);
  flex-wrap: wrap;
}

.rpe-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-right: 4px;
}

.rpe-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--fill);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
  padding: 0;
}

.rpe-dot:hover { background: var(--surface-2); color: var(--text-1); transform: scale(1.08); }
.rpe-dot.active[data-rpe="1"],.rpe-dot.active[data-rpe="2"],.rpe-dot.active[data-rpe="3"] { background: var(--green); color: #fff; }
.rpe-dot.active[data-rpe="4"],.rpe-dot.active[data-rpe="5"],.rpe-dot.active[data-rpe="6"] { background: var(--orange); color: #fff; }
.rpe-dot.active[data-rpe="7"],.rpe-dot.active[data-rpe="8"],.rpe-dot.active[data-rpe="9"] { background: var(--accent); color: #fff; }
.rpe-dot.active[data-rpe="10"] { background: var(--accent-dk); color: #fff; }

.rpe-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  background: var(--fill);
  border: none;
  color: var(--text-2);
  vertical-align: middle;
  margin-left: 5px;
}

/* skeleton */
.sk {
  background: linear-gradient(90deg, rgba(120,120,128,0.10) 25%, rgba(120,120,128,0.18) 50%, rgba(120,120,128,0.10) 75%);
  background-size: 200% 100%;
  animation: sk 1.4s ease infinite;
  border-radius: 8px;
  color: transparent;
  user-select: none;
}

@keyframes sk {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── CHARTS ROW ─────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
}

.chart-legend {
  display: flex;
  gap: 16px;
}

.legend-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.legend-dot::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ── BOTTOM ROW ─────────────────────────────────── */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

/* ── TRAININGSKALENDER ───────────────────────────── */
.cal-card { overflow-x: auto; }

.cal-grid {
  padding: 10px 18px 18px;
}

.cal-head-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr) 48px;
  gap: 4px;
  margin-bottom: 4px;
}

.cal-day-head {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-3);
  padding-bottom: 4px;
}

.cal-week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr) 48px;
  gap: 4px;
  margin-bottom: 4px;
}

.cal-week-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding-left: 8px;
  gap: 3px;
}

.cal-week-hours {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.cal-week-sports {
  display: flex;
  gap: 2px;
}

.cal-week-sport-bar {
  height: 3px;
  border-radius: 2px;
  min-width: 4px;
}

.cal-cell {
  border: none;
  border-radius: 10px;
  padding: 5px 4px 6px;
  min-height: 52px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
}

.cal-cell.cal-today {
  box-shadow: 0 0 0 2px var(--tint) inset;
}

.cal-cell.cal-out {
  background: transparent;
}

.cal-cell.cal-future {
  background: var(--surface-2);
  opacity: 0.4;
}

.cal-date {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.cal-today .cal-date { color: var(--tint); font-weight: 700; }

.cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.cal-dot {
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.9;
  cursor: default;
}

/* Geplante Einheiten (TrainingPeaks → Garmin): Ring statt gefüllter Punkt */
.cal-dot.cal-planned {
  background: transparent;
  border: 2px dashed;
  box-sizing: border-box;
  cursor: pointer;
}
.cal-cell.cal-future.cal-has-plan { opacity: 1; }
.cal-week-plan {
  font-size: 9px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.plan-desc { font-size: 11px; color: var(--text-2); margin-top: 8px; white-space: pre-wrap; }
.plan-steps { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.plan-step {
  display: grid;
  grid-template-columns: 70px 60px 1fr;
  gap: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.plan-step-kind { color: var(--text-2); }
.plan-step-target { text-align: right; }
.plan-repeat { display: block; font-weight: 700; color: var(--blue); margin-top: 2px; }

/* ── CALENDAR MONTH HEADER ───────────────────────── */
.cal-month-header {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 14px 0 6px;
  border-top: 0.5px solid var(--border-2);
  margin-top: 4px;
}
.cal-month-header:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 2px;
}

/* ── ACTIVITIES ─────────────────────────────────── */
.act-item {
  display: grid;
  grid-template-columns: 38px 1fr auto 14px;
  gap: 14px;
  align-items: center;
  padding: 13px 20px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 0.5px solid var(--border-2);
}

.act-item:last-child { border-bottom: none; }
.act-item:hover { background: var(--surface-2); }

.act-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.act-icon.run  { background: var(--orange-lt); color: var(--orange); }
.act-icon.ride { background: var(--blue-lt);   color: var(--blue); }
.act-icon.swim { background: var(--teal-lt);   color: var(--teal); }

.act-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.act-meta {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

.act-stats {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.6;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.interval-chip {
  display: inline-flex;
  align-items: center;
  background: var(--blue-lt);
  color: var(--blue);
  border-radius: var(--r-pill);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Activity chevron ────────────────────────────── */
.act-chevron {
  font-size: 11px;
  color: var(--text-3);
  transition: transform 0.2s;
  line-height: 1;
  user-select: none;
}
.act-chevron.open { transform: rotate(180deg); }

/* ── Activity detail panel ───────────────────────── */
.act-detail {
  display: none;
  background: var(--surface-2);
  border-bottom: 0.5px solid var(--border-2);
  padding: 16px 20px 20px;
}
.act-detail.open { display: block; }

.detail-extra-stats {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 0.5px solid var(--border-2);
}

.detail-cols {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.detail-col {
  flex: 1;
  min-width: 200px;
}

/* ── Laps / Splits table ─────────────────────────── */
.laps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.laps-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: left;
  padding: 3px 8px;
}

.laps-table td {
  padding: 6px 8px;
  border-top: 0.5px solid var(--border-2);
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

.lap-hidden { display: none; }
.splits-wrapper.show-all .lap-hidden { display: table-row; }

.lap-show-more {
  margin-top: 10px;
  font-size: 12px;
  padding: 6px 14px;
  display: block;
}

/* ── Zone bars ───────────────────────────────────── */
.zones-group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 10px;
}

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

.zone-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  width: 20px;
  flex-shrink: 0;
}

.zone-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--fill);
  border-radius: 3px;
  overflow: hidden;
}

.zone-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.zone-time {
  font-size: 11px;
  color: var(--text-3);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.zone-range {
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}

.zones-ftp-note {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-2);
}

/* ── CHAT ────────────────────────────────────────── */
.chat-card {
  position: fixed;
  top: calc(60px + env(safe-area-inset-top, 0px));
  right: 0;
  bottom: 0;
  width: 360px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-left: 0.5px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}

.chat-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 86%;
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
}

.msg.user {
  background: var(--tint);
  color: #fff;
  align-self: flex-end;
  font-weight: 400;
  border-bottom-right-radius: 6px;
}

.msg.coach {
  background: var(--fill);
  color: var(--text-1);
  align-self: flex-start;
  border: none;
  border-bottom-left-radius: 6px;
}

.msg.coach h2, .msg.coach h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 4px;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.msg.coach ul, .msg.coach ol {
  padding-left: 18px;
  margin: 4px 0;
}

.msg.coach li { margin: 2px 0; }

.msg.coach code {
  background: rgba(120,120,128,0.16);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
}

.msg.coach strong { font-weight: 600; }

.msg.coach table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 6px 0;
}

.msg.coach td, .msg.coach th {
  border: 0.5px solid var(--border);
  padding: 4px 8px;
}

.msg.coach th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-2);
}

.msg.typing {
  background: var(--fill);
  color: var(--text-3);
  align-self: flex-start;
  font-style: italic;
  border: none;
  border-bottom-left-radius: 6px;
}

.msg-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  margin: auto;
}

.chat-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 0.5px solid var(--border-2);
  flex-wrap: wrap;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 14px;
  border-top: 0.5px solid var(--border);
}

.chat-input {
  flex: 1;
  border: 0.5px solid var(--border);
  border-radius: 18px;
  padding: 9px 14px;
  font-size: 16px;   /* ≥16px verhindert iOS-Safari-Auto-Zoom beim Fokussieren */
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 88px;
  line-height: 1.4;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
  color: var(--text-1);
}

.chat-input::placeholder { color: var(--text-3); }
.chat-input:focus { border-color: var(--tint); background: transparent; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--tint);
  color: #fff;
  padding: 10px 20px;
}

.btn-primary:hover { background: var(--blue-dk); }
.btn-primary:disabled { opacity: 0.35; cursor: default; }

.btn-ghost {
  background: var(--fill);
  color: var(--tint);
  border: none;
  font-size: 12px;
  padding: 6px 13px;
}

.btn-ghost:hover { background: rgba(120,120,128,0.22); }

.btn-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--tint);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  padding: 0;
}

.btn-send:hover { background: var(--blue-dk); }
.btn-send:disabled { opacity: 0.35; cursor: default; }

/* ── MIC + IMAGE BUTTONS ─────────────────────────────── */
.btn-mic, .btn-input-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--fill);
  border: none;
  color: var(--text-2);
  flex-shrink: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-mic:hover, .btn-input-icon:hover {
  background: rgba(120,120,128,0.22);
  color: var(--text-1);
}
.btn-mic.recording {
  background: var(--accent);
  color: #fff;
  animation: pulse-mic 1s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(255,59,48,0); }
}

/* ── METRIC CARD ACTIVE STATE ───────────────────── */
.metric.active {
  box-shadow: 0 0 0 2px var(--tint) inset, var(--shadow);
  cursor: pointer;
}

.metric.clickable { cursor: pointer; }
.metric.clickable:hover { box-shadow: 0 0 0 1.5px var(--border) inset, var(--shadow-md); }

/* ── FILTER CHIPS ────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 5px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: var(--fill);
  color: var(--text-2);
  transition: all 0.15s;
}

.filter-chip:hover { color: var(--text-1); }

.filter-chip.active {
  background: var(--text-1);
  color: var(--bg);
}

.filter-chip.run.active   { background: var(--orange); color: #fff; }
.filter-chip.ride.active  { background: var(--blue);   color: #fff; }
.filter-chip.swim.active  { background: var(--teal);   color: #fff; }

/* ── CHART NAV (prev/next week/month) ────────────── */
.vol-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-nav {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.btn-nav:disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

/* ── LOADED-AT ────────────────────────────────────── */
.loaded-at {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

/* ── CHART TOGGLE TAB ────────────────────────────── */
.chart-tab-bar {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.chart-tab {
  padding: 4px 11px;
  white-space: nowrap;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
}

.chart-tab:hover { color: var(--text-1); }
.chart-tab.active {
  background: var(--fill);
  color: var(--text-1);
}

/* ── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── MOBILE CHAT FAB ─────────────────────────────── */
#chat-fab {
  display: none;
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  z-index: 500;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background: var(--tint);
  color: #fff;
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  box-shadow: 0 6px 20px rgba(0,122,255,0.4);
}
#chat-fab:hover { background: var(--blue-dk); transform: scale(1.06); }

#chat-backdrop { display: none; }

#btn-chat-close { display: none; }

/* ── CALENDAR POPUP ─────────────────────────────── */
#cal-popup-bd {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 590;
}
#cal-popup-bd.open { display: block; }

#cal-popup {
  display: none;
  position: fixed;
  z-index: 600;
  background: var(--surface-op);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  width: 260px;
  box-shadow: var(--shadow-md);
}
#cal-popup.open { display: block; }

.cal-popup-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.cal-popup-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.cal-popup-icon.run  { background: var(--orange-lt); color: var(--orange); }
.cal-popup-icon.ride { background: var(--blue-lt);   color: var(--blue); }
.cal-popup-icon.swim { background: var(--teal-lt);   color: var(--teal); }

.cal-popup-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}
.cal-popup-date {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.cal-popup-stats {
  border-top: 0.5px solid var(--border-2);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-popup-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.cal-popup-stat-lbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
}
.cal-popup-stat-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

/* ── CP MINI PILLS ───────────────────────────────── */
.cp-pill {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: none;
  border-radius: 14px;
  min-width: 72px;
}
.cp-pill-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}
.cp-pill-val {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.cp-pill-sub {
  font-size: 10px;
  color: var(--text-3);
}

/* ── ROUTE CANVAS ────────────────────────────────────── */
.route-col { flex: 0 0 auto; }
.route-canvas {
  display: block;
  border: 0.5px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface-2);
}

/* ── DARK MODE ───────────────────────────────────────── */
body.dark {
  --bg:         #000000;
  --surface:    rgba(28,28,30,0.72);
  --surface-op: #1C1C1E;
  --surface-2:  rgba(120,120,128,0.18);
  --fill:       rgba(120,120,128,0.24);
  --border:     rgba(84,84,88,0.60);
  --border-2:   rgba(84,84,88,0.32);
  --text-1:     #FFFFFF;
  --text-2:     rgba(235,235,245,0.60);
  --text-3:     rgba(235,235,245,0.30);
  --accent:     #FF453A;
  --accent-dk:  #D70015;
  --tint:       #0A84FF;
  --blue:       #0A84FF;
  --blue-dk:    #409CFF;
  --blue-lt:    rgba(10,132,255,0.18);
  --green:      #30D158;
  --green-lt:   rgba(48,209,88,0.16);
  --teal:       #40C8E0;
  --teal-lt:    rgba(64,200,224,0.16);
  --orange:     #FF9F0A;
  --orange-lt:  rgba(255,159,10,0.16);
  --red:        #FF453A;
  --red-lt:     rgba(255,69,58,0.16);
  --shadow:     0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
  --shadow-md:  0 2px 6px rgba(0,0,0,0.4), 0 16px 40px rgba(0,0,0,0.55);
}
body.dark::before {
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(10,132,255,0.14), transparent 60%),
    radial-gradient(1000px 700px at -10% 30%, rgba(255,69,58,0.09), transparent 55%),
    radial-gradient(900px 700px at 60% 110%, rgba(64,200,224,0.10), transparent 60%);
}
body.dark .sk {
  background: linear-gradient(90deg, rgba(120,120,128,0.18) 25%, rgba(120,120,128,0.30) 50%, rgba(120,120,128,0.18) 75%);
  background-size: 200% 100%;
  animation: sk 1.4s ease infinite;
}
body.dark .btn-send { background: var(--tint); color: #fff; }
body.dark .btn-send:hover { background: var(--blue-dk); }
body.dark .filter-chip.active { background: #fff; color: #000; }
body.dark .filter-chip.run.active  { background: var(--orange); color: #000; }
body.dark .filter-chip.ride.active { background: var(--blue);   color: #fff; }
body.dark .filter-chip.swim.active { background: var(--teal);   color: #000; }
body.dark .chart-tab.active { background: rgba(99,99,102,0.9); color: #fff; }

/* ── HEALTH LOG SELECT ───────────────────────────────── */
.log-select {
  flex: 1;
  min-width: 120px;
  padding: 6px 12px;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

/* ── PREDICTOR ───────────────────────────────────────── */
.pred-group { min-width: 120px; }
.pred-sport {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-2); margin-bottom: 8px;
}
.pred-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin-bottom: 4px;
}
.pred-label { font-size: 13px; color: var(--text-2); }
.pred-val   { font-size: 14px; font-weight: 600; color: var(--text-1); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 1200px) {
  .metrics-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Tablet (769–1100 px): Chat nicht mehr als feste 360-px-Spalte — die ließ dem
   Dashboard auf einem iPad hochkant nur ~460 px. Stattdessen wie am Handy:
   Button unten rechts, Chat als Sheet von unten. */
@media (min-width: 769px) and (max-width: 1100px) {
  .main { padding-right: calc(24px + env(safe-area-inset-right, 0px)); padding-bottom: 96px; }
  .metrics-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat-card { display: none; }
  #chat-fab { display: flex; }
  body.chat-open #chat-fab { display: none; }
  body.chat-open #chat-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    z-index: 998;
  }
  body.chat-open .chat-card {
    display: flex !important;
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; max-height: 80dvh;
    border-radius: 20px 20px 0 0;
    border-left: none; border-top: 0.5px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 999;
  }
  body.chat-open .chat-msgs { min-height: 0; flex: 1; }
  body.chat-open #btn-chat-close { display: inline-flex; }
}

@media (max-width: 1000px) {
  /* große Karten untereinander, volle Breite */
  .metric-sleep, .metric-battery { grid-column: 1 / -1; }
}

/* Karten-Köpfe dürfen auch am Desktop umbrechen (sonst ragten z. B. die
   Sport-Filter beim Wochenvolumen über den Kartenrand) */
.card-head { flex-wrap: wrap; row-gap: 8px; }
.card-head > div { flex-wrap: wrap; min-width: 0; }

/* Verlaufs-Tabs: eine Zeile, horizontal wischbar statt 4 Zeilen hoch */
.card-head > .chart-tab-bar {
  flex-wrap: nowrap; overflow-x: auto; max-width: 100%;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chart-tab-bar::-webkit-scrollbar { display: none; }
.chart-tab { white-space: nowrap; flex: 0 0 auto; }

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

@media (max-width: 768px) {
  .main {
    padding: 14px
             calc(14px + env(safe-area-inset-right, 0px))
             calc(96px + env(safe-area-inset-bottom, 0px))
             calc(14px + env(safe-area-inset-left, 0px));
    gap: 14px;
  }

  /* Smaller numbers on 2-col metric grid */
  .metric { padding: 14px 14px 12px; }
  .metric-val { font-size: 28px; }
  .metric-unit { font-size: 12px; }
  .metric-battery .metric-val { font-size: 34px; }

  /* Selects ≥16px gegen iOS-Auto-Zoom */
  .log-select { font-size: 16px; }

  /* Bigger touch targets for chips and tabs */
  .filter-chip { padding: 8px 13px; min-height: 36px; }
  .chart-tab   { padding: 7px 11px; min-height: 32px; }
  .btn-nav     { width: 36px; height: 36px; }

  /* Karten-Kopfzeilen: Titel + Controls brechen sauber in Reihen um
     (statt Quetschen/Scrollen) — gilt für Verlauf, Wochenvolumen,
     Power Curve, Zonen, Energiebilanz, Race-Plan, Kalender */
  .card-head {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 12px 14px 10px;
  }
  .card-head > div { flex-wrap: wrap; min-width: 0; }
  .filter-bar { flex-wrap: wrap; }

  /* Verlaufs-Tabs: eigene volle Zeile, wrappen in zwei Reihen */
  .chart-tab-bar { flex: 1 1 100%; }
  #section-pmc .card-head > div:last-child {
    flex: 1 1 100%;
    justify-content: space-between;
  }
  #section-pmc .chart-legend { gap: 10px; }

  /* Wochenvolumen & Energiebilanz: Controls unter den Titel,
     linksbündig in einer eigenen Reihe */
  #section-vol .card-head > div,
  #section-energy .card-head > div,
  #section-raceplan .card-head > div {
    flex: 1 1 100%;
  }
  #section-raceplan .log-select { max-width: 100%; min-width: 0; }

  /* Activities row less tight */
  .act-item { padding: 12px 14px; gap: 10px; }

  /* Chart touch area */
  #pmc-chart, #vol-chart { touch-action: pan-y; }

  .chat-card {
    position: static;
    width: auto;
    border-left: none;
    border: 0.5px solid var(--border);
    border-radius: var(--r-card);
    display: none;
    top: auto;
  }

  #chat-fab { display: flex; }
  body.chat-open #chat-fab { display: none; }

  body.chat-open #chat-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 998;
  }

  body.chat-open .chat-card {
    display: flex !important;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 88dvh;               /* dynamische Viewport-Höhe (iOS-Tastatur/URL-Leiste) */
    border-radius: 20px 20px 0 0;    /* iOS Sheet */
    border: none;
    border-top: 0.5px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 999;
  }

  body.chat-open .chat-msgs { min-height: 0; flex: 1; }
  body.chat-open #btn-chat-close { display: inline-flex; }

  .metrics-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .header-logo { white-space: nowrap; font-size: 15px; }
  .header-date { display: none; }
  .loaded-at   { display: none; }
  .btn-export-label { display: none; } /* mobil nur ⬇-Icon */

  /* Calendar: kein horizontales Scrollen — Wochenstunden bleiben sichtbar
     (eigene, volle Zeile unter der Woche statt ausgeblendet) */
  .cal-head-row   { grid-template-columns: repeat(7, 1fr); }
  .cal-week-row   { grid-template-columns: repeat(7, 1fr); }
  .cal-cell       { min-height: 40px; }
  .cal-week-label {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 3px 2px 7px;
    margin-bottom: 2px;
    border-bottom: 0.5px solid var(--border-2);
  }
  .cal-week-hours::before {
    content: "Woche ";
    color: var(--text-3);
    font-weight: 600;
  }
  .cal-week-sports { align-items: center; }
  .cal-week-sport-bar { height: 4px; }
}

/* ─── ZONEN-REFERENZ ─────────────────────────────────────── */
#zones-ref-anchors {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 20px 4px;
}
.zref-anchor {
  font-size: 12px; color: var(--text-2);
  background: var(--surface-2); border: none;
  border-radius: var(--r-pill); padding: 4px 10px;
}
.zref-anchor b { color: var(--text-1); font-weight: 600; }
#zones-ref-body { padding: 6px 14px 16px; }
.zref-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.zref-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-3); padding: 6px 8px; border-bottom: 0.5px solid var(--border);
}
.zref-table td {
  padding: 9px 8px; border-bottom: 0.5px solid var(--border-2);
  color: var(--text-1); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.zref-table tr:last-child td { border-bottom: none; }
.zref-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 7px; vertical-align: middle;
}
.zref-lbl { color: var(--text-2); font-size: 11px; margin-left: 4px; }
.zref-empty {
  padding: 24px; text-align: center; color: var(--text-2); font-size: 14px;
}

/* ─── CHART ZOOM-BRUSH (Zeitachse) ───────────────────────── */
.chart-brush {
  margin-top: 1px;
  opacity: 0.92;
}
.chart-brush .apexcharts-selection-rect {
  cursor: grab;
}

/* Zoom-Stufen (touch-freundlich, primär auf Mobile) */
.chart-zoom-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 2px 2px;
}
.zoom-lbl {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3); margin-right: 2px;
}
.zoom-chip {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: var(--fill); border: none;
  border-radius: var(--r-pill); padding: 5px 12px; cursor: pointer;
  user-select: none; line-height: 1.4;
  transition: all 0.15s;
}
.zoom-chip:hover { color: var(--text-1); }
.zoom-chip.active {
  color: #fff; background: var(--tint);
}

@media (max-width: 768px) {
  .zoom-chip { padding: 8px 14px; font-size: 13px; min-height: 34px; display: inline-flex; align-items: center; }
  .chart-zoom-bar { gap: 7px; padding-top: 8px; }
  .chart-brush { min-height: 64px; }   /* etwas mehr Griff-Fläche */
}

/* ─── WOCHENPLAN / MARATHON-PLAN ─────────────────────────── */
#weekplan-body { padding: 12px 18px 18px; }
.wp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
.wp-day {
  border: none;
  border-top: 4px solid var(--border);
  border-radius: 14px;
  padding: 9px 10px 11px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 122px;
}
.wp-daymeta { line-height: 1; }
.wp-date {
  font-size: 13px; font-weight: 700; color: var(--text-1); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.wp-weekday {
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3); margin-top: 2px;
}
.wp-content { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.wp-sport   { font-size: 13px; font-weight: 600; color: var(--text-1); }
.wp-title   { font-size: 12px; font-weight: 600; color: var(--text-1); }
.wp-km {
  display: inline-block;
  font-size: 10px; font-weight: 600; color: var(--text-2);
  background: var(--fill); border-radius: var(--r-pill);
  padding: 1px 7px; margin-left: 2px; vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.wp-summary { font-size: 12px; color: var(--text-2); line-height: 1.35; }
.wp-today   { box-shadow: 0 0 0 2px var(--tint) inset; }
.wp-easy    { border-top-color: var(--green); }
.wp-moderat { border-top-color: var(--teal); }
.wp-hart    { border-top-color: var(--orange); }
.wp-ruhe    { border-top-color: var(--text-3); opacity: 0.75; }

.btn.spinning { animation: dsSpin 0.8s linear infinite; }

@media (max-width: 768px) {
  .wp-grid { grid-template-columns: 1fr; gap: 8px; }
  .wp-day {
    flex-direction: row; align-items: flex-start; gap: 10px;
    min-height: 0;
    border-top: none;
    border-left: 4px solid var(--border);
  }
  .wp-daymeta { flex: 0 0 44px; }        /* Datum bleibt über dem Wochentag */
  .wp-content { flex: 1; margin-top: 0; }
  .wp-easy    { border-left-color: var(--green);  border-top-color: transparent; }
  .wp-moderat { border-left-color: var(--teal);   border-top-color: transparent; }
  .wp-hart    { border-left-color: var(--orange); border-top-color: transparent; }
  .wp-ruhe    { border-left-color: var(--text-3); border-top-color: transparent; }
}

/* ─── TAGESEINHEIT- & WOCHENREPORT-BANNER ────────────────── */
#banner-stack {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  z-index: 1200;
  width: 340px; max-width: calc(100vw - 28px);
  display: flex; flex-direction: column; gap: 12px;
  pointer-events: none;
}
#daily-session-banner,
#weekly-report-banner,
#health-guard-banner {
  width: 100%; pointer-events: auto;
  background: var(--surface-op);
  border: 0.5px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: dsIn 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes dsIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
.ds-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 0.5px solid var(--border-2);
  background: var(--surface-2);
}
.ds-title { font-size: 14px; font-weight: 600; color: var(--text-1); }
.ds-actions { display: flex; gap: 4px; }
.ds-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-2); font-size: 15px; line-height: 1;
  width: 28px; height: 28px; border-radius: 50%;
  transition: background 0.12s;
}
.ds-btn:hover { background: var(--fill); color: var(--text-1); }
.ds-btn.spinning { animation: dsSpin 0.8s linear infinite; }
@keyframes dsSpin { to { transform: rotate(360deg); } }
.ds-body {
  padding: 12px 16px; font-size: 14px; line-height: 1.5;
  color: var(--text-1); max-height: 46vh; overflow-y: auto;
}
.ds-body p { margin: 0 0 8px; }
.ds-body ul { margin: 4px 0 8px; padding-left: 18px; }
.ds-body li { margin-bottom: 3px; }
.ds-body strong { color: var(--text-1); font-weight: 600; }
.ds-meta {
  padding: 6px 16px 12px; font-size: 11px; color: var(--text-3);
}
@media (max-width: 560px) {
  #banner-stack {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    width: auto;
  }
}

/* ─── GESUNDHEITS-GUARD-BANNER ────────────────────────────── */
#health-guard-banner.hg-yellow { border-left: 4px solid var(--orange); }
#health-guard-banner.hg-red    { border-left: 4px solid var(--red); }
#health-guard-banner.hg-yellow .ds-head { background: color-mix(in srgb, var(--orange) 14%, transparent); }
#health-guard-banner.hg-red    .ds-head { background: color-mix(in srgb, var(--red) 16%, transparent); }

/* ─── SAISONPLAN-TIMELINE ─────────────────────────────────── */
.sp-timeline {
  display: flex; gap: 4px; padding: 14px 16px 8px;
}
.sp-block {
  min-width: 34px; padding: 8px 6px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border-top: 4px solid var(--border);
  background: var(--surface-2);
  overflow: hidden; white-space: nowrap;
}
.sp-phase { font-size: 10px; font-weight: 700; letter-spacing: 0.02em; color: var(--text-1); }
.sp-weeks { font-size: 10px; color: var(--text-3); }
.sp-base     { border-top-color: var(--blue); }
.sp-build    { border-top-color: var(--green); }
.sp-peak     { border-top-color: var(--orange); }
.sp-taper    { border-top-color: var(--teal); }
.sp-race     { border-top-color: var(--red); }
.sp-recovery { border-top-color: var(--text-3); }
.sp-current  { box-shadow: 0 0 0 2px var(--tint) inset; }
.sp-detail {
  padding: 6px 18px 4px; font-size: 13px; color: var(--text-1);
}
.sp-focus { margin-top: 3px; font-size: 13px; color: var(--text-2); line-height: 1.4; }
.sp-keys  { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.sp-notes { padding: 4px 18px 14px; font-size: 12px; color: var(--text-3); line-height: 1.4; }

/* ─── PLAN-IST-STRIP (Compliance) ─────────────────────────── */
.cmp-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 16px 12px; border-top: 0.5px solid var(--border-2);
  font-size: 12px; color: var(--text-2);
}
.cmp-strip.cmp-empty { color: var(--text-3); }
.cmp-label { font-weight: 600; }
.cmp-days  { display: flex; gap: 6px; }
.cmp-day {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 26px; cursor: default;
}
.cmp-wd { font-size: 10px; color: var(--text-3); }
.cmp-ic { font-size: 13px; font-weight: 700; line-height: 1; }
.cmp-done    .cmp-ic { color: var(--green); }
.cmp-partial .cmp-ic { color: var(--orange); }
.cmp-skipped .cmp-ic { color: var(--red); }
.cmp-extra   .cmp-ic { color: var(--blue); }
.cmp-rest    .cmp-ic { font-size: 11px; }
.cmp-pending .cmp-ic { color: var(--text-3); }

/* ─── COACH-JOURNAL ───────────────────────────────────────── */
.journal-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px; border-bottom: 0.5px solid var(--border-2);
  font-size: 13px;
}
.journal-row:last-child { border-bottom: none; }
.journal-date { flex: 0 0 38px; color: var(--text-3); font-size: 11px; }
.journal-cat {
  flex: 0 0 auto; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--text-2);
  background: var(--fill); border-radius: var(--r-pill); padding: 2px 8px;
}
.journal-txt { flex: 1; color: var(--text-1); line-height: 1.35; }
.journal-del { flex: 0 0 auto; width: 22px; height: 22px; font-size: 12px; }

@media (max-width: 768px) {
  .sp-timeline { flex-wrap: wrap; }
  .sp-block { min-width: 48px; flex-grow: 1 !important; }
}

/* ─── JAHRES-CHIPS (eigene Zeile unter den Zoom-Stufen) ───── */
.chart-year-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 4px 2px 2px; margin-top: 2px;
  border-top: 0.5px dashed var(--border-2);
}
.chart-year-bar .zoom-chip {
  border: none;
  background: var(--fill);
  font-variant-numeric: tabular-nums;
}
.chart-year-bar .zoom-chip.active {
  background: var(--tint);
  color: #fff;
}

/* ─── REDUCED TRANSPARENCY (Barrierefreiheit, iOS-konform) ── */
@media (prefers-reduced-transparency: reduce) {
  .card, .metric, .header, .chat-card, .login-card {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--surface-op);
  }
}

/* ─── DATENQUALITÄT ─────────────────────────────────────── */
.dq-date {
  font-size: 12px;
  color: var(--text-2);
}
.dq-ok {
  padding: 14px 4px;
  font-size: 14px;
  color: var(--green);
}
.dq-item {
  border-left: 3px solid var(--text-3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: rgba(120,120,128,0.08);
}
.dq-item.dq-critical { border-left-color: var(--red);    background: var(--red-lt); }
.dq-item.dq-warn     { border-left-color: var(--orange); background: var(--orange-lt); }
.dq-item.dq-info     { border-left-color: var(--text-3); }
.dq-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.dq-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(120,120,128,0.20);
  color: var(--text-2);
}
.dq-critical .dq-badge { background: var(--red);    color: #fff; }
.dq-warn     .dq-badge { background: var(--orange); color: #fff; }
.dq-title  { font-size: 14px; font-weight: 600; color: var(--text-1); }
.dq-detail { font-size: 13px; line-height: 1.45; color: var(--text-2); }
.dq-apply  { margin-top: 10px; font-size: 13px; padding: 7px 14px; }
.dq-curve {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-2);
}
.dq-curve span {
  font-size: 12px;
  color: var(--text-2);
  background: rgba(120,120,128,0.10);
  border-radius: 8px;
  padding: 4px 9px;
}
.dq-curve b { color: var(--text-1); font-weight: 600; }
.dq-curve i { font-style: normal; margin-left: 3px; color: var(--text-3); }

/* ── ABSCHNITTE ZU-/AUFKLAPPEN ───────────────────── */
.card > .card-head:has(> .sec-toggle) { position: relative; padding-right: 54px; }
.sec-toggle {
  position: absolute;
  top: 12px; right: 14px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 9px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sec-toggle:hover { background: var(--fill); color: var(--text-1); }
.sec-toggle:focus-visible { outline: 2px solid var(--tint); outline-offset: 1px; }
/* Chevron aus zwei Rahmenkanten: zeigt nach oben = offen, nach unten = zu */
.sec-toggle::before {
  content: '';
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(2px) rotate(-135deg);
  transition: transform 0.15s;
}
.card.collapsed .sec-toggle::before { transform: translateY(-2px) rotate(45deg); }

.sec-title-collapsed { display: none; }
.card.collapsed .sec-title-collapsed { display: inline; }
.card.collapsed > :not(.card-head) { display: none !important; }
.card.collapsed > .card-head { border-bottom: 0; padding-top: 16px; padding-bottom: 16px; min-height: 56px; }
/* Zugeklappt: nur Titel + Knopf, Filter/Tabs ausblenden */
.card.collapsed > .card-head > :not(.card-title):not(.sec-toggle) { display: none !important; }
.charts-row > .card.collapsed { align-self: start; }

/* ── CHAT-MODUS (Claude-Abo | App-Chat-Backup) ───── */
.chat-mode { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--fill); }
.chat-mode button {
  border: 0; background: none; font: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; color: var(--text-2); cursor: pointer;
}
.chat-mode button.active { background: var(--surface-op); color: var(--tint); box-shadow: var(--shadow); }
