:root { color-scheme: light; --surface: #fff; --theme-text: #202726; --theme-soft: #f2f5f3; --theme-selected: #e3eee8; --theme-border: #dce4df; }
:root[data-theme="dark"] {
  color-scheme: dark;
  color: #eceef2;
  background: #101114;
  --green: #a8bcf5;
  --muted: #b0b3bc;
  --line: #34363e;
  --paper: #101114;
  --surface: #1b1c21;
  --theme-text: #eceef2;
  --theme-soft: #25262d;
  --theme-selected: #303544;
  --theme-border: #494c59;
}
.theme-open { background: var(--theme-soft); color: var(--theme-text); border: 1px solid var(--line); padding: 9px 12px; border-radius: 8px; font-size: 12px; }
.theme-open:hover { border-color: var(--green); }
.theme-settings { padding: 16px 0; border-bottom: 1px solid var(--line); }
.theme-settings > strong { display: block; font-size: 13px; margin-bottom: 12px; }
.theme-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.theme-choice { min-width: 0; padding: 12px 8px; border: 1px solid var(--theme-border); border-radius: 10px; background: var(--surface); color: var(--theme-text); text-align: center; }
.theme-choice:hover { background: var(--theme-soft); }
.theme-choice[aria-pressed="true"] { border-color: var(--green); background: var(--theme-selected); box-shadow: inset 0 0 0 1px var(--green); }
.theme-choice strong { display: block; font-size: 12px; margin-top: 10px; }
.theme-choice small { display: block; font-size: 10px; margin-top: 5px; line-height: 1.5; color: var(--muted); }
.theme-swatch { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; margin: auto; width: 62px; height: 40px; padding: 7px; border: 1px solid #82968a; border-radius: 7px; background: #f7f8f8; }
.theme-swatch i { width: 29px; height: 9px; background: #dce7df; border-radius: 3px; }
.theme-swatch i + i { align-self: flex-end; background: #3d6a54; }
.theme-swatch-dark { background: #101114; }
.theme-swatch-dark i { background: #545968; }
.theme-swatch-dark i + i { background: #a8bcf5; }
.theme-swatch-system { background: linear-gradient(90deg,#f7f8f8 50%,#101114 50%); }
.theme-status { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 12px 0 0; }
.admin-top-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 14px; }
[data-theme="dark"] body { color: var(--theme-text); }
[data-theme="dark"] :is(.auth-card,.sidebar,.chat-header,.composer,.chat-menu,.emoji-picker,.attachment-picker,dialog,.admin-top,.admin-stats>div,.admin-table-scroll,#admin-chat-list,#admin-chat-view,.audit-row) { background: var(--surface); color: var(--theme-text); }
[data-theme="dark"] :is(.conversation,.composer-area,.admin-page) { background: var(--paper); }
[data-theme="dark"] .rail { background: #16171b; }
[data-theme="dark"] :is(input:not([type=file]),textarea) { background: #17181d; color: var(--theme-text); border-color: var(--theme-border); }
[data-theme="dark"] .composer textarea { background: transparent; }
[data-theme="dark"] :is(input,textarea)::placeholder { color: #a3a7b2; }
[data-theme="dark"] :is(input,textarea):focus { border-color: var(--green); box-shadow: 0 0 0 3px #a8bcf51f; }
[data-theme="dark"] .composer textarea:focus { box-shadow: none; }
[data-theme="dark"] .composer:focus-within { border-color: var(--green); }
[data-theme="dark"] :is(button,a):focus-visible { outline-color: var(--green); }
[data-theme="dark"] :is(.composer,.emoji-picker,.attachment-picker) { border-color: var(--theme-border); box-shadow: 0 8px 30px #0003; }
[data-theme="dark"] :is(.auth-tabs,.search-box input,.list-tabs button span,.gif-tabs button,.gif-card,.message-option,.attachment-option,.receipt-info>div,.tag-card,.admin-message,.admin-password,th) { background: var(--theme-soft); }
[data-theme="dark"] :is(.auth-tabs button.active,.contact-row.selected,.rail .icon-button.active,.emoji-toggle[aria-expanded="true"],.attach-button[aria-expanded="true"],.emoji-tabs button[aria-pressed="true"],.gif-tabs button[aria-pressed="true"],.admin-chat-item.selected) { background: var(--theme-selected); color: var(--green); }
[data-theme="dark"] :is(.icon-button:hover,.contact-row:hover,.chat-menu button:hover,.settings-row:hover,.message-option:hover,.attachment-option:hover,.emoji-tabs button:hover,.emoji-grid button:hover,.admin-chat-item:hover) { background: #30323b; color: var(--theme-text); }
[data-theme="dark"] :is(.primary,.send-button,.unread,.request-actions button.accept,.once-toggle[aria-pressed="true"]) { color: #131b30; background: var(--green); }
[data-theme="dark"] :is(.primary:hover,.send-button:hover) { background: #c2cefa; }
[data-theme="dark"] :is(.auth-footer button:hover,.empty-list strong,.messages-empty strong,.bubble p,.chat-menu button,.settings-row,.message-option,.gif-card span,.attachment-option,.receipt-info strong,.admin-chat-item) { color: var(--theme-text); }
[data-theme="dark"] :is(.request-actions button,.secondary,.older,.block-row button,.attachment-preview,.reply-preview,.admin-notice) { background: #272a33; color: #d1d5df; border-color: var(--line); }
[data-theme="dark"] .attachment-option-icon { background: #343a4c; }
[data-theme="dark"] .bubble { background: #25262c; border-color: #3b3d47; box-shadow: none; }
[data-theme="dark"] .bubble.mine { background: #333b50; border-color: #4a556f; }
[data-theme="dark"] .bubble.emoji-only { background: transparent; border-color: transparent; }
[data-theme="dark"] :is(.bubble-meta,.delivery-state,.message-more,.copy-message,.reply-preview p,.message-quote span,.once-media small) { color: #c0c5d2; }
[data-theme="dark"] :is(.bubble-meta .read,.delivery-state.read,.once-media) { color: #bccbfc; }
[data-theme="dark"] .message-deleted > p { color: var(--muted); }
[data-theme="dark"] :is(.message-more:hover,.copy-message:hover,.copy-message:focus-visible) { background: #41495f; color: var(--green); }
[data-theme="dark"] .message-quote { background: #13172266; border-left-color: #a8bcf5; }
[data-theme="dark"] .reply-preview { border-left-color: #a8bcf5; }
[data-theme="dark"] .once-toggle { background: var(--surface); color: #cdd3e3; border-color: var(--theme-border); }
[data-theme="dark"] .once-viewer { background: #090a0d; }
[data-theme="dark"] :is(.error,.modal-error,.danger) { color: #ffaaa7 !important; }
[data-theme="dark"] .danger-button { color: #fff !important; background: #a73535 !important; }
[data-theme="dark"] .blocked-banner { background: #3d2e24; color: #f0c6a6; }
[data-theme="dark"] .self-avatar { background: #353b4e; border-color: #535d7b; color: #dde4fb; }
[data-theme="dark"] .avatar { background: #383c4a; color: #d7def4; }
[data-theme="dark"] .avatar[data-color="1"] { background: #4c4230; color: #ecd7ab; }
[data-theme="dark"] .avatar[data-color="2"] { background: #343f55; color: #cad7f2; }
[data-theme="dark"] .avatar[data-color="3"] { background: #513934; color: #f4cac3; }
[data-theme="dark"] .avatar[data-color="4"] { background: #3c3e50; color: #d8d9ef; }
[data-theme="dark"] .online-dot { border-color: var(--surface); background: #a8bcf5; }
[data-theme="dark"] .status-dot { background: #a8bcf5; }
[data-theme="dark"] .composer-area.dragging .composer { background: #2f3545; }
[data-theme="dark"] .toast { background: #e0e5f4; color: #1d2333; box-shadow: 0 6px 24px #0005; }
[data-theme="dark"] dialog { box-shadow: 0 20px 80px #0008; }
[data-theme="dark"] dialog::backdrop { background: #030407b8; }
[data-theme="dark"] .chat-menu { box-shadow: 0 12px 32px #0005; }
[data-theme="dark"] .admin-status { color: #c7d3f7; background: #353e54; }
[data-theme="dark"] .admin-status.suspended { color: #ffccad; background: #503a2d; }
[data-theme="dark"] .gif-card:hover { border-color: var(--green); }
[data-theme="dark"] ::selection { background: #a8bcf54d; color: #fff; }
[data-theme="dark"] * { scrollbar-color: #5c6070 #1a1b20; }
@media(max-width:720px) { .admin-top-actions { gap: 8px; } .theme-open { padding: 8px 10px; font-size: 11px; } .theme-choice { padding: 11px 5px; } }
