/* A native button supports mouse, touch, Enter, and Space without custom key handlers. */
.theme-control {display:flex; align-items:center; gap:12px; flex-shrink:0; min-height:44px;}
#theme-name {font-size:14px; font-weight:500; color:var(--muted); min-width:34px;}
.theme-toggle {position:relative; display:inline-flex; align-items:center; width:56px; height:32px; padding:4px; border:1px solid #a6c7c8; border-radius:999px; background:#dceeef; cursor:pointer; flex-shrink:0; box-shadow:inset 0 1px 3px #17323312;}
/* Extend the hit area to 44px while keeping the track visually compact. */
.theme-toggle::before {content:''; position:absolute; inset:-6px 0;}
.theme-toggle-thumb {width:24px; height:24px; border-radius:50%; background:white; box-shadow:0 1px 4px #17323333; transform:translateX(0); transition:transform 180ms ease; pointer-events:none;}
.theme-toggle[aria-checked="true"] {background:#007c83; border-color:#007c83;}
.theme-toggle[aria-checked="true"] .theme-toggle-thumb {transform:translateX(22px);}
.theme-toggle:focus-visible {outline:3px solid var(--primary); outline-offset:5px;}
.theme-toggle:hover {border-color:var(--primary);}
@media(max-width:480px) {.preference:has(.theme-control) {flex-wrap:wrap; gap:16px;} .theme-control {margin-left:auto;}}

/* Dark surfaces override the light component palette, including dialogs and onboarding. */
html[data-theme="dark"] {color-scheme: dark; --canvas: #142324; --surface: #1c3031; --text: #e7f6f7; --muted: #b0d0d1; --border: #355455; --primary: #a0e8eb; background: var(--canvas);}
html[data-theme="dark"] body {background: var(--canvas); color: var(--text);}
html[data-theme="dark"] :is(.sidebar,.details,.surface,.contact-card,.auth-form,.preview-bar,dialog,.attachment,.composer-area,.composer,.bubble,.search-result) {background: var(--surface); color: var(--text); border-color: var(--border);}
html[data-theme="dark"] :is(.chat-panel,.composer-area,.single-page) {background: var(--canvas);}
html[data-theme="dark"] .composer {background: var(--surface); border-radius: 12px;}
html[data-theme="dark"] :is(.composer textarea,label:not(.search)>input:not([type="checkbox"]),.search,.secondary) {background: #243f40; color: var(--text); border-color: #43686a;}
html[data-theme="dark"] input[readonly] {background: #243f40!important;}
html[data-theme="dark"] :is(input,textarea)::placeholder {color: #a9c9ca; opacity: 1;}
html[data-theme="dark"] .chat-header {background: linear-gradient(100deg,#274748,#336567);}
html[data-theme="dark"] .chat-header .icon-button {background: #ffffff10; color: #d5f5f6;}
html[data-theme="dark"] :is(.sidebar-title .icon-button,.composer .icon-button) {background: #2d4f50; color: #c9f2f4;}
html[data-theme="dark"] .conversation:hover {background: #264546;}
html[data-theme="dark"] .conversation.active {background: #26595b; border-color: #3a777a;}
html[data-theme="dark"] .conversation.active .conversation-title strong {color: #b7edf0;}
html[data-theme="dark"] :is(.outgoing .bubble,.primary,.send-button) {background: #007c83; color: #fff;}
html[data-theme="dark"] .outgoing .message-meta {color: var(--muted);}
html[data-theme="dark"] .receipt {color: #8fdaa1;}
html[data-theme="dark"] :is(.tag,.date-divider span,blockquote) {background: #295658; color: #dcf6f7;}
html[data-theme="dark"] blockquote strong {color: #b8eef0;}
html[data-theme="dark"] .green {background: #244534; color: #b2e8c2;}
html[data-theme="dark"] :is(.online-label,.header-name p span) {color: #95dda8;}
html[data-theme="dark"] .unread-divider {color: #b0ecee;}
html[data-theme="dark"] :is(.date-divider,.unread-divider):before,html[data-theme="dark"] :is(.date-divider,.unread-divider):after {background: #355455;}
html[data-theme="dark"] .auth-story {background: #245557; color: #e6f9fa;}
html[data-theme="dark"] .auth-story :is(p,.eyebrow) {color: #b9e4e6;}
html[data-theme="dark"] .story-card {background: #2d5f61; border-color: #458487;}
html[data-theme="dark"] :is(.document-preview,.skeleton i) {background: #2a4748;}
/* A file preview represents a white document even when the workspace is dark. */
html[data-theme="dark"] .document-sheet {color: #173233;}
html[data-theme="dark"] .connection-banner {background: #4a3b1d; color: #f3d89c;}
html[data-theme="dark"] .error {color: #ffb2a8;}
html[data-theme="dark"] .person-choice:hover {background: #294d4f;}
html[data-theme="dark"] mark {background: #6a5520; color: #fff2bd;}
/* Keep navigation and utility surfaces consistent with dark appearance too. */
html[data-theme="dark"] .topbar {background: linear-gradient(100deg,#224d4f,#1a4042);}
html[data-theme="dark"] .rail {background: #224d4f;}
html[data-theme="dark"] .brand {background: #e0f7f8;}


/* Header surfaces have the same hierarchy in both appearance modes. */
html[data-theme="dark"] .sidebar>.account {background:#203d3e; border-top-color:var(--border);}
html[data-theme="dark"] .topbar {background:#1c3839; color:#f1fcfc; border-bottom-color:#355455;}
html[data-theme="dark"] .topbar-tools button,html[data-theme="dark"] .topbar-tools a {color:#c3e2e3;}
html[data-theme="dark"] .topbar-tools button:hover,html[data-theme="dark"] .topbar-tools a:hover {background:#2d595b; border-color:#417a7c; color:#fff;}
html[data-theme="dark"] .topbar-tools .header-compose {background:#007c83; color:white;}
html[data-theme="dark"] .header-meeting-popover {border-color:#355455; background:#1c3031; color:#e7f6f7; box-shadow:0 12px 32px #0006;}
html[data-theme="dark"] .header-meeting-list {color:#b0d0d1;}
html[data-theme="dark"] .header-meeting-popover>strong {border-bottom-color:#355455;}
html[data-theme="dark"] .header-meeting-row {border-color:#355455; background:#243f40;}
html[data-theme="dark"] .topbar-tools .header-meeting-popover .header-meeting-link {background:transparent; color:#e7f6f7;}
html[data-theme="dark"] .topbar-tools .header-meeting-popover .header-meeting-link:hover {background:#2d595b; color:#fff;}
html[data-theme="dark"] .header-meeting-join:disabled {border-color:#43686a; background:#294446; color:#a0b7b8;}
html[data-theme="dark"] .header-meeting-popover time {color:#b0d0d1;}
html[data-theme="dark"] .topbar-tools .header-meeting-popover .header-meeting-all {color:#a0e8eb;}
@media(max-width:767px) {html[data-theme="dark"] .topbar-tools .header-compose {background:transparent;}}

html[data-theme="dark"] .startup-loader {background:radial-gradient(ellipse at 50% 42%,#265052 0,#1b3c3d 45%,#142324 100%);}
html[data-theme="dark"] .startup-loader:before,html[data-theme="dark"] .startup-loader:after {border-color:#ffffff12;}
html[data-theme="dark"] .startup-card {background:#1c3839e8;border-color:#ffffff12;box-shadow:0 28px 80px #0005,0 4px 14px #0003;}
html[data-theme="dark"] .startup-card h1 {color:#f1fcfc;}
html[data-theme="dark"] .startup-card p {color:#b0d0d1;}
html[data-theme="dark"] .startup-progress {background:#355455;}
html[data-theme="dark"] .startup-caption {color:#9ec0c1;}
html[data-theme="dark"] .startup-name {color:#f1fcfc;}
html[data-theme="dark"] .header-brand-logo {background:#fff; border-radius:5px; padding:2px;}
html[data-theme="dark"] .auth-product-name {color:#e7f6f7;}
html[data-theme="dark"] .filters .unread-count {background:#304f50; color:#bfdedf;}
html[data-theme="dark"] .filters .selected .unread-count {background:#295658; color:#b7edf0;}
