:root {
  /* Текст и линии */
  --ink: #081a37;          /* тёмно-синий основной текст */
  --ink-soft: #263b5b;     /* текст внутри карточек */
  --muted: #52627a;        /* подписи с устойчивым контрастом */
  --line: #cbd8ea;
  --line-strong: #687b99;  /* заметные границы полей ввода */
  --soft: #edf3fb;
  --paper: #ffffff;

  /* Синий. Три ступени, и у каждой своя работа:
     accent — заливки и иконки (текст на нём не пишем),
     accent-dark — кнопки и ссылки: белый текст на нём даёт 5.9:1,
     accent-deep — заголовки и наведение. */
  --accent: #2463eb;
  --accent-dark: #1c54c7;
  --accent-deep: #0b357c;
  --accent-hover: #071f4b;
  --accent-soft: #dfe9ff;   /* заливка активных элементов */
  --accent-wash: #f2f6ff;   /* фон блоков-подсказок */
  --accent-line: #bcd0f4;

  --warning: #785000;
  --warning-bg: #fff4ca;
  --danger: #b3261e;
  --danger-bg: #fdf6f6;
  --danger-line: #e9c3c3;

  /* Тени скупые. Большие мягкие свечения — примета наспех собранного
     сайта: в госсервисах глубину показывают линией, а не размытием. */
  --shadow: 0 18px 60px rgba(7, 31, 75, .15), 0 2px 8px rgba(7, 31, 75, .08);
  --shadow-card: 0 8px 26px rgba(7, 31, 75, .09), 0 1px 3px rgba(7, 31, 75, .06);

  /* Скругления сдержанные: сильно скруглённые «пилюли» читаются как
     мессенджер, а не как городская справочная. */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 34px;

  /* Жёлтая рамка фокуса — приём из GOV.UK Design System. Её видно
     на любом фоне и при любом типе цветовосприятия. */
  --focus: #ffdd00;
  --focus-text: #0b0c0c;
  --gap-xs: 8px;
  --gap-sm: 12px;
  --gap-md: 18px;
  --gap-lg: 28px;
  --gap-xl: 40px;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен прятать всегда. Иначе любой класс с display
   его перебивает — так на странице обращения постоянно висела пометка
   «тема подставлена из чата», даже когда из чата не приходили. */
[hidden] { display: none !important; }

html, body { height: 100%; }
/* Обычные страницы прокручиваются документом, а не внутренним блоком. */
body.layout-doc, body.layout-doc html { height: auto; }

body {
  margin: 0;
  color: var(--ink);
  /* Ровный фон без градиентного свечения в углу. Свечение ничего
     не сообщало и первым выдавало «сайт из генератора». */
  background: #f4f6f7;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(1040px, calc(100% - 40px));
  margin: 18px auto;
  display: grid;
}

/* Чат и карта: окно фиксированной высоты, прокрутка внутри. */
.layout-app .app-shell {
  height: min(880px, calc(100dvh - 36px));
  min-height: 620px;
  grid-template-rows: 72px minmax(0, 1fr) 26px;
}

/* Обычные страницы: высота по содержимому, подвал прижат к низу экрана. */
.layout-doc .app-shell {
  min-height: calc(100dvh - 36px);
  grid-template-rows: 72px 1fr auto;
}

/* Рамка фокуса — жёлтая, как в GOV.UK. Тонкая цветная обводка теряется
   на цветных кнопках; жёлтая полоса видна всегда и сразу говорит,
   где ты находишься при работе с клавиатуры. */
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  box-shadow: 0 3px 0 0 var(--focus-text);
  border-radius: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  color: white;
  background: var(--ink);
  transition: transform .25s ease, background .25s ease;
}

.brand:hover .brand-mark { background: var(--accent-dark); }
.brand-mark svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 16px; letter-spacing: -.01em; }
.brand-copy small { color: #82909b; font-size: 11px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: #48a783; box-shadow: none; }

.about-button {
  height: 38px;
  padding: 0 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255,255,255,.7);
  cursor: pointer;
  transition: transform .16s ease, border-color .2s ease, background .2s ease;
}
.about-button:hover { border-color: #b8c8d1; background: white; }


.chat {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(203, 214, 221, .9);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.conversation {
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 34px clamp(24px, 7vw, 82px) 24px;
  scrollbar-width: thin;
  scrollbar-color: #ccd7dd transparent;
}

/* Экран приветствия. Раньше он был по центру, с огромным заголовком
   и пустотой сверху и снизу — так выглядит рекламная посадочная
   страница, а не городская справочная. Теперь по левому краю и
   сверху: человек сразу видит, куда писать и что можно спросить. */
.welcome {
  width: min(720px, 100%);
  margin: 0 auto;
  padding-top: clamp(16px, 5vh, 56px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  animation: welcomeIn .25s ease-out both;
}

.welcome.leaving { animation: welcomeOut .24s ease both; }
/* Крупная плашка с иконкой поверх заголовка ничего не сообщала.
   Оставляем её только как небольшой знак рядом с надзаголовком. */
.welcome-icon {
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--accent-deep);
  border-radius: var(--r-lg);
  box-shadow: none;
}
.welcome-icon svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { margin: 0 0 10px; color: var(--accent-dark); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
/* Заголовок сдержаннее: 54 пикселя занимали пол-экрана и не добавляли
   ни смысла, ни доверия. */
.welcome h1 { margin: 0; max-width: 18ch; font-size: clamp(27px, 3.2vw, 36px); line-height: 1.15; letter-spacing: -.015em; }
.welcome-text { max-width: 56ch; margin: 12px 0 24px; color: var(--muted); font-size: 15px; line-height: 1.55; }
/* Подпись над списком подсказок: список должен читаться как список,
   а не как набор рекламных плиток. */
.suggestions-label { margin: 0 0 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }

.suggestions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.suggestions button {
  min-width: 0;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: white;
  cursor: pointer;
  box-shadow: none;
  transition: transform .18s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.suggestions button:hover { border-color: var(--accent-dark); background: var(--accent-wash); }
.suggestions button:active, .suggestions button.is-pressed { background: var(--accent-soft); }
.suggestion-icon { flex: 0 0 34px; height: 34px; display: grid; place-items: center; color: var(--accent-dark); background: var(--accent-soft); border-radius: var(--r-sm); font-weight: 700; }
.suggestion-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.suggestions b, .suggestions small { display: block; }
.suggestions b { margin-bottom: 3px; font-size: 13px; }
.suggestions small { color: var(--muted); font-size: 11px; }

.message { width: min(760px, 100%); margin: 0 auto 18px; animation: messageIn .18s ease-out both; }
.message.user { display: flex; justify-content: flex-end; }
.user-bubble { max-width: min(610px, 88%); padding: 12px 16px; color: white; background: var(--ink); border-radius: var(--r-md); font-size: 14px; line-height: 1.45; }

.assistant-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start; }
.assistant-avatar { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--accent); border-radius: var(--r-md); }
.assistant-avatar svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.assistant-bubble { min-width: 0; padding: 17px 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: white; box-shadow: var(--shadow-card); }
.answer-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.answer-status { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-dark); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.answer-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #48a783; }
.answer-status.low { color: var(--warning); }
.answer-status.low::before { background: #d28a25; }
.copy-button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: var(--muted); border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer; transition: background .2s, transform .15s; }
.copy-button:hover { color: var(--ink); background: var(--soft); }

.copy-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.answer-copy { margin: 0; color: #203749; font-size: 15px; line-height: 1.58; white-space: pre-line; }

.route-list { margin: 15px 0 0; padding: 0; display: grid; gap: 8px; list-style: none; counter-reset: route; }
.route-list li { counter-increment: route; display: grid; grid-template-columns: 24px 1fr; gap: 9px; color: #31495a; font-size: 13px; line-height: 1.45; }
.route-list li::before { content: counter(route); width: 22px; height: 22px; display: grid; place-items: center; color: var(--accent-dark); background: var(--accent-soft); border-radius: var(--r-sm); font-size: 10px; font-weight: 800; }

.contacts { margin-top: 14px; padding: 11px 13px; display: flex; flex-wrap: wrap; gap: 7px 14px; color: #344d5f; background: var(--soft); border-radius: var(--r-md); font-size: 12px; line-height: 1.4; }
.contacts span { display: inline-flex; align-items: center; gap: 6px; }
.contacts span::before { content: "•"; color: var(--accent); }

.answer-warning { margin: 13px 0 0; padding: 10px 12px; color: var(--warning); background: var(--warning-bg); border-radius: var(--r-sm); font-size: 12px; line-height: 1.45; }
/* Переходы в наши разделы: карта, конструктор обращения, отключения.
   Визуально отделены от внешних источников — это разные действия. */
.site-links { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 7px; }
.site-links-title { margin: 0 0 2px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.site-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: white; color: var(--ink); text-decoration: none; transition: border-color .18s ease, background .18s ease, transform .16s ease; }
.site-link:hover { border-color: var(--accent); background: var(--soft); }

.site-link-icon { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-dark); }
.site-link-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.site-link-copy { display: grid; gap: 1px; min-width: 0; }
.site-link-copy b { font-size: 12.5px; font-weight: 700; line-height: 1.3; }
.site-link-copy small { font-size: 11px; color: var(--muted); line-height: 1.35; }

.answer-actions { margin-top: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
/* Фон намеренно accent-dark, а не accent: на светлом accent белый текст
   даёт 4.4:1 и не дотягивает до нормы. */
.primary-source { min-height: 40px; padding: 0 15px; display: inline-flex; align-items: center; gap: 8px; color: white; background: var(--accent-dark); border-radius: var(--r-md); text-decoration: none; font-size: 12px; font-weight: 700; transition: transform .16s ease, background .2s ease, box-shadow .2s ease; }
.primary-source:hover { background: var(--accent-deep); }

.primary-source svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.source-details { position: relative; }
/* «Источники: 3 +» читалось как опечатка. Показываем словом, что это
   раскрывающийся список. */
.source-details summary { display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 0 10px; color: var(--muted); cursor: pointer; font-size: 11.5px; list-style: none; border-radius: var(--r-sm); }
.source-details summary:hover { color: var(--ink); background: var(--soft); }
.source-details summary::-webkit-details-marker { display: none; }
.source-details summary::after { content: "показать"; text-decoration: underline; }
.source-details[open] summary::after { content: "скрыть"; }
.source-list { position: absolute; z-index: 5; left: 0; bottom: 42px; width: min(330px, 76vw); padding: 8px; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: var(--r-md); background: white; box-shadow: var(--shadow); animation: popIn .18s ease both; }
.source-list a { padding: 9px 10px; color: var(--ink); border-radius: var(--r-sm); text-decoration: none; font-size: 11px; line-height: 1.35; }
.source-list a:hover { background: var(--soft); }

.typing .assistant-bubble { width: 76px; padding: 15px 18px; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: #8aa0ac; animation: typing 1.1s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .13s; }
.typing-dots i:nth-child(3) { animation-delay: .26s; }

.composer-area { padding: 13px clamp(16px, 6vw, 72px) 14px; background: linear-gradient(to top, white 82%, rgba(255,255,255,.86)); border-top: 1px solid #edf1f3; }
.composer { width: min(780px, 100%); margin: auto; min-height: 54px; padding: 7px 7px 7px 17px; display: flex; align-items: flex-end; gap: 10px; border: 1px solid #cbd7dd; border-radius: var(--r-lg); background: white; box-shadow: var(--shadow-card); transition: border-color .2s ease, box-shadow .2s ease; }
.composer:focus-within { border-color: var(--accent-dark); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { flex: 1; height: 38px; max-height: 112px; padding: 9px 0 7px; resize: none; overflow-y: auto; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: 14px; line-height: 1.45; }
.composer textarea::placeholder { color: #93a1aa; }
.send-button { flex: 0 0 40px; width: 40px; height: 40px; display: grid; place-items: center; color: white; border: 0; border-radius: var(--r-md); background: var(--accent); cursor: pointer; transition: transform .16s ease, background .2s ease; }
.send-button:hover { background: var(--accent-dark); }
.send-button:disabled { cursor: wait; opacity: .6; }
.send-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.send-button:hover svg { transform: translateX(2px); }
.composer-note { margin: 7px auto 0; width: min(780px, 100%); color: #97a4ad; font-size: 10px; text-align: center; }
/* Строка под чатом. Раньше индикатор и кнопка «О проекте» стояли
   встык и налезали друг на друга. */
.legal-line {
  margin: 7px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}
.legal-line .about-button { height: 28px; padding: 0 11px; font-size: 11px; }

.about-dialog { width: min(460px, calc(100% - 32px)); padding: 24px; color: var(--ink); border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow); animation: dialogIn .25s ease both; }
.about-dialog::backdrop { background: rgba(18, 35, 49, .38); backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; }
.dialog-head span { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.dialog-head h2 { margin: 4px 0 13px; font-size: 26px; letter-spacing: -.015em; }
.dialog-head button { width: 34px; height: 34px; color: var(--muted); border: 0; border-radius: var(--r-sm); background: var(--soft); cursor: pointer; font-size: 24px; line-height: 1; }
.about-dialog p, .about-dialog li { color: #536879; font-size: 13px; line-height: 1.55; }
.about-dialog ul { padding-left: 19px; }
.dialog-warning { padding: 11px 13px; background: var(--warning-bg); border-radius: var(--r-sm); }
.dialog-author { margin-top: 17px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.dialog-author a { color: var(--accent-dark); font-weight: 700; }

@keyframes welcomeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes welcomeOut { to { opacity: 0; } }
@keyframes messageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes popIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialogIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 680px) {
  body { background: white; }
  .app-shell { width: 100%; margin: 0; }
  /* Фиксированная высота — только для чата и карты. На обычных страницах
     она возвращала внутреннюю прокрутку: адресная строка не пряталась,
     а якоря и кнопка «наверх» работали через раз. */
  .layout-app .app-shell { height: 100dvh; min-height: 0; grid-template-rows: 64px minmax(0, 1fr) 20px; }
  .layout-doc .app-shell { min-height: 100dvh; }
  .topbar { padding: 0 14px; border-bottom: 1px solid #edf1f3; }
  .brand-mark { width: 37px; height: 37px; border-radius: var(--r-md); }
  .brand-copy small, .status span { display: none; }
  .status { margin-right: -5px; }
  .about-button { height: 36px; padding: 0 12px; }
  .chat { border: 0; border-radius: 0; box-shadow: none; }
  .conversation { padding: 22px 14px 18px; }
  .welcome { justify-content: flex-start; padding-top: clamp(18px, 8vh, 70px); }
  .welcome-icon { width: 48px; height: 48px; margin-bottom: 15px; border-radius: var(--r-md); }
  .welcome h1 { font-size: 35px; }
  .welcome-text { margin: 14px 12px 22px; font-size: 14px; }
  .suggestions { grid-template-columns: 1fr; gap: 8px; }
  .suggestions button { padding: 12px 14px; }
  .message { margin-bottom: 15px; }
  .assistant-row { grid-template-columns: 30px minmax(0,1fr); gap: 8px; }
  .assistant-avatar { width: 30px; height: 30px; border-radius: var(--r-sm); }
  .assistant-bubble { padding: 15px 14px; }
  .answer-copy { font-size: 14px; }
  .user-bubble { max-width: 92%; font-size: 13px; }
  /* На узком экране кнопка источника занимает свою строку целиком:
     рядом со ссылкой «показать» она сжималась в три строки. */
  .answer-actions { align-items: stretch; gap: 4px; }
  .primary-source { flex: 1 1 100%; justify-content: center; }
  .source-details { align-self: flex-start; }
  .source-list { left: auto; right: 0; }
  .composer-area { padding: 10px 12px max(9px, env(safe-area-inset-bottom)); }
  .composer-note { display: none; }
  .legal-line { margin: 4px 0 0; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Блок "сейчас в городе" на главной: ближайшее отключение ЖКХ или спокойное
   подтверждение, что их нет. Задача — показать пользу сайта до первого
   вопроса в чат. На узких экранах прячем: там дороже место, а раздел
   "Отключения" всё равно есть в меню. */
.city-now {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: var(--accent-soft, transparent);
}
.city-now .ic {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--accent-dark);
}
.city-now-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.city-now-copy b {
  font-size: 0.95rem;
}
.city-now-copy small {
  opacity: 0.75;
}
.city-now:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
@media (max-width: 680px) {
  .city-now {
    display: none;
  }
}
