/* Палитра «консоль будущего»: почти чёрный сине-зелёный фон, один
   бирюзовый акцент, янтарный для предупреждений, красный для ошибок.
   Имена переменных прежние — их использует остальной код. */
:root {
  --ink:        #04070a;
  --panel:      rgba(6, 16, 19, 0.9);
  --canvas:     #050a0c;
  --raised:     rgba(255, 255, 255, 0.035);
  --line:       rgba(77, 255, 240, 0.18);
  --bubble-in:  rgba(255, 255, 255, 0.025);
  --bubble-out: rgba(77, 255, 240, 0.07);
  --brass:      #4dfff0;   /* основной акцент */
  --pink:       #7fb5b0;   /* вторичный, приглушённый */
  --jade:       #4dfff0;   /* онлайн / прочитано */
  --online-dot: #3ddc84;   /* кружок «в сети» на аватарке — единственный не-бирюзовый цвет в палитре, по просьбе */
  --text:       #cfe9e6;
  --bright:     #eafffb;
  --muted:      #3f6f6a;
  --warn:       #ffb020;
  --danger:     #ff3860;
  --radius:     0px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  /* Страница целиком не должна скроллиться как документ — только
     список чатов и сама переписка внутри себя (у них overflow-y
     отдельно). Без этого на мобильном при открытой клавиатуре палец
     утаскивал всё окно целиком, обнажая шапку сверху. */
  overflow: hidden;
}

body {
  position: relative;
  background:
    radial-gradient(1200px 700px at 50% -10%, #08222a 0%, transparent 60%),
    var(--ink);
  color: var(--text);
  font: 14px/1.55 "IBM Plex Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  animation: flick 7s linear infinite;
}

/* Развёртка ЭЛТ: строки и виньетка поверх всего интерфейса. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.75) 100%);
}

button, input, textarea { font: inherit; color: inherit; }

::selection { background: var(--brass); color: #04120f; }

* { scrollbar-width: thin; scrollbar-color: rgba(77, 255, 240, 0.25) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(77, 255, 240, 0.25); }
*::-webkit-scrollbar-thumb:hover { background: var(--brass); }

[hidden] { display: none !important; }

.stamp-font { font-family: "Chakra Petch", "IBM Plex Mono", ui-monospace, monospace; }

/* ── Анимации ───────────────────────────────────────── */

@keyframes flick { 0%, 96%, 100% { opacity: 1; } 97% { opacity: 0.85; } 98.5% { opacity: 1; } }
@keyframes sweep { 0% { transform: translateY(-20vh); } 100% { transform: translateY(120vh); } }
@keyframes caret { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide-l { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes slide-r { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(77, 255, 240, 0.5); } 100% { box-shadow: 0 0 0 12px rgba(77, 255, 240, 0); } }
@keyframes drift { from { background-position: 0 0; } to { background-position: 0 -240px; } }
@keyframes boot-in { from { opacity: 0; filter: blur(6px); transform: scale(0.985); } to { opacity: 1; filter: none; transform: none; } }
@keyframes bar-pulse { 0%, 100% { opacity: 0.35; transform: scaleY(0.5); } 50% { opacity: 1; transform: scaleY(1); } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(280%); } }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* ── Вход ───────────────────────────────────────────── */

.gate {
  position: relative;
  z-index: 0;
  min-height: 100%;
  display: grid;
  grid-template-columns: 1fr minmax(380px, 460px) 1fr;
  align-items: center;
  gap: 40px;
  padding: 0 56px;
  overflow: hidden;
}

.gate::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(77, 255, 240, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 255, 240, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: drift 24s linear infinite;
}

.gate::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(77, 255, 240, 0.06) 60%, transparent);
  animation: sweep 6s linear infinite;
}

.gate__matrix {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.18;
  pointer-events: none;
}

/* Фон экрана входа. -20px запаса по краям — под лёгкое смещение от
   параллакса (см. app.js), .gate уже сам обрезает всё лишнее через
   overflow: hidden. Цвет специально сведён к палитре кворума фильтром,
   а не перекраской самой картинки — так проще заменить файл в будущем. */
.gate__bg {
  position: absolute;
  inset: -20px;
  z-index: -1;
  background-image: url('gate-bg.jpg');
  background-size: cover;
  background-position: center;
  filter: saturate(0.7) hue-rotate(160deg) brightness(0.5) contrast(1.05);
  transition: transform 0.2s ease-out;
  will-change: transform;
  pointer-events: none;
}

/* Тёмный оверлей поверх фотографии — без него текст формы поверх
   светлых участков читать не получится. */
.gate__bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 45%, rgba(4, 7, 10, 0.55) 0%, rgba(4, 7, 10, 0.86) 70%, rgba(4, 7, 10, 0.94) 100%);
}

/* Имитация мерцания экранов на фотографии — просто пятно света в левой
   части кадра (там, где на референсе стоят мониторы), дышащее по
   яркости. Не привязано к пикселям картинки, так что переживёт замену
   файла на любую похожую сцену. */
.gate__bg::after {
  content: "";
  position: absolute;
  left: 2%;
  top: 8%;
  width: 34%;
  height: 60%;
  background: radial-gradient(circle, rgba(77, 255, 240, 0.4), transparent 70%);
  mix-blend-mode: screen;
  animation: gate-screen-flicker 3.4s ease-in-out infinite;
}

@keyframes gate-screen-flicker {
  0%, 100% { opacity: 0.5; }
  45% { opacity: 0.85; }
  50% { opacity: 0.3; }
  70% { opacity: 0.9; }
}

/* Системный журнал слева и телеметрия справа. */
.hud {
  position: relative;
  z-index: 2;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* У .gate отступ 56px с обеих сторон — из-за него правая колонка не
   доходила до самого края экрана. Тянем её обратно отрицательным полем
   и оставляем небольшой, но не 56-пиксельный зазор от края. */
.hud--right { align-items: flex-end; gap: 14px; margin-right: -56px; padding-right: 20px; }

.hud__title {
  margin: 0 0 10px;
  font-family: "Chakra Petch", monospace;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--brass);
}

.hud__line {
  display: flex;
  gap: 10px;
  animation: slide-l 0.28s ease both;
}

.hud__tag { flex: 0 0 auto; color: var(--brass); }
.hud__tag--wait { color: var(--pink); }
.hud__tag--warn { color: var(--warn); }
.hud__line--warn .hud__text { color: #c8a06a; }
.hud__text { color: #4a6f6c; }

.hud__caret {
  display: inline-block;
  width: 7px;
  background: var(--brass);
  animation: caret 1s steps(1) infinite;
}

.metric {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slide-r 0.3s ease both;
}

.metric__value { color: var(--bright); min-width: 62px; text-align: right; }

.bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }

.bars i {
  width: 3px;
  height: 14px;
  background: var(--brass);
  animation: bar-pulse 1.1s ease-in-out infinite;
}

.bars i:nth-child(2) { animation-delay: 0.15s; }
.bars i:nth-child(3) { animation-delay: 0.3s; }

.gate__download {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: 8px 16px;
  border: 1px solid rgba(77, 255, 240, 0.25);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.18s, color 0.18s;
}

.gate__download:hover { border-color: var(--brass); color: var(--brass); }

.gate__card {
  position: relative;
  z-index: 2;
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(8, 22, 26, 0.92), rgba(4, 10, 12, 0.94));
  border: 1px solid rgba(77, 255, 240, 0.22);
  border-radius: var(--radius);
  padding: 34px 32px 30px;
  box-shadow: 0 0 60px rgba(77, 255, 240, 0.08), inset 0 0 60px rgba(77, 255, 240, 0.03);
  animation: boot-in 0.5s ease both;
}

/* Уголки-скобки как на прицельной рамке. */
.gate__card::before,
.gate__card::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--brass);
}

.gate__card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.gate__card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.gate__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  font-family: "Chakra Petch", "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.18em;
  color: var(--bright);
}

.gate__mark {
  width: 10px;
  height: 10px;
  background: var(--brass);
  transform: rotate(45deg);
  animation: ring 2.2s ease-out infinite;
}

.gate__node {
  margin-left: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.glitch { position: relative; }

.gate__lede {
  margin: 0 0 22px;
  padding-top: 22px;
  border-top: 1px solid rgba(77, 255, 240, 0.15);
  color: var(--muted);
  font-size: 12px;
}

.switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 24px;
  background: transparent;
  border: 1px solid rgba(77, 255, 240, 0.16);
  border-radius: var(--radius);
}

.switch__btn {
  flex: 1;
  padding: 9px;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: "Chakra Petch", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.switch__btn.is-on { background: rgba(77, 255, 240, 0.14); color: var(--brass); }

.field { display: block; margin-bottom: 16px; }

.field__label {
  display: block;
  margin-bottom: 7px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.rail__search input,
#draft {
  width: 100%;
  padding: 11px 13px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.2);
  border-radius: var(--radius);
  outline: none;
  color: var(--bright);
  letter-spacing: 0.04em;
  caret-color: var(--brass);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.field input:focus,
.rail__search input:focus,
#draft:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 1px rgba(77, 255, 240, 0.35), 0 0 22px rgba(77, 255, 240, 0.18);
}

.gate__seal {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 18px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.gate__seal::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 10px var(--brass);
}

.notice {
  margin: 0 0 12px;
  padding: 9px 11px;
  background: rgba(255, 56, 96, 0.1);
  border: 1px solid rgba(255, 56, 96, 0.4);
  border-left-width: 3px;
  font-size: 12.5px;
  color: #ff9aab;
}

.notice--ok {
  background: rgba(61, 220, 132, 0.1);
  border-color: rgba(61, 220, 132, 0.4);
  color: var(--online-dot);
}

.gate__link {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 4px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gate__link:hover { color: var(--brass); }

.btn {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  background: rgba(0, 0, 0, 0.5);
  padding: 9px 14px;
  font-family: "Chakra Petch", "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.1s, background 0.2s;
}

.btn:hover { border-color: var(--brass); box-shadow: 0 0 18px rgba(77, 255, 240, 0.22); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 1px solid var(--brass); outline-offset: 2px; }

.btn--primary {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 14px;
  background: var(--brass);
  border-color: var(--brass);
  color: #04120f;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.btn--primary:hover { box-shadow: 0 0 28px rgba(77, 255, 240, 0.45); }

/* Блик, пробегающий по кнопке входа. */
.btn--primary::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 2.6s linear infinite;
}

.btn--primary:disabled { opacity: 0.6; cursor: progress; }

.btn--ghost {
  background: none;
  border-color: rgba(77, 255, 240, 0.25);
  color: var(--brass);
  padding: 5px 10px;
  font-size: 10px;
  text-transform: uppercase;
}

.btn--icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 17px;
  color: var(--brass);
  flex: 0 0 auto;
}

.btn--send {
  width: auto;
  flex: 0 0 auto;
  padding: 12px 20px;
  font-size: 12px;
  letter-spacing: 0.2em;
}

.btn--send::after { display: none; }

/* ── Экран «доступ разрешён» ────────────────────────── */

.grant {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 26px;
  background: rgba(4, 7, 10, 0.86);
  backdrop-filter: blur(3px);
}

.grant__text {
  font-family: "Chakra Petch", monospace;
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--brass);
  text-shadow: 0 0 32px rgba(77, 255, 240, 0.6);
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-content: center;
  background: rgba(4, 7, 10, 0.7);
  backdrop-filter: blur(2px);
}

.confirm-modal__box {
  width: min(360px, 84vw);
  padding: 22px 24px;
  background: linear-gradient(180deg, rgba(8, 22, 26, 0.96), rgba(4, 10, 12, 0.98));
  border: 1px solid rgba(77, 255, 240, 0.3);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.confirm-modal__text {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}

.confirm-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.grant__track { width: min(420px, 70vw); height: 3px; background: rgba(77, 255, 240, 0.15); }

.grant__bar {
  height: 100%;
  width: 0;
  background: var(--brass);
  box-shadow: 0 0 18px var(--brass);
  transition: width 0.12s linear;
}

.grant__note { font-size: 11px; letter-spacing: 0.18em; color: var(--muted); }

/* ── Каркас приложения ──────────────────────────────── */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: minmax(0, 1fr);
  animation: boot-in 0.6s ease both;
}

.rail {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(6, 16, 19, 0.9), rgba(4, 8, 10, 0.9));
  border-right: 1px solid rgba(77, 255, 240, 0.18);
}

.rail__matrix {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0.22;
  pointer-events: none;
}

.rail__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(77, 255, 240, 0.12);
}

.rail__head-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.hotkeys-panel {
  position: absolute;
  top: 100%;
  right: 18px;
  margin-top: 8px;
  z-index: 50;
  width: 240px;
  padding: 12px;
  background: #071316;
  border: 1px solid rgba(77, 255, 240, 0.25);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5);
}

.hotkeys-panel__title {
  margin: 0 0 10px;
  font-family: "Chakra Petch", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
}

.hotkeys-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text);
}

.hotkeys-keys {
  flex: 0 0 auto;
  padding: 4px 8px;
  background: rgba(77, 255, 240, 0.08);
  border: 1px solid rgba(77, 255, 240, 0.25);
  color: var(--brass);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
}

.hotkeys-keys:hover { border-color: var(--brass); }
.hotkeys-keys.is-recording { color: var(--warn); border-color: var(--warn); }

.hotkeys-panel__hint {
  margin: 8px 0 0;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}

.me { display: flex; align-items: center; gap: 11px; min-width: 0; }
.me__names { display: flex; flex-direction: column; min-width: 0; }
.me__name { font-weight: 500; color: var(--bright); }

.me__handle,
.room__status {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.me__status {
  display: block;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me__status:hover { color: var(--brass); }
.me__status.is-empty { font-style: italic; }

.me__status-input {
  display: block;
  margin-top: 2px;
  width: 100%;
  max-width: 150px;
  padding: 2px 5px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--brass);
  border-radius: 0;
  font-size: 11px;
  outline: none;
  caret-color: var(--brass);
}

.me__email {
  display: block;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me__email:hover { color: var(--brass); }
.me__email.is-empty { font-style: italic; }
.me__email.is-unverified { color: var(--warn); }

.me__email-input {
  display: block;
  margin-top: 2px;
  width: 100%;
  max-width: 220px;
  padding: 2px 5px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--brass);
  border-radius: 0;
  font-size: 11px;
  outline: none;
  caret-color: var(--brass);
}

.avatar {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: rgba(77, 255, 240, 0.1);
  border: 1px solid rgba(77, 255, 240, 0.35);
  font-family: "Chakra Petch", monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--brass);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
  /* цвет из профиля приходит инлайном — гасим его до тонкой заливки */
  background-blend-mode: overlay;
}

.avatar.is-online::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--online-dot);
  border: 2px solid var(--ink);
  box-shadow: 0 0 6px rgba(61, 220, 132, 0.7);
}

.room__head .avatar {
  width: 56px;
  height: 56px;
  font-size: 17px;
}

.avatar.has-image {
  background-size: cover;
  background-position: center;
  background-blend-mode: normal;
}

.avatar-wrap { position: relative; flex: 0 0 auto; display: inline-flex; }

.avatar-edit {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  background: #071316;
  border: 1px solid var(--brass);
  border-radius: 50%;
  color: var(--brass);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
}

.avatar-edit:hover { box-shadow: 0 0 10px rgba(77, 255, 240, 0.5); }

.rail__search { position: relative; padding: 12px 14px; border-bottom: 1px solid rgba(77, 255, 240, 0.1); }
.rail__search input { padding: 9px 11px; font-size: 12.5px; }

.rail__scroll {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 16px;
}

.section__label {
  margin: 6px 0 8px;
  padding: 0 18px;
  font-family: "Chakra Petch", monospace;
  font-size: 9.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint { margin: 4px 18px; color: var(--muted); font-size: 12px; }

.section__label--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section__action {
  padding: 3px 8px;
  background: none;
  border: 1px solid rgba(77, 255, 240, 0.25);
  color: var(--muted);
  font-family: "Chakra Petch", monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s;
}

.section__action:hover { border-color: var(--brass); color: var(--brass); }

.row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 18px;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s;
  animation: slide-l 0.4s ease both;
}

.row:hover { background: rgba(77, 255, 240, 0.06); }
.row.is-open { background: rgba(77, 255, 240, 0.08); border-left-color: var(--brass); }
.row.is-online .avatar { box-shadow: 0 0 12px rgba(77, 255, 240, 0.45); }

.row__body { flex: 1; min-width: 0; }

.row__friend-star {
  flex: 0 0 auto;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
}
.row__friend-star:hover { color: var(--brass); }
.row__friend-star.is-friend { color: var(--brass); }
.row__friend-star.is-pending { color: var(--pink); }

#friend-star.is-friend { color: var(--brass); }
#friend-star.is-pending { color: var(--pink); }

.row__friend-remove {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}
.row__friend-remove:hover { color: var(--danger); }

.row__friend-actions { flex: 0 0 auto; display: flex; gap: 4px; }

.row__friend-actions button {
  background: none;
  border: 1px solid rgba(77, 255, 240, 0.25);
  color: var(--text);
  font-size: 12px;
  padding: 3px 7px;
  cursor: pointer;
}

.row__friend-actions button:hover { border-color: var(--brass); color: var(--brass); }

.row__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.row__name {
  color: var(--bright);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__time,
.stamp {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--muted);
}

.row__call-tag {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--brass);
  white-space: nowrap;
}

.row__preview {
  margin-top: 2px;
  font-size: 11.5px;
  color: #4a6f6c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  flex: 0 0 auto;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 0;
  background: var(--brass);
  color: #04120f;
  border: 0;
  font-family: "Chakra Petch", monospace;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 0 14px rgba(77, 255, 240, 0.5);
}

.rail__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid rgba(77, 255, 240, 0.12);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.rail__version {
  padding: 0 18px 10px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.7;
}

/* ── Комната ────────────────────────────────────────── */

.room {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--canvas);
}

.room__blank {
  position: relative;
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  overflow: hidden;
}

.room__blank::before {
  content: "КВОРУМ";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Chakra Petch", monospace;
  font-weight: 700;
  font-size: 92px;
  letter-spacing: 0.2em;
  color: rgba(77, 255, 240, 0.05);
  white-space: nowrap;
  pointer-events: none;
}

.room__blank-title {
  margin: 0 0 6px;
  font-family: "Chakra Petch", monospace;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bright);
}

.room__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.room__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: rgba(6, 16, 19, 0.75);
  border-bottom: 1px solid rgba(77, 255, 240, 0.18);
}

.room__names {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.room__title,
.room__status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room__title {
  font-family: "Chakra Petch", monospace;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bright);
}

.room__status.is-online { color: var(--brass); }

/* Длинный список участников группы не должен раздвигать шапку и выталкивать
   кнопки звонка/участников/игр за край экрана — тянется только room__names. */
.room__head > .btn,
.room__head > .call-btn-wrap,
.room__head > .games-menu-wrap,
.room__head .tag {
  flex-shrink: 0;
}

.tag {
  padding: 6px 11px;
  border: 1px solid rgba(77, 255, 240, 0.2);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.pinned {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  background: rgba(6, 16, 19, 0.75);
  border-bottom: 1px solid rgba(77, 255, 240, 0.12);
  border-left: 2px solid var(--brass);
  cursor: pointer;
}

.pinned__icon { flex: 0 0 auto; font-size: 12px; }

.pinned__text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--muted);
}

.pinned__close {
  flex: 0 0 auto;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.pinned__close:hover { color: var(--brass); }

.stream-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.room__matrix {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.1;
  pointer-events: none;
}

.stream {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stream.is-dragover {
  outline: 1px dashed var(--brass);
  outline-offset: -10px;
  background: rgba(77, 255, 240, 0.06);
}

.daymark {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin: 16px 0 10px;
  font-size: 9.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #2f5350;
}

.daymark::before,
.daymark::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(77, 255, 240, 0.14);
}

.msg {
  position: relative;
  max-width: min(600px, 74%);
  padding: 11px 15px;
  border-radius: 0;
  background: var(--bubble-in);
  border: 1px solid rgba(77, 255, 240, 0.14);
  border-left: 2px solid var(--brass);
  align-self: flex-start;
  animation: slide-l 0.32s ease both;
}

.msg.is-mine {
  align-self: flex-end;
  background: var(--bubble-out);
  border: 1px solid rgba(77, 255, 240, 0.28);
  border-right: 2px solid var(--brass);
  box-shadow: 0 0 22px rgba(77, 255, 240, 0.1);
  animation-name: slide-r;
}

.msg.is-followup { margin-top: 0; }
.msg:not(.is-followup) { margin-top: 10px; }

.msg__tools {
  position: absolute;
  top: -15px;
  right: 8px;
  display: none;
  gap: 2px;
  padding: 2px;
  background: #071316;
  border: 1px solid rgba(77, 255, 240, 0.25);
  z-index: 3;
}

.msg.is-mine .msg__tools { right: auto; left: 8px; }
.msg:hover .msg__tools,
.msg__tools.is-open { display: flex; }

.msg__tool {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 12.5px;
  padding: 2px 6px;
  color: var(--text);
}

.msg__tool:hover { background: rgba(77, 255, 240, 0.12); }
.msg__tool.is-active { color: var(--brass); }

.msg__who {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 5px;
}

.msg.is-mine .msg__who { color: var(--pink); }

/* Курсор дешифровки — пока текст входящего «расшифровывается». */
.msg__text.is-decoding::after {
  content: "▮";
  color: var(--brass);
}

.msg__reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.reaction {
  border: 1px solid rgba(77, 255, 240, 0.2);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 0;
  padding: 1px 7px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}

.reaction.is-mine { border-color: var(--brass); background: rgba(77, 255, 240, 0.14); }

.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  display: flex;
  gap: 2px;
  padding: 4px;
  margin-bottom: 4px;
  background: #071316;
  border: 1px solid rgba(77, 255, 240, 0.25);
  z-index: 4;
}

.emoji-picker button {
  background: none;
  border: 0;
  font-size: 16px;
  padding: 2px 5px;
  cursor: pointer;
}

.emoji-picker button:hover { background: rgba(77, 255, 240, 0.12); }

.msg__text { white-space: pre-wrap; overflow-wrap: anywhere; color: #dff7f3; }
.msg__text--deleted { color: var(--muted); font-style: italic; }

.dice {
  font-size: 46px;
  line-height: 1;
  padding: 2px 4px;
  color: var(--brass);
  filter: drop-shadow(0 0 8px rgba(77, 255, 240, 0.5));
  animation: dice-roll 0.35s ease;
}

@keyframes dice-roll {
  from { transform: scale(0.4) rotate(-25deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.msg__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
}

.msg__read { font-size: 10px; color: var(--muted); }
.msg__read.is-read { color: var(--brass); }

.msg__image {
  display: block;
  max-width: 100%;
  max-height: 340px;
  margin-bottom: 6px;
  cursor: zoom-in;
  border: 1px solid rgba(77, 255, 240, 0.25);
  filter: saturate(0.85) contrast(1.05);
}

.msg__video {
  display: block;
  max-width: 100%;
  max-height: 340px;
  margin-bottom: 6px;
  border: 1px solid rgba(77, 255, 240, 0.25);
  background: #000;
}

.msg__file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(77, 255, 240, 0.2);
  color: inherit;
  text-decoration: none;
}

.msg__file:hover { border-color: var(--brass); }
.msg__file-name { font-size: 13px; word-break: break-all; }
.msg__file-size { font-size: 10.5px; letter-spacing: 0.1em; color: var(--muted); }

.composer {
  position: relative;
  padding: 14px 24px 20px;
  background: rgba(6, 16, 19, 0.75);
  border-top: 1px solid rgba(77, 255, 240, 0.18);
}

.composer-emoji {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 100%;
  margin-bottom: 8px;
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 2px;
  padding: 10px;
  background: #071316;
  border: 1px solid rgba(77, 255, 240, 0.25);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5);
  z-index: 5;
}

.composer-emoji button {
  background: none;
  border: 0;
  border-radius: 0;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.composer-emoji button:hover { background: rgba(77, 255, 240, 0.14); }

.ai-image-menu {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 100%;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: #071316;
  border: 1px solid rgba(77, 255, 240, 0.25);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5);
  z-index: 5;
}

.ai-image-menu__row { display: flex; gap: 8px; }
.ai-image-menu__row .btn--primary { width: auto; flex: 0 0 auto; padding: 8px 14px; }

.ai-image-menu select {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  border-radius: 0;
  color: var(--bright);
  font-size: 12.5px;
  outline: none;
}

.ai-image-menu__note { font-size: 11px; color: var(--muted); }

.ai-image-menu input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  border-radius: 0;
  color: var(--bright);
  font-size: 12.5px;
  outline: none;
}

.ai-image-menu.is-busy input,
.ai-image-menu.is-busy select { color: var(--muted); }

.ai-image-menu__edit { display: flex; align-items: center; gap: 10px; }

.ai-image-menu__attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px dashed rgba(77, 255, 240, 0.3);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}

.ai-image-menu__attach:hover { color: var(--brass); border-color: var(--brass); }

.ai-image-menu__attach.is-disabled {
  cursor: default;
  opacity: 0.4;
  pointer-events: none;
}

.ai-image-menu__preview { position: relative; flex: 0 0 auto; }

.ai-image-menu__preview img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border: 1px solid rgba(77, 255, 240, 0.3);
}

.ai-image-menu__preview button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  line-height: 14px;
  padding: 0;
  background: var(--ink);
  border: 1px solid var(--brass);
  color: var(--brass);
  font-size: 11px;
  cursor: pointer;
}

.composer__row { display: flex; align-items: flex-end; gap: 10px; }

.composer__prompt {
  align-self: center;
  padding-bottom: 10px;
  color: var(--brass);
  font-size: 15px;
  font-weight: 600;
}

#draft {
  resize: none;
  max-height: 160px;
  line-height: 1.45;
  padding: 11px 13px;
  /* Кнопки вокруг не сжимаются (flex: 0 0 auto), значит на узком экране
     сжиматься должно только поле ввода — но без flex: 1 оно, наоборот,
     первым съёживалось само, а не забирало оставшееся место. */
  flex: 1 1 auto;
  min-width: 0;
}

.composer__chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 8px;
  padding: 5px 6px 5px 11px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  font-size: 12.5px;
}

.composer__chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.composer__chip-thumb {
  display: block;
  max-width: 240px;
  max-height: 160px;
  border: 1px solid rgba(77, 255, 240, 0.2);
  object-fit: contain;
  background: #000;
}

.composer__chip button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.typing-line {
  height: 20px;
  margin: 0;
  padding: 0 24px 2px;
  background: var(--canvas);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--brass);
}

.room__back { display: none; }

.dots span {
  animation: blink 1.2s infinite;
  animation-delay: calc(var(--i) * 0.18s);
}

/* ── Голосовой звонок ───────────────────────────────── */

.call-bar {
  position: fixed;
  top: 92px; /* ниже шапки чата (~84px) — иначе панель закрывает её кнопки */
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 8px;
  background: rgba(6, 16, 19, 0.95);
  border: 1px solid rgba(77, 255, 240, 0.3);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  animation: ring 2s ease-out infinite;
  /* Ресайз мышкой за угол — тянется само пустое место вокруг кнопок,
     содержимое как было по размеру, так и остаётся: реально крупнее
     кнопки и текст делает только ползунок масштаба рядом. */
  resize: both;
  overflow: hidden;
  min-width: 220px;
  min-height: 44px;
  max-width: 92vw;
  max-height: 70vh;
}

.call-bar__info { display: flex; flex-direction: column; }

.call-bar__name {
  font-family: "Chakra Petch", monospace;
  font-size: 13px;
  color: var(--bright);
}

.call-bar__status {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.call-bar__actions { display: flex; align-items: center; gap: 4px; }
.call-bar__actions .btn--icon { width: 32px; height: 32px; font-size: 14px; }

.call-bar__handle {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.call-bar__handle:hover { color: var(--brass); }

.call-btn-wrap { position: relative; display: inline-flex; }

.call-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brass);
  color: #04100f;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  pointer-events: none;
}

.group-call-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(420px, 92vw);
  min-height: 120px;
  padding: 10px 14px;
  animation: none;
}

.group-call-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.group-call-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  background: rgba(77, 255, 240, 0.06);
  border: 1px solid rgba(77, 255, 240, 0.2);
  font-size: 11.5px;
  color: var(--text);
}

.group-call-chip .avatar { width: 22px; height: 22px; font-size: 9px; }
.group-call-chip.is-muted { opacity: 0.55; }

.group-call-chip__volume {
  width: 46px;
  accent-color: var(--brass);
  cursor: pointer;
}

.group-call-actions { justify-content: flex-end; }

.call-quality {
  padding: 5px 7px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  border-radius: 0;
  color: var(--text);
  font-size: 10.5px;
  outline: none;
}

/* Меню выбора микрофона/колонок — отдельный плавающий блок поверх всего,
   не внутри .call-bar (у неё overflow: hidden из-за ресайза за угол). */
.device-menu {
  position: fixed;
  z-index: 600;
  width: 232px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #071316;
  border: 1px solid rgba(77, 255, 240, 0.25);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5);
  font-size: 11px;
  color: var(--muted);
}

.device-menu__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.device-menu__row select {
  padding: 6px 7px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  border-radius: 0;
  color: var(--bright);
  font-size: 11px;
  outline: none;
  max-width: 100%;
}

.device-menu__note {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--muted);
}

.device-menu__check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(77, 255, 240, 0.15);
  cursor: pointer;
}

.device-menu__check input {
  accent-color: var(--brass);
  cursor: pointer;
}

.screen-view {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 400;
  width: min(420px, 40vw);
  height: min(236px, 30vh);
  min-width: 220px;
  min-height: 130px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: #000;
  border: 1px solid rgba(77, 255, 240, 0.3);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  resize: both;
  overflow: hidden;
}

.screen-view__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px 0 9px;
  background: rgba(6, 16, 19, 0.95);
  border-bottom: 1px solid rgba(77, 255, 240, 0.25);
}

.screen-view__handle {
  flex: 1;
  padding: 6px 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.screen-view__btn {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.screen-view__btn:hover { color: var(--brass); }

.screen-view__volume {
  flex: 0 0 60px;
  accent-color: var(--brass);
  cursor: pointer;
}

.call-bar__volume {
  accent-color: var(--brass);
  width: 60px;
  cursor: pointer;
}

.screen-view video {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  display: block;
}

/* ── Шахматы ────────────────────────────────────────── */

.chess-panel {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 450;
  width: 380px;
  max-width: 94vw;
  background: rgba(6, 16, 19, 0.97);
  border: 1px solid rgba(77, 255, 240, 0.3);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

.chess-panel__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px 0 9px;
  background: rgba(6, 16, 19, 0.95);
  border-bottom: 1px solid rgba(77, 255, 240, 0.25);
}

.chess-panel__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px;
}

.chess-status {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text);
  text-align: center;
  min-height: 16px;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(340px, 84vw);
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(77, 255, 240, 0.35);
}

.chess-sq {
  display: grid;
  place-items: center;
  font-size: clamp(20px, 5.5vw, 32px);
  line-height: 1;
  cursor: default;
  user-select: none;
}

.chess-sq.is-light { background: rgba(255, 255, 255, 0.06); }
.chess-sq.is-dark { background: rgba(0, 0, 0, 0.35); }
.chess-sq.is-white-piece { color: #eafffb; text-shadow: 0 0 6px rgba(77, 255, 240, 0.7); }
.chess-sq.is-black-piece { color: #6a8f8a; text-shadow: 0 0 6px rgba(0, 0, 0, 0.8); }
.chess-sq.is-selectable { cursor: pointer; }
.chess-sq.is-selected { box-shadow: inset 0 0 0 2px var(--brass); }
.chess-sq.is-target { cursor: pointer; box-shadow: inset 0 0 0 2px rgba(77, 255, 240, 0.6); }
.chess-sq.is-target::after {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(77, 255, 240, 0.5);
}
.chess-sq.is-check { box-shadow: inset 0 0 0 2px var(--danger); }
.chess-sq { position: relative; }

.chess-actions { display: flex; gap: 8px; }

/* ── Группы ─────────────────────────────────────────── */

.group-panel .field,
.group-panel .group-members-list,
.group-panel .group-picked,
.group-panel .group-results,
.group-panel #group-submit,
.group-panel #group-leave {
  width: 100%;
}

.group-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.group-avatar-hint {
  font-size: 11px;
  color: var(--muted);
}

.group-members-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}

.group-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  font-size: 13px;
  color: var(--text);
}

.group-picked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.group-picked:empty { display: none; margin: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  background: rgba(77, 255, 240, 0.08);
  border: 1px solid rgba(77, 255, 240, 0.25);
  font-size: 12px;
  color: var(--bright);
}

.chip button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}

.chip button:hover { color: var(--danger); }

.group-results { max-height: 180px; overflow-y: auto; }
.group-results:empty { display: none; }

.group-panel #group-leave { margin-top: 6px; color: #ff9aab; border-color: rgba(255, 56, 96, 0.4); }

/* ── Меню игр ───────────────────────────────────────── */

.games-menu-wrap { position: relative; display: inline-flex; }

.games-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  z-index: 60;
  width: 200px;
  padding: 6px;
  background: #071316;
  border: 1px solid rgba(77, 255, 240, 0.25);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5);
}

.games-menu button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.games-menu button:hover { background: rgba(77, 255, 240, 0.12); color: var(--brass); }

/* ── Пинг-понг ──────────────────────────────────────── */

.pong-canvas {
  background: #000;
  border: 1px solid rgba(77, 255, 240, 0.25);
}

.pong-hint {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.piano-panel { width: 660px; }
.piano-panel .chess-panel__body { overflow-x: auto; }

.piano-keys {
  position: relative;
  margin: 4px auto 0;
}

.piano-key {
  position: absolute;
  top: 0;
  border: 1px solid rgba(77, 255, 240, 0.35);
  border-radius: 0 0 4px 4px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: background 0.05s;
}

.piano-key.is-white {
  background: var(--bright);
  z-index: 1;
}

.piano-key.is-white.is-active { background: var(--brass); }

.piano-key.is-black {
  background: var(--ink);
  z-index: 2;
}

.piano-key.is-black.is-active { background: var(--brass); }

.piano-key__label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  pointer-events: none;
}

.piano-key.is-black .piano-key__label {
  bottom: 6px;
  font-size: 9px;
  color: rgba(234, 255, 251, 0.65);
}

.piano-key.is-white.is-active .piano-key__label { color: var(--ink); }

.beat-panel { width: 660px; }
.beat-panel .chess-panel__body { overflow-x: auto; align-items: stretch; }

.beat-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.beat-bpm {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.beat-bpm input {
  width: 58px;
  padding: 5px 6px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.beat-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 auto;
  width: max-content;
}

.beat-row { display: flex; align-items: center; gap: 8px; }

.beat-label {
  flex: 0 0 76px;
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.beat-row select.beat-sound {
  flex: 0 0 120px;
  font-size: 9.5px;
  padding: 4px 5px;
}

.beat-sampler {
  width: 100%;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed rgba(77, 255, 240, 0.2);
}

.beat-sample-control {
  flex: 0 0 120px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 0;
  background: none;
  border: none;
}

.beat-sample-upload {
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  color: var(--brass);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
}

.beat-sample-upload:hover { border-color: var(--brass); }

.beat-sample-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  color: var(--muted);
}

/* ── Плеер ──────────────────────────────────────────── */

.player-panel { width: 400px; }

.player-viz {
  width: 100%;
  height: 70px;
  background: var(--ink);
  border: 1px solid rgba(77, 255, 240, 0.3);
  box-shadow: inset 0 0 24px rgba(77, 255, 240, 0.08);
}

.player-progress {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(77, 255, 240, 0.25);
  cursor: pointer;
  position: relative;
}

.player-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--brass);
  box-shadow: 0 0 10px var(--brass);
}

.player-time {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.player-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.player-volume input[type="range"] {
  accent-color: var(--brass);
  width: 80px;
}

.player-playlist-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-playlist {
  width: 100%;
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.player-track {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(77, 255, 240, 0.15);
  cursor: pointer;
}

.player-track:hover { border-color: rgba(77, 255, 240, 0.4); }

.player-track.is-current {
  border-color: var(--brass);
  background: rgba(77, 255, 240, 0.1);
}

.player-track__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text);
}

.player-track.is-current .player-track__name { color: var(--brass); }

.player-track__by {
  flex: 0 0 auto;
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}

.player-track__remove {
  flex: 0 0 auto;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.player-track__remove:hover { color: var(--danger); }

.beat-steps { display: flex; gap: 3px; }

.beat-step {
  width: 22px;
  height: 22px;
  padding: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(77, 255, 240, 0.2);
  cursor: pointer;
}

.beat-step.is-group-start { border-left-color: rgba(77, 255, 240, 0.55); }
.beat-step.is-on { background: var(--brass); border-color: var(--brass); }
.beat-step.is-playhead { box-shadow: 0 0 0 2px rgba(234, 255, 251, 0.8) inset; }

@media (prefers-reduced-motion: reduce) {
  body, .app, .gate__card, .row, .msg { animation: none !important; }
  .gate::after, .gate__bg::after, .btn--primary::after, .gate__mark, .bars i, .dots span { animation: none; }
  * { transition: none !important; }
}

@media (max-width: 1100px) {
  .gate {
    grid-template-columns: 1fr;
    align-content: center;
    justify-items: center;
    gap: 24px;
    padding: 32px 24px;
  }
  .hud { align-self: auto; width: min(460px, 100%); }
  .hud--right { display: none; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .app.is-room-open .room { display: flex; }
  .app:not(.is-room-open) .rail { display: flex; }
  .app:not(.is-room-open) .room { display: none; }
  .msg { max-width: 88%; }
  .stream, .composer, .room__head { padding-left: 14px; padding-right: 14px; }
  .room__back { display: block; }

  /* На телефоне строка ввода должна быть невысокой горизонтальной
     полоской вровень с соседними кнопками, а не расти вверх при
     переносе текста — длинное сообщение просто скроллится внутри
     самого поля. Слово «Передать» на такой ширине не помещается,
     заменяем его стрелкой. */
  #draft { max-height: 40px; }
  .btn--send {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 0;
    display: grid;
    place-items: center;
  }
  .btn--send::before {
    content: "➤";
    font-size: 15px;
    letter-spacing: normal;
  }
}
