/* MumkiChat — приложение менеджера. Цвета в духе WhatsApp Web, свой узор и свой значок.
   Экраны: телефон ≤ 768 (одна колонка), планшет 769–1024 (список уже), компьютер, > 1440 — ширина до 1600 по центру. */

:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wa: #1E9E5A;
  --tg: #F57C00;
  --accent: #00a884;
  --accent-2: #008069;
  --page: #d1d7db;
  --band: #00a884;
  --panel: #ffffff;
  --head: #f0f2f5;
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --text: #111b21;
  --text-2: #667781;
  --text-3: #8696a0;
  --icon: #54656f;
  --line: #e9edef;
  --line-2: #d1d7db;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --search: #f0f2f5;
  --input: #ffffff;
  --pill: #f0f2f5;
  --pill-ink: #54656f;
  --pill-on: #d9fdd3;
  --pill-on-ink: #008069;
  --badge: #25d366;
  --badge-ink: #ffffff;
  --time-unread: #1fa855;
  --read: #53bdeb;
  --meta: #667781;
  --danger: #ea0038;
  --wait: #c25e00;
  --wait-bg: #fff0df;
  --wait-line: #f57c00;
  --date-pill: #ffffff;
  --date-ink: #54656f;
  --author: #1b7f62;
  --link: #027eb5;
  --card: rgba(11, 20, 26, .045);
  --card-out: rgba(11, 20, 26, .055);
  --track: rgba(11, 20, 26, .16);
  --warn-bg: #fff4d1;
  --warn-ink: #5b4300;
  --deny-bg: #fde7e9;
  --deny-ink: #b3261e;
  --offline-bg: #ffd65c;
  --offline-ink: #3b2c00;
  --shadow: 0 1px .5px rgba(11, 20, 26, .13);
  --shadow-2: 0 2px 5px rgba(11, 20, 26, .26), 0 2px 10px rgba(11, 20, 26, .16);
  --hover-ic: rgba(11, 20, 26, .06);
  --scroll: rgba(11, 20, 26, .2);
  --toast: #3b4a54;
  --ring: var(--panel);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300' viewBox='0 0 300 300'%3E%3Cg fill='none' stroke='%234a3b22' stroke-opacity='.075' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='42' cy='44' rx='14' ry='18'/%3E%3Cpath d='M42 62l-4 5h8zM42 67c-5 7 5 12 0 20s4 10 0 16'/%3E%3Cpath d='M150 18l4.6 9.4 10.4 1.5-7.5 7.3 1.8 10.3-9.3-4.9-9.3 4.9 1.8-10.3-7.5-7.3 10.4-1.5z'/%3E%3Cpath d='M246 70c-15-10-20-18-14-25 4-5 11-4 14 2 3-6 10-7 14-2 6 7 1 15-14 25z'/%3E%3Cpath d='M70 116h40a9 9 0 0 1 9 9v18a9 9 0 0 1-9 9H88l-11 9v-9h-7a9 9 0 0 1-9-9v-18a9 9 0 0 1 9-9z'/%3E%3Ccircle cx='78' cy='134' r='1.6'/%3E%3Ccircle cx='90' cy='134' r='1.6'/%3E%3Ccircle cx='102' cy='134' r='1.6'/%3E%3Crect x='196' y='148' width='36' height='28' rx='3'/%3E%3Cpath d='M192 140h44v8h-44zM214 140v36M214 140c-5-11-18-8-11 0M214 140c5-11 18-8 11 0'/%3E%3Cpath d='M24 176l7 3M128 70l3 7M266 120l-6 5M176 102l7-2M118 196l-4 7M276 206l7 1M188 270l5-6M20 290l7-3M96 262l2 7'/%3E%3Ccircle cx='160' cy='150' r='2.4'/%3E%3Ccircle cx='30' cy='120' r='2'/%3E%3Ccircle cx='280' cy='20' r='2.4'/%3E%3Ccircle cx='110' cy='20' r='2'/%3E%3Ccircle cx='230' cy='230' r='2'/%3E%3Cpath d='M34 256v-26l20-5v25'/%3E%3Cellipse cx='29' cy='256' rx='5.5' ry='4.2'/%3E%3Cellipse cx='49' cy='250' rx='5.5' ry='4.2'/%3E%3Ccircle cx='150' cy='240' r='14'/%3E%3Ccircle cx='139' cy='228' r='5'/%3E%3Ccircle cx='161' cy='228' r='5'/%3E%3Cpath d='M146 245q4 3 8 0'/%3E%3Ccircle cx='145' cy='237' r='1'/%3E%3Ccircle cx='155' cy='237' r='1'/%3E%3Cpath d='M262 250l3 8 8 3-8 3-3 8-3-8-8-3 8-3z'/%3E%3C/g%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0c1317;
    --band: #0a332c;
    --panel: #111b21;
    --head: #202c33;
    --chat-bg: #0b141a;
    --bubble-in: #202c33;
    --bubble-out: #005c4b;
    --text: #e9edef;
    --text-2: #8696a0;
    --text-3: #6c7d87;
    --icon: #aebac1;
    --line: #222d34;
    --line-2: #3b4a54;
    --hover: #202c33;
    --active: #2a3942;
    --search: #202c33;
    --input: #2a3942;
    --pill: #202c33;
    --pill-ink: #8696a0;
    --pill-on: #0a332c;
    --pill-on-ink: #00a884;
    --badge: #00a884;
    --badge-ink: #111b21;
    --time-unread: #00a884;
    --meta: rgba(233, 237, 239, .6);
    --danger: #f15c6d;
    --wait: #ffad5c;
    --wait-bg: rgba(245, 124, 0, .16);
    --wait-line: #f57c00;
    --date-pill: #182229;
    --date-ink: #8696a0;
    --author: #53bdeb;
    --link: #53bdeb;
    --card: rgba(255, 255, 255, .05);
    --card-out: rgba(0, 0, 0, .14);
    --track: rgba(233, 237, 239, .22);
    --warn-bg: #3a2f12;
    --warn-ink: #ffdf8a;
    --deny-bg: rgba(241, 92, 109, .16);
    --deny-ink: #ff9aa4;
    --offline-bg: #6b5410;
    --offline-ink: #fff3c4;
    --shadow: 0 1px .5px rgba(11, 20, 26, .13);
    --shadow-2: 0 2px 5px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .3);
    --hover-ic: rgba(255, 255, 255, .07);
    --scroll: rgba(255, 255, 255, .16);
    --toast: #3b4a54;
    --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300' viewBox='0 0 300 300'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.045' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='42' cy='44' rx='14' ry='18'/%3E%3Cpath d='M42 62l-4 5h8zM42 67c-5 7 5 12 0 20s4 10 0 16'/%3E%3Cpath d='M150 18l4.6 9.4 10.4 1.5-7.5 7.3 1.8 10.3-9.3-4.9-9.3 4.9 1.8-10.3-7.5-7.3 10.4-1.5z'/%3E%3Cpath d='M246 70c-15-10-20-18-14-25 4-5 11-4 14 2 3-6 10-7 14-2 6 7 1 15-14 25z'/%3E%3Cpath d='M70 116h40a9 9 0 0 1 9 9v18a9 9 0 0 1-9 9H88l-11 9v-9h-7a9 9 0 0 1-9-9v-18a9 9 0 0 1 9-9z'/%3E%3Ccircle cx='78' cy='134' r='1.6'/%3E%3Ccircle cx='90' cy='134' r='1.6'/%3E%3Ccircle cx='102' cy='134' r='1.6'/%3E%3Crect x='196' y='148' width='36' height='28' rx='3'/%3E%3Cpath d='M192 140h44v8h-44zM214 140v36M214 140c-5-11-18-8-11 0M214 140c5-11 18-8 11 0'/%3E%3Cpath d='M24 176l7 3M128 70l3 7M266 120l-6 5M176 102l7-2M118 196l-4 7M276 206l7 1M188 270l5-6M20 290l7-3M96 262l2 7'/%3E%3Ccircle cx='160' cy='150' r='2.4'/%3E%3Ccircle cx='30' cy='120' r='2'/%3E%3Ccircle cx='280' cy='20' r='2.4'/%3E%3Ccircle cx='110' cy='20' r='2'/%3E%3Ccircle cx='230' cy='230' r='2'/%3E%3Cpath d='M34 256v-26l20-5v25'/%3E%3Cellipse cx='29' cy='256' rx='5.5' ry='4.2'/%3E%3Cellipse cx='49' cy='250' rx='5.5' ry='4.2'/%3E%3Ccircle cx='150' cy='240' r='14'/%3E%3Ccircle cx='139' cy='228' r='5'/%3E%3Ccircle cx='161' cy='228' r='5'/%3E%3Cpath d='M146 245q4 3 8 0'/%3E%3Ccircle cx='145' cy='237' r='1'/%3E%3Ccircle cx='155' cy='237' r='1'/%3E%3Cpath d='M262 250l3 8 8 3-8 3-3 8-3-8-8-3 8-3z'/%3E%3C/g%3E%3C/svg%3E");
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 var(--font);
  color: var(--text);
  background: var(--head);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 24px; height: 24px; flex: none; fill: currentColor; }
.noscript { padding: 24px; text-align: center; }

/* ---------- кнопки ---------- */
.icon-btn {
  flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; color: var(--icon);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 18px;
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-wide { width: 100%; min-height: 48px; margin-top: 18px; border-radius: 24px; font-size: 16px; }
.btn-ghost { background: var(--panel); color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost.muted { color: var(--text-2); }
@media (prefers-color-scheme: dark) { .btn-ghost { background: transparent; color: var(--accent); } }
@media (hover: hover) {
  .icon-btn:hover { background: var(--hover-ic); }
  .btn-primary:hover { background: var(--accent-2); }
  .btn-ghost:hover { background: var(--hover); }
}

/* ---------- заставка, вход ---------- */
.splash {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 24px; background: var(--head); text-align: center;
}
.splash-logo { display: block; width: 76px; height: 76px; }
.splash-name { font-size: 22px; font-weight: 700; }
.splash-text { color: var(--text-2); font-size: 15px; max-width: 320px; }
.splash .btn { margin-top: 10px; min-height: 44px; padding: 0 24px; }

.auth {
  position: fixed; inset: 0; z-index: 6; overflow-y: auto;
  display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--head);
}
.auth-card {
  width: 100%; max-width: 380px; margin: auto; padding: 28px 24px 24px;
  background: var(--panel); border-radius: 16px; box-shadow: 0 4px 24px rgba(11, 20, 26, .08);
  text-align: center;
}
.auth-logo { display: block; width: 64px; height: 64px; margin: 0 auto; }
.auth-card h1 { margin: 8px 0 4px; font-size: 22px; }
.auth-sub { margin: 0 0 8px; color: var(--text-2); font-size: 14.5px; }
.field { display: block; margin-top: 14px; text-align: left; }
.field span { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13.5px; }
.field input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--input);
  font-size: 16px; outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 168, 132, .18); }
.auth-error { margin: 12px 0 0; color: var(--danger); font-size: 14.5px; text-align: left; }
.auth-hint { margin: 14px 0 0; color: var(--text-2); font-size: 13px; }

/* ---------- каркас приложения ---------- */
/* Экран приложения неподвижен, прокручиваются список и лента, поле ввода прибито к низу — как в WhatsApp.
   Это утверждённое исключение из правила CLAUDE.md «на мобиле страница скроллится целиком» (research/06, п. 6.1–6.2).
   --app-h/--app-top ставит JS только на iPhone при открытой клавиатуре (visualViewport). */
.app {
  position: fixed; left: 0; right: 0; top: var(--app-top, 0px);
  height: 100vh;
  display: flex; flex-direction: column; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: var(--head);
}
@supports (height: 100dvh) { .app { height: var(--app-h, 100dvh); } }
.banners { flex: none; }
.banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 36px; padding: 4px 16px; font-size: 14px; text-align: center;
}
.banner .ic { width: 18px; height: 18px; }
.banner-warn { background: var(--offline-bg); color: var(--offline-ink); }
.banner-info { background: var(--accent); color: #fff; }
.banner-btn {
  min-height: 30px; padding: 0 14px; border: 1px solid rgba(255, 255, 255, .75); border-radius: 15px;
  background: none; color: #fff; font-size: 14px; font-weight: 600;
}
.panes { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }

@media (min-width: 1441px) {
  body { background: var(--page); }
  body::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 127px; background: var(--band); }
  .app {
    top: calc(var(--app-top, 0px) + 19px); height: calc(100vh - 38px);
    max-width: 1600px; margin: 0 auto; box-shadow: 0 6px 18px rgba(11, 20, 26, .06);
  }
  @supports (height: 100dvh) { .app { height: calc(var(--app-h, 100dvh) - 38px); } }
}

/* ---------- левая колонка ---------- */
.side {
  flex: 0 0 30%; min-width: 320px; max-width: 460px; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  height: 59px; padding: 0 10px 0 16px; background: var(--head);
}
/* логотип и название — кнопка «закрыть открытый диалог» (17.10.2026, МН); выглядит как раньше */
.side-brand {
  flex: 1; min-width: 0; align-self: stretch; display: flex; align-items: center; gap: 10px;
  padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.side-brand:focus-visible { outline-offset: -2px; border-radius: 8px; }
.side-logo { display: block; width: 30px; height: 30px; flex: none; }
.side-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.demo-pill {
  padding: 1px 7px; border-radius: 9px; background: var(--wait-bg); color: var(--wait);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

.search { flex: none; padding: 7px 12px 8px; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 4px 0 12px; border-radius: 8px;
  background: var(--search); color: var(--text-2);
}
.search-box .ic { width: 18px; height: 18px; }
.search-box input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0;
  background: transparent; font-size: 15px;
}
.search-box input::placeholder { color: var(--text-2); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: none; color: var(--text-2);
}
.search-clear .ic { width: 18px; height: 18px; }

.filters {
  flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px;
}
.filters::-webkit-scrollbar { display: none; }
.pill { flex: none; height: 32px; padding: 0; border: 0; background: none; border-radius: 16px; }
.pill-in {
  display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 12px; border-radius: 16px;
  background: var(--pill); color: var(--pill-ink); font-size: 14px; white-space: nowrap;
}
.pill.on .pill-in { background: var(--pill-on); color: var(--pill-on-ink); font-weight: 600; }
.pill-n:empty { display: none; }
.pill-n { font-weight: 600; }
.pill[data-filter="waiting"]:not(.on) .pill-n { color: var(--wait); }
@media (hover: hover) { .pill:not(.on):hover .pill-in { background: var(--hover-ic); } }

.numwarn { flex: none; display: flex; flex-direction: column; gap: 6px; margin: 0 12px 8px; }
.numwarn-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 13.5px; line-height: 1.35;
}
.numwarn-item .ic { width: 18px; height: 18px; margin-top: 1px; color: #e8a400; }
.numwarn-item b { font-weight: 600; }
.numwarn-item a { color: inherit; font-weight: 600; text-decoration: underline; }   /* 17.10.2026: ссылка на страницу номеров */

/* уведомления запрещены в браузере — заметно и постоянно, пока не включат */
.notif-warn {
  flex: none; display: flex; align-items: center; gap: 10px; margin: 0 12px 8px; padding: 6px 4px 6px 12px;
  border-radius: 8px; background: var(--deny-bg); color: var(--deny-ink); font-size: 13.5px; line-height: 1.35;
}
.notif-warn .ic { width: 20px; height: 20px; flex: none; }
.notif-warn-text { flex: 1; min-width: 0; font-weight: 600; }
.notif-warn .notif-warn-btn { flex: none; color: var(--deny-ink); text-decoration: underline; text-underline-offset: 2px; }

.chatlist {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom);
  scrollbar-width: thin; scrollbar-color: var(--scroll) transparent;
}
.list-empty { flex: 1 1 auto; padding: 32px 24px; color: var(--text-2); text-align: center; font-size: 14.5px; }

/* строка чата */
.row {
  position: relative; display: flex; align-items: center; gap: 13px;
  min-height: 72px; padding: 0 14px 0 13px;
  color: inherit; text-decoration: none; cursor: pointer;
  --ring: var(--panel);
}
/* свайп влево (17.10.2026): строка уезжает на ширину кнопок, кнопки прикреплены к её правому краю */
.chatlist { overflow-x: hidden; }
.row { touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; transition: transform .2s ease; }
.row img { -webkit-user-drag: none; }
.row-acts { position: absolute; top: 0; bottom: 0; left: 100%; width: 176px; display: flex; }
.row-act {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: #fff; font-size: 13px; font-weight: 600; line-height: 16px; cursor: pointer;
}
.row-act .ic { width: 22px; height: 22px; }
.row-act.arch { background: #4a7fd4; }
.row-act.del { background: var(--danger); }
.row.on { background: var(--active); --ring: var(--active); }
@media (hover: hover) { .row:not(.on):hover { background: var(--hover); --ring: var(--hover); } }
.row.waiting::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--wait-line);
}
.row-main {
  flex: 1; min-width: 0; align-self: stretch;
  display: flex; flex-direction: column; justify-content: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.row:last-child .row-main { border-bottom-color: transparent; }
.row-top, .row-bot, .row-sub { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row-name {
  flex: 1; min-width: 0; font-size: 16.5px; line-height: 22px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-time { flex: none; font-size: 12px; line-height: 16px; color: var(--text-2); }
.row.unread .row-time { color: var(--time-unread); font-weight: 600; }
.row-bot { margin-top: 1px; }
.row-prev {
  flex: 1; min-width: 0; display: block; font-size: 14px; line-height: 20px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row.unread .row-prev { color: var(--text); }
.row-prev .tk { width: 18px; height: 12px; vertical-align: -1px; margin-right: 3px; }
.row-prev .tk-wait, .row-prev .tk-err { width: 14px; height: 14px; vertical-align: -2px; }
.badge {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--badge); color: var(--badge-ink); font-size: 12px; font-weight: 700;
}
.row-sub { margin-top: 2px; container: rowsub / inline-size; }
/* наши номера: части («WhatsApp +7 921 612-75-02», «· Telegram 600-04-98») — целиком; не влезла — уходит на
   вторую, скрытую строку, а не режется посередине (17.10.2026). Слишком длинная первая — с многоточием */
/* 17.10.2026 (МН: «что за обрубок номера торчит… номер пусть будет»): наш номер в строке списка — всегда целиком.
   Строка номеров не сжимается уже первого номера (min-width по содержимому), места мало — сжимается серая плашка;
   следующие номера («· Telegram 600-04-98») не влезли — уходят на вторую, скрытую строку целиком */
.row-num {
  flex: 1 1 auto; min-width: min-content; display: flex; flex-wrap: wrap; column-gap: .35em; height: 17px; overflow: hidden;
  font-size: 12px; line-height: 17px; color: var(--text-3);
}
.row-num > span, .peer-sub > span { white-space: nowrap; }
.peer-sub > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wait-pill {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  height: 18px; padding: 0 7px; border-radius: 9px;
  background: var(--wait-bg); color: var(--wait); font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.wait-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--wait-line); }
/* «сделка удалена» — серая, слева от «ждёт ответа» (17.10.2026, МН: сделку удалили в amoCRM) */
.gone-pill {
  flex: none; display: inline-flex; align-items: center;
  height: 18px; padding: 0 7px; border-radius: 9px;
  background: rgba(134, 150, 160, .2); color: var(--text-2); font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.done-mark { flex: none; font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
/* узкий список (769–1024 px): серая плашка сжимается с многоточием */
.row-sub .gone-pill, .row-bot .gone-pill { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: 18px; }
/* узкий телефон: две плашки не съедают наш номер */
@media (max-width: 400px) { .row-sub { gap: 4px; } .gone-pill, .wait-pill { padding: 0 5px; font-size: 11px; } .wait-pill { gap: 3px; } }
/* очень узкая строка (окно в пол-экрана рядом с amoCRM): от «ждёт ответа» — оранжевая точка (строка и так отмечена
   полосой слева): номер целиком важнее (17.10.2026). После правил плашки — иначе они перебивают */
@container rowsub (max-width: 270px) { .row-sub .wait-pill { gap: 0; padding: 0 6px; font-size: 0; } }

/* аватарки */
.av-wrap { position: relative; flex: none; width: 49px; height: 49px; }
.av {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--av, #8696a0); color: #fff; font-size: 20px; font-weight: 600; user-select: none;
}
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mbadge {
  position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 0 0 2px var(--ring);
}
.mbadge.wa { background: var(--wa); }
.mbadge.tg { background: var(--tg); }
.mbadge .ic { width: 12px; height: 12px; }
/* у клиента и WhatsApp, и Telegram — два значка рядом внизу справа, чуть внахлёст (17.10.2026) */
.mbadges { position: absolute; right: -6px; bottom: -6px; display: flex; }   /* ниже буквы: не касаются её */
.mbadges .mbadge { position: relative; right: auto; bottom: auto; width: 18px; height: 18px; }
.mbadges .mbadge + .mbadge { margin-left: -3px; }
.mbadges .mbadge .ic { width: 11px; height: 11px; }
/* значок канала в кружке: у времени в пузыре, в «Ответ через», в списке номеров */
.chan {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; color: #fff;
}
.chan.wa { background: var(--wa); }
.chan.tg { background: var(--tg); }
.chan .ic { width: 10px; height: 10px; }

/* ---------- правая колонка ---------- */
.conv {
  position: relative; flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; background: var(--head);
  container-type: inline-size; container-name: conv;
}
.conv-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px; text-align: center; border-bottom: 6px solid var(--accent);
}
.conv-empty-logo { display: block; width: 96px; height: 96px; }
.conv-empty h2 { margin: 18px 0 8px; font-size: 28px; font-weight: 300; }
.conv-empty p { max-width: 460px; margin: 0; color: var(--text-2); font-size: 14px; line-height: 20px; }
.conv-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.conv-head {
  position: relative; z-index: 3; flex: none;
  display: flex; align-items: center; gap: 10px;
  height: 59px; padding: 0 16px; background: var(--head);
  border-left: 1px solid var(--line);
  --ring: var(--head);
}
.back-btn { display: none; margin-left: -6px; }
.peer {
  flex: 1 1 auto; min-width: 0; height: 100%;
  display: flex; align-items: center; gap: 13px;
  padding: 0; border: 0; background: none; color: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.peer .av-wrap { width: 40px; height: 40px; }
.peer .av { font-size: 17px; }
.peer .mbadge { width: 17px; height: 17px; right: -3px; bottom: -3px; }
.peer .mbadge .ic { width: 10px; height: 10px; }
.peer .mbadges { right: -5px; bottom: -5px; }
.peer .mbadges .mbadge { width: 16px; height: 16px; right: auto; bottom: auto; }
.peer .mbadges .mbadge .ic { width: 9px; height: 9px; }
.peer-text { min-width: 0; display: flex; flex-direction: column; }
.peer-name { font-size: 16px; line-height: 21px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-sub { display: flex; flex-wrap: wrap; column-gap: .35em; height: 19px; overflow: hidden; font-size: 13px; line-height: 19px; color: var(--text-2); }
.peer-sub:empty { display: none; }
.head-actions { flex: none; display: flex; align-items: center; gap: 10px; }
.head-done { display: flex; align-items: center; gap: 8px; }
.head-done:empty { display: none; }
.done-btn { background: var(--panel); color: var(--wait); box-shadow: inset 0 0 0 1px var(--wait-line); }
@media (prefers-color-scheme: dark) { .done-btn { background: transparent; } }
@media (hover: hover) { .done-btn:hover { background: var(--wait-bg); } }
.done-state { display: flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 13.5px; white-space: nowrap; }
.done-state .ic { width: 18px; height: 18px; color: var(--accent); }
.link-btn {
  min-height: 32px; padding: 0 6px; border: 0; border-radius: 6px; background: none;
  color: var(--accent-2); font-size: 13.5px; font-weight: 600;
}
@media (prefers-color-scheme: dark) { .link-btn { color: var(--accent); } }
@media (hover: hover) { .link-btn:hover { background: var(--hover-ic); } }
.deal-btn .ic { width: 16px; height: 16px; }
.deal-short { display: none; }

.done-strip {
  display: none; flex: none; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 48px; padding: 2px 8px 2px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); font-size: 14px; color: var(--text-2);
}
.done-strip.is-waiting { background: var(--wait-bg); color: var(--wait); }
.done-strip .done-btn { min-height: 40px; }
.done-strip .txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.done-strip .txt .ic { width: 18px; height: 18px; }

@container conv (max-width: 700px) {
  .head-done { display: none; }
  .done-strip:not([hidden]) { display: flex; }
  .deal-long { display: none; }
  .deal-short { display: inline; }
}

/* ---------- переписка ---------- */
.msgs-wrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  background-color: var(--chat-bg); background-image: var(--pattern); background-size: 300px 300px;
  border-left: 1px solid var(--line);
}
.msgs {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overflow-anchor: none;
  display: flex; flex-direction: column;
  padding: 6px clamp(12px, 6.5%, 72px) 14px; outline: none; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--scroll) transparent;
}
/* короткая переписка прижата к полю ввода, как в WhatsApp */
.msgs > :first-child { margin-top: auto; }
.msgs > * { flex: none; }
.msgs-loading { display: flex; justify-content: center; padding: 10px 0 2px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--track); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.history-start { display: flex; justify-content: center; margin: 8px 0 4px; }
.history-start span, .day-sep span, .unread-sep span {
  padding: 5px 12px 6px; border-radius: 7.5px; background: var(--date-pill); color: var(--date-ink);
  font-size: 12.5px; line-height: 16px; box-shadow: var(--shadow); text-align: center;
}
.history-start span { max-width: 420px; }
.day { position: relative; }
.day-sep { position: sticky; top: 8px; z-index: 2; display: flex; justify-content: center; margin: 10px 0 6px; pointer-events: none; }
.unread-sep { display: flex; justify-content: center; margin: 14px 0 6px; }
.unread-sep span { color: var(--accent-2); font-weight: 600; }
@media (prefers-color-scheme: dark) { .unread-sep span { color: var(--accent); } }

.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 2px; }
.msg.out { align-items: flex-end; }
.msg.first { margin-top: 10px; }
.bubble {
  position: relative; max-width: min(65%, 620px); min-width: 0;
  padding: 6px 7px 8px 9px; border-radius: 7.5px;
  background: var(--bubble-in); box-shadow: var(--shadow);
  font-size: 14.2px; line-height: 19px; overflow-wrap: anywhere; word-break: break-word;
  --meta-w: 40px;
}
.msg.out .bubble { background: var(--bubble-out); --meta-w: 66px; }
.msg.first.in .bubble { border-top-left-radius: 0; }
.msg.first.out .bubble { border-top-right-radius: 0; }
.msg.first .bubble::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px;
}
.msg.first.in .bubble::before { left: -8px; background: var(--bubble-in); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg.first.out .bubble::before { right: -8px; background: var(--bubble-out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.author {
  margin: -1px 0 2px; font-size: 12.5px; line-height: 17px; font-weight: 600; color: var(--author);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg:not(.first) .author { display: none; }
/* подпись и автор не растягивают пузырь шире картинки или карточки */
.bubble.media-b, .bubble.card-b.has-text { width: min-content; }
.bubble.media-b .author, .bubble.card-b .author { width: 0; min-width: 100%; }
.no-amo {
  margin-right: 3px; padding: 0 5px; border-radius: 4px; background: var(--track); color: var(--text-2);
  font-size: 10.5px; line-height: 15px; cursor: help;
}
.bubble.no-amo-b { --meta-w: 118px; }
.msg.out .bubble.no-amo-b { --meta-w: 144px; }
.text { white-space: pre-wrap; }
.text::after { content: ""; display: inline-block; width: var(--meta-w); height: 1px; }
.text a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.note { display: flex; align-items: flex-start; gap: 6px; color: var(--text-2); font-style: italic; }
.note .ic { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.note > span::after { content: ""; display: inline-block; width: var(--meta-w); height: 1px; }
.bubble.card-b .note > span::after { display: none; }
.meta {
  position: absolute; right: 7px; bottom: 3px;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; line-height: 15px; color: var(--meta); white-space: nowrap;
}
.tk { width: 18px; height: 12px; color: var(--meta); }
.tk-read { color: var(--read); }
.tk-wait { width: 13px; height: 13px; }
.tk-err { width: 15px; height: 15px; color: var(--danger); }
.meta .tk { margin-left: 1px; }
/* канал сообщения у времени (у клиента больше одного чата, 17.10.2026): место под него в конце текста — шире на значок */
.meta .chan { width: 14px; height: 14px; margin-right: 1px; }
.meta .chan .ic { width: 9px; height: 9px; }
.bubble.chan-b .text::after, .bubble.chan-b .note > span::after { width: calc(var(--meta-w) + 17px); }

/* вложения */
.bubble.media-b { padding: 3px 3px 4px; }
.bubble.media-b .author { margin: 2px 6px 3px; }
.bubble.media-b .text { display: block; padding: 4px 4px 2px 6px; }
.mediabox {
  position: relative; display: block; width: var(--mw, 260px); max-width: 100%;
  border-radius: 6px; overflow: hidden; background: var(--track);
}
.mediabox img, .mediabox video { display: block; width: 100%; height: auto; max-height: 380px; object-fit: cover; }
.mediabox.loading img { min-height: 180px; }
.pic { padding: 0; border: 0; background: none; cursor: zoom-in; }
.meta.over {
  right: 9px; bottom: 9px; padding: 0 5px; border-radius: 9px;
  background: rgba(11, 20, 26, .45); color: #fff;
}
.meta.over .tk { color: #fff; }
.meta.over .tk-read { color: #8fdcff; }
.media-progress { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .45); overflow: hidden; }
.media-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.msg.sticker .bubble { background: none; box-shadow: none; padding: 0; }
.msg.sticker .bubble::before { display: none; }
.sticker-img { display: block; width: 150px; height: 150px; object-fit: contain; cursor: zoom-in; }
.msg.sticker .meta { position: static; float: right; margin-top: 2px; padding: 1px 6px; border-radius: 8px; background: var(--date-pill); box-shadow: var(--shadow); }

.bubble.card-b { padding-bottom: 22px; }
.bubble.card-b.has-text { padding-bottom: 8px; }
.voice { display: flex; align-items: center; gap: 10px; width: 270px; max-width: 100%; padding: 2px 2px 0 0; }
.vplay {
  flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff;
}
.vplay .ic { width: 22px; height: 22px; }
.vbar { position: relative; flex: 1; height: 28px; cursor: pointer; touch-action: none; }
.vtrack { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.vfill { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); }
.vknob { position: absolute; top: 8px; left: var(--p, 0%); width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--accent); }
.vtime { position: absolute; left: 59px; bottom: 4px; font-size: 11px; line-height: 15px; color: var(--meta); }
.vfail { font-size: 13px; }

.filecard {
  display: flex; align-items: center; gap: 10px; width: 300px; max-width: 100%;
  padding: 10px; border-radius: 6px; background: var(--card); color: inherit; text-decoration: none;
}
.msg.out .filecard { background: var(--card-out); }
.fic { position: relative; flex: none; width: 34px; height: 40px; color: var(--icon); }
.fic .ic { width: 34px; height: 40px; }
.fext {
  position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%);
  padding: 0 3px; border-radius: 3px; background: var(--accent-2); color: #fff;
  font-size: 8.5px; line-height: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap;
}
.finfo { flex: 1; min-width: 0; }
.fname { display: block; font-size: 14.2px; line-height: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsize { display: block; font-size: 12px; line-height: 16px; color: var(--text-2); }
.fdl {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: var(--icon);
  box-shadow: inset 0 0 0 1.5px var(--line-2);
}
.fdl .ic { width: 18px; height: 18px; }

.loc { display: block; width: 270px; max-width: 100%; color: inherit; text-decoration: none; }
.loc-map {
  position: relative; height: 130px; border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: var(--danger);
  background-color: #e8eee4;
  background-image:
    linear-gradient(rgba(255, 255, 255, .9) 3px, transparent 3px),
    linear-gradient(90deg, rgba(255, 255, 255, .9) 3px, transparent 3px),
    linear-gradient(35deg, transparent 47%, #f7d58a 47%, #f7d58a 53%, transparent 53%);
  background-size: 46px 46px, 46px 46px, 100% 100%;
}
@media (prefers-color-scheme: dark) {
  .loc-map {
    background-color: #1f2c26;
    background-image:
      linear-gradient(rgba(255, 255, 255, .08) 3px, transparent 3px),
      linear-gradient(90deg, rgba(255, 255, 255, .08) 3px, transparent 3px),
      linear-gradient(35deg, transparent 47%, #5c4a1d 47%, #5c4a1d 53%, transparent 53%);
  }
}
.loc-map .ic { width: 40px; height: 40px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.loc-caption { padding: 6px 4px 0; font-size: 14.2px; line-height: 19px; }
.loc-link { display: block; padding: 2px 4px 0; color: var(--link); font-size: 13.5px; }

.contact { display: flex; align-items: center; gap: 10px; width: 250px; max-width: 100%; padding: 4px 2px 2px; }
.contact .av-wrap { width: 44px; height: 44px; }
.contact .av { font-size: 18px; }
.contact-info { min-width: 0; }
.contact-name { font-size: 15px; line-height: 20px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-phone { font-size: 14px; line-height: 20px; }

.msg-err {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 2px 8px;
  max-width: min(65%, 620px); margin: 3px 2px 0; color: var(--danger); font-size: 12.5px; line-height: 16px; text-align: right;
}
.msg-err .ic { width: 15px; height: 15px; }
.msg-err .err-line { display: inline-flex; align-items: flex-start; gap: 5px; min-width: 0; }
.msg-err .err-line .ic { margin-top: 1px; }
.msg-err .err-hint { flex-basis: 100%; font-weight: 600; }
.msg-err .link-btn { min-height: 28px; font-size: 13px; }

.to-bottom {
  position: absolute; right: 18px; bottom: 16px; z-index: 4;
  width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--icon); box-shadow: 0 1px 3px rgba(11, 20, 26, .4);
}
.to-bottom-n {
  position: absolute; top: -7px; right: -4px; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--badge); color: var(--badge-ink); font-size: 12px; font-weight: 700;
}
.drop-zone {
  position: absolute; inset: 10px; z-index: 6; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: 14px; background: rgba(0, 168, 132, .12);
  color: var(--accent-2); font-size: 18px; font-weight: 600; pointer-events: none;
}
@media (prefers-color-scheme: dark) { .drop-zone { color: var(--accent); background: rgba(0, 168, 132, .16); } }

/* ---------- поле ввода ---------- */
.composer {
  flex: none; padding: 5px 10px calc(5px + env(safe-area-inset-bottom));
  background: var(--head); border-left: 1px solid var(--line);
}
.kb-open .composer { padding-bottom: 5px; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.attach-btn { width: 42px; height: 42px; }
.input-box {
  flex: 1; min-width: 0; display: flex; align-items: center;
  min-height: 42px; padding: 0 12px; border-radius: 8px; background: var(--input);
}
#input {
  flex: 1; min-width: 0; display: block; height: 20px; max-height: 120px; margin: 11px 0; padding: 0;
  border: 0; outline: 0; resize: none; background: transparent;
  font-size: 15px; line-height: 20px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--scroll) transparent;
}
#input::placeholder { color: var(--text-2); }
.send-btn {
  flex: none; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: none; color: var(--icon); transition: background-color .15s, color .15s;
}
.send-btn.ready { background: var(--accent); color: #fff; }
.send-btn .ic { width: 23px; height: 23px; margin-left: 2px; }
@media (hover: hover) { .send-btn.ready:hover { background: var(--accent-2); } }

/* «Ответ через: [значок] WhatsApp · +7 921 612-75-02 ▾» над полем ввода — у клиента больше одного чата (17.10.2026).
   Нажатие раскрывает список его чатов прямо здесь, в потоке, над кнопкой (кнопка остаётся под пальцем и курсором):
   ничего не всплывает поверх и не уезжает с клавиатурой */
.via-bar { display: flex; flex-direction: column-reverse; align-items: flex-start; padding: 0 0 5px; }
.via-btn {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 30px; padding: 0 8px 0 11px;
  border: 0; border-radius: 15px; background: var(--input); box-shadow: var(--shadow);
  color: var(--text-2); font-size: 13px; line-height: 18px; text-align: left;
}
.via-lbl { flex: none; }
.via-cur { min-width: 0; display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 600; }
.via-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.via-chev { width: 18px; height: 18px; color: var(--icon); transition: transform .15s; }
.via-btn[aria-expanded="true"] .via-chev { transform: rotate(180deg); }
.via-list {
  display: flex; flex-direction: column; gap: 2px; align-self: stretch; max-width: 480px; max-height: 40vh; overflow-y: auto;
  margin: 0 0 6px; padding: 4px; border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-2);
}
.via-item {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 5px 10px;
  border: 0; border-radius: 9px; background: none; color: var(--text); font-size: 14.5px; line-height: 19px; text-align: left;
}
.via-item .chan { width: 24px; height: 24px; }
.via-item .chan .ic { width: 14px; height: 14px; }
.via-item.on { background: var(--active); }
.via-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.via-item-name { overflow-wrap: anywhere; }
.via-item-txt small { color: var(--text-2); font-size: 12.5px; line-height: 16px; }
.via-check { width: 20px; height: 20px; color: var(--accent); }
@media (hover: hover) {
  .via-btn:hover { box-shadow: var(--shadow), inset 0 0 0 100px var(--hover-ic); }
  .via-item:not(.on):hover { background: var(--hover); }
}

.tray { display: flex; gap: 8px; padding: 4px 0 8px; overflow-x: auto; scrollbar-width: thin; }
.tray-item {
  flex: none; display: flex; align-items: center; gap: 8px; max-width: 240px; height: 52px; padding: 4px 0 4px 4px;
  border-radius: 10px; background: var(--panel); box-shadow: var(--shadow);
}
.tray-thumb {
  flex: none; width: 44px; height: 44px; border-radius: 7px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: var(--track); color: var(--icon);
}
.tray-thumb img, .tray-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-thumb .ic { width: 24px; height: 24px; }
.tray-info { min-width: 0; }
.tray-name { font-size: 13px; line-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-size { font-size: 11.5px; line-height: 15px; color: var(--text-2); }
.tray-x { width: 40px; height: 44px; border-radius: 8px; color: var(--text-2); }
.tray-x .ic { width: 18px; height: 18px; }

/* ---------- меню, подсказки, просмотр ---------- */
.menu {
  position: fixed; z-index: 50; min-width: 250px; max-width: calc(100vw - 16px); padding: 6px 0;
  border-radius: 10px; background: var(--panel); box-shadow: var(--shadow-2);
  transform-origin: top right; animation: pop .14s ease-out;
  overflow-y: auto; overscroll-behavior: contain;   /* высоту ставит JS: телефон боком — пункты прокручиваются */
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
.menu-me { padding: 8px 20px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 13px; }
.menu-me b { display: block; color: var(--text); font-size: 15px; font-weight: 600; }
.menu-me .menu-login { display: block; margin-top: 1px; color: var(--text-2); font-size: 13px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 44px; padding: 0 20px;
  border: 0; background: none; color: var(--text); font-size: 14.5px; text-align: left;
}
.menu-item .ic { width: 20px; height: 20px; color: var(--icon); }
.menu-item.ok .ic { color: var(--accent); }
.menu-item.menu-danger, .menu-item.menu-danger .ic { color: var(--danger); }
@media (hover: hover) { .menu-item:hover { background: var(--hover); } }

.sheet-back {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(11, 20, 26, .55);
}
.sheet { width: 100%; max-width: 420px; padding: 22px 22px 20px; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow-2); }
@media (prefers-color-scheme: dark) { .sheet { background: #233138; } }
.sheet h2 { margin: 0 0 10px; font-size: 19px; }
.sheet ol { margin: 0; padding-left: 22px; line-height: 1.6; }
.sheet-note { margin: 12px 0 0; color: var(--text-2); font-size: 13.5px; }
.help-list { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.45; }
.help-list li { margin: 8px 0; }

/* просьба включить уведомления */
.notify-sheet { max-width: 400px; padding: 28px 24px 16px; text-align: center; }
.notify-badge {
  width: 68px; height: 68px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--pill-on); color: var(--accent-2);
}
@media (prefers-color-scheme: dark) { .notify-badge { color: var(--accent); } }
.notify-badge .ic { width: 36px; height: 36px; }
.notify-sheet h2 { margin: 0 0 8px; font-size: 21px; }
.notify-sheet p { margin: 0 0 4px; color: var(--text-2); font-size: 15.5px; line-height: 1.45; }
.notify-on { min-height: 52px; font-size: 17px; }
.btn-quiet { min-height: 44px; margin-top: 6px; background: none; color: var(--text-2); font-size: 15px; font-weight: 600; }
@media (hover: hover) { .btn-quiet:hover { background: var(--hover); } }

/* «Сохранить в библиотеку» (17.10.2026): кружок сбоку от пузыря с вложением — у входящих справа, у своих слева;
   с мышью виден при наведении на сообщение, на сенсорном экране — всегда (зона пальца 44 px) */
.tolib {
  position: absolute; top: 50%; right: -42px; width: 32px; height: 32px; margin-top: -16px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--panel); color: var(--icon); box-shadow: var(--shadow); cursor: pointer;
}
.msg.out .tolib { right: auto; left: -42px; }
.tolib .ic { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .tolib { opacity: 0; transition: opacity .15s; }
  .msg:hover .tolib, .tolib:focus-visible { opacity: 1; }
  .tolib:hover { color: var(--accent-2); }
}
@media (max-width: 768px), (pointer: coarse) { .tolib::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; } }
/* лист выбора папки */
.tolib-sheet { max-width: 440px; max-height: min(80vh, 640px); display: flex; flex-direction: column; }
.tolib-what { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.tolib-note { margin: 8px 0 0; color: var(--danger); font-size: 14px; font-weight: 600; }
.tolib-list { flex: 1 1 auto; min-height: 0; margin: 10px -8px 0; overflow-y: auto; }
.tolib-row {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font-size: 15px; text-align: left; cursor: pointer;
}
.tolib-row .ic { flex: none; width: 20px; height: 20px; color: var(--icon); }
.tolib-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tolib-row.on { background: var(--pill-on); color: var(--pill-on-ink); font-weight: 600; }
.tolib-row.on .ic { color: inherit; }
@media (hover: hover) { .tolib-row:not(.on):hover { background: var(--hover); } }
.tolib-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.tolib-btns .btn { min-height: 44px; margin-top: 0; padding: 0 18px; border-radius: 22px; }

.viewer {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  padding: calc(60px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background: rgba(11, 20, 26, .94); cursor: zoom-out; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }
.viewer-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));   /* боком — не под вырезом */
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .14); color: #fff;
}

.toasts {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 80; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 8px; background: var(--toast); color: #fff;
  font-size: 14px; line-height: 19px; text-align: center; box-shadow: var(--shadow-2); animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.tip {
  position: fixed; z-index: 81; max-width: 260px; padding: 8px 12px; border-radius: 8px;
  background: var(--toast); color: #fff; font-size: 13.5px; line-height: 18px; box-shadow: var(--shadow-2);
  pointer-events: none; animation: toast-in .15s ease-out;
}

/* ---------- планшет: список уже ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
  .side { flex: 0 0 300px; min-width: 0; max-width: none; }
  .msgs { padding-left: 16px; padding-right: 16px; }
}

/* ---------- сенсорный экран (телефон и планшет): всё, во что тычут пальцем, — не меньше 44 px, поля — 16 px ---------- */
@media (max-width: 768px), (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .banner-btn { min-height: 44px; border-radius: 22px; }
  .vbar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; margin-top: -22px; }   /* ползунок: зона пальца 44 px */
  .search-box { height: 44px; padding-right: 2px; }
  .search-box input { font-size: 16px; }
  .search-clear { width: 44px; height: 44px; }
  .pill { height: 44px; }
  .pill-in { height: 34px; padding: 0 13px; border-radius: 17px; font-size: 14.5px; }
  .filters { row-gap: 0; }
  .deal-btn, .head-done .btn { min-height: 44px; padding: 0 12px; border-radius: 22px; }
  .done-strip { min-height: 52px; padding: 4px 6px 4px 14px; }
  .done-strip .done-btn, .done-strip .link-btn { min-height: 44px; }
  .link-btn, .msg-err .link-btn { min-height: 44px; }
  .vplay { width: 44px; height: 44px; }
  .vtime { left: 63px; }
  .fdl { width: 44px; height: 44px; }
  .to-bottom { width: 44px; height: 44px; }
  .attach-btn, .send-btn { width: 44px; height: 44px; }
  .input-box { min-height: 44px; border-radius: 22px; padding: 0 14px; }
  #input { font-size: 16px; line-height: 22px; height: 22px; max-height: 132px; margin: 11px 0; }
  .tray-x { width: 44px; }
  .via-btn { min-height: 44px; border-radius: 22px; padding: 0 10px 0 14px; font-size: 14px; }
  .via-item { min-height: 52px; font-size: 15.5px; }
}

/* ---------- узкий список (телефон, планшет): фильтры в одну строку с прокруткой ---------- */
/* лента фильтров с прокруткой — только для пальца: мышью колесо её не двигает, и последние фильтры были недоступны
   в окне 769–1024 px (пол-экрана рядом с amoCRM). С мышью фильтры переносятся, как на широком экране */
@media (max-width: 1024px) and (hover: none) {
  .filters {
    flex-wrap: nowrap; gap: 3px; padding: 0 16px 4px 12px; overflow-x: auto; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
  }
  /* 17.10.2026: без «WhatsApp» / «Telegram» четыре фильтра целиком влезают в 412 px (телефон МН); уже — лента едет */
  .pill-in { padding: 0 10px; font-size: 14px; }
}

/* ---------- телефон: одна колонка ---------- */
@media (max-width: 768px) {
  body { font-size: 16px; }
  .side { flex: 1 1 auto; min-width: 0; max-width: none; border-right: 0; }
  .side-head { height: 56px; padding: 0 6px 0 14px; }
  .row { min-height: 76px; }

  .conv {
    position: absolute; inset: 0; z-index: 2;
    transform: translateX(100%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  .app.chat-open .conv { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
  .conv-empty { display: none; }
  .conv-head { height: 56px; padding: 0 8px 0 4px; gap: 4px; border-left: 0; }
  .back-btn { display: inline-flex; margin-left: 0; }
  .peer { gap: 10px; }
  .head-actions { gap: 4px; }
  .msgs-wrap, .composer { border-left: 0; }
  .msgs { padding: 4px 12px 12px; }
  .bubble { max-width: 85%; font-size: 15.5px; line-height: 21px; }
  .msg-err { max-width: 85%; }
  .meta { font-size: 11.5px; }
  .to-bottom { right: 12px; }
  .composer { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .kb-open .composer { padding-bottom: 6px; }
  .composer-row { gap: 4px; }
  .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* большой телефон и маленький планшет в одну колонку: пузыри не на всю ширину */
@media (min-width: 481px) and (max-width: 768px) {
  .bubble, .msg-err { max-width: 75%; }
}

/* ═════════════════════════ Библиотека и меню скрепки (2026-10-16.5) ═════════════════════════ */

/* ---------- меню скрепки ---------- */
.attach-menu { position: fixed; z-index: 55; }
.attach-panel {
  display: flex; flex-direction: column; gap: 2px; width: 304px; padding: 8px;
  border-radius: 18px; background: var(--panel);
  box-shadow: 0 14px 38px rgba(11, 20, 26, .22), 0 2px 6px rgba(11, 20, 26, .12);
  opacity: 0; transform: translateY(10px) scale(.97); transform-origin: bottom left;
  transition: opacity .15s ease-out, transform .18s cubic-bezier(.2, .8, .2, 1);
}
.attach-menu.shown .attach-panel { opacity: 1; transform: none; }
.attach-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 7px 10px;
  border: 0; border-radius: 13px; background: none; color: var(--text); text-align: left;
}
@media (hover: hover) { .attach-item:hover { background: var(--hover); } }
.attach-ic {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.attach-ic .ic { width: 23px; height: 23px; }
.attach-lib { margin-bottom: 4px; background: linear-gradient(100deg, rgba(43, 212, 107, .14), rgba(245, 124, 0, .1)); }
.attach-lib .attach-ic {
  width: 52px; height: 52px;
  background: linear-gradient(140deg, #2bd46b, #0e9a4c 55%, #f57c00);
  box-shadow: 0 8px 18px rgba(30, 158, 90, .35);
}
.attach-lib .attach-ic .ic { width: 27px; height: 27px; }
.attach-media .attach-ic { background: linear-gradient(140deg, #38bdf8, #6366f1); }
.attach-file .attach-ic { background: linear-gradient(140deg, #c084fc, #7c3aed); }
.attach-txt { min-width: 0; display: flex; flex-direction: column; }
.attach-txt b { font-size: 15px; font-weight: 600; line-height: 20px; }
.attach-lib .attach-txt b { font-size: 16.5px; }
.attach-txt small { color: var(--text-2); font-size: 12.5px; line-height: 17px; }
/* телефон: лист снизу с крупными кругами */
.attach-menu.sheet-mode { inset: 0; display: flex; align-items: flex-end; background: rgba(11, 20, 26, 0); transition: background .18s; }
.attach-menu.sheet-mode.shown { background: rgba(11, 20, 26, .4); }
.sheet-mode .attach-panel {
  width: 100%; flex-direction: row; justify-content: space-around; gap: 4px;
  padding: 22px 10px calc(22px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0;
  transform: translateY(100%); opacity: 1;
}
.sheet-mode .attach-item { flex: 1; flex-direction: column; gap: 9px; min-width: 0; min-height: 0; padding: 4px 2px; text-align: center; background: none; }
.sheet-mode .attach-ic { width: 60px; height: 60px; }
.sheet-mode .attach-lib .attach-ic { width: 66px; height: 66px; margin-top: -3px; }
.sheet-mode .attach-ic .ic { width: 28px; height: 28px; }
.sheet-mode .attach-txt b { font-size: 14px; }
.sheet-mode .attach-txt small { display: none; }

/* ---------- окно ---------- */
.lib-back {
  position: fixed; inset: 0; z-index: 65; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(11, 20, 26, 0); transition: background .2s;
}
.lib-back.shown { background: rgba(11, 20, 26, .45); }
.lib {
  --acc: #8b5cf6; --acc-2: #b49bff; --acc-soft: rgba(139, 92, 246, .13); --acc-ink: #6d3fe0;
  position: relative; display: flex; flex-direction: column;
  width: min(980px, 100%); height: min(720px, 100%); overflow: hidden; outline: none;
  border-radius: 22px; background: var(--panel);
  box-shadow: 0 28px 70px rgba(11, 20, 26, .38), 0 2px 10px rgba(11, 20, 26, .2);
  opacity: 0; transform: translateY(16px) scale(.975);
  transition: opacity .18s ease-out, transform .24s cubic-bezier(.2, .8, .2, 1);
}
.lib-back.shown .lib { opacity: 1; transform: none; }
.lib[data-sec="video"] { --acc: #f43f5e; --acc-2: #ff8aa0; --acc-soft: rgba(244, 63, 94, .13); --acc-ink: #d61f4a; }
.lib[data-sec="photo"] { --acc: #0ea5e9; --acc-2: #6fd0ff; --acc-soft: rgba(14, 165, 233, .14); --acc-ink: #0284c7; }
.lib[data-sec="docs"] { --acc: #f59e0b; --acc-2: #ffd166; --acc-soft: rgba(245, 158, 11, .16); --acc-ink: #c2700a; }
@media (prefers-color-scheme: dark) {
  .lib { --acc-ink: #c4b0ff; }
  .lib[data-sec="video"] { --acc-ink: #ff9cb0; }
  .lib[data-sec="photo"] { --acc-ink: #7dd3fc; }
  .lib[data-sec="docs"] { --acc-ink: #fcd34d; }
}
/* мягкая цветная подсветка сверху — у каждого раздела своя */
.lib::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 180px; pointer-events: none;
  background: radial-gradient(120% 100% at 10% 0%, var(--acc-soft), transparent 70%);
  transition: background .3s;
}

.lib-head {
  position: relative; flex: none; display: grid; align-items: center; gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 300px) auto auto; grid-template-areas: "title search manage close";
  padding: 16px 14px 10px 20px;
}
.lib-close { grid-area: close; }
.lib-title { grid-area: title; min-width: 0; display: flex; align-items: center; gap: 12px; }
.lib-logo {
  flex: none; width: 42px; height: 42px; border-radius: 13px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #2bd46b, #0e9a4c 55%, #f57c00); box-shadow: 0 6px 16px rgba(30, 158, 90, .3);
}
.lib-logo .ic { width: 24px; height: 24px; }
.lib-title-txt { min-width: 0; display: flex; flex-direction: column; }
.lib-title-txt b { font-size: 20px; line-height: 24px; letter-spacing: -.01em; }
.lib-sub { color: var(--text-2); font-size: 12.5px; line-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-search {
  grid-area: search; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 4px 0 12px;
  border-radius: 12px; background: var(--search); color: var(--text-2);
}
.lib-search .ic { width: 18px; height: 18px; flex: none; }
.lib-search-in { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; font-size: 15px; }
.lib-search-in::-webkit-search-cancel-button { display: none; }
.lib-search-x { flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-2); display: flex; align-items: center; justify-content: center; }
.lib-manage {
  grid-area: manage; height: 38px; padding: 0 16px; border: 0; border-radius: 19px;
  background: var(--acc-soft); color: var(--acc-ink); font-size: 14px; font-weight: 700; white-space: nowrap;
}
.lib-manage[aria-pressed="true"] { background: var(--acc); color: #fff; box-shadow: 0 6px 14px var(--acc-soft); }

/* разделы: цветной кружок со значком, название, число */
.lib-tabs { position: relative; flex: none; display: flex; gap: 8px; padding: 2px 20px 12px; }
.lib-tab {
  --t: #8b5cf6;
  position: relative; display: inline-flex; align-items: center; gap: 9px; height: 44px; padding: 0 14px 0 6px;
  border: 0; border-radius: 22px; background: var(--hover); color: var(--text);
  font-size: 14.5px; font-weight: 600; transition: background .15s, box-shadow .15s, transform .15s;
}
.lib-tab[data-sec="video"] { --t: #f43f5e; }
.lib-tab[data-sec="photo"] { --t: #0ea5e9; }
.lib-tab[data-sec="docs"] { --t: #f59e0b; }
.lib-tab-ic { flex: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--t); color: #fff; }
.lib-tab-ic .ic { width: 18px; height: 18px; }
.lib-tab-n {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--track);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 12px; font-weight: 700;
}
.lib-tab-n:empty { display: none; }
.lib-tab.on { background: var(--panel); box-shadow: 0 0 0 2px var(--t), 0 6px 16px rgba(11, 20, 26, .1); }
.lib-tab.on .lib-tab-n { background: var(--t); color: #fff; }
@media (hover: hover) { .lib-tab:not(.on):hover { transform: translateY(-1px); } }

.lib-crumbs {
  position: relative; flex: none; display: flex; align-items: center; gap: 2px; min-height: 42px; padding: 0 14px;
  overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line);
}
.lib-crumbs::-webkit-scrollbar { display: none; }
.lib-crumb {
  flex: none; display: inline-flex; align-items: center; gap: 7px; max-width: 240px; height: 34px; padding: 0 10px;
  border: 0; border-radius: 10px; background: none; color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-crumb.now { color: var(--text); font-weight: 700; }
.lib-crumb .ic { width: 18px; height: 18px; color: var(--acc); }
@media (hover: hover) { .lib-crumb:not(.now):hover { background: var(--hover); color: var(--text); } }
.lib-crumb-sep { display: inline-flex; color: var(--text-3); }
.lib-crumb-sep .ic { width: 15px; height: 15px; }
.lib-crumb-now { display: inline-flex; align-items: center; gap: 8px; padding: 0 6px; color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; }
.lib-crumb-now .ic { width: 17px; height: 17px; color: var(--acc); }
.lib-crumb-up { width: 36px; height: 36px; margin-right: 2px; }

.lib-tools { position: relative; flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.lib-tool {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px 0 12px; border-radius: 20px;
  border: 1.5px dashed var(--acc); background: var(--acc-soft); color: var(--acc-ink); font-size: 14px; font-weight: 700;
}
.lib-tool .ic { width: 19px; height: 19px; }
.lib-tool-main { border-style: solid; background: var(--acc); color: #fff; box-shadow: 0 6px 16px var(--acc-soft); }
.lib-tools-hint { color: var(--text-3); font-size: 13px; }

.lib-body { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px 24px; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
.lib-loading { display: flex; justify-content: center; padding: 60px 0; }

/* папки */
.lf-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; margin-bottom: 20px; }
.lf-folder {
  position: relative; display: flex; align-items: center; gap: 13px; min-height: 78px; padding: 12px 12px 12px 13px;
  border-radius: 18px; cursor: pointer; outline: none;
  background: linear-gradient(135deg, var(--acc-soft), transparent 80%), var(--panel);
  box-shadow: inset 0 0 0 1px var(--line); transition: transform .16s, box-shadow .16s;
}
@media (hover: hover) { .lf-folder:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--acc-soft), 0 10px 22px rgba(11, 20, 26, .1); } }
.lf-folder:focus-visible { box-shadow: 0 0 0 2px var(--acc); }
.lf-folder-ic {
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 15px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--acc-2), var(--acc)); box-shadow: 0 8px 16px var(--acc-soft);
}
.lf-folder-ic > .ic { width: 28px; height: 28px; }
.lf-folder-sec {
  position: absolute; right: -5px; bottom: -5px; width: 23px; height: 23px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--panel); color: var(--acc); box-shadow: 0 1px 4px rgba(11, 20, 26, .25);
}
.lf-folder-sec .ic { width: 13px; height: 13px; }
.lf-folder-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lf-folder-name { font-size: 15px; font-weight: 700; line-height: 19px; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lf-folder-n { color: var(--text-2); font-size: 12.5px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-folder .lf-more { position: static; margin-right: -6px; }

/* общая плитка файла: выбор, «посмотреть», меню ⋯ */
.lf-tile { position: relative; cursor: pointer; outline: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lf-tile:focus-visible { box-shadow: 0 0 0 2px var(--acc); }
.lf-check {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; color: transparent;
  background: rgba(11, 20, 26, .28); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); opacity: 0; transform: scale(.85);
  transition: opacity .15s, transform .15s, background .15s;
}
.lf-check .ic { width: 16px; height: 16px; }
.sending .lf-check { opacity: 1; transform: none; }
.managing .lf-check { display: none; }
/* 17.10.2026: в «Управлять» (не в поиске) кружок — отметка для перемещения; у фото и видео — слева сверху (справа ⋯) */
.picking .lf-check { display: flex; opacity: 1; transform: none; }
.picking .lf-photo .lf-check, .picking .lf-vthumb .lf-check { left: 8px; right: auto; }
.picking .lf-video .lf-eye { left: 38px; }
.lf-tile.on .lf-check { background: var(--accent); border-color: var(--accent); color: #fff; transform: scale(1.06); }
.lf-eye, .lf-more {
  position: absolute; z-index: 2; width: 40px; height: 40px; padding: 0; border: 0; background: none;
  display: flex; align-items: center; justify-content: center; transition: opacity .15s;
}
.lf-eye { left: 3px; bottom: 3px; }
.lf-more { right: 3px; top: 3px; }   /* в режиме управления кружок выбора скрыт — ⋯ на его месте */
.lf-round {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(11, 20, 26, .58); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.lf-round .ic { width: 17px; height: 17px; }
@media (hover: hover) {
  .lf-photo .lf-eye, .lf-video .lf-eye { opacity: 0; }
  .lf-tile:hover .lf-eye, .lf-eye:focus-visible { opacity: 1; }
}
.lf-state {
  position: absolute; left: 8px; bottom: 8px; z-index: 1; display: inline-flex; align-items: center; gap: 6px;
  max-width: calc(100% - 16px); padding: 4px 9px; border-radius: 11px; background: rgba(11, 20, 26, .66); color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.lf-state.err { background: rgba(214, 31, 74, .9); }
.lf-state .ic { flex: none; width: 14px; height: 14px; }
.lf-state-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-spin { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; }
/* «готовится» / «не получилось» во всё превью фото и видео: значок, заголовок и пояснение по центру */
.lf-state.lf-state-c {
  inset: 0; max-width: none; flex-direction: column; justify-content: center; gap: 3px; padding: 8px 10px; border-radius: 0;
  background: rgba(11, 20, 26, .5); text-align: center; white-space: normal; text-wrap: balance;
}
.lf-state.lf-state-c.err { background: linear-gradient(rgba(150, 12, 44, .62), rgba(120, 8, 34, .78)); }
.lf-state-c.err .ic { color: #ff5c7a; }   /* у значка «!» белый — на белом круге (цвет текста) его не видно */
.lf-state-h { display: inline-flex; align-items: center; justify-content: center; gap: 6px; max-width: 100%; }
/* во всё превью: значок над текстом — на узкой плитке телефона подпись не обрезается; значок-заглушка под ней не просвечивает */
.lf-state-c .lf-state-h { flex-direction: column; gap: 5px; }
.lf-tile.busy .lf-ph .ic { opacity: 0; }
.lf-state-c b { font-size: 12.5px; line-height: 16px; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.lf-state-c small {
  max-width: 100%; font-size: 11.5px; line-height: 14px; font-weight: 500; opacity: .92; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.lf-state-c .lf-spin { width: 14px; height: 14px; }
.lf-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--acc); background: var(--acc-soft); }
.lf-ph .ic { width: 34px; height: 34px; }

/* фото — сетка квадратов */
.lf-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 8px; }
.lf-photo { aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--track); }
.lf-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s cubic-bezier(.2, .8, .2, 1), border-radius .2s; }
@media (hover: hover) { .lf-photo:hover img { transform: scale(1.05); } }
.lf-photo.on img { transform: scale(.88); border-radius: 10px; }
.lf-photo.on { background: var(--pill-on); box-shadow: inset 0 0 0 3px var(--accent); }
.lf-photo.busy img { filter: saturate(.5); opacity: .8; }

/* видео — 16:9, ▶ и длительность */
.lf-videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(226px, 1fr)); gap: 16px 14px; }
.lf-video { display: flex; flex-direction: column; gap: 7px; border-radius: 16px; }
.lf-vthumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #1c2b33; transition: box-shadow .15s, transform .2s; }
.lf-vthumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
@media (hover: hover) { .lf-video:hover .lf-vthumb img { transform: scale(1.04); } .lf-video:hover .lf-vthumb { box-shadow: 0 10px 22px rgba(11, 20, 26, .2); } }
.lf-vthumb::after { content: ""; position: absolute; inset: 55% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, .45)); pointer-events: none; }
.lf-vplay {
  position: absolute; left: 50%; top: 50%; z-index: 1; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .9); color: #111b21; box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.lf-vplay .ic { width: 24px; height: 24px; margin-left: 2px; }
.lf-dur { position: absolute; right: 8px; bottom: 8px; z-index: 1; padding: 1px 7px; border-radius: 9px; background: rgba(11, 20, 26, .7); color: #fff; font-size: 12px; font-weight: 700; }
.lf-vname { padding: 0 4px; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-video.on .lf-vthumb { box-shadow: 0 0 0 3px var(--accent); transform: scale(.97); }
.lf-video .lf-eye { top: 3px; bottom: auto; }

/* строки: песни, документы, результаты поиска */
.lf-rows { display: flex; flex-direction: column; gap: 4px; }
.lf-row { display: flex; align-items: center; gap: 13px; min-height: 66px; padding: 8px 10px 8px 8px; border-radius: 16px; transition: background .15s; }
@media (hover: hover) { .lf-row:hover, .lf-folder-row:hover { background: var(--hover); } }
.lf-row.on { background: var(--pill-on); }
.lf-row .lf-check { position: static; flex: none; border-color: var(--line-2); background: transparent; box-shadow: none; }
.lf-row.on .lf-check { background: var(--accent); border-color: var(--accent); }
.lf-row .lf-eye, .lf-row .lf-more { position: static; flex: none; }
.lf-row .lf-round { background: var(--acc-soft); color: var(--acc-ink); box-shadow: none; width: 38px; height: 38px; }
.lf-row .lf-round .ic { width: 19px; height: 19px; }
.lf-row-music .lf-eye .lf-round { background: var(--acc); color: #fff; box-shadow: 0 4px 12px var(--acc-soft); }
.lf-row-music .lf-eye .lf-round .ic { margin-left: 1px; }
.lf-cover {
  position: relative; flex: none; width: 50px; height: 50px; border-radius: 14px; overflow: hidden; color: #fff;
  display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, #b49bff, #7c3aed);
}
.lf-cover-video { background: linear-gradient(150deg, #ff8aa0, #e11d48); }
.lf-cover-photo { background: linear-gradient(150deg, #6fd0ff, #0284c7); }
.lf-cover img { width: 100%; height: 100%; object-fit: cover; }
.lf-cover > .ic { width: 25px; height: 25px; }
.lf-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lf-name { font-size: 15px; font-weight: 600; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-sub { color: var(--text-2); font-size: 12.5px; line-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-tags { color: var(--acc-ink); font-size: 13px; line-height: 17px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-row .lf-state { position: static; align-self: flex-start; background: var(--acc-soft); color: var(--acc-ink); }
.lf-row .lf-state .lf-spin { border-color: var(--acc-soft); border-top-color: var(--acc); }
.lf-row .lf-state.err { background: rgba(234, 0, 56, .1); color: var(--danger); }
.lf-prog { display: none; height: 3px; margin-top: 5px; border-radius: 2px; background: var(--track); overflow: hidden; }
.lf-prog i { display: block; width: 0; height: 100%; background: var(--acc); transition: width .25s linear; }
.lf-row-music.current .lf-prog { display: block; }
.lf-row-music.current .lf-name { color: var(--acc-ink); }
/* эквалайзер на обложке играющей песни */
.lf-eq, .song-eq { position: absolute; inset: 0; display: none; align-items: flex-end; justify-content: center; gap: 3px; padding-bottom: 14px; background: rgba(76, 29, 149, .45); }
.lf-eq i, .song-eq i { display: block; width: 4px; height: 8px; border-radius: 2px; background: #fff; animation: eq .9s ease-in-out infinite; }
.lf-eq i:nth-child(2), .song-eq i:nth-child(2) { animation-delay: -.3s; }
.lf-eq i:nth-child(3), .song-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 6px; } 50% { height: 20px; } }
.lf-row-music.playing .lf-eq { display: flex; }
/* документ: цветной значок с загнутым уголком */
.lf-badge {
  position: relative; flex: none; width: 44px; height: 52px; border-radius: 8px 15px 8px 8px; background: var(--b, #6b7785);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px;
  color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em; box-shadow: 0 6px 14px rgba(11, 20, 26, .14);
}
.lf-badge::before { content: ""; position: absolute; top: 0; right: 0; width: 15px; height: 15px; border-radius: 0 0 0 6px; background: rgba(255, 255, 255, .45); }
.lf-folder-row { border-radius: 16px; min-height: 66px; padding: 8px 10px 8px 8px; background: none; box-shadow: none; }
.lf-folder-row .lf-folder-ic { width: 50px; height: 50px; border-radius: 14px; }

/* пустые состояния */
.lib-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 20px; color: var(--text-2); text-align: center; }
.lib-empty-art {
  position: relative; width: 108px; height: 108px; margin-bottom: 14px; border-radius: 34px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--acc-2), var(--acc)); box-shadow: 0 18px 36px var(--acc-soft); transform: rotate(-7deg);
}
.lib-empty-art > .ic { width: 50px; height: 50px; transform: rotate(7deg); }
.lib-empty-ring { position: absolute; inset: -12px; border-radius: 42px; border: 2px dashed var(--acc-soft); animation: spin 26s linear infinite; }
.lib-empty b { color: var(--text); font-size: 18px; }
.lib-empty p { max-width: 360px; margin: 0; font-size: 14.5px; line-height: 1.45; }
.lib-empty .btn { margin-top: 12px; min-height: 44px; padding: 0 20px; border-radius: 22px; background: var(--acc); }

/* загрузки */
.lib-ups {
  position: absolute; right: 16px; bottom: 52px; z-index: 4; width: min(390px, calc(100% - 32px)); max-height: 46%; overflow-y: auto;
  padding: 10px 10px 6px; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow-2); animation: toast-in .18s ease-out;
}
.lib-ups-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px 4px; font-size: 14px; }
.lib-up { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-top: 1px solid var(--line); }
.lib-up-ic { flex: none; width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--acc-soft); color: var(--acc-ink); }
.lib-up-ic .ic { width: 19px; height: 19px; }
.lib-up-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lib-up-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-up-bar { display: block; height: 5px; margin: 5px 0 2px; border-radius: 3px; background: var(--track); overflow: hidden; }
.lib-up-bar i { display: block; width: 0; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--acc-2), var(--acc)); transition: width .2s; }
.lib-up-pct { color: var(--text-2); font-size: 12px; }
.lib-up-err { color: var(--danger); font-size: 12.5px; line-height: 1.35; }
.lib-up.done .lib-up-bar i { background: var(--accent); }
.lib-up-ok { flex: none; width: 40px; display: flex; justify-content: center; color: var(--accent); }
.lib-up-ok .ic { width: 22px; height: 22px; }
.lib-up-ok .lf-spin { width: 18px; height: 18px; border-color: var(--acc-soft); border-top-color: var(--acc); }
.lib-up-x { width: 36px; height: 36px; color: var(--text-2); }
.lib-up-x .ic { width: 18px; height: 18px; }
/* «Загрузить в «Фото»» и «Повторить» — под текстом ошибки: на телефоне колонкой справа они сжимали текст в столбик */
.lib-up-fix { align-self: flex-start; margin-top: 3px; text-align: left; white-space: normal; line-height: 1.2; }
.lib-link { min-height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--accent-2); font-size: 13.5px; font-weight: 700; }
@media (prefers-color-scheme: dark) { .lib-link { color: var(--accent); } }

/* выбор: панель отправки снизу */
.lib-sendbar {
  position: relative; z-index: 3; flex: none; padding: 12px 18px 16px; border-top: 1px solid var(--line);
  background: var(--panel); box-shadow: 0 -10px 26px rgba(11, 20, 26, .1); animation: lib-up .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes lib-up { from { transform: translateY(100%); } }
.lib-send-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.lib-send-info { min-width: 0; display: flex; align-items: baseline; gap: 10px; overflow: hidden; }
.lib-send-n { flex: none; font-size: 16px; }
.lib-send-what { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-send-row { display: flex; align-items: flex-end; gap: 10px; }
.lib-caption {
  flex: 1; min-width: 0; height: 46px; min-height: 46px; max-height: 92px; padding: 12px 16px; resize: none; outline: none;
  border: 1px solid var(--line-2); border-radius: 23px; background: var(--input); font-size: 15px; line-height: 20px;
}
.lib-caption:focus { border-color: var(--accent); }
.lib-send {
  flex: none; display: flex; align-items: center; gap: 9px; height: 48px; padding: 0 20px 0 24px; border: 0; border-radius: 24px;
  background: linear-gradient(135deg, #2bd46b, #00a884); color: #fff; font-size: 16px; font-weight: 800;
  box-shadow: 0 10px 22px rgba(0, 168, 132, .35); transition: transform .12s, box-shadow .12s;
}
.lib-send .ic { width: 20px; height: 20px; }
@media (hover: hover) { .lib-send:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(0, 168, 132, .4); } }
.lib-send:disabled { opacity: .45; box-shadow: none; cursor: default; }
.lib-send-note { margin-top: 7px; color: var(--wait); font-size: 13px; }
.lib.has-sel .lib-foot { display: none; }

.lib-foot { position: relative; flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 20px 12px; color: var(--text-3); font-size: 12px; }
.lib-quota-bar { flex: none; width: 110px; height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; }
.lib-quota-bar i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #2bd46b, #00a884); }
.lib-quota-bar.warn i { background: var(--danger); }

.lib-drop {
  position: absolute; inset: 10px; z-index: 9; display: flex; align-items: center; justify-content: center; pointer-events: none;
  border: 3px dashed var(--acc); border-radius: 18px; background: var(--acc-soft); backdrop-filter: blur(2px);
}
.lib-drop-in { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 28px; border-radius: 18px; background: var(--panel); color: var(--acc-ink); font-size: 15px; box-shadow: var(--shadow-2); }
.lib-drop-in .ic { width: 42px; height: 42px; }

/* меню ⋯ и диалоги внутри окна */
.lib-pop { position: absolute; z-index: 7; min-width: 220px; padding: 6px 0; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-2); animation: pop .12s ease-out; }
.lib-pop-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 0 16px; border: 0; background: none; color: var(--text); font-size: 14.5px; text-align: left; }
.lib-pop-item .ic { width: 19px; height: 19px; color: var(--icon); }
.lib-pop-item.danger, .lib-pop-item.danger .ic { color: var(--danger); }
@media (hover: hover) { .lib-pop-item:hover { background: var(--hover); } }
.lib-dlg-back { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(11, 20, 26, .38); animation: fade .15s; }
.lib-dlg { width: min(420px, 100%); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: 20px; background: var(--panel); box-shadow: var(--shadow-2); animation: pop .15s ease-out; }
@media (prefers-color-scheme: dark) { .lib-dlg, .lib-pop { background: #233138; } }
.lib-dlg h3 { margin: 0; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.lib-dlg p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.lib-dlg-in { height: 48px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 13px; outline: none; background: var(--input); font-size: 16px; }
.lib-dlg-in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 168, 132, .18); }
.lib-dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.lib-dlg .btn { min-height: 42px; padding: 0 18px; border-radius: 21px; font-size: 15px; }
.lib-cancel { background: var(--hover); color: var(--text); }
.lib-danger { background: var(--danger); color: #fff; }
.lib-tree { max-height: 300px; overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 14px; }
.lib-tree-row { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font-size: 14.5px; text-align: left; }
.lib-tree-row .ic { flex: none; width: 19px; height: 19px; color: var(--acc); }
.lib-tree-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-tree-row small { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.lib-tree-row.cur { color: var(--text-3); cursor: default; }
.lib-tree-row.on { background: var(--pill-on); color: var(--pill-on-ink); font-weight: 700; }
@media (hover: hover) { .lib-tree-row:not(.on):not(:disabled):hover { background: var(--hover); } }
/* 17.10.2026: окно «Переместить» — подсказка над списком; без выбранной папки кнопка бледная, а нажатие — красная подсказка */
.lib-dlg-hint { margin: -2px 0 0; color: var(--text-2); font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; }
.lib-dlg-hint.warn { color: var(--danger); font-weight: 700; animation: lib-shake .35s; }
@keyframes lib-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.lib-dlg .btn.off { opacity: .45; box-shadow: none; }
@media (hover: hover) { .lib-dlg .btn-primary.off:hover { background: var(--accent); } }

/* отмеченные кружками: панель внизу — сколько, «Выбрать все», «Снять выбор», «Переместить» */
.lib-pickbar {
  position: relative; z-index: 3; flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  padding: 10px 18px 12px; border-top: 1px solid var(--line); background: var(--panel);
  box-shadow: 0 -10px 26px rgba(11, 20, 26, .1); animation: lib-up .22s cubic-bezier(.2, .8, .2, 1);
}
.lib-pick-n { flex: 1 1 auto; min-width: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-pick-links { flex: none; display: flex; gap: 2px; }
.lib-move {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 22px 0 18px;
  border: 0; border-radius: 22px; background: var(--acc); color: #fff; font-size: 15px; font-weight: 800; box-shadow: 0 8px 18px var(--acc-soft);
}
.lib-move .ic { width: 20px; height: 20px; }
@media (hover: hover) { .lib-move:hover { filter: brightness(1.06); } }
.lib.has-pick .lib-foot { display: none; }
.lib.has-pick .lib-ups { bottom: 78px; }

/* перетаскивание мышью: куда можно бросить — пунктир, под курсором — заливка; перетаскиваемое — бледное */
.lib-dragging .lf-folder, .lib-dragging .lib-crumbs [data-folder]:not(.now) { box-shadow: inset 0 0 0 2px var(--acc-soft); }
/* над значком (svg с <use>) Chrome перестаёт слать dragover — бросить на «‹» или на значок папки было нельзя */
.lib-dragging .ic { pointer-events: none; }
.lib-dragging .lf-folder { transform: none; }
.lf-dragged { opacity: .4; }
.lf-folder.drop-on, .lib-crumbs .drop-on { background: var(--acc-soft); box-shadow: inset 0 0 0 2px var(--acc), 0 8px 20px var(--acc-soft); color: var(--text); }
.lf-folder.drop-on .lf-folder-ic { transform: scale(1.08); }
.lf-folder-ic { transition: transform .15s; }
.lib-dragimg {
  position: fixed; left: -1000px; top: -1000px; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px 9px 12px;
  border-radius: 20px; background: var(--accent); color: #fff; font: 700 14px/1.2 var(--font); white-space: nowrap;
}
.lib-dragimg .ic { width: 18px; height: 18px; }

/* ---------- песня в ленте: карточка с названием ---------- */
.song { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; align-items: center; gap: 11px; width: 300px; max-width: 100%; padding: 2px 0 0; }
.song-art { position: relative; width: 50px; height: 50px; border-radius: 13px; overflow: hidden; color: #fff; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, #b49bff, #7c3aed); box-shadow: 0 4px 12px rgba(124, 58, 237, .3); }
.song-art > .ic { width: 25px; height: 25px; }
.song.playing .song-art > .ic { display: none; }
.song.playing .song-eq { display: flex; }
.song-main { min-width: 0; display: flex; flex-direction: column; }
.song-title { font-size: 14.5px; font-weight: 700; line-height: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song .vbar { flex: none; height: 16px; }
.song .vtrack { top: 6px; }
.song .vknob { top: 2px; }
.song .vfill, .song .vknob { background: #7c3aed; }
.song .vtime { position: static; font-size: 11.5px; line-height: 14px; }
.song .vplay { width: 42px; height: 42px; background: #7c3aed; box-shadow: 0 4px 12px rgba(124, 58, 237, .35); }
@media (prefers-color-scheme: dark) { .song .vfill, .song .vknob { background: #c4b0ff; } }

/* просмотр видео из библиотеки */
.viewer video { max-width: 100%; max-height: 100%; border-radius: 6px; background: #000; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }
.viewer.is-video { cursor: default; }
/* PDF из библиотеки на компьютере (17.10.2026): во всю область просмотра, сверху место под крестик */
.viewer.is-doc { cursor: default; }
.viewer-doc { display: block; width: 100%; height: 100%; border: 0; border-radius: 6px; background: #fff; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }

/* ---------- библиотека на телефоне: лист на весь экран снизу ---------- */
@media (max-width: 768px) {
  .lib-back { padding: 0; }
  .lib {
    position: fixed; left: 0; right: 0; top: var(--app-top, 0px); width: 100%; height: 100vh; border-radius: 0;
    padding-top: env(safe-area-inset-top); opacity: 1; transform: translateY(100%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  }
  .lib-head {
    grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "close title manage" "search search search";
    gap: 6px 6px; padding: 6px 10px 8px 4px;
  }
  .lib-logo { width: 36px; height: 36px; border-radius: 11px; }
  .lib-title-txt b { font-size: 18px; line-height: 22px; }
  .lib-search { margin-left: 6px; }
  .lib-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 0 10px 10px; }
  .lib-tab { flex-direction: column; justify-content: center; gap: 4px; height: auto; min-height: 66px; padding: 7px 2px 6px; border-radius: 16px; font-size: 12.5px; }
  .lib-tab-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lib-tab-n { position: absolute; top: 4px; right: 5px; min-width: 20px; height: 20px; font-size: 11px; }
  .lib-crumbs { padding: 0 8px; }
  .lib-tools { padding: 10px 10px 0; }
  .lib-tools-hint { display: none; }
  .lib-body { padding: 12px 10px 20px; }
  .lf-folders { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .lf-folder { min-height: 72px; gap: 10px; padding: 10px; border-radius: 16px; }
  .lf-folder-ic { width: 44px; height: 44px; border-radius: 13px; }
  .lf-folder-ic > .ic { width: 24px; height: 24px; }
  .lf-folder-name { font-size: 14px; line-height: 18px; }
  .lf-photos { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .lf-photo { border-radius: 10px; }
  .lf-videos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 8px; }
  .lf-row { gap: 10px; padding: 6px 4px 6px 4px; }
  .lib-ups { left: 8px; right: 8px; width: auto; bottom: calc(52px + env(safe-area-inset-bottom)); }
  .lib-sendbar { padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); }
  .kb-open .lib-sendbar { padding-bottom: 12px; }
  .lib-send { padding: 0 16px 0 18px; }
  .lib-foot { padding: 6px 14px calc(10px + env(safe-area-inset-bottom)); }
  /* панель отмеченных: сверху «Выбрано» и ссылки, ниже — «Переместить» во всю ширину */
  .lib-pickbar { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .lib-pick-n { font-size: 15px; }
  .lib-move { flex: 1 1 100%; height: 48px; border-radius: 24px; }
  .lib.has-pick .lib-ups { bottom: calc(118px + env(safe-area-inset-bottom)); }
  /* «Отправка в чат: Имя · через Telegram · номер» — в две строки, чтобы был виден номер */
  .lib-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
/* узкий телефон: папки — в одну колонку, иначе «Поздравления Мишка» рвётся посреди слова */
@media (max-width: 480px) { .lf-folders { grid-template-columns: minmax(0, 1fr); } .lf-folder { min-height: 64px; } }
@supports (height: 100dvh) { @media (max-width: 768px) { .lib { height: var(--app-h, 100dvh); } } }
@media (max-width: 768px) { .lib-back.shown .lib { transform: none; } }
/* телефон боком (низкий экран, но шире 768): библиотека — на весь экран, без лишних полос, иначе плиткам не остаётся места */
@media (max-height: 500px) and (min-width: 769px) {
  .lib-back { padding: 0; }
  .lib { width: 100%; height: 100%; border-radius: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
  .lib-head { padding-top: 8px; padding-bottom: 6px; }
  .lib-tabs { padding-bottom: 6px; }
  .lib-foot { display: none; }
}

/* сенсорный экран: всё, во что тычут пальцем, — не меньше 44 px */
@media (max-width: 768px), (pointer: coarse) {
  .lib-manage, .lib-tool, .lib-crumb, .lib-search { min-height: 44px; }
  .lib-search-in, .lib-caption, .lib-dlg-in { font-size: 16px; }
  .lib-search-x, .lib-crumb-up, .lib-up-x { width: 44px; height: 44px; }
  .lf-eye, .lf-more { width: 44px; height: 44px; }
  .lib-link, .lib-pop-item, .lib-tree-row { min-height: 44px; }
  .lib-dlg .btn { min-height: 44px; }
  .lib-tab { min-height: 44px; }
  .lib-caption:placeholder-shown { white-space: nowrap; }   /* подсказка в одну строку, не обрезается посередине */
  .song .vplay { width: 44px; height: 44px; }
}
/* узкий телефон: кнопка сделки без значка — в шапке видны имя и телефон клиента */
@media (max-width: 400px) {
  .deal-btn:not(.muted) { padding: 0 9px; font-size: 13px; } .deal-btn:not(.muted) .ic { display: none; }
  .deal-btn.muted { padding: 0 9px; font-size: 13px; }   /* «Сделки нет» — тоже уже: телефон клиента виден целиком */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
