:root {
  color-scheme: light;
  --bg: #fffaf6;
  --surface: #fffefd;
  --surface-soft: #f4ebe5;
  --ink: #1c1a18;
  --text: #39342f;
  --soft: #776e67;
  --hair: #e8ddd6;
  --accent: #a9745b;
  --accent-deep: #834d36;
  --accent-pale: #f1dfd3;
  --success: #4b7258;
  --danger: #9b5446;
  --radius: 6px;
  --shadow: 0 16px 36px rgba(77, 47, 33, 0.08);
  /* Ниже — «семантические» токены: раньше это были захардкоженные цвета в
     правилах. Вынесены сюда, чтобы тёмная тема переопределялась одним блоком,
     а сами правила ссылались только на переменные. */
  --cta-bg: var(--ink);       /* фон крупных primary-кнопок */
  --cta-fg: #fff;
  --pill-bg: var(--ink);      /* пузырь «моего» сообщения */
  --pill-fg: #fff;
  --field-bg: #fff;           /* фон полей ввода/селектов */
  --danger-surface: #fff8f6;  /* фон плашек ошибок */
  --media-placeholder: #eadfd8;
  --body-glow: #f7e8de;       /* тёплое пятно в углу фона */
  --surface-translucent: rgba(255, 254, 253, 0.84);
  --tryon-grad-from: #fff8f3;
  --tryon-grad-to: #f5e7dd;
  --tryon-border: #ddc0ae;
  --composer-fade: rgba(255, 250, 246, 0.55);
  --avatar-grad-from: #bd886d;
}

/* Тёмная тема. Системная настройка (prefers-color-scheme) — сигнал по
   умолчанию; ручной переключатель ставит data-theme на <html> и побеждает
   систему в обе стороны. Значения продублированы в двух селекторах намеренно:
   так первый кадр у системно-тёмных юзеров уже тёмный (без вспышки), а
   форсированная тема работает поверх. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17120e;
    --surface: #201a15;
    --surface-soft: #2a231d;
    --ink: #f5ece4;
    --text: #e6dcd2;
    --soft: #a99c8d;
    --hair: #372c24;
    --accent: #bf8263;
    --accent-deep: #e2b492;
    --accent-pale: #3a2b21;
    --success: #6fae86;
    --danger: #e59987;
    --shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    --cta-bg: var(--accent);
    --cta-fg: #1d1309;
    --pill-bg: #3a2f26;
    --pill-fg: #f5ece4;
    --field-bg: #241e19;
    --danger-surface: #2c1a16;
    --media-placeholder: #33291f;
    --body-glow: #2a1a10;
    --surface-translucent: rgba(32, 26, 21, 0.84);
    --tryon-grad-from: #2a2018;
    --tryon-grad-to: #211a13;
    --tryon-border: #3d2e22;
    --composer-fade: rgba(23, 18, 14, 0.55);
    --avatar-grad-from: #bd886d;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17120e;
  --surface: #201a15;
  --surface-soft: #2a231d;
  --ink: #f5ece4;
  --text: #e6dcd2;
  --soft: #a99c8d;
  --hair: #372c24;
  --accent: #bf8263;
  --accent-deep: #e2b492;
  --accent-pale: #3a2b21;
  --success: #6fae86;
  --danger: #e59987;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  --cta-bg: var(--accent);
  --cta-fg: #1d1309;
  --pill-bg: #3a2f26;
  --pill-fg: #f5ece4;
  --field-bg: #241e19;
  --danger-surface: #2c1a16;
  --media-placeholder: #33291f;
  --body-glow: #2a1a10;
  --surface-translucent: rgba(32, 26, 21, 0.84);
  --tryon-grad-from: #2a2018;
  --tryon-grad-to: #211a13;
  --tryon-border: #3d2e22;
  --composer-fade: rgba(23, 18, 14, 0.55);
  --avatar-grad-from: #bd886d;
}

* {
  box-sizing: border-box;
}

/* Component display rules must never override semantic hidden state. */
[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  overflow-x: hidden;
}

body {
  min-width: 0;
  min-height: 100dvh;
  margin: 0;
  /* Здесь overflow-x НЕ задаём: он делает body собственным контейнером
     прокрутки и убивает position:sticky у шапки. Горизонтальную прокрутку и
     так режет html — по спецификации overflow корня уходит во вьюпорт. */
  color: var(--text);
  background: radial-gradient(circle at 92% 0%, var(--body-glow) 0, transparent 26rem), var(--bg);
  font-family: "Golos Text", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
select,
input {
  font: inherit;
}

button,
select,
input[type="file"] {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(169, 116, 91, 0.42);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  border-bottom: 1px solid var(--hair);
  /* Шапка липнет к верху, поэтому под ней не должно просвечивать сообщение. */
  background: var(--bg);
}

.account-menu {
  position: sticky;
  top: 64px;
  z-index: 5;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark,
.avatar {
  display: block;
  flex: 0 0 auto;
  /* Пиксель-аватарка Лизы (тот же образ — иконка приложения и сплэш).
     Градиент остаётся фоном, пока картинка не догрузилась. */
  background: linear-gradient(145deg, var(--avatar-grad-from), var(--accent-deep));
  object-fit: cover;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.brand strong,
.brand span span {
  display: block;
}

.brand strong {
  font-size: 1rem;
  line-height: 1.08;
}

.brand span span,
.card-kicker,
.timeline-label,
.selected-media {
  color: var(--soft);
  font-size: 0.75rem;
  line-height: 1.3;
}

.brand span span {
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.balance-button,
.menu-button,
.icon-button,
.quiet-button,
.feedback-button,
.tryon-source-button {
  min-height: 44px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}

.balance-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  color: var(--accent-deep);
  font-size: 0.8rem;
  font-weight: 600;
}

.menu-button,
.icon-button {
  width: 44px;
  padding: 0;
  font-size: 1.08rem;
}

.buy-button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.buy-button:hover {
  /* Затемнение через фильтр вместо смены цвета: в тёмной теме --accent-deep
     светлый (это цвет ТЕКСТА), и белая подпись на нём читалась бы плохо. */
  border-color: var(--accent-deep);
  filter: brightness(1.06);
}

.buy-button-compact {
  display: none;
}

.account-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 0;
  padding: 8px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-menu button,
.account-menu a {
  min-height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  font-size: 0.78rem;
  /* Пункт «Помощь» — ссылка t.me; выглядит как остальные кнопки меню. */
  display: flex;
  align-items: center;
  text-decoration: none;
}

.account-menu button:hover,
.account-menu a:hover {
  background: var(--surface-soft);
}

.chat {
  min-height: calc(100dvh - 174px);
}

.login-view {
  padding: clamp(38px, 9vw, 72px) 0 28px;
}

.eyebrow,
.card-kicker {
  margin: 0;
  color: var(--accent-deep);
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.login-view h1,
.login-card h2,
.sheet h2 {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.033em;
}

.login-view h1 {
  max-width: 10.5ch;
  margin-top: 10px;
  font-size: clamp(2.35rem, 11vw, 4rem);
  line-height: 0.98;
}

.login-lead {
  max-width: 34rem;
  margin: 18px 0 0;
  color: var(--soft);
  font-size: 1rem;
  line-height: 1.55;
}

.login-card,
.operation-card,
.style-context,
.notice {
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--surface);
}

.login-card {
  display: grid;
  gap: 18px;
  margin-top: 28px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin-top: 5px;
  font-size: 1.14rem;
  line-height: 1.2;
}

.login-card p:last-child,
.login-note,
.sheet-card > p {
  margin: 8px 0 0;
  color: var(--soft);
  font-size: 0.94rem;
  line-height: 1.5;
}

.login-note {
  max-width: 31rem;
  margin-top: 16px;
  font-size: 0.82rem;
}

.primary-button {
  display: inline-grid;
  min-height: 48px;
  place-items: center;
  padding: 11px 16px;
  border: 1px solid var(--cta-bg);
  border-radius: var(--radius);
  color: var(--cta-fg);
  background: var(--cta-bg);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 160ms ease, transform 160ms ease;
}

.primary-button:hover,
.primary-button:active {
  border-color: var(--accent);
  background: var(--accent);
}

.primary-button:active,
.send-button:active,
.photo-button:active {
  transform: scale(0.985);
}

.workspace {
  padding: 18px 0 10px;
}

.style-context {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface-translucent);
}

.style-context .avatar,
.message .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.style-context p:last-child {
  margin: 3px 0 0;
  color: var(--soft);
  font-size: 0.8rem;
  line-height: 1.35;
}

.online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(75, 114, 88, 0.12);
}

.timeline {
  padding: 22px 0 14px;
  transition: opacity 160ms ease;
}

.timeline-label {
  margin: 2px 0 15px;
  text-align: center;
}

.message-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.message,
.operation-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.message--you {
  justify-content: flex-end;
}

.bubble {
  max-width: min(90%, 34rem);
  padding: 13px 14px;
  border: 1px solid var(--hair);
  border-radius: 14px 14px 14px 4px;
  background: var(--surface);
  box-shadow: 0 6px 17px rgba(54, 35, 26, 0.035);
}

.message--you .bubble {
  color: var(--pill-fg);
  border-color: var(--pill-bg);
  border-radius: 14px 14px 4px 14px;
  background: var(--pill-bg);
}

.message-copy {
  margin: 0;
  overflow-wrap: anywhere;
  /* pre-line сохраняет переносы строк внутри абзаца (сервер бьёт ответ на
     блоки по пустым строкам, а одиночные \n рисуют короткие строки), лишние
     пробелы при этом схлопываются — стена текста больше не склеивается. */
  white-space: pre-line;
  font-size: 0.95rem;
  line-height: 1.5;
}

.message-copy + .message-copy {
  margin-top: 8px;
}

.media-label {
  margin: 10px 0 0;
  color: inherit;
  font-size: 0.78rem;
  opacity: 0.78;
}

.message-media {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.message-media--album {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.message-photo {
  display: block;
  width: 100%;
  max-height: 320px;
  /* Место под фото резервируем ДО загрузки: иначе картинка догружается после
     прокрутки к последнему сообщению и сдвигает ленту вниз. */
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  background: var(--surface-soft);
  object-fit: cover;
  /* Клик открывает полноэкранный просмотр (лайтбокс). */
  cursor: zoom-in;
}

.message-media--album .message-photo {
  aspect-ratio: 1;
  max-height: none;
}

.message-time {
  display: block;
  margin-top: 6px;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  opacity: 0.6;
  text-align: right;
}

.day-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
}

.day-separator span {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--soft);
  background: var(--surface-soft);
  font-size: 0.7rem;
  font-weight: 600;
}

.tryon-source-button {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  color: var(--accent-deep);
  background: var(--field-bg);
  font-size: 0.8rem;
  font-weight: 600;
}

.feedback-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.feedback-button {
  min-height: 44px;
  padding: 6px 10px;
  color: var(--accent-deep);
  background: var(--surface-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

/* Оценка разбора — иконки 👍/👎, как в Telegram-боте. */
.feedback-button--icon {
  min-width: 52px;
  font-size: 1.05rem;
  line-height: 1;
}

.feedback-reason {
  display: grid;
  width: 100%;
  gap: 7px;
}

.feedback-reason-input {
  width: 100%;
  min-height: 64px;
  padding: 9px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--field-bg);
  font-size: 1rem;
  line-height: 1.38;
  resize: none;
}

.feedback-reason .quiet-button,
.notice .quiet-button {
  margin-top: 0;
}

.operation-message {
  justify-content: flex-start;
}

.operation-card {
  width: min(100%, 34rem);
  padding: 14px;
  background: var(--surface-soft);
  animation: answer-in 220ms ease both;
}

.operation-card--tryon {
  border-color: var(--tryon-border);
  background: linear-gradient(145deg, var(--tryon-grad-from), var(--tryon-grad-to));
}

.operation-status {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
}

.operation-card .message-copy {
  margin-top: 9px;
}

.clarification-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.clarification-guidance {
  margin: 0;
  color: var(--soft);
  font-size: 0.84rem;
  line-height: 1.42;
}

.clarification-candidate {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid rgba(131, 77, 54, 0.2);
  border-radius: 4px;
  background: var(--surface-translucent);
}

.clarification-preview,
.tryon-result {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: var(--media-placeholder);
  object-fit: cover;
}

.clarification-preview {
  aspect-ratio: 1;
}

.tryon-result {
  /* Как и у фото в сообщении, место резервируем заранее: иначе результат
     примерки догружается и сдвигает ленту после прокрутки к последнему. */
  aspect-ratio: 3 / 4;
  max-height: 360px;
  margin-top: 12px;
  cursor: zoom-in;
}

/* --- Полноэкранный просмотр фото (лайтбокс) -------------------------------- */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.lightbox::backdrop {
  background: rgba(15, 10, 7, 0.88);
}

.lightbox-frame {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  width: 100%;
  height: 100%;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  gap: 14px;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  align-self: center;
  border-radius: 8px;
  object-fit: contain;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-download {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.clarification-select,
.profile-select,
.field-label textarea,
.composer textarea {
  width: 100%;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--field-bg);
}

.clarification-select,
.profile-select {
  min-height: 44px;
  padding: 8px 10px;
  /* Контролы держат ≥16px: наследованные 14.4px заставляли iOS зумить
     страницу при фокусе. */
  font-size: 1rem;
}

.quiet-button {
  width: 100%;
  margin-top: 12px;
  padding: 9px 11px;
  color: var(--accent-deep);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px;
  color: var(--accent-deep);
  font-size: 0.86rem;
  line-height: 1.4;
}

.notice--error {
  color: var(--danger);
  border-color: rgba(155, 84, 70, 0.28);
  background: var(--danger-surface);
}

.notice-link {
  color: inherit;
  font-weight: 700;
}

.composer {
  position: sticky;
  bottom: 0;
  display: grid;
  /* Кнопки уже, чем раньше (52px): на 360px они съедали 35% строки,
     текстовому полю оставалось меньше 190px. Тач-цель держит высота 46px. */
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
  background: linear-gradient(180deg, var(--composer-fade), var(--bg) 35%);
}

.photo-button,
.send-button {
  display: grid;
  /* Кнопки тянутся до высоты поля (81px): узкие, но во всю строку — палец
     попадает, а ширина не отъедает у текста ни пикселя. */
  width: 46px;
  height: 81px;
  min-height: 81px;
  place-items: center;
  border-radius: var(--radius);
  font-weight: 600;
}

.photo-button {
  gap: 2px;
  border: 1px solid var(--hair);
  color: var(--accent-deep);
  background: var(--surface-soft);
  font-size: 0.6rem;
}

.photo-button svg {
  display: block;
  width: 19px;
  height: 19px;
}

.composer-field {
  position: relative;
  min-width: 0;
}

.composer textarea {
  display: block;
  /* Ещё +35% к высоте по просьбе тестеров: в поле видно три строки текста. */
  min-height: 81px;
  /* Потолок совпадает с JS-лимитом в resizeComposer (160): CSS-значение 112
     молча обрезало рост, который JS считал разрешённым. */
  max-height: 160px;
  resize: none;
  padding: 11px 13px 10px;
  font-size: 1rem;
  line-height: 1.3;
}

.composer textarea::placeholder {
  color: var(--soft);
  opacity: 1;
}

.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
  padding: 2px 0 4px;
}

.attachment-chip {
  position: relative;
  display: block;
  width: 56px;
  height: 56px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--surface-soft);
}

.attachment-thumb {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  object-fit: cover;
}

.attachment-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  width: 22px;
  height: 22px;
  min-height: 22px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(28, 26, 24, 0.18);
  font-size: 0.8rem;
  line-height: 1;
}

.send-button {
  position: relative;
  border: 1px solid var(--accent);
  color: #fff;
  background: var(--accent);
  font-size: 1.45rem;
}

/* Пока запрос летит, стрелку сменяет спиннер: одно затемнение disabled
   на медленной сети читалось как «нажатие не сработало». */
.send-button.is-loading span {
  visibility: hidden;
}

.send-button.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 20px;
  height: 20px;
  margin: auto;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: send-spin 700ms linear infinite;
}

@keyframes send-spin {
  to {
    transform: rotate(360deg);
  }
}

.install-help {
  position: relative;
  margin: 10px 0 0;
  padding: 15px 40px 4px 0;
  border-top: 1px solid var(--hair);
}

/* Крестик «скрыть подсказку об установке» (п.5): блок больше не висит вечно. */
.install-dismiss {
  position: absolute;
  top: 10px;
  right: 0;
  display: grid;
  width: 32px;
  height: 32px;
  min-height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  color: var(--soft);
  background: transparent;
  font-size: 1.15rem;
  line-height: 1;
}

.install-button {
  width: 100%;
  min-height: 44px;
  margin-bottom: 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  font-weight: 600;
}

.install-help details {
  color: var(--soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

.install-help summary {
  min-height: 44px;
  padding: 10px 0;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}

.install-help p {
  margin: 0 0 12px;
}

.toast-region {
  position: fixed;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(calc(100% - 32px), 420px);
  justify-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 10px 6px 10px 14px;
  border: 1px solid var(--hair);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(28, 26, 24, 0.18);
  font-size: 0.86rem;
  line-height: 1.4;
  pointer-events: auto;
  animation: toast-in 200ms ease both;
}

.toast--error {
  color: var(--danger);
  border-color: rgba(155, 84, 70, 0.34);
  background: var(--danger-surface);
}

.toast-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  color: var(--soft);
  background: transparent;
  font-size: 1.05rem;
  line-height: 1;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-saved {
  margin: 12px 0 0;
  color: var(--soft);
  font-size: 0.78rem;
}

.sheet {
  width: min(calc(100% - 24px), 540px);
  max-height: min(85dvh, 700px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  box-shadow: 0 24px 80px rgba(28, 26, 24, 0.24);
}

.sheet::backdrop {
  background: rgba(28, 26, 24, 0.38);
}

.sheet-card {
  display: grid;
  gap: 15px;
  /* padding-top убран намеренно: верхний отступ даёт сам липкий заголовок и
     прилипает ЗАПОДЛИЦО к верху карточки — без зазора, куда просвечивал контент. */
  padding: 0 20px 20px;
  /* Карточка — сама себе контейнер прокрутки: без явного max-height она росла
     до полной высоты контента, диалог переполнялся, и ни sticky-заголовок, ни
     overscroll не работали (contentHeight == scrollHeight). */
  max-height: min(85dvh, 700px);
  overflow: auto;
  /* Инерция скролла внутри шита не «протекает» на чат за фоном (п.15). */
  overscroll-behavior: contain;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--surface);
}

.sheet-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  /* Тянемся на всю ширину карточки (перекрываем боковой padding) и сами даём
     верхний отступ; фон перекрывает контент, уезжающий под заголовок (п.14). */
  margin: 0 -20px;
  padding: 20px 20px 12px;
  background: var(--surface);
}

.sheet h2 {
  margin-top: 4px;
  font-size: 1.35rem;
}

.field-label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.field-label textarea {
  min-height: 92px;
  padding: 10px;
  resize: none;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.42;
}

.file-field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
}

.file-field input {
  max-width: 100%;
  color: var(--soft);
  font-size: 0.8rem;
  font-weight: 400;
}

/* Ошибка внутри модального окна примерки: снаружи её не видно. */
.tryon-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(155, 84, 70, 0.28);
  border-radius: var(--radius);
  color: var(--danger);
  background: var(--danger-surface);
  font-size: 0.86rem;
  line-height: 1.45;
}

.file-field span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 400;
}

/* Инструкция в попапе установки PWA: короткая плашка для браузеров без
   нативного prompt (iOS и прочие). Цвета из темы — тёмный режим бесплатно. */
.install-popup-guide {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.profile-fields {
  display: grid;
  gap: 12px;
}

.referral-link {
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

/* Витрина пакетов луков: вертикальные карточки-кнопки, цена справа,
   бейдж выгоды сверху. Виджет ЮKassa рендерится в этот же шит. */
.package-list {
  display: grid;
  gap: 10px;
}

.package-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.package-button:hover {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.package-info {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 3px;
  justify-items: start;
}

.package-badge {
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--accent-deep);
  background: var(--accent-pale);
  font-size: 0.7rem;
  font-weight: 700;
}

.package-label {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.25;
}

.package-price {
  flex: 0 0 auto;
  color: var(--accent-deep);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.package-description {
  color: var(--soft);
  font-size: 0.8rem;
  line-height: 1.35;
}

.payment-widget {
  min-height: 320px;
}

.buy-status {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-soft);
  font-size: 0.88rem;
  line-height: 1.45;
}

.buy-status--error {
  color: var(--danger);
  border-color: rgba(155, 84, 70, 0.28);
  background: var(--danger-surface);
}

.buy-note {
  margin: 0;
  color: var(--soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

/* Документы в шите согласия: три ссылки столбиком, тач-цели ≥44px. */
.legal-links {
  display: grid;
  gap: 6px;
}

.legal-links a {
  display: grid;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  color: var(--accent-deep);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.legal-links a:hover {
  border-color: var(--accent);
}

.legal-status {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(155, 84, 70, 0.28);
  border-radius: var(--radius);
  color: var(--danger);
  background: var(--danger-surface);
  font-size: 0.86rem;
  line-height: 1.45;
}

/* Загрузочный экран: пиксель-Лиза дышит, пока initialize() решает,
   логин это или чат. app.js убирает его классом splash--closing. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  background: radial-gradient(circle at 92% 0%, var(--body-glow) 0, transparent 26rem), var(--bg);
  transition: opacity 360ms ease;
}

.splash img {
  width: 132px;
  height: 132px;
  margin-bottom: 12px;
  border-radius: 50%;
  animation: splash-breathe 2.2s ease-in-out infinite;
}

.splash strong {
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.033em;
}

.splash span {
  color: var(--soft);
  font-size: 0.9rem;
}

.splash--closing {
  opacity: 0;
  pointer-events: none;
}

@keyframes splash-breathe {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

@keyframes answer-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Новые строки ленты въезжают мягко; при первом рендере и подгрузке более
   ранних сообщений класс не вешается, чтобы история не прыгала целиком.
   prefers-reduced-motion глушится общим правилом ниже. */
.timeline-enter {
  animation: message-in 260ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 7px;
  vertical-align: 1px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-deep);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Крестик-дисмисс на карточке несостоявшегося запроса (п.13): убрать
   «залипшее» уведомление, не дожидаясь ничего. */
.operation-card {
  position: relative;
}

.operation-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 30px;
  height: 30px;
  min-height: 30px;
  place-items: center;
  padding: 0;
  border: 0;
  color: var(--soft);
  background: transparent;
  font-size: 1.05rem;
  line-height: 1;
}

/* Пунктирная подсветка зоны, когда над окном тащат фото (пп.6–7). */
.composer.drop-active {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius);
}

@media (min-width: 768px) {
  .app-shell {
    padding-right: 26px;
    padding-left: 26px;
  }

  .login-view {
    padding-top: 72px;
  }

  .login-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .login-card .primary-button {
    min-width: 210px;
  }

  .composer {
    grid-template-columns: 56px minmax(0, 1fr) 56px;
    gap: 10px;
  }

  .photo-button,
  .send-button {
    width: 56px;
    height: 86px;
    min-height: 86px;
  }

  .composer textarea {
    min-height: 86px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .balance-button {
    max-width: 94px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* На узкой шапке подпись бренда и полный текст покупки не помещаются
     вместе с балансом и меню — остаются «Лиза» и «+ луки». */
  .brand span span {
    display: none;
  }

  .buy-button-full {
    display: none;
  }

  .buy-button-compact {
    display: inline;
  }

  .account-menu {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
  }
}
