/* Цвета и размеры меняются здесь, в одном месте. Тёмная тема — те же имена ниже, в @media (волна 3). */
:root {
  color-scheme: light dark; /* поля даты, галки и прокрутка тоже темнеют вместе с телефоном */
  --bg: #f7f3f5; --card: #ffffff; --text: #2c2430; --muted: #6f6475; --line: #e4dbe2;
  --accent: #7a4a6b; --accent-text: #ffffff; --accent-soft: #efe1ea; --warn: #a8481f; --ok: #2f6f4f;
  --on-warn: #ffffff; --field-bg: #ffffff; --field-line: #a99fa8; --free-text: #a99fa8;
  --banner-bg: #fbeee6; --banner-line: #e8c7b2; --prepaid-line: #b98aa9; --paid-bg: #e3f1e9; --debt-bg: #fbeee6;
  --open-line: #c99a06; --open-bg: #fbf2d6; --open-text: #7a5c00; --gone-line: #d6ccd3;
  --toast-bg: #2c2430; --toast-text: #ffffff; --toast-action: #f3c9e4; --toast-error-bg: #a8481f;
  --radius: 14px; --ctl: 44px;
}
/* Тёмная тема — когда в телефоне включено тёмное оформление (волна 3, 15.11.2026).
   Контраст текста и кнопок — не ниже 4,5:1, рамок полей — не ниже 3:1. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131a; --card: #241e27; --text: #f1e9ef; --muted: #b9adb7; --line: #3e3442;
    --accent: #d49ac0; --accent-text: #241e27; --accent-soft: #3d2a38; --warn: #f29b78; --ok: #84d3a5;
    --on-warn: #241e27; --field-bg: #1b161e; --field-line: #8c808b; --free-text: #9d919c;
    --banner-bg: #3a2a22; --banner-line: #6b4a3a; --prepaid-line: #a77a98; --paid-bg: #1f3a2c; --debt-bg: #43281d;
    --open-line: #d7aa2a; --open-bg: #3d3215; --open-text: #f0d27a; --gone-line: #4a4050;
    --toast-bg: #463b4c; --toast-text: #ffffff; --toast-action: #f3c9e4; --toast-error-bg: #b4532a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* иначе .field и #tabs показывались бы, несмотря на hidden */
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { padding: 12px 12px 88px; max-width: 720px; margin: 0 auto; }
#offline { background: var(--warn); color: var(--on-warn); padding: 8px 12px; text-align: center; font-size: 14px; }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; min-height: 60px; border: 0; background: none; font-size: 12px; color: var(--muted); flex-direction: column; gap: 2px; padding: 4px 0; border-radius: 0; }
#tabs button.on { color: var(--accent); font-weight: 700; }
/* Значки вкладок (волна 2): у выбранной — светлая «таблетка» под значком */
.tab-ico { width: 24px; height: 24px; box-sizing: content-box; padding: 3px 16px; border-radius: 999px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on .tab-ico { background: var(--accent-soft); }
button, .btn { min-height: var(--ctl); padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--warn); border-color: var(--warn); }
button.ghost { border: 0; background: none; color: var(--muted); }
input, select, textarea { width: 100%; min-height: var(--ctl); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--field-line); background: var(--field-bg); font-size: 16px; color: var(--text); }
textarea { min-height: 88px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
/* Листание периода (неделя сверху и снизу, итоги): период, под ним две широкие цветные кнопки */
.week-nav { margin: 0 0 12px; }
.week-range { display: block; text-align: center; font-size: 17px; margin-bottom: 8px; }
.week-nav-buttons { display: flex; gap: 8px; }
.week-nav-buttons button { flex: 1; min-height: 48px; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); font-weight: 600; }
.week-nav-buttons button:active { background: var(--accent); color: var(--accent-text); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 700; margin-bottom: 6px; }
.day-head.today { color: var(--accent); }
.note { font-size: 14px; color: var(--warn); margin-bottom: 6px; }
.row { display: flex; width: 100%; min-height: var(--ctl); gap: 10px; align-items: center; justify-content: flex-start; text-align: left; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 6px 4px; background: none; }
.row .t { width: 56px; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); }
.row .n { flex: 1; }
.row .sub { display: block; font-size: 13px; color: var(--muted); }
.row.free .n { color: var(--free-text); }
.row.covered .n { color: var(--muted); font-style: italic; }
.row.done .n { color: var(--ok); }
.row.owes .n { color: var(--warn); font-weight: 600; }
.row.gone .n { text-decoration: line-through; color: var(--muted); }
.day-foot { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 14px; }
.small-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.small-actions button { min-height: 36px; font-size: 14px; }
.banner { display: block; width: 100%; margin-bottom: 10px; background: var(--banner-bg); border-color: var(--banner-line); }
#sheet { border: 0; background: var(--card); color: var(--text); border-radius: var(--radius); padding: 14px; width: min(94vw, 520px); max-height: 90vh; overflow: auto; }
#sheet::backdrop { background: rgba(30, 20, 30, .45); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 18px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pick-list button { display: block; width: 100%; margin-top: 4px; text-align: left; }
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row input { flex: 1; min-width: 0; }
.search-row button { flex: none; white-space: nowrap; }
.row-edit { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.row-edit input { flex: 1; min-width: 0; }
.row-edit select { flex: 0 0 42%; width: 42%; }
.row-edit button { flex: none; padding: 0 8px; }
.photos { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.full { display: block; width: 100%; border-radius: 10px; }
.hint { background: var(--bg); border-radius: 10px; padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.hint:empty { display: none; }
.hint button { margin-top: 6px; min-height: 44px; font-size: 14px; }
.warn { color: var(--warn); font-size: 14px; margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }
.big { font-size: 24px; font-weight: 700; }
.line { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.line .sub { display: block; font-size: 13px; color: var(--muted); }
.line-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.line-actions .btn, .line-actions button { min-height: 44px; padding: 0 10px; font-size: 14px; }
/* Замечания и пожелания */
.fb-note .line-actions { flex-wrap: wrap; margin-top: 8px; }
#sheet textarea { font-family: inherit; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; }
.note-edit { min-height: 40vh; }
.voice { margin: 6px 0; }
.transcript { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
#sheet audio { display: block; width: 100%; margin: 6px 0; }
.rec-clock { font-size: 40px; font-weight: 700; text-align: center; margin: 12px 0; font-variant-numeric: tabular-nums; }
.rec-clock.on { color: var(--warn); }

/* ---------- Волна 1 удобства (15.11.2026) ---------- */
/* Состояние записи: цветная полоска слева и подпись справа */
.row[class*="st-"] { border-left: 4px solid transparent; padding-left: 8px; }
.row .tag { flex: none; font-size: 12px; line-height: 1.2; padding: 3px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.row.st-booked { border-left-color: var(--accent); }
.row.st-prepaid { border-left-color: var(--prepaid-line); }
.row.st-prepaid .tag { background: var(--accent-soft); color: var(--accent); }
.row.st-paid { border-left-color: var(--ok); }
.row.st-paid .tag { background: var(--paid-bg); color: var(--ok); }
.row.st-debt { border-left-color: var(--warn); }
.row.st-debt .tag { background: var(--debt-bg); color: var(--warn); font-weight: 600; }
.row.st-open { border-left-color: var(--open-line); }
.row.st-open .tag { background: var(--open-bg); color: var(--open-text); font-weight: 600; }
.row.st-gone { border-left-color: var(--gone-line); }
.row.st-gone .n { text-decoration: line-through; color: var(--muted); }

/* Сегодня — заметнее; у дня меню «⋯» вместо трёх кнопок */
.card.day-today { border: 2px solid var(--accent); }
.today-badge { margin-left: 8px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-text); vertical-align: middle; }
.day-head { align-items: center; }
.day-head-right { display: inline-flex; align-items: center; gap: 6px; }
.day-menu { min-height: 44px; min-width: 44px; padding: 0; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); }

/* Прошедший день — одной строкой */
.day-compact { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; min-height: 48px; padding: 8px 12px; color: var(--muted); }
.day-compact-name { flex: none; font-weight: 700; color: var(--text); }
.day-compact-sum { flex: 1; font-size: 14px; }
.chev { flex: none; font-size: 22px; line-height: 1; }

/* Полоса дней недели */
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 0 0 10px; }
.strip-day { flex-direction: column; min-height: 58px; padding: 4px 0; gap: 0; border-radius: 10px; }
.strip-name { font-size: 12px; color: var(--muted); }
.strip-num { font-size: 17px; font-weight: 700; }
.strip-count { font-size: 12px; min-height: 15px; color: var(--accent); font-weight: 600; }
.strip-day.is-today { border: 2px solid var(--accent); }
.strip-day.is-closed { background: var(--bg); }
.small-actions { margin-bottom: 10px; }
.small-actions button { min-height: 44px; }

/* «Выбрать дату»: месяц с занятостью */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 8px 0; }
.cal-head { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-day { flex-direction: column; justify-content: flex-start; min-height: 64px; padding: 4px 2px; gap: 1px; border-radius: 10px; }
.cal-num { font-size: 16px; font-weight: 700; }
.cal-info, .cal-free { font-size: 11px; line-height: 1.2; min-height: 13px; }
.cal-info { color: var(--accent); font-weight: 600; }
.cal-free { color: var(--ok); }
.cal-day.is-past { opacity: 0.5; }
.cal-day.is-today { border: 2px solid var(--accent); }
.cal-day.is-full { background: var(--accent-soft); }
.cal-day.is-closed { background: var(--bg); color: var(--muted); }

/* Быстрая запись */
.when-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 17px; }
.when-line button { min-height: 44px; }
.recent-clients { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; align-items: center; }
.recent-clients:empty { display: none; }
.recent-clients .muted { width: 100%; }
.recent-clients .chip { min-height: 44px; padding: 0 12px; font-size: 15px; }
details.more { margin-top: 10px; }
details.more summary { min-height: 44px; display: flex; align-items: center; color: var(--accent); font-weight: 600; cursor: pointer; }
.slot-link, .client-link { display: block; width: 100%; margin-top: 8px; color: var(--accent); text-align: left; min-height: 44px; }
.client-link { margin: -4px 0 4px; padding-left: 0; }

/* Связь с клиенткой из записи */
.contact { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.contact-title { font-weight: 600; margin-bottom: 8px; }
.contact-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-buttons .btn, .contact-buttons button { flex: 1 1 30%; min-height: 44px; }
.contact-status:empty { display: none; }
.contact-status { margin-top: 6px; }

/* ---------- Волна 2 удобства (15.11.2026) ---------- */
main { padding-bottom: 96px; } /* вкладки стали выше: 60 точек и значки */

/* Сообщения внизу экрана вместо системных окон; у удаления — «Вернуть» */
#toast { position: fixed; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px; min-height: 52px; border-radius: 12px;
  background: var(--toast-bg); color: var(--toast-text); font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
#toast.toast-error { background: var(--toast-error-bg); }
#toast .toast-text { flex: 1; }
#toast button { flex: none; min-height: 44px; border: 0; background: none; color: var(--toast-action); font-weight: 700; padding: 0 10px; }
#toast.toast-error button { color: var(--toast-text); }
#sheet #toast { bottom: calc(16px + env(safe-area-inset-bottom)); }

/* Карточка «Сегодня» вверху недели */
.today-card { border: 2px solid var(--accent); }
.today-title { font-size: 17px; color: var(--accent); margin-bottom: 2px; }
.today-line, .today-next { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.today-line { display: flex; align-items: center; gap: 8px; }
.today-line.st-open { border-left: 4px solid var(--open-line); padding-left: 8px; }
.today-who { flex: 1; display: block; text-align: left; padding: 4px 0; color: var(--text); font-weight: 600; min-height: 44px; }
.today-label { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.today-actions { display: flex; gap: 8px; margin-top: 4px; }
.today-actions > * { flex: 1; }

/* Долги: просроченное «обещала до» */
.card.debt-overdue { border-left: 4px solid var(--warn); }

/* Карточка клиентки: обзор */
.two-buttons { display: flex; gap: 8px; margin: 10px 0; }
.two-buttons button { flex: 1; }
.client-notes { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: 15px; }
.erase-zone { margin-top: 24px; }
#sheet .contact { margin-top: 8px; }
.phones { display: flex; flex-direction: column; align-items: flex-end; }
.phones > span { white-space: nowrap; }

/* ---------- Волна 3 удобства (15.11.2026) ---------- */
/* Строка поиска вверху экрана */
#topbar { max-width: 720px; margin: 0 auto; padding: 12px 12px 0; }
#search-open { width: 100%; justify-content: flex-start; gap: 10px; border-radius: 999px; color: var(--muted); }
.search-ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#sheet p.muted:empty { display: none; }

/* Листание пальцем: новая неделя «въезжает» сбоку */
@keyframes slide-from-right { from { transform: translateX(28px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes slide-from-left { from { transform: translateX(-28px); opacity: .4; } to { transform: none; opacity: 1; } }
#view.slide-from-right { animation: slide-from-right .18s ease-out; }
#view.slide-from-left { animation: slide-from-left .18s ease-out; }
@media (prefers-reduced-motion: reduce) { #view.slide-from-right, #view.slide-from-left { animation: none; } }

/* ---------- Переписка в MAX: вид как в мессенджерах (15.11.2026) ---------- */
#tabs button { position: relative; }
.tab-badge { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--warn); color: var(--on-warn); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.count-pill { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--accent-text);
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.max-open { width: 100%; margin-top: 8px; }
.max-banner { background: var(--banner-bg); border: 1px solid var(--banner-line); border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; font-size: 14px; }

/* Кружки с буквами: шесть спокойных цветов, у каждой клиентки свой */
.av { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.av-sm { width: 38px; height: 38px; font-size: 14px; }
.av-0 { background: var(--av0-bg); color: var(--av0-fg); } .av-1 { background: var(--av1-bg); color: var(--av1-fg); }
.av-2 { background: var(--av2-bg); color: var(--av2-fg); } .av-3 { background: var(--av3-bg); color: var(--av3-fg); }
.av-4 { background: var(--av4-bg); color: var(--av4-fg); } .av-5 { background: var(--av5-bg); color: var(--av5-fg); }
:root { --av0-bg: #efe1ea; --av0-fg: #6a3d5c; --av1-bg: #dff1ee; --av1-fg: #1f6157; --av2-bg: #fbe9dc; --av2-fg: #8a4513;
  --av3-bg: #e6f2dc; --av3-fg: #3b6a1f; --av4-bg: #e2ecf8; --av4-fg: #24508a; --av5-bg: #f8e3e6; --av5-fg: #8e2d42; }
@media (prefers-color-scheme: dark) {
  :root { --av0-bg: #4a2f43; --av0-fg: #f0cfe4; --av1-bg: #1f3f3a; --av1-fg: #bfe8e0; --av2-bg: #4a3020; --av2-fg: #f6cfae;
    --av3-bg: #2d4122; --av3-fg: #cde8b9; --av4-bg: #233650; --av4-fg: #c4d8f2; --av5-bg: #4a2730; --av5-fg: #f3c7cf; }
}

/* Список чатов */
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 10px; }
.chat-head h2 { margin: 0; font-size: 22px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status-dot.off::before { background: var(--warn); }
.chat-card { padding: 0; overflow: hidden; }
.chat-tools { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.chat-search { border-radius: 999px; padding-left: 16px; }
.chat-row { display: flex; width: 100%; min-height: 72px; gap: 12px; align-items: center; padding: 0 12px; border: 0; border-radius: 0;
  background: none; text-align: left; color: var(--text); }
.chat-row:active { background: var(--bg); }
.chat-text { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 3px;
  border-bottom: 1px solid var(--line); }
.chat-list > .chat-row:last-child .chat-text { border-bottom: 0; }
.chat-l1, .chat-l2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { flex: none; display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
.chat-time .ico { width: 16px; height: 16px; }
.chat-prev { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row.unread .chat-name { font-weight: 700; }
.chat-row.unread .chat-time { color: var(--accent); font-weight: 700; }
.chat-row.unread .chat-prev { color: var(--text); }
.chat-empty { padding: 12px; }
/* Вкладки «Чатов» (15.11.2026): Клиентки · Не из базы · Не клиенты, у каждой — число чатов с новыми */
.chat-tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
button.chat-tab { flex: 1 1 auto; min-width: 0; min-height: var(--ctl); padding: 0 6px; gap: 6px; border: 0; border-radius: 9px;
  background: none; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
button.chat-tab.on { background: var(--accent-soft); color: var(--accent); }
.chat-tab .count-pill { min-width: 20px; height: 20px; padding: 0 6px; font-size: 11px; line-height: 20px; }
.chat-tab-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* очень узкий экран и двузначные счётчики */
.chat-hint { margin: 0; font-size: 13px; }
.sheet-actions .btn { gap: 6px; }
@media (max-width: 360px) { button.chat-tab { padding: 0 3px; gap: 4px; font-size: 13px; } }

/* Переписка на весь экран */
body.chat-open { overflow: hidden; }
#chat { position: fixed; inset: 0; z-index: 30; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); }
#chat[hidden] { display: none !important; }
body.chat-open #toast { bottom: calc(132px + env(safe-area-inset-bottom)); z-index: 40; }
.chat-top { display: flex; align-items: center; gap: 4px; padding: calc(6px + env(safe-area-inset-top)) 6px 6px; background: var(--card);
  border-bottom: 1px solid var(--line); }
button.icon-btn { min-width: 44px; padding: 0; color: var(--accent); }
.icon-btn .ico { width: 24px; height: 24px; }
button.chat-who { flex: 1; min-width: 0; justify-content: flex-start; gap: 10px; padding: 0 4px; color: var(--text); text-align: left; }
.chat-who-text { min-width: 0; display: flex; flex-direction: column; }
.chat-who-text strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-who-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat .max-banner { margin: 8px 10px 0; }
.chat-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column;
  padding: 8px 12px 16px; }
.day-pill { align-self: center; margin: 12px 0 4px; padding: 3px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); }
.new-divider { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; color: var(--accent); font-size: 12px; font-weight: 600; }
.new-divider::before, .new-divider::after { content: ""; flex: 1; border-top: 1px solid var(--accent); }
.b { max-width: 82%; margin-top: 8px; padding: 7px 10px 6px 12px; border-radius: 18px; font-size: 15px; line-height: 1.38;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.b.cont { margin-top: 2px; }
.b.in { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.b.out { align-self: flex-end; background: var(--accent-soft); }
.b.in.tail { border-bottom-left-radius: 6px; }
.b.out.tail { border-bottom-right-radius: 6px; }
.b-time { float: right; margin: 7px 0 -4px 10px; font-size: 11px; line-height: 1; color: var(--muted); }
.b.out .b-time { color: var(--accent); }
.b-kind { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-style: italic; }
.b-kind + .b-text { display: block; margin-top: 4px; }
.chat-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.chat-down { position: absolute; right: 14px; bottom: 12px; width: 44px; height: 44px; padding: 0;
  border-radius: 50%; background: var(--card); color: var(--accent); }
.chat-bottom { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
body.chat-open #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }

/* Поле ответа (фаза 2): «Записать», текст, «Отправить» — как в мессенджерах */
.composer { display: flex; align-items: flex-end; gap: 6px; }
.chat-input { flex: 1; min-height: 44px; max-height: 140px; resize: none; border-radius: 22px; padding: 10px 14px; line-height: 1.35;
  font-family: inherit; }
.send-btn { width: 44px; min-width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.composer-off { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.composer-off .btn { gap: 6px; flex: none; }
.b.pending { opacity: .75; }
.b.problem { border: 1px solid var(--warn); }
.b-state { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.b.problem .b-state { color: var(--warn); }
.b-actions { align-self: flex-end; display: flex; gap: 6px; margin-top: 4px; }
.b-actions button { border-radius: 999px; font-size: 14px; }
.bind-list { margin: 4px -14px 0; }

/* Реакции (15.11.2026): значки под сообщением, выбор — нажатием на сообщение клиентки */
.b-rx { clear: both; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding-top: 4px; }
.rx { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 24px; padding: 0 6px;
  border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; line-height: 1; }
.rx.mine { border-color: var(--accent); }
.rx.waiting { opacity: .55; }
.rx-failed { font-size: 12px; color: var(--warn); }
.b.in[role="button"] { cursor: pointer; }
.b.in[role="button"]:active { background: var(--bg); }
.rx-quote { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 8px 0; }
.rx-btn { min-height: 52px; padding: 0; border-radius: 14px; font-size: 26px; }
.rx-btn.on { border: 2px solid var(--accent); background: var(--accent-soft); }
.composer-note { margin: 0 4px 6px; font-size: 12px; line-height: 1.35; color: var(--muted); }

/* ---------- Заметки дня (15.11.2026): «наклейки» мягкого жёлтого цвета, отдельно от расписания ---------- */
:root { --note-bg: #fff4cc; --note-line: #e8cf7d; --note-time: #7a5c00; }
@media (prefers-color-scheme: dark) { :root { --note-bg: #3b3217; --note-line: #6e5c22; --note-time: #f0d27a; } }
.day-notes { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 10px; }
.today-notes { margin: 8px 0 0; }
.day-note { display: flex; align-items: flex-start; justify-content: flex-start; gap: 8px; width: 100%; min-height: 44px; padding: 9px 12px;
  border-radius: 12px; background: var(--note-bg); border: 1px solid var(--note-line); color: var(--text); text-align: left;
  font-size: 15px; line-height: 1.35; }
.day-note .ico { width: 18px; height: 18px; margin-top: 1px; color: var(--note-time); }
.day-note-time { flex: none; font-weight: 700; color: var(--note-time); font-variant-numeric: tabular-nums; }
.day-note-text { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.day-status { display: inline-block; margin: 0 0 8px; padding: 2px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 13px; }
.note-input { font-family: inherit; }
.note-when { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Смайлики в поле ответа */
.emoji-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; max-height: 196px; overflow-y: auto;
  margin: 0 0 6px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.emoji-btn { min-height: 44px; padding: 0; border: 0; background: none; font-size: 24px; border-radius: 10px; }
.emoji-btn:active { background: var(--accent-soft); }

/* Чат без клиентки (15.11.2026): полоска «Нет в базе» под шапкой — привязать или завести клиентку */
.chat-strip { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.chat-strip-text { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--accent); }
.chat-strip button { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 999px; background: var(--card); }

/* ---------- Фаза 3 MAX (15.11.2026): фото, стикеры и файлы в переписке, скрепка ---------- */
.b-photo { display: block; min-height: 0; padding: 0; margin: 0 0 4px; border: 0; border-radius: 12px; background: none; overflow: hidden; }
.b-photo img { display: block; width: 240px; max-width: 100%; height: auto; max-height: 320px; object-fit: cover; }
.b.with-photo { padding: 4px 4px 6px; }
.b.with-photo .b-text { display: block; padding: 0 6px; }
.b.with-photo .b-time { margin-right: 6px; }
.b.sticker { position: relative; background: none; border: 0; padding: 0; }
.b-sticker img { display: block; width: 140px; max-width: 100%; height: auto; }
.b.sticker .b-time { position: absolute; right: 0; bottom: 0; float: none; margin: 0; padding: 3px 7px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); }
.b.sticker .b-rx { padding-top: 2px; }
.b-file { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; margin: 0 0 4px; border-radius: 12px;
  background: var(--bg); color: var(--text); text-decoration: none; }
.b-file .ico { color: var(--accent); }
.b-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.b-file-size { flex: none; font-size: 12px; color: var(--muted); }
.b-media-wait { display: block; min-width: 180px; margin: 0 0 4px; padding: 28px 10px; border-radius: 12px; background: var(--bg);
  color: var(--muted); font-size: 13px; text-align: center; }
.photo-view { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .92); }
.photo-view img { max-width: 100%; max-height: 100%; object-fit: contain; }
button.photo-close { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 8px; border-radius: 50%; color: #fff; background: rgba(0, 0, 0, .45); }
.attach-chip { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 4px 4px 4px 8px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); }
.attach-chip img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.attach-chip > .ico { width: 28px; height: 28px; color: var(--accent); }
.attach-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.attach-size { flex: none; font-size: 12px; color: var(--muted); }

/* «Кому напомнить на завтра» с MAX (15.11.2026) */
.remind-sample { margin: 0 0 6px; font-size: 13px; }
.warn-text { color: var(--warn) !important; }

/* Голосовые и видео в переписке MAX (15.11.2026) */
.b-audio { display: block; margin: 0 0 4px; }
.b-audio audio { display: block; width: 250px; max-width: 100%; height: 40px; }
.b-transcript { margin: 6px 2px 0; font-size: 14px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
button.b-transcribe { min-height: 36px; margin: 4px 0 0; padding: 0 6px; gap: 6px; font-size: 13px; color: var(--accent); }
.b-transcribe .ico { width: 16px; height: 16px; }
button.b-video { position: relative; display: block; min-height: 0; padding: 0; margin: 0 0 4px; border: 0; border-radius: 12px;
  overflow: hidden; background: #000; }
.b-video img { display: block; width: 220px; max-width: 100%; height: auto; max-height: 320px; object-fit: cover; }
.b-video-blank { display: block; width: 220px; height: 140px; background: var(--bg); }
.b-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: inline-flex; align-items: center;
  justify-content: center; min-width: 52px; height: 52px; padding: 0 14px; border-radius: 999px; background: rgba(0, 0, 0, .55);
  color: #fff; font-size: 13px; }
.b-play .ico { width: 24px; height: 24px; fill: #fff; }
.photo-view video { max-width: 100%; max-height: 100%; }

/* ---------- Чаты MAX, первая волна (18.11.2026): цитата, меню, галочки, «ждут», шаблоны ---------- */
.chat-filter .chips { flex-wrap: nowrap; overflow-x: auto; }
.chat-filter .chips button { min-height: 36px; padding: 0 12px; font-size: 14px; white-space: nowrap; }
.wait-pill { flex: none; padding: 2px 8px; border-radius: 999px; background: var(--open-bg); color: var(--open-text); font-size: 12px; font-weight: 700; }
.wait-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 4px 12px; margin: 6px 8px 0;
  border-radius: 12px; background: var(--open-bg); color: var(--open-text); font-size: 14px; font-weight: 600; }
.wait-strip button.ghost { min-height: 36px; color: var(--open-text); text-decoration: underline; }
.b-quote { display: block; margin: 0 0 4px; padding: 4px 8px; border-left: 3px solid var(--accent); border-radius: 6px;
  background: var(--bg); font-size: 13px; line-height: 1.3; cursor: pointer; overflow: hidden; }
.b-quote strong { display: block; color: var(--accent); font-size: 12px; }
.b-quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.b.removed { opacity: .8; }
.b-removed { font-style: italic; color: var(--muted); }
.b-tick { display: inline-flex; margin-left: 3px; vertical-align: -3px; }
.b-tick .ico { width: 15px; height: 15px; }
.b-tick.read { color: var(--accent); }
.b.flash { outline: 2px solid var(--accent); outline-offset: 2px; }
.msg-actions button { justify-content: flex-start; gap: 10px; }
.msg-actions button .ico { color: var(--accent); }
.msg-actions button.danger .ico { color: var(--warn); }
.reply-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 2px 2px 2px 10px; border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--bg); }
.reply-bar > .ico { color: var(--accent); }
.reply-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
a.icon-btn.top-call { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: var(--ctl);
  padding: 0; border: 0; background: none; color: var(--accent); }
.tpl-row .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-edit { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.tpl-edit textarea { min-height: 72px; font-family: inherit; }
.tpl-edit-actions { display: flex; gap: 6px; }
.tpl-edit-actions button { min-height: 36px; }
.notice-text { padding: 10px 12px; border-radius: 12px; background: var(--bg); white-space: pre-wrap; }
.edit-input { min-height: 96px; }

/* ---------- Чаты MAX, пункты 27–30 (18.11.2026): «не писать», уведомления, «как быстро отвечаю» ---------- */
.no-write-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 6px; padding: 6px 10px;
  border-radius: 10px; background: var(--open-bg); color: var(--open-text); font-size: 14px; }
.no-write-check { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.send-btn:disabled { opacity: .45; }
button:disabled { opacity: .45; cursor: not-allowed; }  /* неактивная кнопка видна сразу (18.11.2026) */
.push-on { font-weight: 600; }
.stat-note { font-size: 13px; margin-top: 8px; }

/* ---------- Чаты MAX, вторая волна (18.11.2026): фото, «в сети», закреплённое, контакт и ссылка, поиск ---------- */
img.av-img { object-fit: cover; padding: 0; background: var(--bg); }
.chat-who-text .online { color: var(--accent); font-weight: 700; }
.pin-strip { display: flex; align-items: center; gap: 6px; margin: 6px 8px 0; padding: 0 2px 0 10px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.pin-strip > .ico { color: var(--accent); flex: none; }
.pin-strip .pin-text { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: left; padding: 0; min-height: 40px; font-weight: 400; }
.b-pinned { display: inline-flex; align-items: center; gap: 3px; margin-top: 2px; font-size: 12px; color: var(--accent); }
.b-pinned .ico { width: 13px; height: 13px; }
.b-link { color: var(--accent); text-decoration: underline; word-break: break-all; }
.b-card { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 4px; padding: 8px 10px; border-radius: 10px;
  background: var(--bg); color: inherit; text-decoration: none; }
.b-card > .ico { color: var(--accent); flex: none; }
.b-card-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.b-card-text span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.b-card-actions { display: flex; gap: 6px; width: 100%; }
.b-card-actions .btn, .b-card-actions button { min-height: 36px; padding: 0 12px; font-size: 14px; }
.older-btn { display: block; margin: 4px auto 8px; min-height: 36px; font-size: 14px; }
.attach-chips { display: flex; gap: 6px; overflow-x: auto; }
.attach-chips .attach-chip { flex: 1 0 auto; max-width: 100%; }
.attach-chips .attach-chip:not(:only-child) { flex: none; width: 200px; }
.char-count { display: block; margin: 0 0 4px; font-size: 13px; color: var(--muted); text-align: right; }
.search-hits .search-title { margin: 12px 14px 4px; }
.hit-row .hit-text { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- «Переслать» (пункт 12, 18.11.2026) ---------- */
.fwd-list { display: flex; flex-direction: column; gap: 4px; max-height: 38vh; overflow-y: auto; margin: 6px 0 10px; }
.fwd-row { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; min-height: 48px;
  padding: 4px 10px; text-align: left; font-weight: 400; }
.fwd-row.on { border-color: var(--accent); background: var(--open-bg); }
.fwd-row > .ico { margin-left: auto; color: var(--accent); }
.fwd-name { display: flex; flex-direction: column; min-width: 0; }
.fwd-name .sub { font-size: 13px; color: var(--muted); }
.fwd-note { margin: 6px 0; }

