:root {
    /* Dunkles Theme (Sportify-Stil) */
    --bg: #0a0e14;
    --surface: #12161d;
    --surface-2: #1a2029;
    --card: #12161d;          /* Kartenhintergrund (= surface) */
    --card-2: #1a2029;        /* leicht abgehobene Fläche */
    --border: #232a36;
    --text: #eef2f7;
    --muted: #8b95a3;
    /* Lindgrüner Akzent */
    --accent: #b6f24d;
    --accent-strong: #c8ff5e;
    --accent-2: #b6f24d;
    --on-accent: #0a0e14;     /* Textfarbe auf grünem Akzent */
    --danger: #ff6b6b;
    --ok: #b6f24d;
    --radius: 14px;
    --shadow: 0 2px 8px rgba(0, 0, 0, .4), 0 14px 36px rgba(0, 0, 0, .4);
    /* Dunkle Menüleiste */
    --menu-bg: #0a0e14;
    --menu-text: #eef2f7;
    --menu-muted: #8b95a3;
    --menu-border: #1a212b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.brand { display: flex; align-items: center; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 38px; display: block; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }
.user-chip:hover { text-decoration: none; color: var(--accent); }
.hi { color: var(--muted); font-size: .95rem; }

/* ---- App-Layout mit Seitenleiste ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex: none;
    background: #0c1016;
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    z-index: 200;
}
.sidebar .brand { padding: 4px 8px 20px; }
.sidebar .brand-logo { height: 42px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px;
    color: var(--menu-muted); font-weight: 600; white-space: nowrap;
}
.side-nav a:hover { background: rgba(255, 255, 255, .05); color: var(--text); text-decoration: none; }
.side-nav a.active { color: var(--accent); background: rgba(182, 242, 77, .12); }
.nav-ico { width: 19px; height: 19px; flex: none; }
.side-user { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mtopbar { display: none; }

.nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 190; }
.nav-overlay.open { display: block; }

/* Topbar nur für ausgeloggte Seiten (Login/Register) */
.topbar { padding: 12px 20px; background: var(--menu-bg); border-bottom: 1px solid var(--menu-border); }
.topbar-inner { display: flex; align-items: center; gap: 16px; max-width: 1100px; margin: 0 auto; }

/* ---- Hamburger ---- */
.burger {
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 40px; height: 40px; padding: 8px;
    background: transparent; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; flex: none;
}
.burger span { display: block; height: 2px; background: var(--text); border-radius: 2px; transition: transform .25s, opacity .25s; }
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Mobile: Seitenleiste als Off-Canvas ---- */
@media (max-width: 900px) {
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; height: 100%;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
        z-index: 300; box-shadow: 4px 0 28px rgba(0, 0, 0, .6);
    }
    .sidebar.open { transform: none; }
    .mtopbar {
        display: flex; align-items: center; gap: 12px;
        padding: 10px 14px; background: var(--menu-bg);
        border-bottom: 1px solid var(--menu-border);
        position: sticky; top: 0; z-index: 150;
    }
    .mtopbar .brand-logo { height: 30px; }
    body.nav-open { overflow: hidden; }
}

/* ---- Avatare ---- */
.avatar { border-radius: 50%; object-fit: cover; display: inline-flex; vertical-align: middle; flex: none; }
.avatar-fallback { align-items: center; justify-content: center; color: #15181d; font-weight: 700; line-height: 1; }

/* ---- Profil ---- */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.profile-name { font-size: 1.4rem; font-weight: 800; }
.profile-facts { width: 100%; }
.profile-facts th { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 600; width: 40%; }
.avatar-input { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.avatar-preview { display: inline-flex; }
.avatar-actions { display: flex; flex-direction: column; gap: 8px; }
.cam-wrap { margin-top: 6px; }
.cam-wrap video, .cam-wrap canvas { width: 100%; max-width: 360px; aspect-ratio: 1/1; object-fit: cover; border-radius: 12px; background: #000; display: block; margin: 0 auto; }
.cam-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* ---- Layout ---- */
.container { max-width: none; margin: 0; padding: 24px 32px; }
.container-wide { max-width: none; }
.site-footer { text-align: center; color: var(--muted); padding: 32px; font-size: .85rem; }

h1, h2, h3 { line-height: 1.2; }
h1 { font-size: 1.6rem; margin-top: 0; }
.muted { color: var(--muted); }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stat { text-align: center; }
.stat .num { font-size: 1.8rem; font-weight: 800; color: var(--text); }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat .num-sub { font-size: 1rem; color: var(--muted); font-weight: 600; }

/* ---- Dashboard-Uebersichtstabelle ---- */
.table-wrap { overflow-x: auto; }
.overview { min-width: 560px; }
.overview .num-col { text-align: right; white-space: nowrap; }
.overview tbody tr.me-row { background: rgba(255, 255, 255, .05); }
.overview tbody td { font-variant-numeric: tabular-nums; }
.overview tfoot td { border-top: 2px solid var(--border); border-bottom: none; }

/* ---- Zeitraum-Navigation (Pfeile) ---- */
.period-nav { display: inline-flex; align-items: center; gap: 10px; }
.period-current { font-size: 1.1rem; min-width: 8ch; text-align: center; }
.period-arrow {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); font-size: 1.4rem; font-weight: 800; line-height: 1; text-decoration: none;
}
.period-arrow:hover { background: var(--accent); color: #15181d; border-color: var(--accent); text-decoration: none; }
.period-arrow.disabled { opacity: .35; pointer-events: none; }

/* ---- Zeitraum-Filter ---- */
.period-filter { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.period-btn {
    padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .85rem;
    color: var(--muted); white-space: nowrap;
}
.period-btn:hover { text-decoration: none; color: var(--accent-strong); }
.period-btn.active { background: var(--accent); color: #15181d; }
.period-btn.active:hover { color: #15181d; }

/* Kalender-Tage im gewählten Zeitraum hervorgehoben */
.cal-cell.in-range { background: rgba(255, 255, 255, .06); }
.cal-cell.today.in-range { background: rgba(255, 255, 255, .12); }

/* ---- Dashboard: User-Kacheln nebeneinander ---- */
.user-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.user-tile {
    flex: 1 1 200px; text-align: left; cursor: pointer; color: var(--text);
    font: inherit; background: var(--surface);
    border: 1px solid var(--border); border-top: 3px solid var(--accent);
    border-radius: var(--radius); padding: 16px; transition: border-color .15s, box-shadow .15s;
}
.user-tile:hover { border-color: var(--accent); }
.user-tile.active { box-shadow: 0 0 0 2px var(--accent) inset; }
.user-tile h3 { margin: 0 0 12px; font-size: 1.1rem; }
.tile-head { display: flex; align-items: center; gap: 8px; }
.tile-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.tile-metrics > div { display: flex; flex-direction: column; }
.tile-metrics .m-val { font-weight: 800; font-size: 1.5rem; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile-metrics .m-lbl { color: var(--muted); font-size: .8rem; }
.user-tile .hint { margin-top: 12px; font-size: .75rem; color: var(--muted); }
.user-tile.active .hint { color: var(--accent); }

.user-detail { display: none; margin-top: 12px; }
.user-detail.open { display: block; }

/* ---- Überschriften-Icon (passend zum Menü-Stil) ---- */
.h-ico {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    vertical-align: -3px;
    color: var(--accent);
    margin-right: 8px;
}

/* ---- Athleten-Suche ---- */
.athlete-search { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-field { position: relative; flex: 1 1 280px; max-width: 420px; }
.search-field .search-ico {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
}
.athlete-search input {
    width: 100%;
    padding: 11px 14px 11px 42px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
}
.athlete-search input:focus { outline: none; border-color: var(--accent); }
.search-field:focus-within .search-ico { color: var(--accent); }
.athlete-search-empty { color: var(--muted); font-size: .9rem; }

/* ---- Athleten-Kacheln (nur Bild, Name, Ort/Land) ---- */
.athlete-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 14px;
}
.athlete-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 20px 14px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 14px;
    cursor: pointer;
    color: var(--text);
    font: inherit;
    transition: transform .12s, box-shadow .12s;
}
.athlete-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.athlete-tile .avatar { width: 72px; height: 72px; }
.athlete-tile .athlete-name { font-weight: 800; font-size: 1.05rem; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.athlete-tile .athlete-place { color: var(--muted); font-size: .85rem; }
.athlete-tile .hint { margin-top: 6px; font-size: .75rem; color: var(--muted); }
.athlete-tile.active { border-color: var(--accent); }
.athlete-tile.active .hint { color: var(--accent); }

/* ---- Athleten-Profilkarte (im Detail) ---- */
.athlete-profile { display: flex; gap: 18px; align-items: flex-start; }
.athlete-profile .avatar { width: 84px; height: 84px; flex: 0 0 auto; }
.athlete-profile-main { flex: 1 1 auto; min-width: 0; }
@media (max-width: 560px) {
    .athlete-profile { flex-direction: column; align-items: center; text-align: center; }
}

/* ---- Auswertungs-Raster (Strava-Statistiken) ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.stat-box {
    background: var(--card-2, rgba(255,255,255,.03));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
.stat-val {
    font-weight: 800;
    font-size: 1.5rem;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat-val .stat-unit { font-size: .8rem; font-weight: 600; color: var(--muted); }
.stat-lbl { margin-top: 4px; color: var(--muted); font-size: .8rem; }
@media (max-width: 560px) {
    .stats-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 8px; }
    .stat-val { font-size: 1.25rem; }
}

/* ---- Sportart-Akkordeon mit Diagrammen ---- */
.sport-acc {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
}
.sport-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text);
    text-align: left;
    font: inherit;
}
.sport-head:hover { background: rgba(255,255,255,.03); }
.sport-head .sport-ico { font-size: 1.3rem; line-height: 1; }
.sport-head .sport-name { font-weight: 800; font-size: 1.05rem; }
.sport-head .sport-sum { color: var(--muted); font-size: .85rem; margin-left: auto; }
.sport-head .sport-caret { transition: transform .2s; color: var(--muted); }
.sport-head.active { background: rgba(182,242,77,.06); }
.sport-head.active .sport-caret { transform: rotate(180deg); color: var(--accent); }
.sport-body { display: none; padding: 0 16px 16px; }
.sport-body.open { display: block; }

/* Sub-Überschriften & Highlight-Kacheln in der Sport-Auswertung */
.sport-sub {
    margin: 18px 0 8px;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.sport-hl { margin-top: 12px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.sport-hl .stat-box {
    background: linear-gradient(180deg, rgba(182,242,77,.10), rgba(182,242,77,.02));
    border-color: rgba(182,242,77,.30);
}
.sport-hl .stat-val { color: var(--accent); font-size: 1.7rem; }

.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 14px;
}
.chart-card {
    background: var(--card-2, rgba(255,255,255,.03));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
}
.chart-title { font-size: .85rem; font-weight: 700; margin-bottom: 6px; }
.chart-title .muted { font-weight: 400; }
.chart-card { cursor: zoom-in; }
.chart-card:hover { border-color: var(--accent); }
.chart-card canvas { width: 100%; display: block; pointer-events: none; }

/* ---- Diagramm-Popup ---- */
body.modal-open { overflow: hidden; }
.chart-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0,0,0,.66);
    backdrop-filter: blur(2px);
}
.chart-modal[hidden] { display: none; }
.chart-modal-card {
    position: relative;
    width: min(900px, 96vw);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 20px 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.chart-modal-title { font-weight: 800; font-size: 1.15rem; margin: 0 30px 12px 2px; }
.chart-modal-canvas { width: 100%; display: block; }
.chart-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
}
.chart-modal-close:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Analyse: Bestwert-Hervorhebung ---- */
td.best {
    color: var(--accent);
    font-weight: 800;
    background: rgba(182, 242, 77, .08);
}

/* Athleten-Auswahl als Foto-Namen-Chips */
.athlete-picks { display: flex; flex-wrap: wrap; gap: 10px; }
.athlete-pick {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 14px 5px 5px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--card); cursor: pointer; user-select: none;
}
.athlete-pick .avatar { width: 30px; height: 30px; }
.athlete-pick:hover { border-color: var(--accent); }
.athlete-pick.selected,
.athlete-pick:has(input:checked) {
    border-color: var(--accent);
    background: rgba(182, 242, 77, .18);
    color: var(--accent);
    font-weight: 700;
}
.athlete-pick.selected::after,
.athlete-pick:has(input:checked)::after { content: '✓'; color: var(--accent); font-weight: 800; margin-left: 2px; }

/* Lauf-Auswahlliste */
.run-pick-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px; max-height: 320px; overflow: auto; padding: 2px;
}
.run-pick {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--card); cursor: pointer;
}
.run-pick:hover { border-color: var(--accent); }
.run-pick.sel,
.run-pick:has(input:checked) { border-color: var(--accent); background: rgba(182, 242, 77, .18); }
.run-pick .avatar { width: 26px; height: 26px; flex: 0 0 auto; }
.run-pick-main { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.run-pick-main .muted { font-size: .8rem; }

/* Lauf-Vergleich: Tabelle mit einer Spalte je Lauf */
.cmp-table th, .cmp-table td { white-space: nowrap; }
.cmp-table tbody th { text-align: left; color: var(--muted); font-weight: 600; }
.cmp-table .cmp-col { min-width: 140px; }
.cmp-head { display: flex; align-items: center; gap: 6px; }
.cmp-head .avatar { width: 28px; height: 28px; flex: 0 0 auto; }
.cmp-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; }
.cmp-leg { display: flex; align-items: center; gap: 6px; }
.cmp-leg .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ---- Bildergalerie ---- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 6px;
}
.gallery-item {
    background: var(--card-2, rgba(255,255,255,.03));
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.gallery-thumb { display: block; cursor: zoom-in; aspect-ratio: 1 / 1; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    font-size: .8rem;
    color: var(--muted);
}
.gallery-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-del {
    background: transparent; border: 0; cursor: pointer; color: var(--muted);
    font-size: .9rem; line-height: 1; padding: 2px 4px;
}
.gallery-del:hover { color: #ef3b30; }
.gallery-cap { padding: 0 8px 8px; font-size: .8rem; color: var(--text); }

/* Lightbox */
.gallery-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(0,0,0,.85);
}
.gallery-modal[hidden] { display: none; }
.gallery-modal-fig { margin: 0; max-width: 96vw; max-height: 92vh; text-align: center; }
.gallery-modal-fig img { max-width: 96vw; max-height: 84vh; border-radius: 10px; display: block; margin: 0 auto; }
.gallery-modal-fig figcaption { color: #e5e7eb; margin-top: 10px; font-size: .9rem; }
.gallery-modal-close {
    position: absolute; top: 14px; right: 16px;
    width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.4);
    color: #fff; font-size: 1.1rem; cursor: pointer;
}
.gallery-modal-close:hover { border-color: var(--accent); color: var(--accent); }
.gallery-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 48px; height: 48px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.45);
    color: #fff; font-size: 1.8rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 2;
}
.gallery-prev { left: 14px; }
.gallery-next { right: 14px; }
.gallery-nav:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 560px) {
    .gallery-nav { width: 40px; height: 40px; font-size: 1.5rem; }
    .gallery-prev { left: 6px; }
    .gallery-next { right: 6px; }
}
@media (max-width: 560px) {
    .sport-head .sport-sum { display: none; }
    .charts { grid-template-columns: 1fr; }
}

/* ---- Druckansicht (Trainingsplan) ---- */
.print-month { display: none; }   /* nur beim Drucken sichtbar */
@media print {
    .print-month { display: inline; }
    @page { size: landscape; margin: 1cm; }
    body { background: #fff; color: #000; }
    .topbar, .site-footer, .no-print, .burger, .nav-overlay { display: none !important; }
    .container { max-width: none; margin: 0; padding: 0; }
    .card { background: #fff; border: none; box-shadow: none; padding: 0; margin: 0 0 8px; }
    h1, h2, h3 { color: #000; }
    a { color: #000; text-decoration: none; }

    .calendar { padding: 0; }
    .cal-grid { gap: 2px; }
    .cal-dow { color: #000; }
    .cal-cell {
        background: #fff; border: 1px solid #999; min-height: 90px;
        break-inside: avoid; page-break-inside: avoid;
    }
    .cal-cell.empty { border: none; }
    .cal-cell.today { box-shadow: none; border: 2px solid #000; }
    .cal-daynum { color: #000; }
    .cal-event {
        background: #fff; border: 1px solid #bbb; border-left-width: 4px !important;
        color: #000;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .cal-event.done .cal-ev-title { color: #666; }
    .cal-ev-actions, .cal-ev-garmin { display: none !important; }
    .tag { border: 1px solid #999; color: #000; background: #fff; }
    .dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Forms ---- */
.form-narrow { max-width: 380px; margin: 48px auto; }
.login-slogan { color: var(--accent); font-weight: 800; font-size: 1.7rem; text-align: center; margin: 0 0 24px; letter-spacing: .02em; line-height: 1.25; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .9rem; }
input, textarea, select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn {
    display: inline-block;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
}
.btn:hover { background: var(--accent-strong); text-decoration: none; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .85rem; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.alert-error { background: #fdecec; border: 1px solid #f5b5b5; color: #b42318; }
.alert-ok { background: #e9f7ef; border: 1px solid #aee0c2; color: #11703a; }

/* ---- Workouts ---- */
.workout { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); }
.workout:last-child { border-bottom: none; }
.workout.done .w-title { text-decoration: line-through; color: var(--muted); }
.w-body { flex: 1; }
.w-title { font-weight: 700; }
.w-meta { color: var(--muted); font-size: .85rem; }
.tag {
    display: inline-block; font-size: .7rem; text-transform: uppercase;
    letter-spacing: .04em; padding: 2px 8px; border-radius: 999px;
    background: var(--surface-2); color: var(--accent-2); font-weight: 700;
}

/* ---- Tabelle ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Chat ---- */
.chat-window {
    height: 50vh; overflow-y: auto; padding: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 12px;
    display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.msg.mine { align-self: flex-end; background: var(--accent); color: #15181d; }
.msg .who { font-size: .75rem; font-weight: 700; opacity: .8; margin-bottom: 2px; }
.msg .when { font-size: .65rem; opacity: .6; margin-top: 2px; }
.chat-form { display: flex; gap: 8px; align-items: flex-start; }
.chat-form input { flex: 1; }
.mention-wrap { position: relative; flex: 1; }
.mention-wrap input { width: 100%; }

/* @-Mention im Nachrichtentext */
.mention { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 700; padding: 0 3px; border-radius: 4px; }

/* Autocomplete-Box */
.mention-box {
    position: absolute; bottom: calc(100% + 4px); left: 0; right: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow); overflow: hidden; z-index: 50;
}
.mention-item { padding: 9px 12px; cursor: pointer; font-size: .95rem; }
.mention-item.active, .mention-item:hover { background: rgba(255, 255, 255, .08); }

/* Push-Button aktiv */
#pushBtn.active { background: var(--accent); color: #15181d; border-color: var(--accent); }

.flex { display: flex; gap: 12px; align-items: center; }
.between { justify-content: space-between; }

/* ---- Athleten-Auswahl (Workout fuer mehrere) ---- */
.for-users { grid-column: 1 / -1; }
.athlete-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.athlete-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border: 1px solid var(--border); border-radius: 999px;
    cursor: pointer; font-weight: 600; font-size: .9rem; background: var(--surface-2); user-select: none;
}
.athlete-chip input { width: auto; margin: 0; accent-color: var(--accent); }
.athlete-chip:has(input:checked) { border-color: var(--accent); background: rgba(255, 255, 255, .12); color: #fff; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }


/* ---- Freigaben ---- */
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.share-row:last-child { border-bottom: none; }
.share-user { display: flex; align-items: center; gap: 10px; }
.share-name { font-weight: 700; }
.share-detail { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: 4px; }

/* ---- Upload-Bereich (Garmin) ---- */
.upload-drop {
    display: flex; align-items: center; gap: 14px;
    padding: 20px; border: 2px dashed var(--border); border-radius: var(--radius);
    background: var(--surface-2); cursor: pointer; text-align: left;
}
.upload-drop:hover { border-color: var(--accent); background: rgba(255, 255, 255, .05); }
.upload-ico { font-size: 2rem; }

/* ---- Pull-to-Refresh-Indikator ---- */
.ptr-indicator {
    position: fixed; top: 0; left: 50%;
    transform: translateX(-50%); opacity: 0;
    width: 40px; height: 40px; border-radius: 50%;
    background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent); font-size: 1.4rem; z-index: 400; pointer-events: none;
}
.ptr-indicator.ready { color: var(--accent-strong); }
.ptr-indicator.loading .ptr-spin { animation: ptr-spin .7s linear infinite; }
.ptr-spin { display: inline-block; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ---- Pager (Seitennavigation) ---- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.pager-info { color: var(--muted); font-size: .85rem; font-weight: 600; }

/* ---- Rangliste ---- */
.rank-list { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 14px; padding: 15px 10px; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-row.winner { background: rgba(255, 255, 255, .1); border-radius: 10px; }
.rank-pos { width: 36px; text-align: center; font-weight: 800; font-size: 1.4rem; }
.rank-name { flex: 1; min-width: 0; font-weight: 700; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-km { font-weight: 800; font-size: 1.2rem; color: var(--accent-strong); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.rank-row .avatar { flex: none; }

/* ---- Admin-Aktionen ---- */
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-actions form { margin: 0; }
.danger-zone { border: 1px solid var(--danger); }
.tag-ok { background: #e9f7ef; color: #11703a; }
.user-search { margin-bottom: 8px; }
.shared-with-me { display: flex; flex-wrap: wrap; gap: 8px; }
.shared-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 5px; border: 1px solid var(--border); border-radius: 999px; font-weight: 600; font-size: .9rem; }

/* ---- Kalender ---- */
.calendar { padding: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-head { margin-bottom: 8px; }
.cal-dow { text-align: center; color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.cal-cell {
    min-height: 140px; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px; overflow: hidden; cursor: pointer;
}
.cal-cell[data-date]:hover { border-color: var(--accent); }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.cal-daynum { font-size: 1.05rem; color: var(--text); font-weight: 700; margin-bottom: 6px; }
.cal-event {
    display: flex; align-items: center; gap: 5px;
    background: var(--surface); border-left: 4px solid var(--accent);
    border-radius: 5px; padding: 5px 7px; margin-bottom: 5px; font-size: .9rem;
}
.cal-event.done .cal-ev-title { text-decoration: line-through; opacity: .55; }
.cal-ev-user { display: none; }
.cal-ev-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-actions { display: flex; gap: 2px; }
.cal-ev-actions form { margin: 0; }
.cal-ev-actions button {
    background: transparent; border: none; color: var(--muted); cursor: pointer;
    font-size: .8rem; line-height: 1; padding: 0 2px;
}
.cal-ev-actions button:hover { color: var(--text); }
.cal-ev-garmin { text-decoration: none; font-size: .8rem; }
.cal-ev-garmin:hover { text-decoration: none; }

@media (max-width: 767px) {
    /* Layout */
    .container, .container-wide { padding: 14px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .user-row { flex-direction: column; }
    .user-tile { flex: none; width: 100%; }

    /* Tabellen horizontal scrollbar */
    .table-wrap { -webkit-overflow-scrolling: touch; }

    /* Buttons grösser für Touch */
    .btn { padding: 12px 18px; font-size: 1rem; min-height: 44px; }
    .btn-sm { padding: 8px 14px; font-size: .9rem; min-height: 38px; }
    input, select, textarea { min-height: 44px; font-size: 1rem; }

    /* Formulare einspaltig */
    .for-users .athlete-picker { flex-direction: column; }
    .athlete-chip { width: 100%; }

    /* Kalender */
    .cal-grid { gap: 2px; }
    .cal-cell { min-height: 64px; padding: 3px; }
    .cal-daynum { font-size: .8rem; margin-bottom: 2px; }
    .cal-event { font-size: .65rem; padding: 2px 3px; }

    /* Chat */
    .chat-window { height: 55vh; }
    .msg { max-width: 88%; }

    /* Profile */
    .profile-head { flex-direction: column; text-align: center; }
    .avatar-input { flex-direction: column; align-items: flex-start; }

    /* Dashboard Kacheln */
    .tile-metrics { grid-template-columns: repeat(3, 1fr); gap: 6px 8px; }
    .tile-metrics .m-val { font-size: 1.25rem; }
    .tile-metrics .m-lbl { font-size: .72rem; }

    /* Rangliste responsiv: kleinere Schrift, Avatare, Wert darf umbrechen */
    .rank-row { gap: 8px; padding: 11px 6px; }
    .rank-pos { width: 24px; font-size: 1.05rem; }
    .rank-name { font-size: .95rem; }
    .rank-km { font-size: .9rem; white-space: normal; text-align: right; }
    .rank-row .avatar { width: 32px !important; height: 32px !important; }

    /* Überschriften kompakter */
    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.15rem; }
    .card h2 { font-size: 1.1rem; }

    /* Modal */
    .modal { padding: 16px; }

    /* Karte */
    .map { height: 260px; }
}

/* ---- Popup / Modal (Kalender-Detail) ---- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
    display: none; align-items: center; justify-content: center;
    z-index: 100; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); width: 100%; max-width: 480px;
    max-height: 85vh; overflow-y: auto; padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 1.25rem; }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 1.8rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-item {
    border-left: 4px solid var(--accent); background: var(--surface-2);
    border-radius: 6px; padding: 12px 14px; margin-bottom: 10px;
}
.modal-item:last-child { margin-bottom: 0; }
.modal-item.done .mi-title { text-decoration: line-through; opacity: .6; }
.modal-item .mi-title { font-weight: 700; font-size: 1.05rem; }
.modal-item .mi-meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.modal-item .mi-desc { margin-top: 6px; }
.modal-item .mi-link { margin-top: 8px; }

/* ---- Karte & Charts ---- */
.map { height: 380px; border-radius: 8px; overflow: hidden; }
.chart { width: 100%; display: block; margin-bottom: 16px; }
.chart-label { color: var(--muted); font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.bar { height: 10px; border-radius: 999px; min-width: 2px; }
