:root {
    --bg-main: #121212;
    --text-bright: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.5);
    --card-dark: #1e1e1e;
    --accent-purple: #bb9af7;
    --accent-lime: #d4fc79; 
    --danger: #ff5f5f;
    --status-ok: #00e676;
    --status-sync: #ffea00;
    --toast-bg: rgba(40, 40, 40, 0.95);
    
    --shadow-card: 0 0 20px rgba(0,0,0,0.3);
    --glow-today: 0 0 25px rgba(212, 252, 121, 0.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }
::-webkit-scrollbar { display: none; }

/* OPTIMIERUNG: Overscroll Fix */
html {
    background-color: var(--bg-main);
    overscroll-behavior-y: none;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-bright);
    margin: 0; padding: 20px;
    padding-top: calc(env(safe-area-inset-top) + 25px);
    padding-bottom: max(120px, env(safe-area-inset-bottom));
    display: flex; flex-direction: column; align-items: center;
    min-height: 100vh;
    overscroll-behavior-y: none;
    -webkit-user-select: none; user-select: none;
    touch-action: manipulation;
}

/* SCROLL LOCK */
body.modal-open { overflow: hidden; height: 100vh; position: fixed; width: 100%; }

/* HEADER */
.header-container { text-align: center; margin-bottom: 30px; width: 100%; max-width: 400px; position: relative; }
.header-row { display: flex; align-items: center; justify-content: center; position: relative; width: 100%; }
h1 { margin: 0; color: var(--accent-purple); font-weight: 800; font-size: 2.2rem; letter-spacing: -1px; cursor: default; line-height: 1; text-shadow: 0 0 25px rgba(187, 154, 247, 0.3); }

/* STATS & DICE BUTTONS */
.stats-icon-btn, .dice-btn {
    position: absolute; top: 0;
    background: rgba(255,255,255,0.1); border: none; color: white;
    width: 40px; height: 40px; border-radius: 50%;
    font-size: 1.2rem; cursor: pointer; display: grid; place-items: center;
    transition: transform 0.2s; z-index: 50;
    transform: translateZ(0);
}
.stats-icon-btn { right: 0; }
.dice-btn { left: 0; font-size: 1.4rem; }

.stats-icon-btn:active { transform: scale(0.9); background: var(--accent-purple); }
.dice-btn:active { transform: scale(0.9) rotate(20deg); background: var(--accent-lime); color: var(--bg-main); }

/* SYNC DOT */
.sync-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background-color: var(--status-ok);
    position: absolute; left: 50%; top: -15px; transform: translateX(-50%);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 0 10px var(--status-ok);
    z-index: 50;
}
.sync-dot.syncing { background-color: var(--status-sync); box-shadow: 0 0 15px var(--status-sync); transform: translateX(-50%) scale(1.3); }

.date-display { font-size: 0.85rem; font-weight: 700; color: var(--text-dim); margin-top: 8px; text-transform: uppercase; letter-spacing: 1.5px; }
.date-display span { color: var(--accent-lime); }

/* TABS */
.tabs { display: flex; background: rgba(255,255,255,0.03); border-radius: 18px; padding: 4px; margin-bottom: 20px; width: 100%; max-width: 400px; border: 1px solid rgba(255,255,255,0.05); }
.tab { flex: 1; text-align: center; padding: 12px 0; border-radius: 14px; cursor: pointer; font-weight: 700; font-size: 0.95rem; transition: all 0.3s; color: var(--text-dim); }
.tab.active { color: var(--bg-main); background: var(--accent-purple); box-shadow: 0 0 20px rgba(187, 154, 247, 0.4); }
#tab-history.active { background: var(--accent-lime); box-shadow: 0 0 20px rgba(212, 252, 121, 0.4); }

/* INPUT FIXED BOTTOM */
.bottom-dock {
    position: fixed; bottom: 0; left: 0; width: 100%;
    padding: 10px 20px; padding-bottom: max(20px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg-main) 40%, transparent);
    display: flex; flex-direction: column; align-items: center; pointer-events: none; z-index: 100;
}

.input-group { 
    pointer-events: auto;
    display: flex; width: 100%; max-width: 400px;
    background: rgba(30, 30, 30, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-radius: 22px; padding: 6px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.2s, opacity 0.3s; 
    transform: translateZ(0); 
    position: relative; z-index: 2;
}
.input-group.hidden { opacity: 0; pointer-events: none; transform: translateY(20px); }
.input-group:focus-within { border-color: rgba(212, 252, 121, 0.4); transform: scale(1.02); }

input { flex-grow: 1; padding: 15px 20px; border: none; font-size: 1.1rem; font-family: 'Nunito', sans-serif; font-weight: 600; outline: none; background: transparent; color: var(--text-bright); }
input::placeholder { color: rgba(255, 255, 255, 0.15); }
button#add-btn { background-color: var(--accent-lime); color: var(--bg-main); border: none; width: 52px; height: 52px; border-radius: 18px; font-weight: 800; font-size: 26px; cursor: pointer; box-shadow: 0 0 15px rgba(212, 252, 121, 0.3); transition: transform 0.1s; }
button#add-btn:active { transform: scale(0.92); }

/* LISTE */
ul { list-style: none; padding: 0; width: 100%; max-width: 400px; overflow-x: visible; }
.section-title { width: 100%; max-width: 400px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: rgba(255, 255, 255, 0.2); margin: 40px 0 15px 15px; font-weight: 800; display: flex; align-items: center; opacity: 0; animation: fadeIn 0.6s forwards; }
.section-title:first-child { margin-top: 10px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.05); margin-left: 20px; }

li { background: var(--card-dark); margin-bottom: 18px; padding: 18px 22px; border-radius: 24px; display: flex; flex-direction: column; box-shadow: var(--shadow-card); border: 1px solid rgba(255,255,255,0.03); opacity: 1; position: relative; overflow: hidden; transition: transform 0.2s; max-height: 500px; transform: translateZ(0); }
li.is-today { border: 2px solid var(--accent-lime); box-shadow: var(--glow-today); z-index: 10; }
li.removing { transform: translateX(50px); opacity: 0; max-height: 0; margin: 0; padding: 0; overflow: hidden; transition: 0.5s; }
li:active { transform: scale(0.98); transition: transform 0.1s; }

.li-top { display: flex; justify-content: space-between; align-items: flex-start; width: 100%; margin-bottom: 15px; }
.name-container { display: flex; flex-direction: column; gap: 4px; max-width: 80%; }
.item-name { font-size: 1.15rem; font-weight: 700; color: #fff; pointer-events: none; line-height: 1.3; } 
.item-name.done { text-decoration: line-through; opacity: 0.5; }
.today-badge { display: inline-block; background: var(--accent-lime); color: var(--bg-main); font-size: 0.65rem; font-weight: 900; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.5px; align-self: flex-start; box-shadow: 0 0 10px rgba(212, 252, 121, 0.4); }
.day-row { display: flex; justify-content: space-between; width: 100%; border-top: 1px solid rgba(255,255,255,0.03); padding-top: 12px; }
.day-btn { font-size: 0.75rem; font-weight: 700; width: 32px; height: 32px; border-radius: 12px; background: rgba(255,255,255,0.03); color: rgba(255, 255, 255, 0.3); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
.day-btn.selected { background: var(--accent-purple); color: var(--bg-main); box-shadow: 0 0 15px rgba(187, 154, 247, 0.4); transform: scale(1.05); }
.day-row.disabled { opacity: 0.2; pointer-events: none; }
.action-btn { width: 42px; height: 42px; border-radius: 14px; border: none; background: rgba(255,255,255,0.05); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-left: 10px; transition: all 0.2s; flex-shrink: 0; }
.check-btn { color: var(--accent-purple); border: 1px solid rgba(187, 154, 247, 0.1); }
.check-btn::after { content: '✓'; font-weight: 900; }
.restore-btn { color: var(--accent-lime); border: 1px solid rgba(212, 252, 121, 0.1); }
.empty-state { text-align: center; margin-top: 60px; opacity: 0; animation: fadeIn 0.8s forwards; pointer-events: none; }
.empty-emoji { font-size: 70px; margin-bottom: 20px; display: block; opacity: 0.4; filter: grayscale(1); }
.empty-text { color: rgba(255, 255, 255, 0.2); font-weight: 700; letter-spacing: 0.5px; }
@keyframes fadeIn { to { opacity: 1; } }
.loader { text-align: center; color: rgba(255,255,255,0.2); margin-top: 40px; font-weight: 700; letter-spacing: 1px; pointer-events: none; }

/* MODALS */
#modal-overlay, #stats-overlay, #dice-overlay, #list-manager-overlay, #new-list-overlay, #confirm-overlay, #alert-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); 
    display: none; justify-content: center; align-items: center; z-index: 1000; 
    opacity: 0; transition: opacity 0.3s; 
    transform: translateZ(0);
}
#modal-overlay.visible, #stats-overlay.visible, #dice-overlay.visible, #list-manager-overlay.visible, #new-list-overlay.visible, #confirm-overlay.visible, #alert-overlay.visible { display: flex; opacity: 1; }

.modal { 
    background: var(--card-dark); width: 85%; max-width: 320px; padding: 30px; 
    border-radius: 30px; text-align: center; 
    box-shadow: 0 25px 50px rgba(0,0,0,0.6); 
    transform: scale(0.95); transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1); 
    border: 1px solid rgba(255,255,255,0.05); 
    display: flex; flex-direction: column;
}
.modal.full-screen-modal { width: 95%; max-width: 500px; height: 80vh; padding: 20px; }
#modal-overlay.visible .modal, #stats-overlay.visible .modal, #dice-overlay.visible .modal, #list-manager-overlay.visible .modal, #new-list-overlay.visible .modal, #confirm-overlay.visible .modal, #alert-overlay.visible .modal { transform: scale(1); }

.modal h2 { margin: 0 0 25px 0; color: var(--text-bright); font-size: 1.4rem; }
.modal input { background: rgba(0,0,0,0.3); width: 100%; margin-bottom: 25px; border-radius: 16px; box-sizing: border-box; font-size: 1.1rem; padding: 14px; color: white; border: 1px solid rgba(255,255,255,0.1); outline: none; }
.modal input:disabled { opacity: 0.5; border-style: dashed; pointer-events: none; }

.modal-actions { display: flex; gap: 12px; justify-content: center; width: 100%; }
.btn-modal { padding: 14px 20px; border-radius: 16px; border: none; font-weight: 800; flex: 1; cursor: pointer; font-size: 1rem; transition: transform 0.1s; }
.btn-modal:active { transform: scale(0.95); }
.btn-cancel { background: transparent; color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.1); }
.btn-save { background: var(--accent-lime); color: var(--bg-main); box-shadow: 0 4px 15px rgba(212, 252, 121, 0.2); }
.btn-delete { background: rgba(255, 95, 95, 0.1); color: var(--danger); margin-top: 20px; width: 100%; border: 1px solid rgba(255, 95, 95, 0.2); }

/* DICE MODAL */
.dice-anim { font-size: 4rem; margin-bottom: 20px; display: block; filter: drop-shadow(0 0 20px rgba(187, 154, 247, 0.4)); animation: shake 0.5s ease; }
.dice-result-text { font-size: 1.8rem; font-weight: 800; color: var(--accent-purple); margin: 20px 0; line-height: 1.2; text-shadow: 0 0 30px rgba(187, 154, 247, 0.3); }
@keyframes shake { 0% { transform: rotate(0); } 25% { transform: rotate(15deg); } 50% { transform: rotate(-15deg); } 75% { transform: rotate(5deg); } 100% { transform: rotate(0); } }

/* SMALL LOGOUT LINK */
.text-link-danger { background: none; border: none; color: var(--danger); font-size: 0.8rem; cursor: pointer; opacity: 0.7; font-weight: 700; transition: 0.2s; border-bottom: 1px solid transparent; }
.text-link-danger:active { opacity: 1; transform: scale(0.95); border-bottom-color: var(--danger); }

/* STATS CONTENT */
.item-stats-container { margin-bottom: 20px; text-align: left; }
.item-stats-title { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; font-weight: 700; margin-bottom: 8px; }
.item-history-list { max-height: 120px; overflow-y: auto; background: rgba(0,0,0,0.2); border-radius: 12px; padding: 10px; border: 1px solid rgba(255,255,255,0.05); }
.hist-entry { font-size: 0.9rem; color: #fff; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.hist-entry:last-child { border-bottom: none; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; width: 100%; }
.close-icon { background: rgba(255,255,255,0.1); border:none; width:36px; height:36px; border-radius:50%; color:white; font-size:1.2rem; cursor:pointer; }
#global-stats-content { flex: 1; overflow-y: auto; text-align: left; width: 100%; }

.stat-row { display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,0.03); padding: 12px 16px; margin-bottom: 8px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.05); }
.stat-name { font-weight: 700; }
.stat-count { background: var(--accent-purple); color: var(--bg-main); font-weight: 800; padding: 2px 8px; border-radius: 8px; font-size: 0.85rem; }
.stat-count.zero { background: rgba(255,255,255,0.1); color: var(--text-dim); }

/* TOAST - OPTIMIERUNG: Bessere Positionierung */
#toast { 
    position: fixed; 
    top: 70px; 
    top: max(70px, calc(env(safe-area-inset-top) + 50px)); /* Safe Area + Abstand */
    left: 50%; transform: translateX(-50%) translateY(-200%); 
    background: var(--toast-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: white; padding: 12px 24px; border-radius: 40px; box-shadow: 0 10px 40px rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.1); font-weight: 700; font-size: 0.9rem; cursor: pointer; z-index: 2000; opacity: 0; transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s; pointer-events: none;
}
#toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }

/* LIST SWITCHER & SETTINGS */
.list-bar-container { width: 100%; max-width: 400px; display: flex; align-items: center; gap: 8px; margin-bottom: 20px; padding-left: 5px; opacity: 0; animation: fadeIn 0.5s forwards 0.2s; }
.btn-list-settings { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; border: none; background: rgba(255,255,255,0.1); color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: 0.2s; }
.btn-list-settings:active { background: var(--accent-purple); color: var(--bg-main); transform: rotate(45deg); }
.list-scroll-area { display: flex; gap: 8px; overflow-x: auto; flex-grow: 1; padding-bottom: 5px; scrollbar-width: none; }
.list-scroll-area::-webkit-scrollbar { display: none; }
.chip { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: var(--text-dim); padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; cursor: pointer; transition: all 0.2s; }
.chip.active { background: var(--text-bright); color: var(--bg-main); box-shadow: 0 0 15px rgba(255,255,255,0.3); border-color: white; }
.chip.shared { border-color: var(--accent-purple); }
.btn-new-list { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; border: 1px dashed rgba(255,255,255,0.3); background: transparent; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: 0.2s; }
.btn-new-list:active { background: rgba(255,255,255,0.2); transform: scale(0.9); }

/* SUGGESTION BOX (FLOATING BUBBLE STYLE - WIEDER DA!) */
.suggestion-box { 
    width: 100%; max-width: 400px; 
    display: flex; flex-direction: column; gap: 8px; 
    margin-bottom: 10px; /* ABSTAND WICHTIG */
    pointer-events: none; z-index: 10;
    position: relative; 
}

.suggestion-pill { 
    background: rgba(30, 30, 30, 0.95); 
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); 
    border: 1px solid var(--accent-lime); 
    border-radius: 16px; /* RUND */
    color: var(--text-bright); padding: 12px 16px; 
    font-weight: 700; font-size: 0.95rem; box-shadow: 0 5px 20px rgba(0,0,0,0.4); 
    pointer-events: auto; cursor: pointer; text-align: left; 
    display: flex; justify-content: space-between; align-items: center; 
    animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.suggestion-pill span { color: var(--accent-lime); font-size: 0.8em; text-transform: uppercase; letter-spacing: 1px; }
@keyframes popUp { from { transform: translateY(20px) scale(0.9); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* MANAGER MODAL STYLES */
.settings-scroll-content { flex: 1; overflow-y: auto; text-align: left; width: 100%; }
.modal-section-title { text-align: left; font-size: 0.75rem; color: var(--accent-purple); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 800; margin-top: 30px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.modal-section-title:first-child { margin-top: 0; }
.modal-section-title::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); }

.input-with-btn { display: flex; gap: 8px; align-items: stretch; width: 100%; }
.input-with-btn input { margin-bottom: 0; flex: 1; }
.btn-inline-save { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); color: var(--accent-lime); border-radius: 14px; width: 50px; flex-shrink: 0; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-inline-save:active { background: var(--accent-lime); color: var(--bg-main); }
.btn-inline-save:disabled { opacity: 0.3; pointer-events: none; border-style: dashed; }

.settings-hint { font-size: 0.75rem; color: gray; margin-top: 6px; margin-bottom: 0; line-height: 1.4; }

/* User Search Autocomplete - DOCKED & FIXED GAP */
.user-search-wrapper { position: relative; width: 100%; z-index: 100; }

/* DER FIX FÜR DEN GRAUEN BALKEN */
.user-search-wrapper input {
    margin-bottom: 0 !important; /* Balken (Margin) entfernen */
}

.user-search-wrapper input.has-results {
    border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}

.user-search-results { 
    position: absolute; top: 100%; left: 0; width: 100%; 
    background: #2a2a2a; 
    border: 1px solid rgba(255,255,255,0.1); border-top: none;
    border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    z-index: 9999; 
    overflow: hidden; display: none; margin-top: 0; 
}
.user-search-results.visible { display: block; animation: fadeIn 0.2s; }
.search-result-item { padding: 12px 15px; border-bottom: 1px solid rgba(255,255,255,0.05); text-align: left; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; transition: background 0.2s; }
.search-result-item:active { background: var(--accent-purple); color: var(--bg-main); }
.search-result-item:last-child { border-bottom: none; }

/* Member List */
.members-list-container { background: rgba(0,0,0,0.2); border-radius: 16px; padding: 10px; min-height: 50px; border: 1px solid rgba(255,255,255,0.05); }
.member-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.member-item:last-child { border-bottom: none; }
.member-name { font-weight: 700; font-size: 0.95rem; }
.btn-remove-member { background: rgba(255, 95, 95, 0.2); color: var(--danger); border: none; border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 0.8rem; font-weight: 700; }

/* Danger Zone */
.danger-zone { margin-top: 40px; padding-top: 20px; border-top: 1px solid rgba(255, 95, 95, 0.2); }
.btn-link-danger { background: none; border: none; color: var(--danger); font-size: 0.9rem; font-weight: 700; cursor: pointer; opacity: 0.8; padding: 10px; width: 100%; transition: all 0.2s; }
.btn-link-danger:active { opacity: 1; transform: scale(0.95); }
.btn-link-danger.leave-mode { color: #f59e0b; }