:root {
  --bg: #0e0f13;
  --panel: #16181e;
  --panel-2: #1d2027;
  --line: #262a33;
  --text: #e9ebf0;
  --muted: #8a90a0;
  --accent: #7c8cff;
  --accent-soft: rgba(124, 140, 255, .14);
  --talk: #3ddc97;
  --danger: #ff5c6c;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Полоса заголовка: за неё таскается окно в приложении */
.titlebar {
  height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 16px;
  -webkit-app-region: drag;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.screen { flex: 1; display: flex; flex-direction: column; padding: 8px 16px 16px; min-height: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }

/* ---------- Вход ---------- */
#login { justify-content: center; align-items: center; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.login-card p { margin: -6px 0 4px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); }
input:not([type=range]), select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  user-select: text;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.server summary { cursor: pointer; color: var(--muted); font-size: 12px; list-style: none; }
.server summary::before { content: "›"; display: inline-block; margin-right: 6px; transition: transform .15s; }
.server[open] summary::before { transform: rotate(90deg); }
.server .field { margin-top: 8px; }

.error { color: var(--danger); margin: 0; font-size: 13px; }

.btn {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 10px; padding: 11px 16px;
  cursor: pointer; transition: filter .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #0b0c10; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: default; }
.wide { width: 100%; }

/* ---------- Комната ---------- */
#room { gap: 12px; width: 100%; max-width: 560px; margin: 0 auto; }
.room-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 0; }
.room-title { font-size: 18px; font-weight: 600; }

.net {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px;
}
.net-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.net.good .net-dot { background: var(--talk); }
.net.warn .net-dot { background: #ffc15c; }
.net.bad .net-dot { background: var(--danger); }

.people { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }

.person {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px;
}
.avatar {
  --c: #555;
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c); color: #0b0c10; font-weight: 700;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 2px transparent;
  transition: box-shadow .12s;
}
.person.speaking .avatar { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--talk), 0 0 16px rgba(61, 220, 151, .45); }

.who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.name-line { display: flex; align-items: center; gap: 6px; }
.pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; }

.vol { display: flex; align-items: center; gap: 8px; }
.vol-val { width: 28px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 4px; border-radius: 4px; outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--accent) var(--p, 100%), var(--line) var(--p, 100%));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--text); border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

.icon, .round {
  display: grid; place-items: center; border: 0; cursor: pointer; color: var(--muted);
  background: transparent; transition: background .15s, color .15s;
}
.icon { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.icon:hover { background: var(--panel-2); color: var(--text); }
.i-spk-off, .i-mic-off { display: none; }
.mute-peer.off { color: var(--danger); }
.mute-peer.off .i-spk { display: none; }
.mute-peer.off .i-spk-off { display: block; }
.person .i-muted { color: var(--danger); flex: none; }

/* ---------- Нижняя панель ---------- */
.controls { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border-radius: 10px; padding: 3px; }
.seg { font: inherit; font-size: 13px; border: 0; border-radius: 8px; padding: 8px; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.seg.active { background: var(--line); color: var(--text); }

.ptt-row { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.keycap {
  font: inherit; font-weight: 600; font-size: 13px; min-width: 44px;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 8px;
  padding: 4px 10px; cursor: pointer;
}
.keycap.listening { border-color: var(--accent); color: var(--accent); }
.keycap.held { border-color: var(--talk); color: var(--talk); }
.hint { margin: 0; padding: 0 4px; }

.bar { display: flex; justify-content: center; gap: 12px; }
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--panel-2); color: var(--text); }
.round:hover { background: var(--line); }
.round.off { background: rgba(255, 92, 108, .15); color: var(--danger); }
.round.off .i-mic { display: none; }
.round.off .i-mic-off { display: block; }
.round.live { background: rgba(61, 220, 151, .16); color: var(--talk); }
.round.danger:hover { background: rgba(255, 92, 108, .18); color: var(--danger); }

.settings { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.row-label { display: flex; justify-content: space-between; }
.row-label b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 8px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
#meterFill { height: 100%; width: 0; background: var(--talk); transition: width .05s linear, background .15s; }
#meterFill.closed { background: #4a4f5c; }
#meterMark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); opacity: .8; }
#sensRow.dim #meterMark { opacity: .2; }
.settings { max-height: 50vh; overflow-y: auto; }
