:root {
  --bg: #f6f7fb;
  --bg-2: #ffffff;
  --bg-3: #eef0f7;
  --ink: #1a1b2e;
  --muted: #6b7080;
  --line: #e4e6f0;
  --accent: #7c3aed;
  --accent-2: #d946ef;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Syne", system-ui, sans-serif;
  --sidebar-w: 260px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}

html, body { height: 100%; }

body.chat-body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }

.chat-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.chat-app.is-settings-open {
  grid-template-columns: 1fr;
}

.chat-app.is-settings-open .chat-sidebar {
  display: none;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  min-width: var(--sidebar-w);
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
}

.chat-sidebar-backdrop {
  display: none;
}

.chat-sidebar__brand {
  display: flex;
  align-items: center;
  padding: 20px 16px 6px;
}

.chat-logo__img {
  display: block;
  height: 28px;
  width: auto;
}

.chat-modes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 4px;
}

.chat-modes__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chat-modes__btn:hover {
  background: var(--bg-3);
  color: var(--ink);
  text-decoration: none;
}

.chat-modes__btn.is-active {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-2));
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
  color: var(--ink);
}

.chat-modes__icon {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg-3);
  color: inherit;
}

.chat-modes__btn.is-active .chat-modes__icon {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-2));
  color: var(--accent);
}

.chat-modes__label {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
}

.chat-modes__badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-2));
}

.chat-sidebar__workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-sidebar__spacer {
  flex: 1;
  min-height: 12px;
}

.chat-sidebar__workspace[hidden],
.chat-sidebar__soon[hidden] {
  display: none !important;
}

.chat-sidebar__soon {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  padding: 18px 16px;
  min-height: 0;
}

.chat-sidebar__soon-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.chat-sidebar__soon-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

.chat-sidebar__top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 12px;
}

.chat-mode-soon {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(2px);
}

.chat-app[data-chat-mode]:not([data-chat-mode="image"]) .chat-mode-soon {
  position: relative;
  inset: auto;
  flex: 1;
  min-height: 0;
  background: transparent;
  backdrop-filter: none;
}

.chat-mode-soon[hidden] {
  display: none !important;
}

.chat-mode-soon__card {
  max-width: 420px;
  padding: 28px 26px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  box-shadow: 0 18px 40px color-mix(in srgb, var(--ink) 6%, transparent);
  text-align: center;
}

.chat-mode-soon__eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.chat-mode-soon__title {
  margin: 0 0 10px;
  font-family: Syne, "IBM Plex Sans", sans-serif;
  font-size: clamp(1.4rem, 2.4vw, 1.8rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--ink);
}

.chat-mode-soon__text {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--muted);
}

.chat-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 14px;
  box-shadow: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chat-new-btn:hover {
  background: color-mix(in srgb, var(--accent) 13%, var(--bg-2));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}

.chat-icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--muted);
}

.chat-icon-btn:hover { background: var(--bg-3); color: var(--ink); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.chat-list__empty {
  margin: 24px 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

.chat-list__empty[hidden] {
  display: none !important;
}

.chat-list__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-size: 0.85rem;
  text-align: left;
  color: var(--muted);
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list__item:hover { background: var(--bg-3); color: var(--ink); }
.chat-list__item.is-active { background: var(--bg-3); color: var(--ink); }

.chat-list__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}

.chat-list__row:hover,
.chat-list__row.is-active,
.chat-list__row.is-menu-open {
  background: var(--bg-3);
}

.chat-list__row.is-active .chat-list__item,
.chat-list__row:hover .chat-list__item,
.chat-list__row.is-menu-open .chat-list__item {
  color: var(--ink);
}

.chat-list__row .chat-list__item {
  flex: 1;
  min-width: 0;
  background: transparent;
}

.chat-list__row .chat-list__item:hover {
  background: transparent;
}

.chat-list__menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-list__menu-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  color: var(--muted);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.chat-list__row:hover .chat-list__menu-btn,
.chat-list__row.is-menu-open .chat-list__menu-btn,
.chat-list__menu-btn:focus-visible {
  opacity: 1;
}

.chat-list__menu-btn:hover,
.chat-list__menu-btn[aria-expanded="true"] {
  background: var(--bg);
  color: var(--ink);
}

.chat-list__dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  min-width: 168px;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 44px rgba(26, 27, 46, 0.18);
}

.chat-list__dropdown[hidden] {
  display: none !important;
}

.chat-list__dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.85rem;
  text-align: left;
  color: var(--ink);
  border-radius: 7px;
  transition: background 0.15s;
}

.chat-list__dropdown-item:hover {
  background: var(--bg-3);
}

.chat-list__dropdown-item--danger {
  color: #f87171;
}

.chat-list__dropdown-item--danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.chat-list__rename {
  flex: 1;
  min-width: 0;
  margin: 4px 0 4px 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--accent-2);
  border-radius: 8px;
}

.chat-list__rename:focus {
  outline: none;
}

@media (hover: none) {
  .chat-list__menu-btn {
    opacity: 1;
  }
}

/* Chat persona modes */
.mode-modal[hidden] {
  display: none !important;
}

.mode-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  padding: 20px;
}

.mode-modal__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  cursor: default;
}

.mode-modal__panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(90vh, 720px);
  overflow-y: auto;
  padding: 24px 22px 20px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.mode-modal__title {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
}

.mode-modal__hint {
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 14px 12px;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.mode-card:hover,
.mode-card:focus-visible {
  border-color: var(--mode-color, var(--accent-2));
  background: var(--bg-3);
  outline: none;
  transform: translateY(-1px);
}

.mode-card__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.mode-card__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mode-color, var(--muted));
  flex-shrink: 0;
}

.mode-card__desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.chat-list__item-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
  width: 100%;
}

.chat-list__title {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-mode-badge {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--mode-color, var(--muted));
  background: color-mix(in srgb, var(--mode-color, #9b9b9b) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--mode-color, #9b9b9b) 35%, transparent);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 560px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.chat-header__left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-burger {
  display: none;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.chat-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-header__logo {
  display: none;
}

.chat-header__logo-img {
  display: block;
  height: 26px;
  width: auto;
}

.chat-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.chat-support-btn {
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chat-support-btn:hover {
  background: rgba(124, 58, 237, 0.08);
  border-color: #7c3aed;
  color: #7c3aed;
}

.chat-sidebar__profile {
  flex-shrink: 0;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.profile-row {
  position: relative;
}

.profile-row__main {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 14px;
  text-align: left;
  transition: background 0.15s;
}

.profile-row__main:hover,
.profile-row.is-open .profile-row__main {
  background: var(--bg-3);
}

.profile-row__avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
}

.profile-row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.profile-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.profile-row__chevron {
  flex-shrink: 0;
  color: var(--muted);
}

.profile-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.22);
  transition: transform 0.15s, box-shadow 0.15s;
}

.profile-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(124, 58, 237, 0.28);
}

.profile-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 120;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 44px rgba(26, 27, 46, 0.18);
}

.profile-dropdown[hidden] {
  display: none !important;
}

.profile-dropdown__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  text-align: left;
  color: var(--ink);
  border-radius: 8px;
  transition: background 0.15s;
  text-decoration: none;
}

.profile-dropdown__item:hover {
  background: var(--bg-3);
}

.profile-dropdown__item--danger {
  color: #f87171;
}

.profile-dropdown__item--danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.chat-content {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.chat-view[hidden],
.chat-settings[hidden] {
  display: none !important;
}

.chat-settings {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 40px;
}

.chat-settings__inner {
  max-width: 560px;
  margin: 0 auto;
}

.chat-settings__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  padding: 6px 10px 6px 4px;
  font-size: 0.88rem;
  color: var(--muted);
  border-radius: 8px;
  text-decoration: none;
}

.chat-settings__back:hover {
  color: var(--ink);
  background: var(--bg-3);
}

.chat-settings__title {
  margin: 0 0 24px;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 800;
}

.settings-card {
  margin-bottom: 16px;
  padding: 18px 20px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.settings-card__title {
  margin: 0 0 14px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-list {
  margin: 0;
}

.settings-list__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.settings-list__row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-list__row dt {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.settings-list__row dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.settings-limits {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.settings-limit {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--muted);
}

.settings-limit strong {
  color: var(--ink);
  font-weight: 600;
}

.settings-limit--pro span {
  color: var(--accent-2);
}

.settings-upgrade {
  display: inline-flex;
  justify-content: center;
  margin-top: 16px;
  text-decoration: none;
}

.settings-upgrade[hidden] {
  display: none !important;
}

.settings-note {
  margin: 14px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.chat-usage-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chat-usage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  padding: 5px 12px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
}

.chat-usage__icon {
  flex-shrink: 0;
  color: var(--accent);
}

.chat-usage strong {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chat-usage.is-exhausted {
  color: #b4453f;
  background: rgba(220, 80, 72, 0.10);
}

.chat-usage.is-exhausted .chat-usage__icon,
.chat-usage.is-exhausted strong {
  color: #d05048;
}

.chat-usage.is-pro {
  color: var(--accent-2);
  background: rgba(217, 70, 239, 0.10);
}

.chat-usage.is-pro .chat-usage__icon,
.chat-usage.is-pro strong {
  color: var(--accent-2);
}

.chat-usage--tokens {
  font-variant-numeric: tabular-nums;
}

.chat-auth-btn {
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  background: #fff;
  color: #111;
  border-radius: 999px;
}

.chat-auth-btn:hover { opacity: 0.9; }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px 16px;
}

.chat-messages:not(:has(.msg)) {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 720px) {
  .chat-messages:not(:has(.msg)) {
    justify-content: flex-start;
    padding-top: 20px;
  }
}

.chat-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 5vw, 56px);
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px;
  text-align: left;
}
.chat-empty__copy {
  flex: 1 1 340px;
  min-width: 280px;
  max-width: 440px;
}

.chat-empty h1 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3.4vw, 2.15rem);
  font-weight: 800;
  line-height: 1.12;
}

.chat-empty__lead {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.98rem;
}
.capabilities-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.capability {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.capability__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}

.capability__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

.capability__label {
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

.capability__sub {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.35;
}
.chat-empty__visual {
  flex: 0 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-cluster {
  position: relative;
  width: 340px;
  height: 300px;
}

.card-cluster__card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 168px;
  aspect-ratio: 3 / 4;
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(124, 58, 237, 0.16);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  will-change: transform;
}

.card-cluster__card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-cluster__card--4 {
  transform: translate(-50%, -50%) translate(-96px, 8px) rotate(-9deg);
  z-index: 1;
}

.card-cluster__card--3 {
  transform: translate(-50%, -50%) translate(-40px, -14px) rotate(-3deg);
  z-index: 2;
}

.card-cluster__card--2 {
  transform: translate(-50%, -50%) translate(40px, 14px) rotate(4deg);
  z-index: 3;
}

.card-cluster__card--1 {
  width: 182px;
  transform: translate(-50%, -50%) translate(96px, -8px) rotate(7deg);
  z-index: 4;
  box-shadow: 0 22px 48px rgba(124, 58, 237, 0.22);
}

.card-cluster:hover .card-cluster__card--4 {
  transform: translate(-50%, -50%) translate(-116px, 8px) rotate(-11deg);
}

.card-cluster:hover .card-cluster__card--3 {
  transform: translate(-50%, -50%) translate(-48px, -20px) rotate(-4deg);
}

.card-cluster:hover .card-cluster__card--2 {
  transform: translate(-50%, -50%) translate(48px, 20px) rotate(5deg);
}

.card-cluster:hover .card-cluster__card--1 {
  transform: translate(-50%, -50%) translate(116px, -12px) rotate(8deg);
}
@media (max-width: 900px) {
  .chat-empty {
    gap: 32px;
  }
  .card-cluster {
    width: 300px;
    height: 270px;
  }
  .card-cluster__card {
    width: 150px;
  }
  .card-cluster__card--1 {
    width: 164px;
  }
}

@media (max-width: 720px) {
  .chat-empty {
    flex-direction: column-reverse;
    text-align: center;
    gap: 22px;
    padding: 8px 16px 16px;
  }
  .chat-empty__copy {
    flex-basis: auto;
    max-width: 440px;
  }
  .chat-empty h1 {
    font-size: clamp(1.45rem, 6.4vw, 1.85rem);
    line-height: 1.15;
  }
  .chat-empty__lead {
    margin-bottom: 18px;
    font-size: 0.95rem;
  }
  .capabilities-list {
    text-align: left;
    gap: 12px;
  }
  .card-cluster {
    width: 236px;
    height: 188px;
  }
  .card-cluster__card {
    width: 118px;
  }
  .card-cluster__card--1 {
    width: 130px;
  }
  .card-cluster__card--4 {
    display: none;
  }
  .card-cluster__card--3 {
    transform: translate(-50%, -50%) translate(-52px, -8px) rotate(-5deg);
  }
  .card-cluster__card--2 {
    transform: translate(-50%, -50%) translate(6px, 10px) rotate(3deg);
  }
  .card-cluster__card--1 {
    transform: translate(-50%, -50%) translate(60px, -6px) rotate(6deg);
  }
}

@media (max-width: 480px) {
  .chat-empty {
    gap: 20px;
  }
  .card-cluster {
    width: 216px;
    height: 172px;
  }
  .card-cluster__card {
    width: 112px;
  }
  .card-cluster__card--1 {
    width: 122px;
  }
  .card-cluster__card--3 {
    transform: translate(-50%, -50%) translate(-46px, -6px) rotate(-5deg);
  }
  .card-cluster__card--2 {
    transform: translate(-50%, -50%) translate(6px, 10px) rotate(3deg);
  }
  .card-cluster__card--1 {
    transform: translate(-50%, -50%) translate(52px, -6px) rotate(6deg);
  }
}

@media (max-width: 380px) {
  .card-cluster__card--3 {
    display: none;
  }
  .card-cluster {
    width: 196px;
    height: 158px;
  }
  .card-cluster__card {
    width: 108px;
  }
  .card-cluster__card--1 {
    width: 116px;
  }
  .card-cluster__card--2 {
    transform: translate(-50%, -50%) translate(-28px, 8px) rotate(-4deg);
  }
  .card-cluster__card--1 {
    transform: translate(-50%, -50%) translate(28px, -6px) rotate(5deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-cluster__card {
    transition: none;
  }
}

.msg {
  max-width: 720px;
  margin: 0 auto 20px;
  line-height: 1.55;
}

.msg--user {
  background: transparent;
  border: 0;
}

.msg--assistant {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
}

.msg__body {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg__body--preview {
  position: relative;
}

.msg__preview-text {
  white-space: pre-wrap;
}

.msg__preview-hidden {
  display: inline;
  filter: blur(4px);
  opacity: 0.42;
  user-select: none;
  pointer-events: none;
}

.msg--assistant .msg__preview-cta {
  margin-top: 12px;
  color: #34d399;
  font-weight: 600;
}

.msg--assistant .msg__preview-cta-link {
  color: #6ee7b7;
  text-decoration: underline;
  cursor: pointer;
}

.msg--assistant .msg__preview-cta-link:hover,
.msg--assistant .msg__preview-cta-link:focus-visible {
  color: #a7f3d0;
  outline: none;
}

.msg-copy {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.msg-copy:hover,
.msg-copy:focus-visible {
  color: var(--ink);
  background: var(--bg-2);
  border-color: #3f3f3f;
  outline: none;
}

.msg-copy.is-copied {
  color: var(--accent-2);
  border-color: rgba(139, 92, 246, 0.45);
}

.msg-copy__tip {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  pointer-events: none;
  z-index: 2;
}

.msg-copy:hover .msg-copy__tip,
.msg-copy:focus-visible .msg-copy__tip,
.msg-copy.is-copied .msg-copy__tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.msg__attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px 8px;
  font-size: 0.78rem;
  color: var(--accent-2);
  background: rgba(124, 58, 237, 0.15);
  border-radius: 6px;
}

.msg--thinking {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.thinking-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent-2);
  border-radius: 50%;
  animation: dot 1.2s ease-in-out infinite;
}

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

@keyframes dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.chat-composer-wrap {
  flex-shrink: 0;
  padding: 12px 20px max(20px, env(safe-area-inset-bottom));
}

.chat-pin {
  max-width: 720px;
  margin: 0 auto 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--accent, #7c6cff);
  border-radius: 10px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #7c6cff) 30%, transparent);
}

.chat-pin:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-pin__thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.chat-composer-wrap.is-dragover .chat-composer {
  border-color: var(--accent, #7c6cff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #7c6cff) 25%, transparent);
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(26, 27, 46, 0.08);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 12px 34px rgba(124, 58, 237, 0.14);
}

.chat-composer textarea {
  flex: 1;
  min-height: 64px;
  max-height: 200px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.5;
  padding: 10px 4px;
}

.chat-composer textarea:focus { outline: none; }

.chat-type {
  display: inline-flex;
  flex-shrink: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.chat-type__btn {
  padding: 5px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
  white-space: nowrap;
}

.chat-type__btn.is-active {
  color: var(--ink);
  background: rgba(139, 92, 246, 0.18);
}

.msg__image {
  display: block;
  max-width: min(100%, 420px);
  border-radius: 12px;
  margin-top: 4px;
  border: 1px solid var(--line);
}

.msg-image {
  position: relative;
  display: inline-block;
  max-width: min(100%, 420px);
}

.msg-image .msg__image {
  margin-top: 0;
  width: 100%;
  cursor: zoom-in;
}

.msg-image__actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

.msg-image:hover .msg-image__actions,
.msg-image:focus-within .msg-image__actions {
  opacity: 1;
}

@media (hover: none) {
  .msg-image__actions {
    opacity: 1;
  }
}

.msg-image__btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--ink);
  background: rgba(13, 13, 13, 0.82);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.msg-image__btn:hover,
.msg-image__btn:focus-visible {
  background: var(--bg-2);
  border-color: #3f3f3f;
  outline: none;
}

.image-lightbox[hidden] {
  display: none !important;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
}

.image-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  border: none;
  cursor: zoom-out;
}

.image-lightbox__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: min(96vw, 1100px);
  max-height: 94vh;
}

.image-lightbox__close {
  position: absolute;
  top: -44px;
  right: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  transition: background 0.15s;
}

.image-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.image-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(94vh - 56px);
  width: auto;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  object-fit: contain;
}

.image-lightbox__bar {
  display: flex;
  justify-content: center;
}

.image-lightbox__download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  transition: background 0.15s;
}

.image-lightbox__download:hover {
  background: rgba(255, 255, 255, 0.18);
}

.chat-send-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.22);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.chat-send-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, #000);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.26);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* Modals */
.auth-switch[hidden] {
  display: none;
}

.modal--locked .modal__close {
  display: none;
}

.modal--locked .modal__backdrop {
  cursor: default;
}

.modal[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal__backdrop {
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  overflow: hidden;
  width: min(410px, 100%);
  padding: 30px 26px 26px;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 70px -20px rgba(124, 58, 237, 0.5), 0 8px 24px rgba(26, 27, 46, 0.08);
}

.modal__panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.modal__panel--sm { width: min(380px, 100%); }

.modal__panel h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.modal__close:hover {
  background: var(--bg-3);
  color: var(--accent);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 22px;
}

.auth-hero__logo-img {
  display: block;
  height: 40px;
  width: auto;
  margin-bottom: 4px;
}

.auth-hero h2 { margin: 4px 0 0; }

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
  border: 2px solid #e8e4f0;
}

.auth-tabs__item {
  flex: 1;
  padding: 10px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  background: #fafafa;
  border-right: 2px solid #e8e4f0;
}

.auth-tabs__item:last-child { border-right: none; }
.auth-tabs__item.is-active { background: linear-gradient(128deg, #4c1d95, #7c3aed); color: #fff; }
.auth-tabs__item:disabled { opacity: 0.55; cursor: not-allowed; }

.auth-soon {
  margin: 0 0 16px;
  font-size: 0.75rem;
  color: #888;
}

.auth-subtitle {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.auth-sso {
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
}

.auth-sso__btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.auth-sso__btn:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 10px 22px -12px rgba(124, 58, 237, 0.55);
}

.auth-sso__btn:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.auth-sso__label { flex: 1; text-align: left; }

.auth-sso__soon {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-sso__btn--vk {
  background: linear-gradient(180deg, #fff, #f4f8ff);
}

.auth-sso__btn--vk .auth-sso__chip {
  background: linear-gradient(135deg, #0a6eff, #2f8bff);
  color: #fff;
}

.auth-sso__btn--vk:not(:disabled):hover {
  border-color: rgba(10, 110, 255, 0.5);
  box-shadow: 0 10px 22px -12px rgba(10, 110, 255, 0.5);
}

.auth-sso__btn--yandex {
  background: linear-gradient(180deg, #fff, #faf9f9);
}

.auth-sso__btn--yandex:not(:disabled):hover {
  border-color: rgba(26, 26, 26, 0.45);
  box-shadow: 0 10px 22px -12px rgba(26, 26, 26, 0.4);
}

.auth-sso__icon {
  display: block;
  flex-shrink: 0;
  width: auto;
  height: 26px;
}

.auth-sso__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 26px;
  padding: 0 9px;
  border-radius: 9px;
  background: var(--bg-3);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 18px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-divider span {
  flex-shrink: 0;
}

.auth-form label {
  display: block;
  margin-bottom: 14px;
}

.auth-form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
}

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.auth-form input:focus {
  outline: none;
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.auth-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  font-size: 0.83rem;
  color: #b91c1c;
}

.auth-error[hidden] { display: none; }

.auth-switch {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.auth-switch button {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-switch button:hover { color: var(--accent-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  border-radius: 14px;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 14px 28px -12px rgba(124, 58, 237, 0.7);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px -12px rgba(124, 58, 237, 0.8);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-outline {
  background: #fff;
  color: #111;
  border-color: #0a0a0f;
}

.btn-block { width: 100%; }

.paywall-features {
  margin: 0 0 20px;
  padding-left: 18px;
  color: #444;
  font-size: 0.9rem;
}

.paywall-features li { margin-bottom: 6px; }

.paywall-topup-balance {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--accent-2);
}

.paywall-error {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: #f0a8a8;
}

.profile-plan { margin: 0 0 20px; color: #666; font-size: 0.9rem; }

@media (max-width: 768px) {
  .chat-app {
    grid-template-columns: 1fr;
  }

  /* Off-canvas drawer: sidebar slides in over a dimmed backdrop. */
  .chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(84vw, 320px);
    min-width: 0;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
  }

  .chat-app.is-sidebar-open .chat-sidebar {
    transform: translateX(0);
  }

  .chat-sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(15, 15, 25, 0.42);
  }

  .chat-burger {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--ink);
  }

  .chat-app.is-settings-open .chat-burger {
    display: none;
  }

  .chat-sidebar__brand {
    justify-content: flex-start;
    padding: 20px 16px 6px;
  }

  .chat-logo__img {
    height: 28px;
  }

  /* Full drawer: labels/logo/profile text must be visible, not collapsed like the old rail. */
  .chat-new-btn {
    padding: 12px 16px;
    font-size: 0.92rem;
    gap: 10px;
  }

  .chat-list__empty {
    font-size: 0.82rem;
    margin: 16px;
  }

  .profile-row__text,
  .profile-row__chevron {
    display: revert;
  }

  .profile-row__main {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .profile-dropdown {
    left: 0;
    right: auto;
    min-width: 180px;
  }

  .chat-type__btn {
    padding: 4px 6px;
    font-size: 0.62rem;
  }

  .chat-composer-wrap {
    padding: 10px 12px max(16px, env(safe-area-inset-bottom));
  }

  .chat-composer {
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 18px;
  }

  .chat-composer textarea {
    min-width: 0;
    width: 100%;
    min-height: 56px;
    max-height: 160px;
    font-size: 1rem;
    line-height: 1.45;
    padding: 8px 4px;
  }

  .chat-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
  }

  .chat-header__left {
    min-width: 0;
  }

  .chat-header__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    position: static;
    left: auto;
    top: auto;
    transform: none;
    max-width: 100%;
    min-width: 0;
    pointer-events: auto;
  }

  .chat-header__logo-img {
    height: 22px;
    max-width: min(118px, 28vw);
    width: auto;
    object-fit: contain;
  }

  .chat-header__right {
    gap: 6px;
    min-width: 0;
    flex-shrink: 0;
  }

  .chat-support-btn {
    padding: 7px 10px;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  .chat-usage {
    font-size: 0.72rem;
    padding: 4px 8px;
  }
}

/* ==== Image chat messages (Creostart) ==== */
.msg {
  display: flex;
  margin: 14px 0;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 16px;
}
.msg--user {
  justify-content: flex-end;
}
.msg__bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.22);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg--assistant .msg__bubble {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 8px 24px rgba(26, 27, 46, 0.06);
}
.msg--assistant .msg__bubble strong {
  font-weight: 600;
}
.msg--assistant .msg__bubble em {
  font-style: italic;
}
.msg--assistant .msg__bubble h3,
.msg--assistant .msg__bubble h4,
.msg--assistant .msg__bubble h5,
.msg--assistant .msg__bubble h6 {
  margin: 0.6em 0 0.35em;
  font-family: inherit;
  font-weight: 600;
  font-size: 1.02em;
  line-height: 1.35;
}
.msg--assistant .msg__list {
  margin: 0.4em 0 0.55em;
  padding-left: 1.25em;
}
.msg--assistant .msg__list li {
  margin: 0.15em 0;
}
.msg--assistant .msg__code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(17, 24, 39, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}
.msg--assistant .msg__codeblock {
  margin: 0.55em 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #111827;
  color: #f9fafb;
  overflow-x: auto;
  font-size: 0.84em;
  line-height: 1.45;
}
.msg--assistant .msg__codeblock code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}
.msg__bubble--stream .msg__caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: currentColor;
  animation: pixcaret 1s steps(1) infinite;
}
@keyframes pixcaret {
  50% { opacity: 0; }
}
.msg__file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.8rem;
}
.chat-pin--file {
  align-items: center;
}
.chat-pin--file .chat-pin__file-ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(17, 24, 39, 0.06);
  color: var(--ink);
  flex: 0 0 auto;
}
.chat-app[data-chat-mode="text"] .chat-empty {
  justify-content: center;
}
.chat-app[data-chat-mode="text"] .chat-empty__copy {
  max-width: 560px;
}
.msg--assistant {
  justify-content: flex-start;
}
.msg__image {
  position: relative;
  width: 320px;
  max-width: 78%;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg-3);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(26, 27, 46, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}
.msg__image--loading {
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
}
.msg__video {
  width: 100%;
  max-width: 520px;
  border-radius: 18px;
  overflow: hidden;
  background: #0f1117;
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(26, 27, 46, 0.1);
}
.msg__video video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  background: #000;
}
.msg__video-wrap .msg__img-hint {
  max-width: 520px;
}
.msg__spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(124, 58, 237, 0.2);
  border-top-color: var(--accent);
  animation: pixspin 0.8s linear infinite;
}
@keyframes pixspin {
  to { transform: rotate(360deg); }
}
.msg__loading-text {
  font-size: 0.85rem;
}
.msg__error {
  background: #fff0f2;
  color: #c02b4a;
  border: 1px solid #ffd4dc;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
}
.msg__image--teaser {
  color: #fff;
}
.msg__teaser-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Полный frost — детали и силуэты не читаются. */
  filter: blur(36px) saturate(1.15) brightness(0.92);
  transform: scale(1.28);
}
.msg__teaser-blur {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 30%, #ffd27d, transparent 45%),
    radial-gradient(circle at 70% 40%, #ff7eb3, transparent 45%),
    radial-gradient(circle at 50% 75%, #7c5cff, transparent 50%),
    linear-gradient(135deg, #8b5cf6, #d946ef);
  filter: blur(28px) saturate(1.1);
  transform: scale(1.2);
}
.msg__teaser-overlay {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(18, 10, 36, 0.42);
  width: 100%;
  height: 100%;
  justify-content: center;
}
.msg__teaser-overlay p {
  margin: 0;
  font-weight: 600;
  line-height: 1.4;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}
.msg__teaser-btn {
  margin-top: 4px;
  border: none;
  cursor: pointer;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}
.msg__teaser-btn:hover {
  transform: translateY(-1px);
}
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-lightbox[hidden] { display: none; }
.image-lightbox__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(15, 12, 30, 0.72);
  backdrop-filter: blur(4px);
}
.image-lightbox__dialog {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 88vh;
}
.image-lightbox__img {
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 16px;
  display: block;
}
.image-lightbox__close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* ==== Image editing: attach button + attachment chip ==== */
.chat-attach-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  color: var(--muted);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chat-attach-btn:hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-2));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--accent);
}

.chat-pin__caption {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-pin__mode {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent, #7c6cff);
}

.chat-pin__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.chat-pin__remove {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--muted);
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

.chat-pin__remove:hover {
  background: var(--bg-3);
  color: #c02b4a;
}

/* Изображение-источник, помеченное как «редактируется». */
.msg--editing .msg__image {
  outline: 2px solid var(--accent, #7c6cff);
  outline-offset: 2px;
  border-radius: 14px;
}

.msg--editing .msg__image-wrap {
  position: relative;
}

.msg--editing .msg__image-wrap::before {
  content: 'редактируется';
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 3px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--accent, #7c6cff);
  border-radius: 999px;
  pointer-events: none;
}

/* ==== Assistant image action toolbar (edit / remove bg) ==== */
.msg__image-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.msg__img-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.msg__img-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.msg__img-action:hover {
  background: var(--bg-3);
  border-color: var(--accent-2);
  color: var(--accent);
}

.msg__img-action svg {
  flex-shrink: 0;
}

.msg__img-hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted, #8a8aa5);
}

.msg__text-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  max-width: 80%;
}
.msg__text-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted, #6b7280);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.msg__text-action:hover {
  background: var(--bg-3, #f3f4f6);
  border-color: var(--accent-2, #a78bfa);
  color: var(--accent, #7c3aed);
}
.msg__text-action.is-copied {
  color: #059669;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.msg__edit-hint {
  max-width: 720px;
  margin: -4px auto 8px;
  padding: 0 16px;
  font-size: 0.8rem;
  color: var(--accent);
}


/* ---- Audio / Music studio ---- */
.chat-app[data-chat-mode="audio"] .chat-main {
  overflow: hidden;
  min-width: 0;
}
.audio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 20px;
  padding: 16px 20px 28px;
  overflow: auto;
  height: calc(100vh - 64px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.audio-studio,
.audio-library {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.audio-studio {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.audio-library {
  overflow: hidden;
}
.audio-studio__title {
  margin: 0 0 6px;
  font-family: Syne, sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
}
.audio-studio__lead {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}
.audio-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}
.audio-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
.audio-field__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.audio-field__label em {
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
}
.audio-field input,
.audio-field textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.4;
  background: var(--bg-2, #f7f7fb);
  resize: vertical;
  box-sizing: border-box;
}
.audio-field input:focus,
.audio-field textarea:focus {
  outline: 2px solid rgba(124, 58, 237, 0.25);
  border-color: var(--accent);
  background: #fff;
}
.audio-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}
.audio-seg__btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  min-width: 0;
}
.audio-seg__btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.audio-suggestions {
  min-width: 0;
  max-width: 100%;
}
.audio-suggestions__head {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.audio-suggestions__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.audio-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--ink);
  max-width: 100%;
}
.audio-chip:hover {
  border-color: var(--accent-2);
  color: var(--accent);
}
.audio-submit {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.25);
  box-sizing: border-box;
}
.audio-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}
.audio-submit__cost {
  font-weight: 600;
  opacity: 0.9;
  font-size: 0.88rem;
}
.audio-form__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.audio-form__error {
  margin: 0;
  color: #c02b4a;
  font-size: 0.88rem;
}
.audio-library {
  display: flex;
  flex-direction: column;
}
.audio-library__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.audio-library__head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-family: Syne, sans-serif;
}
.audio-library__refresh {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}
.audio-library__list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  min-width: 0;
  flex: 1;
}
.audio-library__empty {
  margin: 24px 0;
  text-align: center;
  color: var(--muted);
}
.audio-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--bg-2, #f7f7fb);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.audio-card__top {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  min-width: 0;
}
.audio-card__cover {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  flex: 0 0 auto;
  background: #111827;
}
.audio-card__cover--empty {
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.audio-card__info {
  min-width: 0;
  flex: 1;
}
.audio-card__title {
  margin: 0 0 4px;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}
.audio-card__sample {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #15803d;
}
.audio-card__meta,
.audio-card__styles {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.audio-card__styles {
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.audio-card__player {
  width: 100%;
  max-width: 100%;
  margin-top: 4px;
}
.audio-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.audio-card__btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.audio-card__btn--danger {
  color: #c02b4a;
}
.audio-card__pending {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}
.audio-card__spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(124, 58, 237, 0.2);
  border-top-color: var(--accent);
  animation: pixspin 0.8s linear infinite;
}
.audio-card__error {
  margin: 0;
  color: #c02b4a;
  font-size: 0.86rem;
}
@media (max-width: 960px) {
  .audio-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .chat-app[data-chat-mode="audio"] .chat-main {
    overflow: auto;
  }
  .audio-library__list {
    max-height: none;
  }
}
