/* Telegram Night palette. Light theme and saved user colors remain in app.css / appearance settings. */
:root.dark {
    color-scheme: dark;
    --sosedi-dark-page: #0e1621;
    --sosedi-dark-surface: #17212b;
    --sosedi-dark-raised: #232e3c;
    --sosedi-dark-border: #2b3948;
    --sosedi-dark-text: #f0f2f5;
    --sosedi-dark-muted: #98a7b7;
    --sosedi-dark-accent: #6ab2f2;
    --sosedi-dark-chat-link: #a9d7ff;
    --sosedi-dark-chat-meta: #c3d3e0;
    --sosedi-dark-button: #3478b8;
    --sosedi-dark-danger: #ff7c7c;
    --sosedi-dark-glass: rgba(23, 33, 43, 0.94);
    --sosedi-dark-wallpaper-shade: rgba(14, 22, 33, 0.87);
    --sosedi-dark-chat-blue: #2b5278;
    --sosedi-dark-chat-red: #633b47;
    --sosedi-dark-chat-pink: #573d5c;
    --sosedi-dark-chat-purple: #45486c;
    --sosedi-dark-chat-sky: #304a68;
    --sosedi-dark-chat-teal: #28575b;
    --sosedi-dark-chat-green: #355947;
    --sosedi-dark-chat-olive: #53593b;
    --sosedi-dark-chat-sent: var(--sosedi-dark-chat-blue);

    --f7-theme-color: var(--sosedi-dark-accent);
    --f7-theme-color-rgb: 106, 178, 242;
    --f7-theme-color-shade: #4d9dde;
    --f7-theme-color-tint: #89c4f5;
    --f7-text-color: var(--sosedi-dark-text);
    --f7-text-color-secondary: var(--sosedi-dark-muted);
    --f7-page-bg-color: var(--sosedi-dark-page);
    --f7-bars-bg-color: var(--sosedi-dark-surface);
    --f7-bars-bg-color-rgb: 23, 33, 43;
    --f7-bars-text-color: var(--sosedi-dark-text);
    --f7-bars-border-color: var(--sosedi-dark-border);
    --f7-navbar-bg-color: var(--sosedi-dark-surface);
    --f7-navbar-bg-color-rgb: 23, 33, 43;
    --f7-navbar-link-color: var(--sosedi-dark-text);
    --f7-toolbar-bg-color: var(--sosedi-dark-surface);
    --f7-toolbar-bg-color-rgb: 23, 33, 43;
    --f7-tabbar-link-active-color: var(--sosedi-dark-accent);
    --f7-tabbar-link-inactive-color: var(--sosedi-dark-muted);
    --f7-glass-bg-color: var(--sosedi-dark-glass);
    --f7-glass-shadow: 0 2px 16px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    --f7-glass-shadow-thumb: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    --f7-list-bg-color: var(--sosedi-dark-surface);
    --f7-list-strong-bg-color: var(--sosedi-dark-surface);
    --f7-list-item-border-color: var(--sosedi-dark-border);
    --f7-list-item-text-text-color: var(--sosedi-dark-muted);
    --f7-list-item-after-text-color: var(--sosedi-dark-muted);
    --f7-list-item-footer-text-color: var(--sosedi-dark-muted);
    --f7-list-item-header-text-color: var(--sosedi-dark-muted);
    --f7-list-link-pressed-bg-color: var(--sosedi-dark-raised);
    --f7-list-group-title-bg-color: var(--sosedi-dark-page);
    --f7-list-group-title-text-color: var(--sosedi-dark-muted);
    --f7-card-bg-color: var(--sosedi-dark-surface);
    --f7-card-header-text-color: var(--sosedi-dark-text);
    --f7-card-footer-text-color: var(--sosedi-dark-muted);
    --f7-block-strong-bg-color: var(--sosedi-dark-surface);
    --f7-block-title-text-color: var(--sosedi-dark-muted);
    --f7-login-screen-content-bg-color: var(--sosedi-dark-page);
    --f7-input-text-color: var(--sosedi-dark-text);
    --f7-input-placeholder-color: var(--sosedi-dark-muted);
    --f7-input-info-text-color: var(--sosedi-dark-muted);
    --f7-input-clear-button-color: var(--sosedi-dark-muted);
    --f7-label-text-color: var(--sosedi-dark-muted);
    --f7-searchbar-input-bg-color: var(--sosedi-dark-raised);
    --f7-searchbar-input-text-color: var(--sosedi-dark-text);
    --f7-searchbar-input-placeholder-color: var(--sosedi-dark-muted);
    --f7-searchbar-input-border-color: var(--sosedi-dark-border);
    --f7-button-fill-bg-color: var(--sosedi-dark-button);
    --f7-button-fill-pressed-bg-color: #28679f;
    --f7-button-fill-text-color: #fff;
    --f7-segmented-strong-bg-color: var(--sosedi-dark-surface);
    --f7-segmented-strong-button-text-color: var(--sosedi-dark-muted);
    --f7-segmented-strong-button-active-text-color: var(--sosedi-dark-text);
    --f7-segmented-strong-button-active-bg-color: var(--sosedi-dark-raised);
    --f7-dialog-bg-color: var(--sosedi-dark-glass);
    --f7-dialog-text-color: var(--sosedi-dark-text);
    --f7-dialog-input-bg-color: var(--sosedi-dark-page);
    --f7-dialog-input-text-color: var(--sosedi-dark-text);
    --f7-dialog-input-placeholder-color: var(--sosedi-dark-muted);
    --f7-actions-bg-color: var(--sosedi-dark-glass);
    --f7-actions-button-pressed-bg-color: var(--sosedi-dark-raised);
    --f7-actions-label-text-color: var(--sosedi-dark-muted);
    --f7-sheet-bg-color: var(--sosedi-dark-surface);
    --f7-popover-bg-color: var(--sosedi-dark-surface);
    --f7-toast-bg-color: var(--sosedi-dark-raised);
    --f7-toast-text-color: var(--sosedi-dark-text);
    --f7-messagebar-bg-color: var(--sosedi-dark-surface);
    --f7-messagebar-bg-color-rgb: 23, 33, 43;
    --f7-messagebar-sheet-bg-color: var(--sosedi-dark-surface);
    --f7-messagebar-textarea-bg-color: var(--sosedi-dark-raised);
    --f7-messagebar-textarea-text-color: var(--sosedi-dark-text);
    --f7-messagebar-textarea-placeholder-color: var(--sosedi-dark-muted);
    --f7-message-received-bg-color: var(--sosedi-dark-surface);
    --f7-message-sent-bg-color: var(--sosedi-dark-chat-sent);
    --f7-message-received-text-color: var(--sosedi-dark-text);
    --f7-message-sent-text-color: var(--sosedi-dark-text);
    --f7-message-text-header-text-color: var(--sosedi-dark-chat-link);
    --f7-message-text-header-opacity: 1;
    --f7-message-text-footer-text-color: var(--sosedi-dark-chat-meta);
    --f7-message-text-footer-opacity: 1;
    --f7-message-name-text-color: var(--sosedi-dark-accent);
    --f7-message-footer-text-color: var(--sosedi-dark-muted);
    --f7-message-header-text-color: var(--sosedi-dark-muted);
    --f7-messages-title-text-color: var(--sosedi-dark-muted);
}

html.dark, html.dark body { background: var(--sosedi-dark-page); }

html.dark .list .item-title,
html.dark .block_messages_title_date .item-title,
html.dark .profile-gifts-title,
html.dark .settings-rewards-value,
html.dark .gift-card-name,
html.dark .simple-button,
html.dark .button_wrapper,
html.dark .similar_message a,
html.dark .popover-menu .list a,
html.dark .text-color-black { color: var(--sosedi-dark-text); }

html.dark .text-gray,
html.dark .profile_user_item,
html.dark .profile_user_last_online,
html.dark .settings-rewards-label,
html.dark .gift-card-price,
html.dark .gifts-empty-state,
html.dark .gift-recipient-empty,
html.dark .points-history-date small,
html.dark .points-history-empty,
html.dark .profile-gift-recipient,
html.dark .login-screen-agreement,
html.dark .login-screen-footer-copy,
html.dark .messages-navbar-preloader,
html.dark .message-local-sync-preloader,
html.dark .message-audio-time,
html.dark .messagebar-voice-recording-hint { color: var(--sosedi-dark-muted); }

html.dark .input-white,
html.dark .search-white {
    background: var(--sosedi-dark-raised) !important;
    color: var(--sosedi-dark-text) !important;
    border-color: var(--sosedi-dark-border) !important;
    box-shadow: none !important;
}

html.dark .button-gray,
html.dark .color-semi-black {
    color: var(--sosedi-dark-text) !important;
    border-color: var(--sosedi-dark-border) !important;
}

html.dark .profile-gifts-block,
html.dark .button_wrapper,
html.dark .page-profile .swiper-slide,
html.dark .profile-navbar-btn,
html.dark .accordion-item-content,
html.dark .profile_other_photo_wrapper {
    background: var(--sosedi-dark-surface);
    border-color: var(--sosedi-dark-border);
}

html.dark .profile-gift-sheet {
    --f7-sheet-bg-color: var(--sosedi-dark-surface);
    --f7-toolbar-bg-color: var(--sosedi-dark-surface);
}
html.dark .profile-gift-option,
html.dark .profile-gift-footer,
html.dark .settings-rewards-gifts,
html.dark .chat-document,
html.dark .document-draft-row { border-color: var(--sosedi-dark-border); }
html.dark .profile-gift-choice input:checked + .profile-gift-option {
    background: var(--sosedi-dark-chat-blue);
    border-color: var(--sosedi-dark-accent);
}
html.dark .button.profile-gift-close,
html.dark .profile-gift-count,
html.dark .gift-buy-button-unavailable {
    background: var(--sosedi-dark-raised);
    color: var(--sosedi-dark-muted);
    border-color: var(--sosedi-dark-border);
}

/* Dim the wallpaper itself, never the messages, media, avatars or controls above it. */
html.dark .messages-content {
    background-color: var(--sosedi-dark-page) !important;
    background-image: linear-gradient(var(--sosedi-dark-wallpaper-shade), var(--sosedi-dark-wallpaper-shade)),
        var(--sosedi-chat-wallpaper, url('../assets/backgrounds/bg_light_9.png')) !important;
    background-size: cover !important;
    background-position: center !important;
}
html.dark .message-received .message-bubble {
    background: var(--sosedi-dark-surface) !important;
    color: var(--sosedi-dark-text);
}
html.dark .message-sent .message-bubble {
    background: var(--sosedi-dark-chat-sent) !important;
    color: var(--sosedi-dark-text);
}
html.dark .message-text a,
html.dark .answer-to-user { color: var(--sosedi-dark-chat-link); }
html.dark .message-audio-time,
html.dark .message-local-sync-preloader,
html.dark .message-text-footer:has(.message-local-sync-failed) { color: var(--sosedi-dark-chat-meta); }
html.dark .answer-to-block { background: rgba(106, 178, 242, 0.1); border-color: var(--sosedi-dark-accent); }
html.dark .messagebar_answer_block { background: var(--sosedi-dark-surface); color: var(--sosedi-dark-text); }
html.dark .messagebar_answer_block .answer-to-block { background: var(--sosedi-dark-raised); }
html.dark .message-reaction {
    background: var(--sosedi-dark-raised);
    color: var(--sosedi-dark-text);
    border-color: var(--sosedi-dark-border);
}
html.dark .message-reaction-selected { background: var(--sosedi-dark-chat-blue); border-color: var(--sosedi-dark-accent); }
html.dark .message-reaction-picker { border-color: var(--sosedi-dark-border); }
html.dark .message-reaction-picker-selected,
html.dark .message-reaction-picker-button.active-state { background: var(--sosedi-dark-chat-blue); }
html.dark .messagebar a.link.not-selected,
html.dark .messagebar #messagebar_documents_link,
html.dark #messagebar_button_send[data-action="voice"],
html.dark #messagebar_files_link,
html.dark .messagebar-voice-recording-inner,
html.dark .dialog_scroll_down_button { color: var(--sosedi-dark-text); }
html.dark .dialog_scroll_down_button,
html.dark .pinned-message { background: var(--sosedi-dark-glass); border-color: var(--sosedi-dark-border); }
html.dark .group-dialog-invite .group-dialog-invite-close { background: var(--sosedi-dark-raised); color: var(--sosedi-dark-text); }
html.dark .avatar_online_status_dot { border-color: var(--sosedi-dark-surface); }
html.dark .badge.badge_channel { background: var(--sosedi-dark-raised); color: var(--sosedi-dark-text); }
html.dark .banner_page_messages_body,
html.dark .banner_invite_to_group { background: var(--sosedi-dark-raised); border-color: var(--sosedi-dark-border); }
html.dark .banner_invite_to_group .message-bubble { background: transparent !important; }
html.dark .video-draft-status { color: var(--sosedi-dark-muted); }
html.dark .video-draft-preview,
html.dark .video-draft-thumb { background: var(--sosedi-dark-raised); }
html.dark .video-draft-fallback { color: var(--sosedi-dark-muted); }
html.dark .chat-gallery-status,
html.dark .chat-gallery-retry,
html.dark .chat-gallery-save {
    background: var(--sosedi-dark-raised);
    color: var(--sosedi-dark-text);
    border-color: var(--sosedi-dark-border);
}
html.dark .setup-status.is-error { color: var(--sosedi-dark-danger); }
html.dark .document-file-icon { color: var(--sosedi-dark-accent); }
html.dark .document-file-icon[data-format="PDF"] { color: var(--sosedi-dark-danger); }
html.dark .document-file-icon[data-format="XLS"],
html.dark .document-file-icon[data-format="XLSX"] { color: #72cb99; }

html.dark #app .popup.launch-ad-popup,
html.dark .launch-ad-actions { background: var(--sosedi-dark-surface); color: var(--sosedi-dark-text); }
html.dark .launch-ad-header .launch-ad-close { background: var(--sosedi-dark-raised); color: var(--sosedi-dark-muted); }
html.dark .launch-ad-popup .launch-ad-progress { --f7-progressbar-bg-color: var(--sosedi-dark-border); }

/* The same eight saved swatches get dark counterparts; no server-side color migration. */
html.dark[data-chat-color="#ffe1e1"] { --sosedi-dark-chat-sent: var(--sosedi-dark-chat-red); }
html.dark[data-chat-color="#fee1ff"] { --sosedi-dark-chat-sent: var(--sosedi-dark-chat-pink); }
html.dark[data-chat-color="#e9e1ff"] { --sosedi-dark-chat-sent: var(--sosedi-dark-chat-purple); }
html.dark[data-chat-color="#e1ecff"] { --sosedi-dark-chat-sent: var(--sosedi-dark-chat-sky); }
html.dark[data-chat-color="#e1fffd"] { --sosedi-dark-chat-sent: var(--sosedi-dark-chat-teal); }
html.dark[data-chat-color="#e1ffe5"] { --sosedi-dark-chat-sent: var(--sosedi-dark-chat-green); }
html.dark[data-chat-color="#f9ffe1"] { --sosedi-dark-chat-sent: var(--sosedi-dark-chat-olive); }
html.dark .design_app_chat_color_item[data-color="#eeffe1"] { background: var(--sosedi-dark-chat-blue) !important; }
html.dark .design_app_chat_color_item[data-color="#ffe1e1"] { background: var(--sosedi-dark-chat-red) !important; }
html.dark .design_app_chat_color_item[data-color="#fee1ff"] { background: var(--sosedi-dark-chat-pink) !important; }
html.dark .design_app_chat_color_item[data-color="#e9e1ff"] { background: var(--sosedi-dark-chat-purple) !important; }
html.dark .design_app_chat_color_item[data-color="#e1ecff"] { background: var(--sosedi-dark-chat-sky) !important; }
html.dark .design_app_chat_color_item[data-color="#e1fffd"] { background: var(--sosedi-dark-chat-teal) !important; }
html.dark .design_app_chat_color_item[data-color="#e1ffe5"] { background: var(--sosedi-dark-chat-green) !important; }
html.dark .design_app_chat_color_item[data-color="#f9ffe1"] { background: var(--sosedi-dark-chat-olive) !important; }
html.dark .design_app_item { background-color: var(--sosedi-dark-wallpaper-shade); background-blend-mode: multiply; }
html.dark .design_app_item,
html.dark .design_app_chat_color_item { border-color: var(--sosedi-dark-border); }
html.dark .design_app_item.active,
html.dark .design_app_chat_color_item.active { border-color: var(--sosedi-dark-accent); }

/* Only monochrome UI assets. QR codes, photos, gifts and colored artwork keep their original pixels. */
html.dark .tab-link:not(.tab-link-active) .tabbar-icon,
html.dark img[src="assets/icons/more.svg"],
html.dark img[src="assets/icons/reply-icon.svg"],
html.dark img[src="assets/icons/copy-icon.svg"],
html.dark img[src="assets/icons/delete-icon.svg"],
html.dark img[src="assets/icons/delete_chat.svg"],
html.dark img[src="assets/icons/clear_chat.svg"],
html.dark img[src="assets/icons/pin.svg"],
html.dark img[src="assets/icons/mute.svg"] { filter: brightness(0) invert(0.75); }
html.dark img[src="assets/icons/edit-photo.svg"] { filter: invert(0.9); }
html.dark .profile_other_photo_add { filter: invert(0.75); }
html.dark .login-screen-title img { filter: brightness(1.5); }
