/* =====================================================================
   Fitness-App — Design-System "iOS Native Light"
   Reines CSS, keine Frameworks. Mobile-first, Desktop nachrangig.
   ===================================================================== */

:root {
    --bg: #F2F2F7;
    --card: #FFFFFF;
    --accent: #007AFF;
    --accent-dark: #0062CC;
    --text: #000000;
    --text-2: #8E8E93;
    --sep: #C6C6C8;
    --sep-light: #E5E5EA;
    --red: #FF3B30;
    --red-bg: #FFEDED;
    --green: #34C759;
    --green-bg: #E9FBEF;
    --orange: #FF9500;
    --yellow: #FFCC00;
    --radius: 10px;
    --radius-lg: 16px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-h: 52px;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

h1, h2, h3, p { margin: 0; }

/* Sprungziele für #-Anchor-Links (z.B. "Bearbeiten" in der User-Verwaltung,
   settings.php) — ohne das würde der sticky Header (s.u.) die obersten ~60px
   der Zielkarte verdecken, wenn der Browser dorthin springt. */
#editUserCard, #editInviteCard, #userManagementList,
#gymAnalysisSettingsCard, #gymAnalysisSettingsCardAdmin, #exerciseDetailAnchor {
    scroll-margin-top: calc(var(--header-h) + var(--safe-top) + 12px);
}

/* --- App-Header --------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    height: calc(var(--header-h) + var(--safe-top));
    padding: var(--safe-top) 4px 0;
    background: rgba(242, 242, 247, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--sep-light);
}

.burger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: var(--accent);
    border-radius: 8px;
}
.burger-btn:active { background: rgba(0, 122, 255, 0.12); }

.app-header-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Echter Platzhalter statt eines margin-Hacks auf .app-header-title: so bleibt
   der Titel exakt mittig, EGAL ob rechts ein .header-action-btn steht (z.B.
   Kalender-Icon auf Gym-Analyse) oder nichts — beide sind exakt 44px breit
   wie der Burger-Button links, der Titel füllt symmetrisch den Rest. */
.app-header-spacer { width: 44px; flex-shrink: 0; }

.header-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: var(--accent);
    border-radius: 8px;
    flex-shrink: 0;
}
.header-action-btn:active { background: rgba(0, 122, 255, 0.12); }

/* --- Burger-Menü --------------------------------------------------------- */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 29;
}
.menu-overlay.is-open { opacity: 1; pointer-events: auto; }

.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 82vw);
    background: var(--card);
    z-index: 30;
    display: flex;
    flex-direction: column;
    padding: calc(var(--safe-top) + 20px) 0 calc(var(--safe-bottom) + 16px);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
}
.side-menu.is-open { transform: translateX(0); }

.side-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--sep-light);
    margin-bottom: 8px;
}
.side-menu-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
}
.side-menu-name { font-weight: 600; font-size: 16px; }

.side-menu-list { list-style: none; margin: 0; padding: 4px 0; flex: 1; }

.side-menu-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 20px;
    color: var(--text);
    font-size: 16px;
    min-height: 44px;
}
.side-menu-link svg { color: var(--text-2); flex-shrink: 0; }
.side-menu-link.is-active { color: var(--accent); background: rgba(0, 122, 255, 0.08); }
.side-menu-link.is-active svg { color: var(--accent); }
.side-menu-link:active { background: var(--sep-light); }

.side-menu-footer {
    border-top: 1px solid var(--sep-light);
    padding-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.side-menu-version { font-size: 11px; color: var(--text-2); padding-right: 20px; flex-shrink: 0; }
.side-menu-link-danger { color: var(--red); }
.side-menu-link-danger svg { color: var(--red); }

/* --- Kalender-Modal (Gym-Analyse) ------------------------------------------ */
.calendar-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 39;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.calendar-modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.calendar-modal {
    background: var(--card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 360px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transform: scale(0.94);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
}
.calendar-modal-overlay.is-open .calendar-modal { transform: scale(1); opacity: 1; }

.calendar-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.calendar-modal-title { font-size: 16px; font-weight: 700; }
.calendar-modal-subtitle { text-align: center; font-size: 12px; color: var(--text-2); margin: -6px 0 10px; }
.calendar-nav-btn, .calendar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--sep-light);
    border: none;
    border-radius: 50%;
    color: var(--text);
}
.calendar-nav-btn:active, .calendar-close-btn:active { background: var(--sep); }

.calendar-modal-weekdays, .calendar-modal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.calendar-modal-weekdays { margin-bottom: 4px; }
.calendar-modal-weekdays span { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-2); }

.calendar-modal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border-radius: 50%;
    color: var(--text);
}
.calendar-modal-day.is-outside { visibility: hidden; }
/* Generisch grün/grau (nicht nur Gym) — wiederverwendet für z.B. den
   Protein-Kalender auf der Ernährungs-Analyse (Ziel erreicht/nicht erreicht). */
.calendar-modal-day.is-hit { background: var(--green); color: #fff; font-weight: 600; }
.calendar-modal-day.is-miss { background: var(--sep-light); color: var(--text-2); }
.calendar-modal-day.is-today { box-shadow: 0 0 0 2px var(--accent) inset; }
/* Trainingsfreie Tage (Gym-Analyse-Kalender, s. gym-calendar.js): Gym-Tag
   (is-hit, grün) hat immer Vorrang, falls an einem Tag beides vorliegt. */
.calendar-modal-day.is-vacation { background: var(--yellow); color: var(--text); font-weight: 600; }
.calendar-modal-day.is-sick { background: var(--orange); color: #fff; font-weight: 600; }

/* Kalendertage im "Trainingsfreien Tag"-Popup (gym-tracking.php) sind echte
   <button>-Elemente, klickbar für die Zeitspannen-Auswahl — anders als der
   reine Anzeige-Kalender in der Gym-Analyse. Browser-Standardstil zurücksetzen,
   sonst überlagert er Rand/Hintergrund der Zustands-Klassen oben. */
button.calendar-modal-day {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
}
button.calendar-modal-day:disabled { cursor: default; }
/* Zeitspannen-Auswahl selbst (nicht zu verwechseln mit is-hit/is-miss/
   is-vacation/is-sick oben, die vergangene/geplante Tage im ANZEIGE-Kalender
   einfärben): Start-/Endtag als ausgefüllter Kreis, dazwischenliegende Tage
   als helle Fläche — kein durchgehender Balken, weil die Zellen durch den
   Grid-gap sichtbar getrennt bleiben (bewusst, s. .calendar-modal-grid). */
.calendar-modal-day.is-range-endpoint { background: var(--accent); color: #fff; font-weight: 600; }
.calendar-modal-day.is-range-mid { background: rgba(0, 122, 255, 0.15); color: var(--text); }

/* Teilerfolg an verfehlten Tagen (--pct als Zahl 0–99, per JS gesetzt):
   ein grüner Ring am Rand des Kreises, dessen Bogenlänge dem Prozentsatz
   entspricht — 50% Zielerreichung ergibt so einen grünen Halbkreis-Rand.
   Der Ring wird per conic-gradient + Mask-Subtraktion gezeichnet, damit die
   Zahl in der Mitte weiterhin auf grauem Grund lesbar bleibt. */
.calendar-modal-day-num { position: relative; }
.calendar-modal-day.has-pct { position: relative; }
.calendar-modal-day.has-pct::before {
    content: '';
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    border-radius: 50%;
    padding: 2px;
    background: conic-gradient(var(--green) calc(var(--pct) * 1%), transparent 0);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-2);
}
.calendar-legend-item { display: flex; align-items: center; gap: 6px; }
.calendar-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.calendar-legend-dot.is-hit { background: var(--green); }
.calendar-legend-dot.is-miss { background: var(--sep-light); }
.calendar-legend-dot.is-partial { background: var(--sep-light); border: 2px solid var(--green); }
.calendar-legend-dot.is-vacation { background: var(--yellow); }
.calendar-legend-dot.is-sick { background: var(--orange); }

/* --- Info-Popover (z.B. "Zielerreichung"-Erklärung, Ernährungs-Analyse) --- */
/* Kurzes Erklär-Popup, das beim Antippen einer Kennzahl aufklappt, von selbst
   nach ein paar Sekunden wieder verschwindet, aber jederzeit per X-Button
   früher geschlossen werden kann. Fixiert am unteren Bildschirmrand wie
   .toast, aber mit mehr Platz für Fließtext statt einer einzeiligen Meldung. */
.info-popover {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(20px + var(--safe-bottom));
    max-width: 480px;
    margin: 0 auto;
    background: var(--card);
    color: var(--text);
    border-radius: var(--radius-lg);
    padding: 14px 38px 14px 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 60;
}
.info-popover.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.info-popover-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.info-popover p { font-size: 13px; line-height: 1.45; color: var(--text-2); }
.info-popover-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--sep-light);
    color: var(--text-2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.info-popover-close:active { background: var(--sep); }

/* --- Main / Layout --------------------------------------------------------- */
.app-main {
    padding: 16px 16px calc(24px + var(--safe-bottom));
    max-width: 640px;
    margin: 0 auto;
}

/* --- Section-Header --------------------------------------------------------- */
.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 10px;
}
.section-header:first-child { margin-top: 4px; }
.section-title { font-size: 20px; font-weight: 700; }
.section-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* --- Karten --------------------------------------------------------------- */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}

/* .card, das gleichzeitig ein <button> ist (z.B. Streak-/Wochen-Karten auf
   der Gym-Analyse, antippbar für Details) — setzt die UA-Button-Optik zurück. */
.card-btn {
    border: none;
    width: 100%;
    text-align: center;
    cursor: pointer;
    display: block;
}
.card-btn:active { background: var(--sep-light); }

.quicklink-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.quicklink-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    background: var(--card);
    border-radius: var(--radius-lg);
    text-align: center;
    font-size: 13px;
    font-weight: 500;
}
.quicklink-card:active { background: var(--sep-light); }
.quicklink-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 122, 255, 0.1);
    color: var(--accent);
}

.stat-row { display: flex; gap: 10px; }
.stat-card { flex: 1; background: var(--card); border-radius: var(--radius-lg); padding: 14px; display: block; }
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* Touch-Feedback für .card/.stat-card, die als <a> verlinkt sind (z.B. Home:
   Letztes Training, Heute, Aktuelles Gewicht) — .card-btn deckt nur <button> ab. */
a.card:active, a.stat-card:active { background: var(--sep-light); }

/* --- Gruppierte Listen (iOS-Style) --------------------------------------- */
.list {
    background: var(--card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 12px;
}
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    min-height: 44px;
    border-bottom: 1px solid var(--sep-light);
}
.list-row:last-child { border-bottom: none; }
.list-row.is-link:active { background: var(--sep-light); }

/* Listenzeile als <button> in einem <form> — nötig, wo der Klick etwas ANLEGT
   (Trainingsstart, s. gym-tracking.php): das lief früher über einen GET-Link,
   der sich von jeder fremden Seite aus auslösen ließ. Optisch soll die Zeile
   identisch bleiben, deshalb hier der Button-Reset. */
button.list-row {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
/* Der <form>-Wrapper macht jede Zeile zum letzten Kind ihres Elternelements —
   ohne diese beiden Regeln greift .list-row:last-child auf ALLE Zeilen und
   sämtliche Trennlinien verschwinden. */
.list > form .list-row { border-bottom: 1px solid var(--sep-light); }
.list > form:last-child .list-row { border-bottom: none; }
.list-row-title { font-size: 16px; font-weight: 500; }
.list-row-subtitle { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.list-row-chevron { color: var(--sep); flex-shrink: 0; }
.list-row-actions { display: flex; gap: 8px; flex-shrink: 0; }

.list-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-2);
    font-size: 14px;
}

/* Suchfeld über einer .list (z.B. globale Übungen/Lebensmittel in den
   Admin-Einstellungen) — bewusst eigenständig statt in .field gewrappt,
   da hier kein <label> nötig ist. */
.list-search-input {
    display: block;
    width: 100%;
    font-size: 16px; /* verhindert Auto-Zoom bei Fokus auf iOS Safari */
    padding: 10px 14px;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    margin-top: 10px;
}
.list-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
    vertical-align: middle;
}
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-pending { background: rgba(255, 149, 0, 0.15); color: var(--orange); }

/* --- Buttons --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--radius);
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: rgba(0, 122, 255, 0.1); color: var(--accent); }
.btn-secondary:active { background: rgba(0, 122, 255, 0.2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:active { background: #FFDADA; }
.btn-plain { background: none; color: var(--accent); padding: 0 8px; min-height: 36px; font-weight: 500; }
.btn-sm { min-height: 30px; padding: 0 14px; font-size: 13px; border-radius: 100px; }

/* --- Trainings-Timer (Gym-Tracking, "Training läuft") ----------------------- */
/* tabular-nums: verhindert, dass die Breite bei jedem Sekundentick springt,
   weil z.B. "1" schmaler ist als "8" — sonst "hüpft" der Pause-Button daneben. */
.session-timer { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.btn-icon { width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 8px; }
.btn:disabled { opacity: 0.4; }

/* --- Formulare --------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 6px;
    font-weight: 500;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field input[type="date"],
.field select,
.field textarea {
    width: 100%;
    font-size: 16px; /* wichtig: verhindert Auto-Zoom bei Fokus auf iOS Safari */
    padding: 12px 14px;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
}
.field textarea { resize: vertical; min-height: 70px; font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}
.field-hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* Login-Formular nutzt eigene, größere Feld-Optik */
.login-body { background: var(--bg); }
.login-wrap {
    max-width: 360px;
    margin: 0 auto;
    padding: calc(var(--safe-top) + 64px) 20px 40px;
    text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-title { font-size: 26px; font-weight: 700; }
.login-subtitle { font-size: 14px; color: var(--text-2); margin-top: 4px; margin-bottom: 24px; }
.login-form { text-align: left; }
.login-form label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; font-weight: 500; }
.login-form input {
    width: 100%;
    font-size: 16px;
    padding: 13px 14px;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    background: var(--card);
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15); }
.login-form .btn { margin-top: 22px; }
.login-invite-link {
    display: block;
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-2);
    text-align: center;
    text-decoration: none;
}
.login-invite-link:hover { color: var(--accent); text-decoration: underline; }

/* --- Zahlen-Stepper (Gewicht/Wdh) — bediengerecht für schwitzige Finger --- */
.stepper {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--card);
}
.stepper-btn {
    width: 48px;
    flex-shrink: 0;
    background: var(--sep-light);
    border: none;
    font-size: 20px;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stepper-btn:active { background: var(--sep); }
.stepper input {
    flex: 1;
    min-width: 0;
    border: none;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    padding: 8px 4px;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
}
.stepper input:focus { outline: none; }
.stepper-label {
    text-align: center;
    font-size: 11px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 4px;
}

.stepper-row { display: flex; gap: 10px; }
.stepper-col { flex: 1; }

/* Zahlenfelder in .stepper-col (Übungs-/Ziel-Werte): gemeinsame Basis-Optik statt
   wiederholtem Inline-Style auf jedem einzelnen Feld. Die drei Tagesziel-Felder
   (goal_protein_g/goal_carbs_g/goal_fat_g) behalten ihr etwas größeres Padding. */
.stepper-col input[type="number"] {
    width: 100%;
    font-size: 16px;
    padding: 8px;
    border: 1px solid var(--sep);
    border-radius: 8px;
}
.stepper-col input[name^="goal_"] {
    padding: 10px;
}

/* --- Segmented Control --------------------------------------------------- */
.segmented {
    display: flex;
    background: var(--sep-light);
    border-radius: var(--radius);
    padding: 2px;
    gap: 2px;
}
.segmented button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
    min-height: 36px;
}
.segmented button.is-active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* --- Flash / Toast --------------------------------------------------------- */
.flash {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 14px;
}
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-success { background: var(--green-bg); color: #248A3D; }
.flash-info { background: rgba(0, 122, 255, 0.1); color: var(--accent-dark); }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + var(--safe-bottom));
    transform: translate(-50%, 20px);
    background: rgba(28, 28, 30, 0.92);
    color: #fff;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --- Set-/Log-Reihen (Gym-Tracking) --------------------------------------- */
.set-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--sep-light);
}
.set-row:last-child { border-bottom: none; }
.set-row-number {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--sep-light);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.set-row input {
    width: 100%;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    padding: 8px 4px;
    border: 1px solid var(--sep);
    border-radius: 8px;
    background: var(--card);
}
.set-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15); }
/* Explizit Browser-Standardbutton zurücksetzen (Rand/Hintergrund/Ecken) —
   sonst rendern manche Browser dieses <button> mit eigener, eckiger Optik
   statt des gewünschten grauen Kreises. */
.set-row-remove {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    border-radius: 50%;
    background: var(--sep-light);
    color: var(--red);
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.set-row-remove:active { background: var(--sep); }

/* Aufwärmsatz-Schalter — gleiche Kreis-Optik wie der Entfernen-Button.
   Aufwärmsätze sind in Rekorden und Auswertungen ausgeklammert (is_warmup = 0
   als Filter in chart-data.php); ohne diesen Schalter ließ sich das Feld gar
   nicht setzen und der Filter lief ins Leere. */
.set-row-warmup {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    border-radius: 50%;
    background: var(--sep-light);
    color: var(--text-2);
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.set-row-warmup:active { background: var(--sep); }
.set-row.is-warmup .set-row-warmup { background: rgba(255, 149, 0, 0.15); color: var(--orange); }
/* Markierte Aufwärmsätze treten optisch zurück — sie sind Beiwerk, nicht das
   Ergebnis des Trainings. */
.set-row.is-warmup .set-row-number { background: transparent; border: 1px dashed var(--sep); }
.set-row.is-warmup .set-weight, .set-row.is-warmup .set-reps { opacity: 0.65; }

.prev-value {
    font-size: 13px;
    color: var(--accent);
    background: rgba(0, 122, 255, 0.08);
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 10px;
}
/* Progressions-Vorschlag (gym-tracking.php): eigene Akzentfarbe, damit er sich
   optisch vom reinen "Letztes Mal"-Hinweis abhebt. */
.prev-value.is-suggestion {
    color: #248A3D;
    background: var(--green-bg);
}

/* --- Tages-Navigation (Körpergewicht/Gym-Tracking/Ernährungs-Tracking) ---- */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
/* <a> statt <button>: die Tagesnavigation ist ein reiner Seitenwechsel und
   kam vorher nur über onclick="location.href=…" zustande — als Link
   funktioniert sie auch mit Tastatur, Mittelklick und ohne inline-JS (CSP). */
.calendar-nav button, .calendar-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--accent);
    width: 40px;
    height: 40px;
    font-size: 20px;
    text-decoration: none;
}
.calendar-nav-label { font-size: 16px; font-weight: 600; }

/* --- Diagramm-Container --------------------------------------------------- */
.chart-card { background: var(--card); border-radius: var(--radius-lg); padding: 16px 12px 8px; margin-bottom: 12px; }
.chart-card-title { font-size: 15px; font-weight: 600; padding: 0 4px 4px; }
.chart-card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 4px; }
.chart-card-title-row .chart-card-title { padding: 0; }
.chart-info-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--sep-light);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}
.chart-info-btn:active { background: var(--sep); }
.chart-wrap { position: relative; height: 220px; width: 100%; }
.chart-empty { padding: 40px 16px; text-align: center; color: var(--text-2); font-size: 14px; }

/* --- Progress-Bar (Tagesziele) --------------------------------------------- */
.progress-track { height: 8px; border-radius: 4px; background: var(--sep-light); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s ease; }
.progress-fill.is-over { background: var(--orange); }
/* Kalorien-Balken im Ernährungs-Tracking: 80–99% des Tageslimits -> Orange
   (nähert sich dem Limit), ab 100% -> Rot (Limit erreicht/überschritten). */
.progress-fill.is-near-limit { background: var(--orange); }
.progress-fill.is-limit-exceeded { background: var(--red); }

/* --- Macro-Chips --------------------------------------------------------- */
.macro-row { display: flex; gap: 8px; margin-top: 10px; }
.macro-chip { flex: 1; text-align: center; }
.macro-chip-value { font-size: 15px; font-weight: 700; }
.macro-chip-value.is-over-limit { color: var(--red); }
/* #248A3D statt --green (#34C759): das helle Grün ist als Flächenfarbe gedacht
   und auf weißer Karte als Text kaum lesbar — dieselbe dunklere Variante nutzen
   schon .flash-success und .prev-value.is-suggestion. */
.macro-chip-value.is-goal-met { color: #248A3D; }
.macro-chip-label { font-size: 11px; color: var(--text-2); }

/* --- Toggle-Schalter (z.B. "Gym-Analyse Einstellungen") -------------------- */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input[type="checkbox"] { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
    position: absolute;
    inset: 0;
    background: var(--sep-light);
    border-radius: 100px;
    transition: background 0.2s ease;
    pointer-events: none;
}
.switch-track::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* --- Utility --------------------------------------------------------------- */
.text-secondary { color: var(--text-2); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* --- Übungsauswahl (plan-edit.js) --------------------------------------- */
.ex-select {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    padding: 10px 12px;
    border: 1px solid var(--sep);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
}
.ex-select:focus { outline: none; border-color: var(--accent); }

/* --- Suche / Autocomplete --------------------------------------------- */
.search-results { max-height: 280px; overflow-y: auto; margin-top: 8px; }
.search-result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 4px;
    border-bottom: 1px solid var(--sep-light);
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:active { background: var(--sep-light); }

/* --- Desktop (nachrangig, aber vorhanden) --------------------------------- */
@media (min-width: 768px) {
    .app-main { padding: 24px 16px 40px; }
    .quicklink-grid { max-width: 480px; }
    .card, .list { margin-bottom: 16px; }
}
