.bot-maintenance {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 10px;
  border-left: 2px solid var(--chat-orange);
  background: rgba(113, 58, 32, .14);
  color: #e7d9c6;
  font-size: 12px;
  line-height: 1.45;
}

html.bot-document {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

.bot-page {
  --chat-orange: #cd6b38;
  --chat-orange-bright: #ed8c52;
  --chat-orange-dark: #713a20;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

.bot-shell {
  height: 100%;
  min-height: 0;
  overscroll-behavior: none;
}

.bot-main {
  min-height: 0;
  position: relative;
  z-index: 2;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--surface-border);
  border-bottom: 1px solid #080808;
  background: var(--surface-background);
  box-shadow: inset 0 10px 20px rgba(0, 0, 0, .25);
}

.bot-access,
.bot-dialog {
  min-height: 0;
  flex: 1 1 auto;
}

.bot-access[hidden],
.bot-dialog[hidden] {
  display: none;
}

.bot-access {
  padding: 28px 18px;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.bot-access-panel {
  width: min(100%, 510px);
  padding: 25px 27px 23px;
  position: relative;
  border: 1px solid var(--surface-border);
  border-radius: 3px;
  background: var(--surface-panel);
  box-shadow: inset 0 1px rgba(255, 255, 255, .035), 0 12px 28px #0009;
}

.bot-access-panel::before {
  width: 3px;
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: -1px;
  content: "";
  background: #b25a30;
  box-shadow: 0 0 8px rgba(196, 78, 31, .16);
}

.terminal-label {
  margin: 0 0 7px;
  color: #c89472;
  font: 11px/1.3 "WarHelios", "Arial Narrow", sans-serif;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.bot-access-panel h1 {
  margin: 0 0 10px;
  color: #e7d9c6;
  font: 28px/1.15 "WarHelios", "Arial Narrow", sans-serif;
  font-weight: 400;
  letter-spacing: .3px;
}

.bot-access-panel > p:not(.terminal-label) {
  margin: 0;
  color: #b9b3a9;
  font-size: 15px;
  line-height: 1.5;
}

.vk-id-login-shell {
  margin-top: 20px;
}

.vk-id-login {
  width: min(100%, 360px);
  min-height: 108px;
  margin-inline: auto;
  display: grid;
  place-items: center;
  transition: opacity .18s ease, filter .18s ease;
}

.vk-id-login:empty::before {
  content: "Загрузка защищённой формы VK ID…";
  color: #b39c8c;
  font-size: 13px;
}

.bot-access.is-authenticating .vk-id-login {
  opacity: .42;
  filter: grayscale(.35);
  pointer-events: none;
}

.access-error {
  min-height: 16px;
  margin: 9px 0 0;
  text-align: center;
  color: #ee9c85;
  font-size: 13px;
}

.vk-id-login[hidden] { display: none; }
.remembered-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.remembered-actions[hidden] { display: none; }
.remembered-actions button { min-height: 44px; padding: 10px 14px; color: #e2c29b; background: #292118; border: 1px solid #756047; border-radius: 3px; cursor: pointer; }
.remembered-actions button:focus-visible { outline: 2px solid #eca36f; outline-offset: 2px; }
.remembered-actions button:disabled { opacity: .6; cursor: wait; }
.remembered-actions #bot-continue { color: #f0dfc9; border-color: #a26338; background: linear-gradient(#754122, #442817); }
@media (hover: hover) {
  .remembered-actions button:hover:not(:disabled) { border-color: #ae825c; }
  .remembered-actions #bot-continue:hover:not(:disabled) { background: linear-gradient(#874c29, #56301b); }
}

.bot-dialog .is-player .message-meta {
  justify-content: flex-end;
  min-height: 16px;
  margin-bottom: 3px;
}

.bot-dialog .is-bot .message-meta { gap: 6px; margin-bottom: 3px; }
.bot-access-panel .access-warning,
.bot-access-panel .bot-access-warning {
  margin-top: 10px !important;
  padding-top: 10px;
  color: #b39c8c !important;
  border-top: 1px solid #2b1b14;
  font-size: 12px;
}

.bot-dialog {
  --message-feed-padding: 12px 20px;
  --message-min-height: 48px;
  --message-padding: 5px 8px 7px 52px;
  --message-meta-height: 22px;
  --message-font-size: 14px;
  --message-line-height: 1.4;
  --message-preview-height: min(640px, 70dvh);
  display: flex;
  flex-direction: column;
}

.bot-message-area {
  min-height: 0;
  position: relative;
  flex: 1 1 auto;
}

.bot-messages {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y pinch-zoom;
}

.bot-message-list { display: flow-root; }

.chat-jump-latest {
  min-height: 34px;
  padding: 0 13px 0 9px;
  position: absolute;
  right: clamp(18px, 3.5vw, 38px);
  bottom: 15px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #d8b8a5;
  border: 1px solid #7a442a;
  border-radius: 18px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 230, 213, .025) 0 1px, transparent 1px 4px),
    linear-gradient(#4b2919, #1b0e08);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .72), inset 0 1px rgba(255, 196, 156, .1);
  font: 10px/1 "WarHelios", "Arial Narrow", sans-serif;
  letter-spacing: .35px;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, transform .18s ease, opacity .18s ease;
}

.chat-jump-latest[hidden] { display: none; }

.chat-jump-latest:hover,
.chat-jump-latest:focus-visible {
  color: #fff0e6;
  border-color: #bd6a3f;
  outline: none;
  transform: translateY(-1px);
}

.chat-jump-arrow {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  color: #f09a66;
  border: 1px solid #79442b;
  border-radius: 50%;
  font: 15px/1 Arial, sans-serif;
}

.dialog-date {
  margin: 0 0 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #b19a87;
  font: 11px/1 "WarHelios", "Arial Narrow", sans-serif;
  letter-spacing: 1.3px;
  text-transform: uppercase;
}

.dialog-date::before,
.dialog-date::after {
  height: 1px;
  flex: 1 1 auto;
  content: "";
  background: linear-gradient(90deg, transparent, #39241a);
}

.dialog-date::after {
  background: linear-gradient(90deg, #39241a, transparent);
}

.message-assets {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}

.message-assets.is-gallery {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.message-image {
  min-width: 0;
  max-width: min(100%, 380px);
  justify-self: start;
  padding: 0;
  display: block;
  border: 1px solid #4a3023;
  border-radius: clamp(12px, 2vw, 20px);
  overflow: hidden;
  background: #050302;
  box-shadow: 0 3px 9px rgba(0, 0, 0, .35);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
  transition: border-color .16s ease, filter .16s ease;
}

.message-image:hover,
.message-image:focus-visible {
  border-color: #8c5c43;
  filter: brightness(1.06);
  outline: none;
}

.message-image img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: var(--message-preview-height);
  display: block;
  object-fit: contain;
  object-position: left center;
}

.message-assets.is-gallery .message-image {
  justify-self: stretch;
}

.message-assets.is-gallery .message-image img {
  width: 100%;
  max-width: 100%;
  height: var(--message-preview-height);
  object-fit: cover;
  object-position: center;
}

@media (min-width: 681px) {
  .bot-dialog .message-image { max-width: min(100%, 640px); }
  .bot-dialog .message-assets.is-gallery .message-image { justify-self: start; }
  .bot-dialog .message-assets.is-gallery .message-image img {
    width: auto;
    height: auto;
    object-fit: contain;
  }
}

.message-image.is-unavailable {
  padding: 12px;
  color: #8d6251;
  border-style: dashed;
  font-size: 11px;
  text-align: center;
  cursor: default;
}

.message-assets a,
.message-assets span {
  color: #bb7450;
  font-size: 11px;
}

.message-keyboard {
  max-width: 640px;
  margin-top: 6px;
  display: grid;
  gap: 4px;
}

.global-keyboard {
  max-height: 194px;
  padding: 7px 2px 2px;
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  border-top: 1px solid var(--surface-border);
  scrollbar-color: #555044 #100f0d;
  scrollbar-width: thin;
}

.global-keyboard[hidden] { display: none; }

.global-keyboard .keyboard-button {
  min-height: 34px;
  padding-block: 5px;
  background-image:
    repeating-linear-gradient(0deg, #e5ddc603 0 1px, transparent 1px 4px),
    linear-gradient(#ffffff05, #00000018);
  box-shadow: inset 0 1px #ffffff08;
}

.keyboard-row {
  display: flex;
  gap: 5px;
}

.keyboard-button {
  --keyboard-surface: #1a1a17;
  --keyboard-border: #45453b;
  --keyboard-text: #d7d4c7;
  --keyboard-accent: #c18c55;
  --keyboard-pressed: #30271c;
  min-width: 0;
  min-height: 28px;
  padding: 4px 10px;
  flex: 1 1 0;
  display: grid;
  place-items: center;
  color: var(--keyboard-text);
  border: 1px solid var(--keyboard-border);
  border-radius: 3px;
  background: var(--keyboard-surface);
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

.keyboard-button.is-primary {
  --keyboard-surface: #292117;
  --keyboard-border: #795235;
  --keyboard-text: #efbd84;
  --keyboard-pressed: #3b2b1b;
}

.keyboard-button.is-positive {
  --keyboard-surface: #1c241b;
  --keyboard-border: #4e6041;
  --keyboard-text: #becda5;
  --keyboard-accent: #8eac6b;
  --keyboard-pressed: #2b3823;
}

.keyboard-button.is-negative {
  --keyboard-surface: #291c19;
  --keyboard-border: #70463c;
  --keyboard-text: #dda493;
  --keyboard-accent: #c7826d;
  --keyboard-pressed: #3c2520;
}

@media (hover: hover) {
  .keyboard-button:hover:not(:disabled):not(.is-pending) {
    color: var(--keyboard-accent);
    border-color: var(--keyboard-accent);
  }
}

.keyboard-button:disabled,
.keyboard-button.is-pending {
  opacity: .5;
  cursor: wait;
}

.keyboard-button:active:not(:disabled):not(.is-pending) {
  background-color: var(--keyboard-pressed);
  border-color: var(--keyboard-accent);
}

.keyboard-button:focus-visible {
  outline: 2px solid var(--keyboard-accent);
  outline-offset: -3px;
}

@media (pointer: coarse), (max-width: 680px) {
  .keyboard-button,
  .global-keyboard .keyboard-button { min-height: 44px; }
}

.chat-typing {
  width: 55px;
  min-height: 35px;
  padding: 14px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid #3a2a21;
  border-radius: 2px 9px 9px 9px;
  background: #15100c;
}

.chat-typing span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #9d5a37;
  animation: chat-typing 1s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: .13s; }
.chat-typing span:nth-child(3) { animation-delay: .26s; }

.bot-composer {
  padding: 18px clamp(18px, 3vw, 32px) max(8px, env(safe-area-inset-bottom));
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  background: var(--surface-panel);
  box-shadow: inset 0 1px rgba(255, 204, 160, .04);
}

.bot-composer textarea {
  width: 100%;
  height: 46px;
  max-height: 112px;
  padding: 11px 12px;
  resize: none;
  overflow-y: hidden;
  color: #eee0d4;
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  outline: none;
  background: var(--surface-input);
  box-shadow: inset 0 2px 8px #000;
  font: 16px/1.4 Arial, Helvetica, sans-serif;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.bot-dialog .bot-composer {
  padding-block: 12px max(6px, env(safe-area-inset-bottom));
  gap: 6px;
}

.bot-composer [hidden] { display: none !important; }
.bot-composer.is-input-collapsed .global-keyboard { padding-top: 0; border-top: 0; }

.bot-composer textarea.is-scrollable { overflow-y: auto; }

.bot-composer textarea::placeholder { color: #b29d8d; }

.bot-composer textarea:focus {
  border-color: #8c4c2c;
  box-shadow: inset 0 2px 8px #000, 0 0 0 1px rgba(190, 89, 43, .12), 0 0 12px rgba(158, 60, 24, .12);
}

.bot-composer textarea:disabled { color: #6b5b52; cursor: wait; }

.bot-send-button {
  height: 46px;
  min-width: 132px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #e0beaa;
  border: 1px solid #79452c;
  border-radius: 6px;
  outline: none;
  background:
    repeating-linear-gradient(0deg, rgba(255, 230, 213, .025) 0 1px, transparent 1px 4px),
    linear-gradient(#5a2d1a, #251108);
  box-shadow: inset 0 1px rgba(255, 190, 145, .13), 0 2px 5px #000;
  font: 14px/1 "WarHelios", "Arial Narrow", sans-serif;
  letter-spacing: .6px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.bot-send-button .icon {
  width: 17px;
  height: 17px;
}

@media (pointer: fine) and (min-width: 681px) {
  .bot-dialog .bot-send-button { height: 42px; }
}

.bot-send-button:hover,
.bot-send-button:focus-visible {
  color: #fff0e6;
  border-color: #b26640;
  box-shadow: inset 0 1px rgba(255, 198, 157, .18), 0 0 12px rgba(178, 63, 20, .25);
}

.bot-send-button:disabled {
  color: #69564b;
  border-color: #3f2a20;
  cursor: wait;
  filter: saturate(.5);
}

.composer-hint {
  margin: 0;
  grid-column: 1 / -1;
  color: #ad9888;
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  text-align: left;
}

.dialog-state-copy {
  min-height: 28px;
  min-width: 44px;
  padding: 3px;
  color: #d5a481;
  border: 0;
  border-bottom: 1px dotted #5a3524;
  background: none;
  font-size: 11px;
  cursor: pointer;
}

.dialog-state-copy:hover { color: #b76b46; }
.dialog-state-copy:focus-visible { outline: 2px solid #cd6b38; outline-offset: 2px; }


.dialog-state {
  flex: 1 1 220px;
  min-width: 0;
  color: #ad9888;
  font-size: 11px;
}


.dialog-state summary {
  min-height: 28px;
  padding: 6px 0;
  box-sizing: border-box;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.dialog-state summary:hover,
.dialog-state summary:focus-visible { color: #e7d9c6; }

.dialog-state-content {
  padding: 6px 8px;
  border: 1px solid #46372b;
  border-radius: 4px;
  background: rgb(0 0 0 / 18%);
}

.dialog-state pre {
  margin: 0;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.dialog-state [data-state-status] { margin-left: 8px; }

.bot-footer {
  flex: 0 0 auto;
}


@keyframes chat-typing {
  0%, 70%, 100% { opacity: .35; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 680px) {
  .bot-main {
    min-height: 0;
  }

  .chat-jump-latest {
    right: 12px;
    bottom: 11px;
  }

  .bot-composer {
    padding: 16px 10px max(8px, env(safe-area-inset-bottom));
    gap: 7px;
  }

  .bot-send-button {
    min-width: 45px;
    padding: 0 12px;
  }

  .bot-send-button span { display: none; }

  .bot-access { padding: 14px 10px; }
  .bot-access-panel { padding: 21px 18px 19px; }

  .keyboard-row { align-items: stretch; }
  .keyboard-button { min-height: 28px; padding-right: 6px; padding-left: 6px; }
  .global-keyboard .keyboard-button { min-height: 40px; }

  .global-keyboard {
    max-height: min(190px, 32dvh);
    padding-top: 8px;
    gap: 4px;
  }

  .message-assets.is-gallery {
    grid-template-columns: 1fr;
  }

  .message-assets.is-gallery .message-image {
    justify-self: start;
  }

}

@media (max-width: 920px) {
  .bot-shell > .section-nav {
    flex-shrink: 0;
    transition: transform .22s ease, margin-bottom .22s ease, visibility .22s;
  }

  .bot-shell > .section-nav.is-dialog-nav-hidden {
    margin-bottom: calc(-1 * var(--mobile-nav-height));
    transform: translateY(-100%);
    visibility: hidden;
  }
}

@media (max-width: 680px) {
  .bot-dialog {
    --message-feed-padding: 8px 7px;
    --message-min-height: 40px;
    --message-padding: 4px 7px 6px 42px;
    --message-meta-height: 18px;
    --message-font-size: 12.5px;
    --message-line-height: 1.45;
  }

  .bot-dialog .chat-message:not(.is-player) { padding: var(--message-padding); }
  .bot-dialog .chat-message.is-bot { --message-padding: 4px 7px 6px; }
  .bot-dialog .is-bot .message-meta .message-avatar {
    position: relative;
    left: auto;
    top: auto;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    font-size: 9px;
  }
  .bot-dialog .message-meta { font-size: 11px; gap: 5px; }
  .bot-dialog .message-meta time { font-size: 10px; }
  .bot-dialog .message-avatar { width: 30px; height: 30px; left: 5px; top: 8px; }
  .bot-dialog .chat-message.is-player {
    max-width: calc(100% - 57px);
    margin: 5px 37px 8px auto;
    padding: 6px 8px 8px;
  }
  .bot-dialog .is-player .message-meta { min-height: 14px; margin-bottom: 2px; }
  .bot-dialog .chat-message.is-player .message-avatar { left: auto; right: -38px; top: 3px; }
  .bot-dialog .message-assets { margin-top: 5px; gap: 5px; }
  .bot-dialog .message-image { width: min(100%, 420px); max-width: 100%; }
  .bot-dialog .message-assets .message-image img {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bot-shell > .section-nav { transition: none; }
  .keyboard-button { transition: none; }

  .chat-typing span {
    animation: none;
  }
}
