@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --primary-color: #6366F1;
    --primary-dark: #4F46E5;
    --secondary-color: #64748B;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --bg-color: #F8F9FF;
    --card-bg: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --border-color: #E2E8F0;
    --message-sent: #DCF8C6;
    --message-received: #FFFFFF;
    --header-bg: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
    --header-text: #FFFFFF;
}

/* Themes */
body.theme-dark {
    --bg-color: #0F0F1A;
    --card-bg: #1A1A2E;
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --border-color: #2D2D44;
    --message-sent: #1E3A5F;
    --message-received: #1A1A2E;
    --header-bg: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);
}

body.theme-dark #loginScreen.active {
    background: linear-gradient(160deg, #0F0F1A 0%, #1E1B4B 50%, #312E81 100%);
}

body.theme-nature {
    --primary-color: #2E7D32;
    --bg-color: #F1F8E9;
    --message-sent: #C8E6C9;
    --header-bg: linear-gradient(135deg, #2E7D32 0%, #43A047 100%);
}

body.theme-glass {
    --bg-color: #85a1ba;
    --card-bg: rgba(255, 255, 255, 0.2);
    --border-color: rgba(255, 255, 255, 0.3);
}

body.theme-glass .card {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Login screen always covers the full viewport including the fixed tab bar */
#loginScreen.active {
    position: fixed;
    inset: 0;
    z-index: 500;
    overflow-y: auto;
    background: linear-gradient(160deg, #EEF2FF 0%, #E0E7FF 50%, #C7D2FE 100%);
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Logo */
.logo {
    margin-bottom: 20px;
    animation: fadeInDown 0.6s ease;
}

.logo-small {
    margin-bottom: 15px;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--success-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    margin-bottom: 20px;
    animation: scaleIn 0.5s ease;
}

h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 10px;
}

h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 30px;
    text-align: center;
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    width: 100%;
    max-width: 400px;
    animation: fadeInUp 0.6s ease;
}

.dashboard-container {
    padding: 20px;
}

.section-header {
    margin: 30px 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 8px 0;
}

.btn-primary {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: scale(0.98);
    background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

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

.btn-secondary:active {
    transform: scale(0.98);
    background: #5A6268;
}

.btn-danger:active {
    transform: scale(0.98);
    background: #C82333;
}

.btn-large {
    padding: 20px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    border: none;
    margin-left: 10px;
    cursor: pointer;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
    transition: transform 0.2s;
}

.icon-btn:active {
    transform: scale(0.9);
}

/* Input */
input[type="text"],
input[type="email"] {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    margin: 8px 0;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.otp-field {
    text-align: center;
    letter-spacing: 8px;
    font-size: 24px;
    font-weight: bold;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    margin-top: 10px;
    cursor: pointer;
    text-decoration: underline;
}

.theme-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
}

/* Divider */
.divider {
    text-align: center;
    color: var(--text-secondary);
    margin: 20px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

/* Family Code Display */
.family-code {
    background: var(--bg-color);
    border: 3px dashed var(--primary-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--primary-color);
    margin: 20px 0;
    font-family: 'Courier New', monospace;
}

.hint {
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
    margin: 15px 0;
}

/* Chat Screen */
#chatScreen {
    background: var(--bg-color);
    height: 100dvh;
    min-height: 0; /* überschreibt .screen { min-height: 100vh } */
    overflow: hidden;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}

#dashboardScreen {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* Tab Bar */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    z-index: 200;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    gap: 3px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 0 0 4px 4px;
}

.tab-btn svg {
    stroke: currentColor;
}

#dashboardScreen .chat-list {
    padding-bottom: 70px;
}

.chat-header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 12px 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;       /* schrumpft nie → immer sichtbar */
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.family-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.family-code-small {
    font-size: 11px;
    opacity: 0.8;
    font-family: 'Courier New', monospace;
}

.chat-header .icon-btn {
    color: white;
}

/* Messages Container */
.messages-container {
    flex: 1;
    min-height: 0;         /* ermöglicht echtes Schrumpfen im Flex-Layout */
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: fadeIn 0.3s ease;
}

.message.sent {
    align-self: flex-end;
}

.message.received {
    align-self: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.sent .message-bubble {
    background: var(--message-sent);
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: var(--message-received);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 4px;
    padding: 0 4px;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
}

.message-time {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: right;
}

.message-photo {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
    cursor: pointer;
}

.date-separator {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    margin: 16px 0;
    align-self: center;
}

.missed-call-msg {
    text-align: center;
    margin: 8px 0;
    align-self: center;
}
.missed-call-bubble {
    display: inline-block;
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
    font-size: 12px;
    padding: 3px 12px;
    border-radius: 10px;
}

/* Chat Search Bar */
.chat-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(0,0,0,0.15);
    animation: slideDown 0.2s ease-out;
}
@keyframes slideDown {
    from { transform: translateY(-8px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.chat-search-input {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 14px;
    background: rgba(255,255,255,0.9);
    color: #333;
    outline: none;
}

/* Search results panel */
.search-results-panel {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    max-height: 260px;
    overflow-y: auto;
    z-index: 10;
}
.search-result-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 8px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s;
}
.search-result-item:hover { background: var(--hover-color, rgba(0,0,0,0.04)); }
.search-result-name { font-size: 13px; font-weight: 600; color: var(--primary-color); grid-column: 1; }
.search-result-time { font-size: 11px; color: var(--text-secondary); grid-column: 2; grid-row: 1 / 3; align-self: center; }
.search-result-text { font-size: 13px; color: var(--text-primary); grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-text mark { background: rgba(255,210,0,0.5); border-radius: 2px; }
.search-no-results { padding: 16px; text-align: center; color: var(--text-secondary); font-size: 14px; }

/* Chat Input */
.chat-input-container {
    display: flex;
    flex-direction: column;
    padding: 6px 12px 8px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    gap: 4px;
    flex-shrink: 0;
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#messageInput {
    flex: 1;
    width: 100%;
    margin: 0;
    border-radius: 18px;
    padding: 9px 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    overflow-y: hidden;
    max-height: 120px;
    outline: none;
    box-sizing: border-box;
    display: block;
}
#messageInput:focus {
    border-color: var(--primary-color);
    overflow-y: auto;
}

.send-btn {
    color: var(--primary-color);
    font-size: 28px;
}

.send-btn:disabled {
    opacity: 0.4;
}

/* Menu Overlay */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: flex-end;
}

.overlay.active {
    display: flex;
}

.menu-content {
    background: white;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    animation: slideUp 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.menu-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-item:last-of-type {
    border-bottom: none;
}

/* Family List */
.family-list {
    width: 100%;
    margin-bottom: 20px;
}

.family-item {
    padding: 15px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.family-item:active {
    transform: scale(0.98);
}

.family-name {
    font-weight: 600;
}

.family-id {
    font-size: 10px;
    color: var(--text-secondary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Scrollbar */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 3px;
    overflow-y: auto;
    height: calc(100vh - 60px);
}

.gallery-item {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.2s;
}

.gallery-item:hover {
    opacity: 0.8;
}

/* Video Call Overlay */
.call-overlay {
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 2000;
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.call-overlay.active {
    display: flex;
}

.call-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 20px;
    position: relative;
}

.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.local-video {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 120px;
    height: 160px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid white;
    background: #333;
}

.call-info {
    position: relative;
    z-index: 10;
    text-align: center;
    margin-top: 60px;
}

.call-controls,
.incoming-controls {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 40px;
}

.call-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(5px);
    transition: background 0.3s;
}

.call-btn.btn-danger {
    background: #DC3545;
}

.call-btn.btn-success {
    background: #28A745;
}

.call-btn:active {
    transform: scale(0.9);
}

.call-btn .icon {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.member-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.member-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image Preview Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.image-modal.active {
    display: flex;
}

.image-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-modal-content img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    touch-action: pinch-zoom;
    user-select: none;
}

.close-modal-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 32px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.close-modal-btn:active {
    transform: scale(0.9);
}

/* Voice Message Recording */
.recording-indicator {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--primary-color);
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    border-radius: 20px 20px 0 0;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: #ff4444;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.recording-time {
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.message-audio {
    width: 250px;
    margin: 5px 0;
}

.message-audio audio {
    width: 100%;
    height: 32px;
}

/* Read Receipts */
.read-receipt {
    font-size: 11px;
    margin-left: 5px;
    color: rgba(255, 255, 255, 0.6);
}

.read-receipt.read {
    color: #4fc3f7;
}

/* Profile Pictures */
.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 10px auto;
    display: block;
    cursor: pointer;
    border: 3px solid var(--primary-color);
}

.avatar-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    margin-right: 8px;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 5px;
    padding: 10px;
    overflow-y: auto;
    height: calc(100vh - 60px);
}

.gallery-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.gallery-item:active img {
    transform: scale(0.95);
}

/* WhatsApp-style Chat List (Dashboard) */
.chat-list {
    flex: 1;
    overflow-y: auto;
    background: var(--card-bg);
}

.chat-list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    gap: 14px;
    transition: background 0.15s;
}

.chat-list-item:active {
    background: var(--bg-color);
}

.chat-avatar {
    position: relative;
    flex-shrink: 0;
}

.chat-avatar-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
}

.chat-avatar-circle.group {
    background: #25D366;
    font-size: 26px;
}

.online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #bbb;
    border: 2px solid var(--card-bg);
}

.online-dot.online {
    background: #25D366;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.unread-badge {
    background: #e53935;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.member-call-actions {
    display: flex;
    gap: 6px;
}

.member-call-actions .action-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 0;
}

.typing-indicator span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Missing btn-danger base */
.btn-danger {
    background: var(--danger-color);
    color: white;
}

/* Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
}

.reaction-badge {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 12px;
    cursor: pointer;
}

.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border-radius: 20px;
    padding: 5px 10px;
    display: flex;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 100;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from {
        transform: scale(0.5) translateY(10px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.reaction-option {
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.1s;
}

.reaction-option:active {
    transform: scale(1.4);
}

/* Message context menu (long-press / right-click) */
.msg-context-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 101;
    animation: popIn 0.15s ease-out;
    min-width: 140px;
}
.msg-context-menu button {
    background: none;
    border: none;
    padding: 8px 12px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-primary);
}
.msg-context-menu button:hover { background: var(--hover-color, rgba(0,0,0,0.06)); }
.msg-context-menu .msg-ctx-delete { color: #dc3545; }

/* Pinned message banner */
.pinned-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--primary-color);
    color: #fff;
    font-size: 13px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}
.pinned-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pinned-unpin-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    opacity: 0.8;
}
.pinned-unpin-btn:hover { opacity: 1; }

/* Deleted message placeholder */
.message-deleted {
    color: var(--text-secondary) !important;
    font-style: italic;
    opacity: 0.6;
}

/* Edited indicator */
.message-edited {
    font-size: 10px;
    opacity: 0.6;
    font-style: italic;
    margin-left: 4px;
}

/* ── Poll Bubble ──────────────────────────────────────────────────────────── */
.poll-bubble {
    min-width: 220px;
    max-width: 320px;
}
.poll-question {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    line-height: 1.3;
}
.poll-option-btn {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 6px;
    padding: 8px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
    overflow: hidden;
    text-align: left;
    font-size: 13px;
    color: var(--text-primary);
    transition: border-color 0.15s;
}
.poll-option-btn.poll-voted {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.08);
}
.poll-option-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: rgba(74, 144, 226, 0.15);
    transition: width 0.3s ease;
    border-radius: 6px 0 0 6px;
}
.poll-option-text {
    position: relative;
    flex: 1;
    z-index: 1;
}
.poll-option-pct {
    position: relative;
    z-index: 1;
    font-size: 11px;
    opacity: 0.7;
    margin-left: 8px;
    flex-shrink: 0;
}
.poll-total {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

/* Poll Modal */
.poll-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.poll-modal {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    width: min(380px, 90vw);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.poll-modal h3 { margin: 0 0 4px; font-size: 16px; }
.poll-modal-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    box-sizing: border-box;
}
.poll-modal-input:focus { border-color: var(--primary-color); }
.poll-add-opt-btn {
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
}
.poll-multi-label {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.poll-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}
.poll-cancel-btn, .poll-submit-btn {
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    cursor: pointer;
}
.poll-cancel-btn { background: var(--bg-secondary); color: var(--text-secondary); }
.poll-submit-btn { background: var(--primary-color); color: #fff; }

/* ── Notizen ──────────────────────────────────────────────────────────────── */
#notizenScreen {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.notes-grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    align-content: start;
}
.notes-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 14px;
    line-height: 1.6;
}
.note-card {
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    min-height: 100px;
    position: relative;
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
    transition: transform 0.12s, box-shadow 0.12s;
    overflow: hidden;
}
.note-card:active { transform: scale(0.97); }
.note-card.note-dark .note-card-title,
.note-card.note-dark .note-card-snippet,
.note-card.note-dark .note-card-meta { color: #fff; }
.note-pin-icon {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 12px;
    opacity: 0.7;
}
.note-card-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 5px;
    line-height: 1.3;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-card-snippet {
    font-size: 12px;
    color: #444;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.note-card-meta {
    font-size: 10px;
    color: #888;
    margin-top: 8px;
}

/* Note Editor Overlay */
.note-editor-overlay {
    position: absolute;
    inset: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    z-index: 100;
}
.note-editor-overlay.visible {
    transform: translateX(0);
}
.note-editor-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.note-editor-colors {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
}
.note-color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    transition: transform 0.1s;
}
.note-color-swatch.active {
    border-color: var(--primary-color);
    transform: scale(1.2);
}
.note-editor-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.note-editor-title {
    font-size: 18px;
    font-weight: 600;
    padding: 14px 16px 6px;
    border: none;
    outline: none;
    background: transparent;
    color: inherit;
    width: 100%;
    box-sizing: border-box;
}
.note-editor-content {
    flex: 1;
    padding: 6px 16px 16px;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.6;
    background: transparent;
    color: inherit;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

/* Tab-Bar: 6 Tabs – etwas kompakter */
.tab-bar .tab-btn span {
    font-size: 9px;
}

/* Inline edit input */
.message-edit-input {
    width: 100%;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 14px;
    background: var(--surface-color);
    color: var(--text-primary);
    outline: none;
}
.message-edit-save, .message-edit-cancel {
    border: none;
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 4px;
}
.message-edit-save { background: var(--primary-color); color: #fff; }
.message-edit-cancel { background: var(--border-color); color: var(--text-primary); }

/* ── Haushaltsbuch ─────────────────────────────────────────────────────────── */

#haushaltsbuchScreen {
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--bg-color);
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}

.hb-month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hb-month-label {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    min-width: 130px;
    text-align: center;
}

.hb-month-btn {
    background: rgba(255,255,255,0.25);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Total bar */
.hb-total-bar {
    display: flex;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.hb-total-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
}

.hb-total-block:first-child {
    border-right: 1px solid var(--border-color);
}

.hb-total-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.hb-total-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-color);
}

/* Add form */
.hb-form {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

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

.hb-form-input {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
}
.hb-form-input:focus {
    border-color: var(--primary-color);
}

.hb-form-desc { flex: 1; }
.hb-form-amount { width: 100px; }
.hb-form-date { flex: 1; }

.hb-form-submit {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

/* List */
.hb-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.hb-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px 20px;
    font-size: 14px;
}

.hb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-color);
}

.hb-item-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.hb-item-info {
    flex: 1;
    min-width: 0;
}

.hb-item-reason {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.hb-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
    display: block;
}

.hb-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.hb-item-amount {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.hb-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #DC3545;
    font-size: 12px;
    padding: 4px 6px;
    border-radius: 6px;
    opacity: 0.5;
}

/* ── Budget-Limits ────────────────────────────────────────────────────────── */

.hb-budget-bar {
    padding: 8px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}
.hb-budget-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.hb-budget-label { font-size: 13px; color: var(--text-secondary); }
.hb-budget-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 2px 6px;
}
.hb-budget-progress-track {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}
.hb-budget-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease, background 0.3s ease;
}
.hb-budget-edit {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

/* ── Wiederkehrende Ausgaben ──────────────────────────────────────────────── */

.hb-recurring-panel {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 16px;
    animation: slideDown 0.2s ease;
}
.hb-rec-list {
    margin-bottom: 10px;
}
.hb-rec-empty {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 0 4px;
}
.hb-rec-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}
.hb-rec-item:last-child { border-bottom: none; }
.hb-rec-item.hb-rec-inactive { opacity: 0.45; }
.hb-rec-info { flex: 1; min-width: 0; }
.hb-rec-reason {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hb-rec-meta {
    font-size: 11px;
    color: var(--text-secondary);
}
.hb-rec-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.hb-rec-toggle, .hb-rec-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: background 0.15s;
}
.hb-rec-toggle:hover { background: var(--bg-secondary); }
.hb-rec-delete:hover { color: #dc3545; background: rgba(220,53,69,0.08); }
.hb-rec-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}
.hb-recur-badge {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.7;
}

/* ── Haushaltsbuch Stats ──────────────────────────────────────────────────── */

.hb-stats-panel {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    animation: slideDown 0.2s ease;
}

.hb-stats-section {
    margin-bottom: 20px;
}

.hb-stats-section:last-child {
    margin-bottom: 0;
}

.hb-stats-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px;
}

.hb-bar-chart {
    overflow-x: auto;
}

.hb-bar-svg {
    display: block;
    overflow: visible;
}

.hb-bar-val {
    font-size: 9px;
    fill: var(--text-secondary);
    font-family: inherit;
}

.hb-bar-label {
    font-size: 10px;
    fill: var(--text-secondary);
    font-family: inherit;
}

.hb-pie-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

#hbPieChart {
    flex-shrink: 0;
    border-radius: 50%;
}

.hb-pie-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}

.hb-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.hb-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.hb-legend-label {
    flex: 1;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 90px;
}

.hb-legend-pct {
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 30px;
    text-align: right;
}

.hb-legend-amt {
    color: var(--text-secondary);
    font-size: 11px;
    min-width: 55px;
    text-align: right;
}

.hb-stats-empty {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 12px 0;
}

/* ── Kalender ──────────────────────────────────────────────────────────────── */

#kalenderScreen {
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--bg-color);
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}

/* Month grid */
.cal-grid-wrap {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    padding: 8px 8px 10px;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 4px;
}

.cal-weekdays span {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 2px 0;
    text-transform: uppercase;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 4px;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: background 0.1s;
    overflow: hidden;
}
.cal-cell:active { background: var(--border-color); }

.cal-cell-empty { cursor: default; }

.cal-day-num {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1;
    flex-shrink: 0;
}

.cal-today .cal-day-num {
    color: var(--primary-color);
    font-weight: 700;
}

.cal-selected {
    background: var(--primary-color) !important;
}
.cal-selected .cal-day-num {
    color: #fff !important;
}

.cal-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary-color);
    margin-top: 2px;
}
.cal-selected .cal-dot {
    background: rgba(255,255,255,0.8);
}
.cal-birthday-dot {
    font-size: 9px;
    line-height: 1;
    margin-top: 1px;
}
.cal-birthday-item .cal-ev-dot {
    background: #FF69B4;
}

/* Day panel */
.cal-day-panel {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cal-day-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.cal-day-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cal-no-events {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 0;
}

.cal-event-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--card-bg);
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
}

.cal-ev-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
}

.cal-ev-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cal-ev-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.cal-ev-time {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 500;
}

.cal-ev-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.cal-ev-who {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.cal-ev-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.cal-ev-delete, .cal-ev-edit {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 0 3px;
    flex-shrink: 0;
}
.cal-ev-delete:hover { color: #DC3545; }
.cal-ev-edit:hover   { color: var(--primary); }

/* Add bar (now just a button wrapper) */
.cal-add-bar {
    padding: 10px 12px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.cal-open-modal-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.2px;
}
.cal-open-modal-btn:active { opacity: 0.85; }

.cal-recurrence-select {
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 6px;
    height: 38px;
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
    cursor: pointer;
}
.cal-recurrence-select:focus { border-color: var(--primary-color); }

.cal-ev-recur {
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.7;
}

/* Multi-day event bars */
.cal-multiday-bar {
    display: flex;
    align-items: center;
    height: 13px;
    margin-top: 1px;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    font-size: 8px;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
    flex-shrink: 0;
    border-radius: 0;
}
.cal-bar-start {
    border-radius: 5px 0 0 5px;
    padding-left: 3px;
    margin-left: 2px;
    width: calc(100% - 2px);
}
.cal-bar-end {
    border-radius: 0 5px 5px 0;
    margin-right: 2px;
    width: calc(100% - 2px);
}
.cal-bar-single {
    border-radius: 5px;
    padding: 0 3px;
    margin: 0 2px;
    width: calc(100% - 4px);
}
.cal-bar-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-in-range {
    background: rgba(74, 144, 226, 0.07);
}

/* NRW Feiertage + Schulferien */
.cal-feiertag { background: #FFCDD2; }
.cal-feiertag .cal-day-num { color: #C62828; font-weight: 700; }
.cal-schulferien { background: #FCE4EC; }
.cal-schulferien .cal-day-num { color: #AD1457; }
.cal-holiday-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin: 4px 0 2px;
}
.cal-feiertag-banner { background: #FFCDD2; color: #C62828; }
.cal-schulferien-banner { background: #FCE4EC; color: #AD1457; }

.cal-ev-daterange {
    font-size: 11px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 1px;
}

/* Calendar Event Modal */
.cal-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.cal-modal-sheet {
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    padding: 20px 16px 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
.cal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.cal-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}
.cal-modal-close {
    background: var(--border-color);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Type chips */
.cal-type-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.cal-type-chip {
    flex: 1;
    padding: 8px 4px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.cal-type-chip.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
}
/* Modal inputs */
.cal-modal-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
    box-sizing: border-box;
    margin-bottom: 12px;
}
.cal-modal-input:focus { border-color: var(--primary-color); }
.cal-modal-dates {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.cal-modal-date-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cal-modal-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cal-modal-date {
    width: 100%;
    padding: 10px 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
    box-sizing: border-box;
}
.cal-modal-date:focus { border-color: var(--primary-color); }
.cal-modal-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.cal-modal-time {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
}
.cal-modal-time:focus { border-color: var(--primary-color); }
.cal-modal-save {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.cal-modal-save:active { opacity: 0.85; }

.cal-add-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--primary-color);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Einkaufsliste ──────────────────────────────────────────────────────────── */

#einkaufslisteScreen {
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-color);
}

.sh-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 8px 0;
}

.sh-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 15px;
}

.sh-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: opacity 0.2s;
}

.sh-item.sh-checked {
    opacity: 0.45;
}

.sh-checkbox {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    transition: border-color 0.15s;
}

.sh-checked .sh-checkbox {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: white;
}

.sh-item-body {
    flex: 1;
    min-width: 0;
}

.sh-item-title {
    display: block;
    font-size: 15px;
    color: var(--text-primary);
}

.sh-checked .sh-item-title {
    text-decoration: line-through;
}

.sh-item-meta {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.sh-delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    opacity: 0.6;
    flex-shrink: 0;
}

.sh-delete-btn:hover { opacity: 1; }

.sh-add-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px calc(10px + 60px + env(safe-area-inset-bottom, 0px));
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sh-add-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.sh-add-input:focus { border-color: var(--accent-color); }

.sh-add-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    font-size: 22px;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── In-App Toast ──────────────────────────────────────────────────────────── */
.hb-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 240px;
    max-width: 320px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s ease;
}
.hb-toast.hb-toast-show {
    transform: translateX(-50%) translateY(0);
}
.hb-toast strong {
    font-size: 13px;
    color: var(--text-primary);
}
.hb-toast span {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Aufgaben-Liste ───────────────────────────────────────────────────────── */
.task-list {
    padding: 12px 16px 80px;
    overflow-y: auto;
    flex: 1;
}
.task-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 15px;
}
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: opacity 0.2s;
}
.task-item.task-done {
    opacity: 0.55;
}
.task-check-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 18px;
    line-height: 1;
}
.task-check-circle {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
}
.task-check-done {
    display: inline-block;
    width: 20px;
    height: 20px;
    background: var(--success-color);
    border-radius: 50%;
    color: #fff;
    font-size: 13px;
    text-align: center;
    line-height: 20px;
}
.task-content {
    flex: 1;
    min-width: 0;
}
.task-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    display: block;
}
.task-item.task-done .task-title {
    text-decoration: line-through;
    color: var(--text-secondary);
}
.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
    align-items: center;
}
.task-meta-tag {
    font-size: 11px;
    background: var(--bg-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 2px 7px;
}
.task-prio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.task-prio-high   { background: #dc3545; }
.task-prio-medium { background: #fd7e14; }
.task-prio-low    { background: #28a745; }
.task-done-label {
    font-size: 11px;
    color: var(--success-color);
    margin-top: 4px;
    display: block;
}
.task-done-divider {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 10px 0 6px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}
.task-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    padding: 4px;
    flex-shrink: 0;
    opacity: 0.6;
}
.task-delete-btn:hover { opacity: 1; color: var(--danger-color); }

/* Task Modal */
.task-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.task-modal {
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 32px;
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.task-modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.task-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 14px;
}
.task-modal-btns {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

/* Tab-Bar: 7 Tabs – noch kompakter */
.tab-bar .tab-btn span {
    font-size: 8px;
}
.tab-bar .tab-btn svg {
    width: 20px;
    height: 20px;
}

/* Ausgaben-Kategorie-Badge */
.hb-cat-badge {
    display: inline-block;
    font-size: 10px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 5px;
    padding: 1px 5px;
    margin-left: 5px;
    vertical-align: middle;
    opacity: 0.85;
}

/* ── RSVP-Buttons im Kalender ──────────────────────────────────────────────── */
.cal-ev-rsvp {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.cal-rsvp-btn {
    font-size: 11px;
    padding: 3px 9px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
}
.cal-rsvp-btn.active.yes   { background: #4CAF50; border-color: #4CAF50; color: #fff; }
.cal-rsvp-btn.active.maybe { background: #FF9800; border-color: #FF9800; color: #fff; }
.cal-rsvp-btn.active.no    { background: #F44336; border-color: #F44336; color: #fff; }
.cal-ev-rsvp-summary {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 3px;
    display: block;
}

/* ── Notiz-Versionshistorie ────────────────────────────────────────────────── */
.note-version-item {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
}
.note-version-item:last-child { border-bottom: none; }
.note-version-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.note-version-snippet {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-version-restore {
    font-size: 12px;
    padding: 4px 10px;
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
}
.task-modal-cancel {
    padding: 8px 18px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
}

/* ── Galerie Filter ────────────────────────────────────────────────────────── */
.gallery-filter-bar {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.gallery-filter-chip {
    white-space: nowrap;
    padding: 5px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
}
.gallery-filter-chip.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.gallery-item-wrap {
    display: flex;
    flex-direction: column;
}
.gallery-item-meta {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 2px 4px 6px;
    text-align: center;
}
.gallery-audio-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}
.gallery-audio-icon { font-size: 24px; flex-shrink: 0; }
.gallery-audio-info { flex: 1; min-width: 0; }
.gallery-file-link {
    font-size: 13px;
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
}

/* ── Settings Menu Redesign ────────────────────────────────────────────────── */
.settings-menu {
    padding: 0 !important;
    overflow-y: auto;
    max-height: 100dvh;
}
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}
.settings-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}
.settings-close-btn {
    font-size: 18px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
}
.settings-section {
    padding: 12px 20px 4px;
    border-bottom: 1px solid var(--border-color);
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.settings-profile-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 14px;
}
.settings-avatar-wrap {
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}
.settings-avatar-edit {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-profile-info {
    display: flex;
    flex-direction: column;
}
.settings-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 10px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-col {
    flex-direction: column;
    align-items: flex-start;
}
.settings-row-label {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    flex-shrink: 0;
}
.settings-input {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 13px;
}
.settings-select {
    padding: 6px 10px !important;
    font-size: 13px !important;
}
.settings-danger-btn {
    width: 100%;
    padding: 11px;
    margin: 8px 20px;
    width: calc(100% - 40px);
    border: 1.5px solid #dc3545;
    border-radius: 10px;
    background: transparent;
    color: #dc3545;
    font-size: 14px;
    cursor: pointer;
}
