/* Pegel - Mobile-first Dark Mode PWA Styles */

:root {
    --bg: #0f172a;
    --bg2: #1e293b;
    --bg3: #334155;
    --text: #f1f5f9;
    --text2: #94a3b8;
    --text3: #64748b;
    --accent: #3b82f6;
    --accent2: #2563eb;
    --border: #334155;
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;
    --darkred: #991b1b;
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
    --bg: #f8fafc;
    --bg2: #ffffff;
    --bg3: #e2e8f0;
    --text: #0f172a;
    --text2: #475569;
    --text3: #94a3b8;
    --border: #e2e8f0;
}

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

html {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(56px + var(--safe-bottom));
    /* Verhindert auf iOS, dass die Adressleiste die Viewport-Höhe ändert */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#app {
    min-height: calc(100vh - 56px - var(--safe-bottom));
    min-height: calc(100dvh - 56px - var(--safe-bottom));
    display: flex;
    flex-direction: column;
}

/* Versteckt App-Inhalt bis init() + route() fertig (verhindert Login-Flash bei Reload/bfcache) */
body.app-boot #app,
body.app-boot .app-menu,
body.app-boot .pull-refresh-indicator {
    visibility: hidden;
}
/* Tab-Bar: mit opacity verstecken, nicht visibility – bleibt so von Anfang an korrekt am unteren Rand positioniert */
body.app-boot .tab-bar {
    opacity: 0;
    pointer-events: none;
}

/* Tab Bar – fest am unteren Rand (iOS/Android-sicher) */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    min-height: 56px;
    box-sizing: border-box;
    z-index: 100;
    /* Eigene Compositor-Schicht, fixiert die Bar auf iOS/Android am unteren Rand */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* Feste Höhe inkl. Safe Area, verhindert Springen */
    height: calc(56px + var(--safe-bottom));
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0;
    color: var(--text3);
    text-decoration: none;
    font-size: 11px;
    transition: color 0.2s;
}

.tab-item.active {
    color: var(--accent);
}

/* Pull-to-Refresh: nur Reload-Icon, Optik wie Tab-Bar-Icons */
.pull-refresh-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, calc(-100% - 10px));
    padding: 10px 14px;
    background: var(--bg2);
    border-radius: 0 0 var(--radius) var(--radius);
    color: var(--text2);
    z-index: 200;
    transition: transform 0.15s ease-out;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pull-refresh-indicator svg {
    display: block;
    flex-shrink: 0;
}
.pull-refresh-indicator--visible {
    transform: translate(-50%, var(--pull-distance, 0));
}

/* App-Menü (Hamburger-Dropdown) */
.app-menu {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    right: 12px;
    min-width: 200px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 150;
    padding: 8px 0;
}
.app-menu.app-menu--hidden {
    display: none;
}
.app-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.app-menu-item:hover,
.app-menu-item:active {
    background: var(--bg3);
}
.app-menu-item svg {
    flex-shrink: 0;
    color: var(--text2);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
}

/* User Tabs */
.user-tabs {
    display: flex;
    overflow-x: auto;
    gap: 0;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.user-tabs::-webkit-scrollbar { display: none; }

.user-tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text3);
    background: none;
    border: none;
    border-bottom: 2.5px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.user-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.user-tab:active { opacity: 0.7; }

.user-tab-add {
    padding: 10px 14px;
    font-size: 18px;
    font-weight: 400;
    color: var(--text3);
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.user-tab-add:active { color: var(--accent); }

/* Local User Tabs (kleine runde Buttons mit Initialen) */
.local-user-tab {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg3);
    color: var(--text2);
    border: 2px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.local-user-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.local-user-tab:active { transform: scale(0.95); }

/* Add Local User Button */
.add-local-user-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg3);
    color: var(--text2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.add-local-user-btn:hover,
.add-local-user-btn:active {
    background: var(--accent);
    color: white;
    transform: scale(0.95);
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    background: none;
    border: none;
    color: var(--text2);
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.header-btn:active { background: var(--bg3); }

/* Gauge-Bereich inkl. Nüchtern-Text; Platz rechts nur wenn Skala sichtbar */
.gauge-section {
    position: relative;
}

.gauge-and-peak {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px 8px;
}

.gauge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
}

.gauge {
    position: relative;
    width: 220px;
    height: 110px;
    overflow: hidden;
}

.gauge-bg {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: conic-gradient(
        from 270deg at 50% 50%,
        var(--green) 0deg,
        var(--green) 27deg,
        var(--yellow) 27deg,
        var(--yellow) 45deg,
        var(--orange) 45deg,
        var(--orange) 72deg,
        var(--red) 72deg,
        var(--red) 135deg,
        var(--darkred) 135deg,
        var(--darkred) 180deg,
        var(--bg3) 180deg,
        var(--bg3) 360deg
    );
    -webkit-mask: radial-gradient(circle at 50% 50%, transparent 60%, black 61%);
    mask: radial-gradient(circle at 50% 50%, transparent 60%, black 61%);
}

.gauge-needle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 3px;
    height: 76px;
    background: var(--text);
    transform-origin: bottom center;
    transform: rotate(-90deg);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 2px 2px 0 0;
    margin-left: -1.5px;
}

.gauge-dot {
    position: absolute;
    bottom: -6px;
    left: 50%;
    width: 12px;
    height: 12px;
    background: var(--text);
    border-radius: 50%;
    margin-left: -6px;
}

.gauge-value {
    text-align: center;
    margin-top: 8px;
}

.gauge-promille {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s;
}

.gauge-unit {
    font-size: 18px;
    color: var(--text2);
    margin-left: 2px;
}

.gauge-status {
    font-size: 14px;
    font-weight: 600;
    margin-top: 2px;
}

/* Höchststands-Skala: schmal, ganz rechts, überlagert – Inhalt richtet sich nicht nach Skala */
.peak-scale-wrap {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible;
}

.peak-scale-label {
    font-size: 9px;
    color: var(--text2);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.peak-scale-bar {
    flex: 0 0 193px;
    width: 12px;
    height: 193px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.peak-scale-fill {
    width: 100%;
    height: 100%;
    transition: background 0.5s ease;
}

.peak-scale-value {
    font-size: 10px;
    font-weight: 700;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    white-space: nowrap;
    align-self: flex-end;
    text-align: right;
    min-width: 3.5em;
}

/* Sober By */
.sober-info {
    text-align: center;
    padding: 8px 16px 16px;
    font-size: 15px;
    color: var(--text2);
}

.sober-time {
    font-weight: 700;
    color: var(--text);
    font-size: 17px;
}

/* Drink Grid */
.section-label {
    padding: 12px 16px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-label--with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-label-icon {
    display: inline-flex;
    color: var(--text3);
}

.section-label-icon svg {
    flex-shrink: 0;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    vertical-align: middle;
}

.party-code-icon {
    display: inline-flex;
    vertical-align: middle;
    color: var(--text3);
}

.drink-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 0 12px 12px;
}

.drink-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 12px 4px;
    border-radius: var(--radius);
    background: var(--bg2);
    border: 1.5px solid var(--border);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
    min-height: 76px;
    -webkit-user-select: none;
    user-select: none;
}

.drink-btn:active {
    transform: scale(0.93);
    border-color: var(--accent);
    background: var(--accent2);
}

.drink-btn .emoji,
.drink-btn .drink-emoji-fallback {
    font-size: 26px;
    line-height: 1;
}

.drink-btn .drink-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.drink-btn .drink-btn-icon .drink-icon-wrap {
    display: inline-flex;
    align-items: center;
}

.drink-btn .drink-btn-icon .drink-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.drink-btn .name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.drink-btn .detail {
    font-size: 11px;
    color: var(--text3);
}

/* Drink List */
.drink-list {
    padding: 0 12px 12px;
}

.drink-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg2);
    border-radius: var(--radius);
    margin-bottom: 6px;
}

.drink-item-time {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    min-width: 48px;
    cursor: pointer;
}

.drink-item-time:active { opacity: 0.6; }

.drink-item-info {
    flex: 1;
    font-size: 14px;
}

.drink-item-info .drink-icon-wrap {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 4px;
}

.drink-item-info .drink-icon {
    width: 1.2em;
    height: 1.2em;
    object-fit: contain;
    vertical-align: middle;
}

.drink-item-info .drink-emoji-fallback {
    vertical-align: middle;
}

.drink-item-info small {
    color: var(--text3);
    margin-left: 4px;
}

.drink-item-del {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 20px;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
}

.drink-item-del:active { background: var(--red); color: white; }

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    transition: transform 0.3s ease;
    z-index: 200;
    max-width: calc(100% - 32px);
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

.toast button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

/* Forms */
.form-card {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
}

.btn:active { opacity: 0.8; }

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

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

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

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-row .btn { flex: 1; }

/* User List */
.user-list {
    padding: 12px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg2);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: border-color 0.2s;
    border: 1.5px solid transparent;
}

.user-item.active { border-color: var(--accent); }
.user-item.inactive { opacity: 0.6; }

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-avatar .drink-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-avatar .drink-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.user-avatar .drink-emoji-fallback {
    font-size: 22px;
}

.user-info { flex: 1; }
.user-name { font-weight: 600; font-size: 15px; }
.user-detail { font-size: 13px; color: var(--text3); }

/* Gelage: Teilnehmer mit Promille-Skala (orange–rot, horizontal) */
/* Gelage: Beitrittsanfragen (Creator sieht „NAME möchte beitreten“ und kann einladen) */
.party-join-requests-banner {
    background: var(--bg3);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    margin: 0 12px 16px;
    padding: 12px 14px;
}
.party-join-request-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.party-join-request-row:last-child { border-bottom: none; }
.party-join-request-name { font-weight: 600; font-size: 14px; color: var(--text); }
.party-join-request-actions { display: flex; gap: 8px; }
.party-join-item .user-info { min-width: 0; }

.party-participants-list {
    padding: 12px;
}

.party-participant-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 56px;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg2);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.party-participant-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.party-participant-promille-bar-wrap {
    height: 20px;
    background: var(--bg3);
    border-radius: 10px;
    overflow: hidden;
}

/* Hintergrund pro Balken per Inline (Index-Bereiche 0–2 ‰); Rest der Breite = grau (Wrap) */
.party-participant-promille-bar {
    height: 100%;
    min-width: 2px;
    border-radius: 10px;
    transition: width 0.4s ease;
}

.party-participant-name.clickable {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.party-participant-promille-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    text-align: right;
}

/* Session List (History) */
.session-item {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 14px;
    margin: 0 12px 8px;
}
.session-item.clickable {
    cursor: pointer;
}
.session-item.clickable:hover {
    background: var(--bg3);
}

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

.session-label { font-weight: 600; font-size: 15px; }
.session-date { font-size: 13px; color: var(--text3); }

.session-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text2);
}

.session-stat-val { font-weight: 700; color: var(--text); }

/* Verlauf: Beendete Gelage – alle Teilnehmer, was jeder getrunken hat */
.history-party-block {
    background: var(--bg2);
    border-radius: var(--radius);
    margin: 0 12px 12px;
    padding: 14px;
    border: 1px solid var(--border);
}
.history-party-block.clickable {
    cursor: pointer;
}
.history-party-block.clickable:hover {
    background: var(--bg3);
}
.history-party-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.history-party-name { font-weight: 600; font-size: 16px; color: var(--text); }
.history-party-date { font-size: 13px; color: var(--text3); }
.history-delete-btn {
    margin-left: auto;
    padding: 4px 8px;
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.7;
    border-radius: 6px;
}
.history-delete-btn:hover {
    opacity: 1;
    background: var(--bg3);
}
.session-header .history-delete-btn {
    margin-left: auto;
}
.history-party-participant {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.history-party-participant:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.history-party-participant-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 6px;
}
.history-party-drinks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 13px;
    color: var(--text2);
}
.history-drink-item {
    display: inline-block;
    white-space: nowrap;
}

.history-drink-item .drink-icon-wrap {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 2px;
}

.history-drink-item .drink-icon {
    width: 1em;
    height: 1em;
    object-fit: contain;
    vertical-align: middle;
}

.history-drink-item .drink-emoji-fallback {
    vertical-align: middle;
}

.history-drink-empty { font-style: italic; color: var(--text3); }
.history-party-participant-sum {
    font-size: 12px;
    color: var(--text3);
    margin-top: 4px;
}

/* Verlauf: Sitzungs-Detail (eine Sitzung ansehen) */
.history-session-detail {
    padding: 0 12px 24px;
}
.history-session-date {
    font-size: 15px;
    color: var(--text2);
    margin-bottom: 12px;
}
.history-session-stats {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text2);
    margin-bottom: 8px;
}
.history-session-drinks {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 8px 0;
    border: 1px solid var(--border);
}
.history-session-drink-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.history-session-drink-row:last-child {
    border-bottom: none;
}
.history-session-drink-time {
    color: var(--text3);
    font-size: 13px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text3);
}

.empty-state .emoji { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; line-height: 1.5; }

/* Inline Time Edit */
.time-edit-input {
    background: var(--bg3);
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    color: var(--text);
    padding: 2px 6px;
    font-size: 14px;
    width: 70px;
}

.btn-inline-done {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-inline-done:active {
    background: var(--accent2);
}

/* Settings */
.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}

.setting-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.setting-item:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }

.setting-label { font-size: 15px; }
.setting-value { color: var(--text2); font-size: 14px; }

.settings-card {
    margin: 0 12px;
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
}
.settings-card--padded {
    padding: 16px;
}
.settings-card .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.settings-card .btn-primary .setting-row-icon { color: inherit; }
.setting-item--with-icon {
    display: flex;
    align-items: center;
    gap: 12px;
}
.setting-item--with-icon .setting-row-icon {
    flex-shrink: 0;
    color: var(--text2);
    display: flex;
    align-items: center;
    justify-content: center;
}
.setting-item--with-icon .setting-row-icon svg {
    width: 22px;
    height: 22px;
}
.setting-item--with-icon .setting-label { flex: 1; }
.setting-item--with-icon .setting-value { flex-shrink: 0; }

/* Disclaimer */
.disclaimer {
    margin: 12px;
    padding: 12px;
    background: var(--bg2);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text3);
    line-height: 1.5;
    border-left: 3px solid var(--yellow);
}

/* Gender select buttons */
.gender-select {
    display: flex;
    gap: 8px;
}

.gender-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--bg3);
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
}

.gender-btn.selected {
    border-color: var(--accent);
    background: var(--accent2);
    color: white;
}

/* Slider */
.range-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-wrap input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.range-val {
    font-weight: 700;
    min-width: 50px;
    text-align: right;
    font-size: 15px;
}

/* Session end button */
.session-end-btn {
    display: block;
    width: calc(100% - 24px);
    margin: 4px 12px 12px;
    padding: 10px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text3);
    font-size: 13px;
    cursor: pointer;
    text-align: center;
}

.session-end-btn:active { background: var(--bg3); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

#app.page-load > * {
    animation: fadeIn 0.2s ease;
}

/* Ausnüchterungsgraph */
.chart-wrap {
    margin: 0 12px 12px;
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 12px;
    overflow: hidden;
}

.chart-canvas {
    width: 100%;
    height: 160px;
    display: block;
}

/* Meilenstein-Timeline */
.milestones {
    padding: 0 12px 12px;
}

.milestone {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    position: relative;
}

.milestone + .milestone {
    border-top: 1px solid var(--border);
}

.milestone-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    font-weight: 700;
}

.milestone-content {
    flex: 1;
}

.milestone-label {
    font-size: 14px;
    font-weight: 600;
}

.milestone-time {
    font-size: 13px;
    color: var(--text2);
    margin-top: 1px;
}

.milestone-value {
    font-size: 13px;
    color: var(--text3);
}

.milestone.reached .milestone-icon {
    background: var(--green);
    color: white;
}

.milestone.reached .milestone-label {
    color: var(--green);
}

.milestone.pending .milestone-icon {
    background: var(--bg3);
    color: var(--text3);
}

.milestone.active .milestone-icon {
    background: var(--orange);
    color: white;
    animation: pulse 1.5s infinite;
}

/* Akkordeon */
.accordion-item {
    margin: 0 12px 8px;
    background: var(--bg2);
    border-radius: var(--radius);
    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    -webkit-user-select: none;
    user-select: none;
}

.accordion-header::after {
    content: '▸';
    transition: transform 0.2s;
    color: var(--text3);
}

.accordion-item.open .accordion-header::after {
    transform: rotate(90deg);
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-item.open .accordion-body {
    max-height: 600px;
}

.accordion-content {
    padding: 0 16px 16px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text2);
}

.accordion-content code {
    background: var(--bg3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--accent);
}

.accordion-content strong {
    color: var(--text);
}

/* Sync indicator */
.sync-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.sync-dot:hover {
    transform: scale(1.2);
}

.sync-dot.online { background: var(--green); }
.sync-dot.offline { background: var(--orange); }
.sync-dot.syncing { background: var(--accent); animation: pulse 1s infinite; }

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

/* Scrollbar */
::-webkit-scrollbar { width: 0; }

/* Modal Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 20px;
}

.modal label {
    display: block;
    margin-bottom: 16px;
}

.modal label span {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text2);
}

.modal input,
.modal select {
    width: 100%;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
}

.modal input:focus,
.modal select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover,
.btn-primary:active {
    background: var(--accent2);
}

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

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--border);
}
