/* Палитра «чернила и латунь»: спокойный фон переписки, свои сообщения — тёмно-синие,
   латунь — только для кода входа, непрочитанных и отметки «прочитано». */
:root {
  --wall: #e7ebef;
  --paper: #ffffff;
  --text: #15263d;
  --mist: #5b697a;
  --line: #d5dce3;
  --hover: #f1f4f7;
  --own: #1d3557;
  --own-text: #f3f6fa;
  --own-mist: #b4c3d6;
  --brass: #9a6514;
  --brass-ink: #ffffff;
  --brass-tint: #f6ecda;
  --tick-read: #e7b863;
  --online: #23784a;
  --danger: #b42318;
  --scrim: rgba(10, 16, 24, 0.5);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r-bubble: 18px;
  --r-tight: 6px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wall: #0e141a;
    --paper: #18212b;
    --text: #e3e9ef;
    --mist: #8d9bab;
    --line: #27323e;
    --hover: #1f2a36;
    --own: #2c4d7f;
    --own-text: #f1f5fa;
    --own-mist: #b3c4dc;
    --brass: #dba54b;
    --brass-ink: #1b1306;
    --brass-tint: #33291a;
    --tick-read: #f0c069;
    --online: #5cc28a;
    --danger: #ff8a80;
    --scrim: rgba(0, 0, 0, 0.6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--wall);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.noscript { padding: 24px; }

.ic {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 1px solid transparent; border-radius: 14px;
  background: transparent; font-weight: 600; font-size: 16px; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--own); color: var(--own-text); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { border-color: var(--line); background: var(--paper); }
.btn.ghost:hover { background: var(--hover); }
.btn.quiet { color: var(--mist); }
.btn.quiet:hover { color: var(--text); background: var(--hover); }
.btn.small { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: default; filter: none; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--mist);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.input {
  width: 100%; height: 50px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper); font-size: 16px;
}
.input:focus { outline: none; border-color: var(--own); box-shadow: 0 0 0 3px color-mix(in srgb, var(--own) 20%, transparent); }

/* ---------- экран входа ---------- */
.auth { position: fixed; inset: 0; overflow-y: auto; background: var(--paper); }
.auth-inner {
  width: min(420px, 100%); margin: 0 auto;
  padding: max(36px, 7vh) 24px calc(40px + env(safe-area-inset-bottom));
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; font-weight: 700; font-size: 18px; }
.auth h1 { margin: 0 0 8px; font-size: 30px; line-height: 1.12; letter-spacing: -0.015em; }
.lead { margin-bottom: 28px; color: var(--mist); }
.auth-form > h1:last-child { margin-bottom: 28px; }
.field { margin-bottom: 22px; }
.field > label, .label-row label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.label-row label { margin: 0; }
.hint { margin-top: 6px; font-size: 13px; color: var(--mist); }
.form-error { margin: -6px 0 16px; font-size: 14px; color: var(--danger); }
.form-error:empty { display: none; }
.notice { margin-bottom: 28px; padding: 12px 14px; border-radius: 12px; background: var(--brass-tint); font-size: 14px; }
.auth-foot { margin-top: 24px; font-size: 14px; color: var(--mist); }
.auth-foot .btn { margin-top: 10px; }
.auth code { font-family: var(--mono); font-size: 0.92em; background: var(--hover); padding: 2px 6px; border-radius: 6px; }

/* 6 ячеек кода. Настоящее поле лежит поверх них прозрачным — работает вставка и автозаполнение. */
.otp { position: relative; }
.otp-input {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%;
  border: 0; opacity: 0; font-size: 16px; caret-color: transparent;
}
.otp-cells { display: flex; gap: 8px; }
.otp-gap { flex: none; width: 10px; }
.otp-cell {
  flex: 1; height: 64px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper);
  font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.otp-cell.filled { border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.otp-cell.active { border-color: var(--brass); box-shadow: inset 0 -3px 0 var(--brass); }
.otp.error .otp-cell { border-color: var(--danger); }

.totp-timer { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mist); font-variant-numeric: tabular-nums; white-space: nowrap; }
.totp-timer svg { width: 18px; height: 18px; transform: rotate(-90deg); }
.totp-timer .track { fill: none; stroke: var(--line); stroke-width: 3; }
.totp-timer .fg { fill: none; stroke: var(--brass); stroke-width: 3; stroke-linecap: round; }
.totp-timer.soon .fg { stroke: var(--danger); }

.steps { margin: 0 0 24px; padding-left: 22px; }
.steps li { margin-bottom: 10px; padding-left: 4px; }
.steps li::marker { color: var(--brass); font-weight: 700; }
.qr-block {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  margin-bottom: 28px; padding: 20px; border: 1px solid var(--line); border-radius: 18px;
}
.add-app { margin-bottom: 14px; }
.qr { display: block; width: 216px; height: 216px; border-radius: 10px; }
.secret { width: 100%; text-align: center; }
.secret-label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--mist); }
.auth .secret-key {
  display: block; margin-bottom: 10px; padding: 8px 10px; border-radius: 10px;
  font-family: var(--mono); font-size: 15px; letter-spacing: 0.05em; word-break: break-all; user-select: all;
}
@media (hover: hover) and (pointer: fine) { .touch-only { display: none !important; } }

/* ---------- каркас приложения ---------- */
.app {
  position: fixed; left: 0; right: 0; top: var(--vv-top, 0px);
  height: var(--vv-h, 100dvh);
  display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); overflow: hidden;
}
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); border-right: 1px solid var(--line); }
.side-head {
  display: flex; align-items: center; gap: 8px; flex: none;
  height: calc(60px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-weight: 700; font-size: 19px; }
.brand img { border-radius: 8px; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { font-size: 13px; color: var(--danger); white-space: nowrap; }

.chat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.chat-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 14px; background: transparent; text-align: left;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: color-mix(in srgb, var(--own) 13%, var(--paper)); }
.ci-main { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.ci-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ci-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-time { flex: none; font-size: 12px; color: var(--mist); font-variant-numeric: tabular-nums; }
.ci-preview { flex: 1; min-width: 0; font-size: 14px; color: var(--mist); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--brass); color: var(--brass-ink);
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums;
}
.list-hint { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px 14px; font-size: 14px; color: var(--mist); }

/* ---------- аватары ---------- */
.avatar {
  position: relative; flex: none; display: grid; place-items: center;
  width: 50px; height: 50px; border-radius: 50%;
  color: #fff; font-size: 17px; font-weight: 600; letter-spacing: 0.02em; user-select: none;
}
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar.lg { width: 60px; height: 60px; font-size: 21px; }
.avatar.general { background: var(--own); color: var(--own-text); }
.avatar.general .ic { width: 26px; height: 26px; }
.avatar.sm.general .ic { width: 22px; height: 22px; }
.avatar .dot {
  position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--online); border: 2.5px solid var(--paper);
}
.avatar.sm .dot { width: 12px; height: 12px; border-width: 2px; }
.c0 { background: #3d6a8c; } .c1 { background: #7a4f86; } .c2 { background: #2f7466; } .c3 { background: #8c5a33; }
.c4 { background: #84405c; } .c5 { background: #4f6b2c; } .c6 { background: #3653a0; } .c7 { background: #8a4141; }
.t0 { color: #2f5f84; } .t1 { color: #74488a; } .t2 { color: #256b5d; } .t3 { color: #8a5426; }
.t4 { color: #8c3b5c; } .t5 { color: #4c6a22; } .t6 { color: #3450a8; } .t7 { color: #9a3a3a; }
@media (prefers-color-scheme: dark) {
  .t0 { color: #7fb0d6; } .t1 { color: #c39ad6; } .t2 { color: #6fc2ae; } .t3 { color: #e0a370; }
  .t4 { color: #e08aac; } .t5 { color: #a6c76e; } .t6 { color: #93a8f0; } .t7 { color: #ef8f8f; }
}

/* ---------- переписка ---------- */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--wall); }
.chat-empty { flex: 1; display: grid; place-items: center; padding: 24px; color: var(--mist); text-align: center; }
.chat-head {
  display: flex; align-items: center; gap: 12px; flex: none;
  height: calc(60px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 16px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.back { display: none; margin-left: -10px; margin-right: -6px; color: var(--text); }
.chat-title { flex: 1; min-width: 0; }
.chat-name { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { font-size: 13px; color: var(--mist); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status.online { color: var(--online); }

.messages { position: relative; flex: 1; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; padding: 8px 14px 14px; }
.msg-list { width: 100%; max-width: 760px; margin: auto auto 0; display: flex; flex-direction: column; }
.day { align-self: center; margin: 16px 0 6px; }
.day span {
  display: inline-block; padding: 4px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 75%, transparent);
  font-size: 13px; font-weight: 600; color: var(--mist);
}
.chat-note { align-self: center; margin: 10px 0 2px; font-size: 13px; color: var(--mist); text-align: center; }
.chat-blank { align-self: center; margin: 32px 0; max-width: 300px; text-align: center; color: var(--mist); }
.chat-blank strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 17px; }

.row { display: flex; margin-top: 8px; }
.row.cont { margin-top: 2px; }
.row.own { justify-content: flex-end; }
.row.enter { animation: rise 0.18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bubble {
  position: relative; max-width: min(78%, 560px);
  padding: 7px 12px; border-radius: var(--r-bubble);
  background: var(--paper); overflow-wrap: anywhere;
}
.row.own .bubble { background: var(--own); color: var(--own-text); }
.row.other.cont .bubble { border-top-left-radius: var(--r-tight); }
.row.other.has-next .bubble { border-bottom-left-radius: var(--r-tight); }
.row.own.cont .bubble { border-top-right-radius: var(--r-tight); }
.row.own.has-next .bubble { border-bottom-right-radius: var(--r-tight); }
.row.sending .bubble { opacity: 0.72; }

.author { margin-bottom: 1px; font-size: 13px; font-weight: 700; }
.text { white-space: pre-wrap; }
.text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* Невидимый «хвост» резервирует место под время в последней строке */
.meta-space { display: inline-block; width: 44px; height: 1px; }
.meta-space.own { width: 60px; }
.meta {
  position: absolute; right: 11px; bottom: 6px;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; line-height: 1; color: var(--mist); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.row.own .meta { color: var(--own-mist); }
.tick { width: 17px; height: 17px; stroke-width: 2.2; }
.tick.read { color: var(--tick-read); }

.bubble.has-media { padding: 3px; }
.bubble.has-media .author { padding: 4px 9px 3px; }
.bubble.has-media .text { padding: 5px 9px 5px; }
.bubble.has-media { width: min-content; }
.media {
  position: relative; max-width: 100%; width: 280px; overflow: hidden;
  border-radius: 15px; background: color-mix(in srgb, var(--mist) 22%, transparent);
}
.bubble.has-media:not(.media-only) .media { border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }
.media img, .media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.media:not(.sized) img { height: auto; }
.media.image { cursor: zoom-in; -webkit-touch-callout: none; }
.media.video video { background: #000; object-fit: contain; }
.media.broken { display: grid; place-items: center; aspect-ratio: auto !important; width: 240px; min-height: 0; }
.file-fallback { display: flex; align-items: center; gap: 10px; width: 100%; padding: 16px; font-weight: 600; text-decoration: none; }
.bubble.media-only .meta {
  right: 10px; bottom: 10px; padding: 4px 7px; border-radius: 10px;
  background: rgba(8, 14, 22, 0.55); color: #fff;
}
.bubble.media-only.video-msg .meta { top: 10px; bottom: auto; }
.row.own .bubble.media-only .meta { color: #fff; }

/* загрузка файла */
.media.uploading { width: 220px; aspect-ratio: 4 / 3; }
.up-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(8, 14, 22, 0.45); color: #fff;
}
.up-cancel { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.5); color: #fff; }
.up-track { width: 62%; height: 4px; overflow: hidden; border-radius: 2px; background: rgba(255, 255, 255, 0.3); }
.up-bar { display: block; width: 0; height: 100%; background: #fff; transition: width 0.2s; }
.up-label { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.to-bottom {
  position: sticky; bottom: 4px; align-self: flex-end; flex: none; margin: -46px 0 0;
  display: grid; place-items: center; width: 46px; height: 46px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--mist);
  box-shadow: 0 4px 14px rgba(10, 20, 30, 0.12);
}

.drop-zone {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; margin: 10px;
  border: 2px dashed var(--brass); border-radius: 18px; pointer-events: none;
  background: color-mix(in srgb, var(--wall) 88%, transparent); font-weight: 600;
}

/* ---------- поле ввода ---------- */
.tray {
  display: flex; align-items: center; gap: 8px; flex: none; overflow-x: auto;
  padding: 10px 12px 2px; background: var(--paper); border-top: 1px solid var(--line);
}
.tray-item { position: relative; flex: none; width: 66px; height: 66px; overflow: hidden; border-radius: 12px; background: var(--wall); }
.tray-item img, .tray-item video { display: block; width: 100%; height: 100%; object-fit: cover; }
.tray-badge { position: absolute; left: 4px; bottom: 4px; padding: 1px 5px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11px; font-weight: 700; }
.tray-remove {
  position: absolute; top: 3px; right: 3px; display: grid; place-items: center;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.62); color: #fff;
}
.tray-remove .ic { width: 14px; height: 14px; stroke-width: 2.6; }
.tray-hint { flex: none; padding-left: 4px; font-size: 13px; color: var(--mist); white-space: nowrap; }

.composer {
  display: flex; align-items: flex-end; gap: 6px; flex: none;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line);
}
.tray:not([hidden]) + .composer { border-top: 0; }
.composer textarea {
  flex: 1; min-width: 0; height: 42px; max-height: 160px; padding: 9px 15px; resize: none;
  border: 1px solid var(--line); border-radius: 21px; background: var(--wall);
  font-size: 16px; line-height: 1.35; outline: none;
}
.composer textarea:focus { border-color: color-mix(in srgb, var(--own) 45%, var(--line)); }
.composer .attach { width: 42px; height: 42px; }
.send-btn {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; padding: 0;
  border: 0; border-radius: 50%; background: var(--own); color: var(--own-text);
}
.send-btn .ic { width: 22px; height: 22px; stroke-width: 2.4; }
.send-btn:hover { filter: brightness(1.15); }

/* ---------- меню, диалоги, всплывающие ---------- */
dialog { padding: 0; border: 0; color: var(--text); }
.sheet {
  width: min(440px, calc(100vw - 24px)); max-height: min(680px, calc(100dvh - 48px));
  border-radius: 22px; background: var(--paper); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop { background: var(--scrim); }
.sheet-head { display: flex; align-items: center; gap: 4px; flex: none; padding: 14px 10px 6px 22px; }
.sheet-head.with-back { padding-left: 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; }
.sheet-body { overflow-y: auto; padding: 6px 22px 22px; }
.sheet-body > p + p, .sheet-body > p + .link-box, .sheet-body > .link-box + p { margin-top: 12px; }
.muted { color: var(--mist); }
.profile { display: flex; align-items: center; gap: 14px; padding: 6px 0 18px; border-bottom: 1px solid var(--line); }
.profile-name { font-size: 18px; font-weight: 700; }
.profile-sub { font-size: 14px; color: var(--mist); }
.menu-list { display: flex; flex-direction: column; padding-top: 8px; }
.menu-row {
  display: flex; align-items: center; gap: 14px; width: calc(100% + 16px); margin: 0 -8px; padding: 12px 8px;
  border: 0; border-radius: 12px; background: transparent; color: var(--text); text-align: left;
}
.menu-row:hover { background: var(--hover); }
.menu-row .ic { color: var(--mist); }
.mr-text { display: flex; flex-direction: column; }
.mr-title { font-weight: 600; }
.mr-sub { font-size: 13px; color: var(--mist); }
.link-box { display: flex; flex-direction: column; gap: 10px; }
.link-box .input { font-size: 14px; height: 46px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.user-list { display: flex; flex-direction: column; }
.user-item + .user-item { border-top: 1px solid var(--line); }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.user-row.off .avatar { filter: grayscale(1); opacity: 0.55; }
.ur-text { flex: 1; min-width: 0; }
.ur-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ur-sub { font-size: 13px; color: var(--mist); }
.ur-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.ur-slot:not(:empty) { padding: 0 0 14px; }
.ur-slot .hint { margin: 0 0 10px; }

.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0;
  background: #05080c; color: #fff;
}
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: transparent; }
.lb-bar { display: flex; align-items: center; gap: 4px; flex: none; padding: calc(8px + env(safe-area-inset-top)) 8px 8px 18px; }
.lb-info { flex: 1; min-width: 0; font-size: 14px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.lb-stage { position: relative; flex: 1; min-height: 0; }
.lb-stage img { position: absolute; inset: 0; margin: auto; max-width: calc(100% - 16px); max-height: calc(100% - 16px); }
.lb-caption { flex: none; padding: 12px 20px calc(18px + env(safe-area-inset-bottom)); text-align: center; white-space: pre-wrap; }

.msg-menu {
  position: fixed; z-index: 50; min-width: 210px; padding: 6px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--paper);
  box-shadow: 0 12px 32px rgba(8, 18, 30, 0.2);
}
.msg-menu .mm-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  font-size: 15px; text-decoration: none; text-align: left;
}
.msg-menu .mm-item:hover { background: var(--hover); }
.msg-menu .mm-item .ic { width: 20px; height: 20px; color: var(--mist); }
.msg-menu .mm-item.danger, .msg-menu .mm-item.danger .ic { color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); width: max-content; max-width: min(92vw, 440px);
  padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--paper);
  font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; }
  .chat { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .chat { display: flex; }
  .back { display: inline-grid; }
  .messages { padding: 6px 8px 12px; }
  .bubble { max-width: 86%; }
  .sheet {
    width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 90dvh;
    border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom);
  }
}
@media (pointer: coarse) {
  .bubble { -webkit-user-select: none; user-select: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
