/* Palette mirrors the Windows client (App.xaml). */
:root {
  --bg-rail: #0E0F12;
  --bg-darkest: #111214;
  --bg-sidebar: #15161A;
  --bg-main: #1B1C20;
  --bg-elevated: #202126;
  --bg-input: #25262B;
  --bg-hover: #2D2F35;
  --bg-selected: #35373D;
  --divider: #2A2C32;
  --accent: #5865F2;
  --accent-hover: #6571F5;
  --accent-soft: #292E5A;
  --accent-text: #AEB6FF;
  --auth-glow: #23264A;
  --green: #23A55A;
  --green-hover: #2DBD68;
  --red: #F23F43;
  --red-soft: #3A2024;
  --yellow: #F0B232;
  --text: #DBDEE1;
  --text-bright: #F2F3F5;
  --text-secondary: #B5BAC1;
  --text-muted: #949BA4;
  --radius: 10px;
  color-scheme: dark;
}

/* ЛабКит Звонки (лабкит.рф): the landing's blues instead of Discord violet. */
:root[data-brand="labkit"] {
  --accent: #1F6FD0;
  --accent-hover: #2B7FE3;
  --accent-soft: #15345C;
  --accent-text: #8EC2FF;
  --auth-glow: #12345B;
}
:root[data-brand="labkit"] .boot-logo,
:root[data-brand="labkit"] .auth-logo,
:root[data-brand="labkit"] .head-logo { border-radius: 22%; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text);
  font: 15px/1.4 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.sprite { display: none; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }

.screen { position: fixed; inset: 0; }
.center { display: flex; align-items: center; justify-content: center; padding: 16px; }
.boot-logo { width: 72px; height: 72px; opacity: .85; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .55; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border: 0; border-radius: 8px;
  background: var(--bg-hover); color: var(--text-bright); font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .12s;
}
.btn:hover { background: var(--bg-selected); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.success { background: var(--green); color: #fff; }
.btn.success:hover { background: var(--green-hover); }
.btn.danger { background: var(--red); color: #fff; }
.btn.secondary { background: var(--bg-input); }
.btn.ghost { background: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text-bright); }
.btn.link { background: none; height: auto; padding: 4px; color: var(--accent-text); font-weight: 500; }
.btn.link:hover { text-decoration: underline; }
.btn.wide { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-secondary); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-bright); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.icon-btn.off { color: var(--red); }
.icon-btn.danger { color: var(--red); }
.icon-btn.danger:hover { background: var(--red-soft); }

input, select {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px;
  background: var(--bg-input); color: var(--text-bright); outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label { display: block; margin: 12px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--text-secondary); text-transform: uppercase; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }
.error { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: #FFB4B6; font-size: 14px; }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row .btn { flex: 1; }

/* ---------- auth ---------- */
#auth { background: radial-gradient(1200px 600px at 50% -10%, var(--auth-glow) 0%, var(--bg-darkest) 60%); overflow-y: auto; }
.auth-card {
  width: 100%; max-width: 420px; padding: 32px 28px 22px; border-radius: 16px;
  background: var(--bg-elevated); box-shadow: 0 18px 48px rgba(0,0,0,.55); text-align: center;
}
.auth-logo { width: 64px; height: 64px; }
.auth-card h1 { margin: 8px 0 4px; font-size: 26px; color: var(--text-bright); }
.auth-sub { margin: 0 0 8px; color: var(--text-muted); }
.auth-invite { margin: 4px 0 8px; color: var(--text-secondary); }
.auth-invite b { color: var(--text-bright); }
.auth-form { text-align: left; margin-top: 12px; }
.auth-form .btn.primary { margin-top: 16px; }
.auth-form .btn.link { display: block; margin: 14px auto 0; }
.download { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--text-muted); }

/* ---------- layout ---------- */
#app { display: flex; }
#sidebar {
  width: 280px; flex: none; display: flex; flex-direction: column;
  background: var(--bg-sidebar); border-right: 1px solid var(--divider); min-height: 0;
}
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-main); }
.scrim { display: none; }

.sidebar-head {
  display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--divider); font-weight: 700; color: var(--text-bright);
}
.sidebar-head span { flex: 1; }
.head-logo { width: 28px; height: 28px; }
.rooms-caption { padding: 16px 16px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--text-muted); }
#rooms { flex: 1; overflow-y: auto; padding: 0 8px 8px; }

.room {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 4px 4px 8px; margin: 1px 0;
  border-radius: 8px; cursor: pointer; color: var(--text-secondary);
}
.room:hover { background: var(--bg-hover); color: var(--text); }
.room.selected { background: var(--bg-selected); color: var(--text-bright); }
.room-hash {
  width: 28px; height: 28px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--bg-hover); color: var(--text-muted); font-weight: 700;
}
.room-text { flex: 1; min-width: 0; }
.room-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-count { font-size: 11px; color: var(--text-muted); }
.room .icon-btn { width: 32px; height: 32px; opacity: .8; }
.room.in-call .room-hash { background: #162D22; color: var(--green); }

.voice-users { margin: 0 0 4px 44px; }
.voice-user {
  display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px;
  font-size: 13px; color: var(--text-secondary); cursor: default; user-select: none;
}
.voice-user:hover { background: var(--bg-hover); }
.voice-user .avatar { width: 24px; height: 24px; font-size: 10px; }
.voice-user .vu-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-user .vu-share { width: 15px; height: 15px; fill: var(--green); }

.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; box-shadow: 0 0 0 2px transparent; transition: box-shadow .1s;
}
.avatar.speaking { box-shadow: 0 0 0 2px var(--green); }

.voice-panel {
  display: flex; align-items: center; gap: 4px; margin: 4px 8px 8px; padding: 9px 8px 9px 12px;
  border-radius: 9px; background: var(--bg-darkest);
}
.voice-info { flex: 1; min-width: 0; }
.voice-status { font-size: 12px; font-weight: 700; color: var(--green); }
.voice-status.pending { color: var(--yellow); }
.voice-status.bad { color: var(--red); }
.voice-room { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.me-panel {
  display: flex; align-items: center; gap: 4px; height: 58px; padding: 0 6px 0 10px;
  background: var(--bg-darkest); padding-bottom: env(safe-area-inset-bottom);
}
.me-text { flex: 1; min-width: 0; margin-left: 6px; }
.me-name { font-size: 13px; font-weight: 700; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 11px; color: var(--text-muted); }

/* ---------- channel ---------- */
.channel-head {
  display: flex; align-items: center; gap: 8px; height: 56px; flex: none; padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--divider);
}
.menu-btn { display: none; }
.hash { font-size: 22px; font-weight: 700; color: var(--text-muted); }
.channel-title { flex: 1; min-width: 0; }
.channel-name { font-weight: 700; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-kind { font-size: 9px; letter-spacing: .07em; color: var(--text-muted); }

.messages { flex: 1; overflow-y: auto; padding: 12px 0 8px; }
.welcome { padding: 24px 20px 12px; }
.welcome-hash {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover); font-size: 34px; font-weight: 700; color: var(--text-bright);
}
.welcome h2 { margin: 12px 0 4px; color: var(--text-bright); }
.welcome p { margin: 0; color: var(--text-muted); }
.msg { display: flex; gap: 14px; padding: 2px 20px; }
.msg:hover { background: rgba(255,255,255,.025); }
.msg.first { margin-top: 14px; }
.msg .avatar { margin-top: 2px; }
.msg .gutter { width: 36px; flex: none; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; color: var(--text-bright); }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.msg-text a { color: #00A8FC; }

.composer { flex: none; padding: 0 16px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.composer input { height: 46px; padding: 0 16px; border-radius: 10px; }

/* ---------- screen share stage ---------- */
.stage { flex: none; display: flex; flex-direction: column; height: 55%; min-height: 220px; border-bottom: 1px solid var(--divider); background: #000; }
.stage-tabs { display: flex; gap: 6px; padding: 6px 8px; background: var(--bg-elevated); overflow-x: auto; }
.stage-tab { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: var(--bg-input); color: var(--text-secondary); cursor: pointer; white-space: nowrap; font-size: 13px; }
.stage-tab.active { background: var(--accent); color: #fff; }
.stage-view { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.stage-view canvas, .stage-view video { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage-empty { color: var(--text-muted); }
.stage-full { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.55); color: #fff; }
.stage-view:fullscreen { background: #000; }

/* ---------- dialogs & popovers ---------- */
.dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px; background: var(--bg-elevated); color: var(--text); box-shadow: 0 18px 48px rgba(0,0,0,.7); }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-body { margin: 0; padding: 18px 20px 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 18px; color: var(--text-bright); }
.dialog-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.meter { height: 6px; margin-top: 8px; border-radius: 3px; background: var(--bg-input); overflow: hidden; }
.meter-fill { width: 0; height: 100%; background: var(--green); transition: width .08s linear; }

.volume-pop { position: fixed; z-index: 30; width: 220px; padding: 12px 14px; border-radius: 10px; background: var(--bg-elevated); box-shadow: 0 12px 32px rgba(0,0,0,.6); }
.volume-name { font-weight: 700; color: var(--text-bright); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.volume-pop input { height: auto; padding: 0; accent-color: var(--accent); background: none; }
.volume-value { font-size: 12px; color: var(--text-muted); text-align: right; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40; transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: #0b0c0e; color: var(--text-bright);
  box-shadow: 0 8px 24px rgba(0,0,0,.6); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #4a1c1f; }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  #sidebar { position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s; }
  #app.nav-open #sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  #app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.5); }
  .menu-btn { display: inline-flex; }
  .channel-head { padding-left: 6px; gap: 4px; }
  .hash { display: none; }
  .channel-head .btn { padding: 0 10px; }
  .channel-head .btn span { display: none; }
  .msg { padding: 2px 12px; gap: 10px; }
  .stage { height: 40%; }
}
