/* Тема только из Телеграма (переменные --tg-theme-*, их ставит telegram-web-app.js и меняет на лету).
   Запасные цвета нужны лишь вне Телеграма, где экран всё равно показывает «нет входа».
   Раскладка и размеры по макету (экраны «Дела» и «Карточка дела»), цвета макета не берём: ниже их роли
   сопоставлены переменным темы (_reports/miniapp_mockup/README.md, «Цвета»). Исключение одно: метки и точки
   срока, своих цветов у темы нет; они как в макете, отдельно для светлой и тёмной схемы Телеграма (атрибут
   data-scheme ставит app.js по colorScheme). Контраст текста меток к подложке 6.2-9.0, не меньше 4.5. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f2);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #fff));
  --line: var(--tg-theme-section-separator-color, rgba(0, 0, 0, .1));
  --ink: var(--tg-theme-text-color, #000);
  --sub: var(--tg-theme-hint-color, #888);
  --accent: var(--tg-theme-link-color, #2a7ae2);
  --prim: var(--tg-theme-button-color, #2a7ae2);
  --primi: var(--tg-theme-button-text-color, #fff);
  --lateb: #FCE9DD; --latei: #9A3412; --softb: #E4ECFF; --softi: #1A43A8; --calmb: #F0F0EC; --calmi: #4A4F58;
  --dotlate: #C2410C; --dotcalm: #8A8F98;
}
:root[data-scheme="dark"] {
  --lateb: #3A2116; --latei: #FDBA8C; --softb: #1E2A47; --softi: #B4C8FF; --calmb: #23272D; --calmi: #B8BDC6;
  --dotlate: #FB923C; --dotcalm: #6B717B;
}
* { box-sizing: border-box; }
/* Окно по высоте Телеграма (--app-h ставит app.js по tg.viewportHeight, то же число, что --tg-viewport-height;
   меняется при открытии клавиатуры). Страница целиком не прокручивается никогда: прокручивается
   только содержимое вкладки (.main) или лента «Спросить». Безопасные отступы: env() и отступы Телеграма
   (--safe-top, --safe-bottom ставит app.js по safeAreaInset и contentSafeAreaInset). */
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font: 16px/1.4 -apple-system, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;  /* касание срабатывает сразу: телефон не ждёт второго касания (увеличение двойным) */
}
#root { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h, var(--tg-viewport-height, 100%)); display: flex;
  flex-direction: column; padding-top: max(env(safe-area-inset-top), var(--safe-top, 0px)); overflow: hidden; }
/* 7ж: переход вместе с клавиатурой айфона ставит app.js (style у #root); под полем при открытой клавиатуре запас
   --kb-gap (настройка keyboard_gap, только на айфоне): iOS не докручивает страницу к полю */
#root.kb .ask-bar { padding-bottom: calc(10px + var(--kb-gap, 0px)); }
.main { flex: 1; min-height: 0; min-width: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.notice { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 2rem; text-align: center; color: var(--sub); }
button { font: inherit; border: 0; cursor: pointer; color: inherit; background: none; }
.primary { margin-top: 1rem; min-height: 44px; padding: .7rem 1.5rem; border-radius: 14px; font-weight: 600;
  background: var(--prim); color: var(--primi); }
.sub { color: var(--sub); font-size: 14px; }

/* Вкладки внизу: иконка над подписью */
/* клавиатура открыта (класс kb у #root, ставит app.js по уменьшению высоты при поле в фокусе): вкладок нет, поле
   прямо над клавиатурой */
#root.kb .tabs { display: none; }
.tabs { flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  height: calc(76px + max(env(safe-area-inset-bottom), var(--safe-bottom, 0px))); padding-bottom: max(env(safe-area-inset-bottom), var(--safe-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line); }
.tab { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; font-weight: 500; color: var(--sub); }
.tab.on { color: var(--accent); font-weight: 600; }

/* «Дела»: шапка, поиск, фильтры */
.top { padding: 20px 20px 12px; display: flex; flex-direction: column; gap: 14px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; }
.title-row h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.search { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; color: var(--sub);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
/* у всех полей ввода шрифт не меньше 16 px: иначе iOS при фокусе увеличивает экран и он уезжает вбок */
.search input { flex: 1; align-self: stretch; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 16px;
  background: transparent; color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 0 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; font-size: 14px; font-weight: 500;
  white-space: nowrap; background: var(--surface); border: 1px solid var(--line); }
.chip.on { background: var(--prim); color: var(--primi); border-color: var(--prim); }

/* Группы и строки */
.list { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 18px; }
section { display: flex; flex-direction: column; gap: 8px; }
.caption { margin: 0 4px; font-size: 13px; font-weight: 600; color: var(--sub); text-transform: uppercase;
  letter-spacing: 0.06em; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.row { display: flex; gap: 12px; width: 100%; padding: 14px; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { font-size: 16px; font-weight: 500; line-height: 1.3; }
.row-meta { font-size: 13px; color: var(--sub); line-height: 1.3; }
.dot { flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 4px; background: var(--dotcalm); }
.dot.overdue { background: var(--dotlate); }
.dot.today { background: var(--accent); }
.badge { flex: none; align-self: flex-start; font-size: 12px; font-weight: 500; padding: 4px 8px; border-radius: 8px;
  color: var(--calmi); background: var(--calmb); }
.badge.overdue { font-weight: 600; color: var(--latei); background: var(--lateb); }
.badge.today, .badge.soft { font-weight: 600; color: var(--softi); background: var(--softb); }
.empty { margin: 24px 4px; text-align: center; color: var(--sub); }

/* Плашка после действия: цвета темы наоборот (текст на подложке цвета текста) */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + max(env(safe-area-inset-bottom), var(--safe-bottom, 0px))); z-index: 3;
  display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--surface); font-size: 14px; line-height: 1.35;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 25%, transparent); }
.toast span { flex: 1; }
.toast button { min-height: 44px; padding: 0 12px; font-size: 14px; font-weight: 600; color: var(--surface);
  text-decoration: underline; }

/* Карточка дела: поверх списка и вкладок, действия прижаты книзу */
.sheet { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h, var(--tg-viewport-height, 100%)); z-index: 2;
  display: flex; flex-direction: column; background: var(--bg);
  padding-top: max(env(safe-area-inset-top), var(--safe-top, 0px)); }
.back-bar { padding: 12px 12px 0; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px; font-size: 16px;
  font-weight: 500; color: var(--accent); }
.card-body { flex: 1; overflow-y: auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.card-head { padding: 0 4px; display: flex; flex-direction: column; gap: 10px; }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.card-details { margin: 0; font-size: 15px; line-height: 1.45; }
.field { display: flex; justify-content: space-between; gap: 12px; padding: 13px 14px; font-size: 14px; }
.field + .field { border-top: 1px solid var(--line); }
.field .value { font-weight: 500; text-align: right; }
.quote { margin: 0; padding: 14px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; }
.history { padding: 4px 14px; }
.event { display: flex; gap: 12px; padding: 10px 0; font-size: 14px; }
.event + .event { border-top: 1px solid var(--line); }
.event .at { width: 64px; flex: none; font-size: 13px; }
.actions { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px calc(20px + max(env(safe-area-inset-bottom), var(--safe-bottom, 0px)));
  background: var(--surface); border-top: 1px solid var(--line); }
.actions .primary { margin: 0; height: 50px; font-size: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.secondary { height: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px;
  font-weight: 500; background: var(--surface); }
.secondary.accent { padding: 0 16px; color: var(--accent); font-weight: 600; }
.closed { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px;
  font-size: 15px; font-weight: 500; }

/* «Память» (макет Memory.dc.html). Отступление от макета: кнопки и переключатель 44 px вместо 36 и 40
   (всё нажимаемое не меньше 44 px). Подложка переключателя: линия темы (в макете свой серый --seg). */
.screen-title { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.lead { margin: 0; font-size: 14px; line-height: 1.4; color: var(--sub); }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px;
  background: var(--line); }
.seg button { height: 44px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--sub); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; }
.list.memory { gap: 10px; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; }
.item-title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.item .row-meta { line-height: 1.35; }
.mem-btn { flex: none; height: 44px; min-width: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 13px; font-weight: 500; }
.mem-btn.undo { border: 0; background: var(--softb); color: var(--softi); font-weight: 600; }

/* «Сегодня» (макет Summary.dc.html): шапка, встречи, дела сводки с номерами, ссылка на давние.
   Отступление: колонка времени встречи не 48 px, а по тексту: у агента со вторым городом время длиннее. */
.today-screen { padding: 20px 16px 16px; display: flex; flex-direction: column; gap: 18px; }
.today-head { padding: 0 4px; display: flex; flex-direction: column; gap: 4px; }
.event-row { display: flex; gap: 14px; padding: 13px 14px; }
.event-row + .event-row { border-top: 1px solid var(--line); }
.event-row .item-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.event-time { flex: none; max-width: 50%; min-width: 48px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.num { flex: none; width: 18px; font-size: 15px; font-weight: 600; color: var(--sub); font-variant-numeric: tabular-nums; }
.row-title.done { text-decoration: line-through; color: var(--sub); }
.more { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 16px;
  font-size: 15px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }


/* «Спросить» (макет Ask.dc.html) раскладкой чата: шапка, лента (прокручивается только она), поле ввода; вкладки
   ниже (при клавиатуре скрыты). Своё сообщение цветом главной кнопки темы (в макете свой --mine).
   Отступления: кнопка отправки вместо микрофона (микрофон в этапе 7). Подтверждения календаря и города в ленте
   последними, перед полем ввода. Анимации только transform и opacity. */
.ask { height: 100%; display: flex; flex-direction: column; min-width: 0; }
.ask-head { flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 20px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.ask-head h1 { margin: 0; font-size: 22px; font-weight: 700; flex: none; }
.ask-head .sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.talk-wrap { flex: 1; min-height: 0; position: relative; }
.talk { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; }
.talk-in { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.bubble { max-width: 88%; min-width: 0; padding: 10px 14px; font-size: 15px; line-height: 1.4; white-space: pre-wrap;
  overflow-wrap: anywhere; word-break: break-word; }
.bubble.mine { align-self: flex-end; max-width: 78%; border-radius: 18px 18px 6px 18px; background: var(--prim);
  color: var(--primi); }
.bubble.agent { align-self: flex-start; border-radius: 18px 18px 18px 6px; background: var(--surface);
  border: 1px solid var(--line); }
.bubble.agent a { color: var(--accent); text-decoration: none; }
.bubble blockquote { margin: 6px 0; padding-left: 10px; border-left: 2px solid var(--line); }
.hid { display: none; }  /* ещё не «напечатанное» слово: пузырь растёт по мере печати */
.answer { align-self: flex-start; max-width: 88%; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.answer .bubble { max-width: none; }
.answer .box { min-width: 0; }
.row.small { padding: 11px 12px; gap: 10px; }
.row.small .row-title { font-size: 14px; }
.quiet { display: flex; align-items: center; gap: 6px; min-height: 28px; font-size: 13px; color: var(--sub);
  min-width: 0; overflow-wrap: anywhere; }
.quiet .mem-btn { margin-left: 4px; }
.note { margin: 0; text-align: center; }
.confirm { padding: 12px 14px; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.choices .secondary { padding: 0 14px; }
/* пузырь этапа постоянного размера: смена этапа не двигает ленту */
.status { align-self: flex-start; box-sizing: border-box; width: 220px; max-width: 88%; height: 46px; display: flex;
  align-items: center; padding: 0 14px; border-radius: 18px 18px 18px 6px; background: var(--surface);
  border: 1px solid var(--line); color: var(--sub); overflow: hidden; }
.stg { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--sub); white-space: nowrap;
  animation: stg .3s ease-out; }
.stg svg { color: var(--accent); flex: none; }
@keyframes stg { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.lens { animation: lens 1.6s ease-in-out infinite; transform-origin: center; }
@keyframes lens { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(2px, -2px); }
  50% { transform: translate(0, -3px); } 75% { transform: translate(-2px, -1px); } }
.page { animation: page 1.4s ease-in-out infinite; transform-origin: 12px 9px; }
@keyframes page { 0%, 40% { transform: scaleY(1); } 55% { transform: scaleY(0.2); } 70%, 100% { transform: scaleY(1); } }
.pen { animation: pen 1.2s ease-in-out infinite; }
@keyframes pen { 0% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 100% { transform: translateX(-4px); } }
.ink { stroke-dasharray: 14; animation: ink 1.2s linear infinite; }
@keyframes ink { 0% { stroke-dashoffset: 14; } 100% { stroke-dashoffset: 0; } }
.down { position: absolute; right: 12px; bottom: 12px; z-index: 1; width: 44px; height: 44px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); animation: stg .2s ease-out; }
@media (prefers-reduced-motion: reduce) { .stg, .lens, .page, .pen, .ink, .down { animation: none; } }
.ask-bar { position: relative; flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 10px; min-width: 0;
  background: var(--bg); border-top: 1px solid var(--line); }
.ask-field { flex: 1; min-width: 0; display: flex; align-items: center; min-height: 46px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 23px; }
/* многострочное поле: растёт до 5 строк (5 по 20 px), дальше прокручивается внутри себя */
.ask-field textarea { flex: 1; min-width: 0; height: 20px; max-height: 100px; margin: 12px 0; padding: 0; border: 0;
  outline: 0; resize: none; overflow-y: auto; font: inherit; font-size: 16px; line-height: 20px;
  background: transparent; color: var(--ink); }
.send { width: 46px; height: 46px; flex: none; border-radius: 23px; display: flex; align-items: center;
  justify-content: center; background: var(--prim); color: var(--primi); }
.send:disabled { opacity: .5; pointer-events: none; }  /* касание уходит полосе ввода: фокус поля не теряется */
/* запись голоса поверх поля той же высоты (46 px): раскладка не прыгает, поле под панелью остаётся в фокусе
   (клавиатура не уезжает); вид по макету Ask.dc.html */
.send.voice { background: var(--accent); color: #fff; }
.rec { position: absolute; left: 12px; right: 12px; bottom: 10px; min-height: 46px; display: flex; gap: 10px;
  align-items: center; background: var(--bg); }
/* панель стоит ровно по полю: снизу тот же отступ, что у поля, с запасом под полем и без */
#root.kb .rec { bottom: calc(10px + var(--kb-gap, 0px)); }
/* курсор поля в фокусе iOS рисует поверх страницы: на время записи он прозрачный */
.ask-bar:has(.rec) textarea { caret-color: transparent; }
.rec-dot { width: 10px; height: 10px; flex: none; border-radius: 5px; background: var(--dotlate); }
.rec-text { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-time { color: var(--sub); font-variant-numeric: tabular-nums; }
.rec-cancel { height: 44px; flex: none; padding: 0 14px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--surface); color: var(--ink); font-size: 14px; }
.voiced svg { vertical-align: -2px; margin-right: 6px; }
/* заготовка реплики голосом, пока идёт расшифровка: три точки по очереди */
.dots { display: inline-flex; gap: 4px; vertical-align: 1px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: currentColor; opacity: .35; animation: dots 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dots { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }
.ask-toast { bottom: calc(150px + max(env(safe-area-inset-bottom), var(--safe-bottom, 0px))); }

/* Тур при первом открытии (М7, этап 8): карточки во всю ширину, листаются пальцем (прокрутка с прилипанием),
   под ними точки страниц и кнопки. Стоит вместо экранов, поэтому сверху отступ #root (вырез и кнопки Телеграма). */
.tour { flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding-bottom: calc(16px + max(env(safe-area-inset-bottom), var(--safe-bottom, 0px))); }
.tour-strip { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain; scrollbar-width: none; }
.tour-strip::-webkit-scrollbar { display: none; }
.tour-page { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; display: flex; align-items: center;
  padding: 16px; overflow-y: auto; }
/* карточка по макету Tour.dc.html: кусочек вкладки (или значок) сверху, под ним заголовок и текст. По центру по высоте
   отступом auto (страница тура это section, у него колонка): не влезла по высоте, верх не обрежется, страница прокрутится */
.tour-card { width: 100%; margin: auto 0; padding: 20px 20px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  display: flex; flex-direction: column; gap: 22px; }
.tour-card h1 { margin: 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.tour-card p { margin: -14px 4px 0; font-size: 16px; line-height: 1.45; color: var(--sub); }
.tour-icon { width: 64px; height: 64px; margin: 4px 4px 0; border-radius: 20px; display: flex; align-items: center;
  justify-content: center; background: var(--softb); color: var(--accent); }
/* кусочек вкладки: строки те же, что на вкладке, на фоне экрана */
.tour-frag { display: flex; flex-direction: column; justify-content: center; gap: 10px; min-height: 200px; padding: 16px;
  border-radius: 16px; background: var(--bg); }
.tour-frag .caption { margin: 0; }
.tour-frag .ask-bar { padding: 0; border: 0; background: none; }  /* граница отделяет полосу от ленты, здесь ленты нет */
.tour-note { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); }
.tour-dots { flex: none; display: flex; justify-content: center; gap: 8px; padding: 4px 0 16px; }
.tour-dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--line); }
.tour-dots i.on { background: var(--accent); }
.tour-actions, .offer-actions { flex: none; display: flex; gap: 10px; }
.tour-actions { padding: 0 16px; }
.tour-actions button, .offer-actions button { flex: 1; min-width: 0; margin: 0; height: 50px; font-size: 16px; }
/* вторая кнопка рядом с главной («Пропустить», «Не сейчас»): рамка без заливки, видна на любом фоне */
.second { border-radius: 14px; font-weight: 600; text-align: center; background: transparent; border: 1px solid var(--line); }
/* Предложение значка на экран (М1): поверх экрана, внизу, над краем телефона */
.offer-back { position: fixed; inset: 0; z-index: 4; display: flex; align-items: flex-end; background: rgba(0, 0, 0, .35);
  padding: 16px 16px calc(16px + max(env(safe-area-inset-bottom), var(--safe-bottom, 0px))); }
.offer { width: 100%; padding: 20px; background: var(--surface); border-radius: 20px; }
.offer p { margin: 0 0 16px; font-size: 17px; line-height: 1.4; }
