/* Rovitek — внешний вид в стиле WhatsApp (Android 2024+), светлая и тёмная тема */
:root {
  --green: #1daa61;
  --green-2: #25d366;
  --green-dark: #008069;
  --green-soft: #d8fdd2;
  --green-soft-text: #15603e;
  --bg: #ffffff;
  --bg-2: #f7f5f3;
  --panel: #ffffff;
  --text: #111b21;
  --text-2: #667781;
  --text-3: #8696a0;
  --line: #e9edef;
  --hover: #f5f6f6;
  --search: #f0f2f5;
  --chat-bg: #efeae2;
  --doodle: url(/img/doodle-light.svg);
  --bubble-out: #d9fdd3;
  --bubble-in: #ffffff;
  --bubble-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
  --meta: #667781;
  --quote-bg: rgba(11, 20, 26, .05);
  --sys-bg: #ffeecd;
  --sys-text: #54656f;
  --date-bg: #ffffff;
  --input-bg: #ffffff;
  --danger: #ea0038;
  --link: #027eb5;
  --icon: #54656f;
  --blue: #53bdeb;
  --overlay: rgba(11, 20, 26, .45);
  --sheet: #ffffff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --green: #21c063;
    --green-2: #25d366;
    --green-soft: #103529;
    --green-soft-text: #d8fdd2;
    --bg: #0b141a;
    --bg-2: #0b141a;
    --panel: #0b141a;
    --text: #e9edef;
    --text-2: #8696a0;
    --text-3: #8696a0;
    --line: #1f2c33;
    --hover: #1b252c;
    --search: #1f272a;
    --chat-bg: #0b141a;
    --doodle: url(/img/doodle-dark.svg);
    --bubble-out: #144d37;
    --bubble-in: #1f272a;
    --bubble-shadow: 0 1px 0.5px rgba(0, 0, 0, .25);
    --meta: rgba(233, 237, 239, .6);
    --quote-bg: rgba(0, 0, 0, .18);
    --sys-bg: #1f272a;
    --sys-text: #ffd279;
    --date-bg: #1f272a;
    --input-bg: #1f272a;
    --link: #53bdeb;
    --icon: #aebac1;
    --overlay: rgba(0, 0, 0, .6);
    --sheet: #1f272a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
input, textarea, button { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--link); }
svg.i { width: 24px; height: 24px; display: block; fill: currentColor; flex: none; }
.selectable, .bubble .txt { -webkit-user-select: text; user-select: text; }

#app { position: fixed; inset: 0; display: flex; }
.boot { margin: auto; text-align: center; color: var(--text-2); }
.boot img { width: 84px; height: 84px; border-radius: 22px; }
.boot-name { margin-top: 12px; font-size: 18px; letter-spacing: .3px; }

/* ---------- раскладка: список слева, чат справа на широком экране ---------- */
.side { width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--panel); position: relative; }
.main { display: none; flex: 1; min-width: 0; height: 100%; position: relative; }
.app-mobile.has-main .side { display: none; }
.app-mobile.has-main .main { display: flex; }
@media (min-width: 900px) {
  .side { width: 400px; flex: none; border-right: 1px solid var(--line); }
  .main { display: flex; }
  .app-mobile.has-main .side { display: flex; }
}
.empty-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg-2); color: var(--text-2); text-align: center; padding: 40px; border-bottom: 6px solid var(--green);
}
.empty-main h2 { font-weight: 300; font-size: 30px; color: var(--text); margin: 8px 0 0; }
.empty-main img { width: 110px; height: 110px; border-radius: 28px; opacity: .9; }

/* ---------- верхняя панель ---------- */
.topbar {
  flex: none; display: flex; align-items: center; gap: 4px; padding: calc(var(--safe-top) + 8px) 8px 6px 18px;
  min-height: calc(var(--safe-top) + 60px); background: var(--panel);
}
.topbar .title { flex: 1; font-size: 23px; font-weight: 600; letter-spacing: -.2px; }
.topbar .title.brand { color: var(--green); }
.topbar .title.plain { font-size: 21px; font-weight: 500; color: var(--text); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--icon); flex: none;
}
.icon-btn:active { background: var(--hover); }
.icon-btn.light { color: #fff; }

/* поиск и фильтры */
.search { margin: 2px 16px 8px; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 16px; border-radius: 24px; background: var(--search); color: var(--text-2); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.chips { display: flex; gap: 8px; padding: 2px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 18px; background: var(--search); color: var(--text-2); font-size: 14.5px; font-weight: 500; }
.chip.on { background: var(--green-soft); color: var(--green-soft-text); }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* ---------- список чатов ---------- */
.row { display: flex; align-items: center; gap: 14px; padding: 0 16px; min-height: 76px; cursor: pointer; position: relative; }
.row:active, .row.sel { background: var(--hover); }
@media (hover: hover) { .row:hover { background: var(--hover); } }
.row .body { flex: 1; min-width: 0; padding: 12px 0; }
.row .line1, .row .line2 { display: flex; align-items: center; gap: 8px; }
.row .name { flex: 1; min-width: 0; font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { font-size: 12px; color: var(--text-2); flex: none; }
.row .time.unread { color: var(--green); font-weight: 500; }
.row .prev { flex: 1; min-width: 0; color: var(--text-2); font-size: 14.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 3px; }
.row .prev .typing { color: var(--green); font-weight: 500; }
.row .prev svg.i { width: 18px; height: 18px; }
.badge { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: var(--green-2); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; flex: none; margin-top: 3px; }
@media (prefers-color-scheme: dark) { .badge { color: #0b141a; } }
.row .muted-ic { color: var(--text-3); margin-top: 3px; }
.row .muted-ic svg.i { width: 18px; height: 18px; }
.section-title { padding: 14px 16px 8px; color: var(--text-2); font-size: 14.5px; font-weight: 500; }
.list-empty { padding: 50px 30px; text-align: center; color: var(--text-2); line-height: 1.5; }
.row .sub { color: var(--text-2); font-size: 14.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .action-ic { color: var(--green); }
.row .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-3); flex: none; display: grid; place-items: center; }
.row .check.on { background: var(--green); border-color: var(--green); color: #fff; }
.row .check svg.i { width: 16px; height: 16px; }
.row.lead .ava { background: var(--green); color: #fff; }

/* аватар */
.ava { position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #dfe5e7; color: #fff; font-weight: 500; }
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava.def { background: #dfe5e7; color: #fff; }
@media (prefers-color-scheme: dark) { .ava.def { background: #6a7175; color: #cfd4d6; } }
.ava svg.i { width: 62%; height: 62%; }
.ava-wrap { position: relative; flex: none; }
.ava-wrap .dot { position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px; border-radius: 50%; background: var(--green-2); border: 2.5px solid var(--panel); }

/* FAB */
.fab {
  position: absolute; right: 16px; bottom: calc(var(--safe-bottom) + 86px); width: 56px; height: 56px; border-radius: 16px;
  background: var(--green); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 6px rgba(0,0,0,.18), 0 2px 3px rgba(0,0,0,.1); z-index: 3;
}
@media (prefers-color-scheme: dark) { .fab { color: #0b141a; } }
.fab:active { transform: scale(.96); }

/* нижнее меню */
.tabbar { flex: none; display: flex; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 0 calc(var(--safe-bottom) + 10px); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--text); position: relative; }
.tab .pill { width: 62px; height: 32px; border-radius: 16px; display: grid; place-items: center; transition: background .15s; position: relative; }
.tab.on .pill { background: var(--green-soft); color: var(--green-soft-text); }
.tab.on { font-weight: 700; }
.tab .tbadge { position: absolute; left: 34px; top: -3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--green-2); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* баннер (уведомления, установка) */
.banner { margin: 6px 12px 10px; padding: 12px 14px; border-radius: 14px; background: var(--green-soft); color: var(--green-soft-text); display: flex; gap: 12px; align-items: center; font-size: 14px; }
.banner .t { flex: 1; }
.banner b { display: block; font-size: 15px; margin-bottom: 2px; }
.banner button.go { background: var(--green); color: #fff; border-radius: 18px; padding: 8px 14px; font-weight: 600; font-size: 14px; flex: none; }
.banner button.x { color: inherit; opacity: .7; }

/* ---------- экран чата ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; background: var(--chat-bg); position: relative; }
.chat::before { content: ""; position: absolute; inset: 0; background-image: var(--doodle); background-size: 420px; pointer-events: none; }
.chat > * { position: relative; }
.chat-head { flex: none; display: flex; align-items: center; gap: 2px; padding: calc(var(--safe-top) + 6px) 4px 6px 2px; min-height: calc(var(--safe-top) + 60px); background: var(--panel); z-index: 2; border-bottom: 1px solid var(--line); }
.chat-head .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 0; }
.chat-head .who .ava { width: 40px; height: 40px; }
.chat-head .who .n { font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who .s { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who .s.on { color: var(--green); }
.chat-head .who > div { min-width: 0; }

.msgs { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: flex; flex-direction: column; }
.msgs .spacer { flex: 1; }
.day { align-self: center; margin: 10px 0 8px; padding: 5px 12px; border-radius: 8px; background: var(--date-bg); color: var(--text-2); font-size: 12.5px; box-shadow: var(--bubble-shadow); position: sticky; top: 6px; z-index: 1; }
.sys { align-self: center; max-width: 85%; text-align: center; margin: 6px 0; padding: 6px 12px; border-radius: 8px; background: var(--sys-bg); color: var(--sys-text); font-size: 12.5px; box-shadow: var(--bubble-shadow); }
.sys.e2e { display: flex; gap: 6px; align-items: flex-start; text-align: left; }

.m { display: flex; padding: 0 4.5%; margin-top: 2px; position: relative; }
.m.first { margin-top: 10px; }
.m.out { justify-content: flex-end; }
.m .reply-ic { position: absolute; left: 6px; top: 50%; margin-top: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--date-bg); color: var(--icon); display: grid; place-items: center; opacity: 0; box-shadow: var(--bubble-shadow); }
.bubble {
  position: relative; max-width: min(78%, 560px); min-width: 64px; padding: 6px 8px 7px 9px; border-radius: 8px;
  background: var(--bubble-in); box-shadow: var(--bubble-shadow); font-size: 15.2px; line-height: 1.38; word-wrap: break-word; overflow-wrap: anywhere;
}
.m.out .bubble { background: var(--bubble-out); }
.m.first .bubble { border-top-left-radius: 0; }
.m.out.first .bubble { border-top-left-radius: 8px; border-top-right-radius: 0; }
.m.first .bubble::before {
  content: ""; position: absolute; top: 0; left: -8px; width: 8px; height: 13px; background: inherit;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.m.out.first .bubble::before { left: auto; right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.bubble .author { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.bubble .txt { white-space: pre-wrap; }
.bubble .txt a { color: var(--link); }
.bubble .txt.big { font-size: 42px; line-height: 1.15; }
.bubble .meta-pad { display: inline-block; width: 44px; height: 1px; }
.bubble.edited .meta-pad { width: 108px; }
.bubble .txt.big + .meta-pad { display: block; height: 10px; }
.bubble .meta { position: absolute; right: 7px; bottom: 3px; font-size: 11px; color: var(--meta); display: flex; align-items: center; gap: 3px; white-space: nowrap; height: 15px; }
.bubble .meta.abs { bottom: 4px; }
.bubble .meta svg.i { width: 15px; height: 15px; }
.bubble .meta .err { color: var(--danger); }
.bubble.media { padding: 3px; }
.bubble.media .author { padding: 3px 6px 2px; }
.bubble.media .cap { padding: 5px 6px 3px; }
.bubble.media .meta.on-media { right: 9px; bottom: 8px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.bubble.media .meta.on-media::before { content: ""; position: absolute; inset: -14px -10px -8px -30px; background: radial-gradient(ellipse at bottom right, rgba(0,0,0,.35), transparent 70%); z-index: -1; }
.bubble.deleted .txt { color: var(--text-2); font-style: italic; display: inline-flex; gap: 6px; align-items: center; }
.bubble.deleted svg.i { width: 17px; height: 17px; }

.photo { position: relative; display: block; border-radius: 6px; overflow: hidden; background: rgba(0,0,0,.08); cursor: pointer; max-width: 100%; }
.photo img, .photo video { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo .blur { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(8px); transform: scale(1.1); }
.photo .play { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(11,20,26,.55); color: #fff; display: grid; place-items: center; }
.photo .dur { position: absolute; left: 8px; bottom: 6px; color: #fff; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.6); display: flex; gap: 4px; align-items: center; }
.photo .dur svg.i { width: 16px; height: 16px; }
.photo .progress { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; }
.gone { padding: 14px 10px; color: var(--text-2); font-size: 13.5px; display: flex; gap: 8px; align-items: center; }

.doc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; background: var(--quote-bg); min-width: 220px; text-decoration: none; color: inherit; }
.doc .ext { width: 36px; height: 42px; border-radius: 4px; background: #e2574c; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: end center; padding-bottom: 6px; flex: none; text-transform: uppercase; }
.doc .dn { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.doc .ds { font-size: 12px; color: var(--text-2); }

/* цитата */
.quote { display: flex; border-radius: 6px; background: var(--quote-bg); overflow: hidden; margin-bottom: 4px; cursor: pointer; min-height: 42px; }
.quote .bar { width: 4px; flex: none; }
.quote .qb { flex: 1; min-width: 0; padding: 5px 10px 6px 8px; }
.quote .qn { font-size: 13px; font-weight: 600; }
.quote .qt { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.quote img { width: 52px; height: 52px; object-fit: cover; flex: none; }
.bubble.media .quote { margin: 0 0 3px; }

/* голосовое */
.voice { display: flex; align-items: center; gap: 10px; width: 270px; max-width: 100%; padding: 2px 0 6px 0; }
.voice .vava { position: relative; flex: none; }
.voice .vava .ava { width: 48px; height: 48px; }
.voice .vava .mic { position: absolute; right: -4px; bottom: -2px; color: var(--green-2); }
.voice .vava .mic svg.i { width: 20px; height: 20px; }
.voice .pp { width: 34px; height: 34px; display: grid; place-items: center; color: var(--icon); flex: none; }
.voice .pp svg.i { width: 32px; height: 32px; }
.voice .wv { flex: 1; min-width: 0; position: relative; }
.voice .bars { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.voice .bars i { flex: 1; min-width: 2px; border-radius: 2px; background: var(--text-3); opacity: .55; }
.voice .bars i.p { background: var(--blue); opacity: 1; }
.m.out .voice .bars i.p { background: #1aa2d9; }
.voice .vt { position: absolute; left: 0; top: 30px; font-size: 11px; color: var(--meta); }
.voice .speed { flex: none; font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: 12px; background: var(--text-3); color: #fff; }

/* звонок в чате */
.callmsg { display: flex; align-items: center; gap: 12px; min-width: 210px; padding: 4px 4px 8px 2px; cursor: pointer; }
.callmsg .ci { width: 40px; height: 40px; border-radius: 50%; background: var(--quote-bg); display: grid; place-items: center; color: var(--icon); flex: none; }
.callmsg .ci.miss { color: var(--danger); }
.callmsg .ct { font-size: 15px; }
.callmsg .cs { font-size: 13px; color: var(--text-2); }

/* «печатает» в чате */
.typing-bubble { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: tb 1.2s infinite; }
.typing-bubble i:nth-child(2) { animation-delay: .2s; }
.typing-bubble i:nth-child(3) { animation-delay: .4s; }
@keyframes tb { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.to-bottom { position: absolute; right: 14px; bottom: 84px; width: 42px; height: 42px; border-radius: 50%; background: var(--date-bg); color: var(--icon); display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.25); z-index: 2; }
.to-bottom .badge { position: absolute; top: -8px; right: -4px; margin: 0; }

/* поле ввода */
.composer { flex: none; display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px calc(var(--safe-bottom) + 8px) 6px; z-index: 2; }
.composer .field { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--input-bg); border-radius: 26px; box-shadow: var(--bubble-shadow); overflow: hidden; }
.composer .field .row-in { display: flex; align-items: flex-end; min-height: 50px; padding: 0 4px; }
.composer textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; resize: none; font-size: 17px; line-height: 22px; padding: 14px 4px; max-height: 140px; -webkit-user-select: text; user-select: text; }
.composer textarea::placeholder { color: var(--text-2); }
.composer .field .icon-btn { width: 44px; height: 50px; border-radius: 22px; }
.send-btn { width: 50px; height: 50px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; flex: none; box-shadow: var(--bubble-shadow); }
@media (prefers-color-scheme: dark) { .send-btn { color: #0b141a; } }
.send-btn:active { transform: scale(.95); }
.composer .replybox { margin: 6px 6px 0; }
.composer .replybox .quote { margin: 0; }
.composer .replybox .x { padding: 0 8px; color: var(--icon); align-self: flex-start; padding-top: 6px; }
.composer .editbox { display: flex; align-items: center; gap: 10px; margin: 8px 10px 0 16px; color: var(--green); font-size: 13.5px; font-weight: 600; }
.composer .editbox span { flex: 1; }

/* запись голосового */
.recbar { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--input-bg); border-radius: 26px; height: 50px; padding: 0 6px 0 14px; box-shadow: var(--bubble-shadow); }
.recbar .rdot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.recbar .rtime { font-variant-numeric: tabular-nums; font-size: 16px; min-width: 44px; }
.recbar .rwave { flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; overflow: hidden; justify-content: flex-end; }
.recbar .rwave i { width: 3px; border-radius: 2px; background: var(--text-3); flex: none; }
.recbar .icon-btn { color: var(--icon); }

/* эмодзи */
.emoji-panel { flex: none; height: 270px; background: var(--panel); border-top: 1px solid var(--line); overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); padding: 8px 8px calc(var(--safe-bottom) + 8px); z-index: 2; }
.emoji-panel button { font-size: 28px; height: 46px; border-radius: 8px; }
.emoji-panel button:active { background: var(--hover); }
.emoji-panel .eh { grid-column: 1 / -1; font-size: 13px; color: var(--text-2); padding: 8px 4px 4px; font-weight: 500; }

/* ---------- меню, шторки, диалоги ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 50; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.menu { position: fixed; z-index: 51; min-width: 200px; background: var(--sheet); border-radius: 14px; padding: 8px 0; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: pop .12s ease-out; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.menu button { display: flex; width: 100%; align-items: center; gap: 16px; padding: 12px 20px; font-size: 16px; text-align: left; }
.menu button:active { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu button svg.i { color: var(--icon); }
.menu button.danger svg.i { color: var(--danger); }
.menu .reacts { display: flex; justify-content: space-around; padding: 4px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 26px; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--sheet); border-radius: 22px 22px 0 0; padding: 10px 0 calc(var(--safe-bottom) + 14px); animation: up .2s ease-out; max-height: 85vh; overflow-y: auto; }
@media (min-width: 900px) { .sheet { left: 50%; width: 420px; margin-left: -210px; bottom: 20px; border-radius: 22px; } }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--text-3); opacity: .5; margin: 0 auto 12px; }
.sheet h3 { margin: 4px 22px 14px; font-size: 18px; font-weight: 600; }
.attach-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 6px; padding: 8px 14px 6px; }
.attach-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.attach-grid .ac { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #fff; }

.dialog { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 52; width: min(340px, calc(100% - 48px)); background: var(--sheet); border-radius: 24px; padding: 22px 22px 12px; box-shadow: 0 10px 40px rgba(0,0,0,.3); animation: pop .15s; }
.dialog h3 { margin: 0 0 10px; font-size: 19px; font-weight: 600; }
.dialog p { margin: 0 0 12px; color: var(--text-2); line-height: 1.45; }
.dialog .btns { display: flex; justify-content: flex-end; gap: 4px; margin-top: 12px; }
.dialog .btns button { padding: 10px 14px; border-radius: 20px; color: var(--green-dark); font-weight: 600; font-size: 15px; }
@media (prefers-color-scheme: dark) { .dialog .btns button { color: var(--green); } }
.dialog .btns button.danger { color: var(--danger); }
.dialog input { width: 100%; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 100px); transform: translateX(-50%); z-index: 60; background: #323739; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14.5px; max-width: calc(100% - 40px); box-shadow: 0 4px 14px rgba(0,0,0,.3); animation: fade .2s; text-align: center; }

/* ---------- формы, настройки, профиль ---------- */
.page { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; background: var(--panel); }
.page-head { flex: none; display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-top) + 6px) 8px 6px 4px; min-height: calc(var(--safe-top) + 60px); background: var(--panel); }
.page-head .t { flex: 1; font-size: 20px; font-weight: 500; min-width: 0; }
.page-head .t small { display: block; font-size: 13px; color: var(--text-2); font-weight: 400; }
.page-head.green { background: var(--green-dark); color: #fff; }
.page-head.green .icon-btn { color: #fff; }
.field-row { padding: 6px 22px 14px; }
.field-row label { display: block; font-size: 13px; color: var(--green-dark); font-weight: 500; margin-bottom: 4px; }
@media (prefers-color-scheme: dark) { .field-row label { color: var(--green); } }
.inp { width: 100%; border: 0; border-bottom: 2px solid var(--line); background: transparent; outline: 0; font-size: 17px; padding: 8px 2px; border-radius: 0; -webkit-user-select: text; user-select: text; }
.inp:focus { border-color: var(--green); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 24px; border-radius: 24px; background: var(--green); color: #fff; font-weight: 600; font-size: 16px; }
@media (prefers-color-scheme: dark) { .btn { color: #0b141a; } }
.btn:disabled { opacity: .5; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: var(--green-dark); border: 1.5px solid var(--line); }
@media (prefers-color-scheme: dark) { .btn.ghost { color: var(--green); } }
.err-text { color: var(--danger); font-size: 14px; margin: 10px 0; text-align: center; }
.hint { color: var(--text-2); font-size: 13.5px; line-height: 1.45; }

.profile-top { display: flex; flex-direction: column; align-items: center; padding: 18px 20px 20px; gap: 6px; }
.profile-top .ava { width: 150px; height: 150px; font-size: 54px; cursor: pointer; }
.profile-top .ava-edit { position: absolute; right: 4px; bottom: 4px; width: 46px; height: 46px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; border: 3px solid var(--panel); }
.profile-top h2 { margin: 12px 0 0; font-size: 24px; font-weight: 500; text-align: center; }
.profile-top .s { color: var(--text-2); font-size: 15px; }
.actions { display: flex; gap: 10px; justify-content: center; padding: 6px 16px 16px; }
.actions button { flex: 1; max-width: 104px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 14px; border: 1px solid var(--line); color: var(--green-dark); font-size: 13.5px; }
@media (prefers-color-scheme: dark) { .actions button { color: var(--green); } }
.gap { height: 8px; background: var(--bg-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { .gap { background: #050b0e; border-color: #050b0e; } }
.item { display: flex; align-items: center; gap: 22px; padding: 14px 22px; min-height: 60px; cursor: pointer; }
.item:active { background: var(--hover); }
.item .ic { color: var(--icon); }
.item .tx { flex: 1; min-width: 0; }
.item .tx .a { font-size: 16.5px; }
.item .tx .b { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.item.danger, .item.danger .ic { color: var(--danger); }
.switch { width: 36px; height: 20px; border-radius: 10px; background: var(--text-3); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(16px); }

/* ---------- вход ---------- */
.auth { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: calc(var(--safe-top) + 40px) 26px calc(var(--safe-bottom) + 28px); background: var(--panel); }
.auth .logo { width: 96px; height: 96px; border-radius: 26px; box-shadow: 0 6px 20px rgba(29,170,97,.3); }
.auth h1 { font-size: 26px; font-weight: 500; margin: 26px 0 8px; text-align: center; }
.auth .lead { text-align: center; color: var(--text-2); line-height: 1.5; margin: 0 0 24px; max-width: 340px; }
.auth form { width: 100%; max-width: 360px; }
.auth .field-row { padding: 6px 0 14px; }
.auth .switch-link { margin-top: 18px; text-align: center; color: var(--text-2); font-size: 15px; }
.auth .switch-link button { color: var(--green-dark); font-weight: 600; }
@media (prefers-color-scheme: dark) { .auth .switch-link button { color: var(--green); } }
.auth .ill { width: 220px; height: 220px; border-radius: 50%; background: var(--green-soft); display: grid; place-items: center; margin-top: 10px; }
.auth .ill svg.i { width: 100px; height: 100px; color: var(--green); }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: -6px; top: 0; }

/* ---------- просмотр фото ---------- */
.viewer { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; animation: fade .15s; }
.viewer .vh { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-top) + 6px) 8px 6px; color: #fff; background: linear-gradient(rgba(0,0,0,.6), transparent); position: absolute; left: 0; right: 0; top: 0; z-index: 2; }
.viewer .vh .t { flex: 1; min-width: 0; }
.viewer .vh .t small { display: block; opacity: .7; font-size: 12.5px; }
.viewer .vb { flex: 1; display: grid; place-items: center; overflow: hidden; touch-action: pinch-zoom; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 20px calc(var(--safe-bottom) + 20px); color: #fff; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.6)); }

/* превью перед отправкой */
.preview { position: fixed; inset: 0; z-index: 65; background: #0b141a; display: flex; flex-direction: column; color: #fff; }
.preview .pb { flex: 1; display: grid; place-items: center; overflow: hidden; padding: 10px; }
.preview .pb img, .preview .pb video { max-width: 100%; max-height: 100%; border-radius: 6px; }
.preview .pf { display: flex; gap: 8px; align-items: flex-end; padding: 8px 8px calc(var(--safe-bottom) + 10px); }
.preview .pf textarea { flex: 1; border: 0; outline: 0; resize: none; border-radius: 24px; background: #1f272a; color: #e9edef; font-size: 17px; padding: 13px 18px; max-height: 120px; }
.preview .thumbs { display: flex; gap: 8px; padding: 0 12px 8px; overflow-x: auto; }
.preview .thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; opacity: .6; border: 2px solid transparent; }
.preview .thumbs img.on { opacity: 1; border-color: var(--green-2); }

/* ---------- звонок ---------- */
.call { position: fixed; inset: 0; z-index: 80; background: #0b141a; color: #fff; display: flex; flex-direction: column; overflow: hidden; }
.call .cbg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(40px) brightness(.45); transform: scale(1.1); }
.call .cbg.plain { background: radial-gradient(circle at 50% 30%, #1e3a33, #0b141a 70%); filter: none; }
.call .ctop { position: relative; z-index: 3; text-align: center; padding: calc(var(--safe-top) + 26px) 20px 10px; }
.call .ctop .enc { font-size: 12.5px; opacity: .7; display: flex; justify-content: center; align-items: center; gap: 5px; }
.call .ctop .enc svg.i { width: 14px; height: 14px; }
.call .ctop h2 { margin: 18px 0 6px; font-size: 28px; font-weight: 500; }
.call .ctop .st { opacity: .85; font-size: 16px; }
.call .cmid { flex: 1; position: relative; z-index: 1; display: grid; place-items: center; }
.call .cmid .big-ava { width: 150px; height: 150px; font-size: 54px; box-shadow: 0 0 0 0 rgba(37,211,102,.4); }
.call .cmid .big-ava.ring { animation: ringpulse 1.6s infinite; }
@keyframes ringpulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); } 100% { box-shadow: 0 0 0 36px rgba(255,255,255,0); } }
.call .remote { position: absolute; inset: 0; z-index: 1; background: #000; }
.call .remote video { width: 100%; height: 100%; object-fit: cover; }
.call .grid { position: absolute; inset: 0; z-index: 1; display: grid; gap: 4px; padding: calc(var(--safe-top) + 4px) 4px calc(var(--safe-bottom) + 120px); }
.call .tile { position: relative; background: #1f272a; border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.call .tile video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.call .tile .tn { position: absolute; left: 10px; bottom: 8px; font-size: 13.5px; text-shadow: 0 1px 3px rgba(0,0,0,.7); display: flex; gap: 4px; align-items: center; z-index: 2; }
.call .tile .tn svg.i { width: 16px; height: 16px; }
.call .tile.speaking { box-shadow: inset 0 0 0 3px var(--green-2); }
.call .self { position: absolute; z-index: 4; right: 14px; top: calc(var(--safe-top) + 14px); width: 104px; height: 150px; border-radius: 14px; overflow: hidden; background: #1f272a; box-shadow: 0 4px 18px rgba(0,0,0,.4); touch-action: none; }
.call .self video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.call .self video.back { transform: none; }
.call .cbar { position: relative; z-index: 5; margin: 0 auto calc(var(--safe-bottom) + 22px); display: flex; gap: 10px; padding: 12px 14px; border-radius: 34px; background: rgba(31, 39, 42, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.call .cbtn { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; }
.call .cbtn.on { background: #fff; color: #0b141a; }
.call .cbtn.end { background: #ea0038; color: #fff; }
.call .cbtn.acc { background: #25d366; color: #fff; }
.call .cbtn svg.i { width: 28px; height: 28px; }
.call .incoming { position: relative; z-index: 5; display: flex; justify-content: space-around; padding: 0 30px calc(var(--safe-bottom) + 50px); }
.call .incoming > div { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 14px; opacity: .95; }
.call .incoming .cbtn { width: 70px; height: 70px; }
.call .incoming .cbtn svg.i { width: 34px; height: 34px; }
.call .incoming .acc { animation: bounce 1.4s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.call-mini { position: fixed; z-index: 75; left: 50%; transform: translateX(-50%); top: calc(var(--safe-top) + 8px); background: var(--green); color: #fff; border-radius: 20px; padding: 8px 18px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.25); display: flex; gap: 8px; align-items: center; }

.calls-row .dir { display: flex; align-items: center; gap: 4px; }
.calls-row .dir svg.i { width: 16px; height: 16px; }
.calls-row .dir.miss { color: var(--danger); }
.calls-row .dir.ok { color: var(--green); }
.calls-row.miss .name { color: var(--danger); }

.spin { width: 30px; height: 30px; border: 3px solid rgba(127,127,127,.25); border-top-color: var(--green); border-radius: 50%; animation: rot .8s linear infinite; margin: 20px auto; }
@keyframes rot { to { transform: rotate(360deg); } }
.conn { flex: none; text-align: center; font-size: 13px; padding: 4px; background: #ffd279; color: #3b2f00; }
svg.i.inline { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; }
.fab:disabled { opacity: .6; }
