/* Split from website/static/css/pages.css. Keep selector order compatible with the original cascade. */

/* Chat page layout */
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 6px;
  background: #11131a;
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0;
}

.chat-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.chat-back svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.chat-title {
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
}

#chat .top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

#chat .top-bar .burger {
  grid-column: 3;
  justify-self: end;
}

.chat-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header-balance {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  grid-column: 2;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0;
}

.chat-balance-value {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  min-width: max-content;
  text-align: center;
  letter-spacing: 0.02em;
}

.chat-balance-add {
  width: 14px;
  height: 14px;
  border-radius: 0;
  border: none;
  background: transparent;
  color: #fff;
  padding: 0;
  min-width: 14px;
  min-height: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, color 0.2s ease;
}

.chat-balance-add:hover {
  transform: scale(0.99);
  opacity: 0.95;
  color: #f5f7ff;
}

.chat-balance-add:active {
  transform: scale(0.97);
}

.chat-balance-add svg {
  width: 12px;
  height: 12px;
  display: block;
}

.chat-hero {
  position: sticky;
  top: 40px;
  overflow: visible;
}

.chat-head-wrap {
  margin: 0 -16px;
  padding: 0 16px 16px;
  position: fixed;
  width: 100vw;
  max-width: var(--chat-shell-content-max-width, 560px);
  z-index: 10;
  top: var(--app-top-safe-inset);
  overflow: visible;
  background: rgba(18, 20, 27, calc(0.88 * var(--section-topbar-alpha, 0)));
  border-bottom: 1px solid rgba(255, 255, 255, calc(0.03 * var(--section-topbar-alpha, 0)));
  backdrop-filter: blur(calc(14px * var(--section-topbar-alpha, 0)));
  -webkit-backdrop-filter: blur(calc(14px * var(--section-topbar-alpha, 0)));
  box-shadow: 0 10px 24px rgba(0, 0, 0, calc(0.12 * var(--section-topbar-alpha, 0)));
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, backdrop-filter 0.22s ease;
}

.support-chat-head-wrap {
  padding-bottom: 10px;
}

#support-chat-section .top-bar {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.support-chat-back {
  width: var(--ui-chat-header-icon-button-size);
  height: var(--ui-chat-header-icon-button-size);
  flex: 0 0 var(--ui-chat-header-icon-button-size);
  border-radius: 10px;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: rgba(245, 246, 251, 0.92);
  background: transparent;
  transition: opacity 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

.support-chat-back:hover,
.support-chat-back:focus-visible {
  background: rgba(255, 255, 255, 0.03);
}

.support-chat-back:active {
  transform: scale(0.96);
  opacity: 0.86;
}

.support-chat-back svg {
  width: 18px;
  height: 18px;
}

.support-chat-title-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

#support-chat-section .support-chat-title-group .title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.support-chat-top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.support-chat-subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(241, 243, 250, 0.56);
}

/* Matches .home-start-chat (welcome) — white CTA, same hover/active motion */
#support-chat-section .support-chat-new-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 6px 12px;
  min-height: 34px;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  color: #000000;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.12s ease, background 0.12s ease;
}

#support-chat-section .support-chat-new-btn:hover {
  background: #f2f2f2;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.25);
  transform: scale(0.99);
  opacity: 0.95;
}

#support-chat-section .support-chat-new-btn:active {
  background: #e9e9e9;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.28);
  transform: scale(0.97);
}

#support-chat-section .support-chat-new-btn:focus-visible {
  outline: 2px solid rgba(88, 205, 231, 0.6);
  outline-offset: 2px;
}

.support-chat-new-btn-icon {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
  color: #000000;
}

.support-chat-new-btn-label {
  white-space: nowrap;
}

#chat.settings-open .chat-head-wrap {
  padding-bottom: 0;
}

.chat-hero .chat-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.chat-model-name {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}

.chat-menu {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  gap: 4px;
  cursor: pointer;
}

.chat-menu span {
  display: block;
  width: 16px;
  height: 2px;
  background: #fff;
}

.chat-open-bar {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  z-index: 1;
  align-items: flex-end;
  width: 100%;
  overflow: visible;
}

.chat-open-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  position: relative;
  z-index: 13;
  isolation: isolate;
  transition: transform 0.28s var(--motion-ease-soft);
}

.chat-open-toggle::before {
  content: "";
  position: absolute;
  left: -10px;
  right: -10px;
  top: -10px;
  bottom: -14px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(18, 20, 27, 0.86) 0%, rgba(18, 20, 27, 0.7) 52%, rgba(18, 20, 27, 0.14) 100%);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.24s var(--motion-ease-soft), transform 0.24s var(--motion-ease-soft);
  pointer-events: none;
  z-index: -1;
}

.chat-open-bar.stack-open .chat-open-toggle::before {
  opacity: 1;
  transform: translateY(0);
}

.chat-open-bar.stack-open .chat-open-toggle {
  transform: translateY(calc(var(--chat-opened-stack-height, 0px) + 8px));
}

.chat-open-add {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(33, 35, 47, 0.92);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 4px;
}

.chat-open-add svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.chat-open-more {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(33, 35, 47, 0.92);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  cursor: pointer;
  justify-content: flex-start;
  transition: transform 0.15s ease, opacity 0.15s ease,
    background 0.2s ease, border-color 0.2s ease, gap 0.25s ease;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-open-more:active {
  transform: scale(0.97);
}

.chat-open-more:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 255, 0.12);
}

.chat-open-more-icon {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: transform 0.22s ease;
}

.chat-open-bar.stack-open .chat-open-more-icon {
  transform: rotate(180deg);
}

.chat-open-more-icon svg {
  width: 16px;
  height: 16px;
  display: block;
  color: currentColor;
}

.chat-open-toggle-text {
  font-size: 11px;
  color: #d4d6e0;
  white-space: nowrap;
  max-width: 120px;
  transition: opacity 0.25s ease, transform 0.25s ease, max-width 0.25s ease;
}

.chat-open-bar.stack-open .chat-open-toggle-text {
  opacity: 1;
  transform: none;
  max-width: 120px;
}

.chat-open-bar.stack-open .chat-open-more {
  gap: 5px;
}

@media (hover: hover) and (pointer: fine) {
  .chat-open-add:hover,
  .chat-open-more:hover {
    transform: scale(0.99);
    opacity: 0.95;
    background: rgba(43, 46, 58, 0.96);
  }
}

.chat-opened-item {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 42px;
  padding: 6px 9px;
  background: linear-gradient(180deg, rgba(33, 35, 47, 1), rgba(30, 32, 42, 0.985));
  border-radius: 12px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 6px 12px rgba(0, 0, 0, var(--stack-shadow-opacity, 0.08));
  opacity: 0;
  transform: translateY(var(--stack-y, 0px));
  transition: opacity 0.18s ease, transform 0.22s var(--motion-ease-soft),
    box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  overflow: hidden;
  transform-origin: top center;
  isolation: isolate;
}

.chat-opened-item::before {
  content: "";
  position: absolute;
  inset: -12% -6% 46% -6%;
  background: radial-gradient(84% 68% at 50% 6%, rgba(44, 47, 60, 0.16) 0%, rgba(25, 27, 35, 0) 72%);
  opacity: 0.34;
  pointer-events: none;
  z-index: 0;
}

.chat-opened-item > * {
  position: relative;
  z-index: 1;
}

.chat-opened-item.is-active {
  border-color: rgba(124, 92, 255, 0.34);
  background: linear-gradient(180deg, rgba(33, 35, 47, 1), rgba(29, 31, 41, 0.99));
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.08), 0 6px 12px rgba(0, 0, 0, var(--stack-shadow-opacity, 0.08));
}

.chat-opened-item.is-active::before {
  opacity: 0.42;
  background: radial-gradient(86% 70% at 50% 6%, rgba(88, 68, 176, 0.1) 0%, rgba(25, 27, 35, 0) 72%);
}

.chat-opened-item.menu-open:not(.is-active) {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 16px rgba(0, 0, 0, 0.14);
}

.chat-opened-item.is-dragging {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
  cursor: grabbing;
  transition: none;
}

.chat-opened-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(110, 201, 255, 0.5), 0 16px 30px rgba(0, 0, 0, 0.3);
}

.chat-opened-main {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.chat-opened-handle {
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  padding: 0;
  color: #7d808d;
  cursor: default;
  flex: 0 0 12px;
  touch-action: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.chat-opened-item.is-draggable .chat-opened-handle {
  cursor: grab;
  opacity: 0.8;
  pointer-events: auto;
}

.chat-opened-item.is-draggable .chat-opened-handle:hover {
  color: #d7d9e2;
}

.chat-opened-item.is-dragging .chat-opened-handle {
  cursor: grabbing;
}

.chat-opened-handle svg {
  width: 10px;
  height: 10px;
  display: block;
}

.chat-opened-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.chat-opened-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  flex: none;
}

.chat-opened-title {
  font-size: 13px;
  line-height: 17px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-opened-stack {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 12;
  width: 100%;
  transition: height 0.28s var(--motion-ease-soft);
}

.chat-opened-stack.open {
  height: var(--chat-opened-stack-height, 0px);
  pointer-events: auto;
}

.chat-opened-menu-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: #8f93a3;
  flex: 0 0 auto;
  transition: transform 0.15s ease, opacity 0.15s ease,
    background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chat-opened-menu-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  color: #f2f3f8;
}

.chat-opened-menu-btn:focus-visible {
  outline: none;
  border-color: rgba(110, 201, 255, 0.45);
  box-shadow: 0 0 0 2px rgba(110, 201, 255, 0.18);
}

.chat-opened-menu-btn:active {
  transform: scale(0.97);
}

.chat-opened-menu-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.chat-opened-menu {
  position: absolute;
  background: rgba(32, 35, 46, 0.98);
  border-radius: 13px;
  padding: 5px;
  flex-direction: column;
  gap: 4px;
  min-width: 148px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
  animation: menuFade 0.18s ease forwards;
  z-index: 360;
  backdrop-filter: blur(14px);
}

.chat-opened-menu button {
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}

.chat-opened-menu button:hover {
  opacity: 0.95;
  background: rgba(255, 255, 255, 0.055);
}

.chat-opened-menu button:active {
  opacity: 0.9;
}

.chat-opened-menu button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  transform: none;
}

.chat-opened-menu button[data-action="delete"] {
  color: #ff405d;
}

.chat-opened-menu-icon {
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.chat-opened-menu-icon svg {
  width: 15px;
  height: 15px;
  display: block;
}

.chat-opened-menu-label {
  line-height: 1.2;
}

.chat-opened-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    calc(24px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.chat-opened-modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.chat-opened-modal .modal-card {
  background: linear-gradient(180deg, rgba(35, 38, 49, 0.98), rgba(26, 28, 37, 0.98));
  border-radius: 18px;
  width: 100%;
  max-width: 332px;
  padding: 16px;
  text-align: left;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(14px);
}

.chat-opened-modal.open .modal-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-opened-modal .modal-question {
  margin: 0;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
}

.chat-opened-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chat-opened-modal-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.chat-opened-modal-desc {
  margin: 0;
  font-size: 12px;
  line-height: 17px;
  color: rgba(255, 255, 255, 0.58);
}

.chat-opened-modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.78);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}

.chat-opened-modal-close:hover {
  transform: scale(0.99);
  opacity: 0.95;
  background: rgba(255, 255, 255, 0.07);
}

.chat-opened-modal-close svg {
  width: 13px;
  height: 13px;
  display: block;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.chat-opened-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-opened-modal-label {
  font-size: 12px;
  line-height: 16px;
  color: rgba(255, 255, 255, 0.52);
}

.chat-opened-modal-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 14px;
  line-height: 19px;
  padding: 11px 13px;
  outline: none;
}

.chat-opened-modal-input:focus {
  border-color: rgba(124, 188, 255, 0.34);
  box-shadow: 0 0 0 1px rgba(33, 183, 255, 0.12);
}

.chat-opened-modal-error {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: #ffbaba;
}

.chat-opened-modal-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 100%;
}

.chat-opened-modal .modal-buttons {
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 100%;
}

.chat-opened-modal .modal-btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  border-radius: 13px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  width: 100%;
}

.chat-opened-modal .modal-btn.danger {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.chat-opened-modal .modal-btn.primary {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.chat-opened-modal .modal-btn.secondary {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
}

.chat-opened-modal .modal-btn:hover:not(:disabled) {
  transform: scale(0.99);
  opacity: 0.95;
}

.chat-opened-modal .modal-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.chat-opened-modal .modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-opened-add-modal {
  position: fixed;
  inset: 0;
  display: block;
  padding: 0;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 320;
}

.chat-opened-add-modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.chat-opened-add-modal.is-share-context {
  background: rgba(4, 7, 14, 0.52);
  backdrop-filter: blur(1.5px);
}

.chat-opened-add-anchor-clone {
  position: fixed;
  z-index: 321;
  pointer-events: none;
  overflow: hidden;
  border-radius: 14px;
  filter: none !important;
  opacity: 1 !important;
}

.chat-opened-add-card {
  --chat-opened-card-max-height: min(410px, calc(100dvh - 16px));
  width: min(100%, 292px);
  max-height: var(--chat-opened-card-max-height);
  box-sizing: border-box;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: linear-gradient(180deg, rgba(34, 37, 49, 0.88) 0%, rgba(20, 23, 33, 0.94) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 18px 42px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  position: absolute;
  z-index: 322;
  text-align: left;
  isolation: isolate;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-opened-add-card.is-model-picker-height-animating,
.model-modal .model-modal-card.is-model-picker-height-animating {
  overflow: hidden;
  transition:
    height 0.28s var(--motion-ease-soft),
    opacity 0.2s ease,
    transform 0.2s ease !important;
  will-change: height;
}

.chat-opened-add-modal.open .chat-opened-add-card {
  opacity: 1;
  transform: translateY(0);
}

.chat-opened-share-anchor {
  position: relative;
  z-index: 321 !important;
  filter: none !important;
  opacity: 1 !important;
}

.chat-opened-add-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.15s ease;
  z-index: 6;
  pointer-events: auto;
}

.chat-opened-add-close svg {
  width: 14px;
  height: 14px;
  stroke: #7d808d;
  stroke-width: 1.5;
  fill: none;
}

.chat-opened-add-title,
.chat-opened-add-subtitle {
  max-width: calc(100% - 48px);
  font-size: 14px;
  line-height: 18px;
  color: #ffffff;
  margin: 0;
  overflow-wrap: anywhere;
}

.chat-opened-add-step-viewport {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  z-index: 1;
}

.chat-opened-modal-lock-scroll {
  overflow: hidden !important;
  left: 0;
  right: 0;
  touch-action: none;
}

body.model-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

body.chat-credits-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

body.model-modal-open .page-chat-single-scroll,
body.model-modal-open #chat-main,
body.model-modal-open .messages-container {
  overscroll-behavior: contain;
}

.chat-opened-modal-lock-scroll .page-chat-single-scroll,
.chat-opened-modal-lock-scroll #chat-main,
.chat-opened-modal-lock-scroll .messages-container {
  overscroll-behavior: contain;
}

.chat-opened-add-step {
  position: relative;
  grid-area: 1 / 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-opened-add-step[hidden] {
  display: none !important;
}

.chat-opened-add-step--history {
  align-items: center;
  text-align: center;
}

.chat-opened-add-step--model {
  align-items: stretch;
  text-align: left;
  height: 100%;
  min-height: 0;
}

.chat-opened-add-step.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.chat-opened-add-step.is-entering.is-back {
  transform: translateX(-16px);
}

.chat-opened-add-step.is-leaving {
  pointer-events: none;
}

.chat-opened-add-step.is-leaving.is-forward {
  opacity: 0;
  transform: translateX(-16px);
}

.chat-opened-add-step.is-leaving.is-back {
  opacity: 0;
  transform: translateX(16px);
}

.chat-opened-add-step-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
}

.chat-opened-add-step-header .chat-opened-add-title {
  text-align: center;
}

.chat-opened-add-back {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: none;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}

.chat-opened-add-back svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-opened-add-back:hover {
  transform: translateY(-50%) scale(0.99);
  opacity: 0.95;
  background: rgba(255, 255, 255, 0.12);
}

.chat-opened-add-back:active {
  transform: translateY(-50%) scale(0.97);
}

.chat-opened-add-start {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: none;
  border-radius: 11px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.15s ease;
}

.chat-opened-add-start-icon svg {
  width: 16px;
  height: 16px;
}

.chat-opened-add-start:hover {
  transform: scale(0.99);
  opacity: 0.95;
  background: rgba(255, 255, 255, 0.16);
}

.chat-opened-add-start:active {
  transform: scale(0.97);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
}

.chat-opened-add-start-text {
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
}

.chat-opened-add-search {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(25, 27, 35, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-opened-add-search-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}

.chat-opened-add-search-icon svg {
  width: 19px;
  height: 19px;
  stroke: #ffffff;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-opened-add-search-input {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #ffffff;
  font-size: 12px;
  line-height: 15px;
  outline: none;
  padding: 0;
}

.chat-opened-add-search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.chat-opened-add-list {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(208px, 34dvh);
  overflow-y: auto;
}

.chat-opened-add-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  color: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}


.chat-opened-add-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chat-opened-add-item-title {
  font-size: 12px;
  line-height: 20px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-opened-add-star {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #ffffff;
}

.chat-opened-add-star[data-bookmark-state="default"] svg {
  opacity: 0.68;
}

.chat-opened-add-star[data-bookmark-state="filled"] svg {
  opacity: 1;
}

.chat-opened-add-star svg {
  width: 18px;
  height: 18px;
  display: block;
  transition: opacity 0.18s ease;
}

.chat-opened-add-empty {
  font-size: 12px;
  line-height: 15px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  padding: 16px 0;
}

.chat-opened-add-model-groups {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px 8px 2px;
  box-sizing: border-box;
}

.chat-opened-add-model-groups.model-picker-frame--models {
  overflow: hidden;
}

.chat-opened-add-model-step[data-context="create"] .model-option-status.is-active {
  display: none;
}

.chat-opened-add-error {
  margin: 0;
  min-height: 16px;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  color: #ffb2b2;
}

.chat-body.settings-open .chat-opened-add-modal:not(.model-modal) {
  display: none;
}

html:has(body:not(.login-only) .page.page-chat-single-scroll),
html:has(body:not(.login-only) .page.page-chat-single-scroll) body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--app-shell-background);
}

html:has(body:not(.login-only) .page.page-chat-single-scroll):focus-within {
  scroll-behavior: auto;
}

body:has(.page.page-chat-single-scroll) {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--app-shell-background);
}

body:has(.page.page-chat-single-scroll) .root-shell {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--app-shell-background);
}

body:has(.page.page-chat-single-scroll) :is(
  .messages-container,
  .image-generation-surface,
  .image-generation-detail,
  .image-generation-detail-composer,
  .chat-settings-screen,
  .model-modal-body,
  .chat-opened-add-list,
  .chat-opened-add-model-groups,
  .message-edit-body
) {
  touch-action: pan-y;
}

.page.page-chat-single-scroll {
  box-sizing: border-box;
  height: 100dvh;
  min-height: 100dvh;
  padding-bottom: 0;
  overflow: hidden;
  touch-action: none;
  background: var(--app-shell-background);
}

.page.page-chat-single-scroll #chat.section.active,
.page.page-chat-single-scroll #support-chat-section.section.active {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  padding-bottom: 0;
}

.page.page-chat-single-scroll {
  z-index: auto;
}

.page.page-chat-single-scroll:has(#chat.active #chat-main.image-mode) {
  padding-left: var(--chat-shell-edge-gutter, 16px);
  padding-right: var(--chat-shell-edge-gutter, 16px);
}

.page.page-chat-single-scroll:has(#chat.active #chat-main.image-mode) .chat-head-wrap {
  margin-inline: auto;
  width: 100vw;
  max-width: calc(var(--chat-shell-content-max-width, 560px) + (2 * var(--chat-shell-edge-gutter, 16px)));
  padding-left: var(--chat-shell-edge-gutter, 16px);
  padding-right: var(--chat-shell-edge-gutter, 16px);
  padding-bottom: 10px;
}

.page.page-chat-single-scroll:has(#chat.active #chat-main.image-mode) #chat .top-bar {
  margin-inline: 0;
  padding-left: 0;
  padding-right: 0;
}

.page.page-chat-single-scroll:has(#chat.active #chat-main.image-mode) .chat-body {
  padding-top: var(--image-generation-shell-top-reserve, calc(100px + var(--app-top-safe-inset)));
}

/* Chat shell: the page is a bounded app shell; messages remain the only vertical scroller. */
body.chat-shell:has(.page.page-chat-single-scroll) {
  background: var(--app-shell-background);
  overscroll-behavior-y: none;
}

body.chat-shell:has(.page.page-chat-single-scroll) .root-shell {
  height: var(--chat-vvh, 100dvh);
  min-height: var(--chat-vvh, 100dvh);
}

body.chat-shell .page.page-chat-single-scroll {
  height: var(--chat-vvh, 100dvh);
  min-height: var(--chat-vvh, 100dvh);
  max-height: var(--chat-vvh, 100dvh);
}

body.chat-shell .page.page-chat-single-scroll .chat-body,
body.chat-shell .page.page-chat-single-scroll .support-chat-body {
  min-height: 0;
  overflow: hidden;
}

body.chat-shell-keyboard-open .chat-head-wrap {
  transform: none;
}

/* Chat Shell V3: Telegram-style bounded stack for mobile runtimes.
   Header, thread, and composer are layout siblings; the document never becomes
   the keyboard scroller. */
body.chat-shell-telegram.chat-shell-mobile.chat-shell-text:has(.page.page-chat-single-scroll) .root-shell {
  height: var(--chat-shell-height, 100dvh);
  min-height: var(--chat-shell-height, 100dvh);
  max-height: var(--chat-shell-height, 100dvh);
  overflow: hidden;
}

body.chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll,
body.chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll #chat.section.active {
  height: var(--chat-shell-height, 100dvh);
  min-height: var(--chat-shell-height, 100dvh);
  max-height: var(--chat-shell-height, 100dvh);
  overflow: hidden;
  box-sizing: border-box;
}

body.chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll {
  padding: 0;
}

body.chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll #chat.section.active {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
  box-sizing: border-box;
}

body.chat-shell-telegram.chat-shell-mobile.chat-shell-text #chat.section.active .chat-head-wrap {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--chat-shell-content-max-width, 560px);
  margin: 0 auto;
  padding-top: var(--app-top-safe-inset, 0px);
  padding-left: var(--chat-shell-edge-gutter, 16px);
  padding-right: var(--chat-shell-edge-gutter, 16px);
  transform: none;
}

body.tg-fullscreen.chat-shell-telegram.chat-shell-mobile.chat-shell-text #chat.section.active .chat-head-wrap {
  --chat-shell-fullscreen-header-inset: var(--app-telegram-fullscreen-header-inset, clamp(52px, calc(var(--app-top-safe-inset, 0px) - 29px), 60px));
  --chat-shell-fullscreen-balance-top: clamp(38px, calc(var(--app-top-safe-inset, 0px) - 44px), 48px);
  --chat-shell-fullscreen-balance-offset: calc(var(--chat-shell-fullscreen-balance-top) - var(--chat-shell-fullscreen-header-inset));
  padding-top: var(--chat-shell-fullscreen-header-inset);
}

body.tg-fullscreen.chat-shell-telegram.chat-shell-mobile.chat-shell-text #chat.section.active .chat-head-wrap > .top-bar {
  position: static;
}

body.tg-fullscreen.chat-shell-telegram.chat-shell-mobile.chat-shell-text #chat .chat-header-balance {
  position: absolute;
  left: 50%;
  top: var(--chat-shell-fullscreen-balance-offset);
  right: auto;
  transform: translateX(-50%);
  grid-column: auto;
  justify-self: auto;
  z-index: 2;
}

body.tg-fullscreen #support-chat-section.section.active .support-chat-head-wrap {
  top: var(--app-telegram-fullscreen-header-inset, var(--app-top-safe-inset));
}

body.tg-fullscreen .page.page-chat-single-scroll:has(#chat.active #chat-main.image-mode) .chat-body {
  padding-top: var(--image-generation-shell-top-reserve, calc(100px + var(--app-telegram-fullscreen-header-inset, var(--app-top-safe-inset))));
}

body.chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll #chat-main.chat-body:not(.image-mode) {
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  box-sizing: border-box;
  position: relative;
  min-height: 0;
  height: auto;
  max-height: none;
  width: 100%;
  max-width: var(--chat-shell-content-max-width, 560px);
  margin: 0 auto;
  padding-top: 0;
  padding-bottom: var(--chat-keyboard-overlay-inset, 0px);
  gap: 0;
  overflow: hidden;
  align-content: stretch;
  align-items: stretch;
}

body.chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll #chat-main.chat-body:not(.image-mode) :where(.chat-scroll-bottom) {
  position: absolute;
  right: calc(var(--chat-shell-edge-gutter, 16px) + 12px);
  bottom: calc(
    var(--chat-composer-zone-height, 56px)
    + var(--chat-composer-rest-gap, 10px)
    + 16px
  );
  z-index: 8;
}

body.chat-shell-telegram.chat-shell-mobile.chat-shell-text.chat-shell-keyboard-open .page.page-chat-single-scroll #chat-main.chat-body:not(.image-mode) :where(.chat-scroll-bottom) {
  bottom: calc(
    var(--chat-composer-zone-height, 56px)
    + var(--chat-composer-keyboard-gap, 8px)
    + 16px
  );
}
