/* 321ConnectChat 2.4.6
   Tema chiaro/scuro applicato esclusivamente quando #chatScreen è visibile.
   La schermata scelta stanze e il pannello admin non vengono modificati. */

/* ---------------- Pulsante sole/luna ---------------- */
#chatThemeToggle.chat-theme-toggle {
  width: 76px !important;
  min-width: 76px !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 3px 6px !important;
  border: 1px solid #7698b5 !important;
  border-radius: 999px !important;
  background: linear-gradient(180deg, #f8fcff, #d5e7f5) !important;
  color: #315a79 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 4px !important;
  box-shadow: inset 0 1px rgba(255,255,255,.9), 0 1px 3px rgba(35,72,105,.18) !important;
  cursor: pointer !important;
  transition: background .2s ease, border-color .2s ease, color .2s ease !important;
}

.chat-theme-toggle .chat-theme-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.chat-theme-toggle .chat-theme-icon svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-theme-toggle .chat-theme-track {
  position: relative;
  width: 27px;
  height: 14px;
  flex: 0 0 27px;
  border-radius: 999px;
  background: #92abc0;
  box-shadow: inset 0 1px 3px rgba(31,61,87,.28);
  transition: background .2s ease;
}

.chat-theme-toggle .chat-theme-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.32);
  transition: transform .2s ease, background .2s ease;
}

html[data-chat-theme="dark"] .chat-theme-toggle .chat-theme-track {
  background: #3178b7;
}

html[data-chat-theme="dark"] .chat-theme-toggle .chat-theme-knob {
  transform: translateX(13px);
  background: #dcecff;
}

html[data-chat-theme="dark"] #chatThemeToggle.chat-theme-toggle {
  border-color: #4d6980 !important;
  background: linear-gradient(180deg, #26394b, #162434) !important;
  color: #dcecff !important;
  box-shadow: inset 0 1px rgba(255,255,255,.08), 0 1px 4px rgba(0,0,0,.35) !important;
}

/* ---------------- Tema scuro: solo chat ---------------- */
html.chat-theme-active[data-chat-theme="dark"] {
  color-scheme: dark;
  --text: #e7eef6;
  --panel: #1c2b39;
  --line: #3e5569;
  --accent: #56a9f2;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen {
  background: #0b121b !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row.has-secondary-strip-color,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row.has-secondary-strip-bg {
  border-top-color: #354d61 !important;
  border-bottom-color: #07101a !important;
  background: linear-gradient(180deg, #2c4153 0%, #162534 100%) !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row .module-icon-svg,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row button,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row a {
  color: #dce9f4 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row .toolbar-icon-btn:hover,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen > .module-row .module-icon:hover {
  background: rgba(111,181,238,.14) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .chat-frame {
  background: #0a1119 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .main-chat,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .side-panel {
  border-color: #344b5e !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .main-chat {
  background:
    linear-gradient(rgba(8,15,23,.86), rgba(8,15,23,.86)),
    var(--chat-background-image) !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .messages,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .main-chat .messages {
  background-color: rgba(8,15,23,.88) !important;
  background-image:
    linear-gradient(rgba(8,15,23,.78), rgba(8,15,23,.78)),
    var(--chat-background-image) !important;
  background-blend-mode: normal !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .message,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .message > div,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .message-body {
  color: #e7eef6;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .message.system {
  color: #74b9ff !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .chat-image {
  border-color: #4b6478 !important;
  background: #111b25 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-tabbar {
  border-bottom-color: #344b5e !important;
  background: linear-gradient(180deg, #263a4c, #152433) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-tab {
  border-color: #455f74 !important;
  background: #172533 !important;
  color: #dbe7f1 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-tab.active {
  border-color: #5aa7e6 !important;
  background: #254662 !important;
  color: #fff !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-tab.is-private-tab {
  border-color: #8a674d !important;
  background: #2b211b !important;
  color: #ffd5b7 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-tab.is-private-tab.active {
  border-color: #d08348 !important;
  background: #4a2d1c !important;
  color: #fff0e4 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-media-panel {
  border-color: #3b5265 !important;
  background: #172532 !important;
  color: #dbe7f1 !important;
}

/* Composer */
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .message-box,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .input-line,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .input-avatar {
  border-color: #344b5e !important;
  background: #101a24 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .toolbar-line {
  border-color: #344b5e !important;
  background: linear-gradient(180deg, #263a4c, #172635) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .tool-btn {
  color: #9acaf2 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .tool-btn.active,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .tool-btn:hover {
  color: #fff !important;
  background: #29445c !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen input,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen textarea,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen select {
  border-color: #42596c !important;
  background: #111c27 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen input::placeholder,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen textarea::placeholder {
  color: #8397a9 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen option {
  background: #111c27;
  color: #e7eef6;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .input-line textarea {
  border-left-color: #344b5e !important;
}

/* Pannello utenti, stanze e social */
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .side-panel {
  background: #111c27 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .me-card {
  border-bottom-color: #344b5e !important;
  background: #162432 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .credits-pill {
  border-color: #84682c !important;
  background: linear-gradient(135deg, #3b321e, #2a2419) !important;
  color: #f4d480 !important;
  box-shadow: inset 0 1px rgba(255,255,255,.06) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .side-tabs {
  border-color: #344b5e !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .side-tabs button {
  border-color: #344b5e !important;
  background: #1b2b39 !important;
  color: #b8cad9 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .side-tabs button.active {
  background: linear-gradient(180deg, #397cad, #235a83) !important;
  color: #fff !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #usersTab,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen #roomsTab,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen #friendsTab,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen #socialTab,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .users-list,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .rooms-list {
  color: #e7eef6 !important;
  background-color: #101a24 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #roomsTab::before {
  background: rgba(5,10,16,.56) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .user-item,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .friend-item {
  border-color: rgba(94,129,157,.55) !important;
  background: rgba(24,39,52,.88) !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .user-item:hover,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item:hover,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .friend-item:hover {
  border-color: #5e9fd1 !important;
  background: #20384d !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .user-media-badge {
  border-color: #49657b !important;
  background: #1c2d3c !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.28) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .side-panel-handle {
  border-color: #306fa2 !important;
  background: linear-gradient(#377fb5, #205a86) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .side-panel-backdrop {
  background: rgba(3,8,13,.72) !important;
}

/* Popup e finestre aperti dalla chat */
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal),
html.chat-theme-active[data-chat-theme="dark"] .floating-popup,
html.chat-theme-active[data-chat-theme="dark"] .options-popup,
html.chat-theme-active[data-chat-theme="dark"] .blacklist-popup,
html.chat-theme-active[data-chat-theme="dark"] .guest-menu-popup,
html.chat-theme-active[data-chat-theme="dark"] .user-action-popup,
html.chat-theme-active[data-chat-theme="dark"] .user-context-menu,
html.chat-theme-active[data-chat-theme="dark"] .avatar-window,
html.chat-theme-active[data-chat-theme="dark"] .gift-window,
html.chat-theme-active[data-chat-theme="dark"] .profile-window,
html.chat-theme-active[data-chat-theme="dark"] .edit-profile-window,
html.chat-theme-active[data-chat-theme="dark"] .about-window,
html.chat-theme-active[data-chat-theme="dark"] .share-window,
html.chat-theme-active[data-chat-theme="dark"] .ignore-notice-window,
html.chat-theme-active[data-chat-theme="dark"] .webcam-request-window,
html.chat-theme-active[data-chat-theme="dark"] .webcam-popup .webcam-window {
  border-color: #425a6d !important;
  background: #15222e !important;
  color: #e7eef6 !important;
  box-shadow: 0 6px 22px rgba(0,0,0,.48) !important;
}

html.chat-theme-active[data-chat-theme="dark"] .modal-title,
html.chat-theme-active[data-chat-theme="dark"] .popup-title,
html.chat-theme-active[data-chat-theme="dark"] .user-context-menu-header {
  border-color: #425a6d !important;
  background: linear-gradient(180deg, #344c60, #203443) !important;
  color: #fff !important;
}

html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) input,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) textarea,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) select,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup input,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup textarea,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup select {
  border-color: #425a6d !important;
  background: #0f1923 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .options-popup button,
html.chat-theme-active[data-chat-theme="dark"] .user-context-menu-option,
html.chat-theme-active[data-chat-theme="dark"] .guest-menu-popup button,
html.chat-theme-active[data-chat-theme="dark"] .user-action-popup button {
  color: #e0eaf2 !important;
  background: transparent !important;
  border-color: rgba(111,143,168,.25) !important;
}

html.chat-theme-active[data-chat-theme="dark"] .options-popup button:hover,
html.chat-theme-active[data-chat-theme="dark"] .user-context-menu-option:hover,
html.chat-theme-active[data-chat-theme="dark"] .guest-menu-popup button:hover,
html.chat-theme-active[data-chat-theme="dark"] .user-action-popup button:hover {
  background: #21394d !important;
}

html.chat-theme-active[data-chat-theme="dark"] .font-popup-body,
html.chat-theme-active[data-chat-theme="dark"] .font-panel,
html.chat-theme-active[data-chat-theme="dark"] .font-family-list,
html.chat-theme-active[data-chat-theme="dark"] .font-size-grid,
html.chat-theme-active[data-chat-theme="dark"] .font-preview,
html.chat-theme-active[data-chat-theme="dark"] .picker-popup,
html.chat-theme-active[data-chat-theme="dark"] .smiley-picker,
html.chat-theme-active[data-chat-theme="dark"] .gif-popup,
html.chat-theme-active[data-chat-theme="dark"] .youtube-popup {
  border-color: #425a6d !important;
  background: #15222e !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .font-family-list button,
html.chat-theme-active[data-chat-theme="dark"] .font-size-grid button,
html.chat-theme-active[data-chat-theme="dark"] .font-style-btn {
  border-color: #425a6d !important;
  background: #1c2d3b !important;
  color: #dce7ef !important;
}

/* Chat privata, compresa webcam privata */
html.chat-theme-active[data-chat-theme="dark"] .private-chat-window {
  border-color: #4a6072 !important;
  background: #111b25 !important;
  color: #e7eef6 !important;
  box-shadow: 0 8px 28px rgba(0,0,0,.58) !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-header {
  border-bottom-color: #425a6d !important;
  background: linear-gradient(180deg, #354e62, #203443) !important;
  color: #fff !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-title,
html.chat-theme-active[data-chat-theme="dark"] .private-chat-header-copy strong {
  color: #fff !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-btn {
  border-color: #5a7183 !important;
  background: rgba(13,24,34,.55) !important;
  color: #e8f0f7 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-toolbar {
  border-bottom-color: #3d5365 !important;
  background: linear-gradient(180deg, #263a4b, #172532) !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-window:not(.is-minimized) .private-chat-tool,
html.chat-theme-active[data-chat-theme="dark"] .private-chat-tool {
  border-color: #4a6174 !important;
  background: #1a2a38 !important;
  color: #dce7ef !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-window:not(.is-minimized) .private-chat-tool.is-active,
html.chat-theme-active[data-chat-theme="dark"] .private-chat-tool:hover {
  border-color: #5ba9e8 !important;
  background: #274762 !important;
  color: #fff !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-history {
  background: #0d1620 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-message-body {
  border-color: #40576a !important;
  background: #1b2b39 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-message.is-self .private-chat-message-body {
  border-color: #416c8d !important;
  background: linear-gradient(180deg, #284a64, #203b50) !important;
  color: #fff !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-form,
html.chat-theme-active[data-chat-theme="dark"] .private-chat-compose {
  border-color: #3d5365 !important;
  background: #111c27 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-chat-input,
html.chat-theme-active[data-chat-theme="dark"] .private-chat-form textarea,
html.chat-theme-active[data-chat-theme="dark"] .private-chat-form input {
  border-color: #425a6d !important;
  background: #0d1720 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-video-panel {
  border-color: #3f5668 !important;
  background: linear-gradient(180deg, #1c2b38, #121e29) !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-video-status {
  border-color: #425a6d !important;
  background: rgba(12,22,31,.86) !important;
  color: #c9d9e6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-video-invite-card {
  border-color: #4a6275 !important;
  background: #172532 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-video-invite-card strong {
  color: #eaf4fc !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-video-invite-card p {
  color: #b9cad8 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .private-video-controls button,
html.chat-theme-active[data-chat-theme="dark"] .private-video-invite-actions button.secondary {
  border-color: #4d6679 !important;
  background: linear-gradient(180deg, #263b4d, #192a38) !important;
  color: #e6eef5 !important;
}

/* Social interno alla chat */
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-composer,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-post,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-mini-popup,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-notif-dropdown,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-likers-modal {
  border-color: #40576a !important;
  background: #172532 !important;
  color: #e7eef6 !important;
  box-shadow: 0 3px 10px rgba(0,0,0,.32) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #socialComposerInput,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-mini-popup input,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-comment-form-inline input {
  border-color: #40576a !important;
  background: #0f1923 !important;
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-tool-btn,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-toolbar-icon-btn,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-load-more-btn {
  border-color: #40576a !important;
  background: #1d2f3e !important;
  color: #9dccf2 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-tool-btn:hover,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-toolbar-icon-btn:hover,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-load-more-btn:hover {
  border-color: #5ba9e8 !important;
  background: #27455d !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-post-head-name,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-post-likes,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-post-caption,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-comment-body,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-notif-dropdown-head {
  color: #e7eef6 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-post-media {
  background: #0d1620 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-comment-form-inline,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-notif-dropdown-head {
  border-color: #354b5e !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-icon-btn,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-post-menu-btn,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-view-comments,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .social-empty {
  color: #9fb3c4 !important;
}

@media (max-width: 620px) {
  #chatThemeToggle.chat-theme-toggle {
    width: 68px !important;
    min-width: 68px !important;
    padding-inline: 5px !important;
  }
}

/* =========================================================
   321ConnectChat 2.4.7 — sincronizzazione completa tema scuro
   Interviene esclusivamente nella chat quando il tema scuro è attivo.
   ========================================================= */

/* Composer principale: elimina ogni residuo bianco delle regole legacy. */
html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose {
  border-top-color: #344b5e !important;
  background: #0f1923 !important;
  color: #d8e2eb !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose .input-line {
  border-color: #344b5e !important;
  background: #0f1923 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose .input-avatar,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose .input-avatar-wrap,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose .composer-avatar,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose .send-stack {
  border-color: #344b5e !important;
  background: #0f1923 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose #messageInput {
  border-color: #496174 !important;
  background: #17232f !important;
  color: #d8e2eb !important;
  caret-color: #eef5fb !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.42) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose #messageInput::placeholder {
  color: #8799a9 !important;
  opacity: 1 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose #sendButton {
  border-color: #3e8ed0 !important;
  background: linear-gradient(180deg, #357fb8, #215a86) !important;
  color: #f4f8fb !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose #sendButton:hover:not(:disabled) {
  background: linear-gradient(180deg, #438fc8, #286995) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #messageForm.bottom-compose #sendButton:disabled {
  border-color: #3d4e5d !important;
  background: #263541 !important;
  color: #81909c !important;
}

/* Nome utente collegato e testi della scheda personale. */
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .me-card,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .me-card-info {
  color: #d9e3ec !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen #meName,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .me-card strong {
  color: #d9e3ec !important;
  text-shadow: 0 1px rgba(0,0,0,.28) !important;
}

/* Elenco stanze: titoli, descrizioni, conteggi e badge leggibili. */
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item:nth-child(even) {
  border-color: #405b70 !important;
  background: rgba(24,38,51,.94) !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item strong,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item-title-line,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item-title-line strong {
  color: #d6e0e9 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item small,
html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item-body small {
  color: #9fb0bf !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item-count {
  border-color: #48677d !important;
  background: rgba(66,95,117,.36) !important;
  color: #c6d5e1 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item-count.is-hot {
  border-color: #8b7137 !important;
  background: rgba(122,91,30,.32) !important;
  color: #f3d184 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item-count.is-full {
  border-color: #8a4c5c !important;
  background: rgba(115,45,62,.34) !important;
  color: #f0a6b7 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item img {
  border-color: #526c80 !important;
  background: #101923 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen .room-item-live-dot {
  border-color: #172532 !important;
}

/* Popup GIF: intestazione, ricerca, griglia e caricamento completamente scuri. */
html.chat-theme-active[data-chat-theme="dark"] #gifPopup,
html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-search-bar,
html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-grid,
html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-loading {
  border-color: #40586b !important;
  background: #111c27 !important;
  color: #d9e3ec !important;
}

html.chat-theme-active[data-chat-theme="dark"] #gifPopup .popup-title {
  border-bottom-color: #425a6d !important;
  background: linear-gradient(180deg, #344c60, #203443) !important;
  color: #f3f7fa !important;
}

html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-search-bar {
  border-bottom-color: #354b5e !important;
}

html.chat-theme-active[data-chat-theme="dark"] #gifPopup #gifSearchInput {
  border-color: #50697c !important;
  background: #0b151f !important;
  color: #dce5ed !important;
  caret-color: #eef5fb !important;
}

html.chat-theme-active[data-chat-theme="dark"] #gifPopup #gifSearchInput::placeholder {
  color: #8193a2 !important;
}

html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-placeholder,
html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-loading {
  color: #9eb0bf !important;
}

html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-grid img {
  border-color: #2d4152 !important;
  background: #0a121a !important;
}

html.chat-theme-active[data-chat-theme="dark"] #gifPopup .gif-grid img:hover {
  border-color: #6b9fca !important;
}

/* Regali e finestre credito: nessun pannello interno bianco. */
html.chat-theme-active[data-chat-theme="dark"] .gift-window,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-modal-body,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-bottom,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-form,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .asset-grid,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-grid,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-preview {
  border-color: #40586b !important;
  background: #14212c !important;
  color: #d9e3ec !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window .modal-title {
  border-bottom-color: #425a6d !important;
  background: linear-gradient(180deg, #344c60, #203443) !important;
  color: #f4f8fb !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window .tabs-mini,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-tabs {
  border-color: #40586b !important;
  background: #111c27 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window .tabs-mini button {
  border-color: #4b6477 !important;
  background: linear-gradient(180deg, #263a49, #192936) !important;
  color: #cbd8e2 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window .tabs-mini button.active {
  border-color: #5b83a2 !important;
  background: #29465c !important;
  color: #f6f9fb !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-preview strong,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-preview span,
html.chat-theme-active[data-chat-theme="dark"] .gift-window label,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-balance,
html.chat-theme-active[data-chat-theme="dark"] .gift-window .coin-status {
  color: #d9e3ec !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-legacy-note {
  color: #ef9b9b !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window .gift-cost {
  color: #efc375 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window input,
html.chat-theme-active[data-chat-theme="dark"] .gift-window textarea,
html.chat-theme-active[data-chat-theme="dark"] .gift-window select {
  border-color: #4b6477 !important;
  background: #0d1720 !important;
  color: #dce5ed !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window [style*="background:#f7fafd"],
html.chat-theme-active[data-chat-theme="dark"] .gift-window [style*="background: #f7fafd"] {
  border-color: #4b6477 !important;
  background: #0d1720 !important;
  color: #dce5ed !important;
}

html.chat-theme-active[data-chat-theme="dark"] .gift-window [style*="background:#e8f4fd"],
html.chat-theme-active[data-chat-theme="dark"] .gift-window [style*="background: #e8f4fd"] {
  border-color: #40586b !important;
  background: #1a2c3a !important;
  color: #c9d8e4 !important;
}

/* Tutte le finestre interne della chat: corpi, pannelli e azioni coerenti. */
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal),
html.chat-theme-active[data-chat-theme="dark"] .floating-popup,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) > div:not(.modal-title),
html.chat-theme-active[data-chat-theme="dark"] .floating-popup > div:not(.popup-title),
html.chat-theme-active[data-chat-theme="dark"] .profile-body,
html.chat-theme-active[data-chat-theme="dark"] .about-body,
html.chat-theme-active[data-chat-theme="dark"] .youtube-popup-body,
html.chat-theme-active[data-chat-theme="dark"] .share-window,
html.chat-theme-active[data-chat-theme="dark"] .avatar-window,
html.chat-theme-active[data-chat-theme="dark"] .font-popup-body,
html.chat-theme-active[data-chat-theme="dark"] .smiley-picker {
  border-color: #40586b !important;
  background-color: #14212c !important;
  color: #d9e3ec !important;
}

html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) p,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) span,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) label,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup p,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup span,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup label,
html.chat-theme-active[data-chat-theme="dark"] .about-body,
html.chat-theme-active[data-chat-theme="dark"] .about-body p {
  color: #cbd7e1 !important;
}

html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) .secondary,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup .secondary,
html.chat-theme-active[data-chat-theme="dark"] .modal-actions .secondary {
  border-color: #536b7d !important;
  background: linear-gradient(180deg, #2a3c49, #1a2934) !important;
  color: #dce5ec !important;
}

/* Barre di scorrimento coerenti nel tema scuro. */
html.chat-theme-active[data-chat-theme="dark"] #chatScreen *,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) *,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup * {
  scrollbar-color: #526d82 #101a24;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen *::-webkit-scrollbar-track,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) *::-webkit-scrollbar-track,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup *::-webkit-scrollbar-track {
  background: #101a24;
}

html.chat-theme-active[data-chat-theme="dark"] #chatScreen *::-webkit-scrollbar-thumb,
html.chat-theme-active[data-chat-theme="dark"] .legacy-modal:not(.signin-modal):not(.auth-modal) *::-webkit-scrollbar-thumb,
html.chat-theme-active[data-chat-theme="dark"] .floating-popup *::-webkit-scrollbar-thumb {
  background: #526d82;
  border-radius: 8px;
}
