/* Окошко бота-помощника. z-index 990: выше контента, season-switcher (100/150/200)
 * и мобильного #sticky_bar (998 — но пузырь поднят над ним, см. @media),
 * ниже backdrop/drawer (999/1000) и cookie-баннера (9999).
 * Открытое полноэкранное окно на мобиле — 1001 (перекрывает и sticky_bar, и drawer-слой). */
.aw { position: fixed; right: 16px; bottom: 16px; z-index: 990; font-family: var(--font-body); }
.aw__bubble {
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--color-primary); color: #fff; font-size: 24px;
  box-shadow: var(--shadow-md); position: relative;
}
.aw__bubble:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.aw__badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--color-danger); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
.aw__badge[hidden] { display: none; }
.aw__panel {
  position: absolute; right: 0; bottom: 68px; width: 360px; max-height: min(560px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden;
}
.aw__panel[hidden] { display: none; }
.aw__header {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  background: var(--color-primary-dark); color: #fff;
}
.aw__title { font-weight: 600; }
.aw__close { background: none; border: none; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; min-width: 44px; min-height: 44px; }
.aw__messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.aw__msg {
  max-width: 85%; padding: 8px 12px; border-radius: var(--radius-md); line-height: var(--line-height-base);
  overflow-wrap: anywhere; white-space: normal;
}
.aw__msg--user { align-self: flex-end; background: var(--color-primary); color: #fff; white-space: pre-wrap; }
.aw__msg--bot, .aw__msg--admin { align-self: flex-start; background: var(--color-bg); border: 1px solid var(--color-border); }
.aw__msg--admin { border-color: var(--color-accent); }
.aw__msg a { color: var(--color-primary-dark); text-decoration: underline; }
.aw__msg-label { font-size: 12px; color: var(--color-text-muted); margin-bottom: 4px; }
.aw__typing { color: var(--color-text-muted); font-style: italic; }
.aw__form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--color-border); }
.aw__input {
  flex: 1; min-width: 0; resize: none; font: inherit; font-size: 16px; /* 16px — без автозума iOS */
  padding: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.aw__send {
  flex: none; padding: 0 14px; min-height: 44px; border: none; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--color-primary); color: #fff; font: inherit;
}
.aw__send:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 767px) {
  /* Над фиксированной нижней панелью «Написать в Макс/VK» (#sticky_bar, ~74px) */
  .aw { bottom: 88px; }
}

.aw__backdrop { display: none; }

/* Мобила: окно — нижняя шторка поверх затемнённой страницы (видно, что это окно
 * над сайтом, а не переход). Высота и позиция — от видимой области
 * (visualViewport, см. JS: --aw-top/--aw-height): с открытой клавиатурой шторка
 * ужимается над ней, и заголовок не уезжает за экран. */
@media (max-width: 480px) {
  .aw { right: 12px; }
  .aw--open { z-index: 1001; }
  .aw--open .aw__bubble { display: none; }
  .aw--open .aw__backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  }
  .aw--open .aw__panel {
    position: fixed; left: 0; right: 0; bottom: auto; width: 100%; max-height: none;
    top: var(--aw-top, 15dvh); height: var(--aw-height, 85dvh);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0; border: none;
  }
  .aw__messages { overscroll-behavior: contain; }
}
html.aw-lock, html.aw-lock body { overflow: hidden; }
