:root {
    --primary: #6c5ce7;
    --primary-hover: #5b4bc4;
    --secondary: #a29bfe;
    --success: #00b894;
    --danger: #ff7675;
    --bg-color: #dfe6e9;
    --card-bg: #ffffff;
    --text-color: #2d3436;
    --text-muted: #636e72;
    --border-radius: 16px;
    --shadow: 0 10px 25px rgba(0,0,0,0.05);
}

/* Dark Mode Variablen */
body.dark-mode {
    --bg-color: #1e272e;
    --card-bg: #2f3640;
    --text-color: #f5f6fa;
    --text-muted: #b2bec3;
    --shadow: 0 10px 25px rgba(0,0,0,0.3);
}

body.dark-mode .modern-input {
    background: #353b48;
    border-color: #353b48;
    color: white;
}
body.dark-mode .modern-input:focus {
    border-color: var(--primary);
    background: #353b48;
}
body.dark-mode li {
    background: #353b48;
    border-color: #353b48;
}
body.dark-mode li:hover {
    background: #3d4655;
}
body.dark-mode .domain-chip {
    background: #353b48;
    border-color: #353b48;
}
body.dark-mode .share-inner {
    background: #353b48;
    border-color: #353b48;
}

/* Lade-Animation (Overlay) */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.3s ease-out, visibility 0.3s;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #dfe6e9;
    border-bottom-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-container.hidden {
    opacity: 0;
    visibility: hidden;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: var(--card-bg);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    margin: 0;
    min-height: 100vh;
    /* Safe Area Support (Notch & Home Bar) */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    /* Verhindert Wackeln der ganzen Seite (Rubber-Banding) */
    overscroll-behavior-y: none;
    height: 100dvh; /* Volle Höhe auf Mobile erzwingen */
    overflow: hidden; /* Scrollen auf Body verhindern, damit Footer fix bleibt */
}

.container {
    background: var(--card-bg);
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
    height: 100%; /* Füllt den Body */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Wichtig für Sticky Footer */
}

h1 {
    text-align: center;
    color: var(--text-color);
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

#listTitle {
    outline: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
    border-radius: 4px;
}

#listTitle[contenteditable="true"] {
    border-bottom-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.5);
    cursor: text;
    padding: 0 4px;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-top: 0.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

/* Moderne Inputs */
.modern-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #f1f2f6;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fa;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.modern-input:focus {
    border-color: var(--primary);
    background: white;
}

.input-group .modern-input {
    margin-bottom: 0;
    flex-grow: 1;
}

/* Domain Chips (Schnellwahl) */
.domain-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    margin-bottom: 15px;
    -webkit-overflow-scrolling: touch; /* Flüssiges Scrollen auf iOS */
    scrollbar-width: none; /* Firefox Scrollbar ausblenden */
}
.domain-chips::-webkit-scrollbar {
    display: none; /* Chrome/Safari Scrollbar ausblenden */
}
.domain-chip {
    background: #f1f2f6;
    border: 1px solid #dfe6e9;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}
.domain-chip:hover {
    background: #e2e6ea;
    color: var(--primary);
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    width: 100%;
}

.btn:active {
    transform: scale(0.98);
}

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

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

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

/* Text Button (z.B. für Aufräumen) */
.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    padding: 10px;
}

.btn:disabled {
    background-color: #b2bec3;
    cursor: not-allowed;
}

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.round-btn {
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Scrollbarer Bereich für die Liste */
.content-area {
    flex-grow: 1;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    margin: 0 -1.5rem; /* Padding vom Container ausgleichen */
    padding: 0 1.5rem; /* Padding wieder hinzufügen */
    display: flex;
    flex-direction: column;
    min-height: 0; /* WICHTIG: Damit Flex-Item schrumpfen kann und Scrollen funktioniert */
}

ul#shoppingList {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#allLists {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    min-height: 0; /* WICHTIG: Damit Flex-Item schrumpfen kann und Scrollen funktioniert */
}

li {
    background: #fff;
    margin-bottom: 10px;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    border: 1px solid #f1f2f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
li:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
}
/* Klickbare Listen im Dashboard */
li.list-entry {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
}

.list-icon {
    background-color: #eef2ff;
    color: var(--primary);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.list-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.list-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 4px;
}

.list-meta {
    font-size: 13px;
    color: var(--text-muted);
}

li.completed span {
    text-decoration: line-through;
    color: #b2bec3;
}

/* Wrapper für größere Klickfläche */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    padding: 10px 15px 10px 10px; /* Großzügiges Padding für Touch */
    margin: -10px 0 -10px -10px; /* Kompensiert Padding, damit Layout gleich bleibt */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* Verhindert Zoom-Verzögerung */
}

/* Runde Checkbox */
.custom-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #dfe6e9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background-color: white;
}

.checkbox-wrapper:hover .custom-checkbox {
    border-color: var(--primary);
}

/* Drück-Effekt auf Mobile */
.checkbox-wrapper:active .custom-checkbox {
    transform: scale(0.9);
}

.custom-checkbox.checked {
    background-color: var(--success);
    border-color: var(--success);
}

.custom-checkbox.checked::after {
    content: '';
    width: 10px;
    height: 5px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg);
    margin-bottom: 2px;
}

/* Bearbeitbarer Text in der Liste */
.item-text {
    flex-grow: 1;
    margin: 0 8px;
    padding: 12px 10px; /* Größere Trefferfläche für Finger */
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
}
.item-text:hover {
    background-color: rgba(0,0,0,0.05);
}
body.dark-mode .item-text:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Temporäres Input-Feld beim Bearbeiten */
.edit-item-input {
    flex-grow: 1;
    margin: 0 8px !important; /* Überschreibt modern-input Margin */
    padding: 8px 12px;
    width: auto;
    margin-bottom: 0 !important;
}

/* Icon Button in der Liste */
.delete-item-btn {
    background-color: transparent;
    color: #b2bec3;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
}
.delete-item-btn:hover {
    background-color: #ffeaa7;
    color: #d63031;
}

/* Header Navigation */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* User Avatar (Kreis mit Initialen) */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    cursor: default;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.icon-btn:hover {
    background-color: #f1f2f6;
}

/* Share Section (Accordion Style) */
.share-section {
    overflow-y: auto;
    max-height: 500px;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease;
    opacity: 1;
    margin-bottom: 15px;
}

.share-section.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

.share-inner {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #eee;
}

.share-hint {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--text-muted);
}

.input-row {
    display: flex;
    gap: 8px;
}

.modern-input.small {
    padding: 10px;
    font-size: 14px;
}

.btn.small {
    width: auto;
    padding: 10px 16px;
    font-size: 14px;
}

/* Liste der geteilten Nutzer */
.shared-users-list {
    margin-top: 15px;
    padding: 0;
}
.shared-users-list li {
    background: none;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 8px 0;
    box-shadow: none;
    margin-bottom: 0;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 92%;
    max-width: 400px;
}

.toast {
    background: #2d3436;
    color: white;
    padding: 16px 20px;
    border-radius: 16px;
    font-size: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(20px);
    animation: slideUpFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto; /* Wichtig: Damit man Buttons klicken kann */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

/* Spezielles Design für Bestätigungs-Popup */
.toast.confirmation {
    background: white;
    color: var(--text-color);
    border: 1px solid rgba(0,0,0,0.05);
    padding: 20px;
}

.toast.confirmation div:first-child {
    font-weight: 600;
    font-size: 17px;
    margin-bottom: 5px;
}

.toast-buttons {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    width: 100%;
}

.toast-btn {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    border: none;
    transition: transform 0.1s;
}

.toast-btn:active {
    transform: scale(0.96);
}

.toast-btn.confirm {
    background-color: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 118, 117, 0.3);
}

.toast-btn.cancel {
    background-color: #f1f2f6;
    color: var(--text-color);
}

@keyframes slideUpFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Desktop Optimierungen */
@media (min-width: 600px) {
    body {
        align-items: center;
        padding-top: 0;
        background-color: var(--bg-color);
    }
    .container {
        box-shadow: var(--shadow);
        border-radius: var(--border-radius);
        padding: 2.5rem;
        max-width: 450px;
        height: 85vh; /* Feste Höhe damit internes Scrollen funktioniert */
        max-height: 900px;
    }

    /* Anpassung der Ränder für das größere Desktop-Padding */
    .content-area {
        margin: 0 -2.5rem;
        padding: 0 2.5rem;
    }
    .footer-input {
        margin-left: -2.5rem;
        margin-right: -2.5rem;
        padding-left: 2.5rem;
        padding-right: 2.5rem;
    }
}

/* Footer Input (Sticky Bottom) */
.footer-input {
    margin-top: auto;
    padding-top: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    margin-bottom: 0;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    background: var(--card-bg);
    z-index: 10;
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* Password Toggle */
.password-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
}
.password-wrapper input {
    margin-bottom: 0;
    padding-right: 40px;
}
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    display: flex;
    align-items: center;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.empty-state svg {
    color: #dfe6e9;
    width: 64px;
    height: 64px;
}
body.dark-mode .empty-state svg {
    color: #353b48;
}