:root {
  --bg: #111418;
  --panel: #1b2027;
  --panel-2: #262c35;
  --text: #eef1f4;
  --muted: #9aa4b1;
  --accent: #3fb68b;
  --accent-text: #06231a;
  --danger: #e5484d;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.screen { min-height: 100dvh; }
.center { display: grid; place-items: center; padding: 16px; }
.card {
  width: min(440px, 100%);
  background: var(--panel);
  border-radius: 24px;
  padding: 28px 22px;
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
}
.logo { width: 64px; height: 64px; margin: 0 auto; }
h1 { margin: 0; font-size: 26px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }
.error { color: #ff8b8f; margin: 0; }

.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  background: var(--panel-2); color: var(--text);
  border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.big { padding: 16px; font-size: 18px; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn:active { transform: scale(.98); }

.row { display: flex; gap: 8px; }
input {
  flex: 1; min-width: 0;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--panel-2); border-radius: 12px;
  padding: 12px 14px; font: inherit;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; color: var(--muted); font-size: 14px; }

.preview { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: var(--radius); overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.preview-controls { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; gap: 12px; justify-content: center; }

.round {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: var(--text);
  display: grid; place-items: center; backdrop-filter: blur(8px);
}
.round svg { width: 26px; height: 26px; fill: currentColor; }
.round.off { background: #fff; color: #111; }
.round.danger { background: var(--danger); }
.round.active { background: var(--accent); color: var(--accent-text); }

/* ---------- звонок ---------- */
#call { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}
.topbar #callTitle { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid {
  flex: 1; min-height: 0;
  display: grid; gap: 8px; padding: 0 8px;
  grid-template-columns: repeat(var(--cols, 1), 1fr);
  grid-auto-rows: 1fr;
}
.tile {
  position: relative; background: var(--panel); border-radius: var(--radius); overflow: hidden;
  min-height: 0; outline: 3px solid transparent; transition: outline-color .15s;
}
.tile.speaking { outline-color: var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.contain video { object-fit: contain; }
.tile .avatar {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 44px; font-weight: 700; color: var(--muted); background: var(--panel);
}
.tile .label {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  background: rgba(0, 0, 0, .55); padding: 4px 10px; border-radius: 10px; font-size: 14px;
  display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .label svg { width: 16px; height: 16px; fill: #ff8b8f; flex: none; }
.tile .status {
  position: absolute; top: 8px; left: 8px; font-size: 13px; color: var(--muted);
  background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 8px;
}

.alone { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; text-align: center; padding: 24px; pointer-events: none; }
.alone > * { pointer-events: auto; }
.self {
  position: absolute; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 92px);
  width: 28vw; max-width: 180px; aspect-ratio: 3 / 4;
  border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
  z-index: 2; touch-action: none;
}
.self video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.self.back video, .self.screen video { transform: none; }
.self.solo { inset: 56px 8px calc(env(safe-area-inset-bottom) + 88px); width: auto; max-width: none; aspect-ratio: auto; }
.controls {
  display: flex; gap: 14px; justify-content: center;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px);
}
@media (min-width: 900px) {
  .self { width: 220px; max-width: none; aspect-ratio: 16 / 10; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translateX(-50%);
  background: #fff; color: #111; padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 10;
  max-width: calc(100% - 32px); text-align: center;
}

/* ---------- индикатор уровня микрофона ---------- */
.meter { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.meter.big { height: 10px; margin: 8px 0; }
.meter > div { height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.self-meter { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 4px; border-radius: 2px; background: rgba(0,0,0,.4); overflow: hidden; }
.self-meter > div { height: 100%; width: 0; background: var(--accent); }
.self.nomirror video { transform: none; }

/* ---------- плитки: доп. элементы ---------- */
.tile .q { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; margin-left: 4px; }
.tile .q i { width: 3px; background: rgba(255,255,255,.3); border-radius: 1px; }
.tile .q i:nth-child(1) { height: 4px; } .tile .q i:nth-child(2) { height: 8px; } .tile .q i:nth-child(3) { height: 12px; }
.tile .q.good i { background: var(--accent); }
.tile .q.ok i:nth-child(-n+2) { background: #f0b429; }
.tile .q.poor i:nth-child(1) { background: var(--danger); }
.tile .menu {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.5); color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.tile .hand { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-size: 28px; }
.self .hand { position: absolute; top: 4px; right: 6px; font-size: 20px; }
.tile.pinned { grid-column: 1 / -1; grid-row: span 2; }

/* ---------- кнопки управления ---------- */
.controls { flex-wrap: wrap; gap: 10px; }
.round { position: relative; font-size: 22px; }
.badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; }
@media (max-width: 520px) {
  .round { width: 42px; height: 42px; font-size: 18px; }
  .round svg { width: 20px; height: 20px; }
  .controls { gap: 6px; padding-left: 8px; padding-right: 8px; flex-wrap: nowrap; }
  /* своё видео — в правом нижнем углу над кнопками: там у плиток нет элементов управления */
  .self:not(.solo) { bottom: calc(env(safe-area-inset-bottom) + 70px); right: 10px; width: 24vw; }
}
.ptt-hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 84px); background: rgba(0,0,0,.6); padding: 6px 12px; border-radius: 10px; font-size: 14px; z-index: 3; }

/* ---------- чат ---------- */
.chat {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 100%); z-index: 5;
  background: var(--panel); display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.4);
  padding: calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 12px);
}
.chat header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 10px; }
.msg { background: var(--panel-2); border-radius: 12px; padding: 8px 10px; max-width: 90%; word-wrap: break-word; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: #1f4d3d; }
.msg .who { font-size: 12px; color: var(--muted); display: block; margin-bottom: 2px; }
.msg a { color: #8fd8bb; }

/* ---------- диалоги ---------- */
dialog { border: 0; border-radius: 20px; background: var(--panel); color: var(--text); padding: 0; max-width: min(520px, calc(100% - 24px)); width: 100%; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.settings-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100dvh - 40px); overflow-y: auto; }
.settings-body header { display: flex; justify-content: space-between; align-items: center; }
.settings-body h2 { margin: 0; font-size: 20px; }
.settings section { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--panel-2); padding-top: 12px; }
.settings h3, .peer-menu h3 { margin: 0; font-size: 15px; color: var(--muted); font-weight: 600; }
select { background: var(--bg); color: var(--text); border: 1px solid var(--panel-2); border-radius: 12px; padding: 10px 12px; font: inherit; width: 100%; min-width: 0; }
.opt { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.slider input { width: 100%; accent-color: var(--accent); }
.stats { line-height: 1.6; }
.peer-menu form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.row.wrap { flex-wrap: wrap; }

/* ================= пространство (как Discord) ================= */
.space { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; min-height: 0; overflow: hidden; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; position: relative; flex: none;
  font: inherit; font-size: 20px; line-height: 1;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn.sm { width: 22px; height: 22px; font-size: 16px; }
.icon-btn.off { color: var(--danger); }
.icon-btn.on { color: var(--accent); }
.icon-btn.danger:hover { background: var(--danger); color: #fff; }
.danger-text { color: #ff8b8f !important; }
.hint { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 14px; }
.confirm { display: flex; flex-direction: column; gap: 10px; }
.confirm p { margin: 0; }
.confirm .row > * { flex: 1; }

.ava {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 15px; text-shadow: 0 1px 2px rgba(0,0,0,.3); user-select: none;
}
.ava.sm { width: 24px; height: 24px; font-size: 12px; }
.ava-wrap { position: relative; display: inline-flex; flex: none; }
.dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: #5c6570; border: 2px solid var(--panel); }
.dot.on { background: var(--accent); }

/* ---- боковая панель ---- */
.sidebar { background: var(--panel); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid #0b0d10; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 12px) 12px 12px 16px; border-bottom: 1px solid #0b0d10; font-size: 17px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.side-section { display: flex; align-items: center; justify-content: space-between; padding: 14px 6px 4px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.side-empty { padding: 2px 8px; }
.ch {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; text-align: left;
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; min-height: 34px;
}
.ch:hover { background: var(--panel-2); color: var(--text); }
.ch.active { background: #333a45; color: var(--text); }
.ch.unread { color: var(--text); font-weight: 600; }
.ch .hash { width: 18px; flex: none; text-align: center; font-size: 18px; opacity: .7; fill: currentColor; height: 18px; }
.ch .ch-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch .badge, .ch-badge { position: static; flex: none; }
.ch.voice.joined { color: var(--accent); }
.ch.person.offline { opacity: .55; }
.vm { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 34px; border-radius: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }
.vm:hover { background: var(--panel-2); color: var(--text); }
.vm > span:not(.ava) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm .ava { outline: 2px solid transparent; transition: outline-color .1s; }
.vm.speaking .ava { outline-color: var(--accent); }
.vm i { display: inline-flex; gap: 4px; align-items: center; font-style: normal; }
.vm i svg { width: 15px; height: 15px; fill: var(--muted); }
.vm i svg.red { fill: var(--danger); }
.live { background: var(--danger); color: #fff; font-size: 9px; font-weight: 800; padding: 1px 4px; border-radius: 4px; }

.voice-bar { display: flex; align-items: center; gap: 2px; padding: 8px; border-top: 1px solid #0b0d10; background: #161a20; }
.vb-info { appearance: none; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 2px 6px; border-radius: 8px; }
.vb-info:hover { background: var(--panel-2); }
.vb-info b { color: var(--accent); font-size: 13px; }
.vb-info span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-bar { display: flex; align-items: center; gap: 2px; padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px); background: #161a20; }
.me { appearance: none; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.me:hover { background: var(--panel-2); }
.me span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- основная часть ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.main-head { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; border-bottom: 1px solid #0b0d10; min-height: 54px; }
.main-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.main-title b, .main-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: none; font-size: 30px; }
.main-body { flex: 1; min-height: 0; display: flex; position: relative; }
.voice-pane { flex: 1; min-width: 0; display: flex; }
.offscreen { position: absolute !important; left: -10000px; top: 0; width: 1px !important; height: 1px; overflow: hidden; flex: none; }
#call.embedded { height: auto; flex: 1; min-width: 0; position: relative; }
#call.embedded .topbar { display: none; }
#call.embedded .grid { padding-top: 8px; }
#call.embedded .self.solo { inset: 8px 8px 88px; }

.chat-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.chat-pane.beside { flex: none; width: 380px; border-left: 1px solid #0b0d10; }
.msg-list { flex: 1; overflow-y: auto; padding: 12px 14px 6px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.msg-list > .more, .msg-list > .start { text-align: center; padding: 10px; }
.day, .new-sep { display: flex; justify-content: center; margin: 10px 0 6px; position: sticky; top: 0; z-index: 1; }
.day span { background: rgba(38, 44, 53, .9); color: var(--muted); font-size: 13px; padding: 3px 10px; border-radius: 10px; backdrop-filter: blur(6px); }
.new-sep { position: static; border-top: 1px solid var(--danger); margin: 12px 0; }
.new-sep span { background: var(--bg); color: #ff8b8f; font-size: 12px; font-weight: 700; padding: 0 8px; margin-top: -10px; }

.m { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 8px; padding-left: 44px; position: relative; }
.m.grouped { margin-top: 2px; }
.m.mine { flex-direction: row-reverse; padding-left: 0; padding-right: 4px; }
.m .m-ava { position: absolute; left: 0; top: 0; cursor: pointer; }
.bubble {
  position: relative; max-width: min(560px, 82%); min-width: 72px; background: var(--panel-2); border-radius: 16px 16px 16px 6px;
  padding: 6px 10px 6px; word-wrap: break-word; overflow-wrap: anywhere;
}
.m.grouped .bubble { border-top-left-radius: 6px; }
.m.mine .bubble { background: #1f4d3d; border-radius: 16px 16px 6px 16px; }
.m.mine.grouped .bubble { border-top-right-radius: 6px; }
.m.mentioned .bubble { box-shadow: inset 3px 0 0 #f0b429; }
.m.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 30% { background: #4b5a6e; } }
.bubble .who { display: block; font-size: 14px; margin-bottom: 1px; cursor: pointer; }
.bubble .text { white-space: pre-wrap; display: inline; }
.bubble .text a { color: #8fd8bb; }
.bubble .text code { background: rgba(0,0,0,.3); padding: 1px 5px; border-radius: 5px; font: 14px ui-monospace, Menlo, Consolas, monospace; }
.bubble .text pre { background: rgba(0,0,0,.3); padding: 8px 10px; border-radius: 8px; margin: 4px 0; overflow-x: auto; font: 13px ui-monospace, Menlo, Consolas, monospace; white-space: pre; }
.mention { color: #8ec5ff; font-weight: 600; }
.mention.me { background: rgba(240, 180, 41, .2); color: #f0c75e; border-radius: 4px; padding: 0 2px; }
.bubble .meta { float: right; font-size: 11px; color: rgba(238,241,244,.5); margin: 8px 0 -4px 10px; white-space: nowrap; user-select: none; }
.bubble.jumbo { background: transparent !important; font-size: 40px; line-height: 1.15; padding: 0 2px; }
.bubble.media { padding: 3px; }
.bubble.media .meta { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.5); color: #fff; padding: 1px 6px; border-radius: 8px; margin: 0; }
.bubble .pic { display: block; width: 100%; max-width: 100%; height: auto; max-height: 360px; object-fit: cover; border-radius: 12px; margin: 2px 0 4px; cursor: zoom-in; background: rgba(0,0,0,.25); }
.bubble video.pic { cursor: auto; object-fit: contain; }
.bubble audio { display: block; max-width: 100%; margin: 4px 0; }
.file { display: flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; padding: 6px 4px; }
.file b { display: block; font-size: 14px; word-break: break-all; }
.file small, .att small { display: block; color: var(--muted); font-size: 12px; }
.file-ico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: rgba(0,0,0,.3); border-radius: 10px; font-size: 20px; }
.quote { border-left: 3px solid var(--c); background: rgba(255,255,255,.06); border-radius: 6px; padding: 3px 8px; margin: 2px 0 4px; cursor: pointer; font-size: 14px; display: flex; flex-direction: column; overflow: hidden; }
.quote b { color: var(--c); font-size: 13px; }
.quote span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acts { position: absolute; top: -14px; right: 6px; display: none; gap: 2px; background: var(--panel); border-radius: 8px; padding: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.m.mine .acts { right: auto; left: 6px; }
.bubble:hover .acts { display: flex; }
.acts button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 28px; height: 26px; border-radius: 6px; font-size: 16px; }
.acts button:hover { background: var(--panel-2); color: var(--text); }
.reacts { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; }
.m.mine .reacts { justify-content: flex-end; }
.react { border: 1px solid transparent; background: var(--panel-2); color: var(--text); border-radius: 12px; padding: 2px 8px; font: inherit; font-size: 14px; cursor: pointer; }
.react.mine { background: #1f4d3d; border-color: var(--accent); }

.typing { min-height: 20px; padding: 0 16px; font-size: 13px; color: var(--muted); font-style: italic; }
.to-bottom { position: absolute; right: 18px; bottom: 90px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--panel-2); color: var(--text); font-size: 20px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.4); z-index: 2; }
.to-bottom .badge { top: -6px; right: -4px; }
.composer { padding: 0 12px calc(env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; gap: 6px; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; background: var(--panel); border-radius: 14px; padding: 5px; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; padding: 6px 4px; max-height: 200px; line-height: 1.4;
}
.send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); cursor: pointer; display: grid; place-items: center; flex: none; }
.send svg { width: 18px; height: 18px; fill: currentColor; }
.reply-bar { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 12px; padding: 6px 8px 6px 12px; border-left: 3px solid var(--accent); }
.reply-bar > svg { width: 20px; height: 20px; fill: var(--accent); flex: none; }
.reply-bar.editing { border-left-color: #8ec5ff; }
.reply-bar.editing > svg { fill: #8ec5ff; }
.reply-bar div { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.reply-bar span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-list { display: flex; gap: 8px; overflow-x: auto; }
.att { display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 12px; padding: 6px 8px; flex: none; max-width: 240px; }
.att.failed { outline: 1px solid var(--danger); }
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.att-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.att button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.drop-hint { position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: 16px; background: rgba(17,20,24,.85); display: grid; place-items: center; font-size: 20px; font-weight: 600; z-index: 4; pointer-events: none; }

/* ---- меню, просмотр, профиль ---- */
.ctx-menu { position: fixed; z-index: 20; background: var(--panel); border-radius: 14px; padding: 6px; min-width: 220px; box-shadow: 0 8px 30px rgba(0,0,0,.55); display: flex; flex-direction: column; }
.ctx-menu > button { appearance: none; border: 0; background: none; color: var(--text); font: inherit; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.ctx-menu > button:hover { background: var(--panel-2); }
.ctx-react { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--panel-2); margin-bottom: 4px; }
.ctx-react button { border: 0; background: none; font-size: 22px; cursor: pointer; border-radius: 8px; width: 34px; height: 36px; padding: 0; }
.ctx-react button:hover { background: var(--panel-2); transform: scale(1.15); }
.ctx-title { display: flex; gap: 10px; align-items: center; padding: 6px 8px 8px; border-bottom: 1px solid var(--panel-2); margin-bottom: 4px; }
.ctx-title small { display: block; color: var(--muted); font-size: 12px; }
.viewer { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: calc(100dvh - 90px); object-fit: contain; }
.viewer a { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 16px); }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.colors button.sel { border-color: #fff; }
.settings a.btn, .settings section > .btn { justify-content: flex-start; }
.peer-menu input { width: 100%; }

/* ---- телефон: список каналов и чат по очереди, как в Telegram ---- */
@media (max-width: 760px) {
  .space { grid-template-columns: 1fr; }
  .main { display: none; }
  body.main-open .main { display: flex; }
  body.main-open .sidebar { display: none; }
  .back { display: inline-grid; }
  .chat-pane.beside { position: absolute; inset: 0; width: auto; z-index: 6; background: var(--bg); border: 0; }
  .bubble { max-width: 86%; }
  .m { padding-left: 40px; }
  .ava { width: 32px; height: 32px; }
  .ch { min-height: 42px; }
  .acts { display: none !important; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .chat-pane.beside { width: 320px; }
}
