/* The same palette is used by the desktop, mobile portal and media view. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #090a0d;
  --shell: #111215;
  --surface: #181a1f;
  --field: #101216;
  --raised: #22262e;
  --hover: #283240;
  --line: #3c4655;
  --input-line: #697688;
  --ink: #f1f5fc;
  --muted: #b5c2d3;
  --accent: #93c9ff;
  --focus: #8ecaff;
  --selected: #202f46;
  --selected-ink: #d1e6ff;
  --selected-line: #669ee0;
  --primary: #1757b0;
  --primary-hover: #1c63c5;
  --success: #a1ebbe;
  --success-bg: #152d24;
  --warn: #ffdbac;
  --warn-bg: #332617;
  --danger: #ffd0dd;
  --danger-bg: #3e2030;
  --shadow: #0007;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #edf1f7;
  --shell: #f6f8fc;
  --surface: #fff;
  --field: #fff;
  --raised: #edf2f9;
  --hover: #e4ecf8;
  --line: #c7d2e2;
  --input-line: #75849a;
  --ink: #142238;
  --muted: #475972;
  --accent: #164e9d;
  --focus: #1455aa;
  --selected: #dceafe;
  --selected-ink: #163e75;
  --selected-line: #4c77b1;
  --primary: #1757b0;
  --primary-hover: #11468f;
  --success: #15573a;
  --success-bg: #e2f3e9;
  --warn: #65420f;
  --warn-bg: #fff1d8;
  --danger: #812244;
  --danger-bg: #fbe7ed;
  --shadow: #1b33562b;
}

:root:is([data-theme="light"], [data-theme="dark"]), :root:is([data-theme="light"], [data-theme="dark"]) body {
  color: var(--ink);
  background: var(--page);
}

:root:is([data-theme="light"], [data-theme="dark"]) :is(button, input, select, textarea, summary, a):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

:root:is([data-theme="light"], [data-theme="dark"]) :is(input, textarea)::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* Original blue uses the built-in styles in each view. */

/* Desktop chrome, room and chat surfaces. */
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.app, .rail, .top, .bottom, .left) {
  background: var(--shell) !important;
  border-color: var(--line);
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .app::before,
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .app::after {
  background: none;
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.center, .right, .screen-mini),
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .app.sm-three-panes .sm-pane,
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .right :is(.chat-heading, .messages) {
  background: var(--surface) !important;
  border-color: var(--line);
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .sm-pane.is-side::before { box-shadow: none; }
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .left-divider { background: var(--line); }

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .chat-empty {
  background: var(--surface);
  color: var(--muted);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .screen:fullscreen .placeholder,
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .screen:fullscreen .placeholder b {
  color: #f1f5fc !important;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.status, .room-count, .voice-count, .sm-voice-health, .friend-search-wrap, .composer, .screen:not(:fullscreen), .settings-note, .msg a, .my-id) {
  background: var(--raised) !important;
  color: var(--muted);
  border-color: var(--line);
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.sm-dm-line, .room, .friend-card, .emoji-pop, .avatar-choose, .meter) {
  background: var(--raised);
  border-color: var(--line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.member-tile.me, .member-tile:not(.me)) {
  background: var(--raised) !important;
  border-color: var(--line);
  box-shadow: none !important;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .member-tile.me {
  background: var(--selected) !important;
  border-color: var(--selected-line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .member-tile.me::before,
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .member-tile.me::after {
  background: none !important;
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.member-tile.vacant, .channel-locked) {
  opacity: 1;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .member-tile .empty-member {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line);
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.room-current, .channel.active, .rail-item.selected, .tab.selected, .sm-dm-line.self) {
  background: var(--selected) !important;
  border-color: var(--selected-line);
  color: var(--selected-ink) !important;
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.room-current .ic, .channel.active .ic, .tab.selected .ic) { color: inherit; }
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] #roomCatalog .room-current { color: var(--selected-ink); }

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.settings-panel, .dialog, .profile-dialog, .sm-dm-box, .sm-call-dialog, .sm-private-toast, .sm-join-toast, #quickAudioDevices, #roomMoreMenu) {
  background: var(--surface) !important;
  color: var(--ink);
  border-color: var(--line) !important;
  box-shadow: 0 14px 36px var(--shadow) !important;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.sm-call-frame, .sm-dm-log) {
  background: var(--field);
  border-color: var(--line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.settings-panel, .dialog, .profile-dialog, .sm-dm-box, #quickAudioDevices) :is(select, input:not([type="range"], [type="checkbox"], [type="file"])),
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] #createRoomDialog .friend-search {
  background: var(--field) !important;
  border: 1px solid var(--input-line) !important;
  color: var(--ink);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.title-with-icon h2, .screen-info strong, .screen .placeholder b, .chat-empty strong, .identity b, .member-tile strong, .msg strong, .msg p, .tab-content h3, .profile-dialog h2, .friend-card b, .friend-search, .composer input, .composer textarea),
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] #roomCatalog button:not(.room-current) {
  color: var(--ink);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.brand small, .tiny, .eyebrow, .hint, .footnote, .room-muted, .room-subtitle, .channel:not(.active), .screen-info p, .screen .placeholder, .tab-content, .member-tile small, .msg time, .identity, .friend-info small, .friend-empty, .composer-icon, .settings-panel h3, .settings-panel label, .settings-status, .dialog p, .profile-dialog .profile-label, .avatar-choose-actions small, .preset-heading small, .sm-dm-info, .sm-private-toast span, .sm-join-subtitle, .sm-call-toolbar span, .sm-call-help, #quickAudioDevices label, #quickAudioStatus) {
  color: var(--muted) !important;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.brand span, .title-with-icon > .ic, .screen-info > .ic, .sm-dm-line b, .sm-join-eyebrow, .avatar-reset, .msg a) {
  color: var(--accent);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.icon-btn:not(.primary), .round-action:not(.primary, .disconnect), .footer-control, .btn:not(.primary, .red, .active), .sm-dm-box button, .sm-private-actions button, .sm-call-actions button, .sm-join-decline) {
  background: var(--raised);
  color: var(--ink);
  border-color: var(--input-line);
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.rail-item:not(.selected), .win-control, .room-muted .ic) { color: var(--muted); }

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.msg:hover, .channel:not(.active):hover, .room-muted:hover, .rail-item:not(.selected):hover, .win-control:not(.close):hover, .btn:not(.primary, .red, .active):hover) {
  background: var(--hover);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.btn.primary, .btn.active, .icon-btn.primary, .round-action.primary, .send-btn, .sm-dm-box form button, .sm-private-actions button:first-child) {
  background: var(--primary);
  color: #fff;
  border-color: var(--selected-line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.btn.primary, .btn.active, .send-btn):hover { background: var(--primary-hover); }

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.btn.red, .bottom .footer-control[aria-pressed="true"], .call-actions button[aria-pressed="true"]) {
  background: var(--danger-bg);
  color: var(--danger);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .sm-voice-health[data-ok="1"] {
  background: var(--success-bg) !important;
  color: var(--success);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.chat-heading h2, .sidebar-header b, .friends-header strong) {
  color: var(--ink);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.room-current strong, .rail-item.active) { color: var(--selected-ink); }
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.plain-icon, .identity-expand) { color: var(--accent); }
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.online-note, .member-presence .mic-on) { color: var(--success); }

[data-theme="light"][data-platform="desktop"] :is(.brand-name, .chat-heading h2, .room-heading h2, .sidebar-header b, .friends-header strong, .member-presence strong, .screen-info strong) {
  text-shadow: none;
}

[data-theme="light"][data-platform="desktop"] :is(.title-with-icon > .ic, .room-subtitle, .room-muted, .channel, .tab, .screen-info p, .member-presence .mic-on) {
  filter: none;
}

/* Mobile portal and desktop media frame. */
:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] .app {
  background: var(--shell);
  border-color: var(--line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.top, .nav, .card, .room-menu-items),
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] .panel {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 4px 16px var(--shadow);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.bubble, .person, .person.host, .mobile-screen-empty, .room-menu summary, #roomCount, .friend .pill, .room-emblem, .net.off, .notice, .btn.secondary) {
  background: var(--raised);
  color: var(--ink);
  border-color: var(--line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.hero, .chatinfo, .bubble.mine, .tab.active, .mobile-channel.active) {
  background: var(--selected);
  color: var(--selected-ink);
  border-color: var(--selected-line);
  box-shadow: none;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.mobile-view-title h1, .heading, .mobile-section-heading h2, .mobile-host-friend, .room-menu-items button, .room-menu[open] summary, .mobile-channel) {
  color: var(--ink);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.mobile-view-title p, .muted, .room small, .person small, .friend small, .mobile-channel small, .mobile-channel svg, .chatinfo span, .note, .empty, label, .settingsline span, .avatar-hint, .tab:not(.active), #callStatus, #screenStatus),
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] :is(p, small, .label, .status) {
  color: var(--muted);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.brand span, .subtitle, .sectionlabel, .bubble b, .bubble.mine b, .avatar-field summary, .avatar-clear, .mobile-back, .mobile-channel.active svg),
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] h1 span {
  color: var(--accent);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.top, .settingsline, .composer, .friend, .friends-section, .mobile-audio-controls) { border-color: var(--line); }
:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.mobile-channel:hover:not(:disabled, .active), .room-menu-items button:hover) { background: var(--hover); }
:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.count, .net:not(.off)) { color: var(--success); }
:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] .net:not(.off) { background: var(--success-bg); border-color: var(--line); }
:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] .notice.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--line); }

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] .btn:not(.secondary),
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] button.active,
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] body[data-mode="screen"] #screen {
  background: var(--primary);
  color: #fff;
  border-color: var(--selected-line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] .mobile-audio-controls .btn[aria-pressed="true"],
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] button.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(input, select),
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] button:not(.active, .danger, #screen) {
  background: var(--field);
  color: var(--ink);
  border-color: var(--input-line);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] body[data-mode="screen"] { background: var(--surface); }
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] h1 small { color: var(--muted); }

.theme-setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.theme-setting select {
  min-height: 44px;
  min-width: 125px;
  padding: 0 10px;
  border: 1px solid;
  border-radius: 9px;
  font: inherit;
}

[data-theme="original"][data-platform="mobile"] .theme-setting select {
  background: #0b1930;
  color: #f1f7ff;
  border-color: #597ca7;
}

/* Localized neon accents keep the chat, forms and status text on solid surfaces. */
:root[data-theme="light"] {
  --neon-core: #227dec;
  --neon-tip: #44cfff;
  --neon-edge: #79adf2;
  --neon-haze: #218cff24;
  --neon-halo: #218cff3b;
  --neon-tint: #e4efff;
}

:root[data-theme="dark"] {
  --neon-core: #319aff;
  --neon-tip: #6deaff;
  --neon-edge: #357ab8;
  --neon-haze: #087fff24;
  --neon-halo: #1495ff62;
  --neon-tint: #17283a;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .top {
  background-image: url('assets/ref-top-light.svg'), linear-gradient(106deg, var(--shell) 34%, var(--neon-tint) 88%, var(--shell)) !important;
  background-position: center top !important;
  background-size: 100% 100% !important;
  background-repeat: no-repeat !important;
  border-bottom-color: var(--neon-edge);
  box-shadow: 0 3px 18px var(--neon-haze), inset 0 -1px 0 var(--neon-halo);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.left, .bottom, .screen-mini),
:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .app.sm-three-panes .sm-pane {
  background-image: radial-gradient(ellipse at 100% 100%, var(--neon-haze), transparent 50%) !important;
  border-color: var(--neon-edge);
  box-shadow: inset 0 0 24px var(--neon-haze);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .bottom::before {
  box-shadow: inset 0 1px 0 var(--neon-edge), 0 -2px 12px var(--neon-haze);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .member-tile.me {
  background-image: radial-gradient(ellipse at 50% 44%, var(--neon-haze), transparent 67%) !important;
  border-color: var(--neon-core);
  box-shadow: inset 0 0 18px var(--neon-haze), 0 0 13px var(--neon-halo) !important;
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] .member-tile.me .glow-avatar {
  border-color: var(--neon-tip);
  box-shadow: 0 0 0 4px var(--neon-haze), 0 0 0 8px var(--neon-haze), 0 0 19px var(--neon-halo);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="desktop"] :is(.room-current, .channel.active, .rail-item.selected),
:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.mobile-channel.active, .tab.active) {
  border-color: var(--neon-core);
  box-shadow: inset 0 0 12px var(--neon-haze), 0 0 10px var(--neon-haze);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] :is(.top, .nav),
:is([data-theme="light"], [data-theme="dark"])[data-platform="host"] .panel {
  background-image: linear-gradient(115deg, transparent 35%, var(--neon-haze) 86%, transparent);
  border-color: var(--neon-edge);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] .app::before {
  background: linear-gradient(90deg, transparent 5%, var(--neon-core) 50%, var(--neon-tip) 69%, transparent 96%);
  box-shadow: 0 1px 15px var(--neon-halo);
}

:is([data-theme="light"], [data-theme="dark"])[data-platform="mobile"] .person.host {
  background-image: radial-gradient(ellipse at 50% 40%, var(--neon-haze), transparent 70%);
  border-color: var(--neon-core);
  box-shadow: inset 0 0 14px var(--neon-haze), 0 0 10px var(--neon-haze);
}
