:root {
    --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Logo-Palette: #DCE5F5 (hell) → #7FA0E0 (mittel) → #2563EB (Kernblau) */
    --bg:          #F3F6FC;
    --surface:     #FFFFFF;
    --surface2:    #EAF0FB;
    --border:      #DDE6F7;
    --text:        #12172B;
    --muted:       #667088;

    --accent:      #2563EB;
    --accent-dark: #1D4ED8;
    --accent-mid:  #7FA0E0;
    --accent-pale: #DCE5F5;
    --accent-soft: #EAF0FB;

    --success:      #16A34A;
    --success-soft: #DCFCE7;
    --danger:       #DC2626;
    --danger-soft:  #FEE2E2;
    --warn:         #D97706;
    --warn-soft:    #FEF3C7;

    --radius-sm:   10px;
    --radius:      14px;
    --radius-lg:   20px;

    --nav-h:       64px;
    --header-h:    56px;

    --shadow:        0 1px 2px rgba(18,23,43,.05), 0 1px 1px rgba(18,23,43,.04);
    --shadow-md:     0 10px 24px -10px rgba(18,23,43,.16);
    --shadow-accent: 0 10px 22px -8px rgba(37,99,235,.4);

    /* Für Header/Bottom-Nav/Back-Header (backdrop-filter blur) — reine
       --surface-Deckkraft würde den Blur-Effekt verlieren, daher eigener
       halbtransparenter Token statt hartkodiertem rgba(255,255,255,…). */
    --surface-blur: rgba(255,255,255,.85);
    --surface-ring: rgba(255,255,255,.9);

    color-scheme: light;
}

/* ── Dark Mode ───────────────────────────────────────────────
   Greift automatisch nach System-Einstellung, oder manuell über
   [data-theme] (Umschalter im Profil, siehe js/theme.js). Fast die gesamte
   App ist bereits Token-getrieben, daher reicht dieser eine Block, um sie
   app-weit umzuschalten — Ausnahmen sind Media Detail und die Live-TV-
   Slideshow, die noch hartkodierte Dunkel-Werte statt Tokens verwenden. */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --bg:          #0B0F1A;
        --surface:     #121826;
        --surface2:    #1A2236;
        --border:      #232C42;
        --text:        #EDF1FB;
        --muted:       #8B93AC;

        --accent:      #5B8DEF;
        --accent-dark: #3B6FE0;
        --accent-mid:  #3E5488;
        --accent-pale: #1E2A47;
        --accent-soft: #16203A;

        --success:      #34D399;
        --success-soft: #0F2E22;
        --danger:       #F87171;
        --danger-soft:  #3B1717;
        --warn:         #FBBF24;
        --warn-soft:    #3A2E12;

        --shadow:        0 1px 2px rgba(0,0,0,.3), 0 1px 1px rgba(0,0,0,.24);
        --shadow-md:     0 14px 28px -12px rgba(0,0,0,.55);
        --shadow-accent: 0 10px 24px -8px rgba(91,141,239,.45);

        --surface-blur: rgba(18,24,38,.8);
        --surface-ring: rgba(18,24,38,.9);

        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg:          #0B0F1A;
    --surface:     #121826;
    --surface2:    #1A2236;
    --border:      #232C42;
    --text:        #EDF1FB;
    --muted:       #8B93AC;

    --accent:      #5B8DEF;
    --accent-dark: #3B6FE0;
    --accent-mid:  #3E5488;
    --accent-pale: #1E2A47;
    --accent-soft: #16203A;

    --success:      #34D399;
    --success-soft: #0F2E22;
    --danger:       #F87171;
    --danger-soft:  #3B1717;
    --warn:         #FBBF24;
    --warn-soft:    #3A2E12;

    --shadow:        0 1px 2px rgba(0,0,0,.3), 0 1px 1px rgba(0,0,0,.24);
    --shadow-md:     0 14px 28px -12px rgba(0,0,0,.55);
    --shadow-accent: 0 10px 24px -8px rgba(91,141,239,.45);

    --surface-blur: rgba(18,24,38,.8);
    --surface-ring: rgba(18,24,38,.9);

    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .login-title, .album-view-title { text-wrap: balance; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ── App Header ──────────────────────────────────────────── */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--surface-blur);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 100;
}
.app-header-logo {
    display: flex;
    align-items: center;
    gap: .45rem;
    background: none; border: none; padding: 0; margin: 0; font: inherit;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
/* Ohne das hier kann ein Tap auf dem <img> mobil als Bild-Geste (Safari-Callout zum
   Speichern/Kopieren) statt als Klick auf den umschließenden Button ankommen — der
   Tap-Bereich soll immer direkt beim <button> landen. */
.app-header-logo img, .app-header-logo span {
    pointer-events: none;
    -webkit-touch-callout: none;
}
/* Wordmark ist EIN Flex-Item (kein loser Text + <span> daneben) — sonst reißt
   der obige gap auch zwischen "memory" und "hub" auf. */
.app-header-wordmark {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--text);
}
.app-header-wordmark .logo-dot { color: var(--accent); font-weight: 700; }
.app-logo-icon { width: 26px; height: 26px; flex-shrink: 0; filter: drop-shadow(0 2px 5px rgba(37,99,235,.25)); }
.header-icon-btn {
    position: relative;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.header-icon-btn:hover { background: var(--accent-soft); }
.header-icon-btn svg { width: 21px; height: 21px; stroke: currentColor; fill: none; }
.header-icon-btn .badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 4px;
    min-width: 14px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface-ring);
}
.header-right {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-shrink: 0;
}
.header-profile-btn {
    display: flex;
    align-items: center;
    gap: .55rem;
    background: none;
    border: none;
    padding: 3px 3px 3px 8px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s;
}
.header-profile-btn:hover { background: var(--accent-soft); }
.header-profile-btn .nav-avatar { width: 30px; height: 30px; font-size: .82rem; flex-shrink: 0; }
.header-profile-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    max-width: 110px;
}
.header-profile-name {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-profile-plan {
    font-size: .7rem;
    font-weight: 600;
    color: var(--muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Navigation ──────────────────────────────────────────── */
.nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--surface-ring);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: 100;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    gap: 2px;
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color .15s;
    padding: 6px 4px;
    letter-spacing: .1px;
    border-radius: var(--radius-sm);
}
.nav-btn .icon {
    display: flex;
    width: 22px; height: 22px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transition: background .18s, transform .18s;
}
.nav-btn .icon svg { width: 20px; height: 20px; stroke: currentColor; }
.nav-btn.active { color: var(--accent-dark); }
.nav-btn.active .icon { background: var(--accent-pale); transform: translateY(-1px); }
.nav-avatar {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-mid), var(--accent-dark));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: .56rem;
}

/* ── Profile ─────────────────────────────────────────────── */
.profile-head {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 2.25rem 1.5rem 1.5rem;
}
.profile-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-mid), var(--accent-dark));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 1.4rem;
    box-shadow: 0 8px 20px -6px rgba(37,99,235,.5);
    margin-bottom: .8rem;
}
.profile-name  { font-weight: 800; font-size: 1.08rem; letter-spacing: -.2px; }
.profile-email { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.profile-row {
    display: flex; align-items: center; gap: .7rem;
    width: 100%;
    padding: .85rem 1rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background .12s;
}
.profile-row:last-child { border-bottom: none; }
.profile-row:hover { background: var(--accent-soft); }
.profile-row .icon-wrap {
    width: 20px; height: 20px;
    flex-shrink: 0;
    color: var(--accent);
    display: flex;
}
.profile-row .icon-wrap svg { width: 100%; height: 100%; stroke: currentColor; fill: none; }
.profile-row .chev { margin-left: auto; color: var(--muted); display: flex; }
.profile-row .chev svg { width: 17px; height: 17px; stroke: currentColor; fill: none; }

/* Segmented-Control, eigenständige Klasse statt der zweckentfremdeten
   .admin-tabs (die gehört semantisch in den Admin-Bereich, siehe dort). */
.theme-switch { display: flex; gap: 2px; }
.theme-switch button {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: .35rem;
    font: inherit; font-size: .82rem; font-weight: 700;
    border: none; background: none; color: var(--muted);
    padding: .55rem .5rem; border-radius: var(--radius-sm); cursor: pointer;
}
.theme-switch button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.theme-switch button.active { background: var(--accent-soft); color: var(--accent-dark); }
.profile-logout-btn { color: var(--danger); border-color: var(--danger); }
.profile-logout-btn:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ── Content area ────────────────────────────────────────── */
.content {
    flex: 1;
    padding-top: var(--header-h);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    overflow-y: auto;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.section-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: 1rem 1rem .5rem;
    color: var(--muted);
}

/* ── Plan-Kacheln (Profil → Dein Plan) ──────────────────────── */
.plan-tiles {
    display: flex;
    gap: .7rem;
    padding: 0 1rem 1.25rem;
    overflow-x: auto;
    scroll-snap-type: x proximate;
}
.plan-tile {
    flex: 0 0 auto;
    width: 200px;
    scroll-snap-align: start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .9rem .9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.plan-tile.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.plan-tile-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--muted);
}
.plan-tile.active .plan-tile-label { color: var(--accent-dark); }
.plan-tile-price {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
}
.plan-tile-price small { font-size: .68rem; font-weight: 600; color: var(--muted); }
.plan-tile-meta {
    font-size: .76rem;
    color: var(--muted);
    line-height: 1.5;
    flex: 1;
}
.plan-tile-usage {
    font-size: .74rem;
    color: var(--text);
    line-height: 1.5;
    background: var(--surface2);
    border-radius: var(--radius-sm);
    padding: .5rem .6rem;
}
.plan-tile-switch {
    margin-top: auto;
}

/* ── Guthaben-basierte Speicheranzeige (Familien-Archiv, siehe profile.js) ──── */
.storage-status {
    margin: -.5rem 1rem 1.25rem;
    padding: .8rem .9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.storage-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--surface2);
    overflow: hidden;
    margin-bottom: .5rem;
}
.storage-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width .25s ease;
}
.storage-bar-fill.over { background: var(--danger); }
.storage-status-line {
    font-size: .78rem;
    color: var(--muted);
    line-height: 1.6;
}
.storage-status-overage { color: var(--text); font-weight: 600; }
.text-danger { color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .65rem 1.2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .1s, box-shadow .15s, opacity .1s, background .15s;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: .1px;
}
.btn:active { transform: scale(.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-accent);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #C31C1C; }
.btn-ghost   { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent-mid); color: var(--accent-dark); }
.btn-sm      { padding: .4rem .85rem; font-size: .8rem; }
.btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; flex-shrink: 0; }

/* ── Album Grid ──────────────────────────────────────────── */
.album-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 14px;
}
@media (min-width: 480px) { .album-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 720px) { .album-grid { grid-template-columns: repeat(4, 1fr); } }

.album-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    cursor: pointer;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: box-shadow .2s, transform .2s;
}
.album-card:hover  { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.album-card:active { opacity: .9; transform: translateY(0); }

.album-thumb {
    aspect-ratio: 4 / 3;
    position: relative;
    overflow: hidden;
    background: var(--surface2);
}
.album-thumb .cover {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}
.album-card:hover .cover { transform: scale(1.04); }
.album-thumb .cover-placeholder {
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-pale), var(--surface2));
    color: var(--accent-mid);
}
.album-thumb .cover-placeholder::after {
    content: '';
    width: 32px; height: 32px;
    border: 2px solid currentColor;
    border-radius: 8px;
    position: relative;
}
.album-thumb .cover-placeholder::before {
    content: '';
    width: 12px; height: 10px;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: absolute;
    opacity: .7;
}
.album-info { padding: .65rem .8rem .75rem; }
.album-info h3 {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: .15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.1px;
}
.album-info small { font-size: .75rem; color: var(--muted); }
.album-stats {
    display: flex;
    gap: .6rem;
    margin-top: .3rem;
}
.album-stat {
    font-size: .72rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.album-stat svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }

/* ── Media Grid ──────────────────────────────────────────── */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}
@media (min-width: 480px) { .media-grid { grid-template-columns: repeat(4, 1fr); } }
.media-grid-sentinel { height: 1px; }

/* ── Album-Ansicht: nach Ereignis (Datum + Ort) gruppiert ─── */
.event-group + .event-group { margin-top: .4rem; }
.event-group-header {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .9rem 1rem .45rem;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
}
.event-group:first-child .event-group-header { padding-top: .4rem; }
.event-group-header svg {
    width: 15px; height: 15px;
    stroke: var(--accent-dark); fill: none;
    flex-shrink: 0;
}
.event-group-header span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.event-group-header small {
    margin-left: auto;
    font-size: .75rem;
    font-weight: 700;
    color: var(--muted);
}
.event-group-header.muted { color: var(--muted); }
.event-group-header.muted svg { stroke: var(--muted); }

/* Kleiner "Verschieben"-Stift auf jeder Kachel */
.tile-move-btn {
    position: absolute;
    top: 4px; right: 4px;
    display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; padding: 0;
    border: none; border-radius: 6px;
    background: rgba(0, 0, 0, .45);
    color: #fff; cursor: pointer;
    opacity: 0; transition: opacity .12s;
}
.media-thumb:hover .tile-move-btn,
.tile-move-btn:focus-visible { opacity: 1; }
@media (hover: none) { .tile-move-btn { opacity: .85; } }
.tile-move-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }

/* "Verschieben"-Panel: Ereignisliste zur Auswahl */
.move-opt-list { display: flex; flex-direction: column; gap: 2px; max-height: 45vh; overflow-y: auto; }
.move-opt {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .6rem; border-radius: 8px; cursor: pointer;
    font-size: .85rem;
}
.move-opt:hover { background: var(--surface2); }
.move-opt span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-opt small { color: var(--muted); font-weight: 700; }
/* Vorschau-Grid in "Meine Listen" — immer 4 Spalten, unabhängig von .media-grid */
.col-media { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }

.media-thumb {
    aspect-ratio: 1;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: var(--surface2);
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.media-thumb:active img { transform: scale(.97); }
.media-thumb .video-badge {
    position: absolute;
    bottom: 5px; right: 5px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    letter-spacing: .3px;
}
/* Zentrierter Icon-Platzhalter für fehlende Vorschaubilder — genutzt in
   .media-thumb, .queue-thumb und .col-media (Meine Listen). */
.no-thumb {
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-mid);
    background: var(--surface2);
}
.no-thumb svg { width: 28px; height: 28px; stroke: currentColor; fill: none; }
.queue-thumb .no-thumb svg { width: 20px; height: 20px; }
/* Frisch hochgeladen, Server verarbeitet noch im Hintergrund (siehe album.js-Polling) —
   dezentes Pulsieren statt eines starren Platzhalters, damit klar ist: kommt noch, nicht kaputt. */
@keyframes thumb-pending-pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
.no-thumb.pending { animation: thumb-pending-pulse 1.6s ease-in-out infinite; }

/* ── Upload Zone ─────────────────────────────────────────── */
.upload-zone {
    margin: 14px;
    border: 1.5px dashed var(--accent-mid);
    border-radius: var(--radius);
    padding: 1.6rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .12s, background .12s;
    background: var(--surface);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.upload-zone .upload-icon {
    font-size: 1.4rem;
    color: var(--accent);
    margin-bottom: .35rem;
    line-height: 1;
}
.upload-zone div { font-weight: 700; font-size: .9rem; color: var(--text); }
.upload-zone p { color: var(--muted); font-size: .8rem; margin-top: .2rem; }

/* ── Media Detail ────────────────────────────────────────── */
.media-detail {
    position: fixed; inset: 0;
    background: #0a0a0a;
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.media-detail .detail-header {
    /* War früher position:absolute über dem Medium (wie der Footer vor seinem Fix,
       siehe Kommentar bei .detail-footer) — das Medium wurde dann über die volle
       detail-body-Höhe zentriert und sein oberer Teil lag hinter dieser Kopfzeile
       verdeckt (bei hohen Hoch-Formaten/Videos wirkte das wie abgeschnitten). Jetzt
       bekommt der Header wie der Footer echten Platz im Flex-Layout, das Medium
       schrumpft sich per object-fit:contain im verbleibenden Raum ein. */
    flex: 0 0 auto;
    padding: env(safe-area-inset-top, 12px) 12px 12px;
    background: #111214;
    display: flex; align-items: center; gap: 8px;
    z-index: 10;
    /* Titel/Datum/Uploader-Zeile hatten bisher keine eigene Textfarbe und erbten die
       Theme-Textfarbe (im hellen Theme dunkel) — auf dem dunklen Verlaufs-Hintergrund
       kaum lesbar. Bewusst fest weiß, unabhängig vom App-Theme (wie .detail-icon-btn
       daneben), da dieser Viewer immer dunkel bleibt. */
    color: #fff;
}
.media-detail .detail-body {
    position: relative;
    flex: 1 1 auto; min-height: 0;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.media-detail .detail-body img,
.media-detail .detail-body video {
    max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
}
/* Eigener Bereich statt Overlay über dem Medium: bei Videos lag hier vorher die
   Kommentar-/Reaktions-Leiste als absolut positionierter Scrim direkt über der
   nativen Abspiel-HUD des <video>-Elements (Play/Pause, Zeitleiste) — die HUD sitzt
   immer am unteren Rand der Video-Box, und die Box füllte den ganzen Bildschirm.
   Jetzt bekommt der Footer echten Platz im Flex-Layout, das Medium schrumpft sich
   entsprechend (object-fit: contain) darüber ein statt vom Footer verdeckt zu werden. */
.media-detail .detail-footer {
    flex: 0 0 auto;
    display: flex; flex-direction: column;
    min-height: 0;
    max-height: min(40vh, 360px);
    background: #111214;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,.35);
    padding: 2px 14px calc(8px + env(safe-area-inset-bottom));
}
/* Standard ist eingeklappt (siehe media-detail.js _footerCollapsed = true) — nur dieser
   schmale Balken mit Pfeil ist sichtbar, Klick klappt Filmstreifen/Statuszeile/Kommentare
   aus (Zustand bleibt beim Weiterblättern erhalten). Pfeil zeigt nach oben ("mehr
   anzeigen") und dreht beim Ausklappen nach unten ("einklappen"). */
.detail-footer-handle {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 22px;
    background: none; border: none; cursor: pointer;
    flex-shrink: 0;
    color: rgba(255,255,255,.5);
    transition: color .15s;
}
.detail-footer-handle svg {
    width: 18px; height: 18px; stroke: currentColor; fill: none;
    transform: rotate(180deg);
    transition: transform .2s;
}
.detail-footer-handle.expanded svg { transform: rotate(0deg); }
.detail-footer-handle:hover,
.detail-footer-handle:active { color: rgba(255,255,255,.85); }
.detail-footer.collapsed .detail-stats-row,
.detail-footer.collapsed .detail-footer-top,
.detail-footer.collapsed .comment-section {
    display: none;
}
.detail-footer.collapsed { padding-bottom: calc(2px + env(safe-area-inset-bottom)); }
.detail-footer-top { flex: 0 0 auto; }
.comment-section {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column;
    margin-top: 4px;
}
/* Immer weiß-auf-dunkel — unabhängig vom App-Theme, da dieser Viewer
   bewusst dauerhaft dunkel bleibt (wie ein Kamera-Rollen-Viewer). */
.detail-icon-btn {
    background: none; border: none; color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    transition: background .15s;
}
.detail-icon-btn:hover { background: rgba(255,255,255,.12); }
.detail-icon-btn svg { width: 21px; height: 21px; stroke: currentColor; fill: none; }
#del-btn.detail-icon-btn { color: #F87171; }
#cover-btn.detail-icon-btn.active { color: #FBBF24; }
#cover-btn.detail-icon-btn.active svg path { fill: currentColor; }
.detail-nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,.5); border: none; color: #fff; cursor: pointer;
    width: 40px; height: 40px; border-radius: 50%; z-index: 20;
    display: flex; align-items: center; justify-content: center;
}
.detail-nav-btn:hover { background: rgba(0,0,0,.7); }
.detail-nav-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; }
#prev-btn.detail-nav-btn { left: 8px; }
#next-btn.detail-nav-btn { right: 8px; }
.detail-location {
    display: inline-flex; align-items: center; gap: .3rem;
    color: rgba(255,255,255,.6); text-decoration: none;
}
.detail-location svg { width: 14px; height: 14px; stroke: currentColor; fill: none; flex-shrink: 0; }
.detail-place-edit {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; padding: 0;
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.45); border-radius: 6px;
}
.detail-place-edit:hover { color: rgba(255,255,255,.8); background: rgba(255,255,255,.08); }
.detail-place-edit svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
.detail-date { display: inline-flex; align-items: center; gap: .25rem; vertical-align: -1px; }
.detail-date svg { width: 12px; height: 12px; stroke: currentColor; fill: none; flex-shrink: 0; }

/* ── "Entdecken": zeigt, aus welchem Album der Zufallstreffer stammt ── */
.detail-album-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    margin-top: 3px;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    font-size: .68rem; font-weight: 600;
    color: rgba(255,255,255,.85);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.detail-album-badge svg { width: 12px; height: 12px; stroke: currentColor; fill: none; flex-shrink: 0; }

/* ── Video: großer Play-Button statt kleinem nativen Button ── */
.detail-video-wrap {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    max-width: 100%; max-height: 100%;
}
.detail-video-wrap video { display: block; }
.detail-play-overlay {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 72px; height: 72px; border-radius: 50%;
    background: rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.85);
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity .15s, transform .15s;
}
.detail-play-overlay:active { transform: translate(-50%, -50%) scale(.94); }
.detail-play-overlay svg { width: 30px; height: 30px; margin-left: 4px; }
.detail-play-overlay.hidden { opacity: 0; pointer-events: none; }

/* ── Statuszeile: Views/Reaktionen/Kommentare kompakt ───────── */
.detail-stats-row {
    display: flex; align-items: center; gap: 14px;
    padding: 0 0 4px;
    flex-shrink: 0;
}
.detail-stat {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .82rem; font-weight: 600;
    color: rgba(255,255,255,.85);
}
.detail-stat-icon { display: inline-flex; }
.detail-stat-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
button.detail-stat-btn {
    background: none; border: none; cursor: pointer; padding: 4px 2px;
    color: rgba(255,255,255,.85);
}

/* Emoji-Leiste ist standardmäßig eingeklappt — die Statuszeile oben zeigt die Summe schon
   kompakt an, die volle Auswahl (6 Emojis) muss man nicht permanent sehen (Tap auf die
   Herz-Zahl klappt sie auf). */
.emoji-bar-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .18s ease;
}
.emoji-bar-wrap.expanded { grid-template-rows: 1fr; }
.emoji-bar-wrap > .reaction-bar { overflow: hidden; min-height: 0; margin: 0; }
.emoji-bar-wrap.expanded > .reaction-bar { margin: .3rem 0; }

/* ── Diashow ─────────────────────────────────────────────────
   Ein Fortschrittsbalken pro aktuellem Medium (nicht ein Segment pro Album-Eintrag —
   bei 150+ Medien wären das nur noch unlesbare Striche). Läuft im detail-body, damit er
   auch während der Diashow (Footer ausgeblendet) sichtbar bleibt. */
.detail-slideshow-progress {
    display: none;
    position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px;
    height: 3px; border-radius: 2px;
    background: rgba(255,255,255,.25);
    z-index: 15; overflow: hidden;
}
.media-detail.slideshow-mode .detail-slideshow-progress { display: block; }
.media-detail.slideshow-mode .detail-footer { display: none; }
.detail-slideshow-progress-fill { height: 100%; width: 0%; background: #fff; }

/* ── Slideshow-Freigabe-Warteschlange (Album-Einstellungen) ─────────── */
.queue-row {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}
.queue-row:last-child { border-bottom: none; }
.queue-thumb {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    overflow: hidden; flex-shrink: 0; background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
}
.queue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-info { flex: 1; min-width: 0; }

/* ── Live-TV-Slideshow (Präsentationsmodus, #present/{albumId}) ────── */
.slideshow-stage {
    position: fixed; inset: 0;
    background: #000;
    overflow: hidden;
}
.slideshow-frame {
    position: absolute; inset: 0;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1.4s ease;
}
.slideshow-frame.visible { opacity: 1; }
.slideshow-caption {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 2.5rem 2rem 3rem;
    background: linear-gradient(transparent, rgba(0,0,0,.75));
    color: rgba(255,255,255,.92);
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: .2px;
    min-height: 20px;
}
.slideshow-empty {
    position: absolute; inset: 0;
    display: none;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 1rem;
    text-align: center;
    padding: 2rem;
}
.slideshow-empty.visible { display: flex; }
.slideshow-logo { font-size: 1.9rem; font-weight: 800; color: rgba(255,255,255,.92); }
.slideshow-logo span { color: var(--accent-mid); }
.slideshow-empty p { font-size: 1rem; color: rgba(255,255,255,.5); }

.slideshow-exit {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 20;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.4);
    color: rgba(255,255,255,.75);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.slideshow-exit:hover,
.slideshow-exit:focus-visible { background: rgba(0,0,0,.65); color: #fff; }
.slideshow-exit svg { width: 19px; height: 19px; stroke: currentColor; fill: none; }

/* ── Reactions ───────────────────────────────────────────── */
.reaction-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: .5rem 0; }
.reaction-btn {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    padding: 4px 11px;
    font-size: .85rem;
    cursor: pointer;
    color: #fff;
    display: flex; align-items: center; gap: 4px;
    transition: background .12s;
}
.reaction-btn.mine  { background: rgba(37,99,235,.55); border-color: rgba(37,99,235,.75); }
.reaction-btn:active{ opacity: .8; }

/* ── Slide-up Panel ──────────────────────────────────────── */
.panel-overlay {
    position: fixed; inset: 0;
    background: rgba(18,23,43,.4);
    backdrop-filter: blur(2px);
    z-index: 300;
    display: flex; align-items: flex-end;
}
.panel {
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-height: 82dvh;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    box-shadow: 0 -12px 30px -10px rgba(18,23,43,.2);
}
.panel-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 999px;
    margin: 0 auto 1rem;
}

/* ── Age Entry ───────────────────────────────────────────── */
.age-entry { display: flex; align-items: center; gap: 12px; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.age-entry:last-child { border-bottom: none; }
.age-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-mid);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden;
    border: 1px solid var(--border);
}
.age-avatar img { width: 100%; height: 100%; object-fit: cover; }
.age-avatar svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }

/* ── Comments ────────────────────────────────────────────── */
.comment-list {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column; gap: 8px; margin: 0 0 8px;
}
.comment-item { background: rgba(255,255,255,.08); border-radius: 10px; padding: .5rem .7rem; }
.comment-author { font-size: .73rem; color: #93C5FD; font-weight: 600; margin-bottom: 2px; }
.comment-text  { font-size: .88rem; color: rgba(255,255,255,.88); }
.comment-time  { font-size: .68rem; color: rgba(255,255,255,.35); margin-top: 2px; }
.comment-input-row { flex: 0 0 auto; display: flex; gap: 8px; }
.comment-input {
    flex: 1;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 999px;
    padding: .55rem .9rem;
    color: #fff;
    font-size: .88rem;
}
.comment-input::placeholder { color: rgba(255,255,255,.3); }

/* ── Form Elements ───────────────────────────────────────── */
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; letter-spacing: .1px; }
.input {
    width: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .65rem .9rem;
    color: var(--text);
    font-size: .95rem;
    transition: border-color .12s, box-shadow .12s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23667088' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .9rem center; padding-right: 2.1rem; }

/* ── Upload Progress ─────────────────────────────────────── */
.upload-progress-track {
    height: 6px;
    background: var(--surface2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-mid), var(--accent));
    border-radius: 999px;
    transition: width .15s ease;
}

/* ── Notifications ───────────────────────────────────────────
   Jedes Album ist eine eigene Karte (Rand+Schatten wie album-card/memories-today), damit man
   die Gruppierung auf den ersten Blick sieht, statt einer durchgehenden flachen Liste mit
   lauter gleich aussehenden Trennlinien. Innerhalb der Karte trennen nur die Art-Abschnitte
   (Kommentare/Reaktionen/...) mit einer Linie — einzelne Einträge derselben Art bekommen
   keine eigene Linie mehr, das wirkte bei mehreren Einträgen schnell wie Bahnschienen. */
.notif-group {
    margin: 12px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.notif-group-header {
    display: flex; align-items: center; gap: 8px;
    padding: .7rem 1rem;
    font-size: .88rem; font-weight: 700;
    color: var(--text);
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.notif-group-header .notif-group-icon {
    flex-shrink: 0;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center;
}
.notif-group-header svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }

.notif-type-section { padding: .3rem 0; }
.notif-type-section:not(:last-child) { border-bottom: 1px solid var(--border); }
.notif-type-label {
    padding: .4rem 1rem .2rem;
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px;
    color: var(--muted);
}

.notif-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: .5rem 1rem;
    cursor: pointer;
    transition: background .1s;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: var(--accent-soft); }
.notif-icon {
    flex-shrink: 0; margin-top: 1px;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-dark);
    display: flex; align-items: center; justify-content: center;
}
.notif-icon svg { width: 17px; height: 17px; stroke: currentColor; fill: none; }
.notif-thumb {
    position: relative;
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface2);
}
.notif-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.notif-thumb-badge {
    position: absolute; bottom: -3px; right: -3px;
    width: 19px; height: 19px; border-radius: 50%;
    background: var(--accent); color: #fff;
    border: 2px solid var(--surface);
    display: flex; align-items: center; justify-content: center;
}
.notif-thumb-badge svg { width: 10px; height: 10px; stroke: currentColor; fill: none; }
.notif-body { flex: 1; min-width: 0; padding-top: 2px; }
.notif-text { font-size: .87rem; color: var(--text); }
.notif-time { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.notif-preview { color: var(--text); font-style: italic; }

.notif-group.ungrouped .notif-group-header { background: var(--surface); border-bottom: 1px solid var(--border); }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: calc(var(--header-h) + .6rem);
    left: 50%; transform: translateX(-50%);
    z-index: 9999;
    display: flex; flex-direction: column; gap: 6px;
    pointer-events: none;
    max-width: calc(100vw - 2rem);
}
.toast {
    background: var(--text);
    color: #fff;
    border-radius: var(--radius);
    padding: .6rem 1.1rem;
    font-size: .85rem;
    font-weight: 500;
    display: flex; align-items: center; gap: .45rem;
    animation: slide-in .18s ease;
    pointer-events: all;
    max-width: min(85vw, 380px);
    box-shadow: var(--shadow-md);
}
.toast.ok   { background: #14532D; }
.toast.err  { background: #7F1D1D; }
.toast.warn { background: #78350F; }

@keyframes slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(560px 420px at 12% -8%, var(--accent-pale) 0%, transparent 60%),
        radial-gradient(640px 480px at 108% 108%, var(--accent-pale) 0%, transparent 55%),
        var(--bg);
}
.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.1rem 1.85rem;
    box-shadow: var(--shadow-md);
}
.login-lockup {
    display: flex; align-items: center; gap: .6rem;
    margin-bottom: 1.1rem;
}
.login-lockup-sm { margin-bottom: .6rem; }
.login-logo { width: 40px; height: 40px; flex-shrink: 0; filter: drop-shadow(0 3px 8px rgba(37,99,235,.3)); }
.login-lockup-sm .login-logo { width: 30px; height: 30px; }
.login-wordmark {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--text);
}
.login-lockup-sm .login-wordmark { font-size: 1.1rem; }
.login-wordmark .logo-dot { color: var(--accent); font-weight: 700; }
.login-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -.4px;
    margin-bottom: .2rem;
    text-align: left;
}
.login-sub { color: var(--muted); font-size: .88rem; margin-bottom: 1.5rem; text-align: left; }
.login-divider {
    display: flex; align-items: center; gap: .6rem;
    margin: .9rem 0;
    color: var(--muted); font-size: .78rem;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3.75rem 1.75rem;
}
.empty-state-icon {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-pale), var(--accent-soft));
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1rem;
}
.empty-state-icon svg { width: 28px; height: 28px; stroke: currentColor; fill: none; }
.empty-state-title { font-weight: 700; font-size: .98rem; color: var(--text); }
.empty-state-sub { font-size: .85rem; color: var(--muted); max-width: 30ch; line-height: 1.55; margin-top: .35rem; }

/* ── Loading ─────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 22px; height: 22px;
    border: 2.5px solid var(--accent-pale);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 4rem 2rem; }

/* ── Admin ───────────────────────────────────────────────── */
/* Tab-Leiste — generisch, wird u.a. von admin.js UND album-settings.js
   genutzt (vorher missbrauchte album-settings.js dafür die admin-tabs-Klasse). */
.tabbar {
    display: flex; gap: .2rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    overflow-x: auto;
    scrollbar-width: none;
    padding: .4rem .5rem 0;
}
.tab-btn {
    padding: .65rem 1rem;
    border: none;
    border-radius: 999px 999px 0 0;
    background: none;
    color: var(--muted);
    font-size: .83rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: color .12s, background .12s;
}
.tab-btn.active { color: var(--accent-dark); background: var(--accent-soft); }

.data-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.data-table th {
    padding: .55rem .75rem;
    text-align: left;
    color: var(--muted);
    font-weight: 700;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}
.data-table td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--accent-soft); }

/* ── Status badges ───────────────────────────────────────── */
.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .2px;
}
.badge-active   { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--danger-soft); color: var(--danger); }
.badge-role     { background: var(--surface2); color: var(--muted); }
.badge-admin    { background: var(--accent-pale); color: var(--accent-dark); }
.badge-guest    { background: var(--surface2); color: var(--muted); }

/* ── "An diesem Tag" ──────────────────────────────────────── */
.memories-today {
    margin: 14px 14px 4px;
    padding: .9rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 140%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.memories-today h3 {
    font-size: .72rem;
    color: var(--muted);
    margin-bottom: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
}
/* ── "Rätsel des Tages" (Archiv-Nostalgie-Spiel) ────────────── */
.riddle-thumb {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 16 / 9;
    background: var(--surface2);
}
.riddle-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.riddle-badge {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: linear-gradient(transparent, rgba(0,0,0,.7));
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.4;
    padding: 24px 10px 10px;
}
/* Ohne Deckelung würde .riddle-thumb (aspect-ratio 16/9) auf breiten Bildschirmen die
   komplette Zeilenbreite ausfüllen — das Bild (s.o. per <picture> zwar schon in höherer
   Auflösung geladen) wirkt dadurch trotzdem unangenehm groß. Auf Desktop bewusst kleiner
   und nicht die volle Breite. */
@media (min-width: 720px) {
    .riddle-card { max-width: 640px; }
}

/* ── Foto-Challenge / Bingo — bewusst wärmer/spielerischer als der Rest der App ── */
.game-section {
    margin: 14px 14px 4px;
    padding: .9rem;
    background: var(--surface);
    border: 1.5px solid var(--warn);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.game-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .75rem;
}
.game-title { font-weight: 800; font-size: .92rem; color: var(--text); }
.game-progress {
    font-size: .74rem;
    font-weight: 800;
    color: var(--warn);
    background: var(--warn-soft);
    padding: .2rem .65rem;
    border-radius: 999px;
}
.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
@media (min-width: 480px) { .game-grid { grid-template-columns: repeat(4, 1fr); } }
.game-tile {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--warn-soft);
    border: 1.5px dashed var(--accent-mid);
    display: flex; align-items: center; justify-content: center;
}
.game-tile.done { border-style: solid; border-color: var(--warn); }
.game-tile-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.game-tile-label {
    position: relative; z-index: 1;
    font-size: .66rem; font-weight: 700; text-align: center;
    padding: 6px; line-height: 1.25; color: var(--text);
}
.game-tile.done .game-tile-label {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
    background: linear-gradient(transparent, rgba(0,0,0,.68));
    color: #fff;
    padding: 12px 5px 4px;
}
.game-tile-check {
    position: absolute; top: 4px; right: 4px; z-index: 3;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    display: none; align-items: center; justify-content: center;
}
.game-tile-check svg { width: 11px; height: 11px; stroke: currentColor; fill: none; }
.game-tile.done .game-tile-check { display: flex; }

.game-tag-picker {
    margin: 0 12px 8px;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.game-tag-picker label { font-size: .8rem; font-weight: 700; color: var(--warn); flex-shrink: 0; }
.game-tag-picker select { flex: 1; min-width: 160px; }

/* ── Back header ─────────────────────────────────────────── */
.back-header {
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem 1rem;
    background: var(--surface-blur);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.back-btn {
    background: none; border: none;
    color: var(--accent);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 0;
    display: flex; align-items: center; gap: .25rem;
}

/* ── Album header row ────────────────────────────────────── */
.album-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: .9rem 1rem;
}
.album-header-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.album-view-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.2px;
    line-height: 1.3;
}

/* ── Premium-Branding (Gäste-Ansicht) ───────────────────────── */
.album-branding-header { position: relative; }
.branding-header-image {
    width: 100%; max-height: 160px; object-fit: cover; display: block;
}
.branding-logo {
    width: 40px; height: 40px; object-fit: contain; border-radius: 10px;
    background: var(--surface);
    position: absolute; left: 1rem; bottom: -18px;
    box-shadow: var(--shadow-md);
}
.album-welcome-text {
    margin: .9rem 1rem; padding: .8rem .9rem;
    background: var(--surface2); border-radius: var(--radius);
    font-size: .88rem; line-height: 1.5; color: var(--text);
}
.album-expired-banner {
    margin: 0 1rem .9rem; padding: .7rem .9rem;
    background: var(--warn-soft); color: var(--warn); border-radius: var(--radius);
    font-size: .83rem; line-height: 1.45;
}
.pending-summary {
    margin: 0 1rem .9rem; padding: .55rem .9rem;
    background: var(--surface2); border-radius: var(--radius);
    font-size: .83rem; color: var(--muted);
}
.pending-summary summary {
    cursor: pointer; list-style: none; user-select: none;
}
.pending-summary summary::-webkit-details-marker { display: none; }
.pending-summary summary::after { content: " ▾"; }
.pending-summary[open] summary::after { content: " ▴"; }
.pending-summary-body { margin-top: .5rem; }
.pending-summary-row {
    padding: .2rem 0; font-size: .82rem; line-height: 1.4;
}
.pending-summary-failed { color: var(--warn); }
.sg-page { max-width: 640px; margin: 0 auto; width: 100%; }
.sg-card { margin: 0 1rem 1rem; overflow: hidden; }
.sg-summary {
    display: flex; align-items: center; gap: .5rem;
    padding: 1rem; cursor: pointer; list-style: none; user-select: none;
}
.sg-summary::-webkit-details-marker { display: none; }
.sg-summary::after {
    content: ""; width: 9px; height: 9px; flex-shrink: 0; margin-left: .4rem;
    border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted);
    transform: rotate(45deg); transition: transform .15s;
}
.sg-card[open] .sg-summary::after { transform: rotate(-135deg); }
.sg-summary-name { font-weight: 700; flex: 1; }
.sg-card-body { padding: 0 1rem 1rem; }
.sg-year-group + .sg-year-group { margin-top: .3rem; }
.sg-year-label {
    font-weight: 700; font-size: .78rem; color: var(--accent-dark);
    letter-spacing: .3px; padding: .5rem 0 .15rem;
    border-top: 1px solid var(--border);
}
.sg-year-group:first-child .sg-year-label { border-top: none; padding-top: 0; }
.sg-album-row { border-bottom: 1px solid var(--border); }
.sg-album-row:last-child { border-bottom: none; }

/* ── Zugriffsstatistik (access-stats.js) ─────────────────── */
.as-link-row {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .8rem 1rem; border-bottom: 1px solid var(--border);
}
.as-link-row:last-child { border-bottom: none; }
.as-viewer-list { display: flex; flex-direction: column; gap: 0; }
.as-viewer-row {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .3rem 0; font-size: .85rem; border-bottom: 1px solid var(--border);
}
.as-viewer-row:last-child { border-bottom: none; }
.as-media-item { border-bottom: 1px solid var(--border); }
.as-media-item:last-child { border-bottom: none; }
.as-media-summary {
    display: flex; align-items: center; gap: .5rem;
    padding: .55rem 0; cursor: pointer; list-style: none; user-select: none;
}
.as-media-summary::-webkit-details-marker { display: none; }
.as-media-summary::after {
    content: ""; width: 7px; height: 7px; flex-shrink: 0; margin-left: .2rem;
    border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
    transform: rotate(45deg); transition: transform .15s;
}
.as-media-item[open] .as-media-summary::after { transform: rotate(-135deg); }
.as-media-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.powered-by-memoryhub {
    text-align: center; font-size: .72rem; color: var(--muted);
    padding: 1.5rem 0 2rem; letter-spacing: .02em;
}
.powered-by-memoryhub a {
    color: var(--accent-mid); font-weight: 600; text-decoration: none;
}
.powered-by-memoryhub a:hover { text-decoration: underline; }
/* Bezahlte/Archiv-Pläne blenden "powered by memoryhub" aus — der Hinweis fürs eigene
   Album bleibt trotzdem da, aber bewusst kleiner/unauffälliger als bei kostenlosen Events. */
.own-album-hint-subtle {
    text-align: center; font-size: .68rem; padding: 1rem 0 1.75rem;
}
.own-album-hint-subtle a { color: var(--muted); text-decoration: underline; }
.own-album-hint-subtle a:hover { color: var(--accent-mid); }
.premium-upsell {
    background: var(--surface2); border-radius: var(--radius); padding: .8rem .9rem;
}

/* ── Timeline ────────────────────────────────────────────── */
.timeline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .9rem 1rem .5rem;
}
.timeline-greeting {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.2px;
}
.timeline-greeting small {
    display: block;
    font-size: .78rem;
    font-weight: 500;
    color: var(--muted);
    margin-top: 1px;
}
.timeline-group { padding-bottom: .5rem; }
.timeline-year-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
    padding: .9rem 1rem .4rem;
    border-top: 1px solid var(--border);
}
.timeline-group:first-child .timeline-year-label { border-top: none; padding-top: .6rem; }
.timeline-group .album-grid { padding-top: 0; }

/* ── Zeitleiste/Anlässe-Umschalter (nur Familien-Archiv) ─── */
.view-toggle {
    display: flex;
    gap: .3rem;
    margin: 0 1rem .6rem;
    background: var(--surface2);
    border-radius: 999px;
    padding: 3px;
}
.view-toggle-btn {
    flex: 1;
    padding: .5rem .8rem;
    border: none;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: color .12s, background .12s;
}
.view-toggle-btn.active { color: var(--accent-dark); background: var(--surface); box-shadow: var(--shadow); }

.occasion-tab small {
    margin-left: .35rem;
    font-weight: 700;
    color: var(--muted);
}
.occasion-tab.active small { color: var(--accent-dark); }
#occasion-tabs { margin: 0 0 .5rem; }

/* ── Fokus-Album ─────────────────────────────────────────── */
.featured-album {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin: 14px 14px 4px;
    padding: .7rem .9rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--accent-pale) 140%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow .2s, transform .2s;
}
.featured-album:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.featured-thumb {
    width: 64px; height: 64px;
    border-radius: calc(var(--radius) - 4px);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--surface2);
}
.featured-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.featured-info small {
    display: block;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--accent-dark);
    margin-bottom: 2px;
}
.featured-info h3 { font-size: .95rem; font-weight: 700; }

/* ── Share Panel ─────────────────────────────────────────── */
.share-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.share-panel-title {
    padding: .5rem .8rem;
    font-size: .7rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.share-row {
    padding: .55rem .8rem;
    border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
}
.share-row:last-child { border-bottom: none; }
.share-row-label { font-size: .83rem; font-weight: 600; color: var(--text); min-width: 130px; }
.share-row-url { flex: 1; font-size: .7rem; color: var(--muted); word-break: break-all; line-height: 1.4; min-width: 0; }
.share-row-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }

/* ── Utilities ───────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.p-3 { padding: .75rem; }
.p-4 { padding: 1rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: .83rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }
