:root {
  color-scheme: dark;
  font: 16px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --background: #111019;
  --panel: #1a1825;
  --surface: #222030;
  --stroke: #393449;
  --ink: #f5f0fc;
  --muted: #b3aabf;
  --accent: #bc9dff;
  --accent-ink: #201233;
  --green: #92e7c4;
  color: var(--ink);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-width: 0;
  margin: 0;
  background: radial-gradient(ellipse 46rem 28rem at 64% 10%, #201831, transparent 78%);
}

button, input, textarea, select { font: inherit; color: inherit; }
button, input, textarea, select {
  min-height: 2.75rem;
  min-width: 0;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--stroke);
  border-radius: 0.75rem;
  background: var(--surface);
}

button { font-weight: 650; }
button:not(:disabled) { cursor: pointer; }
button:not(:disabled):hover { background: #302940; border-color: #635674; }
button:disabled { opacity: 0.48; }
input, textarea { background: #15141e; }
input::placeholder, textarea::placeholder { color: #a19aaf; }
:focus-visible { outline: 2px solid #c8a8ff; outline-offset: 3px; }
button.button-primary {
  border-color: transparent;
  background: #bd9dff;
  color: var(--accent-ink);
}
button.button-primary:not(:disabled):hover { background: #d2baff; }

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 77rem);
  min-height: 100svh;
  margin: 0 auto;
  padding-inline: clamp(1rem, 4vw, 3rem);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 5rem;
  border-bottom: 1px solid #322c40;
}

.brand { display: flex; align-items: center; gap: 0.7rem; }
.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.45rem; }
#sound-settings { min-height: 2.25rem; padding: 0.34rem 0.65rem; font-size: 0.88rem; }
.brand h1 { margin: 0; font-size: 1.45rem; font-weight: 750; letter-spacing: -0.045em; }
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.19rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid #d5baff;
  border-radius: 0.7rem;
  background: #bd9dff;
}

.brand-mark i { width: 0.18rem; height: 0.62rem; border-radius: 1rem; background: #211235; }
.brand-mark i:nth-child(2) { height: 1.02rem; }
#connection {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  margin: 0;
  padding: 0.32rem 0.72rem;
  border: 1px solid #3d374e;
  border-radius: 2rem;
  background: #211d2e;
  color: #e1d8ed;
  font-size: 0.83rem;
  font-weight: 600;
  white-space: nowrap;
}

#connection::before {
  width: 0.46rem;
  height: 0.46rem;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

main { flex: 1; min-width: 0; padding-block: clamp(1rem, 4.7vh, 2.5rem); }
.button-row { display:flex; flex-wrap:wrap; align-items:center; gap:.55rem; }

.room-grid { display: grid; grid-template-columns: minmax(14.5rem, 0.34fr) minmax(0, 1fr); gap: 0.9rem; }
.panel { min-width: 0; padding: 1rem; border: 1px solid #373247; border-radius: 1.2rem; background: var(--panel); }
.panel-heading { padding: 0.1rem 0.15rem 0.75rem; }
.panel-heading h2 { margin: 0; font-size: 1.08rem; font-weight: 700; letter-spacing: -0.018em; }
#participant-list {
  display: grid;
  align-content: start;
  gap: 0.42rem;
  max-height: clamp(16rem, 57svh, 32rem);
  margin: 0;
  padding: 0 0.12rem 0.2rem;
  list-style: none;
  overflow: auto;
}

.participant {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.08rem 0.55rem;
  min-width: 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid #383247;
  border-radius: 0.78rem;
  background: #242031;
}

.participant-avatar {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 2.22rem;
  height: 2.22rem;
  border-radius: 0.66rem;
  background: #42305b;
  color: #f0dcff;
  font-weight: 750;
  font-size: 0.9rem;
}

.participant[data-tone="1"] .participant-avatar { background: #553651; color: #ffd7f3; }
.participant[data-tone="2"] .participant-avatar { background: #34465d; color: #d4e8ff; }
.participant[data-tone="3"] .participant-avatar { background: #514239; color: #ffe1c4; }
.participant-name { overflow: hidden; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.participant-self { padding: 0.02rem 0.32rem; border-radius: 0.32rem; background: #3b3151; color: #e4d4ff; font-size: 0.66rem; }
.participant-status { grid-column: 2 / -1; color: #b8aec6; font-size: 0.75rem; }
.participant-speaking { border-color: #6bc5a4; background: #243630; }
.participant-speaking .participant-status { color: var(--green); font-weight: 680; }

#messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: clamp(15rem, 47svh, 31rem);
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid #332d43;
  border-radius: 0.88rem;
  background: #14131e;
  scrollbar-width: thin;
  scrollbar-color: #604e77 transparent;
}

#empty-chat { display: grid; gap: 0.55rem; justify-items: center; margin: auto; color: #b5abc2; font-size: 0.9rem; text-align: center; }
#empty-chat::before {
  display: block;
  width: 1.55rem;
  height: 1.12rem;
  border: 2px solid #78648f;
  border-radius: 0.44rem 0.44rem 0.44rem 0.15rem;
  content: "";
}

.chat-message {
  align-self: flex-start;
  max-width: min(87%, 32rem);
  padding: 0.45rem 0.73rem 0.52rem;
  border: 1px solid #393149;
  border-radius: 0.22rem 0.85rem 0.85rem;
  background: #262133;
}

.own-message { align-self: flex-end; border-color: #60497d; border-radius: 0.85rem 0.22rem 0.85rem 0.85rem; background: #3b2c50; }
.chat-meta { display: flex; align-items: baseline; gap: 0.63rem; color: #ddc5ff; font-size: 0.74rem; }
.chat-meta strong { overflow-wrap: anywhere; }
.chat-meta time { color: #c1b3d0; }
.chat-message p { margin: 0.12rem 0 0; font-size: 0.93rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 0.45rem; margin-top: 0.65rem; }
#message { width: 100%; resize: vertical; max-height: 9rem; }
#emoji-toggle { width: 2.75rem; padding: 0.35rem; }
#emoji-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(2.55rem, 1fr)); gap: 0.25rem; margin-top: 0.4rem; }
#emoji-picker button { min-height: 2.55rem; padding: 0.15rem; font-size: 1.2rem; }
#file-traffic { margin:.45rem 0 0; color:var(--muted); font-size:.8rem; }
#chat-notice { margin: 0.55rem 0 0; color: #e3c8f5; font-size: 0.85rem; }

.call-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
  padding: 0.65rem;
  border: 1px solid #3c334b;
  border-radius: 1rem;
  background: #1d1a2a;
}

#voice-mode { cursor: pointer; font-weight: 650; }
.radio-strip {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  padding: 0.45rem;
  border: 1px solid #4c3b65;
  border-radius: 0.76rem;
  background: #262037;
}

#radio-talk { min-width: min(100%, 15rem); touch-action: none; user-select: none; border-color: #775d9d; background: #403154; color: #f0dfff; }
#radio-talk[data-talking="true"] { border-color: #72c4a5; background: #2c483c; color: #d0f8e7; }
#radio-hint { margin: 0; color: var(--muted); font-size: 0.83rem; }

#mute::before { display: inline-block; width: 0.48rem; height: 0.48rem; margin-right: 0.48rem; border-radius: 50%; background: #9d90ad; content: ""; vertical-align: 0.12em; }
#mute[aria-pressed="true"], #screen-toggle[aria-pressed="true"],
#screen-camera-toggle[aria-pressed="true"], #voice-check[aria-expanded="true"] {
  border-color:#5c9d81;
  background:#2c433d;
  color:#c2f7e2;
}
#mute[aria-pressed="true"]::before { background: var(--green); }
button.button-leave { border-color: #754655; background: #432834; color: #ffcbd3; }
button.button-leave:hover { border-color: #b97787; background: #613646; }
.feedback { margin-top: 0.8rem; padding: 0.68rem 0.95rem; border: 1px solid var(--stroke); border-radius: 0.8rem; background: #221c31; }
#notice { margin: 0; color: #dfd5ed; font-size: 0.88rem; }

.sound-dialog {
  width: min(28rem, calc(100% - 1.5rem));
  max-height: calc(100svh - 1.5rem);
  padding: clamp(0.85rem, 4vw, 1.35rem);
  border: 1px solid #504260;
  border-radius: 1rem;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1rem 3rem #090710bb;
}

.sound-dialog::backdrop { background: #0c0a14b8; }
.sound-heading { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 1.05rem; }
.sound-heading h2 { margin: 0; font-size: 1.24rem; letter-spacing: -0.03em; }
.sound-dialog label { display: block; margin-bottom: 0.32rem; font-size: 0.88rem; font-weight: 650; }
.sound-device { display: grid; gap: 0.42rem; }
.sound-device select { width: 100%; }
.sound-device button { justify-self: start; }
.sound-test { margin-top: 1rem; padding: 0.9rem; border: 1px solid var(--stroke); border-radius: 0.75rem; background: #15141e; }
#sound-level { display: block; width: 100%; height: 1.05rem; margin-bottom: 0.68rem; accent-color: var(--green); }
#sound-status { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.85rem; }
#sound-playback { display: block; width: 100%; height: 2.65rem; margin-top: 0.6rem; }

@media (max-width: 740px) {
  .topbar { min-height: 4rem; }
  main { padding-block: 1rem; }
  .room-grid { grid-template-columns: minmax(0, 1fr); gap: 0.65rem; }
  .panel { padding: 0.75rem; }
  #participant-list { grid-auto-flow: column; grid-auto-columns: clamp(8.5rem, 37.5vw, 11rem); grid-template-columns: none; }
  #messages { height: clamp(11rem, 30svh, 22rem); }
}

@media (max-width: 430px) {
  .chat-compose { grid-template-columns: auto 1fr; }
  #message { grid-column: 1 / -1; height: 3.25rem; }
  .call-controls { align-items: stretch; }
  .call-controls .button-row { align-items: stretch; flex-direction: column; }
  .call-controls .button-leave { align-self: start; }
  .radio-strip { align-items: stretch; flex-direction: column; }
}

.lobby-layout { display:grid; grid-template-columns:minmax(15rem, .42fr) minmax(0, 1fr); gap:.9rem; }
.lobby-intro, .lobby-directory { padding:clamp(1rem,3vw,2rem); }
.lobby-intro h2 { margin:0 0 1rem; font-size:clamp(2rem,5vw,3.25rem); letter-spacing:-.05em; }
.lobby-intro label, .room-form label { display:block; margin-bottom:.45rem; color:var(--muted); font-size:.9rem; }
.lobby-intro input, .room-form input, .room-form select { display:block; width:100%; margin-bottom:.8rem; }
.lobby-header { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.5rem; }
.lobby-header h2 { margin:0; font-size:1.25rem; }
#room-list { display:grid; gap:.45rem; max-height:31rem; overflow:auto; }
#status:empty { display:none; }
.room-entry { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.5rem; text-align:left; align-items:center; }
.room-entry strong { overflow-wrap:anywhere; }
.room-entry span { color:var(--muted); font-size:.82rem; white-space:nowrap; }
#room-error { color:#ffc1cb; font-size:.85rem; }
.participant-controls { grid-column:2 / -1; }
.participant-controls input[type="range"] { display:block; width:100%; min-height:1.35rem; padding:0; accent-color:var(--accent); }
.chat-compose { grid-template-columns:minmax(0,1fr) auto auto auto; }
.chat-message a { color:#ddc5ff; text-decoration-thickness:1px; }
.chat-message img { display:block; max-width:100%; max-height:16rem; margin:.2rem 0 .45rem; border-radius:.55rem; }
.screen-panel { margin-bottom:.8rem; }
#screen-frame { display:block; width:100%; max-height:62svh; object-fit:contain; border-radius:.65rem; background:#0d0c13; }
.sound-dialog .noise-setting { display:flex; align-items:center; gap:.5rem; margin-top:.8rem; }
.noise-setting input { min-height:0; margin:0; accent-color:var(--accent); }
@media (max-width:740px) {
  .lobby-layout { grid-template-columns:minmax(0,1fr); }
  #room-list { max-height:21rem; }
}
@media (max-width:520px) {
  .chat-compose { grid-template-columns:auto auto minmax(0,1fr); }
  #message { grid-column:1 / -1; }
}


.active-room-name { margin:0 0 .7rem; font-size:1.35rem; overflow-wrap:anywhere; }

.context-menu { position:fixed; z-index:20; min-width:11rem; padding:.3rem; background:#242031; border:1px solid #4b425e; border-radius:.65rem; box-shadow:0 .6rem 1.4rem #0008; }
.context-menu button { display:block; width:100%; border:0; text-align:left; background:transparent; }
.context-menu button:is(:hover,:focus-visible) { background:#3c3450; }
.attachment-row { display:flex; align-items:center; gap:.65rem; margin-top:.35rem; }
.attachment-row > span { display:grid; min-width:0; overflow-wrap:anywhere; }
.attachment-row small { opacity:.68; }
.attachment-row .attachment-download { display:grid; place-items:center; flex:0 0 2.3rem; height:2.3rem; border-radius:50%; background:#a990fa2b; color:#e0d6ff; font-size:1.35rem; text-decoration:none; }
.attachment-row .attachment-download:is(:hover,:focus-visible) { background:#a990fa55; }
.chat-message :is(video,audio) { display:block; width:min(100%,28rem); margin:.35rem 0; }
.chat-message video { max-height:20rem; background:#100e18; border-radius:.6rem; }
.attachment-error { color:#f3c5b6; }
.voice-setting { display:grid; gap:.35rem; margin-top:.75rem; }

.screen-preview-stack { position:relative; width:min(100%,24rem); overflow:hidden; border-radius:.65rem; background:#0d0c13; }
#screen-preview { display:block; width:100%; max-height:13rem; object-fit:contain; }
#screen-camera-preview { position:absolute; right:2.25%; bottom:4%; width:24%; max-height:38%; aspect-ratio:16 / 9; object-fit:cover; border:2px solid #15121d; border-radius:.3rem; background:#15121d; }
.screen-preview-stack[data-camera-position$="-left"] #screen-camera-preview { right:auto; left:2.25%; }
.screen-preview-stack[data-camera-position^="top-"] #screen-camera-preview { bottom:auto; top:4%; }
#screen-camera-note { margin:0 0 .5rem; font-size:.85rem; color:var(--muted); }
.screen-panel:is(:fullscreen,.screen-expanded) #screen-camera-note { display:none; }
#screen-frame { cursor:zoom-in; }
.screen-panel:fullscreen, .screen-panel.screen-expanded { display:grid; grid-template-rows:auto minmax(0,1fr); box-sizing:border-box; width:100%; height:100%; background:#0d0c13; margin:0; border:0; border-radius:0; }
.screen-panel.screen-expanded { position:fixed; inset:0; z-index:25; }
.screen-panel:is(:fullscreen,.screen-expanded) #screen-frame { height:100%; max-height:100%; cursor:zoom-out; }

#room-search { width:100%; margin:.1rem 0 .4rem; }
#network-status, #screen-stats, #hotkey-status { color:var(--muted); font-size:.83rem; }
#network-status { white-space:nowrap; }
#screen-panel .panel-heading { flex-wrap:wrap; gap:.5rem; }
#hotkey-status:empty { display:none; }

#file-preview { width:min(46rem, calc(100% - 1.5rem)); }
#file-preview-title { overflow-wrap:anywhere; }
#file-preview-body :is(img,video,audio) { display:block; max-width:100%; max-height:70svh; margin:auto; }
#file-preview-body :is(video,audio) { width:100%; }
.attachment-open { margin-top:.35rem; }
.attachment-download[aria-busy="true"] { opacity:.55; }

.settings-trigger { display:inline-flex; align-items:center; gap:.5rem; }
.settings-trigger span { font-size:1.2rem; line-height:1; }
.settings-dialog { width:min(39rem, calc(100% - 1.5rem)); max-height:calc(100svh - 1.5rem); }
.settings-nav { display:flex; flex-wrap:wrap; gap:.35rem; margin-bottom:1rem; padding-bottom:.8rem; border-bottom:1px solid var(--stroke); }
.settings-nav button { flex:1 0 auto; color:var(--muted); }
.settings-nav button[aria-pressed="true"] { color:var(--ink); background:#3b304f; border-color:#7861ad; }
.settings-section > p, #shortcut-capture-status, #settings-nickname-status { color:var(--muted); font-size:.86rem; }
.settings-section :is(p[role="status"],#shortcut-availability):empty { display:none; }
.settings-field { display:flex; flex-wrap:wrap; gap:.5rem; }
.settings-field input { flex:1 1 12rem; min-width:0; }
.settings-section .settings-select { display:grid; gap:.35rem; margin-bottom:.8rem; }
.settings-section .settings-select select { width:100%; }
.shortcut-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.45rem; margin:.65rem 0; }
.shortcut-group { border-top:1px solid var(--stroke); margin-top:1rem; padding-top:.75rem; }
.shortcut-group h3 { font-size:.94rem; margin:0 0 .45rem; }
.shortcut-actions { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; }
.shortcut-actions kbd { border:1px solid var(--stroke); border-radius:.45rem; padding:.35rem .5rem; color:var(--ink); }
.shortcut-actions button { min-height:2.35rem; }
.shortcut-row button[data-capturing="true"] { border-color:#bda3ff; background:#3b304f; }
#shortcut-reset { margin-top:.3rem; }
@media (max-width:430px) {
  .settings-nav button { flex:1 1 45%; }
}

.watch-banner { display:flex; flex-wrap:wrap; align-items:center; gap:.45rem; margin-bottom:.6rem; padding:.5rem; border-radius:.6rem; background:#242032; }
.watch-banner span { flex:1 1 12rem; overflow-wrap:anywhere; }
.watch-open { margin-inline-start:.35rem; }
#watch-dialog { width:min(46rem, calc(100% - 1.5rem)); }
#watch-title { overflow-wrap:anywhere; }
#watch-player :is(video,audio) { display:block; width:100%; max-height:60svh; }
.watch-volume input { vertical-align:middle; min-height:1.2rem; }
#watch-status, #voice-priority, #voice-check-status { color:var(--muted); font-size:.85rem; }
#screen-limit-control { display:flex; align-items:center; flex-wrap:wrap; gap:.4rem; color:var(--muted); font-size:.85rem; }
#voice-priority { grid-column:1 / -1; margin:.2rem 0; }
#voice-diagnostics { margin-top:.75rem; }
#voice-check-results { padding-inline-start:1.25rem; margin:.15rem 0 .7rem; }

#watch-timeline { display:grid; gap:.2rem; margin:.35rem 0; color:var(--muted); font-size:.82rem; }
#watch-timeline progress { width:100%; accent-color:var(--accent); }
