/* ============ tokens ============ */
:root {
  --rail: #0b0f0e;
  --side: #121816;
  --main: #171e1c;
  --elev: #1f2826;
  --elev-2: #273230;
  --hover: rgba(255, 255, 255, .045);
  --active: rgba(255, 255, 255, .085);
  --line: rgba(255, 255, 255, .07);
  --text: #e4ebe8;
  --text-2: #b7c4bf;
  --muted: #7f918b;
  --accent: #2fbf71;
  --accent-2: #26a361;
  --accent-ink: #04140b;
  --danger: #ef4f5a;
  --warn: #f0b429;
  --mention-bg: rgba(240, 180, 41, .08);
  --mention-line: #f0b429;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Nastaliq Urdu", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--main);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: #4fb4ff; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 4px 0; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .1); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  background: var(--elev-2); color: var(--text); font-weight: 600; font-size: 14px;
  transition: background .12s, transform .06s;
}
.btn:hover { background: #313d3a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #3fd282; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #ff6670; }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.off { color: var(--danger); }

input[type=text], input[type=password], input:not([type]), textarea, select {
  width: 100%; background: var(--rail); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; outline: none; transition: border-color .12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 14px 0 0; }
label input, label select, label textarea { margin-top: 6px; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 15px; color: var(--text); }
label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ============ auth ============ */
.auth {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px; overflow: auto;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(47, 191, 113, .16), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(58, 160, 255, .10), transparent 60%),
    var(--rail);
}
.auth-card {
  width: min(420px, 100%); background: var(--side); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 18px 0 2px; font-size: 24px; }
.auth-card p { margin: 0; }
.auth-card .btn.block { margin-top: 18px; padding: 12px; }
.auth-card #auth-switch { margin-top: 14px; text-align: center; }
.auth-card #auth-switch a { cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.brand img { width: 34px; height: 34px; }

/* ============ app grid ============ */
.app {
  height: 100dvh; display: grid;
  grid-template-columns: 72px 248px minmax(0, 1fr) 240px;
}
.app.no-members { grid-template-columns: 72px 248px minmax(0, 1fr) 0; }
.app.no-members .members { display: none; }

/* ============ rail ============ */
.rail {
  background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 0; overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-sep { width: 32px; height: 2px; background: var(--line); border-radius: 2px; margin: 2px 0; flex: none; }
.rail-item { position: relative; flex: none; }
.rail-btn {
  width: 48px; height: 48px; border-radius: 24px; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--elev); color: var(--text); font-weight: 700; font-size: 15px; overflow: hidden;
  transition: border-radius .18s, background .18s, color .18s;
}
.rail-btn img { width: 100%; height: 100%; object-fit: cover; }
.rail-btn:hover, .rail-item.active .rail-btn { border-radius: 16px; background: var(--accent); color: var(--accent-ink); }
.rail-btn.home { background: var(--elev); }
.rail-btn.home img { width: 30px; height: 30px; }
.rail-btn.add { color: var(--accent); background: var(--elev); }
.rail-btn.add:hover { color: var(--accent-ink); }
.rail-item::before {
  content: ""; position: absolute; left: -12px; top: 50%; width: 4px; height: 0; border-radius: 0 4px 4px 0;
  background: var(--text); transform: translateY(-50%); transition: height .15s;
}
.rail-item.unread::before { height: 8px; }
.rail-item:hover::before { height: 20px; }
.rail-item.active::before { height: 40px; }
.badge {
  position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center;
  border: 3px solid var(--rail); box-sizing: content-box;
}

/* ============ sidebar ============ */
.sidebar { background: var(--side); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head {
  height: 52px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--line); font-weight: 700;
}
.sidebar-head .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-head button.title {
  background: none; border: 0; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 8px 0; font-weight: 700;
}
.channel-list { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.cat {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 4px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.cat .icon-btn { width: 22px; height: 22px; }
.ch {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; cursor: pointer;
  padding: 7px 8px; border-radius: 6px; color: var(--muted); text-align: left; position: relative; min-height: 34px;
}
.ch:hover { background: var(--hover); color: var(--text-2); }
.ch.active { background: var(--active); color: var(--text); }
.ch.unread { color: var(--text); font-weight: 700; }
.ch.unread::before {
  content: ""; position: absolute; left: -8px; top: 50%; width: 4px; height: 8px; border-radius: 0 4px 4px 0;
  background: var(--text); transform: translateY(-50%);
}
.ch .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch .actions { display: none; }
.ch:hover .actions { display: flex; }
.ch .actions .icon-btn { width: 24px; height: 24px; }
.ch .badge { position: static; border: 0; }
.voice-users { padding: 2px 0 6px 30px; display: flex; flex-direction: column; gap: 1px; }
.voice-user {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; color: var(--text-2);
  font-size: 14px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%;
}
.voice-user:hover { background: var(--hover); }
.voice-user .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-user .flags { display: flex; gap: 3px; color: var(--muted); }
.voice-user .flags .live { background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; }

/* ============ avatars ============ */
.av {
  --size: 32px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: calc(var(--size) * .42); color: #0b0f0e; position: relative; user-select: none;
  transition: box-shadow .1s;
}
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.av.s20 { --size: 22px; }
.av.s40 { --size: 40px; }
.av.s80 { --size: 80px; }
.av .dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  background: #6b7a75; border: 3px solid var(--side); box-sizing: content-box;
}
.av .dot.on { background: var(--accent); }
.speaking .av, .av.speaking { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--accent); }

/* ============ voice + user panels ============ */
.voice-panel { border-top: 1px solid var(--line); padding: 10px 10px 8px; background: #101614; }
.voice-panel .status { display: flex; align-items: center; gap: 8px; }
.voice-panel .status b { color: var(--accent); font-size: 14px; }
.voice-panel .status.warn b { color: var(--warn); }
.voice-panel .status.bad b { color: var(--danger); }
.voice-panel .where { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.voice-panel .where:hover { text-decoration: underline; }
.voice-panel .row { display: flex; gap: 6px; margin-top: 8px; }
.voice-panel .row .btn { flex: 1; padding: 7px; }
.voice-panel .row .btn.on { background: var(--accent); color: var(--accent-ink); }
.user-panel {
  height: 56px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 8px; background: #0f1513;
}
.user-panel .who { flex: 1; min-width: 0; line-height: 1.2; cursor: pointer; border-radius: 6px; padding: 4px; display: flex; gap: 8px; align-items: center; }
.user-panel .who:hover { background: var(--hover); }
.user-panel .who .names { min-width: 0; }
.user-panel .who .names b, .user-panel .who .names span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-panel .who .names b { font-size: 14px; }
.user-panel .who .names span { font-size: 12px; color: var(--muted); }

/* ============ main ============ */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--main); }
.main-head {
  height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}
.main-head .title { font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.main-head .title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-head .title svg { color: var(--muted); }
.main-head .menu-btn { display: none; }
.main-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

.empty {
  flex: 1; display: grid; place-items: center; text-align: center; padding: 32px; color: var(--muted);
}
.empty h2 { color: var(--text); margin: 12px 0 6px; }
.empty .art { font-size: 48px; }

/* ============ messages ============ */
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 0 8px; overscroll-behavior: contain; }
.messages .start { padding: 16px 16px 20px; }
.messages .start .big { width: 64px; height: 64px; border-radius: 50%; background: var(--elev-2); display: grid; place-items: center; margin-bottom: 10px; }
.messages .start .big svg { width: 34px; height: 34px; }
.messages .start h2 { margin: 0 0 4px; font-size: 26px; }
.messages .loading { text-align: center; color: var(--muted); padding: 12px; font-size: 13px; }
.day { display: flex; align-items: center; gap: 10px; margin: 18px 16px 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.msg { position: relative; padding: 2px 56px 2px 72px; min-height: 26px; }
.msg.head { margin-top: 14px; padding-top: 4px; }
.msg:hover { background: rgba(0, 0, 0, .14); }
.msg.mentioned { background: var(--mention-bg); box-shadow: inset 2px 0 0 var(--mention-line); }
.msg.pending { opacity: .55; }
.msg .av { position: absolute; left: 16px; top: 6px; --size: 40px; cursor: pointer; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 700; cursor: pointer; }
.msg .author:hover { text-decoration: underline; }
.msg .time { font-size: 12px; color: var(--muted); }
.msg .side-time {
  position: absolute; left: 0; width: 64px; text-align: right; top: 5px; font-size: 11px; color: var(--muted); display: none;
}
.msg:not(.head):hover .side-time { display: block; }
.msg .body { word-wrap: break-word; overflow-wrap: anywhere; white-space: normal; color: var(--text); }
.msg .body.big-emoji { font-size: 44px; line-height: 1.2; }
.msg .edited { font-size: 11px; color: var(--muted); margin-left: 4px; }
.msg code { font-family: var(--mono); font-size: 13px; background: var(--rail); padding: 1px 5px; border-radius: 4px; }
.msg pre { background: var(--rail); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 6px 0; max-width: 100%; }
.msg pre code { background: none; padding: 0; white-space: pre; }
.msg .mention { background: rgba(47, 191, 113, .16); color: #7fe0ac; padding: 0 3px; border-radius: 4px; font-weight: 600; }
.msg .mention.me { background: rgba(240, 180, 41, .2); color: #ffd36b; }
.msg .spoiler { background: #000; color: transparent; border-radius: 4px; cursor: pointer; padding: 0 2px; }
.msg .spoiler.shown { background: rgba(255, 255, 255, .1); color: inherit; }
.msg .reply {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 2px; cursor: pointer;
  min-width: 0; white-space: nowrap;
}
.msg .reply::before {
  content: ""; position: absolute; left: 36px; top: 12px; width: 30px; height: 10px;
  border-left: 2px solid #3b4845; border-top: 2px solid #3b4845; border-top-left-radius: 6px;
}
.msg .reply .av { position: static; --size: 16px; font-size: 9px; }
.msg .reply b { color: var(--text-2); }
.msg .reply span { overflow: hidden; text-overflow: ellipsis; }
.msg.flash { animation: flash 1.6s; }
@keyframes flash { 0%, 40% { background: rgba(47, 191, 113, .18); } 100% { background: transparent; } }

.attach { margin-top: 6px; }
.attach img, .attach video {
  display: block; max-width: min(420px, 100%); max-height: 340px; border-radius: 8px; cursor: zoom-in; background: var(--rail);
}
.attach audio { width: min(420px, 100%); }
.file-card {
  display: inline-flex; align-items: center; gap: 12px; padding: 12px 14px; max-width: min(420px, 100%);
  background: var(--elev); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text);
}
.file-card .fname { color: #4fb4ff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fsize { font-size: 12px; color: var(--muted); }

.msg-actions {
  position: absolute; right: 16px; top: -14px; display: none; background: var(--elev); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); z-index: 2;
}
.msg:hover .msg-actions, .msg.menu-open .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 32px; height: 30px; border-radius: 0; }
.msg-actions .icon-btn.danger:hover { color: var(--danger); }
.msg .edit-box textarea { min-height: 44px; resize: none; margin: 4px 0; }
.msg .edit-box .hint { font-size: 12px; color: var(--muted); }
.msg .edit-box .hint a { cursor: pointer; }

/* ============ composer ============ */
.composer-wrap { padding: 0 16px 20px; flex: none; position: relative; }
.typing { height: 22px; font-size: 12px; color: var(--text-2); padding: 3px 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typing .dots { display: inline-block; letter-spacing: 1px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.composer { background: var(--elev); border-radius: var(--radius); }
.composer .bar {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; font-size: 13px; color: var(--text-2);
  border-bottom: 1px solid var(--line);
}
.composer .row { display: flex; align-items: flex-end; gap: 4px; padding: 4px 8px; }
.composer textarea {
  flex: 1; border: 0; background: transparent; resize: none; max-height: 40vh; min-height: 44px; padding: 11px 6px; line-height: 1.4;
}
.composer .icon-btn { width: 40px; height: 44px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; margin: 10px 12px 0;
  background: var(--rail); border-radius: 8px; font-size: 13px; max-width: calc(100% - 24px);
}
.chip img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.chip .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip progress { width: 80px; accent-color: var(--accent); }
.drop-hint {
  position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: 14px; background: rgba(23, 30, 28, .92);
  display: grid; place-items: center; font-size: 20px; font-weight: 700; z-index: 5; pointer-events: none;
}
.autocomplete {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% - 16px); background: var(--elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow); z-index: 4;
}
.autocomplete .opt { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.autocomplete .opt.sel, .autocomplete .opt:hover { background: var(--active); }
.autocomplete .opt span { color: var(--muted); font-size: 13px; }

/* ============ voice stage ============ */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #0c1110; }
.stage-grid {
  flex: 1; min-height: 0; padding: 16px; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); align-content: center; overflow-y: auto;
}
.stage-grid.focused { grid-template-columns: 1fr; grid-template-rows: 1fr auto; align-content: stretch; }
.stage-grid.focused .tile:not(.focus) { display: none; }
.tile {
  position: relative; aspect-ratio: 16 / 9; background: var(--elev); border-radius: 12px; overflow: hidden;
  display: grid; place-items: center; cursor: pointer; min-height: 0; border: 2px solid transparent; transition: border-color .1s;
}
.stage-grid.focused .tile.focus { aspect-ratio: auto; height: 100%; }
.tile.speaking { border-color: var(--accent); }
.tile .av { --size: 84px; }
.tile.speaking .av { box-shadow: none; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile video.mirror { transform: scaleX(-1); }
.tile video.cover { object-fit: cover; }
.tile .label {
  position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 16px);
  background: rgba(0, 0, 0, .6); padding: 3px 8px; border-radius: 6px; font-size: 13px; font-weight: 600;
}
.tile .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .conn { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .6); padding: 2px 8px; border-radius: 6px; font-size: 12px; color: var(--warn); }
.stage-bar { flex: none; display: flex; justify-content: center; gap: 12px; padding: 14px; flex-wrap: wrap; }
.round {
  width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--elev-2); color: var(--text); transition: background .12s;
}
.round:hover { background: #34413e; }
.round.on { background: var(--text); color: var(--rail); }
.round.off { background: rgba(239, 79, 90, .18); color: var(--danger); }
.round.leave { background: var(--danger); color: #fff; }
.round.leave:hover { background: #ff6670; }
.round svg.i { width: 22px; height: 22px; }
.stage-join { flex: 1; display: grid; place-items: center; text-align: center; padding: 24px; }
.stage-join .who-here { display: flex; justify-content: center; gap: -6px; margin: 16px 0; }
.stage-join .who-here .av { margin: 0 -4px; box-shadow: 0 0 0 3px #0c1110; }

/* ============ members ============ */
.members { background: var(--side); overflow-y: auto; padding: 8px 8px 16px; }
.member {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; width: 100%;
  border: 0; background: none; text-align: left;
}
.member:hover { background: var(--hover); }
.member.offline { opacity: .45; }
.member .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .crown { color: var(--warn); }

/* ============ overlays ============ */
.backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .66); display: grid; place-items: center; padding: 16px; z-index: 50;
  animation: fade .12s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--side);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); animation: pop .14s;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal.wide { width: min(560px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 4px; }
.modal header h2 { margin: 0; font-size: 20px; }
.modal .content { padding: 4px 20px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: #0f1513; }
.tabs { display: flex; gap: 4px; background: var(--rail); padding: 4px; border-radius: 10px; margin: 12px 0 4px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 600; }
.tabs button.active { background: var(--elev-2); color: var(--text); }
.radio-card {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px; background: var(--rail); cursor: pointer;
  margin-top: 8px; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); font-weight: 600; border: 1px solid transparent;
}
.radio-card:has(input:checked) { border-color: var(--accent); background: rgba(47, 191, 113, .08); }
.radio-card input { accent-color: var(--accent); margin: 0 0 0 auto; width: 18px; height: 18px; }
.copy-row { display: flex; gap: 8px; margin-top: 6px; }
.copy-row input { font-family: var(--mono); font-size: 13px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatches button.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--side) inset; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 6px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.list-row .name { flex: 1; min-width: 0; }
.profile-head { display: flex; align-items: center; gap: 14px; margin: 8px 0; }
.profile-head .av { --size: 72px; }
.danger-zone { border: 1px solid rgba(239, 79, 90, .35); border-radius: 10px; padding: 12px; margin-top: 22px; display: flex; align-items: center; gap: 12px; }
.danger-zone p { margin: 0; flex: 1; font-size: 13px; color: var(--text-2); }

.popover {
  position: fixed; z-index: 60; width: 280px; background: var(--side); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; animation: pop .1s;
}
.popover .banner { height: 54px; }
.popover .inner { padding: 0 16px 16px; }
.popover .av { --size: 72px; margin-top: -36px; border: 5px solid var(--side); box-sizing: content-box; }
.popover h3 { margin: 6px 0 0; font-size: 19px; }
.popover .uname { color: var(--muted); font-size: 13px; }
.popover .btn { margin-top: 12px; }
.popover input[type=range] { width: 100%; accent-color: var(--accent); }

.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .9); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--elev-2); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: pop .15s;
  max-width: calc(100vw - 32px);
}
.toast.err { background: #4a1d22; color: #ffd0d4; }
.connection {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 90; background: var(--warn); color: #1b1300;
  font-weight: 700; font-size: 13px; padding: 4px 14px; border-radius: 0 0 8px 8px;
}

.call-card { text-align: center; padding: 28px 24px 24px; }
.call-card .av { --size: 96px; margin: 0 auto 14px; animation: ring 1.4s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(47, 191, 113, .6); } 100% { box-shadow: 0 0 0 22px rgba(47, 191, 113, 0); } }
.call-card .actions { display: flex; justify-content: center; gap: 24px; margin-top: 22px; }
.call-card .round { width: 60px; height: 60px; }
.call-card .round.accept { background: var(--accent); color: var(--accent-ink); }

.scrim { display: none; }

/* ============ responsive ============ */
@media (max-width: 1100px) {
  .app, .app.no-members { grid-template-columns: 72px 240px minmax(0, 1fr); }
  .members {
    position: fixed; right: 0; top: 0; bottom: 0; width: min(280px, 85vw); z-index: 30; transform: translateX(100%);
    transition: transform .2s; box-shadow: var(--shadow);
  }
  .app.show-members .members { transform: none; display: block; }
  .app.show-members .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }
}
@media (max-width: 760px) {
  .app, .app.no-members { grid-template-columns: minmax(0, 1fr); }
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 30; transition: transform .2s; }
  .rail { left: 0; width: 72px; transform: translateX(-332px); }
  .sidebar { left: 72px; width: min(260px, calc(100vw - 72px)); transform: translateX(-332px); }
  .app.show-nav .rail, .app.show-nav .sidebar { transform: none; }
  .app.show-nav .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }
  .main { grid-column: 1; }
  .main-head .menu-btn { display: inline-grid; margin-left: -8px; }
  .main-head { padding-left: 12px; }
  .msg { padding-left: 60px; padding-right: 12px; }
  .msg .av { left: 10px; --size: 36px; }
  .msg .reply::before { left: 28px; width: 26px; }
  .msg-actions { right: 8px; }
  .composer-wrap { padding: 0 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .stage-grid { padding: 8px; gap: 8px; }
  .round { width: 48px; height: 48px; }
}
@media (hover: none) {
  .msg:hover { background: none; }
  .msg:hover .msg-actions { display: none; }
  .msg.menu-open .msg-actions { display: flex; }
  .ch .actions { display: flex; }
}

/* ============ added: chat container, call area, menus ============ */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.call-area.in-call { flex: none; height: min(48vh, 440px); border-bottom: 1px solid var(--line); }
.call-area.in-call .stage-grid { align-content: start; }
.call-area.banner {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: rgba(47, 191, 113, .08); border-bottom: 1px solid var(--line);
}
.call-area.banner span:not(.av) { flex: 1; min-width: 0; font-size: 14px; }
.sidebar-head .t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { padding: 6px; }
.menu-item { justify-content: flex-start; font-weight: 500; padding: 9px 10px; }
.menu-item.danger-text { color: var(--danger); }
.popover:has(.menu) { width: 220px; }
.av.s20 .dot { width: 7px; height: 7px; border-width: 2px; right: -3px; bottom: -3px; }
.main-head .av .dot { border-color: var(--main); }
.menu-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px 4px; }
.share-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; border: 1px solid transparent; border-radius: 8px;
  background: none; padding: 9px 10px; cursor: pointer; text-align: left; color: var(--text);
}
.share-opt:hover { background: var(--hover); }
.share-opt.sel { border-color: rgba(47, 191, 113, .5); background: rgba(47, 191, 113, .06); }
.share-opt span { font-size: 12px; color: var(--muted); }
.popover:has(.share-menu) { width: 250px; }

/* ============ settings window ============ */
.modal.settings-modal { width: min(860px, 100%); }
.settings-modal .content { padding: 0; }
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); height: min(72dvh, 680px); border-top: 1px solid var(--line); }
.settings-nav { background: #0f1513; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.settings-nav button {
  display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 6px;
  color: var(--text-2); cursor: pointer; text-align: left; font-weight: 600; font-size: 14px;
}
.settings-nav button:hover { background: var(--hover); color: var(--text); }
.settings-nav button.active { background: var(--active); color: var(--text); }
.settings-pane { overflow-y: auto; padding: 6px 22px 24px; }
.settings-pane h3 { margin: 12px 0 4px; font-size: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid2 .radio-card { margin-top: 8px; }
label .val { float: right; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text); }
input[type=range] { width: 100%; accent-color: var(--accent); margin-top: 10px; }
input[type=range]:disabled { opacity: .5; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch { position: relative; width: 42px; height: 24px; flex: none; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #4a5652; transition: background .15s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.mic-test { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.mic-test .btn { flex: none; min-width: 130px; }
.meter { position: relative; flex: 1; height: 10px; border-radius: 5px; background: var(--rail); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: #6b7a75; border-radius: 5px; transition: width .05s linear; }
.meter-fill.open { background: var(--accent); }
.meter-mark { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: var(--warn); border-radius: 2px; }
.ptt-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.ptt-row .btn { min-width: 120px; font-family: var(--mono); }
.ptt-row .btn.capturing { background: var(--warn); color: #1b1300; }
.cam-test { margin-top: 10px; }
.cam-preview { display: block; width: min(360px, 100%); margin-top: 10px; border-radius: 10px; background: #000; transform: scaleX(-1); }
kbd {
  font-family: var(--mono); font-size: 12px; background: var(--rail); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: 2px 8px; white-space: nowrap;
}
@media (max-width: 760px) {
  .settings { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); height: min(80dvh, 720px); }
  .settings-nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .settings-nav button { flex: none; }
  .settings-pane { padding: 6px 16px 20px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ============ invite / download landing ============ */
.get-app h1 { margin: 18px 0 4px; }
.steps { margin: 18px 0 8px; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 18px; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; display: flex; flex-direction: column; gap: 8px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center;
}
.steps .btn { margin: 0; text-decoration: none; }
.steps code { font-family: var(--mono); background: var(--rail); padding: 1px 6px; border-radius: 4px; color: var(--text); }
.link-btn { border: 0; background: none; color: #4fb4ff; cursor: pointer; padding: 0; font-size: inherit; }
.ga-alt { text-align: center; margin-top: 18px; }

/* ============ keybinds ============ */
.kb-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.kb-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 220px) 32px; gap: 8px; align-items: center;
  padding: 10px; background: var(--rail); border: 1px solid var(--line); border-radius: 10px;
}
.kb-row select { padding: 8px 10px; }
.kb-keys { font-family: var(--mono); font-size: 13px; font-weight: 600; justify-content: center; min-height: 38px; }
.kb-keys.capturing { background: var(--warn); color: #1b1300; }
.kb-hint { grid-column: 1 / -1; }
.kb-hint.warn { color: var(--warn); }
.kb-buttons { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.notice { background: rgba(240, 180, 41, .1); border: 1px solid rgba(240, 180, 41, .35); border-radius: 8px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.ptt-row kbd { font-size: 13px; }
@media (max-width: 760px) { .kb-row { grid-template-columns: minmax(0, 1fr) 32px; } .kb-keys { grid-column: 1; } }

/* ============ ping ============ */
.ping-chip { font-size: 12px; font-weight: 700; margin-left: 6px; color: var(--muted); cursor: help; }
.ping-chip.good, .tile-ping.good { color: var(--accent); }
.ping-chip.ok, .tile-ping.ok { color: var(--warn); }
.ping-chip.bad, .tile-ping.bad { color: var(--danger); }
.tile-ping {
  position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .6); padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 700;
}
