/* ==========================================================================
   Z — оформление. Цвета меняются в одном месте (переменные ниже).
   ========================================================================== */

:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --border: #e0e5ee;
  --text: #121821;
  --muted: #6b7686;
  --accent: #4f7cff;
  --accent-text: #ffffff;
  --mine: #4f7cff;
  --mine-text: #ffffff;
  --theirs: #ffffff;
  --theirs-text: #121821;
  --danger: #e5484d;
  --ok: #1fb57a;
  --shadow: 0 2px 12px rgba(20, 30, 50, .08);
  --radius: 18px;
  --app-h: 100dvh;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --panel: #161b22;
    --panel-2: #1d232c;
    --border: #262d38;
    --text: #e7ebf0;
    --muted: #8b95a5;
    --accent: #5b8cff;
    --mine: #3f6fe8;
    --theirs: #1d232c;
    --theirs-text: #e7ebf0;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
img, video { max-width: 100%; }
[hidden] { display: none !important; }

#app {
  height: var(--app-h);
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
@media (min-width: 761px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

.splash { flex: 1; display: grid; place-items: center; }
.logo {
  width: 84px; height: 84px; border-radius: 24px;
  display: grid; place-items: center;
  font: 900 48px/1 "Arial Black", Arial, sans-serif; color: #fff;
  background: linear-gradient(135deg, #5b8cff, #7b5bff);
  box-shadow: var(--shadow);
}

/* ---------- экраны ---------- */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-shrink: 0;
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .sub.typing { color: var(--accent); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.pad { padding: 16px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; flex-shrink: 0;
  color: var(--text);
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.accent { background: var(--accent); color: var(--accent-text); }
.icon-btn.accent:hover { filter: brightness(1.08); }
.icon-btn.danger { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px; border-radius: 12px;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--panel-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--border); }
.btn.small { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-size: 13px; color: var(--muted); }
.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); outline: none; font-size: 16px;
}
.input:focus { border-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

/* ---------- вход ---------- */
.auth { flex: 1; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; padding: 24px; }
.auth .logo { margin: 0 auto 16px; }
.auth h2 { text-align: center; margin: 0 0 4px; }
.auth .lead { text-align: center; color: var(--muted); margin: 0 0 24px; }
.auth form { width: 100%; max-width: 380px; margin: 0 auto; }
.auth .switch { text-align: center; margin-top: 18px; color: var(--muted); }
.auth .switch button { color: var(--accent); font-weight: 600; }
.notice {
  background: var(--panel-2); border-radius: 12px; padding: 12px 14px;
  font-size: 14px; color: var(--muted); margin-bottom: 14px;
}

/* ---------- аватары ---------- */
.avatar {
  position: relative; flex-shrink: 0;
  width: var(--size, 48px); height: var(--size, 48px);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: calc(var(--size, 48px) * .4);
  background: var(--hue-bg, #888);
  user-select: none;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.saved { background: linear-gradient(135deg, #ffb347, #ff8a3d); }
.avatar.saved svg { width: 55%; height: 55%; }
.avatar .dot {
  position: absolute; right: 1px; bottom: 1px;
  width: 26%; height: 26%; min-width: 11px; min-height: 11px;
  border-radius: 50%; background: var(--ok); border: 2px solid var(--panel);
}

/* ---------- список чатов / людей ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; width: 100%; text-align: left;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.list-item:hover { background: var(--panel-2); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .top { display: flex; align-items: baseline; gap: 8px; }
.list-item .name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.list-item .bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.list-item .preview { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty .btn { margin-top: 14px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 18px 16px 8px; }
.search { padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }

.banner {
  margin: 10px 12px 0; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(91,140,255,.16), rgba(123,91,255,.16));
  display: flex; align-items: center; gap: 12px; font-size: 14px;
}
.banner .grow b { display: block; font-size: 15px; }
.banner > svg { width: 28px; height: 28px; color: var(--accent); }
.avatar > svg { width: 50%; height: 50%; }

/* ---------- чат ---------- */
.messages { padding: 12px 10px 6px; display: flex; flex-direction: column; gap: 3px; }
.day-sep { align-self: center; margin: 10px 0 6px; padding: 3px 10px; border-radius: 10px; font-size: 12px; color: var(--muted); background: var(--panel-2); }
.load-more { align-self: center; color: var(--muted); font-size: 13px; padding: 8px; }

.msg { display: flex; flex-direction: column; max-width: 82%; align-self: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.bubble {
  position: relative;
  background: var(--theirs); color: var(--theirs-text);
  border-radius: var(--radius); border-bottom-left-radius: 6px;
  padding: 7px 11px 6px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.msg.mine .bubble { background: var(--mine); color: var(--mine-text); border-bottom-left-radius: var(--radius); border-bottom-right-radius: 6px; }
.bubble .text { white-space: pre-wrap; }
.bubble .text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble .meta { display: inline-flex; gap: 4px; align-items: center; float: right; margin: 6px 0 -2px 10px; font-size: 11px; opacity: .72; }
.bubble .meta svg { width: 16px; height: 16px; }
.bubble .meta .read { color: #9fe8c9; opacity: 1; }
.msg:not(.mine) .bubble .meta .read { color: var(--ok); }
.bubble.media { padding: 4px; }
.bubble.media .meta { position: absolute; right: 10px; bottom: 8px; margin: 0; background: rgba(0,0,0,.45); color: #fff; padding: 1px 6px; border-radius: 8px; opacity: 1; }
.bubble.bare { background: none !important; box-shadow: none; padding: 0; }
.bubble.bare .meta { float: none; position: static; display: flex; justify-content: flex-end; color: var(--muted); background: none; margin-top: 2px; }
.bubble .photo { display: block; border-radius: 14px; max-height: 360px; min-width: 120px; min-height: 80px; object-fit: cover; background: var(--panel-2); }
.bubble.pending { opacity: .6; }
.bubble .reply {
  border-left: 3px solid currentColor; padding: 2px 8px; margin: 2px 0 6px;
  font-size: 13px; opacity: .85; border-radius: 4px;
}
.bubble .reply b { display: block; font-size: 12px; }
.sender-name { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.reaction {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 12px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--border);
}
.reaction.mine { border-color: var(--accent); background: rgba(91,140,255,.15); }

/* голосовые */
.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.voice .play { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.22); flex-shrink: 0; }
.msg:not(.mine) .voice .play { background: var(--accent); color: #fff; }
.voice .play svg { width: 22px; height: 22px; }
.voice .wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 32px; cursor: pointer; }
.voice .wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .35; }
.voice .wave i.on { opacity: 1; }
.voice .dur { font-size: 12px; opacity: .8; min-width: 34px; text-align: right; }

/* видео-кружки */
.circle {
  position: relative; width: 220px; height: 220px; border-radius: 50%; overflow: hidden;
  background: #000; box-shadow: var(--shadow);
}
.circle video { width: 100%; height: 100%; object-fit: cover; display: block; }
.circle .overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.18); }
.circle .overlay svg { width: 46px; height: 46px; filter: drop-shadow(0 1px 4px rgba(0,0,0,.5)); }
.circle .len { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 12px; background: rgba(0,0,0,.45); color: #fff; padding: 1px 8px; border-radius: 8px; }

/* стикеры */
.sticker { width: 160px; height: 160px; display: grid; place-items: center; }
.sticker img, .sticker video { width: 100%; height: 100%; object-fit: contain; }
.sticker > div { width: 100%; height: 100%; }

/* ---------- поле ввода ---------- */
.composer { background: var(--panel); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.composer .bar { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 40px;
  padding: 9px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--panel-2); outline: none; font-size: 16px; line-height: 1.35;
}
.composer textarea:focus { border-color: var(--accent); }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 6px 8px; font-size: 13px; }
.reply-bar .grow { border-left: 3px solid var(--accent); padding-left: 8px; }
.reply-bar b { color: var(--accent); display: block; }
.reply-bar span { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.recording { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.recording .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.recording .live { flex: 1; display: flex; align-items: center; gap: 2px; height: 32px; overflow: hidden; }
.recording .live i { width: 3px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.recording .timer { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 40px; }
@keyframes blink { 50% { opacity: .2; } }

.panel { height: 300px; display: flex; flex-direction: column; border-top: 1px solid var(--border); margin: 6px -8px 0; background: var(--panel); }
.panel .tabs { display: flex; gap: 4px; padding: 6px; overflow-x: auto; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.panel .tab { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.panel .tab.on { background: var(--panel-2); outline: 2px solid var(--accent); }
.panel .tab img { width: 36px; height: 36px; object-fit: contain; }
.panel .tab svg { width: 24px; height: 24px; }
.panel .grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; padding: 8px; align-content: start; }
.panel .grid button { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; }
.panel .grid button:hover { background: var(--panel-2); }
.panel .grid img { width: 100%; height: 100%; object-fit: contain; }
.panel .gifs { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.panel .gifs img { object-fit: cover; border-radius: 10px; }
.panel .inner { padding: 12px; overflow-y: auto; }

/* ---------- всплывающие окна ---------- */
.sheet-back { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 760px; background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  animation: up .18s ease-out;
}
.sheet .emojis { display: flex; justify-content: space-around; padding: 6px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.sheet .emojis button { font-size: 28px; width: 44px; height: 44px; border-radius: 50%; }
.sheet .emojis button:hover { background: var(--panel-2); }
.sheet .action { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 10px; border-radius: 12px; text-align: left; }
.sheet .action:hover { background: var(--panel-2); }
.sheet .action svg { width: 22px; height: 22px; color: var(--muted); }
.sheet .action.danger, .sheet .action.danger svg { color: var(--danger); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.fullscreen { position: absolute; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.fullscreen img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fullscreen .close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; color: #fff; }

.recorder { gap: 28px; }
.recorder .circle { width: min(78vw, 320px); height: min(78vw, 320px); }
.recorder .circle video { transform: scaleX(-1); }
.recorder .circle.back video { transform: none; }
.recorder .controls { display: flex; align-items: center; gap: 28px; }
.recorder .shutter { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.recorder .shutter i { width: 54px; height: 54px; border-radius: 50%; background: var(--danger); transition: all .2s; }
.recorder .shutter.on i { width: 28px; height: 28px; border-radius: 6px; }
.recorder .timer { color: #fff; font-variant-numeric: tabular-nums; font-size: 18px; }
.recorder .icon-btn { color: #fff; background: rgba(255,255,255,.12); width: 52px; height: 52px; }
.ring { position: absolute; inset: -6px; pointer-events: none; }

.toast {
  position: absolute; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(20,24,32,.92); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; z-index: 100; max-width: 90%; text-align: center; animation: fade .2s;
}

/* ---------- настройки ---------- */
.card { background: var(--panel); border-radius: 16px; margin: 0 12px 12px; padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.profile { display: flex; align-items: center; gap: 14px; }
.profile .avatar { cursor: pointer; }
.copy-box { display: flex; gap: 8px; align-items: center; background: var(--panel-2); border-radius: 12px; padding: 8px 8px 8px 12px; margin-bottom: 10px; }
.copy-box code { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.member:first-of-type { border-top: 0; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li { margin-bottom: 6px; }
.status-ok { color: var(--ok); font-weight: 600; }
.footer-note { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 0 24px; }

/* ==========================================================================
   Общая панель «Эмодзи · Стикеры · GIF»
   ========================================================================== */
.panel.picker { height: 340px; }
.picker-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.picker-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.picker-search { padding: 8px 8px 0; }
.picker-hint { grid-column: 1 / -1; padding: 12px; line-height: 1.5; }
.picker-bar { display: flex; justify-content: center; gap: 4px; padding: 6px; border-top: 1px solid var(--border); flex-shrink: 0; }
.picker-bar button { padding: 6px 16px; border-radius: 16px; font-size: 14px; color: var(--muted); font-weight: 600; }
.picker-bar button.on { background: var(--panel-2); color: var(--accent); }
.panel .gifs button { aspect-ratio: auto; height: 110px; overflow: hidden; }
.panel .gifs img, .panel .gifs video { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }

.emoji-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); padding: 4px 8px 8px; align-content: start; }
.emoji-title { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 4px 4px; }
.emoji { font-size: 26px; height: 42px; border-radius: 10px; line-height: 1; }
.emoji:hover { background: var(--panel-2); }

/* ==========================================================================
   Видео, файлы, скорость воспроизведения
   ========================================================================== */
.bubble .clip { background: #000; max-height: 420px; }
.file-card { display: flex; align-items: center; gap: 12px; min-width: 220px; max-width: 320px; padding: 4px 2px; color: inherit; text-decoration: none; }
.file-card .file-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: rgba(127,127,127,.18); flex-shrink: 0; }
.file-card .file-info { display: flex; flex-direction: column; min-width: 0; }
.file-card .file-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.file-card .file-info span { font-size: 12px; opacity: .75; }
.file-card:hover .file-info span { text-decoration: underline; }

.voice-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.speed { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; background: rgba(127,127,127,.22); color: inherit; min-width: 30px; }
.circle-wrap { position: relative; display: inline-block; }
.speed.on-circle { position: absolute; right: 6px; top: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 3px 8px; }

/* ==========================================================================
   Кнопка записи: удержание — запись, нажатие — голосовое ⇄ кружок
   ========================================================================== */
.rec-btn { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.recording .hold-hint { display: none; color: var(--muted); font-size: 13px; white-space: nowrap; }
.recording.holding .hold-hint { display: inline; }
.recording.holding .icon-btn { display: none; }
.rec-hint { color: #bbb; font-size: 13px; text-align: center; padding: 0 20px; }

/* ==========================================================================
   «Сделать GIF» из видео
   ========================================================================== */
.gifmaker { gap: 14px; padding: 16px; }
.gifmaker .gm-video { max-width: min(92%, 640px); max-height: 55%; border-radius: 12px; background: #000; }
.gm-panel { width: min(92%, 520px); background: var(--panel); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; color: var(--text); }
.gm-panel label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.gm-panel input[type=range] { flex: 1; accent-color: var(--accent); }
.gm-info { font-size: 13px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }

/* перетаскивание файлов в чат */
.chat-screen { position: relative; }
.drop-hint { display: none; position: absolute; inset: 10px; z-index: 40; border: 3px dashed var(--accent); border-radius: 18px; background: rgba(91,140,255,.12); color: var(--accent); font-size: 20px; font-weight: 700; place-items: center; pointer-events: none; }
.chat-screen.dragging .drop-hint { display: grid; }

.sheet a.action { color: inherit; text-decoration: none; }
.list-item.active { background: rgba(91,140,255,.14); }
.no-chat { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); text-align: center; padding: 24px; }
.no-chat .logo { margin-bottom: 12px; opacity: .9; }
.no-chat p { margin: 0; }

/* ==========================================================================
   Компьютер: две колонки, как в Telegram Desktop
   ========================================================================== */
@media (min-width: 900px) {
  html, body { background: var(--bg); }
  #app { max-width: 1440px; }
  #app.split { flex-direction: row; }
  #app.split > .side {
    width: 360px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0;
    border-right: 1px solid var(--border); background: var(--panel);
  }
  #app.split > .main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
  #app.split .side .list-item { border-bottom: 0; border-radius: 12px; margin: 2px 6px; width: calc(100% - 12px); }
  #app.split .side .banner { margin: 8px 8px 0; }
  #app.split .chat-screen .back-btn { display: none; }

  /* сообщения не растягиваются на всю ширину большого экрана */
  .messages { padding: 16px 6% 8px; }
  .msg { max-width: min(82%, 560px); }
  .composer { padding: 8px 6% 10px; }
  .composer .bar { gap: 6px; }

  /* панель эмодзи/стикеров/GIF — всплывающее окно над кнопкой, как в Telegram Desktop */
  .composer { position: relative; }
  .panel.picker {
    position: absolute; right: 6%; bottom: calc(100% + 6px); z-index: 30;
    width: 400px; height: 440px; margin: 0;
    border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,.28);
  }

  /* меню — окошком по центру, а не «шторкой» снизу */
  .sheet-back { align-items: center; }
  .sheet { max-width: 420px; border-radius: 18px; padding: 10px; }

  /* настройки и участники — аккуратной колонкой */
  #app.split > .main .card, #app.split > .main .search, #app.split > .main .list-item { max-width: 720px; margin-left: auto; margin-right: auto; }
  #app.split > .main .card { margin-bottom: 12px; }

  .auth form { max-width: 400px; }

  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: rgba(127,127,127,.35); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-track { background: transparent; }
}