/* Palette mirrors the Windows client (App.xaml). */
:root {
  --bg-darkest: #111214;
  --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;
  --red: #F23F43;
  --red-hover: #F65257;
  --red-soft: #3A2024;
  --text: #DBDEE1;
  --text-bright: #F2F3F5;
  --text-secondary: #B5BAC1;
  --text-muted: #949BA4;
  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"] .card-logo,
:root[data-brand="labkit"] .top-logo { border-radius: 22%; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-darkest);
  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; overflow-y: auto;
  background: radial-gradient(1200px 600px at 50% -10%, var(--auth-glow) 0%, var(--bg-darkest) 60%);
}
.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 & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 0; border-radius: 10px;
  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.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%; }
.btn.big { height: 48px; font-size: 16px; }
.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); }

input, select {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid transparent; border-radius: 10px;
  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: 10px 0 0; font-size: 13px; color: var(--text-muted); }
.muted { margin: 4px 0 0; color: var(--text-muted); }
.error { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: #FFB4B6; font-size: 14px; text-align: left; }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row .btn { flex: 1; }

/* ---------- cards: home, lobby, left ---------- */
.card {
  width: 100%; max-width: 420px; padding: 32px 28px 24px; border-radius: 18px;
  background: var(--bg-elevated); box-shadow: 0 18px 48px rgba(0,0,0,.55); text-align: center;
}
.card-logo { width: 64px; height: 64px; }
.card h1 { margin: 10px 0 4px; font-size: 24px; color: var(--text-bright); overflow-wrap: anywhere; }
.brand-line { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.lobby-room { font-size: 28px !important; }
.form { text-align: left; margin-top: 18px; }
.form .btn.primary { margin-top: 16px; }
#account-toggle { margin-top: 14px; }

/* ---------- call layout ---------- */
#call { display: flex; flex-direction: column; background: var(--bg-darkest); }
.topbar {
  display: flex; align-items: center; gap: 10px; height: 56px; flex: none; padding: 0 12px 0 16px;
  padding-top: env(safe-area-inset-top);
}
.top-logo { width: 30px; height: 30px; }
.top-title { flex: 1; min-width: 0; }
.top-room { font-weight: 700; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-status { font-size: 12px; color: var(--text-muted); }
.top-status.pending { color: #F0B232; }

.call-body { flex: 1; min-height: 0; display: flex; gap: 10px; padding: 0 10px; }
.call-main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }

.tiles {
  flex: 1; min-height: 0; display: grid; gap: 10px; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  overflow-y: auto;
}
.tile {
  position: relative; min-height: 160px; aspect-ratio: 16 / 10; border-radius: 16px; background: var(--bg-main);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .12s;
}
.tile.speaking { box-shadow: inset 0 0 0 3px var(--green); }
.tile .avatar { width: 84px; height: 84px; font-size: 30px; }
.tile.speaking .avatar { box-shadow: 0 0 0 4px rgba(35,165,90,.35); }
.tile-name {
  position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px);
  display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px;
  background: rgba(0,0,0,.45); color: var(--text-bright); font-size: 13px;
}
.tile-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-name svg { width: 16px; height: 16px; }
.tile-name .off { color: var(--red); }
.tile-name .share { color: var(--green); }

/* With a screen share the share takes the space and tiles become a strip. */
.call-main.has-stage .tiles {
  flex: none; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; align-content: initial;
}
.call-main.has-stage .tile { flex: none; width: 168px; min-height: 0; height: 100px; aspect-ratio: auto; }
.call-main.has-stage .tile .avatar { width: 48px; height: 48px; font-size: 18px; }

.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; transition: box-shadow .12s;
}

.alone {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(460px, calc(100% - 24px));
  padding: 16px 18px; border-radius: 14px; background: var(--bg-elevated); box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.alone-title { font-weight: 700; color: var(--text-bright); }
.alone-text { margin: 2px 0 10px; font-size: 13px; color: var(--text-muted); }
.link-box {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 10px;
  background: var(--bg-input); color: var(--text-bright); cursor: pointer; text-align: left;
}
.link-box span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-box:hover { background: var(--bg-hover); }

/* ---------- screen share stage ---------- */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: #000; }
.stage-tabs { display: flex; gap: 6px; padding: 6px 8px; background: var(--bg-elevated); overflow-x: auto; }
.stage-tabs:empty { display: none; }
.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; }

/* ---------- chat panel ---------- */
.chat-panel {
  width: 340px; flex: none; display: flex; flex-direction: column; border-radius: 16px; background: var(--bg-main); overflow: hidden;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 8px 0 16px; font-weight: 700; color: var(--text-bright); }
.messages { flex: 1; overflow-y: auto; padding: 4px 0 8px; }
.empty-chat { padding: 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
.msg { padding: 2px 16px; }
.msg.first { margin-top: 12px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; font-size: 13px; color: var(--text-bright); }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.msg-text a { color: #00A8FC; }
.composer { flex: none; padding: 8px 12px 12px; }

/* ---------- control bar ---------- */
.controls {
  flex: none; display: flex; justify-content: center; gap: 12px; padding: 12px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.round {
  position: relative; width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--bg-hover);
  color: var(--text-bright); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .12s;
}
.round:hover { background: var(--bg-selected); }
.round svg { width: 22px; height: 22px; }
.round.off { background: var(--red); color: #fff; }
.round.off:hover { background: var(--red-hover); }
.round.active { background: var(--accent); color: #fff; }
.round.hangup { width: 64px; border-radius: 26px; background: var(--red); color: #fff; }
.round.hangup:hover { background: var(--red-hover); }
.badge {
  position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
}

/* ---------- 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; }
.dialog-actions .btn:only-child, .dialog-actions .hidden + .btn { margin-left: auto; }
.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: 96px; 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;
  overflow-wrap: anywhere;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #4a1c1f; }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  .topbar { padding-left: 12px; }
  .topbar .btn span { display: none; }
  .call-body { padding: 0 8px; }
  .chat-panel { position: fixed; inset: 0; z-index: 20; width: auto; border-radius: 0; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
  .tile { min-height: 120px; }
  .tile .avatar { width: 64px; height: 64px; font-size: 24px; }
  .controls { gap: 8px; }
  .round { width: 48px; height: 48px; }
  .round.hangup { width: 58px; }
}
