:root {
  --bg: #0d0d0d;
  --bg-2: #171717;
  --bg-3: #212121;
  --ink: #ececec;
  --muted: #9b9b9b;
  --line: #2f2f2f;
  --accent: #7c3aed;
  --accent-2: #8b5cf6;
  --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;
  transition: grid-template-columns 0.22s ease;
}

.chat-app.is-sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

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

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

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

.chat-sidebar {
  display: flex;
  flex-direction: column;
  min-width: var(--sidebar-w);
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
  transition: opacity 0.22s ease, border-color 0.22s ease;
}

.chat-app.is-sidebar-collapsed .chat-sidebar {
  opacity: 0;
  overflow: hidden;
  border-right-color: transparent;
  pointer-events: none;
}

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

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

.chat-new-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  border-radius: 10px;
  transition: background 0.15s;
}

.chat-new-btn:hover { background: var(--bg-3); }

.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__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 12px 40px rgba(0, 0, 0, 0.45);
}

.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;
}

.sidebar-toggle--open[hidden] {
  display: none !important;
}

.chat-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  overflow: visible;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
}

.chat-logo__icon {
  display: none;
}

.chat-logo .logo-brand {
  height: 32px;
  width: auto;
  overflow: visible;
}

.chat-logo .logo-brand--icon {
  width: 32px;
  height: 32px;
}

.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;
  transition: background 0.15s, border-color 0.15s;
}

.chat-support-btn:hover {
  background: var(--bg-3);
  border-color: #3f3f3f;
}

.profile-menu {
  position: relative;
}

.profile-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  min-width: 180px;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.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 {
  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 {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.chat-usage.is-exhausted {
  color: #f0a8a8;
  border-color: rgba(240, 168, 168, 0.35);
}

.chat-usage.is-pro {
  color: var(--accent-2);
  border-color: rgba(139, 92, 246, 0.35);
}

.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;
}

.chat-empty {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  text-align: center;
}

.chat-empty h1 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
}

.chat-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.msg--user {
  padding: 14px 16px;
  background: var(--bg-3);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.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-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-attachment {
  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(--line);
  border-radius: 10px;
}

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

.chat-attachment__thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.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: 8px;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.chat-composer textarea {
  flex: 1;
  min-height: 24px;
  max-height: 160px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
  padding: 6px 0;
}

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

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

.chat-composer__meta .chat-model {
  flex: 1;
  min-width: 0;
  max-width: 148px;
}

.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);
}

.chat-model {
  position: relative;
  flex-shrink: 0;
  max-width: 148px;
}

.chat-model__trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.chat-model__trigger span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-model__trigger:hover {
  border-color: rgba(139, 92, 246, 0.45);
}

.chat-model__menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 168px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  background: #1a1a1f;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 30;
}

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

.chat-model__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  border-radius: 8px;
}

.chat-model__item:hover,
.chat-model__item.is-active {
  background: rgba(139, 92, 246, 0.14);
  color: #fff;
}

.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: 36px;
  height: 36px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  flex-shrink: 0;
}

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

/* 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__panel {
  position: relative;
  width: min(420px, 100%);
  padding: 28px 24px 24px;
  background: #fff;
  color: #111;
  border: 2px solid #0a0a0f;
  box-shadow: 8px 8px 0 #4c1d95;
}

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

.modal__panel h2 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 1.5rem;
  line-height: 1;
  color: #666;
}

.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-form label {
  display: block;
  margin-bottom: 14px;
}

.auth-form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
}

.auth-form input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 2px solid #e8e4f0;
  border-radius: 0;
}

.auth-form input:focus {
  outline: 2px solid #7c3aed;
  outline-offset: -2px;
}

.auth-error {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: #b91c1c;
}

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

.auth-switch button {
  color: #5b21b6;
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 2px solid transparent;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(128deg, #4c1d95, #7c3aed);
  color: #fff;
  border-color: #4c1d95;
}

.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,
  .chat-app.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .chat-app.is-sidebar-collapsed .chat-sidebar {
    opacity: 1;
    pointer-events: auto;
  }

  .chat-sidebar {
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    opacity: 1;
    pointer-events: auto;
  }

  .chat-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
  }

  .chat-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .chat-sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-toggle--open {
    display: grid !important;
  }

  .sidebar-toggle--open[hidden] {
    display: grid !important;
  }

  .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 {
    display: grid;
    grid-template-columns: 36px 1fr 36px;
    grid-template-rows: auto auto;
    gap: 8px 10px;
    align-items: center;
    padding: 8px 10px;
  }

  .chat-composer #attach-btn {
    grid-column: 1;
    grid-row: 1;
  }

  .chat-composer textarea {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    width: 100%;
    padding: 4px 0;
  }

  .chat-composer .chat-send-btn {
    grid-column: 3;
    grid-row: 1;
  }

  .chat-composer__meta {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 8px;
    min-width: 0;
  }

  .chat-composer__meta .chat-type {
    flex-shrink: 0;
  }

  .chat-composer__meta .chat-model {
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  .chat-model__trigger {
    width: 100%;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 0.68rem;
  }

  .chat-header {
    padding: 10px 12px;
    gap: 8px;
  }

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

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

  .chat-logo__full {
    display: none;
  }

  .chat-logo__icon {
    display: flex;
  }

  .chat-support-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .chat-auth-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

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