/* Эфир — дизайн-система.
   Направление: сдержанный служебный интерфейс связи. Плотная сетка, тонкие
   границы, один сигнальный акцент, никакой декоративности ради декоративности. */

:root {
  --bg: #0b0e13;
  --bg2: #0f1420;
  --panel: #111621;
  --panel2: #161d2b;
  --line: #1f2837;
  --line2: #2a3547;
  --ink: #e7ecf4;
  --ink-dim: #8794a9;
  --accent: #4c7df0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(76, 125, 240, .14);
  --live: #f2a03d;
  --ok: #2fb98a;
  --danger: #e0574f;

  --r-lg: 14px;
  --r: 10px;
  --r-sm: 7px;
  --shadow: 0 20px 48px rgba(0, 0, 0, .45);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --navh: 0px;
}

[data-theme="midnight"] {
  --bg: #070a16; --bg2: #0b1024; --panel: #0e1430; --panel2: #141c3f; --line: #1e2850; --line2: #2b3865;
  --ink: #e8ecff; --ink-dim: #8d99c6; --accent: #6d8dff; --accent-soft: rgba(109,141,255,.16); --live: #ffb454; --ok: #48d3a8;
}
[data-theme="document"] {
  --bg: #eef1f5; --bg2: #e5e9f0; --panel: #ffffff; --panel2: #f4f6fa; --line: #dde3ec; --line2: #c9d2e0;
  --ink: #0f1723; --ink-dim: #5d6b80; --accent: #2b5ce6; --accent-ink: #fff; --accent-soft: rgba(43,92,230,.10);
  --live: #c9741a; --ok: #12855f; --danger: #c8392f;
  --shadow: 0 16px 36px rgba(24, 40, 70, .12);
}
[data-theme="cobalt"] {
  --bg: #06121a; --bg2: #081a26; --panel: #0a1f2d; --panel2: #0e2939; --line: #16394d; --line2: #1e4a63;
  --ink: #e2f2fa; --ink-dim: #7fa5b8; --accent: #24b8d8; --accent-ink: #04141c; --accent-soft: rgba(36,184,216,.14); --live: #f0a63c; --ok: #3fcf9a;
}
[data-theme="pine"] {
  --bg: #0b1410; --bg2: #0f1d17; --panel: #11201a; --panel2: #172c23; --line: #21402f; --line2: #2c5540;
  --ink: #e3f0e6; --ink-dim: #86a692; --accent: #4fb477; --accent-ink: #04140a; --accent-soft: rgba(79,180,119,.14); --live: #e0b341; --ok: #6cd08f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
input, textarea { font-size: 16px; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; }
.ic--lg { width: 20px; height: 20px; }

/* ---------------- кнопки ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line2); background: var(--panel2); color: var(--ink);
  padding: 10px 15px; border-radius: var(--r); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background .14s, border-color .14s, transform .08s;
}
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--wide { width: 100%; }
.btn--lg { padding: 13px 18px; font-size: 15px; }
.btn--sm { padding: 8px 12px; font-size: 13px; border-radius: var(--r-sm); gap: 6px; }
.btn[disabled] { opacity: .42; cursor: not-allowed; }

.iconbtn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: transparent; border-radius: var(--r-sm); color: var(--ink-dim);
}
.iconbtn:hover { color: var(--ink); border-color: var(--accent); }

.field { display: block; margin: 0 0 14px; }
.field--row { display: flex; align-items: center; gap: 10px; margin: 0; }
.field__label { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 7px; }
.field--row .field__label { margin: 0; }
.field__input {
  width: 100%; padding: 12px 14px; background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line2); border-radius: var(--r);
}
.field__input::placeholder { color: var(--ink-dim); }
.field__input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field__input--sm { width: 84px; padding: 9px 10px; }

.segment { display: inline-flex; background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--r); padding: 3px; gap: 3px; }
.segment__btn { border: none; background: transparent; color: var(--ink-dim); padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; font-weight: 600; }
.segment__btn--on { background: var(--accent); color: var(--accent-ink); }

.badge {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); border-radius: 999px; padding: 5px 11px;
}
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.live {
  display: none; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10px;
  letter-spacing: .14em; color: var(--live); border: 1px solid color-mix(in srgb, var(--live) 45%, transparent);
  border-radius: 999px; padding: 4px 9px;
}
.live.on { display: inline-flex; }
.live__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); animation: blip 1.7s infinite; }
@keyframes blip { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------------- экран входа ---------------- */
.gate { position: fixed; inset: 0; overflow: auto; display: grid; place-items: center; padding: 24px; }
.gate__orb { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .55; }
.gate__inner { position: relative; width: min(460px, 100%); }
.gate__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand__mark { border-radius: 10px; }
.brand__name { font-weight: 800; font-size: 19px; letter-spacing: .14em; }
.brand__tag { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); letter-spacing: .06em; }

.gate__card {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line2); border-radius: var(--r-lg); padding: 26px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.gate__title { font-size: clamp(26px, 6.4vw, 34px); line-height: 1.14; letter-spacing: -.02em; margin: 16px 0 12px; font-weight: 800; }
.gate__sub { color: var(--ink-dim); font-size: 14px; line-height: 1.6; margin: 0 0 22px; }
.gate__err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 8px; }
.gate__foot { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.gate__foot .btn { flex: 1 1 0; min-width: 0; }
.gate__foot .btn span, .gate__foot .btn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gate__specs { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 9px; }
.gate__specs li { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-size: 13px; }
.gate__specs .ic { color: var(--accent); }

.legal {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; min-width: 0;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-dim);
}
.legal__link { background: none; border: none; padding: 0; color: var(--ink-dim); cursor: pointer; font-size: 11.5px; text-decoration: underline; text-underline-offset: 3px; }
.legal__link:hover { color: var(--accent); }
.legaltext { color: var(--ink-dim); font-size: 13.5px; line-height: 1.65; max-height: 60vh; overflow: auto; margin-bottom: 16px; }
.legaltext h4 { color: var(--ink); font-size: 14px; margin: 16px 0 6px; }
.legaltext p { margin: 0 0 10px; }
.legaltext ul { margin: 0 0 10px; padding-left: 18px; }

/* ---------------- каркас ---------------- */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--bg); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar__logo { border-radius: 7px; flex: none; }
.topbar__room { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.chip { padding: 7px 12px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line2); font-size: 13px; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip--admin { border-color: var(--accent); color: var(--accent); }

.layout { flex: 1; display: grid; grid-template-columns: 258px minmax(0, 1fr) 306px; gap: 12px; padding: 12px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; display: flex; flex-direction: column; min-height: 0; }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; flex: none; }
.panel__title { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; margin: 0; color: var(--ink-dim); font-weight: 600; }
.panel__hint { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.panel__legal { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--ink-dim); }
.panel__legal .legal__link { font-size: 10.5px; }

/* ---------------- комнаты ---------------- */
.roomlist { display: flex; flex-direction: column; gap: 7px; overflow: auto; flex: 1; }
.room { text-align: left; width: 100%; padding: 11px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel2); cursor: pointer; display: grid; gap: 7px; }
.room:hover { border-color: var(--accent); }
.room.on { border-color: var(--accent); background: var(--accent-soft); }
.room__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.room__name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.room__name .ic { width: 14px; height: 14px; color: var(--ink-dim); }
.room__count { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.room__dots { display: flex; gap: 3px; }
.room__dot { flex: 1; height: 3px; border-radius: 2px; background: var(--line2); }
.room__dot.on { background: var(--accent); }
.room--private { border-style: dashed; }
.room__tag { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; color: var(--live); }
.roomlist__foot { display: grid; gap: 6px; margin-top: 10px; flex: none; }

/* ---------------- центр ---------------- */
.stage { min-height: 0; display: flex; flex-direction: column; }
.hall { margin: auto; text-align: center; max-width: 440px; padding: 20px; }
.hall__mark { border-radius: 14px; margin-bottom: 16px; opacity: .9; }
.hall__title { font-size: 22px; margin: 0 0 10px; font-weight: 700; }
.hall__text { color: var(--ink-dim); line-height: 1.65; font-size: 14px; }
.hall__text--dim { font-size: 12.5px; opacity: .75; }
.roomview { display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; }

.deck { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; }
.deck__btn { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.deck__btn:hover { border-color: var(--accent); }
.deck__btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.deck__btn.off { background: color-mix(in srgb, var(--danger) 18%, var(--panel2)); border-color: var(--danger); color: var(--ink); }
.deck__btn--dim { opacity: .5; }
.deck__meter { width: 92px; height: 6px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 4px; overflow: hidden; flex: none; }
.deck__meterfill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ok), var(--accent)); transition: width .07s linear; }
.deck__tabs { display: flex; gap: 5px; margin-left: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; }
.tab { display: flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: var(--r-sm); border: none; background: transparent; color: var(--ink-dim); cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab--on { background: var(--accent); color: var(--accent-ink); }

.warn { background: color-mix(in srgb, var(--danger) 14%, var(--panel)); border: 1px solid var(--danger); padding: 11px 14px; border-radius: var(--r); font-size: 13px; line-height: 1.5; flex: none; }
.view { flex: 1; min-height: 0; overflow: auto; }
.view--voice { display: flex; flex-direction: column; gap: 12px; }

/* участники */
.peergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 10px; flex: none; }
.peer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 15px 12px; text-align: center; display: grid; gap: 9px; justify-items: center; transition: border-color .12s, box-shadow .12s; }
.peer.talking { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.peer__ava { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 18px; background: var(--panel2); border: 1px solid var(--line2); color: var(--accent); }
.peer.talking .peer__ava { border-color: var(--accent); background: var(--accent-soft); }
.peer__nick { font-weight: 700; font-size: 13.5px; word-break: break-word; }
.peer__vu { width: 100%; height: 4px; border-radius: 2px; background: var(--panel2); overflow: hidden; }
.peer__vufill { height: 100%; width: 0%; background: var(--accent); transition: width .07s linear; }
.peer__state { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; color: var(--ink-dim); display: flex; align-items: center; gap: 5px; }
.peer__state .ic { width: 12px; height: 12px; }
.peer__vol { width: 100%; }
input[type="range"] { accent-color: var(--accent); }

/* чат внутри голосовой вкладки */
.roomchat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; display: flex; flex-direction: column; gap: 9px; min-height: 190px; flex: 1; }
.roomchat__head { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); }
.roomchat__hint { margin-left: auto; text-transform: none; letter-spacing: 0; font-family: var(--font); opacity: .7; }
.roomchat__log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; min-height: 90px; }
.roomchat__form { display: flex; gap: 6px; }

/* ---------------- люди и чат справа ---------------- */
.userlist { display: flex; flex-direction: column; gap: 5px; max-height: 38%; overflow: auto; margin-bottom: 12px; flex: none; }
.uitem { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--panel2); border: 1px solid transparent; }
.uitem.talking { border-color: var(--accent); }
.uitem__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line2); flex: none; }
.uitem.talking .uitem__dot { background: var(--accent); }
.uitem__nick { flex: 1; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uitem__tag { font-family: var(--mono); font-size: 9px; color: var(--accent); letter-spacing: .08em; }
.uitem__act { border: none; background: none; cursor: pointer; color: var(--ink-dim); padding: 3px; display: grid; place-items: center; }
.uitem__act:hover { color: var(--danger); }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); padding-top: 11px; }
.chat__log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 7px; }
.msg { font-size: 13px; line-height: 1.5; word-break: break-word; }
.msg__time { font-family: var(--mono); font-size: 9.5px; color: var(--ink-dim); margin-right: 6px; }
.msg__nick { font-weight: 700; color: var(--accent); }
.msg--sys { color: var(--ink-dim); font-size: 12px; }
.chat__form { display: flex; gap: 6px; margin-top: 10px; flex: none; }
.chat__input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--panel2); }
.chat__input:focus { outline: none; border-color: var(--accent); }

/* ---------------- крестики-нолики ---------------- */
.ttt { max-width: 440px; margin: 0 auto; display: grid; gap: 14px; }
.ttt__seats { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.seat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; text-align: center; display: grid; gap: 6px; flex: 1; min-width: 0; }
.seat.mine { border-color: var(--accent); }
.seat.turn { box-shadow: 0 0 0 2px var(--accent-soft); }
.seat__mark { font-size: 22px; font-weight: 800; color: var(--accent); }
.seat__nick { font-size: 12px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; }
.ttt__score { font-family: var(--mono); font-size: 17px; color: var(--ink-dim); flex: none; }
.ttt__board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.cell { aspect-ratio: 1; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); font-size: clamp(28px, 9vw, 38px); font-weight: 800; cursor: pointer; color: var(--ink); }
.cell:hover:not(:disabled) { border-color: var(--accent); }
.cell--x { color: var(--accent); }
.cell--o { color: var(--ok); }
.cell.win { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.cell:disabled { cursor: default; }
.ttt__status { text-align: center; color: var(--ink-dim); min-height: 20px; font-size: 14px; }
.ttt__ctrls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ttt__queue { text-align: center; color: var(--ink-dim); font-size: 12px; min-height: 16px; }

/* ---------------- сломанный телефон ---------------- */
.gpanel { max-width: 820px; margin: 0 auto; width: 100%; display: grid; gap: 13px; padding-bottom: 16px; }
.gpanel__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gpanel__title { font-size: 19px; margin: 0; font-weight: 800; }
.gpanel__sub { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); letter-spacing: .06em; }
.gpanel__note { color: var(--ink-dim); font-size: 12.5px; margin: 0; text-align: center; line-height: 1.55; }
.rules { color: var(--ink-dim); line-height: 1.75; margin: 0; padding-left: 20px; font-size: 13.5px; }
.gsettings { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 13px; }
.gsetting { display: grid; gap: 7px; }
.gplayers { display: flex; flex-wrap: wrap; gap: 6px; }
.gplayer { padding: 6px 11px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line2); font-size: 13px; font-weight: 600; }

.gbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); }
.gbar__time { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--accent); font-weight: 600; flex: none; }
.gbar__time b { font-size: 19px; }
.gbar__time--hot { color: var(--danger); }
.gtimeline { height: 3px; background: var(--panel2); border-radius: 2px; overflow: hidden; }
.gtimeline i { display: block; height: 100%; width: 100%; background: var(--accent); transition: width .3s linear; }
.gtimeline.hot i { background: var(--danger); }

.gprog { display: flex; flex-wrap: wrap; gap: 5px; }
.gchip { display: flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 4px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line2); color: var(--ink-dim); font-weight: 600; }
.gchip--done { border-color: var(--ok); color: var(--ok); }
.gchip--done::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }

.gprompt { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r); padding: 14px 16px; line-height: 1.55; font-size: 14px; }
.gprompt--task { display: flex; flex-direction: column; gap: 4px; }
.gprompt--task span { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); }
.gprompt--task b { font-size: clamp(16px, 4.4vw, 21px); font-weight: 800; line-height: 1.3; }
.gimage { display: grid; place-items: center; }
.gimage img { max-width: 100%; max-height: 42vh; border-radius: var(--r); border: 1px solid var(--line2); background: #fff; }
.ginput { display: flex; gap: 7px; }
.ginput .field__input { flex: 1; }
.gwait { color: var(--ink-dim); font-size: 13px; text-align: center; min-height: 18px; }
.ghost-ctrls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.canvaswrap { background: #fff; border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; line-height: 0; }
#paper { width: 100%; height: auto; touch-action: none; cursor: crosshair; display: block; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.tools__colors { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: var(--r-sm); border: 2px solid var(--line2); cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--ink); transform: scale(1.1); }
.tools__group { display: flex; gap: 5px; align-items: center; }
.tool { width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; color: var(--ink); display: grid; place-items: center; }
.tool:hover { border-color: var(--accent); }
.tool--on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tool--color { padding: 2px; }
.tool:disabled { opacity: .32; cursor: default; }
.tools__size { width: 96px; }

.gres { display: grid; gap: 12px; justify-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; min-height: 250px; align-content: center; }
.gres__author { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); }
.gres__ava { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line2); color: var(--accent); font-size: 9px; font-weight: 800; font-family: var(--font); }
.gres__text { font-size: clamp(18px, 4.6vw, 26px); text-align: center; line-height: 1.35; max-width: 620px; font-weight: 700; }
.gres img { max-width: 100%; max-height: 44vh; border-radius: var(--r); background: #fff; }
.gres__ctrls { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.gres__ctrls .btn.liked { border-color: var(--danger); color: var(--danger); }

.gbook { display: grid; gap: 16px; margin-top: 4px; }
.gbook__album { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px; }
.gbook__title { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 10px; color: var(--ink-dim); }
.gbook__strip { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 6px; }
.gbook__cell { flex: none; width: 166px; margin: 0; display: grid; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; }
.gbook__cell img { width: 100%; border-radius: var(--r-sm); background: #fff; display: block; }
.gbook__text { font-size: 13px; margin: 0; line-height: 1.4; min-height: 52px; font-weight: 600; }
.gbook__cell figcaption { font-family: var(--mono); font-size: 9.5px; color: var(--ink-dim); }

/* ---------------- нижняя навигация ---------------- */
.mobnav { display: none; }
.mobnav__btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px calc(9px + env(safe-area-inset-bottom, 0px)); border: none; background: transparent; color: var(--ink-dim); cursor: pointer; font-size: 11px; font-weight: 600; }
.mobnav__btn--on { color: var(--accent); }
.mobnav__badge { position: absolute; top: 3px; right: 50%; transform: translateX(20px); background: var(--danger); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700; padding: 1px 6px; min-width: 18px; }

/* ---------------- модалки ---------------- */
.modal { position: fixed; inset: 0; background: rgba(3, 6, 12, .68); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; z-index: 60; overflow: auto; }
.modal__box { background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r-lg); padding: 22px; width: min(430px, 100%); box-shadow: var(--shadow); max-height: 92vh; max-height: 92dvh; overflow: auto; }
.modal__box--wide { width: min(720px, 100%); }
.modal__title { margin: 0 0 16px; font-size: 18px; font-weight: 800; }
.modal__note { color: var(--ink-dim); font-size: 12.5px; line-height: 1.55; margin: 0 0 14px; }
.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; cursor: pointer; font-size: 14px; font-weight: 600; }
.switch input { width: 19px; height: 19px; accent-color: var(--accent); }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 9px; margin-bottom: 16px; }
.themecard { border: 1px solid var(--line2); border-radius: var(--r); padding: 10px; cursor: pointer; background: var(--panel2); display: grid; gap: 8px; }
.themecard.on { border-color: var(--accent); }
.themecard__dots { display: flex; gap: 5px; }
.themecard__dot { width: 15px; height: 15px; border-radius: 5px; }
.themecard__name { font-size: 13px; font-weight: 600; }

.adm__row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.adm__row .field__input { flex: 1; min-width: 160px; }
.adm__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; }
.adm__h { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); margin: 0 0 8px; }
.adm__list { display: grid; gap: 7px; max-height: 250px; overflow: auto; }
.adm__item { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px; display: grid; gap: 6px; font-size: 13px; }
.adm__btns { display: flex; gap: 5px; flex-wrap: wrap; }
.adm__banned { font-size: 12px; color: var(--ink-dim); margin-bottom: 10px; min-height: 16px; }

.invite { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r); padding: 11px 13px; font-size: 13px; line-height: 1.45; margin-bottom: 16px; }
.invitebox { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r); padding: 14px; flex: none; }
.invitebox__title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 9px; }
.invitebox__link { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; margin-bottom: 9px; word-break: break-all; user-select: all; }
.invitebox__row { display: flex; gap: 8px; flex-wrap: wrap; }
.invitebox__note { color: var(--ink-dim); font-size: 12px; margin: 9px 0 0; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--navh)); transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); padding: 12px 18px; border-radius: 999px; z-index: 90; box-shadow: var(--shadow); font-size: 14px; font-weight: 600; max-width: calc(100vw - 24px); text-align: center; }

/* =====================================================================
   Узкие экраны: три колонки превращаются в три вкладки внизу
   ===================================================================== */
@media (max-width: 1080px) {
  :root { --navh: 62px; }
  .topbar { padding: 9px 12px; gap: 8px; }
  .topbar__brand { flex: 1; min-width: 0; }
  .topbar__room { flex: 1; min-width: 0; }
  .chip { max-width: 96px; font-size: 12px; padding: 6px 10px; }

  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 0; padding: 10px; }
  .panel--rooms, .stage, .panel--side { display: none; min-height: 0; }
  #app[data-pane="rooms"] .panel--rooms { display: flex; }
  #app[data-pane="stage"] .stage { display: flex; }
  #app[data-pane="chat"] .panel--side { display: flex; }
  .mobnav { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border-top: 1px solid var(--line); flex: none; }

  .peergrid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); }
  .peer { padding: 12px 10px; gap: 7px; }
  .peer__ava { width: 44px; height: 44px; font-size: 16px; }

  .deck {
    display: grid; gap: 8px; grid-template-columns: 1fr 1fr 1fr;
    grid-template-areas: "mic deaf ns" "meter meter meter" "tabs tabs tabs"; align-items: center;
  }
  .deck__btn--mic { grid-area: mic; }
  #deafBtn { grid-area: deaf; }
  .deck__btn--ns { grid-area: ns; }
  .deck__meter { grid-area: meter; width: 100%; }
  .deck__btn { justify-content: center; padding: 11px 8px; gap: 6px; }
  .deck__tabs { grid-area: tabs; display: grid; grid-template-columns: repeat(3, 1fr); margin-left: 0; }
  .tab { justify-content: center; padding: 9px 6px; font-size: 12px; }
  .roomchat { min-height: 150px; }
}

@media (max-width: 560px) {
  .gate { padding: 14px; }
  .gate__card { padding: 18px; }
  .gate__inner { max-width: 100%; }
  .gate__foot { flex-direction: column; }   /* две кнопки в ряд не помещаются */
  .gate__foot .btn { width: 100%; }
  .gate__specs li { font-size: 12.5px; }
  .deck__label { font-size: 11.5px; }
  .live { display: none !important; }
  .topbar__actions { gap: 6px; }
  .adm__cols { grid-template-columns: 1fr; }
  .modal__box { padding: 17px; }
  .gsettings { gap: 12px; padding: 11px; }
  .tools__group { width: 100%; justify-content: space-between; }
  .tools__size { width: 100%; }
  .seat { padding: 9px; }
  .ttt__score { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }


/* ---------------- статистика ---------------- */
.adm__tabs { display: inline-flex; background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--r); padding: 3px; gap: 3px; margin-bottom: 14px; }
.stats { display: grid; gap: 16px; margin-bottom: 14px; }
.stats__cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.statcard { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 12px; display: grid; gap: 3px; }
.statcard__v { font-size: 21px; font-weight: 800; line-height: 1.1; }
.statcard__l { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); }
.statcard--accent .statcard__v { color: var(--accent); }
.stats__block { display: grid; gap: 8px; }
.stats__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stats__head .adm__h { margin: 0; }
.stats__legend { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--ink-dim); }
.dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; margin-right: 5px; }
.dot--a { background: var(--accent); }
.dot--b { background: var(--ok); }
.chart { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar-a { fill: var(--accent); }
.chart .bar-b { fill: var(--ok); }
.chart .axis { fill: var(--ink-dim); font-family: var(--mono); font-size: 8px; }
.chart .grid { stroke: var(--line2); stroke-width: .5; }
.stats__rooms { display: grid; gap: 6px; }
.statroom { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.statroom__name { width: 120px; flex: none; color: var(--ink-dim); }
.statroom__bar { flex: 1; height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.statroom__fill { height: 100%; background: var(--accent); border-radius: 4px; }
.statroom__n { font-family: var(--mono); font-size: 12px; width: 34px; text-align: right; }
