:root {
  --bg-deep: #0D1410; --bg-rail: #111A15; --bg-panel: #15201A; --bg-elevated: #1B2A22; --bg-hover: #22352A;
  --border: #28392F; --accent: #22C55E; --accent-2: #14B8A6; --accent-ink: #06210F;
  --text: #EAF3ED; --muted: #8FA79A; --faint: #5E7468;
  --online: #4ADE80; --danger: #FF5C7A; --gold: #FFD166;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg-deep); color: var(--text); overflow: hidden; -webkit-font-smoothing: antialiased; font-size: 15px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; background: none; border: 0; outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.boot { position: fixed; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 28px; letter-spacing: .12em; color: var(--accent); }

/* ---------- gate ---------- */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(900px 500px at 50% -10%, rgba(34,197,94,.14), transparent 60%), var(--bg-deep); }
.gate-card { width: 100%; max-width: 380px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 18px; padding: 28px; }
.gate-logo { font-weight: 900; font-size: 34px; letter-spacing: .14em; color: var(--accent); text-align: center; }
.gate-tag { text-align: center; color: var(--faint); font-size: 12px; letter-spacing: .06em; margin: 4px 0 20px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg-deep); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tab { flex: 1; padding: 9px; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--muted); }
.auth-tab.active { background: var(--accent); color: var(--accent-ink); }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input { width: 100%; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font-size: 15px; }
.field input:focus { border-color: var(--accent); }
.auth-hint { font-size: 12.5px; color: var(--gold); line-height: 1.5; margin: 2px 0 10px; }
.auth-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.btn-primary { width: 100%; background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: 12px; border-radius: 10px; font-size: 15px; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 72px 260px minmax(0, 1fr) auto; height: 100dvh; }
.rail { background: var(--bg-rail); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 10px; overflow-y: auto; }
.rail-item { position: relative; width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--bg-elevated);
  color: var(--muted); font-weight: 800; font-size: 13px; transition: border-radius .15s, background .15s, color .15s; flex-shrink: 0; }
.rail-item:hover, .rail-item.active { border-radius: 13px; background: var(--accent); color: var(--accent-ink); }
.rail-item.active::before { content: ""; position: absolute; left: -12px; width: 4px; height: 24px; border-radius: 0 3px 3px 0; background: var(--text); }
.rail-item.home { background: var(--accent-2); color: #04211D; font-size: 18px; }
.rail-item.premium { background: linear-gradient(135deg, var(--gold), var(--accent)); color: #102010; font-size: 18px; margin-top: auto; }
.rail-sep { width: 30px; height: 1px; background: var(--border); flex-shrink: 0; }
.dot-badge { position: absolute; right: -3px; bottom: -3px; 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(--bg-rail); }

.side { background: var(--bg-panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.side-head { padding: 16px; border-bottom: 1px solid var(--border); min-height: 57px; }
.side-title { font-weight: 800; font-size: 16px; }
.side-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.section-label { font-size: 11.5px; color: var(--faint); padding: 14px 8px 6px; font-weight: 700; letter-spacing: .02em; }
.row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; text-align: left; color: var(--muted); }
.row:hover { background: var(--bg-hover); color: var(--text); }
.row.active { background: var(--bg-elevated); color: var(--text); }
.row .meta { flex: 1; min-width: 0; }
.row .name { font-size: 14.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row .sub.call { color: var(--online); }
.row .hash { width: 18px; text-align: center; color: var(--faint); font-size: 16px; }
.badge { background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: grid; place-items: center; }
.voice-users { margin: 0 0 6px 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 3px 8px; font-size: 13px; color: var(--muted); }
.empty-note { padding: 12px 8px; font-size: 13px; color: var(--faint); line-height: 1.55; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #06210F; flex-shrink: 0; position: relative; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.md { width: 30px; height: 30px; font-size: 11.5px; }
.avatar .st { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--bg-panel); background: #3D4D44; }
.avatar .st.on { background: var(--online); }
.crown { color: var(--gold); font-size: 12px; margin-left: 4px; }

.me-bar { border-top: 1px solid var(--border); padding: 8px 10px; display: flex; align-items: center; gap: 8px; }
.me-info { flex: 1; min-width: 0; text-align: left; border-radius: 8px; padding: 3px 4px; }
.me-info:hover { background: var(--bg-hover); }
.me-name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-status { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; font-size: 16px; flex-shrink: 0; position: relative; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.lock::after { content: "👑"; position: absolute; top: -3px; right: -3px; font-size: 9px; }

/* ---------- friends & servers ---------- */
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head-btns { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.btn-small { background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 12.5px; padding: 7px 10px; border-radius: 8px; white-space: nowrap; flex-shrink: 0; }
.btn-small:hover { filter: brightness(1.08); }
.req-actions { display: flex; gap: 6px; flex-shrink: 0; }
.req-btn { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.req-btn.ok { background: var(--accent); color: var(--accent-ink); }
.req-btn.no { background: var(--bg-hover); color: var(--muted); }
.req-btn.no:hover { background: var(--danger); color: #fff; }
.section-label.with-add { display: flex; align-items: center; justify-content: space-between; padding-right: 4px; }
.section-add { width: 22px; height: 22px; border-radius: 6px; color: var(--muted); font-size: 17px; line-height: 1; display: grid; place-items: center; }
.section-add:hover { background: var(--bg-hover); color: var(--text); }
.rail-item.add { color: var(--accent); font-size: 24px; font-weight: 400; }
.rail-item.add:hover { background: var(--accent); color: var(--accent-ink); }
.owner-tag { color: var(--gold); }
.composer-locked { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--bg-elevated); border: 1px dashed var(--border); border-radius: 14px; padding: 12px 14px; color: var(--muted); font-size: 13.5px; }
.empty-big { font-size: 40px; margin-bottom: 8px; }
.empty-chat p { margin: 4px 0; }
.empty-chat b { color: var(--accent); }
.empty-note b { color: var(--accent); }
.field-hint { display: block; color: var(--faint); font-size: 11.5px; margin-top: 5px; }
.invite-note { background: rgba(34,197,94,.1); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin-bottom: 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 16px 0 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-primary.alt { background: var(--bg-hover); color: var(--text); }
.chan-edit { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 6px 10px; border-radius: 9px; font-size: 14px; }
.chan-edit:hover { background: var(--bg-hover); }
.two-btns { display: flex; gap: 8px; margin-top: 8px; }
.two-btns .btn-ghost { flex: 1; border: 1px solid var(--border); }
.danger-text { color: var(--danger) !important; }
.modal .lead b { color: var(--accent); }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-header { height: 57px; flex-shrink: 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.chat-title { font-weight: 800; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-topic { font-size: 12.5px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { margin-left: auto; display: flex; gap: 2px; }
.menu-btn { display: none; }
.conn-state { font-size: 11.5px; color: var(--gold); white-space: nowrap; }

.messages { flex: 1; overflow-y: auto; padding: 14px 16px 6px; display: flex; flex-direction: column; }
.msg { display: flex; gap: 12px; padding: 3px 8px; border-radius: 10px; }
.msg:hover { background: rgba(255,255,255,.025); }
.msg.first { margin-top: 10px; }
.msg .gutter { width: 38px; flex-shrink: 0; }
.msg .body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 700; font-size: 14px; }
.msg-time { font-size: 11px; color: var(--faint); }
.msg-text { font-size: 14.5px; line-height: 1.5; color: #DCE7E0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.pending .msg-text { opacity: .55; }
.msg-text a { color: var(--accent-2); }
.day { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11.5px; font-weight: 600; margin: 16px 0 4px; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.load-more { align-self: center; font-size: 12.5px; color: var(--muted); padding: 6px 12px; border-radius: 8px; margin-bottom: 6px; }
.load-more:hover { background: var(--bg-hover); }
.empty-chat { margin: auto; text-align: center; color: var(--faint); font-size: 14px; max-width: 320px; line-height: 1.6; }

.voice-msg { display: inline-flex; align-items: center; gap: 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 22px; padding: 6px 14px 6px 6px; margin-top: 3px; min-width: 210px; }
.voice-play { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
.voice-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--border); position: relative; overflow: hidden; min-width: 90px; }
.voice-bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-2); }
.voice-dur { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.typing { padding: 0 24px; font-size: 12.5px; color: var(--muted); min-height: 18px; }
.composer-wrap { padding: 6px 16px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.composer { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; display: flex; align-items: flex-end; padding: 6px 6px 6px 12px; gap: 4px; }
.composer:focus-within { border-color: #35503F; }
.composer textarea { flex: 1; resize: none; font-size: 15px; line-height: 1.45; padding: 7px 0; max-height: 160px; min-height: 36px; }
.composer textarea::placeholder { color: var(--faint); }
.send-btn { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.rec { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; background: var(--bg-elevated); border: 1px solid var(--danger); border-radius: 14px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-size: 14px; }
.rec-hint { flex: 1; font-size: 12.5px; color: var(--muted); }
.btn-ghost { padding: 8px 12px; border-radius: 9px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- call ---------- */
.callbar { margin: 12px 16px 0; padding: 14px; border-radius: 14px; background: var(--bg-elevated); border: 1px solid var(--border); }
.callbar-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.callbar-title { font-size: 13.5px; font-weight: 700; color: var(--online); display: flex; align-items: center; gap: 7px; }
.callbar-title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--online); animation: pulse 1.6s infinite; }
.callbar-timer { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tiles { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.tile { width: 80px; text-align: center; }
.tile .avatar { width: 58px; height: 58px; font-size: 18px; margin: 0 auto 6px; box-shadow: 0 0 0 3px var(--bg-elevated); transition: box-shadow .12s; }
.tile.speaking .avatar { box-shadow: 0 0 0 3px var(--online); }
.tile .tname { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tstate { font-size: 10.5px; color: var(--faint); }
.tile .muted-ico { position: absolute; right: -2px; bottom: -2px; font-size: 12px; background: var(--danger); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; }
.call-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.call-btn { height: 40px; min-width: 40px; padding: 0 12px; border-radius: 11px; background: var(--bg-hover); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; }
.call-btn:hover { filter: brightness(1.15); }
.call-btn.off { background: var(--danger); color: #fff; }
.call-btn.leave { background: var(--danger); color: #fff; margin-left: auto; }
.call-note { font-size: 12px; color: var(--gold); margin-top: 10px; line-height: 1.5; }

.banner { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 300; background: var(--bg-elevated); border: 1px solid var(--accent);
  border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.45); max-width: calc(100vw - 32px); }
.banner .b-text { font-size: 14px; }
.banner .b-text b { color: var(--accent); }
.btn-accept { background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: 9px 14px; border-radius: 9px; }
.btn-decline { background: var(--danger); color: #fff; font-weight: 800; padding: 9px 14px; border-radius: 9px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #26372D; border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px; z-index: 400; max-width: calc(100vw - 32px); }

/* ---------- members ---------- */
.members { width: 230px; border-left: 1px solid var(--border); background: var(--bg-panel); padding: 8px; overflow-y: auto; }
.members .row { cursor: default; }
.members .row:hover { background: none; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(4,8,6,.7); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 18px; padding: 24px; width: 100%; max-width: 440px; max-height: 88dvh; overflow-y: auto; position: relative; }
.modal h2 { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.modal .lead { color: var(--muted); font-size: 13.5px; line-height: 1.55; margin-bottom: 18px; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.plan { border: 1.5px solid var(--border); border-radius: 12px; padding: 13px 15px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.plan.best { border-color: var(--accent); background: rgba(34,197,94,.07); }
.plan b { font-size: 14.5px; }
.plan .price { color: var(--accent); font-weight: 800; }
.plan .price small { color: var(--faint); font-weight: 500; }
.feat { display: flex; gap: 10px; font-size: 13.5px; color: var(--muted); margin: 8px 0; line-height: 1.45; }
.feat::before { content: "✓"; color: var(--online); font-weight: 800; }
.feat.soon::before { content: "…"; color: var(--faint); }
.demo-note { font-size: 12px; color: var(--gold); margin: 14px 0 10px; line-height: 1.5; }
.theme-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px; border: 1.5px solid var(--border); margin-bottom: 8px; text-align: left; }
.theme-row.active { border-color: var(--accent); }
.theme-dots { display: flex; gap: 4px; }
.theme-dots i { width: 16px; height: 16px; border-radius: 50%; display: block; }

.scrim { display: none; }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) { .members { display: none; } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail, .side { position: fixed; top: 0; bottom: 0; z-index: 120; transition: transform .2s ease; }
  .rail { left: 0; width: 72px; transform: translateX(-332px); }
  .side { left: 72px; width: min(260px, calc(100vw - 72px)); transform: translateX(-332px); }
  .app.drawer .rail, .app.drawer .side { transform: none; }
  .app.drawer .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 110; }
  .menu-btn { display: grid; }
  .chat-topic { display: none; }
  .messages { padding: 10px 8px 6px; }
  .msg { gap: 10px; padding: 3px 4px; }
  .composer-wrap { padding: 6px 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .callbar { margin: 10px 8px 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
