/* ===== Тема: цвета RideChat — чёрный, фирменный жёлтый, белый ===== */
:root {
  --accent: #f5b203;            /* фирменный жёлтый: кнопки, значки, переключатели */
  --accent-strong: #e0a000;     /* он же при нажатии */
  --accent-ink: #8a5f00;        /* жёлтый для текста и значков на светлом фоне (читается, в отличие от яркого) */
  --accent-soft: rgba(245, 178, 3, 0.16);
  --on-accent: #151515;         /* цвет текста на жёлтом */
  --bg: #ffffff;
  --bg-2: #f4f4f4;
  --surface: #ffffff;
  --text: #151515;
  --text-2: #6b6b6b;
  --border: #e6e6e6;
  --header-bg: #151515;
  --header-text: #ffffff;
  --header-sub: rgba(255, 255, 255, 0.7);
  --header-accent: #f5b203;
  --chat-bg: #ececec;
  --bubble-in: #ffffff;
  --bubble-in-text: #151515;
  --bubble-out: #151515;
  --bubble-out-text: #ffffff;
  --meta-in: #8b8b8b;
  --meta-out: rgba(255, 255, 255, 0.66);
  --tick-read: #f5b203;
  /* детали внутри исходящего пузыря: подложки, линии, акценты */
  --out-tint: rgba(255, 255, 255, 0.16);
  --out-line: rgba(255, 255, 255, 0.85);
  --out-strong: #ffffff;
  --out-fail: #ffb4ab;
  --danger: #e5484d;
  --ok: #2fb67c;
  --overlay: rgba(10, 10, 10, 0.5);
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-strong: #ffc83d;
    --accent-ink: #f5b203;
    --bg: #101010;
    --bg-2: #181818;
    --surface: #1a1a1a;
    --text: #ededed;
    --text-2: #9a9a9a;
    --border: #2a2a2a;
    --chat-bg: #0b0b0b;
    --bubble-in: #202020;
    --bubble-in-text: #ededed;
    --bubble-out: #e3a500;
    --bubble-out-text: #151515;
    --meta-in: #858585;
    --meta-out: rgba(21, 21, 21, 0.62);
    --tick-read: #151515;
    --out-tint: rgba(21, 21, 21, 0.14);
    --out-line: rgba(21, 21, 21, 0.7);
    --out-strong: #151515;
    --out-fail: #8c1d18;
    --overlay: rgba(0, 0, 0, 0.62);
    --shadow: 0 4px 22px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-strong: #ffc83d;
  --accent-ink: #f5b203;
  --bg: #101010;
  --bg-2: #181818;
  --surface: #1a1a1a;
  --text: #ededed;
  --text-2: #9a9a9a;
  --border: #2a2a2a;
  --chat-bg: #0b0b0b;
  --bubble-in: #202020;
  --bubble-in-text: #ededed;
  --bubble-out: #e3a500;
  --bubble-out-text: #151515;
  --meta-in: #858585;
  --meta-out: rgba(21, 21, 21, 0.62);
  --tick-read: #151515;
  --out-tint: rgba(21, 21, 21, 0.14);
  --out-line: rgba(21, 21, 21, 0.7);
  --out-strong: #151515;
  --out-fail: #8c1d18;
  --overlay: rgba(0, 0, 0, 0.62);
  --shadow: 0 4px 22px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ===== База ===== */
* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: pan-x pan-y; }
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  -webkit-touch-callout: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-user-select: none; user-select: none; touch-action: pan-x pan-y; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
svg { display: block; }

#splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: #151515;
  transition: opacity .25s ease;
}
#splash img { width: 96px; height: auto; }
#splash.hide { opacity: 0; pointer-events: none; }

#app {
  position: fixed;
  left: 0; right: 0; top: 0; bottom: 0;
  top: var(--vv-top, 0px);
  height: var(--vv-h, auto);
  display: flex;
  background: var(--bg);
}
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
#sidebar { width: 100%; background: var(--bg); }
#main { width: 100%; background: var(--chat-bg); }
#app[data-pane="list"] #main { display: none; }
#app[data-pane="main"] #sidebar { display: none; }

@media (min-width: 860px) {
  #sidebar { width: 360px; flex: none; border-right: 1px solid var(--border); }
  #main { flex: 1; }
  #app[data-pane="list"] #main, #app[data-pane="main"] #sidebar { display: flex; }
  .only-mobile { display: none !important; }
}

.view { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* ===== Шапка ===== */
.bar {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 6px 0 6px;
  background: var(--header-bg);
  color: var(--header-text);
  position: relative; z-index: 5;
}
.bar .title { flex: 1; min-width: 0; padding: 0 8px; }
.bar .title h1 { margin: 0; font-size: 19px; font-weight: 650; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .title .sub { font-size: 13px; color: var(--header-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .title .sub.typing, .bar .title .sub.online { color: var(--header-accent); }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: inherit;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.16); }
.icon-btn svg { width: 24px; height: 24px; }
.bar-title-btn { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; color: inherit; padding: 4px 6px; border-radius: 12px; }
.bar-title-btn .t { font-size: 17px; font-weight: 650; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title-btn .s { font-size: 13px; color: var(--header-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title-btn .s.online, .bar-title-btn .s.typing { color: var(--header-accent); }
.bar-title-btn > div { min-width: 0; }

/* ===== Аватар ===== */
.avatar {
  --size: 52px;
  position: relative; flex: none;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, hsl(var(--hue, 240) 68% 64%), hsl(var(--hue, 240) 68% 46%));
  color: #fff;
  font-weight: 650;
  font-size: calc(var(--size) * 0.38);
  -webkit-user-select: none; user-select: none;
}
.avatar.sm { --size: 34px; }
.avatar.md { --size: 40px; }
.avatar.lg { --size: 96px; }
.avatar .dot {
  position: absolute; right: 0; bottom: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ok); border: 2.5px solid var(--bg);
}
.avatar.saved { background: linear-gradient(135deg, #ffd24d, #e0a000); color: #151515; }
.avatar svg { width: 54%; height: 54%; }

/* ===== Список чатов ===== */
.search-box { padding: 8px 12px; background: var(--bg); position: sticky; top: 0; z-index: 2; }
.search-box .field {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border-radius: 12px; padding: 0 12px; height: 38px; color: var(--text-2);
}
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; color: var(--text); }
.search-box svg { width: 18px; height: 18px; flex: none; }

.chat-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 8px 14px; text-align: left;
  background: var(--bg);
}
.chat-item:active { background: var(--bg-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item .main { flex: 1; min-width: 0; }
.chat-item .row { display: flex; align-items: baseline; gap: 8px; }
.chat-item .name { flex: 1; min-width: 0; font-weight: 600; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .time { flex: none; font-size: 12.5px; color: var(--text-2); }
.chat-item .row.second { margin-top: 2px; align-items: center; }
.chat-item .preview { flex: 1; min-width: 0; font-size: 15px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .preview .who { color: var(--text); }
.chat-item .preview.typing { color: var(--accent-ink); }
.badge {
  flex: none; min-width: 21px; height: 21px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: 12.5px; font-weight: 650;
}
.badge.muted { background: var(--text-2); color: #fff; opacity: .75; }
.mute-ic { width: 14px; height: 14px; color: var(--text-2); flex: none; }
.empty { padding: 56px 28px; text-align: center; color: var(--text-2); }
.empty h3 { margin: 12px 0 6px; color: var(--text); font-size: 18px; }
.empty p { margin: 0 auto; max-width: 320px; font-size: 15px; }
.empty svg { width: 56px; height: 56px; margin: 0 auto; color: var(--accent-ink); opacity: .85; }
.section-title { padding: 14px 16px 6px; font-size: 13px; font-weight: 650; color: var(--accent-ink); text-transform: uppercase; letter-spacing: .04em; }

.fab {
  position: absolute; right: 18px; bottom: calc(18px + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; z-index: 4;
}
.fab:active { transform: scale(.96); }
.fab svg { width: 26px; height: 26px; }

.banner {
  margin: 10px 12px 2px; padding: 12px 14px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent-soft);
  display: flex; gap: 12px; align-items: center;
}
.banner .txt { flex: 1; font-size: 14.5px; line-height: 1.35; }
.banner .txt b { display: block; font-size: 15px; margin-bottom: 2px; }
.banner .btn { flex: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 15px;
}
.btn:active { background: var(--accent-strong); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: none; color: var(--accent-ink); }
.btn.block { width: 100%; min-height: 46px; font-size: 16px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ===== Чат ===== */
.chat-view { background: var(--chat-bg); }
.messages {
  padding: 8px 10px 6px;
  background-color: var(--chat-bg);
  background-image: var(--wall-pattern, none), var(--wall-bg, none);
  background-size: 180px 180px, cover;
  background-attachment: local, local;
}
.messages .inner { display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
.day-sep, .sys-msg, .unread-sep { align-self: center; margin: 10px 0 6px; }
.day-sep span, .sys-msg span {
  display: inline-block; padding: 3px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.42); color: #fff; font-size: 13px; font-weight: 500; text-align: center;
}
:root[data-theme="dark"] .day-sep span, :root[data-theme="dark"] .sys-msg span { background: rgba(255, 255, 255, 0.12); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .day-sep span, :root:not([data-theme="light"]) .sys-msg span { background: rgba(255, 255, 255, 0.12); }
}
.sys-msg { max-width: 90%; }
.unread-sep { align-self: stretch; text-align: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 600; padding: 5px 0; margin: 8px -10px; }

.msg { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; max-width: 100%; }
.msg.out { justify-content: flex-end; }
.msg.first { margin-top: 8px; }
.msg .av-slot { width: 34px; flex: none; }
.bubble {
  position: relative; max-width: min(82%, 520px); min-width: 56px;
  padding: 6px 10px 6px 10px;
  border-radius: var(--radius);
  background: var(--bubble-in); color: var(--bubble-in-text);
  box-shadow: 0 1px 1px rgba(20, 24, 40, 0.08);
  overflow-wrap: anywhere;
  -webkit-touch-callout: none;
}
.msg.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); }
.msg.in.last .bubble { border-bottom-left-radius: 6px; }
.msg.out.last .bubble { border-bottom-right-radius: 6px; }
.msg.in:not(.first) .bubble { border-top-left-radius: 6px; }
.msg.out:not(.first) .bubble { border-top-right-radius: 6px; }
.bubble.sel { outline: 2px solid var(--accent-ink); outline-offset: 1px; }
@media (pointer: coarse) { .bubble { -webkit-user-select: none; user-select: none; } }
.bubble .sender { font-size: 13.5px; font-weight: 650; margin-bottom: 1px; cursor: pointer; }
.bubble .text { white-space: pre-wrap; word-break: break-word; font-size: 16px; line-height: 1.32; }
.bubble .text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg.in .bubble .text a { color: var(--accent-ink); }
.bubble .meta {
  float: right; margin: 7px 0 -3px 12px;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; color: var(--meta-in); line-height: 1; height: 14px;
}
.msg.out .bubble .meta { color: var(--meta-out); }
.bubble .meta svg { width: 16px; height: 16px; }
.bubble .meta .read { color: var(--tick-read); }
.bubble .meta .failed { color: var(--out-fail); }
.bubble::after { content: ''; display: block; clear: both; }
.bubble .reply-quote {
  display: block; width: 100%; text-align: left; margin: 2px 0 5px;
  padding: 3px 8px; border-left: 3px solid var(--accent); border-radius: 4px;
  background: var(--accent-soft); font-size: 14px; line-height: 1.25; color: inherit;
}
.msg.out .bubble .reply-quote { border-left-color: var(--out-line); background: var(--out-tint); }
.reply-quote .rq-name { display: block; font-weight: 650; color: var(--accent-ink); font-size: 13.5px; }
.msg.out .reply-quote .rq-name { color: var(--out-strong); }
.reply-quote .rq-text { display: block; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble .photo { display: block; margin: -2px -6px 4px; border-radius: 14px; overflow: hidden; cursor: zoom-in; background: rgba(120, 128, 150, 0.25); max-width: 340px; }
.bubble .photo img { display: block; width: 100%; height: auto; }
.bubble.photo-only { padding: 3px; }
.bubble.photo-only .photo { margin: 0; }
.bubble.photo-only .meta {
  position: absolute; right: 9px; bottom: 8px; float: none; margin: 0;
  background: rgba(15, 18, 28, 0.55); color: #fff; padding: 3px 7px; border-radius: 10px; height: auto;
}
.bubble.photo-only .meta .read { color: #f5b203; }
.msg.out .bubble.photo-only .meta { color: #fff; }
.bubble.photo-only::after { display: none; }
.file-card { display: flex; align-items: center; gap: 10px; padding: 2px 2px 4px; color: inherit; text-decoration: none; min-width: 190px; }
.file-card .fi {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center;
}
.msg.out .file-card .fi { background: var(--out-tint); color: var(--out-strong); }
.file-card .fi svg { width: 22px; height: 22px; }
.file-card .fn { font-weight: 600; font-size: 15px; word-break: break-all; line-height: 1.2; }
.file-card .fs { font-size: 12.5px; opacity: .75; }
.progress { height: 3px; border-radius: 2px; background: var(--out-tint); margin-top: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--out-strong); width: 0; transition: width .2s; }

.to-bottom {
  position: absolute; right: 12px; bottom: 12px; z-index: 6;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); color: var(--text-2); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.to-bottom svg { width: 22px; height: 22px; }
.to-bottom .badge { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); }
.typing-dots span { display: inline-block; width: 4px; height: 4px; margin-right: 2px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ===== Поле ввода ===== */
.composer-wrap { position: relative; flex: none; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: 0; }
body.kb .composer, body.kb .rec-bar { padding-bottom: 6px; }
html, body { background: var(--surface); }
#main { background: var(--chat-bg); }
.ctx-bar { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--border); }
.ctx-bar .ic { color: var(--accent-ink); }
.ctx-bar .ic svg { width: 22px; height: 22px; }
.ctx-bar .body { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; }
.ctx-bar .b1 { font-size: 13.5px; font-weight: 650; color: var(--accent-ink); }
.ctx-bar .b2 { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-bar .icon-btn { color: var(--text-2); width: 38px; height: 38px; }
.ctx-bar .icon-btn:active { background: var(--bg-2); }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 6px 6px 4px 4px; }
.composer .icon-btn { color: var(--text-2); }
.composer .icon-btn:active { background: var(--bg-2); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0;
  background: var(--bg-2); border-radius: 20px; padding: 10px 14px;
  font-size: 16px; line-height: 1.3; max-height: 140px; min-height: 40px;
  -webkit-appearance: none; appearance: none;
}
.composer textarea::placeholder { color: var(--text-2); }
.send-btn {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center;
}
.send-btn svg { width: 22px; height: 22px; }
.send-btn[disabled] { background: var(--bg-2); color: var(--text-2); }

/* ===== Страницы: новый чат, профиль, настройки ===== */
.page { background: var(--bg); }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; text-align: left; background: var(--bg); }
.list-row:active { background: var(--bg-2); }
.list-row .main { flex: 1; min-width: 0; }
.list-row .t { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .s { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .ico { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; flex: none; }
.list-row .ico svg { width: 22px; height: 22px; }
.list-row .check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: flex; align-items: center; justify-content: center; color: var(--on-accent); }
.list-row.selected .check { background: var(--accent); border-color: var(--accent); }
.list-row .check svg { width: 16px; height: 16px; opacity: 0; }
.list-row.selected .check svg { opacity: 1; }
.list-row.danger .t { color: var(--danger); }
.list-row .right { color: var(--text-2); font-size: 14px; flex: none; }
.divider { height: 8px; background: var(--bg-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-radius: 16px; background: var(--accent-soft); font-size: 14px; }
.chip .avatar { --size: 24px; font-size: 10px; }
.chip button { color: var(--text-2); width: 18px; height: 18px; }
.profile-head { display: flex; flex-direction: column; align-items: center; padding: 22px 16px 16px; gap: 6px; text-align: center; }
.profile-head h2 { margin: 8px 0 0; font-size: 22px; }
.profile-head .sub { color: var(--text-2); font-size: 15px; }
.form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.field-label { font-size: 13px; color: var(--text-2); margin: 0 0 4px 2px; }
.input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 12px; font-size: 16px;
  border: 1.5px solid var(--border); background: var(--bg); outline: 0;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--accent); }
.hint { font-size: 13px; color: var(--text-2); margin: 2px 4px 0; line-height: 1.35; }
.error-text { color: var(--danger); font-size: 14px; min-height: 18px; margin: 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; border-radius: 15px; background: var(--border); transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.seg { display: flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 34px; border-radius: 8px; font-size: 14.5px; color: var(--text-2); font-weight: 600; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

/* ===== Вход ===== */
.auth-screen {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #151515;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  display: flex; flex-direction: column; align-items: center;
}
.auth-screen h1.brand { margin: 5vh 0 12px; line-height: 0; }
.auth-screen .brand img { display: block; width: min(230px, 62vw); height: auto; }
.auth-screen .brand-mark { display: block; margin-top: 6vh; width: 84px; height: auto; }
.auth-screen h1 { color: #fff; margin: 16px 0 4px; font-size: 30px; letter-spacing: -.01em; }
.auth-screen .tag { color: rgba(255, 255, 255, .82); margin: 0 0 22px; font-size: 16px; text-align: center; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); color: var(--text); border-radius: 22px; padding: 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .07); }
.auth-card .seg { margin-bottom: 14px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }

/* ===== Окна, листы, тосты ===== */
#overlay-root { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); bottom: 0; height: var(--vv-h, auto); z-index: 900; pointer-events: none; }
#overlay-root > * { pointer-events: auto; }
.backdrop { position: absolute; inset: 0; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.backdrop.center { align-items: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet {
  width: 100%; max-width: 520px; max-height: 86%; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 8px 0 calc(var(--safe-bottom) + 8px); animation: rise .2s ease;
}
.sheet .grab { width: 38px; height: 4px; background: var(--border); border-radius: 2px; margin: 4px auto 8px; }
.sheet .sheet-title { padding: 4px 18px 8px; color: var(--text-2); font-size: 14px; }
.sheet .item { display: flex; align-items: center; gap: 16px; width: 100%; padding: 13px 20px; text-align: left; font-size: 17px; }
.sheet .item:active { background: var(--bg-2); }
.sheet .item svg { width: 22px; height: 22px; color: var(--text-2); }
.sheet .item.danger, .sheet .item.danger svg { color: var(--danger); }
.dialog { width: 100%; max-width: 340px; background: var(--surface); border-radius: 18px; padding: 20px 20px 12px; animation: rise .18s ease; }
.dialog h3 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 14px; color: var(--text-2); font-size: 15px; line-height: 1.4; white-space: pre-line; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 4px; }
.dialog .actions .btn { background: none; color: var(--accent-ink); }
.dialog .actions .btn.danger { color: var(--danger); background: none; }
.dialog .steps { margin: 0 0 12px; padding-left: 20px; font-size: 15.5px; line-height: 1.5; }
.dialog .steps li { margin-bottom: 6px; }
.dialog .steps svg { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; color: var(--accent-ink); }

.toasts { position: absolute; left: 0; right: 0; top: calc(var(--safe-top) + 8px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast {
  pointer-events: auto; max-width: 480px; width: 100%;
  background: rgba(24, 24, 24, .94); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 15px;
  box-shadow: var(--shadow); animation: drop .22s ease; text-align: left;
}
.toast.msg-toast { display: flex; gap: 10px; align-items: center; }
.toast .tt { font-weight: 650; font-size: 14.5px; }
.toast .tb { opacity: .85; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast .tcol { min-width: 0; flex: 1; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

.viewer { position: absolute; inset: 0; background: rgba(0, 0, 0, .94); display: flex; align-items: center; justify-content: center; animation: fade .15s ease; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close { position: absolute; top: calc(var(--safe-top) + 8px); right: 8px; color: #fff; }
.viewer .close:active { background: rgba(255, 255, 255, .16); }
.viewer .dl { position: absolute; bottom: calc(var(--safe-bottom) + 14px); left: 50%; transform: translateX(-50%); background: rgba(255, 255, 255, .16); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 15px; text-decoration: none; }

.offline-strip { background: #c7652a; color: #fff; text-align: center; font-size: 13px; padding: 4px 8px; flex: none; }
.update-strip { background: var(--accent); color: var(--on-accent); text-align: center; font-size: 14px; padding: 8px 12px; flex: none; width: 100%; }
.placeholder-main { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.placeholder-main span { background: rgba(0, 0, 0, .4); color: #fff; padding: 5px 14px; border-radius: 14px; font-size: 14px; }

/* ===== Дополнения ===== */
.msg-area { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.msg-area .scroll { flex: 1; }
.msg-loading { margin: auto; padding: 24px; text-align: center; color: var(--text-2); font-size: 15px; }
.msg-loading > div { margin-bottom: 4px; }
.msg.flash .bubble { animation: flash 1.3s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent-ink); } 100% { box-shadow: 0 1px 1px rgba(20, 24, 40, 0.08); } }
.msg.in .bubble .sender { color: hsl(var(--hue, 240) 55% 40%); }
:root[data-theme="dark"] .msg.in .bubble .sender { color: hsl(var(--hue, 240) 75% 72%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .msg.in .bubble .sender { color: hsl(var(--hue, 240) 75% 72%); }
}
.bubble .photo { max-height: 420px; max-width: calc(100% + 12px); }
.bubble.photo-only .photo { max-width: 100%; }
.bubble .photo img { height: 100%; object-fit: cover; }
.bubble.pending .photo img { opacity: .72; }
.bubble .fail-note { font-size: 12.5px; color: var(--out-fail); margin-top: 3px; }
.msg.in .bubble .fail-note { color: var(--danger); }
.bubble .file-card { margin-bottom: 0; }

.hint.pad { padding: 12px 16px; }
.hint.center { text-align: center; padding: 18px 16px 28px; }
.form.tight { padding-top: 8px; padding-bottom: 8px; }
.list-row .s.wrap { white-space: normal; }
.list-row[disabled] { opacity: .6; pointer-events: none; }
.bar .text-btn { flex: none; height: 44px; padding: 0 14px; color: inherit; font-weight: 650; font-size: 16px; border-radius: 12px; }
.bar .text-btn:active { background: rgba(255, 255, 255, 0.16); }
.bar .text-btn[disabled] { opacity: .5; pointer-events: none; }
.sheet.tall { height: 72%; display: flex; flex-direction: column; }
.sheet.tall .picker-list { flex: 1; min-height: 0; overflow-y: auto; }
.sheet .search-box { position: static; }
.update-strip.float { position: absolute; left: 0; right: 0; top: 0; z-index: 5; padding-top: calc(var(--safe-top) + 10px); padding-bottom: 10px; }
.auth-screen .install-link { margin-top: 18px; color: rgba(255, 255, 255, .92); font-size: 14.5px; text-decoration: underline; text-underline-offset: 3px; text-align: center; padding: 6px 10px; }
.auth-screen .btn.light { background: #fff; color: #151515; }
.auth-card .hint { margin: 0 2px; }
.auth-card .error-text { min-height: 0; }
.auth-card .error-text:empty { display: none; }
.bubble.photo-only { padding: 0; background: transparent; box-shadow: none; overflow: hidden; }
.bubble.photo-only .photo { border-radius: 0; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.block svg { width: 20px; height: 20px; }
.messages { overflow-anchor: none; }

/* ===== Логотип ===== */
.bar .bar-logo { width: 26px; height: auto; flex: none; margin-left: 10px; }

/* ===== Голосовые сообщения ===== */
.mic-btn { background: var(--bg-2); color: var(--text-2); }
.mic-btn:active { background: var(--accent); color: var(--on-accent); }
.rec-bar { display: flex; align-items: center; gap: 10px; padding: 6px 6px 4px 4px; min-height: 52px; }
.rec-bar .rec-cancel { color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; flex: none; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 44px; }
.rec-hint { flex: 1; color: var(--text-2); font-size: 14.5px; }
.bubble.voice-bubble { min-width: 230px; }
.voice { display: flex; align-items: center; gap: 10px; padding: 2px 0 4px; }
.voice .vplay {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center;
}
.voice .vplay svg { width: 20px; height: 20px; }
.voice .vmid { flex: 1; min-width: 0; }
.voice .vwave { display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; }
.voice .vwave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .28; transition: opacity .15s; }
.voice .vwave i.on { opacity: .95; }
.voice .vtime { font-size: 12.5px; opacity: .75; font-variant-numeric: tabular-nums; }

/* ===== Звонок ===== */
.call-screen {
  position: fixed; inset: 0; z-index: 950;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-top) + 64px) 24px calc(var(--safe-bottom) + 48px);
  background: radial-gradient(120% 90% at 50% 0%, #2b2b2b 0%, #101010 70%);
  color: #fff; animation: fade .2s ease;
  -webkit-user-select: none; user-select: none;
}
.call-top { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 100%; }
.call-avatar { margin-bottom: 14px; border-radius: 50%; }
.call-screen.ringing .call-avatar { animation: callpulse 1.6s ease-out infinite; }
@keyframes callpulse { 0% { box-shadow: 0 0 0 0 rgba(245, 178, 3, .55); } 100% { box-shadow: 0 0 0 38px rgba(245, 178, 3, 0); } }
.call-name { font-size: 28px; font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-status { font-size: 17px; color: rgba(255, 255, 255, .72); font-variant-numeric: tabular-nums; }
.call-screen.ended .call-status { color: var(--accent); }
.call-actions { display: flex; justify-content: center; gap: 48px; width: 100%; }
.call-act { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 14px; color: rgba(255, 255, 255, .8); }
.call-btn { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.call-btn svg { width: 30px; height: 30px; }
.call-btn.hang { background: #e5484d; }
.call-btn.accept { background: #2fb67c; }
.call-btn.mute { background: rgba(255, 255, 255, .16); }
.call-btn.mute.on { background: #fff; color: #151515; }
.call-btn:active { filter: brightness(.85); }
.rec-bar .icon-btn { color: var(--danger); } .rec-bar .icon-btn:active { background: var(--bg-2); }

/* ===== Фото профиля, галочка, админ-панель ===== */
.avatar { overflow: visible; }
.avatar .av-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .dot { z-index: 1; }
.avatar-edit { position: relative; border-radius: 50%; display: block; }
.avatar-edit .cam {
  position: absolute; right: -2px; bottom: -2px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); border: 3px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.avatar-edit .cam svg { width: 16px; height: 16px; }
.vbadge { display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -0.17em; color: var(--accent); flex: none; margin-left: 1px; }
.chat-item .name .vbadge, .list-row .t .vbadge { width: 16px; height: 16px; vertical-align: -3px; }
.bar-title-btn .t .vbadge { color: var(--header-accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 12px 4px; }
.stat { background: var(--bg-2); border-radius: 12px; padding: 10px 6px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 19px; }
.stat span { font-size: 12px; color: var(--text-2); }
.tags { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; }
.tag { font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); }
.tag.blocked { background: rgba(229, 72, 77, .16); color: var(--danger); }
.call-btn.speaker { background: rgba(255, 255, 255, .16); }
.call-btn.speaker.on { background: #fff; color: #151515; }

/* ===== Профиль пользователя ===== */
.profile-head .sub.online { color: var(--accent-ink); }
.profile-actions { display: flex; justify-content: center; gap: 10px; padding: 0 16px 16px; flex-wrap: wrap; }
.pa-btn { flex: 1; min-width: 84px; max-width: 130px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 600; }
.pa-btn svg { width: 22px; height: 22px; }
.pa-btn:active { background: var(--bg-2); }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 15.5px; }
.info-row .k { color: var(--text-2); }
.info-row .v { font-weight: 600; text-align: right; word-break: break-word; }

/* ===== Видеокружки ===== */
.cam-btn { color: var(--text-2); }
.bubble.circle-bubble { position: relative; background: transparent !important; padding: 0; box-shadow: none; }
.bubble.circle-bubble .meta { position: absolute; right: 8px; bottom: 6px; padding: 1px 7px; border-radius: 10px; background: rgba(0, 0, 0, .5); color: #fff; }
.bubble.circle-bubble .meta .read { color: var(--accent); }
.bubble.circle-bubble::after { display: none; }
.circle {
  --p: 0deg; position: relative; width: min(220px, 62vw); aspect-ratio: 1; border-radius: 50%; cursor: pointer;
  background: conic-gradient(var(--accent) var(--p), transparent 0); padding: 4px; box-sizing: border-box;
}
.circle .circle-video { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #222; display: block; }
.circle .circle-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; pointer-events: none; }
.circle .circle-play svg { width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: rgba(0, 0, 0, .45); }
.circle.playing .circle-play { display: none; }
.circle .circle-time { position: absolute; left: 12px; top: 10px; padding: 1px 7px; border-radius: 10px; background: rgba(0, 0, 0, .5); color: #fff; font-size: 12.5px; font-variant-numeric: tabular-nums; pointer-events: none; }
.circle-rec {
  position: fixed; inset: 0; z-index: 960; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 20px calc(var(--safe-bottom) + 28px); background: rgba(10, 10, 10, .96); color: #fff;
}
.circle-rec .cr-close { align-self: flex-start; color: #fff; }
.circle-rec .cr-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.circle-rec .cr-ring { --p: 0deg; width: min(300px, 78vw); aspect-ratio: 1; border-radius: 50%; padding: 5px; box-sizing: border-box; background: conic-gradient(var(--danger) var(--p), rgba(255, 255, 255, .18) 0); }
.circle-rec .cr-video { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #000; display: block; }
.circle-rec .cr-time { font-size: 17px; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .8); }
.circle-rec .cr-controls { display: flex; align-items: center; justify-content: space-between; width: min(300px, 78vw); }
.circle-rec .cr-spacer { width: 48px; }
.circle-rec .cr-flip { color: #fff; width: 48px; height: 48px; background: rgba(255, 255, 255, .14); }
.circle-rec .cr-flip svg { width: 24px; height: 24px; }
.cr-rec { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; display: flex; align-items: center; justify-content: center; }
.cr-rec i { width: 56px; height: 56px; border-radius: 50%; background: var(--danger); transition: all .15s; }
.circle-rec.recording .cr-rec i { width: 28px; height: 28px; border-radius: 8px; }

/* ===== Выбор иконки приложения ===== */
.icon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 12px 8px; }
.icon-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 2px; border-radius: 14px; border: 2px solid transparent; font-size: 11.5px; color: var(--text-2); text-align: center; }
.icon-opt img { width: 56px; height: 56px; border-radius: 13px; }
.icon-opt.on { border-color: var(--accent); color: var(--text); }

/* ===== Индикатор соединения ===== */
.net-pill {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 940;
  top: calc(var(--safe-top) + 64px); max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 18px;
  background: rgba(25, 25, 25, .92); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
  pointer-events: none; animation: fade .2s ease; white-space: nowrap;
}
.net-pill span { overflow: hidden; text-overflow: ellipsis; }
.net-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; }
.net-pill[data-kind="wait"] .net-dot { background: var(--accent); animation: blink 1s infinite; }
.net-pill[data-kind="off"] .net-dot { animation: blink 1.4s infinite; }
.net-pill[data-kind="ok"] .net-dot { background: var(--ok); }

/* ===== Обои чата ===== */
.wall-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 6px 12px 10px; }
.wall-opt {
  position: relative; aspect-ratio: 3 / 4; border-radius: 14px; border: 2px solid var(--border); background: var(--chat-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; padding: 6px 2px;
  color: #fff; font-size: 11px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .55); overflow: hidden; background-size: cover; background-position: center;
}
.wall-opt svg { width: 22px; height: 22px; margin-bottom: auto; margin-top: 10px; opacity: .85; }
.wall-opt:first-child { color: var(--text-2); text-shadow: none; }
.wall-opt.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ===== Пароль для входа ===== */
.lock-screen {
  position: fixed; inset: 0; z-index: 945; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 70px) 24px calc(var(--safe-bottom) + 24px);
  background: radial-gradient(120% 90% at 50% 0%, #2b2b2b 0%, #101010 70%); color: #fff;
  -webkit-user-select: none; user-select: none;
}
.lk-top { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.lk-title { font-size: 24px; font-weight: 650; }
.lk-sub { min-height: 22px; font-size: 15px; color: rgba(255, 255, 255, .65); }
.lk-sub.err { color: #ff8a8f; }
.lk-dots { display: flex; gap: 18px; margin-top: 18px; }
.lk-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7); transition: background .1s; }
.lk-dots i.on { background: var(--accent); border-color: var(--accent); }
.lk-dots.shake { animation: lkshake .4s; }
@keyframes lkshake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.lk-pad { display: grid; grid-template-columns: repeat(3, 78px); gap: 16px 24px; justify-content: center; }
.lk-key { width: 78px; height: 78px; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; font-size: 30px; font-weight: 500; display: flex; align-items: center; justify-content: center; }
.lk-key:active { background: rgba(255, 255, 255, .32); }
.lk-key.text { background: none; font-size: 16px; font-weight: 600; color: rgba(255, 255, 255, .8); }
.lk-key svg { width: 28px; height: 28px; }
.lk-foot { color: rgba(255, 255, 255, .65); font-size: 14.5px; padding: 8px 12px; }

/* ===== Своя клавиатура ===== */
.kbd { background: var(--bg-2); padding: 8px 4px calc(8px + var(--safe-bottom) * 0.5); display: flex; flex-direction: column; gap: 8px; user-select: none; -webkit-user-select: none; touch-action: none; }
.kb-row { display: flex; gap: 5px; justify-content: center; }
.kb-row.inset { padding: 0 4.5%; }
.kb-mid { flex: 1; display: flex; gap: 5px; justify-content: center; }
.kb-key {
  flex: 1; min-width: 0; height: 44px; border-radius: 8px; background: var(--surface); color: var(--text); font-size: 21px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.kb-key:active { background: var(--accent-soft); }
.kb-key.fn { background: var(--border); font-size: 16px; }
.kb-key.fn.wide { flex: 0 0 13%; max-width: 54px; }
.kb-key.fn.mid { flex: 0 0 13%; }
.kb-key.fn.on { background: var(--surface); color: var(--accent-ink); }
.kb-key.fn.caps { background: var(--accent); color: var(--on-accent); }
.kb-key.txt { font-size: 13px; font-weight: 600; }
.kb-key.space { flex: 1; font-size: 16px; color: var(--text-2); }
.kb-key svg { width: 22px; height: 22px; }
.kb-emoji { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; height: 220px; overflow-y: auto; touch-action: pan-y; }
.kb-key.emoji { background: none; box-shadow: none; font-size: 26px; height: 40px; }

/* =====================================================================
   Стиль «Telegram» (по умолчанию). Классический жёлтый стиль включается
   в Настройках → «Стиль оформления» (атрибут data-style="classic").
   ===================================================================== */
:root:not([data-style="classic"]) {
  --accent: #3390ec;
  --accent-strong: #2a7fd4;
  --accent-ink: #2481cc;
  --accent-soft: rgba(51, 144, 236, 0.14);
  --on-accent: #ffffff;
  --bg: #ffffff;
  --bg-2: #f1f3f5;
  --surface: #ffffff;
  --text: #000000;
  --text-2: #8a949d;
  --border: #e4e8ec;
  --header-bg: #517da2;
  --header-text: #ffffff;
  --header-sub: rgba(255, 255, 255, 0.72);
  --header-accent: #cbe6ff;
  --chat-bg: #d5e4cf;
  --bubble-in: #ffffff;
  --bubble-in-text: #000000;
  --bubble-out: #effdde;
  --bubble-out-text: #000000;
  --meta-in: #a0acb6;
  --meta-out: #62b457;
  --tick-read: #4fae4e;
  --out-tint: rgba(79, 174, 78, 0.16);
  --out-line: #4fae4e;
  --out-strong: #3d9a3a;
  --out-fail: #e5484d;
  --ok: #4fae4e;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-style="classic"]):not([data-theme="light"]) {
    --accent: #5288c1;
    --accent-strong: #6a9bd1;
    --accent-ink: #6ab3f3;
    --accent-soft: rgba(106, 179, 243, 0.16);
    --on-accent: #ffffff;
    --bg: #17212b;
    --bg-2: #202b36;
    --surface: #17212b;
    --text: #f5f5f5;
    --text-2: #7f91a4;
    --border: #0e1621;
    --header-bg: #232e3c;
    --header-text: #ffffff;
    --header-sub: #7f91a4;
    --header-accent: #6ab3f3;
    --chat-bg: #0e1621;
    --bubble-in: #182533;
    --bubble-in-text: #f5f5f5;
    --bubble-out: #2b5278;
    --bubble-out-text: #ffffff;
    --meta-in: #6d7f8f;
    --meta-out: #7da8d3;
    --tick-read: #6ab3f3;
    --out-tint: rgba(255, 255, 255, 0.12);
    --out-line: #8ec2f4;
    --out-strong: #cfe6ff;
    --out-fail: #ff9aa0;
    --ok: #4fae4e;
  }
}
:root:not([data-style="classic"])[data-theme="dark"] {
  --accent: #5288c1;
  --accent-strong: #6a9bd1;
  --accent-ink: #6ab3f3;
  --accent-soft: rgba(106, 179, 243, 0.16);
  --on-accent: #ffffff;
  --bg: #17212b;
  --bg-2: #202b36;
  --surface: #17212b;
  --text: #f5f5f5;
  --text-2: #7f91a4;
  --border: #0e1621;
  --header-bg: #232e3c;
  --header-text: #ffffff;
  --header-sub: #7f91a4;
  --header-accent: #6ab3f3;
  --chat-bg: #0e1621;
  --bubble-in: #182533;
  --bubble-in-text: #f5f5f5;
  --bubble-out: #2b5278;
  --bubble-out-text: #ffffff;
  --meta-in: #6d7f8f;
  --meta-out: #7da8d3;
  --tick-read: #6ab3f3;
  --out-tint: rgba(255, 255, 255, 0.12);
  --out-line: #8ec2f4;
  --out-strong: #cfe6ff;
  --out-fail: #ff9aa0;
  --ok: #4fae4e;
}

/* Детали оформления в духе Telegram */
:root:not([data-style="classic"]) .bar .bar-logo { display: none; }
:root:not([data-style="classic"]) .bar .title h1 { font-size: 20px; font-weight: 600; }
:root:not([data-style="classic"]) .chat-item { padding-top: 10px; padding-bottom: 10px; }
:root:not([data-style="classic"]) .chat-item .name { font-weight: 600; }
:root:not([data-style="classic"]) .chat-item .time { color: var(--text-2); }
:root:not([data-style="classic"]) .chat-item .badge:not(.muted) { background: var(--accent); color: #fff; }
:root:not([data-style="classic"]) .search-box .field { background: var(--bg-2); border-radius: 22px; }
:root:not([data-style="classic"]) .bubble { box-shadow: 0 1px 1px rgba(16, 35, 47, 0.14); border-radius: 17px; }
:root:not([data-style="classic"]) .msg.out.last .bubble { border-bottom-right-radius: 5px; }
:root:not([data-style="classic"]) .msg.in.last .bubble { border-bottom-left-radius: 5px; }
:root:not([data-style="classic"]) .msg.out .bubble .text a { color: #2481cc; }
:root:not([data-style="classic"]) .day-sep span, :root:not([data-style="classic"]) .sys-msg span, :root:not([data-style="classic"]) .unread-sep {
  background: rgba(45, 62, 82, 0.5); color: #fff;
}
:root:not([data-style="classic"]) .composer textarea { background: var(--bg-2); border-radius: 22px; }
:root:not([data-style="classic"]) .composer-wrap { background: var(--bg); }
:root:not([data-style="classic"]) .send-btn, :root:not([data-style="classic"]) .mic-btn:active { background: var(--accent); color: #fff; }
:root:not([data-style="classic"]) .mic-btn { background: none; color: var(--text-2); }
:root:not([data-style="classic"]) .fab { background: var(--accent); color: #fff; }
:root:not([data-style="classic"]) .voice .vplay { background: var(--accent); color: #fff; }
:root:not([data-style="classic"]) .msg.out .voice .vplay { background: var(--out-line); }
:root:not([data-style="classic"]) .msg.out .progress i { background: var(--out-line); }
:root:not([data-style="classic"]) .tag { background: var(--accent-soft); color: var(--accent-ink); }
:root:not([data-style="classic"]) .vbadge { color: var(--accent); }
:root:not([data-style="classic"]) .bar-title-btn .t .vbadge { color: #fff; }
:root:not([data-style="classic"]) .msg.out .bubble .meta .read { color: var(--tick-read); }
:root:not([data-style="classic"]) .chat-item.active { background: var(--accent-soft); }

/* ===== Реакции, пересылка, закреп, свайп ===== */
.msg { touch-action: pan-y; }
.bubble.swipe-ready { outline: 2px solid var(--accent); outline-offset: 1px; }
.bubble .fwd { font-size: 13px; color: var(--accent-ink); margin-bottom: 2px; }
.msg.out .bubble .fwd { color: var(--out-strong); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.rx {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 6px; border-radius: 14px; font-size: 14px;
  background: var(--accent-soft); color: var(--text);
}
.rx span { font-size: 12.5px; font-weight: 650; }
.rx.mine { background: var(--accent); color: var(--on-accent); }
.msg.out .rx { background: var(--out-tint); }
.msg.out .rx.mine { background: var(--out-line); color: #fff; }
.rx-bar { display: flex; justify-content: space-around; gap: 2px; padding: 4px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.rx-bar button { font-size: 28px; width: 42px; height: 42px; border-radius: 50%; }
.rx-bar button:active, .rx-bar button.on { background: var(--accent-soft); }
.fwd-dialog { max-width: 380px; }
.fwd-list { max-height: 48vh; overflow-y: auto; margin: 0 -8px 8px; }
