/* Cavela – Design-System nach der UI-Suite-Vorlage:
   helle, taktile ("neumorphe") Boxen & Controls mit blauem Akzent (#005daa),
   auf dem blauen Marken-Hintergrund. Mobile-first & responsive. */

:root {
  /* Flächen / Marken-Hintergrund */
  --bg: #1f4fa6;
  --bg-grad: linear-gradient(180deg, #173f88 0%, #2f86e6 58%, #67b6f7 100%);
  --surface: #ffffff;
  --surface-2: #eef4fc;
  --glass: rgba(255, 255, 255, 0.16);
  --glass-line: rgba(255, 255, 255, 0.34);
  --line: var(--hair);
  /* Text */
  --ink: #1a1d1f;
  --muted: #6b7178;
  --on-blue: #ffffff;
  --on-blue-soft: rgba(255, 255, 255, 0.82);
  /* Konturen */
  --hair: rgba(0, 0, 0, .10);
  --hair-2: rgba(0, 0, 0, .06);
  /* Akzent (Vorlage) */
  --accent-col: #005daa;
  --accent-2: #004a8c;
  --accent-lt: #1f7ec9;
  --accent-grad: linear-gradient(180deg, #1f7ec9 0%, #005daa 55%, #004a8c 100%);
  --accent-glow: rgba(0, 93, 170, .35);
  --accent-soft: rgba(0, 93, 170, .10);
  --primary: #005daa;
  --primary-hover: #004a8c;
  --accent: #1f7ec9;
  /* Versenkte ("well") und erhabene ("chip") Flächen */
  --well-grad: linear-gradient(180deg, #f1f2f3 0%, #e3e5e6 60%, #d4d7d8 100%);
  --well-shadow:
    inset 0 1px 0 rgba(255,255,255,1),
    inset 0 -1px 0 rgba(0,0,0,.04),
    inset 0 6px 14px rgba(0,0,0,.10),
    0 1px 0 rgba(255,255,255,.9),
    0 6px 14px -10px rgba(0,0,0,.22),
    0 0 0 1px var(--hair);
  --chip-grad: linear-gradient(180deg, #ffffff 0%, #fafbfb 60%, #f1f3f4 100%);
  --chip-shadow:
    inset 0 1px 0 rgba(255,255,255,1),
    0 1px 1px rgba(0,0,0,.04),
    0 3px 6px rgba(0,0,0,.12),
    0 10px 22px rgba(0,0,0,.18),
    0 0 0 .5px rgba(0,0,0,.08);
  --card-shadow:
    0 1px 1px rgba(0,0,0,.04),
    0 4px 10px rgba(0,0,0,.06),
    0 16px 30px -16px rgba(0,0,0,.16),
    0 0 0 1px var(--hair);
  --danger: #c41010;
  --danger-2: #ff3b3b;
  --danger-soft: rgba(196, 16, 16, .10);
  /* Einheitlicher Schatten für ALLE Controls (Felder, Buttons, Pills) */
  --ctrl-shadow:
    0 1px 2px rgba(0,0,0,.05),
    0 5px 12px -6px rgba(0,0,0,.20),
    0 0 0 1px var(--hair);
  /* Gangartfarben */
  --halt: #8aa0b8;
  --schritt: #00a85a;
  --trab: #f0982f;
  --galopp: #e0584a;
  --piaff: #6a64d8;
  --passage: #9a59c8;
  /* Form (Vorlage: Karten 18, Felder/Buttons 14) */
  --r-card: 18px;
  --r-md: 14px;
  --r-pill: 999px;
  --shadow: var(--card-shadow);
  --shadow-sm: var(--card-shadow);
  --pad: clamp(14px, 4vw, 18px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* Blauer Verlauf als fester Hintergrund (DailyMe-Look) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: var(--bg-grad);
  background-attachment: fixed;
}

.ic { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.22em; flex: none; }
/* Inline-Icons in kleinen/gedämpften Textkontexten kompakter */
.muted .ic, .small .ic, .seg-corrected .ic, .pill .ic, .bar-row .ic { width: 14px; height: 14px; vertical-align: -0.15em; }
.rec-meta .muted { display: inline-flex; align-items: center; gap: 4px; justify-content: center; }
.card h2 .ic { width: 20px; height: 20px; vertical-align: -0.22em; }

/* ---------- Layout ---------- */
#app {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 12px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-titles {
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.1;
}
.topbar-titles .brand {
  font-size: 1.05rem; font-weight: 800; letter-spacing: 0.01em; color: var(--on-blue);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-titles .brand .brand-sub { font-weight: 600; opacity: 0.85; font-size: 0.92em; }
.topbar-titles .page {
  font-size: 0.78rem; font-weight: 600; color: var(--on-blue-soft); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-titles .page:empty { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: var(--r-pill);
  background: var(--glass); color: var(--on-blue); border: 1px solid var(--glass-line);
  backdrop-filter: blur(8px); cursor: pointer; font-size: 1.1rem;
  flex: none;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn .ic { width: 22px; height: 22px; }
/* Icon-Buttons innerhalb heller Karten/Listen: neutraler Stil statt Glas */
.card .icon-btn, .list-item .icon-btn {
  background: #fff; box-shadow: var(--ctrl-shadow); border-color: transparent; backdrop-filter: none; width: 38px; height: 38px;
}

main { flex: 1; padding: 4px var(--pad) calc(env(safe-area-inset-bottom) + 32px); }

/* ---------- Burger-Menü (ausklappbares Drawer) ---------- */
#scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(16, 30, 22, 0.42);
  opacity: 0; pointer-events: none; transition: opacity 0.22s ease;
}
#menu {
  position: fixed; top: 0; right: 0; z-index: 50;
  height: 100%; width: min(82vw, 300px);
  background: var(--surface);
  box-shadow: -20px 0 50px -24px rgba(16, 30, 22, 0.5);
  padding: calc(env(safe-area-inset-top) + 18px) 14px 18px;
  display: flex; flex-direction: column; gap: 4px;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
  overflow-y: auto;
}
#menu .menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 14px; font-weight: 700; font-size: 1.05rem;
}
#menu-close { background: #fff; box-shadow: var(--ctrl-shadow); }
#menu button {
  display: flex; align-items: center; gap: 14px;
  text-align: left; padding: 14px 16px; font-size: 1rem; font-weight: 600;
  background: none; border: none; border-radius: var(--r-md); cursor: pointer;
  color: var(--ink); width: 100%;
}
#menu button .ic { width: 22px; height: 22px; color: var(--muted); }
#menu button:active { background: var(--surface-2); }
#menu button.logout { color: var(--danger); margin-top: auto; }
#menu button.logout .ic { color: var(--danger); }

body.menu-open #scrim { opacity: 1; pointer-events: auto; }
body.menu-open #menu { transform: translateX(0); }

/* ---------- Karten & Typo ---------- */
.card {
  position: relative;
  background: var(--surface); border-radius: var(--r-card);
  padding: var(--pad); margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
/* Hilfe-Button: kleiner "?"-Kreis, direkt außerhalb der Box (oben rechts) */
.help-btn {
  position: absolute; top: -9px; right: -9px; z-index: 4;
  width: 26px; height: 26px; min-width: 26px; flex: none; padding: 0; border-radius: 50%;
  background: #fff; color: var(--accent-col); border: none;
  box-shadow: var(--ctrl-shadow); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.help-btn .ic { width: 16px; height: 16px; }
.help-btn:active { transform: scale(0.92); }
.gi { position: relative; }
/* nur den eigentlichen Aktionsbutton auf volle Breite ziehen – NICHT den Hilfe-"?" */
.gi > button:not(.help-btn) { margin-top: 0; width: 100%; }
/* Hilfe-"?" bleibt ein 26px-Kreis in der oberen rechten Ecke des Buttons */
.gi > .help-btn { top: -9px; right: 8px; width: 26px; height: 26px; }
.card h2 { font-size: 1.06rem; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.01em; }
.card h2 .ic { color: var(--muted); }
h3 { font-size: 0.98rem; font-weight: 700; margin: 10px 0 4px; }
.muted { color: var(--muted); font-size: 0.88rem; }
.small { font-size: 0.85rem; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }

/* ---------- Buttons (einheitlicher Schatten; Grau -> Weiß) ---------- */
button.primary, button.secondary, button.danger, button.accent {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; font-size: 1.0rem; font-weight: 700;
  border: none; border-radius: var(--r-md); cursor: pointer; margin-top: 12px;
  letter-spacing: -0.005em; box-shadow: var(--ctrl-shadow);
  transition: filter 0.2s ease, transform 0.12s ease;
}
button.primary, button.accent { color: #fff; background: var(--accent-grad); }
button.secondary { color: var(--ink); background: #fff; }
button.danger { color: #fff; background: linear-gradient(180deg, #ff5a5a 0%, #d11f1f 55%, #b01010 100%); }
button.primary:hover, button.accent:hover, button.danger:hover { filter: brightness(1.05); }
button.primary:active, button.accent:active, button.danger:active { filter: brightness(.96); }
button.secondary:active { filter: brightness(.97); }
button .ic { width: 20px; height: 20px; }
button:disabled { opacity: 0.45; }
button:active:not(:disabled) { transform: translateY(1px); }

/* Zweispaltiger Aktions-Bereich (Detailseite) */
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.btn-grid button { margin-top: 0; }
.btn-grid .span-2 { grid-column: 1 / -1; }

/* ---------- Formulare (Vorlage: versenkte "well"-Felder) ---------- */
label { display: block; margin-top: 14px; font-weight: 600; font-size: 0.9rem; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 13px 15px; font-size: 1rem; font-weight: 600; font-family: inherit;
  border: none; border-radius: var(--r-md); margin-top: 7px;
  background: #fff; box-shadow: var(--ctrl-shadow); color: var(--ink);
  letter-spacing: -0.005em;
}
textarea { min-height: 84px; }
input:focus, select:focus, textarea:focus {
  outline: none; box-shadow: var(--ctrl-shadow), 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); font-weight: 500; }

/* ---------- Trainingsart-Kacheln ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.tile {
  background: #fff; box-shadow: var(--ctrl-shadow); border: 2px solid transparent;
  border-radius: var(--r-md);
  padding: 16px 8px 14px; text-align: center; font-size: 0.92rem; font-weight: 700; color: var(--ink);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: box-shadow 0.25s ease;
}
.tile .tile-ic {
  width: 46px; height: 46px; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--primary); box-shadow: var(--ctrl-shadow);
}
.tile .tile-ic .ic { width: 24px; height: 24px; }
.tile.selected { box-shadow: var(--ctrl-shadow), 0 0 0 2.5px var(--accent-col); }
.tile.selected .tile-ic { background: var(--accent-grad); color: #fff; box-shadow: 0 2px 6px var(--accent-glow); }

/* ---------- Aufnahme-Ansicht ---------- */
.rec-hero {
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(140%);
  color: var(--on-blue); border-radius: var(--r-card);
  padding: 24px var(--pad); margin-bottom: 14px; text-align: center;
  box-shadow: var(--shadow); position: relative;
}

/* ---------- Kompass ---------- */
.compass {
  width: 64px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.rec-hero .compass { position: absolute; top: 12px; right: 12px; z-index: 3; }
.compass svg { width: 56px; height: 56px; display: block; }
.compass .compass-ring { fill: rgba(255,255,255,0.10); stroke: rgba(255,255,255,0.55); stroke-width: 1.5; }
.compass .compass-fix { stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.compass .compass-rose { transform-origin: 28px 28px; transition: transform 0.18s linear; }
.compass .compass-n { fill: #e0584a; }
.compass .compass-s { fill: rgba(255,255,255,0.75); }
.compass .compass-lbl { fill: #fff; font-size: 7px; font-weight: 700; text-anchor: middle; }
.compass .compass-lbl-n { fill: #ffd9d4; }
.compass .compass-deg { font-size: 0.72rem; font-weight: 700; color: var(--on-blue); letter-spacing: 0.02em; }
.compass.compass-off { opacity: 0.4; }
/* Kompass auf hellem Grund (Detail-/Höhenfenster): dunkle Beschriftung */
.chart-card .compass .compass-lbl { fill: var(--accent-col); }
.chart-card .compass .compass-lbl-n { fill: #e0584a; }
.chart-card .compass .compass-ring { fill: rgba(0,93,170,0.06); stroke: rgba(0,93,170,0.4); }
.chart-card .compass .compass-fix { stroke: var(--accent-col); }
.chart-card .compass .compass-s { fill: rgba(0,93,170,0.4); }
.chart-card .compass .compass-deg { color: var(--accent-col); }

#pause-btn.active { background: var(--accent-grad); color: #fff; }

/* ---------- Markierungen & Bereichs-Editor ---------- */
.markers-line { margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.marker-chip {
  display: inline-flex; align-items: center; font-size: 0.74rem; font-weight: 700;
  padding: 2px 8px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-col);
}
.tl-mark .cap.mark-num { font-size: 0.72rem; font-weight: 800; background: #1f7ec9; }
.range-bar {
  position: relative; height: 34px; margin: 12px 0 2px; border-radius: 9px;
  background: linear-gradient(180deg, #eaf3fb, #dce9f7); box-shadow: var(--well-shadow);
  touch-action: none; cursor: pointer;
}
.range-fill { position: absolute; top: 0; bottom: 0; background: rgba(0,93,170,0.22); border-radius: 9px; }
.range-handle {
  position: absolute; top: -3px; width: 16px; height: 40px; transform: translateX(-50%);
  border-radius: 6px; background: #fff; border: 2px solid var(--accent-col);
  box-shadow: var(--ctrl-shadow); cursor: ew-resize; z-index: 2;
}
.range-tick { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(0,93,170,0.45); transform: translateX(-50%); }
.range-tick b {
  position: absolute; top: -15px; left: 50%; transform: translateX(-50%);
  font-size: 0.68rem; font-weight: 800; color: var(--accent-col);
}
.ex-form select { width: 100%; }
.rec-ring {
  width: clamp(170px, 56vw, 220px); aspect-ratio: 1; margin: 4px auto 10px;
  border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(closest-side, rgba(255,255,255,0.10), rgba(255,255,255,0.02)),
    conic-gradient(var(--accent) var(--ring, 0%), rgba(255,255,255,0.22) 0);
  position: relative;
}
.rec-ring::before {
  content: ""; position: absolute; inset: 12px; border-radius: 50%;
  background: rgba(20, 60, 120, 0.18); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.18);
}
.rec-ring > * { position: relative; }
.rec-speed .value { font-size: clamp(3rem, 16vw, 4rem); font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.rec-speed .unit { font-size: 0.95rem; opacity: 0.75; }
.rec-gait {
  text-align: center; font-size: 1.15rem; font-weight: 800;
  padding: 9px 16px; border-radius: var(--r-pill); color: #fff; margin: 10px auto 4px; min-width: 60%;
  background: rgba(255,255,255,0.18);
}
.rec-meta { display: flex; justify-content: space-around; text-align: center; gap: 8px; }
.rec-meta > div { flex: 1; }
.rec-meta .num { font-size: 1.25rem; font-weight: 800; }
.rec-hero .rec-meta .num { color: #fff; }
.rec-hero .rec-meta .muted { color: var(--on-blue-soft); }

/* ---------- Gangart-/Tempo-/Figuren-Buttons ---------- */
.gait-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.gait-buttons.two { grid-template-columns: repeat(2, 1fr); }
.gait-buttons.three { grid-template-columns: repeat(3, 1fr); }
.gait-buttons button {
  padding: 16px 4px; font-size: 0.9rem; font-weight: 800; color: #fff;
  border: none; border-radius: var(--r-md); cursor: pointer; min-height: 52px;
  box-shadow: var(--ctrl-shadow);
}
.gait-buttons button.active { box-shadow: var(--ctrl-shadow), inset 0 0 0 3px rgba(255,255,255,0.6); }
.g-halt { background: var(--halt); }
.g-schritt { background: var(--schritt); }
.g-trab { background: var(--trab); }
.g-galopp { background: var(--galopp); }
.g-piaff { background: var(--piaff); }
.g-passage { background: var(--passage); }

.tempo-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.tempo-buttons .tempo-lbl { font-size: 0.85rem; color: var(--muted); margin-right: 2px; }
.tempo-buttons button {
  padding: 9px 14px; font-size: 0.85rem; font-weight: 700; color: #fff;
  border: none; border-radius: var(--r-pill); cursor: pointer; opacity: 0.72;
  box-shadow: var(--ctrl-shadow);
}
.tempo-buttons button.active { opacity: 1; box-shadow: var(--ctrl-shadow), inset 0 0 0 3px rgba(255,255,255,0.6); }

details.dressage { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.dressage summary, details > summary {
  font-weight: 700; cursor: pointer; padding: 8px 0; display: flex; align-items: center; gap: 8px;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
.figure-buttons { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.figure-buttons button {
  padding: 9px 13px; font-size: 0.82rem; font-weight: 600;
  color: var(--ink); background: #fff; box-shadow: var(--ctrl-shadow);
  border: none; border-radius: var(--r-pill); cursor: pointer;
}
.figure-buttons button.active {
  color: #fff; background: var(--accent-grad);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 4px 10px var(--accent-glow), 0 0 0 .5px rgba(0,0,0,.05);
}
.fig-badge {
  font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent-col);
}

/* ---------- Timeline / Segmente / Chart ---------- */
.timeline-wrap { position: relative; margin: 12px 0; padding-top: 15px; }
.timeline { display: flex; height: 26px; border-radius: 9px; overflow: hidden; margin: 0; background: #eef2f7; }
/* Marker (Sprünge/Markierungen) über dem Zeitstrahl */
.timeline-marks { position: absolute; left: 0; right: 0; top: 15px; height: 26px; pointer-events: none; }
.tl-mark { position: absolute; top: 0; bottom: 0; transform: translateX(-50%); }
.tl-mark::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px;
  background: rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.tl-mark .cap {
  position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: var(--ctrl-shadow);
}
.tl-mark .cap .ic { width: 11px; height: 11px; }
.tl-mark.m-jump .cap { background: var(--piaff); }
.tl-mark.m-auto .cap { background: #fff; color: var(--piaff); box-shadow: var(--ctrl-shadow), inset 0 0 0 1.5px var(--piaff); }
.tl-mark.m-marker .cap { background: var(--accent-col); }
.int-badge {
  display: inline-block; color: #fff; font-weight: 700; font-size: 0.7rem;
  padding: 2px 9px; border-radius: 999px; text-transform: capitalize; margin-right: 4px;
}
.timeline { cursor: pointer; }
.timeline div { height: 100%; }
/* Hervorhebung des angesprungenen Abschnitts (Klick auf Zeitleiste) */
.seg-list li.flash { animation: segFlash 1.6s ease; }
@keyframes segFlash {
  0% { background: var(--accent-soft); } 15% { background: var(--accent-soft); } 100% { background: transparent; }
}
.chev { color: var(--muted); margin-left: auto; }
.chev .ic { width: 18px; height: 18px; transition: transform 0.2s ease; }
/* Bearbeitetes Pferd: Pfeil zeigt nach unten, solange das Detail-Formular offen ist */
.list-item.editing .chev .ic { transform: rotate(90deg); }
.list-item.editing .chev { color: var(--accent-col); }
/* Teilen-Box im Korrektur-Dialog */
.split-box { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.split-box summary { font-weight: 700; cursor: pointer; padding: 6px 0; display: flex; align-items: center; gap: 8px; list-style: none; }
.split-box summary::-webkit-details-marker { display: none; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 10px; padding: 0; margin-top: 10px;
  background: #e3e7ee; border-radius: 999px; box-shadow: var(--ctrl-shadow);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: var(--ctrl-shadow); border: 2px solid var(--accent-col); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2px solid var(--accent-col); cursor: pointer;
}
/* Abschnitte: begrenzte Höhe mit eigenem Scrollbalken rechts */
.seg-list {
  list-style: none; max-height: 280px; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding-right: 6px;
}
.seg-list::-webkit-scrollbar { width: 8px; }
.seg-list::-webkit-scrollbar-thumb { background: #cdd8ea; border-radius: 8px; }
.seg-list::-webkit-scrollbar-track { background: transparent; }
.seg-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.seg-list li:last-child { border-bottom: none; }
.seg-badge {
  color: #fff; font-weight: 800; font-size: 0.78rem;
  padding: 8px 6px; border-radius: var(--r-md); min-width: 76px; text-align: center; line-height: 1.1;
}
.seg-corrected { font-size: 0.78rem; color: var(--schritt); font-weight: 700; }
.seg-mismatch { font-size: 0.78rem; color: var(--trab); font-weight: 700; }
.seg-corrected .ic, .seg-mismatch .ic { width: 13px; height: 13px; }

/* Vergleichsblock manuell ↔ automatisch (Korrektur-Dialog) */
.compare {
  background: var(--surface-2); border-radius: var(--r-md); padding: 12px 14px; margin: 10px 0;
  font-size: 0.9rem; display: flex; flex-direction: column; gap: 6px;
}
.compare.warn { background: #fff3e2; box-shadow: inset 0 0 0 1.5px var(--trab); }
.compare .ic { width: 16px; height: 16px; color: var(--muted); }
.compare button { margin-top: 8px; }
.seg-list .chev { color: var(--muted); margin-left: auto; }
.seg-list .chev .ic { width: 18px; height: 18px; }

canvas.chart { width: 100%; height: 150px; background: var(--surface-2); border-radius: var(--r-md); }
/* Verlaufsfenster (hellblau) mit Live-Kompass beim Abspielen/Scrubben */
.chart-wrap { position: relative; }
.chart-wrap canvas.chart { background: linear-gradient(180deg, #eaf3fb 0%, #dce9f7 100%); touch-action: none; cursor: ew-resize; }
.chart-wrap .compass { position: absolute; top: 8px; right: 8px; z-index: 2; }
.chart-readout {
  position: absolute; top: 8px; left: 10px; z-index: 2;
  font-size: 0.78rem; font-weight: 700; color: var(--accent-col);
  background: rgba(255,255,255,0.85); border-radius: var(--r-pill); padding: 2px 9px;
}

/* ---------- Tabellen / Listen ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-weight: 700; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 13px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item .lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-item .lead .ic { color: var(--primary); width: 22px; height: 22px; flex: none; }
.list-item strong { font-weight: 700; }
.pill {
  font-size: 0.74rem; font-weight: 700; padding: 5px 12px; border-radius: var(--r-pill);
  background: #fff; box-shadow: var(--ctrl-shadow); color: var(--muted);
  white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 5px;
}
.pill.live { color: var(--danger-2); }
.pill.ok { color: var(--accent-col); }
.pill .ic { width: 13px; height: 13px; }

/* ---------- Bars / Statistik ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 0.86rem; }
.bar-row .bar { height: 16px; border-radius: var(--r-pill); min-width: 3px; }
.bar-row .lbl { width: 68px; font-weight: 600; flex: none; }

/* ---------- Login ---------- */
.login-wrap { padding: clamp(40px, 12vh, 120px) 4px 40px; }
.login-logo {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 26px;
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(10px);
  color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.login-logo .ic { width: 44px; height: 44px; }
.login-title { text-align: center; margin-bottom: 22px; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; color: var(--on-blue); }

/* ---------- Modal / Popup (Vorlage) ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(15, 18, 20, 0.34); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: 20px; padding: 24px;
  width: 100%; max-width: 360px; text-align: center;
  box-shadow:
    0 1px 1px rgba(0,0,0,.04), 0 8px 16px rgba(0,0,0,.10),
    0 32px 60px -16px rgba(0,0,0,.36), 0 0 0 1px var(--hair);
}
.modal .modal-ic {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent-col);
  display: flex; align-items: center; justify-content: center;
}
.modal .modal-ic .ic { width: 32px; height: 32px; }
.modal h2 { font-size: 1.2rem; margin-bottom: 8px; }
.modal .row { gap: 10px; }
.modal .row button { margin-top: 6px; }

/* ---------- Eröffnungs-Screen (Three.js) ---------- */
#splash {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-grad);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; will-change: opacity;
}
#splash-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.splash-ui {
  position: absolute; top: 11%; left: 0; right: 0; z-index: 2; text-align: center;
  padding: 22px 24px 26px; pointer-events: none;
}
/* dezenter Abdunkler für sicheren Kontrast der Schrift */
.splash-ui::before {
  content: ""; position: absolute; inset: -10% -5%; z-index: -1; border-radius: 50%;
  background: radial-gradient(60% 70% at 50% 42%, rgba(8, 22, 55, 0.45), rgba(8, 22, 55, 0) 72%);
  filter: blur(6px);
}
.splash-title {
  font-size: clamp(2.3rem, 12vw, 3.1rem); font-weight: 800; color: #fff; letter-spacing: -0.03em;
  text-shadow: 0 2px 6px rgba(0, 18, 50, 0.55), 0 10px 34px rgba(0, 20, 60, 0.5);
}
.splash-sub {
  margin-top: 4px; color: #fff; opacity: 0.95; font-weight: 700;
  font-size: 0.8rem; letter-spacing: 0.32em; text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 18, 50, 0.55);
}
.splash-tag {
  margin-top: 14px; min-height: 2.8em; color: #fff;
  font-size: clamp(1.02rem, 4.7vw, 1.22rem); font-weight: 600; line-height: 1.35;
  text-shadow: 0 2px 10px rgba(0, 18, 50, 0.6);
}
.splash-progress {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 64px); width: min(60%, 280px);
  height: 4px; background: rgba(255, 255, 255, 0.25); border-radius: 999px; overflow: hidden; z-index: 2;
}
.splash-progress i { display: block; height: 100%; width: 0; background: #fff; border-radius: 999px; }
.splash-skip {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 30px);
  color: rgba(255, 255, 255, 0.62); font-size: 0.8rem; z-index: 2; letter-spacing: 0.02em;
}

/* ---------- Toast (Vorlage: weiße Karte + Akzent-Punkt) ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  background: #fff; color: var(--ink); padding: 13px 18px 13px 16px; border-radius: var(--r-md);
  font-size: 0.9rem; font-weight: 600; z-index: 100; max-width: calc(100% - 32px);
  text-align: left; display: flex; align-items: center; gap: 12px;
  box-shadow:
    0 1px 1px rgba(0,0,0,.04), 0 4px 10px rgba(0,0,0,.06),
    0 16px 30px -16px rgba(0,0,0,.22), 0 0 0 1px var(--hair);
}
#toast::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--on-2, #00d96b); box-shadow: 0 0 0 3px rgba(0,217,107,.18);
}

/* ---------- KI-Auswertung ---------- */
#ai-summary { font-size: 0.92rem; line-height: 1.55; }
#ai-summary h3 { margin-top: 12px; }

/* ---------- Bodenarbeit / Equikinetic: Aufnahme-Hinweis & Übungen ---------- */
.exercise-hint {
  margin: 12px 0 10px; padding: 10px 12px; border-radius: var(--r-md, 12px);
  background: var(--accent-soft); border: 1px solid rgba(0, 93, 170, .18);
}
.exercise-hint p { margin: 0; color: var(--ink); }
button.big-marker { font-size: 1.05rem; padding: 16px; }
.ex-form label { display: block; margin-bottom: 8px; }
.ex-form select { width: 100%; }
.ex-cat { margin-bottom: 16px; }
.ex-cat h3 { margin: 0 0 8px; font-size: 0.95rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ex-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px;
  border-radius: var(--r-pill); background: #fff; box-shadow: var(--ctrl-shadow);
  font-size: 0.85rem; font-weight: 600;
}
.ex-chip .ex-name { cursor: pointer; }
.ex-chip .ex-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%;
  background: var(--danger-soft); color: var(--danger); cursor: pointer; box-shadow: none;
}
.ex-chip .ex-del .ic { width: 14px; height: 14px; }

/* ---------- Desktop-Feinschliff ---------- */
@media (min-width: 600px) {
  #app { box-shadow: var(--shadow); min-height: 100vh; }
  body { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #menu, #scrim, .icon-btn, button { transition: none; }
}
