/* ========================================
   Theme Tokens (Light = Default)
   Dark mode overrides further below.
   ======================================== */
:root {
    color-scheme: light;

    /* Surfaces & background */
    --bg: #f4f4f4;
    --surface: #ffffff;
    --surface-2: #f8f9fa;
    --surface-3: #ecf0f1;

    /* Text */
    --text: #333333;
    --heading: #2c3e50;
    /* Text-Farben jeweils mind. 4.5:1 auf Flächen/Hintergrund (WCAG AA) */
    --text-muted: #5f6b6d;
    --text-soft: #5d6d7e;
    --on-accent: #ffffff;
    --on-primary: #ffffff;   /* Schrift auf var(--primary) */

    /* Brand / accents */
    --primary: #2471a3;
    --primary-hover: #1f6391;
    --secondary: #637174;
    --secondary-hover: #535f62;
    --success: #2ecc71;
    --success-hover: #27ae60;
    --success-bg: #f4fbf6;
    --success-text: #1e7e45;
    --warning: #f39c12;
    --warning-text: #9a5b00;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --danger-bg: #fdecea;
    --record-bg: #fff4d6;
    --record-text: #8a5a00;

    /* Kalender-Heatmap: Stufe 0 (kein Training) bis 4 */
    --heat-0: #ebedf0;
    --heat-1: #9be9a8;
    --heat-2: #40c463;
    --heat-3: #268541;
    --heat-4: #1a5c30;
    /* Schrift auf den Stufen der Monatsansicht (jeweils mind. 4.5:1) */
    --heat-fg-2: var(--text);
    --heat-fg-strong: #ffffff;

    /* Header / tabs */
    --header-bg: #2c3e50;
    --tab-bg: #34495e;
    --tab-hover: #4a5f7f;
    --tab-inactive: #bdc3c7;

    /* Borders & dividers */
    --border: #dddddd;
    --border-soft: #e0e6ea;
    --border-input: #d5dbdb;
    --divider: #ecf0f1;

    /* Misc */
    --plan-active-bg: #f4f9fd;
    --footer-text: #737373;

    /* Shadows */
    --shadow-1: rgba(0, 0, 0, 0.1);
    --shadow-2: rgba(0, 0, 0, 0.15);
    --shadow-soft: rgba(0, 0, 0, 0.08);

    /* Decorative gradients (kept across themes) */
    --grad-purple-1: #667eea;
    --grad-purple-2: #764ba2;
    --grad-heute-1: #2c3e50;
    --grad-heute-2: #3498db;
    /* Weiße Schrift: auch der hellste Punkt erreicht mind. 4.5:1 (#647382 ≈ 4.9:1) */
    --grad-rest-1: #3f4c59;
    --grad-rest-2: #647382;
}

/* Dark palette — system preference (no explicit override) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #14181d;
        --surface: #1e242c;
        --surface-2: #262d36;
        --surface-3: #2d353f;

        --text: #d7dde3;
        --heading: #e8edf2;
        --text-muted: #9aa7b3;
        --text-soft: #aab5c0;
        --on-accent: #ffffff;

        --primary: #4aa3e0;
        --primary-hover: #6cb6e8;
        --on-primary: #0d1b26;   /* weiße Schrift hätte auf dem hellen Blau nur 2.8:1 */
        --secondary: #56616b;
        --secondary-hover: #6b7883;
        --success: #2ecc71;
        --success-hover: #29b866;
        --success-bg: #17301f;
        --success-text: #2ecc71;
        --warning: #f39c12;
        --warning-text: #f5b041;
        --danger: #e96054;
        --danger-dark: #ff6b5e;
        --danger-bg: #3a1e1b;
        --record-bg: #3a2f12;
        --record-text: #f5c451;

        --heat-0: #2a313a;
        --heat-1: #1b5e3a;
        --heat-2: #26954f;
        --heat-3: #3cc768;
        --heat-4: #6ef08f;
        --heat-fg-2: var(--heat-fg-strong);
        --heat-fg-strong: #0b1a10;

        --header-bg: #10151a;
        --tab-bg: #232b34;
        --tab-hover: #2f3944;
        --tab-inactive: #8593a0;

        --border: #3a434d;
        --border-soft: #3a434d;
        --border-input: #454f5a;
        --divider: #2d353f;

        --plan-active-bg: #1b2733;
        --footer-text: #8a94a0;

        --shadow-1: rgba(0, 0, 0, 0.45);
        --shadow-2: rgba(0, 0, 0, 0.55);
        --shadow-soft: rgba(0, 0, 0, 0.4);
    }
}

/* Dark palette — explicit override (wins over system) */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #14181d;
    --surface: #1e242c;
    --surface-2: #262d36;
    --surface-3: #2d353f;

    --text: #d7dde3;
    --heading: #e8edf2;
    --text-muted: #9aa7b3;
    --text-soft: #aab5c0;
    --on-accent: #ffffff;

    --primary: #4aa3e0;
    --primary-hover: #6cb6e8;
    --on-primary: #0d1b26;   /* weiße Schrift hätte auf dem hellen Blau nur 2.8:1 */
    --secondary: #56616b;
    --secondary-hover: #6b7883;
    --success: #2ecc71;
    --success-hover: #29b866;
    --success-bg: #17301f;
    --success-text: #2ecc71;
    --warning: #f39c12;
    --warning-text: #f5b041;
    --danger: #e96054;
    --danger-dark: #ff6b5e;
    --danger-bg: #3a1e1b;
    --record-bg: #3a2f12;
    --record-text: #f5c451;

    --heat-0: #2a313a;
    --heat-1: #1b5e3a;
    --heat-2: #26954f;
    --heat-3: #3cc768;
    --heat-4: #6ef08f;
    --heat-fg-2: var(--heat-fg-strong);
    --heat-fg-strong: #0b1a10;

    --header-bg: #10151a;
    --tab-bg: #232b34;
    --tab-hover: #2f3944;
    --tab-inactive: #8593a0;

    --border: #3a434d;
    --border-soft: #3a434d;
    --border-input: #454f5a;
    --divider: #2d353f;

    --plan-active-bg: #1b2733;
    --footer-text: #8a94a0;

    --shadow-1: rgba(0, 0, 0, 0.45);
    --shadow-2: rgba(0, 0, 0, 0.55);
    --shadow-soft: rgba(0, 0, 0, 0.4);
}

/* Allgemeine Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    transition: background-color 0.3s, color 0.3s;
}

/* Header Styling */
header {
    background-color: var(--header-bg);
    color: var(--on-accent);
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 5px var(--shadow-1);
}

header h1 {
    margin-bottom: 20px;
    font-size: 2em;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.tab-button {
    background-color: var(--tab-bg);
    color: var(--on-accent);
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px 5px 0 0;
    transition: background-color 0.3s;
}

.tab-button:hover {
    background-color: var(--tab-hover);
}

/* Aktiver Tab-Button */
.tab-button.active {
    background-color: var(--primary);
    color: var(--on-primary);
    font-weight: bold;
}

/* Icons nur in der mobilen Bottom-Bar sichtbar */
.tab-icon {
    display: none;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Main Content Area (Desktop: max. ~960 px Inhaltsbreite) */
main {
    max-width: 960px;
    margin: 30px auto;
    padding: 0 20px;
}

/* Tab Content Sections */
.tab-content {
    display: none; /* Standardmäßig versteckt */
    background-color: var(--surface);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-1);
    animation: fadeIn 0.3s;
}

/* Aktiver Tab Content */
.tab-content.active {
    display: block; /* Nur der aktive Tab wird angezeigt */
}

/* Fade-in Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Überschriften in Content */
.tab-content h2 {
    color: var(--heading);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}

/* Form Styling */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--heading);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--on-accent);
    margin-top: 10px;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

/* Saved Info Display */
.saved-info {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--surface-3);
    border-radius: 8px;
}

.saved-info h3 {
    color: var(--heading);
    margin-bottom: 15px;
}

.info-display p {
    margin: 10px 0;
    font-size: 16px;
}

.info-display strong {
    color: var(--heading);
}

/* Form Sections (for grouping fields) */
.form-section {
    background-color: var(--surface-2);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.form-section h4 {
    color: var(--heading);
    margin-bottom: 15px;
    font-size: 1.2em;
}

/* Form Actions (button group) */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions .btn-primary,
.form-actions .btn-secondary {
    flex: 1;
    margin-top: 0;
}

/* Select Dropdowns */
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Training List */
#training-list-container {
    margin-top: 30px;
}

#training-list-container h3 {
    color: var(--heading);
    margin-bottom: 20px;
}

.no-data {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 40px;
}

/* Training Cards (for displaying saved trainings) */
.training-card {
    background-color: var(--surface);
    border-left: 5px solid var(--primary);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 5px var(--shadow-1);
}

.training-card.intensity-1,
.training-card.intensity-2 {
    border-left-color: var(--success); /* Grün für leicht */
}

.training-card.intensity-3 {
    border-left-color: var(--warning); /* Orange für mittel */
}

.training-card.intensity-4,
.training-card.intensity-5 {
    border-left-color: var(--danger); /* Rot für intensiv */
}

.training-card h4 {
    color: var(--heading);
    margin-bottom: 10px;
}

.training-card-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 8px;
    margin-bottom: 15px;
}

.training-card-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.training-card-date {
    color: var(--text-muted);
    font-size: 0.9em;
}

.training-card-toggle {
    display: none;
    /* echter Button (Tastatur/Screenreader), optisch nur der Pfeil */
    background: none;
    border: none;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.training-card-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.training-card-details p {
    margin: 5px 0;
    font-size: 0.95em;
}

.training-card-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
    padding-top: 8px;
    border-top: 1px solid var(--divider);
}

.btn-ghost.training-mini {
    padding: 8px 14px;
    font-size: 0.9em;
    min-height: 44px;
}

.btn-ghost.training-mini.danger {
    color: var(--danger-dark);
}

.btn-ghost.training-mini.danger:hover {
    background-color: var(--danger-bg);
    color: var(--danger-dark);
}

.show-more-btn {
    display: block;
    margin: 15px auto 0;
}

/* Suche & Filter im Verlauf */
.training-filter {
    margin-bottom: 15px;
}

.training-filter[hidden],
.training-filter-panel[hidden] {
    display: none;
}

.training-filter-bar {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.training-filter-bar input[type="search"] {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

.training-filter-bar input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
}

.training-filter-toggle {
    flex: none;
    min-height: 44px;
    padding: 10px 16px;
    margin-top: 0;
}

.training-filter-toggle.active,
.training-filter-toggle.active:hover {
    background-color: var(--primary);
    color: var(--on-primary);
}

.training-filter-panel {
    margin-top: 10px;
    padding: 12px;
    background-color: var(--surface-2);
    border-radius: 8px;
}

.training-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0 12px;
}

.training-filter-grid .form-group {
    margin-bottom: 10px;
}

.training-filter-grid select,
.training-filter-grid input {
    min-height: 44px;
}

.training-filter-reset {
    min-height: 44px;
    padding: 10px 12px;
}

.training-filter-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.training-filter-summary-row[hidden] {
    display: none;
}

.training-filter-summary {
    margin: 0;
}

.training-filter-empty {
    padding: 16px 12px;
}

.training-filter-empty p {
    margin: 0;
}

.training-filter-empty .btn-secondary {
    margin-top: 10px;
    font-style: normal;
}

/* Analysis Tab Styling */
.filter-section {
    margin-bottom: 30px;
    padding: 15px;
    background-color: var(--surface-2);
    border-radius: 8px;
}

.filter-section label {
    font-weight: bold;
    margin-right: 10px;
    color: var(--heading);
}

.filter-section select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    min-height: 44px;
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

/* Stat Cards */
.stat-card {
    background-color: var(--surface);
    padding: 12px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-1);
    text-align: center;
    border-top: 3px solid var(--primary);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px var(--shadow-2);
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: normal;
}

.stat-value {
    color: var(--heading);
    font-size: 1.5em;
    font-weight: bold;
    margin: 4px 0;
}

.stat-detail {
    color: var(--text-muted);
    font-size: 0.8em;
    margin-top: 3px;
}

/* Charts */
.charts-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    min-width: 0;
}

.chart-box {
    background-color: var(--surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-1);
    overflow: hidden;
    min-width: 0;
}

.chart-box.full-width {
    grid-column: 1 / -1;
}

.chart-box h4 {
    color: var(--heading);
    margin-bottom: 15px;
    text-align: center;
}

/* Höhe steuert Chart.js über aspectRatio – kein max-height, sonst verzerrt der Canvas */
.chart-box canvas {
    width: 100% !important;
    max-width: 100%;
}

@media (max-width: 768px) {
    header {
        padding: 12px 10px;
    }

    header h1 {
        font-size: 1.3em;
        margin-bottom: 0;
    }

    /* Bottom Tab Bar (App-Stil) */
    .tab-navigation {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background-color: var(--header-bg);
        gap: 2px;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.25);
    }

    .tab-button {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 2px;
        font-size: 11px;
        min-height: 48px;
        border-radius: 8px;
        background-color: transparent;
        color: var(--tab-inactive);
    }

    .tab-button:hover {
        background-color: transparent;
    }

    .tab-button.active {
        background-color: var(--primary);
        color: var(--on-primary);
    }

    .tab-icon {
        display: block;
    }

    .tab-label {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Platz für die fixe Bottom-Bar (inkl. iPhone Home-Indikator) */
    body {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }

    /* Fokus- und Anker-Scrollen hält Ziele über Bottom-Bar, FAB und Timer-Leiste */
    html {
        scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

    html:has(> body.has-fab),
    html:has(> body.has-timer-bar) {
        scroll-padding-bottom: calc(150px + env(safe-area-inset-bottom));
    }

    html:has(> body.has-fab.has-timer-bar) {
        scroll-padding-bottom: calc(206px + env(safe-area-inset-bottom));
    }

    /* Unten Abstand, damit Toasts (über der Bottom-Bar) die letzten Buttons
       eines Tabs nicht verdecken */
    main {
        padding: 0 10px;
        margin: 15px auto 60px;
    }

    .tab-content {
        padding: 15px;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-box {
        padding: 10px;
    }

    /* minmax(0, 1fr): gleich breite Spalten, auch bei langen Überschriften */
    .stats-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-card .stat-value {
        font-size: 1.2em;
        word-break: break-word;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group select {
        max-width: 100%;
    }

    .correlation-filters {
        padding: 15px;
    }

    .insight-box {
        padding: 15px;
    }

    .training-card {
        cursor: pointer;
    }

    .training-card-header {
        margin-bottom: 0;
    }

    .training-card-toggle {
        display: inline-block;
        font-size: 0.7em;
        color: var(--text-muted);
        transition: transform 0.2s;
    }

    /* visibility nimmt eingeklappte Details aus Tab-Reihenfolge und
       Screenreader-Ausgabe; die Verzögerung erhält die Einklapp-Animation. */
    .training-card-details {
        max-height: 0;
        overflow: hidden;
        visibility: hidden;
        transition: max-height 0.3s ease, visibility 0s linear 0.3s;
    }

    .training-card.expanded .training-card-details {
        /* Platz für viele Übungen (seit v2.0.0 mehrere pro Training) */
        max-height: 2400px;
        margin-top: 15px;
        visibility: visible;
        transition: max-height 0.3s ease, visibility 0s;
    }

    .training-card.expanded .training-card-toggle {
        transform: rotate(180deg);
    }
}

/* Correlations Section */
.correlations-section {
    margin-top: 40px;
}

.correlations-section h3 {
    color: var(--heading);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.correlation-filters {
    background-color: var(--surface-2);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: bold;
    color: var(--heading);
    min-width: 80px;
}

.filter-group select {
    flex: 1;
    max-width: 400px;
}

/* Insight Box */
.insight-box {
    background: linear-gradient(135deg, var(--grad-purple-1) 0%, var(--grad-purple-2) 100%);
    color: var(--on-accent);
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.insight-box h4 {
    color: var(--on-accent);
    margin-bottom: 10px;
    font-size: 1.2em;
}

.insight-box p {
    font-size: 1.1em;
    line-height: 1.6;
    margin: 0;
}

/* Footer / Versionsnummer */
.app-footer {
    text-align: center;
    padding: 20px;
    color: var(--footer-text);
    font-size: 0.8em;
}

/* ========================================
   Reminder Banner
   ======================================== */
.reminder-banner {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    background-color: var(--surface);
    border-left: 6px solid var(--warning);
    padding: 20px 25px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-1);
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reminder-banner-content {
    flex: 1;
    min-width: 250px;
}

.reminder-banner-content h3 {
    color: var(--heading);
    margin-bottom: 6px;
    font-size: 1.15em;
}

.reminder-banner-content p {
    color: var(--text-soft);
    font-size: 0.95em;
    margin: 0;
}

.reminder-banner-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reminder-banner-actions .btn-primary,
.reminder-banner-actions .btn-secondary,
.reminder-banner-actions .btn-ghost {
    margin-top: 0;
    padding: 10px 18px;
    font-size: 0.95em;
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-muted);
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.btn-ghost:hover {
    background-color: var(--surface-3);
    color: var(--heading);
}

/* ========================================
   Settings Tab — Streak Box + Form
   ======================================== */
.streak-box {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, var(--grad-purple-1) 0%, var(--grad-purple-2) 100%);
    color: var(--on-accent);
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px var(--shadow-2);
}

.streak-value {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 2.5em;
    font-weight: bold;
    line-height: 1;
}

.streak-value #streak-emoji {
    font-size: 1em;
}

.streak-label {
    flex: 1;
}

.streak-label p {
    margin: 3px 0;
    font-size: 1.05em;
}

.streak-last {
    opacity: 0.85;
    font-size: 0.9em !important;
}

#reminder-settings-form h3,
#smart-reminder-settings-form h3,
#timer-settings-form h3,
#data-backup h3 {
    color: var(--heading);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 8px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background-color: var(--surface-2);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: normal !important;
    margin-bottom: 0 !important;
}

.checkbox-label:hover {
    background-color: var(--surface-3);
}

.checkbox-label input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-label span {
    color: var(--heading);
}

.toggle-label {
    background-color: var(--surface-2);
}

.settings-status {
    margin-top: 15px;
    padding: 10px 15px;
    background-color: var(--success);
    color: var(--on-accent);
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    animation: fadeIn 0.3s;
}

/* Daten / Backup */
.data-backup {
    margin-top: 35px;
}

.data-backup-actions {
    flex-wrap: wrap;
}

.data-csv {
    margin-top: 16px;
}

.data-backup-warning {
    margin-top: 12px;
    color: var(--danger);
}

.storage-persist-status {
    margin-top: 12px;
}

.storage-persist-status.storage-persist-ok {
    color: var(--success-text);
}

.storage-persist-status.storage-persist-warn {
    color: var(--warning-text);
}

/* Theme (dark mode) setting row */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background-color: var(--surface-2);
    border-radius: 8px;
    margin-bottom: 20px;
}

.setting-row-text h3 {
    color: var(--heading);
    font-size: 1.1em;
    margin: 0 0 3px 0;
    border: none;
    padding: 0;
}

.setting-row-text p {
    color: var(--text-muted);
    font-size: 0.88em;
    margin: 0;
}

/* Segmented control (System / Hell / Dunkel) */
.segmented {
    display: inline-flex;
    background-color: var(--surface-3);
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
}

.segmented button {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 8px 14px;
    font-size: 0.9em;
    border-radius: 6px;
    cursor: pointer;
    min-height: 40px;
    transition: background-color 0.2s, color 0.2s;
}

.segmented button.active {
    background-color: var(--primary);
    color: var(--on-primary);
    font-weight: bold;
}

/* Mobile adjustments for reminder + settings */
@media (max-width: 768px) {
    .reminder-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        padding: 18px;
    }

    .reminder-banner-actions {
        flex-direction: column;
    }

    .reminder-banner-actions button {
        width: 100%;
    }

    .streak-box {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        padding: 20px;
    }

    .streak-value {
        font-size: 2em;
    }
}

/* ========================================
   Heute-Widget (Trainingslog)
   ======================================== */
.heute-widget {
    margin-bottom: 25px;
}

.heute-card {
    background: linear-gradient(135deg, var(--grad-heute-1) 0%, var(--grad-heute-2) 100%);
    color: #ffffff;
    padding: 22px 24px;
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-2);
    animation: slideDown 0.4s ease-out;
}

.heute-card.heute-rest {
    background: linear-gradient(135deg, var(--grad-rest-1) 0%, var(--grad-rest-2) 100%);
}

/* Auf dem helleren Grau ohne Abschwächung bzw. aufhellenden Chip, sonst
   fällt der Kontrast unter 4.5:1 */
.heute-rest .heute-eyebrow {
    opacity: 1;
}

.heute-rest .heute-week {
    background-color: rgba(0, 0, 0, 0.2);
}

.heute-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.heute-eyebrow {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.8em;
    opacity: 0.85;
    font-weight: bold;
}

.heute-week {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}

.heute-plan-name {
    font-size: 1.3em;
    font-weight: bold;
    margin: 0 0 12px 0;
}

.heute-msg {
    font-size: 1.05em;
    margin: 0;
    line-height: 1.5;
}

.heute-msg.heute-done {
    font-weight: bold;
    margin-bottom: 8px;
}

.heute-list {
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
}

.heute-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.heute-list li:last-child {
    border-bottom: none;
}

.he-name {
    font-weight: bold;
}

.he-detail {
    opacity: 0.9;
    font-size: 0.95em;
    text-align: right;
    white-space: nowrap;
}

.heute-notes {
    font-size: 0.9em;
    opacity: 0.9;
    margin: 0 0 16px 0;
    font-style: italic;
}

.heute-card .btn-primary {
    background-color: #ffffff;
    color: #2c3e50;
    margin-top: 0;
    width: 100%;
}

.heute-card .btn-primary:hover {
    background-color: #ecf0f1;
}

.link-btn {
    background: none;
    border: none;
    color: #ffffff;
    text-decoration: underline;
    cursor: pointer;
    font-size: 1em;
    padding: 0;
    font-weight: bold;
}

/* ========================================
   Rest Timer (Trainingslog)
   ======================================== */
.rest-timer {
    margin-bottom: 25px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-1);
    overflow: hidden;
}

.rest-timer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
}

.rest-timer-header h3 {
    color: var(--heading);
    font-size: 1.05em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rest-timer-chevron {
    color: var(--text-muted);
    font-size: 0.8em;
    transition: transform 0.2s;
}

.rest-timer.open .rest-timer-chevron {
    transform: rotate(180deg);
}

.rest-timer-body {
    display: none;
    padding: 0 18px 20px 18px;
}

.rest-timer.open .rest-timer-body {
    display: block;
}

.rest-timer-display {
    text-align: center;
    font-size: 3.2em;
    font-weight: bold;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
    margin: 8px 0 16px;
}

.rest-timer.finished .rest-timer-display {
    color: var(--success);
    animation: timerFlash 0.6s ease-in-out 3;
}

@keyframes timerFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.rest-timer-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 14px;
}

.rest-preset-btn {
    background-color: var(--surface-2);
    color: var(--heading);
    border: 1px solid var(--border);
    padding: 10px 16px;
    font-size: 0.95em;
    border-radius: 6px;
    cursor: pointer;
    min-height: 44px;
    transition: background-color 0.2s, border-color 0.2s;
}

.rest-preset-btn:hover {
    background-color: var(--surface-3);
}

.rest-preset-btn.active {
    background-color: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.rest-timer-custom {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.rest-timer-custom label {
    color: var(--text-muted);
    font-size: 0.9em;
}

.rest-timer-custom input {
    width: 90px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

.rest-timer-custom input:focus {
    outline: none;
    border-color: var(--primary);
}

.rest-timer-controls {
    display: flex;
    gap: 10px;
}

.rest-timer-controls button {
    flex: 1;
    margin-top: 0;
}

.rest-timer-status {
    text-align: center;
    color: var(--success);
    font-weight: bold;
    margin-top: 12px;
    min-height: 1.2em;
}

/* ========================================
   Plan Tab — List, Templates, Editor
   ======================================== */
#plan-list {
    margin-top: 20px;
}

.plan-hint {
    color: var(--text-muted);
    font-size: 0.95em;
    margin-bottom: 15px;
}

/* Plan cards */
.plan-card {
    background-color: var(--surface);
    border-left: 5px solid var(--secondary);
    padding: 18px 20px;
    margin-bottom: 15px;
    border-radius: 6px;
    box-shadow: 0 2px 8px var(--shadow-soft);
}

.plan-card-active {
    border-left-color: var(--primary);
    background-color: var(--plan-active-bg);
}

.plan-card-archived {
    opacity: 0.75;
}

.plan-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plan-card-header h4 {
    color: var(--heading);
    font-size: 1.2em;
    margin: 0;
}

.plan-badge {
    display: inline-block;
    background-color: var(--primary);
    color: var(--on-primary);
    font-size: 0.65em;
    padding: 3px 9px;
    border-radius: 12px;
    vertical-align: middle;
    margin-left: 8px;
    letter-spacing: 0.5px;
}

.plan-card-meta {
    color: var(--text-muted);
    font-size: 0.9em;
    margin: 8px 0 14px 0;
}

.plan-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.plan-card-actions button {
    margin-top: 0;
    padding: 10px 14px;
    font-size: 0.9em;
    min-height: 44px;
}

#archived-plans-wrapper {
    margin-top: 35px;
}

#archived-plans-wrapper h3 {
    color: var(--text-muted);
    font-size: 1.1em;
    margin-bottom: 15px;
}

/* Template chooser */
.template-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.template-card {
    background-color: var(--surface-2);
    border: 2px solid var(--border-soft);
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.template-card:hover,
.template-card:focus-visible {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.15);
}

.template-card h4 {
    color: var(--heading);
    margin-bottom: 8px;
    font-size: 1.1em;
}

.template-card p {
    color: var(--text-muted);
    font-size: 0.9em;
    line-height: 1.5;
    margin: 0;
}

/* Plan editor — day blocks */
#plan-days-editor {
    margin-top: 10px;
}

.plan-day {
    background-color: var(--surface-2);
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid var(--primary);
    overflow: hidden;
}

.plan-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
}

.plan-day-name {
    font-weight: bold;
    color: var(--heading);
    font-size: 1.1em;
}

.rest-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.95em;
}

.rest-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.plan-day-body {
    padding: 0 18px 18px 18px;
}

.day-exercises {
    margin-bottom: 12px;
}

/* Exercise rows in editor */
.exercise-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--surface);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px var(--shadow-soft);
}

.exercise-name {
    flex: 1;
    min-width: 100px;
    font-weight: bold;
    color: var(--heading);
    font-size: 0.95em;
}

.exercise-fields {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ex-field {
    display: flex;
    flex-direction: column;
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    gap: 3px;
}

/* 16px verhindert Auto-Zoom beim Fokussieren auf iOS */
.ex-field input {
    width: 72px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

.ex-field input:focus {
    outline: none;
    border-color: var(--primary);
}

.remove-exercise {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.5em;
    line-height: 1;
    cursor: pointer;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.remove-exercise:hover {
    transform: scale(1.2);
}

.add-exercise-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.add-exercise-controls .exercise-picker {
    flex: 1;
}

.add-exercise-controls .btn-add-exercise {
    margin-top: 0;
    white-space: nowrap;
    padding: 10px 16px;
}

.day-notes-group {
    margin-bottom: 0;
}

.day-notes-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    background-color: var(--surface);
    color: var(--text);
}

.day-notes-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .exercise-row {
        flex-wrap: wrap;
    }

    .exercise-name {
        flex-basis: 100%;
    }

    .ex-field input {
        width: 64px;
    }

    .add-exercise-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .add-exercise-controls .btn-add-exercise {
        width: 100%;
    }

    .heute-list li {
        flex-direction: column;
        gap: 2px;
    }

    .he-detail {
        text-align: left;
    }
}

/* ========================================
   Form helpers (shared)
   ======================================== */
.field-hint {
    color: var(--text-muted);
    font-size: 0.82em;
    margin-top: 5px;
    line-height: 1.4;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ========================================
   Smart Reminders
   ======================================== */
#smart-reminders {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.smart-reminder {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
    background-color: var(--surface);
    border-left: 6px solid var(--primary);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-1);
    animation: slideDown 0.4s ease-out;
}

.smart-reminder-content {
    flex: 1;
    min-width: 220px;
}

.smart-reminder-content h3 {
    color: var(--heading);
    margin-bottom: 4px;
    font-size: 1.05em;
}

.smart-reminder-content p {
    color: var(--text-soft);
    font-size: 0.92em;
    margin: 0;
}

.smart-reminder-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.smart-reminder-actions button {
    margin-top: 0;
    padding: 10px 16px;
    font-size: 0.9em;
    min-height: 44px;
}

/* ========================================
   Ziele Tab — Goals
   ======================================== */
#goals-display {
    margin-top: 25px;
}

.goal-group {
    margin-bottom: 30px;
}

.goal-group h3 {
    color: var(--heading);
    font-size: 1.2em;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--divider);
    padding-bottom: 6px;
}

.goal-card {
    background-color: var(--surface);
    border-left: 5px solid var(--primary);
    padding: 16px 20px;
    margin-bottom: 14px;
    border-radius: 6px;
    box-shadow: 0 2px 8px var(--shadow-soft);
}

.goal-card.goal-done {
    border-left-color: var(--success);
    background-color: var(--success-bg);
}

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

.goal-card-head h4 {
    color: var(--heading);
    font-size: 1.1em;
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.goal-badge {
    display: inline-block;
    background-color: var(--surface-3);
    color: var(--text-muted);
    font-size: 0.62em;
    padding: 3px 8px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.goal-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Schmale Phones (320 px): Buttons in eigene Zeile unter den Titel */
@media (max-width: 360px) {
    .goal-card-head {
        flex-wrap: wrap;
    }

    .goal-card-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

.goal-mini {
    margin-top: 0 !important;
    padding: 9px 14px !important;
    font-size: 0.85em !important;
    min-height: 40px;
}

.goal-sub {
    color: var(--text-soft);
    font-size: 0.9em;
    margin: 8px 0 12px 0;
}

/* Progress bar */
.goal-progress {
    position: relative;
    background-color: var(--surface-3);
    border-radius: 10px;
    height: 22px;
    overflow: hidden;
}

.goal-progress-fill {
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
}

.goal-done .goal-progress-fill {
    background: linear-gradient(90deg, var(--success), var(--success-hover));
}

.goal-progress-label {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    line-height: 22px;
    font-size: 0.78em;
    font-weight: bold;
    color: var(--heading);
}

/* Manual progress entry */
.manual-progress {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.manual-progress-input {
    width: 110px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

.manual-progress-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Habit card */
/* Verlauf: letzte 14 Tage als Punkte */
.habit-history {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 6px 0 2px;
}

.habit-history-dots {
    display: flex;
    gap: 4px;
}

.habit-day {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--divider);
    border: 1px solid var(--border);
    box-sizing: border-box;
}

.habit-day.is-done {
    background: var(--success);
    border-color: var(--success);
}

.habit-day.is-today:not(.is-done) {
    background: transparent;
    border: 2px dashed var(--text-muted);
}

.habit-history-meta {
    color: var(--text-muted);
    font-size: 0.8em;
}

/* Gewohnheiten werden auf Heute abgehakt; hier nur Status + Verweis */
.goal-habit-status {
    color: var(--text-soft);
    font-size: 0.92em;
}

.goal-habit.goal-done .goal-habit-status {
    color: var(--success);
    font-weight: bold;
}

.goal-habit-status .link-btn {
    color: var(--primary);
    font-weight: normal;
    min-height: 44px;
}

/* Notes section (einklappbar am Ende von Fortschritt) */
.goal-notes-section {
    margin-top: 35px;
    padding-top: 15px;
    border-top: 1px solid var(--divider);
}

.goal-notes-section summary {
    color: var(--heading);
    font-weight: bold;
    font-size: 1.1em;
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.goal-notes-section summary::-webkit-details-marker {
    display: none;
}

.goal-notes-section summary::before {
    content: '▸';
    color: var(--primary);
    transition: transform 0.2s;
}

.goal-notes-section[open] summary::before {
    transform: rotate(90deg);
}

.goal-notes-section summary:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.goal-notes-section[open] summary {
    margin-bottom: 12px;
}

.goal-notes-section textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 10px;
    background-color: var(--surface);
    color: var(--text);
}

.goal-notes-section textarea:focus {
    outline: none;
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .smart-reminder {
        flex-direction: column;
        align-items: stretch;
    }

    .smart-reminder-actions {
        flex-direction: column;
    }

    .smart-reminder-actions button {
        width: 100%;
    }
}

/* Übungs-Progression (v1.5.0) */
.chart-box-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.chart-box-head h4 {
    margin-bottom: 0;
    text-align: left;
}

.progression-select {
    padding: 10px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--heading);
    max-width: 60%;
}

/* Sehr schmale Screens (≤ 340px): Stat-Karten einspaltig */
@media (max-width: 340px) {
    .stats-container {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Kleine Phones (≤ 400px)
   ======================================== */
@media (max-width: 400px) {
    .tab-content {
        padding: 12px;
    }

    /* Stat-Karten bleiben 2-spaltig, Werte etwas kleiner */
    .stat-card .stat-value {
        font-size: 1.1em;
        word-break: normal;
    }

    .chart-box-head {
        flex-direction: column;
        align-items: stretch;
    }

    .progression-select {
        max-width: 100%;
        width: 100%;
    }

    .exercise-fields {
        gap: 6px;
    }

    .ex-field input {
        width: 58px;
    }

    .manual-progress {
        flex-wrap: wrap;
    }

    .manual-progress-input {
        flex: 1;
        min-width: 0;
    }
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

.toast {
    background-color: var(--surface);
    color: var(--text);
    border-left: 5px solid var(--primary);
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-2);
    font-size: 0.98em;
    font-weight: bold;
    animation: toastIn 0.3s ease-out;
    pointer-events: auto;
    max-width: 100%;
}

.toast.toast-success {
    border-left-color: var(--success);
}

.toast.toast-error {
    border-left-color: var(--danger);
}

.toast.toast-hide {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

@media (max-width: 768px) {
    .toast-container {
        bottom: calc(80px + env(safe-area-inset-bottom));
        width: calc(100vw - 32px);
    }

    .toast {
        width: 100%;
        text-align: center;
    }
}

/* ========================================
   Tastatur-Fokus (Tabs, Karten, Pfeil-Buttons)
   ======================================== */
.tab-button:focus-visible,
.template-card:focus-visible,
.training-card-toggle:focus-visible,
.rest-timer-header:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.template-card:focus-visible {
    outline-offset: 0;
}

/* Nur für Screenreader sichtbar */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.field-error {
    color: var(--danger-dark);
    font-size: 0.88em;
    margin: 6px 0 0 0;
}

.btn-ghost.goal-mini.danger {
    color: var(--danger-dark);
}

.btn-ghost.goal-mini.danger:hover {
    background-color: var(--danger-bg);
}

/* ========================================
   Eigene Übungen: Inline-Formular + Verwaltung
   ======================================== */
.new-exercise-form {
    background-color: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 15px;
    margin: 0 0 12px 0;
}

.new-exercise-form h4 {
    color: var(--heading);
    margin: 0 0 10px 0;
}

.new-exercise-form .form-actions {
    margin-top: 10px;
}

.new-exercise-form .nex-type-hint {
    margin-top: 0;
}

.custom-exercises {
    margin-top: 35px;
}

#custom-exercise-add-btn {
    min-height: 44px;
}

#custom-exercise-list {
    margin: 12px 0;
}

.custom-exercise-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background-color: var(--surface);
    margin-bottom: 8px;
}

.custom-exercise-row.is-archived {
    opacity: 0.75;
}

.custom-exercise-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.custom-exercise-name {
    color: var(--heading);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.custom-exercise-meta {
    color: var(--text-muted);
    font-size: 0.85em;
}

.custom-exercise-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.custom-exercise-actions .goal-mini {
    min-height: 44px;
}

.custom-exercise-rename {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cex-rename-input {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    border: 1px solid var(--border-input);
    border-radius: 4px;
    background-color: var(--surface);
    color: var(--text);
}

.custom-exercise-archived-title {
    color: var(--text-muted);
    font-size: 0.95em;
    margin: 16px 0 8px 0;
}

/* Konsistenz-Ziel noch nicht gestartet */
.goal-card.goal-state-pending {
    opacity: 0.8;
}

@media (max-width: 480px) {
    .custom-exercise-row {
        flex-direction: column;
        align-items: stretch;
    }

    .custom-exercise-actions {
        justify-content: flex-end;
    }
}

/* ========================================
   Layout v1.9.0: Heute · Training · Plan · Fortschritt · Profil
   ======================================== */

/* Heute: Hinweise oben, darunter Karten (Desktop: Raster) */
.hinweise > .reminder-banner:last-of-type {
    margin-bottom: 20px;
}

/* Leere Hinweis-Liste soll keinen Abstand über der Heute-Karte erzeugen */
#smart-reminders:empty {
    display: none;
}

.heute-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    min-width: 0;
}

.heute-cards > * {
    min-width: 0;
}

.heute-card .heute-free-btn {
    margin-top: 12px;
    min-height: 44px;
}

/* Fortschritt: Ziele oben, Auswertung mit Unteransichten darunter */
.fortschritt-goals > h3,
.fortschritt-analysis > h3,
.profil-block > h3,
.profil-section-title {
    color: var(--heading);
    font-size: 1.3em;
    margin-bottom: 15px;
}

.fortschritt-analysis {
    margin-top: 40px;
}

.fortschritt-analysis .filter-section {
    margin-bottom: 15px;
}

.subview-nav {
    display: flex;
    width: 100%;
    margin-bottom: 20px;
}

/* Breite nach Inhalt, damit kurze Labels längeren Platz abgeben (z.B. "Übersicht" bei 360 px) */
.subview-nav .subview-button {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 8px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subview-button:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.subview-panel {
    display: none;
}

.subview-panel.active {
    display: block;
    animation: fadeIn 0.3s;
}

.subview-panel > .charts-container {
    margin-top: 0;
}

#fortschritt-uebersicht .charts-container {
    margin-top: 20px;
}

/* Muster: Abschnitt direkt unter der Unteransichts-Leiste */
#fortschritt-muster .correlations-section {
    margin-top: 0;
}

#fortschritt-muster .correlations-section h3 {
    font-size: 1.2em;
}

/* Profil */
.profil-block {
    margin-bottom: 30px;
}

.profil-section-title {
    margin-top: 35px;
    padding-top: 20px;
    border-top: 1px solid var(--divider);
}

#tab-profil .app-footer {
    margin-top: 30px;
    padding-bottom: 0;
}

@media (max-width: 380px) {
    .subview-nav .subview-button {
        padding: 8px 3px;
    }
}

/* Desktop / Tablet: Heute und Fortschritt zweispaltig */
@media (min-width: 769px) {
    .heute-cards {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }

    /* Sichtbare Hinweise: links die Hinweise, rechts die Heute-Karten.
       Banner werden per style.display = 'flex' eingeblendet; ohne :has()-Support
       bleibt es beim einspaltigen Layout. */
    #tab-heute.active:has(#hinweise > .reminder-banner[style*="flex"], #smart-reminders:not(:empty)) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 20px;
        align-items: start;
    }

    #tab-heute.active:has(#hinweise > .reminder-banner[style*="flex"], #smart-reminders:not(:empty)) > h2 {
        grid-column: 1 / -1;
    }

    #tab-heute.active:has(#hinweise > .reminder-banner[style*="flex"], #smart-reminders:not(:empty)) .heute-cards {
        grid-template-columns: minmax(0, 1fr);
    }

    #tab-heute.active:has(#hinweise > .reminder-banner[style*="flex"], #smart-reminders:not(:empty)) .hinweise > .reminder-banner:last-of-type,
    #tab-heute.active:has(#hinweise > .reminder-banner[style*="flex"], #smart-reminders:not(:empty)) #smart-reminders {
        margin-bottom: 0;
    }

    /* Ziel-Karten je Gruppe im 2-spaltigen Raster */
    .goal-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 14px;
        align-items: start;
    }

    .goal-group > h3 {
        grid-column: 1 / -1;
    }
}

/* ========================================
   Interaktionsmuster v1.9.0: Sheets, FAB, Timer-Leiste, Rückgängig-Toasts
   ======================================== */

/* ---- Sheets (<dialog>) ---- */
/* Desktop: zentriertes Modal; Handy: Bottom-Sheet bzw. Vollbild (.sheet-full) */
.sheet {
    border: none;
    padding: 0;
    margin: auto;
    width: min(640px, calc(100vw - 48px));
    max-width: none;
    max-height: calc(100vh - 48px); /* Fallback ohne dvh-Unterstützung */
    max-height: calc(100dvh - 48px);
    background-color: var(--surface);
    color: var(--text);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-2);
    overflow: hidden;
}

.sheet[open] {
    display: flex;
    flex-direction: column;
    animation: sheetFadeIn 0.2s ease-out;
}

.sheet-wide {
    width: min(880px, calc(100vw - 48px));
}

.sheet-confirm {
    width: min(480px, calc(100vw - 48px));
}

/* ::backdrop erbt in älteren Browsern keine CSS-Variablen – fester Wert */
.sheet::backdrop {
    background-color: rgba(0, 0, 0, 0.55);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 10px 10px 20px;
    border-bottom: 1px solid var(--divider);
    flex: 0 0 auto;
}

.sheet-header h3 {
    color: var(--heading);
    font-size: 1.2em;
    margin: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.sheet-header h3:focus {
    outline: none;
}

.sheet-header h3:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.sheet-close {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.8em;
    line-height: 1;
    cursor: pointer;
}

.sheet-close:hover {
    background-color: var(--surface-3);
    color: var(--heading);
}

.sheet-close:focus-visible,
.fab:focus-visible,
.toast-action:focus-visible,
.rest-timer-bar button:focus-visible,
.habit-check:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.sheet-body {
    padding: 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
}

/* Abbrechen-Button der Vorlagen-Auswahl über die volle Breite */
#plan-template-view #template-cancel-btn {
    width: 100%;
}

/* Inline-Formular „Neue Übung“ steht im Sheet ohne eigenen Kasten */
#custom-exercise-sheet .new-exercise-form {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

#custom-exercise-sheet .new-exercise-form > h4 {
    display: none;
}

.confirm-dialog-message {
    white-space: pre-line;
    line-height: 1.5;
}

.btn-primary.btn-danger {
    background-color: var(--danger);
}

.btn-primary.btn-danger:hover {
    background-color: var(--danger-dark);
}

body.sheet-open {
    overflow: hidden;
}

@keyframes sheetFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

/* Nur ein kurzes Stück hochschieben: Inhalt ist sofort im sichtbaren Bereich */
@keyframes sheetSlideUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .sheet,
    .sheet-wide,
    .sheet-confirm {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        margin: auto 0 0 0;
        border-radius: 16px 16px 0 0;
    }

    .sheet[open] {
        animation: sheetSlideUp 0.25s ease-out;
    }

    .sheet-full {
        height: 100vh;
        max-height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }

    .sheet-header {
        padding: calc(6px + env(safe-area-inset-top)) 6px 6px 16px;
    }

    .sheet:not(.sheet-full) .sheet-header {
        padding-top: 6px;
    }

    .sheet-body {
        padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .sheet[open] {
        animation: none;
    }
}

/* ---- „+“-Button (FAB) auf Heute und Training ---- */
.fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 900;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 4px 14px var(--shadow-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, bottom 0.2s;
}

.fab[hidden] {
    display: none;
}

.fab:hover {
    background-color: var(--primary-hover);
}

.fab svg {
    width: 28px;
    height: 28px;
}

/* Platz unter dem letzten Inhalt, damit der FAB nichts verdeckt */
body.has-fab main {
    padding-bottom: 70px;
}

/* ---- Schwebende Timer-Leiste ---- */
.rest-timer-bar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 950;
    width: min(480px, calc(100vw - 32px));
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background-color: var(--header-bg);
    color: var(--on-accent);
    border-radius: 12px;
    box-shadow: 0 4px 14px var(--shadow-2);
}

.rest-timer-bar[hidden] {
    display: none;
}

.rest-timer-bar button {
    min-height: 44px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
}

.rest-timer-bar-time {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    background: transparent;
    color: var(--on-accent);
    font-size: 1.2em !important;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.rest-timer-bar-status {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.85em;
    color: var(--tab-inactive);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rest-timer-bar-btn {
    flex: 0 0 auto;
    padding: 0 14px;
    background-color: var(--tab-bg);
    color: var(--on-accent);
    /* „Neu starten“ nie auf zwei Zeilen umbrechen */
    white-space: nowrap;
}

.rest-timer-bar-btn:hover {
    background-color: var(--tab-hover);
}

.rest-timer-bar.finished .rest-timer-bar-status {
    color: var(--success);
    font-weight: bold;
}

.rest-timer-bar.finished .rest-timer-bar-time {
    color: var(--success);
    animation: timerFlash 0.6s ease-in-out 3;
}

/* Abgelaufen: „00:00“ sagt nichts mehr – der Platz gehört dem Status
   „Pause vorbei!“ (das Hauptsignal, wenn Ton und Vibration aus sind) */
.rest-timer-bar.finished #rest-timer-bar-display {
    display: none;
}

.rest-timer-bar.finished .rest-timer-bar-time {
    padding: 0 8px;
}

/* Desktop: FAB rückt über die Timer-Leiste */
body.has-timer-bar .fab {
    bottom: 88px;
}

body.has-timer-bar main {
    padding-bottom: 70px;
}

body.has-timer-bar.has-fab main {
    padding-bottom: 130px;
}

body.has-timer-bar .toast-container {
    bottom: 88px;
}

/* Toasts dürfen den FAB nicht verdecken (sonst fängt der Toast den Tipp ab) */
body.has-fab .toast-container {
    max-width: calc(100vw - 200px);
}

@media (max-width: 768px) {
    /* Über der Bottom-Bar (72 px + iPhone Home-Indikator) */
    .fab {
        right: 16px;
        bottom: calc(84px + env(safe-area-inset-bottom));
    }

    .rest-timer-bar {
        bottom: calc(78px + env(safe-area-inset-bottom));
        width: calc(100vw - 20px);
    }

    body.has-timer-bar .fab {
        bottom: calc(140px + env(safe-area-inset-bottom));
    }

    body.has-timer-bar .toast-container {
        bottom: calc(136px + env(safe-area-inset-bottom));
    }

    /* Toasts über dem FAB statt darüber gelegt */
    body.has-fab .toast-container {
        max-width: calc(100vw - 32px);
        bottom: calc(152px + env(safe-area-inset-bottom));
    }

    body.has-fab.has-timer-bar .toast-container {
        bottom: calc(208px + env(safe-area-inset-bottom));
    }
}

/* Im offenen Sheet liegen Timer-Leiste und Toasts im <dialog> (Top-Layer,
   siehe js/core/sheets.js). Die Leiste sitzt unten (Platz dafür ist im
   Sheet reserviert), Toasts oben unter dem Sheet-Kopf – so verdeckt keins
   von beiden die Speichern-/Abbrechen-Buttons.
   Die Leiste hängt am unteren Rand des Sheets selbst (das modale <dialog> ist
   position: fixed und damit Bezugsrahmen), nicht am Fenster: Auf dem Desktop
   endet das zentrierte Sheet über dem Fensterrand, die Leiste ragte sonst
   darüber hinaus. */
.sheet .rest-timer-bar {
    position: absolute;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: min(480px, calc(100% - 24px));
}

.rest-timer-bar-time:disabled {
    cursor: default;
}

body.has-timer-bar .sheet .sheet-body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

body.sheet-open .sheet .toast-container {
    top: calc(72px + env(safe-area-inset-top));
    bottom: auto;
    max-width: calc(100vw - 32px);
}

@media (max-width: 400px) {
    .rest-timer-bar-btn {
        padding: 0 10px;
    }
}

@media (max-width: 360px) {
    .rest-timer-bar-btn {
        padding: 0 8px;
    }

    .rest-timer-bar.finished .rest-timer-bar-time {
        padding: 0 4px;
    }
}

/* ---- Rückgängig-Toast ---- */
.toast.toast-has-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.toast-text {
    flex: 1 1 auto;
    min-width: 0;
}

.toast-action {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 14px;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: var(--primary);
    font-size: 1em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.toast-action:hover {
    background-color: var(--surface-3);
}

@media (max-width: 768px) {
    .toast.toast-has-action {
        text-align: left;
    }
}

/* ---- Heute: Gewohnheiten und Körpergewicht ---- */
.heute-mini-card {
    background-color: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 16px 18px;
}

.heute-mini-card[hidden] {
    display: none;
}

.heute-mini-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.heute-mini-head h3 {
    color: var(--heading);
    font-size: 1.1em;
    margin: 0;
}

.heute-mini-meta {
    color: var(--text-muted);
    font-size: 0.85em;
    white-space: nowrap;
}

.heute-bodyweight-value {
    color: var(--heading);
    font-size: 1.6em;
    font-weight: bold;
    margin-bottom: 12px;
}

.heute-mini-card .btn-secondary {
    margin-top: 0;
    width: 100%;
    min-height: 44px;
}

.habit-checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.habit-check {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.habit-check:hover {
    border-color: var(--primary);
}

.habit-check-box {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border: 2px solid var(--border-input);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--on-accent);
}

.habit-check-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.habit-check-streak {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.85em;
}

.habit-check.is-done {
    background-color: var(--success-bg);
    border-color: var(--success);
}

.habit-check.is-done .habit-check-box {
    background-color: var(--success);
    border-color: var(--success);
}

.habit-check.is-done .habit-check-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ---- Fortschritt → Körper: Gewichtseinträge ---- */
.bodyweight-entries {
    margin-top: 25px;
}

.bodyweight-entries-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.bodyweight-entries-head h4 {
    color: var(--heading);
    font-size: 1.1em;
}

.bodyweight-entries-head .btn-secondary {
    margin-top: 0;
    min-height: 44px;
}

.bodyweight-rows {
    list-style: none;
}

.bodyweight-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--divider);
}

.bodyweight-row-date {
    color: var(--text);
}

.bodyweight-row-value {
    color: var(--heading);
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.bodyweight-row-bmi {
    color: var(--text-muted);
    font-size: 0.85em;
    min-width: 5.5em;
}

.bodyweight-row .goal-mini {
    min-height: 44px;
}

@media (max-width: 400px) {
    .bodyweight-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
    }

    .bodyweight-row-bmi {
        display: none;
    }
}

/* ========================================
   Layout v1.9.1: Heute-Schnellerfassung, Mini-Übersicht, Plan-Kennzahlen,
   Stat-Details per Tipp, Körper-Kennzahlen, Wischgeste, Verwerfen-Rückfrage
   ======================================== */

/* ---- Heute: Körpergewicht direkt eintragen ---- */
.heute-bodyweight-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: var(--heading);
    font-size: 0.95em;
}

.heute-bodyweight-row {
    display: flex;
    gap: 10px;
}

.heute-bodyweight-row input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 10px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

.heute-bodyweight-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.heute-bodyweight-row .btn-primary {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 18px;
}

.heute-bodyweight-error {
    color: var(--danger);
    margin: 6px 0 0;
}

.heute-bodyweight-error[hidden] {
    display: none;
}

/* ---- Heute: Mini-Übersicht ---- */
.heute-mini-head .link-btn {
    color: var(--primary);
    font-weight: normal;
    min-height: 44px;
    white-space: nowrap;
}

.heute-overview-stats,
.week-review-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.heute-overview-stat,
.week-review-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    min-width: 0;
}

.heute-overview-label,
.week-review-label {
    color: var(--text-muted);
    font-size: 0.8em;
}

.heute-overview-value,
.week-review-value {
    color: var(--heading);
    font-size: 1.4em;
    font-weight: bold;
}

.heute-overview-detail,
.week-review-detail {
    color: var(--text-muted);
    font-size: 0.8em;
    min-height: 1.2em;
}

.heute-overview-subhead,
.week-review-subhead {
    color: var(--heading);
    font-size: 0.95em;
    margin-bottom: 8px;
}

.heute-deadlines {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.heute-deadline {
    width: 100%;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 12px;
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    text-align: left;
    cursor: pointer;
}

.heute-deadline:hover {
    border-color: var(--primary);
}

.heute-deadline:focus-visible,
.stat-more-btn:focus-visible,
.heute-mini-head .link-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.heute-deadline-title {
    font-weight: bold;
    color: var(--heading);
    overflow-wrap: anywhere;
}

.heute-deadline-meta {
    color: var(--text-muted);
    font-size: 0.85em;
}

.heute-overview-empty,
.week-review-empty {
    color: var(--text-muted);
    font-size: 0.9em;
}

/* Fokus-Ziel beim Sprung aus der Mini-Übersicht */
.goal-card:focus {
    outline: none;
}

.goal-card:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ---- Plan: Kennzahlen auf der aktiven Plankarte ---- */
.plan-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 12px;
}

.plan-card-stat {
    flex: 1 1 140px;
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.plan-card-stat-value {
    color: var(--heading);
    font-size: 1.25em;
    font-weight: bold;
}

.plan-card-stat-label {
    color: var(--text-muted);
    font-size: 0.82em;
}

/* ---- Stat-Karten: Details per Tipp ---- */
.stat-card {
    position: relative;
}

/* Unsichtbarer Button über der ganzen Karte (Tippfläche), Hinweis-Pfeil oben rechts */
.stat-more-btn {
    position: absolute;
    inset: 0;
    width: 100%;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.stat-more-btn::after {
    content: '';
    position: absolute;
    top: 9px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform 0.2s;
}

.stat-more-btn[aria-expanded="true"]::after {
    transform: rotate(-135deg);
    top: 12px;
}

.stat-card.is-open {
    grid-column: 1 / -1;
}

.stat-more {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--divider);
    color: var(--text-soft);
    font-size: 0.85em;
    line-height: 1.45;
    text-align: left;
}

.stat-more[hidden] {
    display: none;
}

.stat-tap-hint {
    display: none;
    margin-top: 8px;
}

/* Körper-Kennzahlen: keine Tippfläche, kein Anheben */
.koerper-summary {
    margin-top: 0;
    margin-bottom: 20px;
}

.koerper-summary .stat-card:hover {
    transform: none;
    box-shadow: 0 2px 10px var(--shadow-1);
}

#bodyweight-metric button,
#progression-metric button {
    min-height: 44px;
    flex: 1 1 0;
}

/* Kennzahl der Übungs-Progression: eigene Zeile unter Überschrift + Auswahl */
.progression-metric {
    display: flex;
    margin-bottom: 15px;
}

#progression-metric button {
    padding: 8px 6px;
    min-width: 0;
}

/* Platz für den Hinweis-Pfeil neben der Überschrift */
.stat-card[data-stat] h3 {
    padding: 0 18px;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.bmi-ranges {
    margin-top: 10px;
}

.bmi-ranges[hidden] {
    display: none;
}

@media (max-width: 768px) {
    .stat-tap-hint {
        display: block;
    }

    /* Drei Kennzahlen im 2er-Raster: die letzte über die volle Breite */
    .koerper-summary .stat-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 380px) {
    .heute-overview-stats,
    .week-review-stats {
        grid-template-columns: 1fr;
    }
}

/* ---- Sheets: Wischgeste am Kopf ---- */
.sheet-header {
    position: relative;
    touch-action: none;
}

.sheet[open] {
    transition: transform 0.2s ease-out;
}

.sheet.sheet-dragging {
    transition: none;
}

@media (max-width: 768px) {
    /* Griff als Hinweis auf die Wischgeste (Bottom-Sheets) */
    .sheet:not(.sheet-full):not(.sheet-confirm) .sheet-header::before {
        content: '';
        position: absolute;
        top: 5px;
        left: 50%;
        width: 36px;
        height: 4px;
        margin-left: -18px;
        border-radius: 2px;
        background-color: var(--border);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sheet[open] {
        transition: none;
    }
}

/* ---- Rückfrage „Änderungen verwerfen?“ (über einem offenen Sheet) ---- */
.discard-dialog > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}

/* ========================================
   Mehrere Übungen pro Training (v2.0.0)
   ======================================== */

/* Trainingskarte: Übungsliste über die volle Breite */
.training-card-exercises {
    grid-column: 1 / -1;
    font-size: 0.95em;
}

.training-card-exercises ul {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
}

.training-card-exercises li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border-bottom: 1px solid var(--divider);
}

.training-card-exercises li:last-child {
    border-bottom: none;
}

.tce-name {
    font-weight: 600;
    color: var(--heading);
}

.tce-detail {
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
}

/* Formular: Abschnitt „Übungen“ */
.log-ex-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 10px;
}

.log-ex-section .log-ex-section-head h4 {
    margin-bottom: 0;
}

.btn-ghost.log-ex-plan-btn {
    padding: 8px 12px;
    min-height: 44px;
    font-size: 0.95em;
    color: var(--primary-hover);
    font-weight: 600;
}

#training-exercises-empty {
    margin-bottom: 12px;
}

.log-ex {
    background-color: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 10px 12px 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px var(--shadow-soft);
}

.log-ex-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.log-ex-title {
    font-weight: bold;
    color: var(--heading);
}

.log-ex-tools {
    display: flex;
    gap: 2px;
}

.log-icon-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-soft);
    font-size: 1.25em;
    line-height: 1;
    cursor: pointer;
}

.log-icon-btn:hover:not(:disabled) {
    background-color: var(--surface-3);
    color: var(--heading);
}

.log-icon-btn.danger {
    color: var(--danger-dark);
}

.log-icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.log-icon-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 1px;
}

.log-ex-select {
    min-height: 44px;
    margin-bottom: 8px;
}

/* Sätze: Nr. | Wdh. | × | kg | entfernen */
.log-set-head,
.log-set {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 14px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 6px;
}

.log-set-head {
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.log-set {
    margin-bottom: 6px;
}

.log-set-head span:first-child,
.log-set-num,
.log-set-x {
    text-align: center;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* 16px verhindert Auto-Zoom beim Fokussieren auf iOS */
.log-set input,
.log-ex-field input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--border-input);
    border-radius: 4px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
}

.log-set input:focus,
.log-ex-field input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-ghost.log-set-add {
    padding: 8px 12px;
    min-height: 44px;
    font-size: 0.95em;
    color: var(--primary-hover);
}

.btn-ghost.log-set-add:disabled {
    opacity: 0.5;
    cursor: default;
}

.log-ex-cardio {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.log-ex-sets + .log-ex-cardio:not([hidden]) {
    margin-top: 8px;
}

.log-ex-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85em;
    font-weight: bold;
    color: var(--heading);
}

.log-ex-sets[hidden],
.log-ex-cardio[hidden] {
    display: none;
}

.btn-secondary.log-ex-add-btn {
    width: 100%;
    margin-top: 0;
    min-height: 44px;
}

@media (max-width: 768px) {
    .form-section.log-ex-section {
        padding: 16px 12px;
    }

    .log-ex {
        padding: 8px 10px 10px;
    }
}


/* ========================================
   Bestwerte, „Letztes Mal“, Progressions-Vorschläge (v2.0.0)
   ======================================== */

/* Trainingsformular: Vorbereitung/Nachfolgen als einklappbare Abschnitte */
.form-collapse {
    padding: 0;
}

.form-collapse > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 10px 20px;
    cursor: pointer;
    list-style: none;
    color: var(--heading);
}

.form-collapse > summary::-webkit-details-marker {
    display: none;
}

.form-collapse > summary::before {
    content: '\25B8';
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.form-collapse[open] > summary::before {
    transform: rotate(90deg);
}

.form-collapse > summary:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
    border-radius: 8px;
}

.form-collapse-title {
    font-weight: bold;
    font-size: 1.2em;
}

.form-collapse-meta {
    margin-left: auto;
    font-size: 0.85em;
    color: var(--text-muted);
}

.form-collapse[open] > summary {
    padding-bottom: 6px;
}

.form-collapse > .form-group {
    padding: 0 20px;
}

.form-collapse[open] {
    padding-bottom: 20px;
}

/* Übungszeile: „Letztes Mal“ und Vorschlag */
.log-ex-last {
    margin: -2px 0 8px;
    font-size: 0.85em;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
}

.log-ex-suggest {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin: 0 0 8px;
    padding: 6px 6px 6px 10px;
    border-radius: 6px;
    background-color: var(--success-bg);
    border: 1px solid var(--success-hover);
    font-size: 0.88em;
    color: var(--text);
}

.log-ex-suggest[hidden],
.log-ex-last[hidden] {
    display: none;
}

.log-ex-suggest-text {
    flex: 1 1 180px;
}

.btn-ghost.log-ex-suggest-apply {
    min-height: 44px;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--success-hover);
}

/* Bestwert-Abzeichen auf Trainingskarten */
.pr-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background-color: var(--record-bg);
    color: var(--record-text);
    font-size: 0.7em;
    font-weight: 700;
    vertical-align: middle;
    white-space: nowrap;
}

.pr-badge.pr-badge-mini {
    font-size: 0.75em;
    padding: 1px 6px;
}

/* Heute: Vorschlag unter der Übung (weiße Schrift auf Verlauf) */
.heute-list li {
    flex-wrap: wrap;
}

.he-suggest {
    flex-basis: 100%;
    font-size: 0.85em;
    opacity: 0.95;
}

.heute-card .heute-suggest-btn {
    margin-top: 12px;
    min-height: 44px;
    width: 100%;
}

/* Fortschritt → Übungen: Bestwerte-Tabelle */
.records-hint {
    margin-bottom: 10px;
}

#records-table-wrap {
    overflow-x: auto;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    font-variant-numeric: tabular-nums;
}

.records-table th,
.records-table td {
    padding: 8px 6px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--divider);
}

.records-table thead th {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.records-table tbody tr:last-child th,
.records-table tbody tr:last-child td {
    border-bottom: none;
}

.records-table tbody th {
    font-weight: 600;
    color: var(--heading);
    overflow-wrap: anywhere;
}

.records-value {
    display: block;
    font-weight: 600;
    color: var(--text);
}

.records-sub {
    display: block;
    font-size: 0.8em;
    color: var(--text-muted);
}

.records-ex-btn {
    background: none;
    border: none;
    padding: 0;
    min-height: 44px;
    margin: -12px 0;
    font: inherit;
    font-weight: 600;
    color: var(--primary-hover);
    text-align: left;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 768px) {
    .form-collapse > summary {
        padding: 10px 12px;
    }

    .form-collapse > .form-group {
        padding: 0 12px;
    }

    .form-collapse[open] {
        padding-bottom: 16px;
    }

    .records-table {
        font-size: 0.9em;
    }
}

/* ========================================
   Wochenrückblick (Heute)
   ======================================== */
.week-review[hidden] {
    display: none;
}

.week-review.is-collapsed {
    grid-column: 1 / -1;
}

.week-review h3:focus {
    outline: none;
}

/* Kopf darf umbrechen: „KW 42 · 12.10.–18.10.2026“ ist auf 360 px zu lang */
.week-review .heute-mini-head {
    flex-wrap: wrap;
}

.week-review .heute-mini-meta {
    white-space: normal;
}

.week-review-msg {
    color: var(--text-soft);
    margin-bottom: 12px;
}

.week-review-records {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.week-review-records li {
    background-color: var(--record-bg);
    color: var(--record-text);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.9em;
    overflow-wrap: anywhere;
}

.week-review-goals {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.week-review-goal {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.week-review-goal-title {
    font-weight: bold;
    color: var(--heading);
    overflow-wrap: anywhere;
}

.week-review-goal-meta {
    color: var(--text-muted);
    font-size: 0.85em;
}

.week-review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.week-review-actions button,
.heute-mini-card .week-review-actions .btn-secondary {
    width: auto;
    min-height: 44px;
    flex: 1 1 140px;
}

.week-review-reopen {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    background-color: var(--surface-2);
    color: var(--primary);
    border: 1px dashed var(--border);
    border-radius: 10px;
    font-size: 0.95em;
    text-align: left;
    cursor: pointer;
}

.week-review-reopen:hover {
    border-color: var(--primary);
}

.week-review-reopen:focus-visible,
.week-review-actions button:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ========================================
   Kalender-Heatmap (Fortschritt → Übersicht)
   ======================================== */
.heatmap-box {
    margin-bottom: 20px;
}

.heatmap-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.heatmap-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.heatmap-nav-btn {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--surface);
    color: var(--heading);
    font-size: 1.4em;
    line-height: 1;
    cursor: pointer;
}

.heatmap-nav-btn:hover:not(:disabled) {
    border-color: var(--primary);
}

.heatmap-nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.heatmap-period {
    min-width: 8.5em;
    text-align: center;
    font-weight: bold;
    color: var(--heading);
}

.heatmap-summary {
    margin-bottom: 10px;
}

/* Die Jahresansicht ist breiter als ein Handy – nur der Kasten scrollt, nie die Seite */
.heatmap-scroll {
    position: relative;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 6px;
}

.hm-year {
    --hm-cell: 13px;
    --hm-gap: 3px;
    display: inline-flex;
    gap: var(--hm-gap);
}

.hm-week,
.hm-weekdays {
    display: grid;
    grid-template-rows: 16px repeat(7, var(--hm-cell));
    gap: var(--hm-gap);
}

/* Wochentage bleiben beim seitlichen Scrollen stehen */
.hm-weekdays {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: var(--surface);
}

.hm-weekdays span {
    color: var(--text-muted);
    font-size: 10px;
    line-height: var(--hm-cell);
    padding-right: 4px;
}

.hm-month-label {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 16px;
    white-space: nowrap;
    width: var(--hm-cell);
    overflow: visible;
}

.hm-cell {
    display: block;
    width: var(--hm-cell);
    height: var(--hm-cell);
    padding: 0;
    border: none;
    border-radius: 3px;
    background-color: var(--heat-0);
}

button.hm-cell,
button.hm-mcell {
    cursor: pointer;
}

.hm-cell.is-outside,
.hm-mcell.is-outside {
    visibility: hidden;
}

.hm-cell.is-future,
.hm-mcell.is-future {
    opacity: 0.35;
}

/* Stufenfarben mit höherer Spezifität als die Grundregeln von .hm-cell und
   .hm-mcell, damit sie unabhängig von der Reihenfolge im Stylesheet greifen */
.hm-cell.hm-l0, .hm-mcell.hm-l0, .hm-swatch.hm-l0 { background-color: var(--heat-0); }
.hm-cell.hm-l1, .hm-mcell.hm-l1, .hm-swatch.hm-l1 { background-color: var(--heat-1); }
.hm-cell.hm-l2, .hm-mcell.hm-l2, .hm-swatch.hm-l2 { background-color: var(--heat-2); }
.hm-cell.hm-l3, .hm-mcell.hm-l3, .hm-swatch.hm-l3 { background-color: var(--heat-3); }
.hm-cell.hm-l4, .hm-mcell.hm-l4, .hm-swatch.hm-l4 { background-color: var(--heat-4); }

.hm-cell.is-today {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.hm-cell.is-selected {
    outline: 2px solid var(--heading);
    outline-offset: 1px;
}

.hm-cell:focus-visible,
.hm-mcell:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 1px;
}

/* Monatsansicht: Kalender mit großen Feldern */
.hm-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    max-width: 480px;
    margin: 0 auto;
}

.hm-mhead {
    color: var(--text-muted);
    font-size: 0.8em;
    text-align: center;
    padding-bottom: 2px;
}

.hm-mcell {
    position: relative;
    min-height: 44px;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 8px;
    background-color: var(--heat-0);
    color: var(--text);
    font-size: 0.95em;
}

.hm-mcell.hm-l2 {
    color: var(--heat-fg-2);
}

.hm-mcell.hm-l3,
.hm-mcell.hm-l4 {
    color: var(--heat-fg-strong);
}

.hm-mcell.is-today {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.hm-mcell.is-selected {
    outline: 3px solid var(--heading);
    outline-offset: 1px;
}

.hm-mday {
    font-weight: bold;
}

.hm-mcount {
    font-size: 0.7em;
}

.heatmap-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 14px;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.8em;
}

.hm-legend-scale {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.hm-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.heatmap-day {
    margin-top: 14px;
    padding: 14px 16px;
    background-color: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}

.heatmap-day[hidden] {
    display: none;
}

.heatmap-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.heatmap-day-head h5 {
    color: var(--heading);
    font-size: 1em;
    margin: 0;
}

.heatmap-day-close {
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5em;
    cursor: pointer;
    border-radius: 8px;
}

.heatmap-day-close:hover {
    background-color: var(--surface-3);
    color: var(--heading);
}

.heatmap-day-list {
    list-style: none;
}

.heatmap-day-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--divider);
}

.heatmap-day-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.heatmap-day-tag {
    font-weight: bold;
    color: var(--heading);
    overflow-wrap: anywhere;
}

.heatmap-day-meta,
.heatmap-day-exercises {
    color: var(--text-muted);
    font-size: 0.85em;
    overflow-wrap: anywhere;
}

.heatmap-day-empty {
    color: var(--text-muted);
    margin-bottom: 4px;
}

.heatmap-day-add {
    margin-top: 10px;
    width: 100%;
    min-height: 44px;
}

/* Ab Desktop-Breite passt das ganze Jahr (bis 54 Wochenspalten plus
   Wochentagsspalte) in den Kasten: Feldgröße folgt der Kastenbreite */
@media (min-width: 769px) {
    @supports (width: 1cqi) {
        .heatmap-scroll {
            container-type: inline-size;
        }

        .hm-year {
            --hm-gap: 2px;
            --hm-cell: clamp(8px, calc((100cqi - 20px - 54 * var(--hm-gap)) / 54), 13px);
        }
    }
}

@media (max-width: 400px) {
    .heatmap-toolbar {
        justify-content: center;
    }

    .heatmap-period {
        min-width: 7em;
    }
}

/* ========================================
   Einrichtung beim ersten Start (Onboarding, v2.0.0)
   ======================================== */
#onboarding-sheet .sheet-body {
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.onboarding-dots {
    display: flex;
    gap: 8px;
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    counter-reset: onboarding-dot;
}

.onboarding-dots li {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 8px;
    border-top: 4px solid var(--border-soft);
    color: var(--text-muted);
    font-size: 0.85em;
    counter-increment: onboarding-dot;
}

.onboarding-dots li::before {
    content: counter(onboarding-dot) ".";
}

.onboarding-dots li.done {
    border-top-color: var(--success);
}

.onboarding-dots li.current {
    border-top-color: var(--primary);
    color: var(--heading);
    font-weight: 600;
}

.onboarding-step h4 {
    color: var(--heading);
    font-size: 1.1em;
    margin: 0 0 8px;
}

.onboarding-step h4:focus {
    outline: none;
}

.onboarding-step h4:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.onboarding-options {
    border: none;
    margin: 0 0 12px;
    padding: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#onboarding-plan-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.onboarding-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 44px;
    padding: 12px 14px;
    background-color: var(--surface-2);
    border: 2px solid var(--border-soft);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.onboarding-option:hover,
.onboarding-option:has(input:checked) {
    border-color: var(--primary);
}

.onboarding-option:has(input:focus-visible) {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.onboarding-option input[type="radio"] {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    accent-color: var(--primary);
}

.onboarding-option-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.onboarding-option-text strong {
    color: var(--heading);
}

.onboarding-option-text small {
    color: var(--text-muted);
    font-size: 0.88em;
    line-height: 1.4;
}

.onboarding-goal-fields {
    margin: -2px 0 4px;
    padding: 0 4px 0 46px;
}

.onboarding-error {
    color: var(--danger-dark);
    font-size: 0.9em;
    margin: 0 0 10px;
}

.onboarding-restore {
    margin-top: 24px;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background-color: var(--surface-2);
}

.onboarding-restore p {
    margin: 0 0 10px;
    line-height: 1.5;
}

/* Touch-Ziele im Sheet mindestens 44px hoch (Formularstil der App ist 40/42px) */
#onboarding-sheet input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
#onboarding-sheet select,
#onboarding-sheet .sheet-body button {
    min-height: 44px;
}

.onboarding-step[hidden],
.onboarding-goal-fields[hidden],
.onboarding-error[hidden] {
    display: none;
}

@media (max-width: 480px) {
    .onboarding-goal-fields {
        padding-left: 4px;
    }
}

/* „+ Satz“ und „⏱ Pause“ unter den Sätzen einer Übung */
.log-set-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-ghost.log-ex-rest {
    padding: 8px 12px;
    min-height: 44px;
    font-size: 0.95em;
    color: var(--primary-hover);
}

/* Touch-Ziele auf dem Handy: alle Formularfelder und Buttons mindestens 44px
   (der Desktop-Formularstil der App ist 40/42px hoch). Am Dateiende, damit die
   Regel die kompakteren Einzelstile oben überstimmt. */
@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
    select,
    .btn-primary,
    .btn-secondary,
    .btn-ghost,
    .goal-mini,
    .segmented button,
    .add-exercise-controls .btn-add-exercise {
        min-height: 44px;
    }

    .remove-exercise {
        min-width: 44px;
        min-height: 44px;
    }
}
