:root {
    /* Farbpalette abgeleitet aus img/banner.png (Comic-Banner: kräftiges
       Himmelblau, schwarze Konturen, orange/gelbes Lettering). */
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --accent-orange: #f97316;
    --accent-yellow: #eab308;
    --dark: #0c2340;
    --border: #cfeafe;
    --bg-main: #f0f9ff;
    --danger: #ef4444;

    /* Zwei getrennte Akzentfarben, damit Task-Liste und Freitext pro Tag
       optisch klar unterscheidbar sind. */
    --task-bg: #e0f2fe;
    --task-border: #38bdf8;
    --note-bg: #fff7ed;
    --note-border: #fb923c;
}

/* Grund-Setup: Verhindert Scrollen auf der ganzen Seite */
* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    font-family: 'Segoe UI', system-ui, sans-serif;
    overflow: hidden;
}

#wrapper {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
#sidebar {
    position: relative;
    width: 260px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
	border-right:10px solid #FFFFFF;
    color: white;
    transition: margin-left 0.3s ease;
    flex-shrink: 0;
    box-shadow: 3px 0 14px rgba(0,0,0,0.12);
}
#sidebar.collapsed { margin-left: -260px; }

/* Ein-/Ausblenden-Button klebt als vertikaler "Halb-Button" (Handle) an der
   Sidebar-Kante und rutscht beim Slide mit, da er ein absolut positioniertes
   Kind von #sidebar ist. Mittig, hoher Kontrast, deutlich größer als vorher. */
.sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    right: -24px;
    transform: translateY(-50%);
    width: 24px;
    height: 80px;
    border-radius: 0 14px 14px 0;
    background: var(--dark);
    color: white;
    border: none;
    border-left: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 0 10px rgba(0,0,0,0.35);
    z-index: 20;
    transition: width 0.15s ease, background 0.15s ease;
}
.sidebar-toggle-btn:hover { background: #081729; width: 28px; }

/* .sidebar-inner ist der einzige scrollbare Bereich der Sidebar (der Toggle-
   Button liegt außerhalb davon und bleibt davon unberührt), damit das Banner
   + viele Ziele nicht über den sichtbaren Bereich hinauswachsen. */
.sidebar-inner {
    padding: 24px 20px 30px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-banner {
    display: block;
    width: 100%;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

/* RECHTE SEITE: Layout-Fix */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column; /* Header oben, Grid unten */
    height: 100vh;
    overflow: hidden; /* Wichtig: Main selbst darf nicht scrollen */
}

.top-nav {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; /* Header behält seine Höhe */
}

/* DAS SCROLLBARE GRID */
#calendar-grid {
    flex: 1; /* Nimmt den restlichen Platz ein */
    overflow-y: auto; /* HIER passiert das vertikale Scrollen */
    padding: 20px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    align-content: start;
    background: var(--bg-main);
}
/* Spaltenanzahl wird von script.js per Klasse gesetzt (statt Inline-Style),
   damit die schmale-Fenster-Regel weiter unten (Mindestbreite pro Spalte)
   sie per Media Query übersteuern kann - ein Inline-Style aus JS würde das
   verhindern. */
#calendar-grid.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#calendar-grid.grid-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }

/* Zellen-Design */
.day-cell {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 10px;
    height: 340px; /* Groß genug, damit alle Tasks ohne eigenen Scrollbar reinpassen */
    min-width: 0; /* Grid-Item darf unter seine Inhalts-Breite schrumpfen (siehe grid-template-columns) */
    cursor: pointer;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: height 0.2s ease, box-shadow 0.2s ease;
}
/* Wenn "Einzelne Tasks anzeigen" aus ist, braucht die Zelle die zusätzliche
   Höhe nicht mehr (nur noch die Ziel-Titel ohne Tasks) - .content-preview
   (flex:1) füllt den Rest ohnehin automatisch, aber die ganze Zelle darf dann
   insgesamt kompakter sein, damit mehr Tage ohne Scrollen sichtbar sind. */
#calendar-grid.tasks-hidden .day-cell { height: 210px; }
.day-cell:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.day-cell.today {
    border: 1px solid var(--primary);
	background: #eaf6ff;
	box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.day-header { font-weight: bold; font-size: 0.85rem; color: #7c93ab; margin-bottom: 5px; flex-shrink: 0; }

/* Scrollbarer Text INNERHALB des Tages - eigener (oranger) Akzent, damit er
   sich klar von der (blauen) Task-Liste absetzt. */
.content-preview {
    flex: 1;
    overflow-y: auto;
    overflow-wrap: break-word;
    word-break: break-word;
    font-size: 0.85rem;
    scrollbar-width: thin;
    background: var(--note-bg);
    border-left: 3px solid var(--note-border);
    border-radius: 4px;
    padding: 6px 6px 6px 6px;
    margin-top: 2px;
}
.content-preview img { width: 100%; border-radius: 6px; margin-top: 5px; display: block; }

/* Navigation Buttons */
.navigation-bar { display: flex; align-items: center; gap: 10px; }
.nav-group { display: flex; align-items: center; background: #eaf6ff; padding: 4px; border-radius: 10px; }
.view-btn { border: none; background: transparent; padding: 6px 10px; cursor: pointer; border-radius: 6px; font-weight: 600; color: #4b6b82; white-space: nowrap; }
.view-btn.active { background: white; color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-icon { background: transparent; border: none; cursor: pointer; padding: 5px 10px; font-size: 1rem; }
.btn { border: none; padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--primary); color: white; }

/* Fortschritt-Button: eigenständiger blauer Button rechts neben "Sprung zu Heute",
   statt Teil der Jahr/Monat/Woche-Gruppe (nutzt weiterhin .view-btn fürs Klick-Handling) */
.progress-nav-btn {
    background: var(--primary);
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    transition: background 0.15s ease;
}
.progress-nav-btn:hover { background: var(--primary-hover); }
.progress-nav-btn.active { background: var(--primary-hover); box-shadow: inset 0 2px 5px rgba(0,0,0,0.25); }

/* Zahnrad-Button: wie die anderen Nav-Buttons (blau, weißes Symbol), nur kleiner */
.settings-gear-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}
.settings-gear-btn:hover { background: var(--primary-hover); }

/* Daily Goals (Sidebar) */
.goals-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
}
.goals-section h3 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
    margin: 0 0 12px;
}
.goals-empty { font-size: 0.8rem; opacity: 0.75; }
.goal-def-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
}
.goal-def-reorder { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; margin-top: 1px; }
.goal-move-btn {
    width: 18px;
    height: 15px;
    padding: 0;
    border: none;
    border-radius: 3px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 0.55rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.goal-move-btn:hover:not(:disabled) { background: rgba(255,255,255,0.4); }
.goal-move-btn:disabled { opacity: 0.25; cursor: default; }
.goal-def-text { flex: 1; min-width: 0; }
.goal-def-text strong { display: block; font-size: 0.9rem; }
.goal-def-tasks { margin: 4px 0 0; padding-left: 16px; font-size: 0.78rem; opacity: 0.85; line-height: 1.4; }
.goal-def-tasks li { margin-bottom: 1px; }
.goal-def-delete { background: none; border: none; color: white; opacity: 0.6; cursor: pointer; font-size: 0.9rem; padding: 0 2px; flex-shrink: 0; }
.goal-def-delete:hover { opacity: 1; }
.goal-add-form { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.goal-add-form input {
    border: none;
    border-radius: 6px;
    padding: 7px 9px;
    font-size: 0.82rem;
    font-family: inherit;
    width: 100%;
}
.goal-add-form button { margin-top: 2px; font-size: 0.85rem; }
.goal-add-form input.input-error {
    outline: 2px solid var(--danger);
    animation: shake-error 0.3s;
}
@keyframes shake-error {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Task-Eingabezeile + gesammelte (noch nicht gespeicherte) Tasks im Formular */
.goal-task-input-row { display: flex; gap: 6px; }
.goal-task-input-row input { flex: 1; }
.goal-task-input-row button {
    flex-shrink: 0;
    width: 30px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.25);
    color: white;
    font-size: 1rem;
    cursor: pointer;
}
.goal-task-input-row button:hover { background: rgba(255,255,255,0.4); }
.goal-pending-tasks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.goal-pending-tasks li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.15);
    border-radius: 5px;
    padding: 3px 6px;
    font-size: 0.78rem;
}
.goal-pending-tasks button {
    background: none;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}
.goal-pending-tasks button:hover { opacity: 1; }

/* Goal-Checkliste innerhalb einer Tages-Zelle - eigener (blauer) Akzent,
   damit sie sich klar vom (orangen) Freitext-Bereich absetzt. */
.goal-checklist {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 6px;
    flex-shrink: 0;
    background: var(--task-bg);
    border-left: 3px solid var(--task-border);
    border-radius: 4px;
    padding: 6px 6px 6px 6px;
}
.goal-group { display: flex; flex-direction: column; gap: 2px; }
.goal-subtasks {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 14px;
    border-left: 2px solid #bae6fd;
    margin-left: 5px;
}
.goal-check-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0; /* erlaubt dem Label, per Ellipsis zu kürzen statt die Zelle zu sprengen */
    cursor: pointer;
    font-size: 0.72rem;
    color: #3b5568;
    line-height: 1.2;
}
.goal-group-header { font-weight: 600; color: #1e3a5f; }
.goal-check-box {
    width: 12px;
    height: 12px;
    border: 1.5px solid #b9d4e8;
    border-radius: 4px;
    flex-shrink: 0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}
.goal-check-item.checked .goal-check-box {
    background: var(--primary);
    border-color: var(--primary);
}
.goal-check-item.checked .goal-check-box::after {
    content: '✓';
    color: white;
    font-size: 8px;
    line-height: 1;
}
.goal-check-item.partial .goal-check-box {
    background: white;
    border-color: var(--primary);
}
.goal-check-item.partial .goal-check-box::after {
    content: '';
    width: 6px;
    height: 2px;
    background: var(--primary);
}
.goal-check-item.checked .goal-check-label { text-decoration: line-through; opacity: 0.55; }
.goal-check-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Einstellungen */
.settings-section { margin-bottom: 22px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section h4 { margin: 0 0 10px; font-size: 0.95rem; color: var(--dark); }
.settings-checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: 0.88rem; cursor: pointer; line-height: 1.4; color: var(--dark); text-align: left; }
.settings-checkbox input { margin-top: 3px; }
.settings-danger-box {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--danger);
    border-radius: 8px;
    background: #fef2f2;
    text-align: left;
}
#delete-confirm-input { border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; width: 100%; margin-bottom: 8px; text-align: left; }
#delete-confirm-final-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modal - Karte mit farbigem "Banner" oben (Icon + Notch), angelehnt an den
   vom Nutzer gezeigten Subscribe-Card-Stil. */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 9999; }
.hidden { display: none !important; }
.modal-content {
    background: white;
    padding: 0;
    border-radius: 22px;
    width: 440px;
    max-width: 92vw;
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.25);
}

.modal-banner {
    position: relative;
    flex-shrink: 0;
    background: var(--primary);
    padding: 22px 44px 32px;
    text-align: center;
}
.modal-banner-title { font-size: 1.15rem; font-weight: 700; color: white; line-height: 1.3; }
.modal-banner-notch {
    position: absolute;
    left: 50%;
    bottom: -13px;
    width: 26px;
    height: 26px;
    background: var(--primary);
    transform: translateX(-50%) rotate(45deg);
    border-radius: 5px;
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.25);
    color: white;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}
.modal-close:hover { background: rgba(255,255,255,0.4); }

.modal-body { padding: 22px 26px 26px; text-align: center; overflow-y: auto; }

textarea { width: 100%; height: 120px; border: 1px solid var(--note-border); border-radius: 10px; padding: 10px; margin: 0 0 14px; font-family: inherit; text-align: left; }

.upload-wrapper { margin-bottom: 14px; }
#upload-label { display: block; border: 2px dashed #cbd5e1; padding: 12px; text-align: center; cursor: pointer; border-radius: 10px; font-size: 0.9rem; color: #64748b; }

.modal-actions { display: flex; justify-content: space-between; gap: 10px; }

/* Pillenförmige Buttons wie im Referenz-Stil */
.btn-pill { border-radius: 999px !important; padding: 10px 26px !important; }
.btn-outline-danger { background: white; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-outline-danger:hover { background: #fef2f2; }
.btn-danger-solid { background: var(--danger); color: white; }
.btn-outline-primary { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline-primary:hover { background: var(--task-bg); }

/* Gewichts-Eingabe im Editor-Modal */
.weight-input-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; text-align: left; }
.weight-input-row label { font-size: 0.85rem; color: var(--dark); font-weight: 600; white-space: nowrap; }
.weight-input-row input {
    flex: 1;
    border: 1px solid var(--task-border);
    background: var(--task-bg);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-family: inherit;
}

/* Kleines Gewichts-Badge im Tages-Header, falls für den Tag ein Wert erfasst ist.
   Gleichzeitig Klick-Auslöser für die Schnelleingabe (kein Modal nötig). */
.day-weight-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary-hover);
    background: var(--task-bg);
    border: 1px solid var(--task-border);
    border-radius: 999px;
    padding: 1px 7px;
    white-space: nowrap;
}
.quick-weight-trigger { cursor: pointer; }

/* "+ ⚖️"-Hinweis für Tage ohne Gewichtswert: nur beim Hover über die Tageskachel
   sichtbar, damit der Kalender im Normalzustand aufgeräumt bleibt */
.day-weight-add {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.65rem;
    color: var(--primary);
    opacity: 0;
    transition: opacity 0.15s ease;
    white-space: nowrap;
}
.day-cell:hover .day-weight-add { opacity: 1; }

/* Inline-Eingabefeld, das Badge/"+"-Hinweis beim Klick ersetzt (Schnelleingabe) */
.quick-weight-input {
    width: 62px;
    margin-left: 6px;
    font-size: 0.7rem;
    padding: 1px 5px;
    border: 1px solid var(--task-border);
    border-radius: 6px;
    font-family: inherit;
}

/* Trend-Pfeil im Vergleich zum letzten zuvor erfassten Gewichtswert */
.weight-trend-arrow { margin-left: 3px; font-weight: 700; }
.weight-trend-arrow.trend-down { color: #16a34a; }
.weight-trend-arrow.trend-up { color: var(--danger); }
.weight-trend-arrow.trend-same { color: #94a3b8; }

/* Fortschritts-Ansicht (4. Tab neben Jahr/Monat/Woche) */
#progress-view {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-main);
}
.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: #7c93ab; margin-bottom: 4px; }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--dark); }

/* Meilenstein-Hinweis: neues Tiefstgewicht oder 5-kg-Etappe seit Start */
.milestone-banner {
    text-align: center;
    font-weight: 700;
    color: var(--primary-hover);
    background: var(--task-bg);
    border: 1px solid var(--task-border);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 20px;
}

.progress-target-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
}
.progress-target-row label { font-weight: 600; color: var(--dark); font-size: 0.88rem; white-space: nowrap; }
.progress-target-row input {
    width: 110px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 9px;
    font-family: inherit;
}

.progress-bar-wrapper { margin-bottom: 22px; }
.progress-bar-track {
    height: 14px;
    background: var(--task-bg);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--task-border);
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: 999px;
    transition: width 0.4s ease;
}
.progress-bar-label { margin-top: 8px; font-size: 0.85rem; color: var(--dark); text-align: center; }

.progress-chart-wrapper {
    position: relative;
    height: 320px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

/* Gemeinsamer Überschrift-Stil für die zusätzlichen Fortschritts-Abschnitte
   (Wochen-Tabelle, Ziele-Heatmap) */
.progress-section-title {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: var(--dark);
}

/* Wochen-Durchschnitts-Tabelle */
.progress-weekly-wrapper {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.weekly-avg-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.weekly-avg-table th {
    text-align: left;
    color: #7c93ab;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}
.weekly-avg-table td {
    padding: 7px 8px 7px 0;
    border-bottom: 1px solid var(--border);
    color: var(--dark);
}
.weekly-avg-empty { text-align: center; color: #7c93ab; padding: 14px !important; }

/* Ziele-Heatmap fürs Jahr (GitHub-artige Kachel-Übersicht) */
.progress-heatmap-wrapper {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.goal-heatmap { display: flex; gap: 3px; overflow-x: auto; padding: 4px 2px; }
.goal-heatmap-empty { color: #7c93ab; font-size: 0.85rem; }
.heatmap-weekday-col { display: flex; flex-direction: column; gap: 3px; margin-right: 4px; flex-shrink: 0; }
.heatmap-weekday-label { width: 11px; height: 11px; font-size: 0.5rem; color: #7c93ab; line-height: 11px; text-align: center; }
.heatmap-week-col { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.heatmap-cell { width: 11px; height: 11px; border-radius: 2px; background: #e5e7eb; }
.heatmap-cell.heat-0 { background: #e5e7eb; }
.heatmap-cell.heat-1 { background: #bae6fd; }
.heatmap-cell.heat-2 { background: #7dd3fc; }
.heatmap-cell.heat-3 { background: #38bdf8; }
.heatmap-cell.heat-4 { background: #0284c7; }
.heatmap-cell.heat-empty { background: transparent; }

/* ==========================================================================
   Dark Mode (Einstellungen -> Anzeige -> "Dunkles Design verwenden")
   Wird per Klasse "dark-mode" auf <html> umgeschaltet (script.js), so früh wie
   möglich beim Seitenaufruf bereits inline in index.php gesetzt, um ein
   Aufblitzen des hellen Designs zu vermeiden. Übersteuert gezielt Hintergrund-
   /Text-/Rahmenfarben der wichtigsten Flächen, ohne die Farbpalette (Primary-
   Blau, Akzentfarben) selbst anzutasten.
   ========================================================================== */
html.dark-mode {
    --bg-main: #0f172a;
    --border: #263449;
    --dark: #e2e8f0;
    --task-bg: #16324f;
    --task-border: #1d4e73;
    --note-bg: #3a2a16;
    --note-border: #7a4a1e;
}
html.dark-mode body { background: #0f172a; }
html.dark-mode .top-nav { background: #111827; border-color: #263449; }
html.dark-mode .nav-group { background: #0f172a; }
html.dark-mode .view-btn { color: #94a3b8; }
html.dark-mode .view-btn.active { background: #1e293b; color: var(--primary); }
/* Content-Header (Monats-/Wochen-/Jahres-Titel) + Prev/Next-Pfeile: hatten
   noch keine eigene Dark-Mode-Regel und blieben dadurch beim Browser-Default
   Schwarz auf dem jetzt dunklen Nav-Hintergrund (Kontrast nur 1.18:1). */
html.dark-mode #current-view-label,
html.dark-mode .btn-icon { color: #e2e8f0; }
html.dark-mode .day-cell,
html.dark-mode .stat-card,
html.dark-mode .modal-content,
html.dark-mode .progress-target-row,
html.dark-mode .progress-chart-wrapper,
html.dark-mode .progress-weekly-wrapper,
html.dark-mode .progress-heatmap-wrapper {
    background: #1e293b;
    color: #e2e8f0;
}
html.dark-mode .day-cell.today { background: #16324f; }
html.dark-mode .day-header { color: #94a3b8; }
html.dark-mode .stat-value,
html.dark-mode .progress-section-title,
html.dark-mode .progress-bar-label,
html.dark-mode .weekly-avg-table td,
html.dark-mode .settings-section h4,
html.dark-mode .settings-checkbox { color: #e2e8f0; }
html.dark-mode textarea,
html.dark-mode input[type="text"],
html.dark-mode input[type="number"],
html.dark-mode .progress-target-row input,
html.dark-mode #delete-confirm-input {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}
html.dark-mode #upload-label { border-color: #334155; color: #94a3b8; }
html.dark-mode .goal-heatmap-empty,
html.dark-mode .weekly-avg-empty,
html.dark-mode .heatmap-weekday-label { color: #7c93ab; }

/* Ziel-Checkliste in den Tageskacheln: die hartkodierten dunklen Textfarben
   (für hellen Hintergrund gedacht) waren gegen den dunklen Kachel-Hintergrund
   praktisch unlesbar (Kontrast ~1.1:1) - hier gezielt aufgehellt. */
html.dark-mode .goal-check-item { color: #ffffff; }
html.dark-mode .goal-group-header { color: #ffffff; }
/* Gewichts-Badge & Meilenstein-Banner: Kontrast von 3.2:1 auf komfortabler lesbar angehoben */
html.dark-mode .day-weight-badge,
html.dark-mode .milestone-banner { color: #7dd3fc; }

/* ==========================================================================
   RESPONSIVE: Content-Bereich (Kopfzeile + Kalender) passt sich schmaleren
   Fensterbreiten an, ohne Inhalte auszublenden oder Daten zu verlieren -
   es wird nur umgebrochen bzw. kompakter dargestellt statt horizontal zu
   scrollen. Die Sidebar (260px) wird ab 900px Fensterbreite zu einem
   Overlay, damit sie den Content-Bereich nicht mehr zusammendrückt (siehe
   applyResponsiveSidebar() in script.js für die automatische Ein-/Ausklapp-
   Logik; die Klasse ".collapsed" behält dabei ihre normale Bedeutung).
   ========================================================================== */
#current-view-label {
    font-size: 1.4rem;
    margin: 0;
    line-height: 1.2;
}

@media (max-width: 900px) {
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 200;
    }
    #sidebar:not(.collapsed) {
        box-shadow: 6px 0 24px rgba(0,0,0,0.35);
    }

    .top-nav {
        flex-wrap: wrap;
        row-gap: 10px;
        padding: 12px 16px;
    }
    .navigation-bar {
        flex-wrap: wrap;
        row-gap: 8px;
    }
}

@media (max-width: 640px) {
    #current-view-label { font-size: 1.15rem; }
    .top-nav { padding: 10px 12px; }
    #calendar-grid { padding: 12px; gap: 8px; }
    .day-cell { padding: 7px; }
    .day-header { font-size: 0.78rem; }
    .content-preview,
    .goal-checklist { font-size: 0.78rem; }

    /* Monats-/Wochenansicht (7 Spalten): unter dieser Breite würden die
       Spalten so schmal, dass z.B. das Gewichts-Badge im Tages-Header nicht
       mehr reinpasst und die Nachbarzelle überlappt. Statt die Zellen
       unlesbar zusammenzuquetschen (= Daten optisch "verlieren"), bekommt
       jede Spalte eine Mindestbreite - reicht der Platz nicht für alle 7,
       scrollt NUR das Kalender-Grid selbst horizontal (die Kopfzeile bleibt
       stehen), die ganze Seite scrollt dabei nicht mit. */
    #calendar-grid.grid-cols-7 {
        grid-template-columns: repeat(7, minmax(78px, 1fr));
        overflow-x: auto;
    }
    .day-weight-badge,
    .day-weight-add {
        font-size: 0.58rem;
        padding: 1px 5px;
        margin-left: 4px;
    }
}
