
:root {
  color-scheme: dark;
  --bg: #0d0f13;
  --panel: #12151b;
  --panel-2: #171a21;
  --panel-3: #1d212a;
  --line: #272c36;
  --text: #f3f5f7;
  --muted: #9aa3b2;
  --accent: #7c5cff;
  --accent-2: #9a85ff;
  --good: #42d392;
  --danger: #ff5f6d;
  --warn: #f1c75b;
  --shadow: 0 18px 55px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.join-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(124,92,255,.18), transparent 35%),
    radial-gradient(circle at 85% 75%, rgba(66,211,146,.08), transparent 30%),
    #0b0d11;
}
.join-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  background: rgba(18,21,27,.96);
  padding: 34px;
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.hero-logo { width: 84px; height: 84px; object-fit: contain; display:block; margin: 0 auto 12px; border-radius: 14px; }
.join-card h1 { margin: 8px 0 4px; font-size: 28px; }
.join-card p { margin: 0 0 24px; color: var(--muted); }
.join-card label { display: block; margin: 14px 0 7px; color: #cfd4dd; font-size: 13px; font-weight: 700; }
.join-card input {
  width: 100%;
  background: #0e1117;
  border: 1px solid #2b313c;
  color: var(--text);
  border-radius: 10px;
  padding: 13px 14px;
  outline: none;
}
.join-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.12); }
.primary-btn {
  width: 100%;
  border: 0;
  margin-top: 18px;
  background: var(--accent);
  border-radius: 10px;
  padding: 13px;
  font-weight: 800;
  cursor: pointer;
}
.primary-btn:hover { background: var(--accent-2); }
.primary-btn:disabled { opacity: .6; cursor: wait; }
.secondary-btn {
  width: 100%;
  border: 1px solid #374050;
  margin-top: 10px;
  background: #171c24;
  color: #eef2f7;
  border-radius: 10px;
  padding: 13px;
  font-weight: 800;
  cursor: pointer;
}
.secondary-btn:hover { background: #202632; }
.small-btn { width:auto; margin-top:0; }
.join-card small { display:block; color: #737d8e; margin-top: 14px; line-height: 1.45; }

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 310px minmax(0,1fr);
}
.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #101319;
  border-right: 1px solid var(--line);
}
.server-header {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.server-header strong { display:block; font-size: 15px; }
.server-header span { color: var(--muted); font-size: 12px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #667080; box-shadow: 0 0 0 4px rgba(102,112,128,.1); }
.status-dot.online { background: var(--good); box-shadow: 0 0 0 4px rgba(66,211,146,.12); }
.channel-label, .voice-title {
  padding: 18px 18px 7px;
  color: #788292;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}
.channel {
  margin: 0 10px;
  width: calc(100% - 20px);
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 9px;
  padding: 9px 10px;
  background: transparent;
  text-align: left;
}
.channel.active { background: #252a34; }
.hash { color:#8791a0; font-size: 21px; }
.member-count { color: var(--good); font-size: 12px; }
.participants { flex: 1; overflow-y: auto; padding: 0 10px 12px; }
.participant {
  border: 1px solid transparent;
  border-radius: 10px;
  margin-bottom: 6px;
  padding: 9px;
  background: rgba(255,255,255,.015);
}
.participant.speaking { border-color: rgba(66,211,146,.65); background: rgba(66,211,146,.05); }
.participant-row { display: flex; align-items: center; gap: 9px; }
.avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items:center;
  background: #303748;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.participant.speaking .avatar { box-shadow: 0 0 0 2px var(--good); }
.p-meta { min-width:0; flex:1; }
.p-meta strong { display:block; font-size: 13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.p-name-row { display:flex; align-items:center; gap:8px; min-width:0; margin-bottom:2px; }
.p-name-row strong { display:block; font-size: 13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.live-badge { display:inline-flex; align-items:center; justify-content:center; padding:3px 8px; border-radius:999px; background:#ef4444; color:#fff; font-size:10px; font-weight:800; letter-spacing:.04em; white-space:nowrap; }
.p-meta span { color: var(--muted); font-size: 11px; }
.volume-row { display:flex; gap:8px; align-items:center; margin-top: 7px; padding-left: 42px; }
.volume-row input { width:100%; accent-color: var(--accent); }
.volume-row span { width:36px; text-align:right; color:#818b9a; font-size:10px; }

.voice-panel {
  margin: 8px;
  padding: 10px;
  border:1px solid var(--line);
  background:#171b22;
  border-radius:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.voice-connected-card {
  display:flex;
  align-items:center;
  gap:10px;
  padding: 6px 4px 2px;
}
.voice-connected-card strong { display:block; font-size:15px; color: var(--good); }
.voice-connected-card span { display:block; font-size:12px; color: var(--muted); }
.voice-connected-badge {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(66,211,146,.12);
}
.action-row {
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:8px;
}
.action-tile {
  border:0;
  background:#242933;
  border-radius:10px;
  min-height:52px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  cursor:pointer;
  transition: transform .14s ease, background .14s ease, opacity .14s ease;
}
.action-tile:hover { background:#2b313d; transform: translateY(-1px); }
.action-tile .tile-icon { font-size: 18px; line-height:1; }
.action-tile .tile-label { font-size: 11px; color:#d2d8e2; }
.action-tile.active { background: rgba(124,92,255,.22); box-shadow: inset 0 0 0 1px rgba(124,92,255,.45); }
.action-tile.sharing { background: rgba(66,211,146,.18); box-shadow: inset 0 0 0 1px rgba(66,211,146,.4); }
.action-tile.binding { background: rgba(241,199,91,.15); box-shadow: inset 0 0 0 1px rgba(241,199,91,.45); }

.local-card {
  padding: 10px;
  display:flex;
  align-items:center;
  gap: 9px;
  border:1px solid var(--line);
  background:#13171d;
  border-radius:12px;
}
.local-meta { min-width:0; flex:1; }
.local-meta strong { display:block; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.local-meta span { color:var(--good); font-size:11px; }
.local-actions { display:flex; align-items:center; gap:6px; }
.icon-btn {
  width:34px; height:34px; border:0; border-radius:10px;
  display:grid; place-items:center; background:#262c37; cursor:pointer;
}
.icon-btn:hover { background:#2e3541; }
.icon-btn.active { background: rgba(124,92,255,.22); color:#fff; }
.icon-btn.off { background: rgba(255,95,109,.18); color:#ffdce0; }
.icon-btn.danger { background: rgba(255,95,109,.18); color:#ffdce0; }
.compact-control { font-size: 16px; }

.main {
  min-width: 0;
  display:flex;
  flex-direction:column;
  background:#0d1015;
}
.topbar {
  height:66px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 18px;
  border-bottom:1px solid var(--line);
  background:#101319;
}
.topbar strong { display:block; }
.topbar span { color:var(--muted); font-size:12px; }
.top-actions { display:flex; align-items:center; gap:10px; }
.safety-pill {
  padding:8px 12px;
  border-radius:999px;
  background:rgba(66,211,146,.08);
  border:1px solid rgba(66,211,146,.25);
  color:#bdebd6;
  font-size:12px;
}
.screen-stage {
  border-bottom:1px solid var(--line);
  background:#0d1015;
}
.screen-head {
  height:48px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
}
.text-btn {
  border:0;
  background:transparent;
  color:#b8c0cd;
  cursor:pointer;
}
.screen-video-wrap {
  height:min(40vh, 380px);
  background:#090b0f;
  display:grid;
  place-items:center;
}
.screen-video-wrap video {
  max-width:100%;
  max-height:100%;
  object-fit:contain;
}
.chat-shell {
  min-height:0;
  flex:1;
  display:flex;
  flex-direction:column;
}
.messages {
  flex:1;
  overflow:auto;
  padding:18px 18px 10px;
}
.welcome-message {
  border:1px solid var(--line);
  background:#10141b;
  border-radius:16px;
  padding:18px;
}
.welcome-icon {
  width:52px; height:52px; border-radius:16px;
  display:grid; place-items:center; font-weight:900;
  background:linear-gradient(135deg, var(--accent), #4b2dd6);
  margin-bottom:12px;
}
.welcome-message h2 { margin:0 0 8px; }
.welcome-message p { margin:0; color:var(--muted); }
.system-message {
  margin:0 0 8px;
  color:#9da6b7;
  font-size:12px;
}
.message {
  display:flex;
  gap:10px;
  margin-bottom:14px;
}
.message-head {
  display:flex;
  align-items:baseline;
  gap:8px;
  margin-bottom:2px;
}
.message-head strong { font-size:14px; }
.message-head time { color:var(--muted); font-size:11px; }
.message-body { color:#e8ebf0; white-space:pre-wrap; word-break:break-word; }
.chat-form {
  padding: 14px 18px 18px;
  display:grid;
  grid-template-columns:minmax(0,1fr) 52px;
  gap:10px;
}
.chat-form input {
  width:100%;
  border:1px solid #2b313c;
  background:#10141b;
  color:#fff;
  border-radius:12px;
  padding:14px 15px;
  outline:none;
}
.chat-form input:focus { border-color: var(--accent); box-shadow:0 0 0 3px rgba(124,92,255,.12); }
.chat-form button {
  border:0;
  border-radius:12px;
  background:var(--accent);
  cursor:pointer;
}
.chat-form button:hover { background:var(--accent-2); }
.toast {
  position:fixed;
  right:18px;
  top:18px;
  z-index:99;
  padding:12px 15px;
  border-radius:12px;
  background:#202530;
  color:#fff;
  border:1px solid #394153;
  box-shadow:var(--shadow);
  transform:translateY(-12px);
  opacity:0;
  pointer-events:none;
  transition:.18s ease;
  max-width: min(420px, calc(100vw - 24px));
}
.toast.show { transform:translateY(0); opacity:1; }
.toast.error { background:#32181d; border-color:#88434b; }
.audio-mount { display:none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, .62);
  backdrop-filter: blur(3px);
  z-index: 100;
  display:grid;
  place-items:center;
  padding:20px;
}
.settings-modal {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #141922;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.settings-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.settings-head strong { display:block; font-size:18px; }
.settings-head span { display:block; margin-top:4px; color:var(--muted); font-size:12px; }
.settings-body { padding: 14px; display:flex; flex-direction:column; gap:10px; }
.setting-item {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:#10151d;
}
.setting-item strong { display:block; margin-bottom:4px; }
.setting-item span { color:var(--muted); font-size:13px; line-height:1.4; }
.mini-action {
  border:0;
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  background: var(--accent);
  font-weight:700;
}
.mini-action:hover { background: var(--accent-2); }
.setting-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(66,211,146,.1);
  color:#bdebd6;
  border:1px solid rgba(66,211,146,.25);
  font-size:12px;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 280px minmax(0,1fr); }
}
@media (max-width: 780px) {
  body { overflow:auto; }
  .app {
    height:auto;
    min-height:100vh;
    grid-template-columns: 1fr;
  }
  .sidebar { border-right:0; border-bottom:1px solid var(--line); }
}

.register-modal { width: min(620px, 100%); }
.register-form label { display:flex; flex-direction:column; gap:6px; color:#dce2ec; font-size:13px; font-weight:700; }
.register-form input, .register-form textarea { width:100%; background:#0f141b; border:1px solid #2b313c; color:#fff; border-radius:10px; padding:12px 13px; outline:none; }
.register-form input:focus, .register-form textarea:focus { border-color: var(--accent); box-shadow:0 0 0 3px rgba(124,92,255,.12); }
.register-actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:6px; }
