/* RunningAway – orientiert an Apples Human Interface Guidelines:
   Systemschrift, semantische Systemfarben, gruppierte Listen,
   durchscheinende Navigationsleiste, Dark Mode, 44pt-Tippflächen. */

:root {
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --bg-tertiary: #f2f2f7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --nav-bg: rgba(242, 242, 247, 0.78);

  --tint: #007aff;
  --green: #34c759;
  --blue: #007aff;
  --red: #ff3b30;
  --orange: #ff9500;
  --purple: #af52de;
  /* Schlafphasen, mit dem Dataviz-Validator geprüft (hell) */
  --sleep-deep: #4b42c4;
  --sleep-light: #2f86e8;
  --sleep-rem: #3fbcd3;
  --sleep-awake: #e07a10;
  --brown: #a2845e;
  --strava: #fc4c02;

  --radius: 12px;
  --radius-lg: 16px;
  --gutter: 16px;
  --max: 1040px;
  --tabbar-h: 50px;
  --pad-top: calc(env(safe-area-inset-top) + 16px);
  --pad-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.32);
    --nav-bg: rgba(18, 18, 18, 0.72);

    --tint: #0a84ff;
    --green: #30d158;
    --blue: #0a84ff;
    --red: #ff453a;
    --orange: #ff9f0a;
    --purple: #bf5af2;
    /* eigene Abstufungen für dunkle Flächen, ebenfalls geprüft */
    --sleep-deep: #6458e6;
    --sleep-light: #2f9bea;
    --sleep-rem: #1fa88a;
    --sleep-awake: #cf6f16;
    --brown: #ac8e68;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* 1rem = 17px wie iOS "Body". Auf dem iPhone folgt die Basis der
   eingestellten Textgröße (Bedienungshilfen → Anzeige & Textgröße). */
html { -webkit-text-size-adjust: 100%; font-size: 106.25%; }
@supports (font: -apple-system-body) {
  html { font: -apple-system-body; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 1rem/1.29 var(--font);
  /* Keine eigene Laufweite: die Systemschrift bringt größenabhängiges Tracking mit. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a { color: var(--tint); text-decoration: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 60%, transparent); outline-offset: 2px; border-radius: 6px; }

.num { font-family: var(--font-rounded); font-variant-numeric: tabular-nums; }
.secondary { color: var(--label-2); }

/* ---------- Navigationsleiste ---------- */

.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding-top: env(safe-area-inset-top);
  background: transparent;
  transition: background-color 0.2s, box-shadow 0.2s;
}
.navbar.scrolled {
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
/* Weicher Übergang statt harter Linie, wo Inhalt unter die Leiste läuft */
.navbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 14px;
  background: linear-gradient(var(--nav-bg), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.navbar.scrolled::after { opacity: 1; }
.navbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  height: 52px;
  padding: 0 max(var(--gutter), env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-left: -4px;
  font-size: 1rem;
  justify-self: start;
}
.nav-title {
  grid-column: 2;
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}
.navbar.scrolled .nav-title { opacity: 1; transform: none; }

/* Tab-Seiten: Leiste liegt über dem Inhalt und erscheint erst beim Scrollen. */
.navbar.root {
  position: fixed;
  left: 0;
  right: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.navbar.root.scrolled { opacity: 1; pointer-events: auto; }

/* ---------- Inhalt ---------- */

.content {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) var(--pad-bottom) max(var(--gutter), env(safe-area-inset-left));
}
.navbar.root ~ .content { padding-top: var(--pad-top); }
/* Waagerechte Gesten gehören der App (Tab-Wischen), senkrechte dem Scrollen.
   So muss der Browser nicht erst abwarten, was die Geste wird. */
.content { touch-action: pan-y pinch-zoom; }

/* Tab-Wechsel per Wischen: neuer Inhalt gleitet von der Seite herein. */
/* Tab-Wechsel bei "Weniger Bewegung": überblenden statt schieben */
.content.fade-in { animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; } }
/* clip statt hidden: kein eigener Scroll-Container, die Leiste oben bleibt sticky */
body { overflow-x: clip; }

.large-title {
  font: 700 2rem/1.2 var(--font-display);
  margin: 4px 0 2px;
}
.large-subtitle { color: var(--label-2); font-size: 0.8824rem; margin: 0 0 20px; }

.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 32px 0 8px;
}
.section-header h2 { font: 700 1.2941rem/1.27 var(--font-display); margin: 0; }
.section-header .secondary { font-size: 0.8824rem; }

.group-header {
  font-size: 0.7647rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--label-2);
  margin: 24px 16px 6px;
}
.group-footer { font-size: 0.7647rem; color: var(--label-2); margin: 6px 16px 0; }

.group {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
}

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 16px;
}

/* ---------- Segmented Control ---------- */

.segmented {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
  max-width: 420px;
}
.segmented button {
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  font-size: 0.7647rem;
  font-weight: 500;
  min-height: 32px;
  border-radius: 7px;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { font-weight: 600; }
.segmented .thumb {
  position: absolute;
  top: 2px; bottom: 2px; left: 2px;
  border-radius: 7px;
  background: var(--bg-elevated);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s var(--ease);
}
@media (prefers-color-scheme: dark) {
  .segmented .thumb { background: #636366; }
}

/* ---------- Home: alles auf einen Blick, ohne Scrollen ---------- */

.home {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Genau eine Bildschirmhöhe zwischen oberem Rand und Tab-Leiste */
  height: calc(100dvh - var(--pad-top) - var(--pad-bottom));
  min-height: 540px;
}
.home-head { flex: none; }
.home-head .large-title { margin: 0; }
.home-meta {
  color: var(--label-2);
  font-size: 0.8824rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-meta strong { color: var(--label); font-weight: 600; }

.home-map {
  position: relative;
  display: block;
  flex: 1 1 0;
  min-height: 140px;
  max-height: 460px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-tertiary);
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}
/* Vorschaukarte: Tippen öffnet die Detailansicht */
.home-map .leaflet-pane, .home-map .leaflet-control-container { pointer-events: none; }
.home-map .leaflet-control-attribution { font-size: 0.5294rem; background: color-mix(in srgb, var(--bg-elevated) 70%, transparent); color: var(--label-2); }
.home-map .leaflet-control-attribution a { color: var(--label-2); }
.home-map .leaflet-tile-pane { filter: saturate(0.55) contrast(0.92) brightness(1.04); }
@media (prefers-color-scheme: dark) {
  .home-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.4); }
}
.home-map.no-map { display: grid; place-items: center; flex-grow: 0.4; }
.no-map-text { color: var(--label-3); font-size: 0.8824rem; }
.map-more {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  color: var(--label);
  font-size: 0.7647rem;
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}
.home-map:active .map-more { opacity: 0.6; }

/* Kennwerte für fit-nice.de: eigene, abgegrenzte Kachel. Ein Tippen kopiert alles. */
.key-tile {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  padding: 12px 16px 14px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--green) 45%, transparent);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, transform 0.15s;
}
.key-tile:hover { background: color-mix(in srgb, var(--green) 6%, var(--bg-elevated)); }
.key-tile:active { transform: scale(0.98); }
.key-tile.copied { background: color-mix(in srgb, var(--green) 16%, var(--bg-elevated)); }
.key-tile-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.key-tile-title { font-size: 0.7647rem; font-weight: 600; color: var(--green); text-transform: uppercase; letter-spacing: 0.03em; }
.key-tile .stat { display: block; min-width: 0; }
.stat-l, .inline-stats dt { display: block; font-size: 0.7647rem; color: var(--label-2); }
.stat-v, .inline-stats dd {
  display: block;
  margin: 2px 0 0;
  font: 600 1.2941rem/1.2 var(--font-rounded);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-v small, .inline-stats dd small { font-size: 0.7647rem; font-weight: 500; color: var(--label-2); margin-left: 2px; }
.stat-v.accent { color: var(--green); }
.stat-v.accent small { color: inherit; }
.copy-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7059rem;
  font-weight: 500;
  color: var(--label-2);
}
.key-tile.copied .copy-hint { color: var(--green); }
@media (max-width: 480px) {
  .key-tile { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
}

/* Schritte: eine Zeile, Zahl links, Ziel und Strecke rechts */
.key-tile.steps-tile { grid-template-columns: 1fr auto; align-items: end; padding-top: 10px; padding-bottom: 10px; row-gap: 4px; }
.steps-tile .steps-meta { text-align: right; }
.steps-tile .steps-meta .stat-l + .stat-l { margin-top: 2px; }

.home-stats {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5px;
  background: var(--separator);
}
.home-stats > div { background: var(--bg-elevated); padding: 10px 12px; min-width: 0; }
.home-stats .stat-v { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Übersicht ---------- */

.summary-card { margin-top: 12px; }
.summary-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.inline-stats { display: flex; gap: 24px; margin: 0; }
.inline-stats dd { font-size: 1rem; }

.hero-label { font-size: 0.8824rem; font-weight: 600; color: var(--label-2); }
.hero-value { font: 700 2.8235rem/1.05 var(--font-rounded); font-variant-numeric: tabular-nums; color: var(--green); margin: 4px 0 0; }
.hero-value small { font-size: 1.2941rem; font-weight: 600; margin-left: 4px; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--separator);
}
.stats > div { background: var(--bg-elevated); padding: 14px 16px; min-width: 0; }
.stat-label { font-size: 0.7647rem; color: var(--label-2); }
.stat-value { font: 600 1.4118rem/1.2 var(--font-rounded); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value small { font-size: 0.8824rem; font-weight: 500; color: var(--label-2); margin-left: 2px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.stats.three > div { padding: 12px; }
.stats.three .stat-value { font-size: 1.1765rem; }
@media (min-width: 560px) {
  .stats.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- Balkendiagramm ---------- */

.bars { margin-top: 16px; }
.bars svg { display: block; width: 100%; height: 160px; overflow: visible; }
.bars .bar { fill: var(--green); }
.bars .bar.empty { fill: var(--fill-2); }
.bars .bar-hit { fill: transparent; cursor: default; }
.bars .bar-hit:hover + .bar, .bars .bar.active { fill: color-mix(in srgb, var(--green) 75%, var(--label)); }
.bars .grid { stroke: var(--separator); stroke-width: 1; }
.bars .axis-label { fill: var(--label-2); font: 0.6471rem var(--font); }
.bars .tick-label { fill: var(--label-3); font: 0.6471rem var(--font-rounded); font-variant-numeric: tabular-nums; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-elevated);
  color: var(--label);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.7647rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16), 0 0 0 0.5px var(--separator);
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
  z-index: 10;
}
.chart-tooltip strong { font-family: var(--font-rounded); font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; }

/* ---------- Laufliste ---------- */

.run-list { list-style: none; margin: 0; padding: 0; }
.run-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  min-height: 84px;
  color: inherit;
  position: relative;
  transition: background-color 0.15s;
}
.run-row:hover { background: var(--fill); }
.run-row:active { background: var(--fill-2); }
.run-list li + li .run-row::before {
  content: "";
  position: absolute;
  top: 0; left: 92px; right: 0;
  border-top: 0.5px solid var(--separator);
}
.route-thumb {
  width: 64px; height: 64px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  display: block;
}
.route-thumb path { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.run-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-meta { font-size: 0.8824rem; color: var(--label-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-distance { font: 600 1.2941rem/1.1 var(--font-rounded); font-variant-numeric: tabular-nums; color: var(--green); text-align: right; white-space: nowrap; }
.run-distance small { font-size: 0.8824rem; margin-left: 2px; }
.run-sub { font-size: 0.7647rem; color: var(--label-2); text-align: right; font-family: var(--font-rounded); font-variant-numeric: tabular-nums; margin-top: 2px; }
.chevron { color: var(--label-3); margin-left: 4px; flex: none; }

.load-more { display: flex; justify-content: center; margin-top: 16px; }

.button-primary, .button-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px;
  padding: 0 24px;
  border: 0;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.button-primary { background: var(--tint); color: #fff; }
.button-secondary { background: var(--fill); color: var(--tint); }
.button-primary:active, .button-secondary:active { opacity: 0.7; transform: scale(0.98); }
.button-primary:disabled, .button-secondary:disabled { opacity: 0.4; cursor: default; }
.button-strava { background: var(--strava); color: #fff; }

/* ---------- Leerer Zustand ---------- */

.empty {
  text-align: center;
  padding: 72px 24px;
  max-width: 440px;
  margin: 0 auto;
}
.empty svg { color: var(--label-3); margin-bottom: 16px; }
.empty h2 { font: 700 1.2941rem/1.27 var(--font-display); margin: 0 0 8px; }
.empty p { color: var(--label-2); margin: 0 0 24px; }

.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 8px 0 16px;
  font-size: 0.8824rem;
}
.banner .secondary { font-size: 0.7647rem; }

/* ---------- Detailansicht ---------- */

.detail-head { margin: 4px 0 16px; }
.detail-date { color: var(--label-2); font-size: 0.8824rem; }

.map {
  height: 380px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-tertiary);
  isolation: isolate;
}
@media (max-width: 600px) { .map { height: 300px; } }
/* Hellere, ruhigere Karte im Stil von Apple Karten, damit die Strecke hervorsticht. */
.map .leaflet-tile-pane { filter: saturate(0.55) contrast(0.92) brightness(1.04); }
@media (prefers-color-scheme: dark) {
  .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.4); }
}
.map .leaflet-control-attribution { font-size: 0.5882rem; background: color-mix(in srgb, var(--bg-elevated) 70%, transparent); color: var(--label-2); }
.map .leaflet-control-attribution a { color: var(--label-2); }
.map .leaflet-bar { border: 0; box-shadow: 0 2px 10px rgba(0,0,0,0.15); border-radius: 10px; overflow: hidden; }
.map .leaflet-bar a { background: var(--bg-elevated); color: var(--label); border-color: var(--separator); }
.map-marker { width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.35); }
.map-marker.start { background: var(--green); }
.map-marker.end { background: var(--red); }
.map-marker.cursor { background: var(--blue); width: 16px; height: 16px; }

.detail-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.metric-chart { padding: 16px 16px 8px; }
.metric-chart + .metric-chart { border-top: 0.5px solid var(--separator); }
.metric-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.metric-name { font-weight: 600; font-size: 0.8824rem; }
.metric-summary { font-size: 0.7647rem; color: var(--label-2); font-family: var(--font-rounded); font-variant-numeric: tabular-nums; }
.metric-readout { font: 600 1.1765rem/1.2 var(--font-rounded); font-variant-numeric: tabular-nums; min-height: 24px; margin-top: 2px; }
.metric-readout small { font-size: 0.7647rem; color: var(--label-2); font-weight: 500; margin-left: 3px; }
.line-chart { display: block; width: 100%; height: 120px; overflow: visible; touch-action: pan-y; }
.line-chart .area { opacity: 0.18; }
.line-chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .grid { stroke: var(--separator); stroke-width: 1; }
.line-chart .tick-label { fill: var(--label-3); font: 0.6471rem var(--font-rounded); font-variant-numeric: tabular-nums; }
.line-chart .crosshair { stroke: var(--label-2); stroke-width: 1; }
.line-chart .dot { stroke: var(--bg-elevated); stroke-width: 2; }
.c-pace { color: var(--blue); }
.c-hr { color: var(--red); }
.c-elev { color: var(--brown); }
.c-cad { color: var(--orange); }
.c-pow { color: var(--purple); }

/* ---------- Gesundheit (Analyse) ---------- */

#healthRange { margin-bottom: 12px; }

/* Kreise im WHOOP-Stil */
.rings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.ring { background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 14px 6px 12px; text-align: center; min-width: 0; border: 0; font: inherit; color: inherit; cursor: pointer; width: 100%; -webkit-tap-highlight-color: transparent; transition: transform 0.15s; }
.ring:active { transform: scale(0.97); }
/* Sprung vom Ring zur Karte: Kante leuchtet kurz auf, unter der Kopfleiste bleibt Platz */
.health-card { scroll-margin-top: 64px; transition: box-shadow 0.4s; }
.health-card.flash { box-shadow: 0 0 0 3px var(--tint); }
.ring-dial { position: relative; width: min(84px, 100%); aspect-ratio: 1; margin: 0 auto 8px; }
.ring-dial svg { width: 100%; height: 100%; display: block; }
.ring-track { fill: none; stroke: var(--fill-2); stroke-width: 8; }
.ring-arc { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ring-in b { font: 700 1.3rem/1 var(--font-rounded); }
.ring-in small { font-size: 0.6471rem; color: var(--label-2); margin-top: 2px; }
.ring-label { font-size: 0.7647rem; font-weight: 600; }
.ring-sub { font-size: 0.6471rem; color: var(--label-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Gesundheitsalter: Balken von der Mitte aus, links jünger, rechts älter */
.ba-axis { display: flex; justify-content: space-between; font-size: 0.6471rem; color: var(--label-3); margin: 8px 0 2px; }
.ba-row { display: grid; grid-template-columns: 1fr 3.2em; gap: 2px 8px; padding: 7px 0; border-top: 0.5px solid var(--separator); font-size: 0.8235rem; }
.ba-name { grid-column: 1 / -1; line-height: 1.3; }
.ba-name .secondary { font-size: 0.7059rem; }
.ba-track { position: relative; height: 8px; border-radius: 4px; background: var(--fill); align-self: center; }
.ba-track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--label-3); }
.ba-track i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.ba-track i.young { background: var(--blue); }
.ba-track i.old { background: var(--orange); }
.ba-years { text-align: right; font-weight: 600; }

/* Letzte Nacht im Detail */
.night { margin-top: 16px; padding-top: 14px; border-top: 0.5px solid var(--separator); }
.night-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.night-times { font-size: 0.7647rem; margin-top: 2px; }
.night-score { font: 700 1.6rem/1 var(--font-rounded); text-align: right; }
.night-score small { display: block; font-size: 0.7059rem; font-weight: 600; margin-top: 2px; }
.night-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 12px 0 6px; gap: 2px; background: var(--bg-elevated); }
.night-bar i { display: block; height: 100%; }
.night-table { width: 100%; border-collapse: collapse; font-size: 0.8235rem; }
.night-table td { padding: 6px 0; border-top: 0.5px solid var(--separator); white-space: nowrap; }
.night-table td:not(:first-child) { text-align: right; padding-left: 8px; }
.night-table td:nth-child(4) { font-size: 0.7059rem; }
.night-table td:last-child { font-size: 0.7059rem; font-weight: 600; }
.night-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(4.5em, 1fr)); gap: 8px; margin-top: 10px; }
.night-facts div { background: var(--fill); border-radius: 10px; padding: 6px 8px; }
.night-facts .num { display: block; font-weight: 600; font-size: 0.8824rem; margin-top: 1px; }
.rings { margin-top: 4px; }

/* Pulszonen: Heute gegen damals auf gemeinsamer bpm-Achse */
#zoneCompare { margin: 4px 0 12px; }
.zbars { margin-bottom: 8px; }
.zbar-row { display: grid; grid-template-columns: 4.6em 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
.zbar-title { font-size: 0.7647rem; color: var(--label-2); }
.zbar { position: relative; height: 18px; border-radius: 5px; background: var(--fill); overflow: hidden; }
.zbar i { position: absolute; top: 0; bottom: 0; background: var(--red); box-shadow: inset -1px 0 0 var(--bg-elevated); }
.zbar-axis { display: flex; justify-content: space-between; margin-left: calc(4.6em + 8px); font-size: 0.6471rem; color: var(--label-3); font-family: var(--font-rounded); }
.zbar-empty { font-size: 0.7647rem; margin: 4px 0 8px; }
.zone-table { width: 100%; border-collapse: collapse; font-size: 0.8235rem; margin-top: 8px; }
.zone-table th { text-align: right; font-weight: 400; font-size: 0.7059rem; color: var(--label-2); padding: 4px 0; }
.zone-table th:first-child, .zone-table td:first-child { text-align: left; }
.zone-table td { text-align: right; padding: 7px 0; border-top: 0.5px solid var(--separator); white-space: nowrap; }
.zdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; }
.health-card + .health-card { margin-top: 12px; }
.hc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 8px; }
.hc-value { font: 700 2rem/1.1 var(--font-rounded); margin-top: 2px; }
.hc-value small { font-size: 0.8824rem; font-weight: 500; color: var(--label-2); margin-left: 4px; }
.hc-side { text-align: right; font-size: 0.8235rem; color: var(--label-2); line-height: 1.45; }
.hc-side .good { color: var(--green); }
.hc-sub { font-size: 0.8824rem; font-weight: 600; margin: 16px 0 4px; }
.hc-sub .secondary { font-weight: 400; }
.health-card .chart-wrap svg { display: block; width: 100%; overflow: visible; }
.health-card .grid { stroke: var(--separator); stroke-width: 1; }
.health-card .tick-label { fill: var(--label-3); font: 0.6471rem var(--font-rounded); font-variant-numeric: tabular-nums; }
.health-card .axis-label { fill: var(--label-2); font: 0.6471rem var(--font); }
.trend .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .pt { fill: currentColor; stroke: var(--bg-elevated); stroke-width: 1.5; }
.trend .band { fill: currentColor; opacity: 0.12; }
.trend .ref { stroke: var(--label-2); stroke-width: 1.5; stroke-dasharray: 4 4; }
.trend .crosshair { stroke: var(--label-2); stroke-width: 1; }
.trend .dot { fill: currentColor; stroke: var(--bg-elevated); stroke-width: 2; }
.health-card .bar-hit { fill: transparent; }
.health-card .stack.active rect { filter: brightness(0.85); }
.chart-empty { margin: 24px 0; text-align: center; font-size: 0.8824rem; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 0.7647rem; color: var(--label-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend b { color: var(--label); font-weight: 600; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.band { background: var(--blue); opacity: 0.2; }
.legend i.dash { width: 14px; height: 0; border-top: 2px dashed var(--label-2); border-radius: 0; }
.fa-factors { margin-top: 14px; border-top: 0.5px solid var(--separator); }
.fa-row { display: grid; grid-template-columns: 1fr auto 5.5em; gap: 10px; padding: 8px 0; font-size: 0.8824rem; border-bottom: 0.5px solid var(--separator); }
.fa-row .num { font-weight: 600; text-align: right; }
.fa-row .secondary { text-align: right; font-size: 0.7647rem; align-self: center; }
.fa-note { font-size: 0.7647rem; margin: 8px 0 0; }

/* Pulszonen: eine Farbe, von hell (Zone 1) nach kräftig (Zone 5) */
.zones { padding: 6px 0; }
.zone-row { display: grid; grid-template-columns: 4.2em 1fr 3.6em; align-items: center; gap: 10px; padding: 6px 16px; font-size: 0.8824rem; }
.zone-name { color: var(--label-2); }
.zone-track { height: 10px; border-radius: 5px; background: var(--fill); overflow: hidden; }
.zone-bar { display: block; height: 100%; border-radius: 5px; background: var(--red); }
.zone-time { text-align: right; }
.garmin-link { color: #007cc3; }
.line-chart .line, .line-chart .dot { stroke: currentColor; }
.line-chart .area, .line-chart .dot { fill: currentColor; }
.line-chart .dot { stroke: var(--bg-elevated); }

.splits { width: 100%; border-collapse: collapse; font-size: 0.8824rem; }
.splits th { font-size: 0.7647rem; font-weight: 400; color: var(--label-2); text-align: left; padding: 10px 16px 6px; }
.splits td { padding: 8px 16px; border-top: 0.5px solid var(--separator); font-family: var(--font-rounded); font-variant-numeric: tabular-nums; white-space: nowrap; }
.splits th:not(:first-child), .splits td:not(:first-child) { text-align: right; }
.splits td.bar-cell { width: 45%; padding-left: 0; padding-right: 0; }
.split-bar { height: 8px; border-radius: 4px; background: var(--blue); opacity: 0.85; }
.split-bar.fastest { background: var(--green); opacity: 1; }
.splits th.bar-cell { padding-left: 0; }

.efforts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1px; background: var(--separator); }
.efforts > div { background: var(--bg-elevated); padding: 12px 16px; }
.pr-badge { display: inline-block; font-size: 0.6471rem; font-weight: 700; color: #fff; background: var(--orange); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 2px; }

.description { white-space: pre-line; padding: 14px 16px; font-size: 0.8824rem; }

.strava-link { display: inline-flex; align-items: center; gap: 6px; color: var(--strava); font-weight: 600; font-size: 0.8824rem; min-height: 44px; margin-top: 12px; }

@media (min-width: 900px) {
  .detail-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .detail-layout .map { height: 460px; }
  .detail-side { position: sticky; top: 64px; }
}

/* ---------- Tab-Leiste ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.tabbar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 14px;
  background: linear-gradient(transparent, var(--nav-bg));
  pointer-events: none;
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  height: var(--tabbar-h);
  color: var(--label-2);
  font-size: 0.5882rem;
  font-weight: 500;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a.active { color: var(--tint); }
/* Feedback sofort beim Berühren, nicht erst beim Loslassen */
.tabbar a:active { opacity: 0.55; transition: none; }
/* Breite Bildschirme: Symbol und Text nebeneinander wie auf dem iPad */
@media (min-width: 700px) {
  .tabbar { grid-template-columns: repeat(4, 160px); justify-content: center; }
  .tabbar a { flex-direction: row; gap: 8px; font-size: 0.7647rem; }
  .tabbar svg { width: 22px; height: 22px; }
}

/* ---------- Profil ---------- */

.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 12px 0 8px;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
}
.profile-card img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: none; }
.profile-name { font: 600 1.2941rem/1.25 var(--font-display); }
.row-button:disabled { color: var(--label-3); cursor: default; }
.row-button.export-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.export-hint { display: block; font-size: 0.7647rem; margin-top: 1px; }

/* Theme-Auswahl im Profil, wie eine Liste in den iOS-Einstellungen */
.row-button.theme-row { display: flex; align-items: center; gap: 12px; color: var(--label); }
.theme-row .theme-name { flex: 1; }
.theme-row .check { color: var(--tint); visibility: hidden; flex: none; }
.theme-row[aria-pressed="true"] .check { visibility: visible; }
.swatch { display: inline-flex; flex: none; }
.swatch i { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--bg-elevated), 0 0 0 2px var(--separator); }
.swatch i + i { margin-left: -6px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 16px; }
.row + .row { border-top: 0.5px solid var(--separator); }
.row .value { color: var(--label-2); text-align: right; }
.row-button { display: block; width: 100%; min-height: 44px; padding: 10px 16px; border: 0; background: none; color: var(--tint); text-align: left; font-size: 1rem; cursor: pointer; }
.row-button:hover { background: var(--fill); }
.row-button + .row-button, .row + .row-button { border-top: 0.5px solid var(--separator); }
.row-button.destructive { color: var(--red); }
.athlete { display: flex; align-items: center; gap: 12px; }
.athlete img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2000;
  max-width: calc(100vw - 32px);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  color: var(--label);
  font-size: 0.8824rem;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 0 0 0.5px var(--separator);
  animation: toast-in 0.35s var(--ease);
}
@keyframes toast-in { from { transform: translate(-50%, 16px); opacity: 0; } }

/* ---------- Ladeplatzhalter ---------- */

.skeleton { background: linear-gradient(90deg, var(--fill) 25%, var(--fill-2) 50%, var(--fill) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Login ---------- */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login { width: 100%; max-width: 360px; text-align: center; }
.login-icon { border-radius: 16px; margin-bottom: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.login h1 { font: 700 1.6471rem/1.2 var(--font-display); margin: 0 0 6px; }
.login > p { margin: 0 0 28px; }
.login-form { text-align: left; display: grid; gap: 16px; }
.field { display: grid; grid-template-columns: 96px 1fr; align-items: center; min-height: 48px; padding: 0 16px; }
.field + .field { border-top: 0.5px solid var(--separator); }
.field span { font-size: 1rem; }
.field input { border: 0; outline: 0; background: transparent; font: inherit; color: var(--label); min-height: 44px; width: 100%; }
.form-error { color: var(--red); font-size: 0.8824rem; margin: 0; text-align: center; }
.login .button-primary { width: 100%; }

/* Weniger Bewegung: nichts schiebt, federt oder skaliert mehr,
   Überblendungen bleiben als ruhiges Feedback erhalten. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .segmented .thumb, .key-tile, .button-primary, .button-secondary { transition-property: opacity, background-color, color !important; }
  .key-tile:active, .button-primary:active, .button-secondary:active { transform: none; }
  .toast { animation-name: fade-in; }
  .skeleton { animation: none; }
  @keyframes fade-in { from { opacity: 0; } }
}

/* Transparenz reduzieren: Leisten und Toast werden blickdicht */
@media (prefers-reduced-transparency: reduce) {
  .navbar.scrolled, .tabbar, .toast, .map-more { background: var(--bg-elevated); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .navbar::after, .tabbar::before { display: none; }
  .navbar.scrolled { box-shadow: 0 0.5px 0 var(--separator); }
  .tabbar { box-shadow: 0 -0.5px 0 var(--separator); }
}

/* Kontrast erhöhen: kräftigere Zweitfarben und sichtbare Kanten */
@media (prefers-contrast: more) {
  :root { --label-2: rgba(60, 60, 67, 0.85); --label-3: rgba(60, 60, 67, 0.6); --separator: rgba(60, 60, 67, 0.45); }
  .group, .card, .key-tile, .home-stats, .profile-card { box-shadow: 0 0 0 1px var(--separator); }
  .navbar.scrolled, .tabbar, .toast { background: var(--bg-elevated); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --label-2: rgba(235, 235, 245, 0.85); --label-3: rgba(235, 235, 245, 0.6); --separator: rgba(84, 84, 88, 0.9); }
}
