/* =========================================================================
   DukeVoice — спокойная тёмная тема
   Нейтральный графит, один мягкий акцент, никакой лишней стилизации.
   ========================================================================= */

/* ---------- шрифт (свой, без внешних CDN) ---------- */
@font-face {
  font-family: "Golos";
  src: url("/fonts/golos-text-cyrillic-wght-normal.woff2") format("woff2-variations"),
       url("/fonts/golos-text-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos";
  src: url("/fonts/golos-text-latin-wght-normal.woff2") format("woff2-variations"),
       url("/fonts/golos-text-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- токены ---------- */
:root {
  color-scheme: dark;
  --bg: #0f1013;
  --bg-2: #131418;
  --surface: #17181c;
  --surface-2: #1c1d22;
  --surface-3: #24252b;
  --surface-4: #2e2f36;
  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.1);
  --text: #ececef;
  --text-2: #b4b5bd;
  --muted: #868791;
  --faint: #5b5c65;

  --accent: #f2b35f;
  --accent-2: #f7c88b;
  --accent-ink: #1e1507;
  --accent-soft: rgba(242, 179, 95, 0.12);
  --accent-line: rgba(242, 179, 95, 0.4);
  --green: #4fcf8a;
  --green-soft: rgba(79, 207, 138, 0.12);
  --red: #ef6257;
  --red-2: #ff8a80;
  --red-soft: rgba(239, 98, 87, 0.13);

  --ok: var(--green);
  --warn: var(--accent);
  --danger: var(--red);

  --r: 10px;
  --r-lg: 16px;
  --font: "Golos", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.36, .5, 1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.5);

  --side-w: 272px;
  --chat-w: 340px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); text-underline-offset: 3px; }
::selection { background: rgba(242, 179, 95, 0.3); color: #fff; }
kbd {
  font: 500 12px var(--mono);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--text-2);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.muted { color: var(--muted); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface-3); color: var(--text);
  font-weight: 600; font-size: 14.5px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .2s;
}
.btn:hover { background: var(--surface-4); }
.btn:active { transform: scale(.98); }
.btn .i { width: 18px; height: 18px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn.sm .i { width: 16px; height: 16px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary:disabled { opacity: .6; cursor: default; transform: none; }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.ghost.on { border-color: var(--accent-line); color: var(--accent-2); background: var(--accent-soft); }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2);
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn.sm .i { width: 16px; height: 16px; }
.icon-btn.off { color: var(--red); }
.icon-btn.off:hover { background: var(--red-soft); }
.icon-btn.danger-hover:hover { background: var(--red-soft); color: var(--red); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; }

.badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: var(--red); color: #fff;
  font: 700 10.5px/17px var(--font); text-align: center;
  animation: pop .3s var(--spring);
}

/* ---------- аватары ---------- */
.avatar {
  --c: #b9bac3;
  position: relative;
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, var(--surface-2));
  color: var(--c);
  font-weight: 700; font-size: 16px;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  flex: none;
  user-select: none;
  transition: box-shadow .2s, transform .25s var(--spring);
}
.avatar.sm { width: 32px; height: 32px; font-size: 12.5px; }
.avatar.xs { width: 22px; height: 22px; font-size: 9.5px; }

/* =========================================================================
   ЭКРАН ВХОДА
   ========================================================================= */
.login {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 24px 16px;
  overflow: auto;
}
.login-glow {
  position: absolute; inset: 0;
  background: radial-gradient(600px 380px at 50% 12%, rgba(242, 179, 95, 0.07), transparent 70%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(400px, 100%);
  padding: 34px 30px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise .5s var(--ease) both;
}
.login-card > * { animation: rise .5s var(--ease) both; }
.login-card > :nth-child(2) { animation-delay: .04s; }
.login-card > :nth-child(3) { animation-delay: .08s; }
.login-card > :nth-child(n+4) { animation-delay: .12s; }
.logo-xl { width: 52px; height: 52px; display: block; margin: 0 auto 16px; }
.login h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.025em; }
.login .tagline { margin: 6px 0 24px; color: var(--muted); font-size: 15px; }
.invite-note {
  margin: -8px 0 18px; padding: 9px 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 13.5px; font-weight: 600;
}
#loginForm { display: grid; gap: 10px; text-align: left; }
#loginForm .field-label { justify-content: flex-start; }
#loginForm .btn { height: 46px; margin-top: 6px; font-size: 15px; }
.login .fine { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); }
.login.leaving .login-card { animation: cardOut .3s var(--ease) forwards; }
.login.leaving .login-glow { transition: opacity .3s; opacity: 0; }
@keyframes cardOut { to { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* =========================================================================
   КАРКАС
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100vh; height: 100dvh;
  animation: fade .4s ease both;
}
.app.in-room { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--chat-w); }
.scrim { display: none; }

/* ---------- сайдбар ---------- */
.sidebar {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.logo-sm { width: 28px; height: 28px; }
.brand-name { font-weight: 700; font-size: 16.5px; letter-spacing: -0.02em; }
.brand-name b { font-weight: inherit; }
.conn {
  margin-left: auto;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
}
.conn.ok { background: var(--green); animation: none; }
.conn.bad { background: var(--red); }
@keyframes blink { 50% { opacity: .35; } }

.side-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 10px 6px 18px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.room-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 12px; scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
.room { margin-bottom: 2px; }
.room-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 38px; padding: 0 10px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2);
  text-align: left;
  transition: background .15s, color .15s;
}
.room-btn .i { width: 18px; height: 18px; color: var(--faint); transition: color .2s; }
.room.live .room-btn .i { color: var(--green); }
.room-btn:hover { background: var(--surface-2); color: var(--text); }
.room-btn.active { background: var(--surface-3); color: var(--text); }
.room-btn.active .i { color: var(--accent); }
.room-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.room-count { font-size: 12px; font-weight: 600; color: var(--muted); }
.room-members { list-style: none; margin: 2px 0 8px; padding: 0 0 0 26px; }
.rm {
  display: flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 8px; border-radius: 7px;
  color: var(--text-2); font-size: 14px;
  animation: rise .3s var(--ease) both;
}
.rm .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .15s; }
.rm .i { width: 14px; height: 14px; color: var(--red); }
.rm.speaking .avatar { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3.5px var(--accent); }
.rm.speaking .nm { color: var(--text); }
.rm.me .nm { color: var(--text); }

.voice-status {
  display: flex; align-items: center; gap: 10px;
  margin: 0 8px 8px; padding: 10px 8px 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  animation: rise .35s var(--ease) both;
}
.vs-text { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.vs-text strong { color: var(--green); font-size: 13px; font-weight: 600; }
.vs-text strong.warn { color: var(--accent); }
.vs-text span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-panel {
  display: flex; align-items: center; gap: 2px;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.me {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px; border: 0; border-radius: 9px;
  background: transparent; text-align: left;
}
.me:hover { background: var(--surface-2); }
.me-text { display: grid; min-width: 0; line-height: 1.25; }
.me-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- сцена ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-head {
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.stage-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.stage-title h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-ico { color: var(--muted); }
.room-sub { color: var(--muted); font-size: 13px; white-space: nowrap; }
.stage-actions { display: flex; align-items: center; gap: 6px; }
.chat-toggle { display: none; }

.stage-body { flex: 1; min-height: 0; overflow-y: auto; position: relative; scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }

/* пустая сцена */
.empty {
  display: grid; place-content: center; justify-items: center; gap: 6px;
  min-height: 100%; padding: 32px 20px; text-align: center;
  animation: rise .5s var(--ease) both;
}
.empty-art {
  position: relative;
  display: grid; place-items: center;
  width: 84px; height: 84px; margin-bottom: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--accent);
}
.empty-art .i { width: 30px; height: 30px; }
.empty-art::before, .empty-art::after {
  content: ""; position: absolute; inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
  animation: ripple 3.2s var(--ease) infinite;
  opacity: 0;
}
.empty-art::after { animation-delay: 1.6s; }
@keyframes ripple { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.9); opacity: 0; } }
.empty h3 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.empty p { margin: 0 0 18px; color: var(--muted); max-width: 380px; }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- плитки участников ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 230px));
  justify-content: center;
  align-content: center;
  gap: 14px;
  padding: 28px;
  min-height: 100%;
}
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-width: 0;
  padding: 30px 14px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color .25s, background .2s, box-shadow .3s, transform .2s var(--ease);
  animation: tileIn .45s var(--spring) both;
}
.tile:nth-child(2) { animation-delay: .04s; }
.tile:nth-child(3) { animation-delay: .08s; }
.tile:nth-child(4) { animation-delay: .12s; }
.tile:nth-child(n+5) { animation-delay: .16s; }
.tile:hover { background: var(--surface-2); }
.tile.me { cursor: default; }
.tile.me:hover { background: var(--surface); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tile.speaking { border-color: var(--accent-line); box-shadow: 0 0 0 1px rgba(242, 179, 95, 0.1), 0 12px 40px rgba(242, 179, 95, 0.06); }
.tile.leaving { animation: tileOut .28s var(--ease) forwards; pointer-events: none; }
@keyframes tileIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes tileOut { to { opacity: 0; transform: scale(.94); } }

/* аватар с «дышащим» кольцом громкости */
.knob { position: relative; width: 96px; height: 96px; display: grid; place-items: center; margin-bottom: 6px; }
.knob .avatar { width: 76px; height: 76px; font-size: 26px; }
.vu {
  --a: calc(var(--lvl, 0) * 1);
  position: absolute; inset: 4px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 2px rgb(242 179 95 / calc(var(--a) * 0.95)),
    0 0 calc(4px + var(--a) * 24px) rgb(242 179 95 / calc(var(--a) * 0.35));
  transform: scale(calc(0.97 + var(--a) * 0.08));
  will-change: transform;
}
.tile.speaking .vu { --a: max(0.5, var(--lvl, 0)); }
.tile-name { max-width: 100%; font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-name small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.tile-flags { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
.flag {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--red-soft); color: var(--red);
  animation: pop .3s var(--spring);
}
.flag .i { width: 15px; height: 15px; }
.flag.dim { background: var(--surface-3); color: var(--text-2); }
.tile-status { min-height: 18px; font-size: 12.5px; color: var(--muted); }
.tile-status.warn { color: var(--accent); animation: blink 1.2s ease-in-out infinite; }
.tile-status.bad { color: var(--red); }
.tile-vol {
  position: absolute; right: 12px; bottom: 11px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  padding: 1px 7px; border-radius: 6px; background: var(--surface-3);
}
.tile-net {
  position: absolute; left: 14px; bottom: 14px;
  display: flex; align-items: flex-end; gap: 2px;
  height: 12px;
}
.tile-net i { display: block; width: 3px; border-radius: 1px; background: var(--surface-4); transition: background .3s; }
.tile-net i:nth-child(1) { height: 4px; }
.tile-net i:nth-child(2) { height: 8px; }
.tile-net i:nth-child(3) { height: 12px; }
.tile-net.good i { background: var(--green); }
.tile-net.ok i:nth-child(-n+2) { background: var(--accent); }
.tile-net.bad i:nth-child(1) { background: var(--red); }

.tile.invite {
  font: inherit; color: var(--text-2);
  background: transparent;
  border: 1.5px dashed var(--line-2);
  justify-content: center;
}
.tile.invite:hover { border-color: var(--accent-line); color: var(--text); background: var(--accent-soft); }
.invite-ico {
  display: grid; place-items: center;
  width: 76px; height: 76px; margin: 10px 0 6px; border-radius: 50%;
  background: var(--surface-2); color: var(--accent);
  transition: transform .3s var(--spring);
}
.invite-ico .i { width: 26px; height: 26px; }
.tile.invite:hover .invite-ico { transform: scale(1.06) rotate(-8deg); }

/* ---------- панель управления ---------- */
.controls {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  flex: none;
  flex-wrap: wrap;
}
.ctrl {
  display: inline-flex; align-items: center; gap: 9px;
  height: 46px; padding: 0 18px 0 15px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 14px; font-weight: 600;
  color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  touch-action: manipulation;
}
.ctrl:hover { background: var(--surface-3); color: var(--text); }
.ctrl:active { transform: scale(.97); }
.ctrl .i { width: 19px; height: 19px; }
.ctrl.off { background: var(--red-soft); border-color: rgba(239, 98, 87, 0.3); color: var(--red-2); }
.ctrl.off:hover { background: rgba(239, 98, 87, 0.2); }
.ctrl.leave { background: var(--red); border-color: transparent; color: #fff; }
.ctrl.leave:hover { background: #f4766c; }
.ctrl.ptt { color: var(--accent-2); border-color: var(--accent-line); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ctrl.ptt.active { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------- чат ---------- */
.chat {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
}
.chat-head { display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.chat-head strong { font-size: 15px; font-weight: 700; }
.chat-head .muted { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 6px 8px; scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
.msg { display: grid; grid-template-columns: 34px 1fr; column-gap: 10px; padding: 4px 10px; border-radius: 8px; animation: msgIn .25s var(--ease) both; }
.msg:hover { background: rgba(255, 255, 255, 0.02); }
.msg.first { margin-top: 10px; }
.msg .avatar { grid-row: span 2; width: 34px; height: 34px; font-size: 12.5px; }
.msg.cont { padding-top: 1px; padding-bottom: 1px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-head strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head time { font-size: 11.5px; color: var(--faint); flex: none; }
.msg-text { grid-column: 2; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; color: var(--text-2); font-size: 14.5px; }
.msg.mine .msg-head strong { color: var(--accent-2); }
.msg-sys {
  display: flex; justify-content: center; align-items: baseline; gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px; color: var(--muted);
  animation: msgIn .25s var(--ease) both;
}
.msg-sys time { color: var(--faint); font-size: 11.5px; }
@keyframes msgIn { from { opacity: 0; transform: translateY(5px); } }
.chat-empty { color: var(--muted); text-align: center; padding: 34px 16px; font-size: 14px; }
.chat-form {
  display: flex; align-items: flex-end; gap: 8px;
  margin: 8px 12px calc(12px + env(safe-area-inset-bottom));
  padding: 5px 5px 5px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  transition: border-color .15s, box-shadow .15s;
}
.chat-form:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-form textarea {
  flex: 1; min-width: 0;
  height: auto; min-height: 36px; max-height: 140px;
  padding: 8px 0; border: 0; outline: 0; background: transparent;
  resize: none; line-height: 1.4;
}
.chat-form textarea:focus-visible { outline: none; }
.chat-form textarea::placeholder { color: var(--faint); }
.chat-form .send { color: var(--accent); }
.chat-form .send:hover { color: var(--accent-2); }

/* ---------- поля ---------- */
.field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.field-label output { font-size: 13px; font-weight: 600; color: var(--text); }
.nick-row { display: flex; align-items: center; gap: 12px; }
input:not([type]), input[type=text], select {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:not([type]):focus, input[type=text]:focus, select:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--faint); }
select {
  appearance: none; padding-right: 36px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23868791' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
select option { background: var(--surface-2); color: var(--text); }
#loginForm .nick-row input { height: 46px; font-size: 16px; }

/* ---------- модалки ---------- */
.modal {
  width: min(600px, calc(100vw - 24px));
  max-height: min(88vh, 920px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  overflow: clip;
}
.modal[open] { display: flex; flex-direction: column; animation: dlgIn .28s var(--ease); }
.modal.small { width: min(440px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(5, 6, 8, 0.6); backdrop-filter: blur(3px); animation: fade .2s ease; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 14px 24px; margin: 0; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.modal-body { padding: 4px 24px 24px; overflow-y: auto; display: grid; gap: 12px; scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; }
#roomForm { display: contents; }

.set-sec { display: grid; gap: 12px; padding: 20px 0 18px; border-top: 1px solid var(--line); }
.set-sec:first-child { border-top: 0; }
.set-sec h3 { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--text); }
.field { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row select { flex: 1; min-width: 0; }
.row.gap { flex-wrap: wrap; gap: 10px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }

/* переключатель режимов */
.seg {
  display: flex; padding: 3px; gap: 3px;
  border-radius: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
}
.seg button {
  flex: 1; min-width: 0;
  height: 36px; padding: 0 8px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .15s, background .2s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked=true] { background: var(--surface-4); color: var(--text); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

/* тумблер */
.toggle { position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14.5px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.tg {
  position: relative; width: 40px; height: 24px; border-radius: 12px; flex: none;
  background: var(--surface-4);
  transition: background .2s;
}
.tg::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #d9dae0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform .22s var(--spring), background .2s;
}
.toggle input:checked + .tg { background: var(--accent); }
.toggle input:checked + .tg::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .tg { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ползунок */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0;
  background: transparent;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--surface-4) var(--p, 50%));
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--surface-4); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; margin-top: -6px;
  border-radius: 50%; border: 0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: transform .15s var(--spring);
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%; border: 0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* шкала уровня микрофона */
.meter-wrap { display: grid; gap: 10px; }
.meter {
  position: relative;
  height: 10px; margin: 6px 0;
  border-radius: 5px;
  background: var(--surface-4);
}
.meter-fill {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 0%;
  border-radius: 5px;
  background: var(--muted);
  opacity: .55;
  transition: width .06s linear, background .15s, opacity .15s;
}
.meter.open .meter-fill { background: var(--green); opacity: 1; }
.meter-thr { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 2px var(--surface); transition: left .12s; }
.meter input[type=range] { position: absolute; inset: -8px 0; height: auto; opacity: 0; cursor: ew-resize; }
.meter.auto input { pointer-events: none; }
.meter.auto .meter-thr { background: var(--text-2); transition: left .3s var(--ease); }
.meter.no-thr .meter-thr, .meter.no-thr input { display: none; }

.ptt-key { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.key-btn {
  min-width: 64px; height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line-2); border-bottom-width: 3px;
  background: var(--surface-3);
  font: 700 13px var(--font); color: var(--text);
}
.key-btn:active { border-bottom-width: 1px; transform: translateY(2px); }
.key-btn.listening { border-color: var(--accent-line); color: var(--accent-2); animation: blink 1s ease-in-out infinite; }

/* диагностика */
.diag { display: grid; gap: 10px; }
.diag-out { display: grid; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line-2); animation: rise .25s var(--ease) both; }
.diag-out ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13.5px; line-height: 1.45; }
.diag-out li { position: relative; padding-left: 20px; color: var(--text-2); animation: rise .25s var(--ease) both; }
.diag-out li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface-4); }
.diag-out li.ok::before { background: var(--green); }
.diag-out li.warn::before { background: var(--accent); }
.diag-out li.bad::before { background: var(--red); }
.diag-out li.bad { color: var(--text); }
.diag-out li.wait::before { background: var(--accent); animation: blink .8s ease-in-out infinite; }
.diag-out .link-btn { justify-self: start; font-size: 13px; }
.diag-out .diag-act { margin-top: 8px; height: 32px; }

/* ---------- меню участника ---------- */
.popover {
  position: fixed; z-index: 60;
  width: 270px;
  padding: 14px;
  display: grid; gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: popIn .2s var(--ease);
  transform-origin: top center;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.97); } }
.pm-head { display: flex; align-items: center; gap: 10px; min-width: 0; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.pm-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-stats { font-size: 12px; line-height: 1.5; color: var(--muted); display: flex; align-items: flex-start; gap: 7px; }
.pm-stats .i { width: 14px; height: 14px; margin-top: 2px; }
.pm-stats.good .i { color: var(--green); }
.pm-stats.ok .i { color: var(--accent); }
.pm-stats.bad .i { color: var(--red); }

/* ---------- уведомления ---------- */
.toasts {
  position: fixed; left: 50%; bottom: 100px; z-index: 80;
  transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
  width: min(460px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px 11px 14px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500;
  animation: toastIn .3s var(--spring);
  pointer-events: auto;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); }
.toast.err::before { background: var(--red); }
.toast.ok::before { background: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 9px 16px;
  background: #2a2213;
  border-bottom: 1px solid var(--accent-line);
  color: var(--accent-2);
  font-size: 13.5px; font-weight: 600;
  animation: slideDown .3s var(--ease);
}
.banner::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: blink 1s ease-in-out infinite; }
@keyframes slideDown { from { transform: translateY(-100%); } }
.noscript { padding: 40px 16px; text-align: center; color: var(--text-2); }

/* ---------- общие анимации ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }

/* ---------- адаптив ---------- */
.only-narrow { display: none; }

@media (max-width: 1150px) {
  .app.in-room { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .chat-toggle { display: inline-grid; }
  .chat {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
    width: min(380px, 100vw);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .3s var(--ease), visibility 0s .3s;
    box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  }
  .app.chat-open .chat { transform: none; visibility: visible; transition: transform .3s var(--ease), visibility 0s; }
  .app.chat-open .scrim, .app.side-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(5, 6, 8, 0.55); animation: fade .2s ease; }
}

@media (max-width: 760px) {
  :root { --side-w: 0px; }
  .app, .app.in-room { grid-template-columns: minmax(0, 1fr); }
  .only-narrow { display: inline-grid; }
  .btn.only-narrow { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .3s var(--ease), visibility 0s .3s;
    box-shadow: 30px 0 80px rgba(0, 0, 0, 0.5);
  }
  .app.side-open .sidebar { transform: none; visibility: visible; transition: transform .3s var(--ease), visibility 0s; }
  .chat { width: 100vw; }
  .stage-head { padding: 0 8px; gap: 6px; }
  .room-ico, .room-sub { display: none; }
  #inviteBtn span { display: none; }
  #inviteBtn { width: 36px; padding: 0; border: 0; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; align-content: start; }
  .tile { padding: 24px 8px 28px; }
  .knob { width: 84px; height: 84px; }
  .knob .avatar, .invite-ico { width: 64px; height: 64px; font-size: 22px; }
  .controls { gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .ctrl { padding: 0; width: 52px; justify-content: center; height: 48px; }
  .ctrl span { display: none; }
  .ctrl.ptt { flex: 1 1 100%; width: auto; padding: 0 16px; order: -1; }
  .ctrl.ptt span { display: inline; }
  .toasts { bottom: 150px; }
  .modal { max-height: 92vh; border-radius: 16px; }
  .modal-body { padding: 4px 16px 18px; }
  .seg { flex-wrap: wrap; }
  .seg button { flex: 1 1 auto; }
  .login-card { padding: 28px 20px 22px; }
}

/* меньше движения — по запросу системы */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .empty-art::before, .empty-art::after { display: none; }
}
