/* Full-screen chat — ai-flip style */
:root {
  --chat-bg: #0a0a0a;
  --chat-sidebar: #111;
  --chat-surface: #1a1a1a;
  --chat-border: rgba(255, 255, 255, 0.08);
  --chat-text: #ececec;
  --chat-muted: #888;
  --chat-user-bubble: #2a2a2a;
  --chat-composer-bg: #1c1c1c;
  --chat-sidebar-w: 52px;
  --chat-sidebar-panel-w: 260px;
  --chat-history-w: 260px;
  --chat-thread-max: 720px;
  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body.chat-app {
  background: var(--chat-bg);
  color: var(--chat-text);
}

.chat-shell {
  display: grid;
  grid-template-columns: var(--chat-sidebar-panel-w) 1fr;
  height: 100dvh;
  min-height: 100dvh;
  position: relative;
  background: var(--chat-bg);
}

body.sidebar-collapsed .chat-shell {
  grid-template-columns: var(--chat-sidebar-w) 1fr;
}

body.sidebar-collapsed .chat-sidebar__panel {
  display: none;
}

body.sidebar-expanded .chat-sidebar__rail {
  display: none;
}

body.sidebar-expanded .chat-sidebar__panel {
  display: flex;
  width: 100%;
}

.material {
  font-family: 'Material Symbols Outlined';
  font-size: 22px;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.scroll-hint.is-hidden { opacity: 0; }

/* Sidebar */
.chat-sidebar {
  display: flex;
  flex-direction: row;
  width: 100%;
  max-width: 100%;
  background: var(--chat-sidebar);
  border-right: 1px solid var(--chat-border);
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
}

.chat-sidebar__rail {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 12px;
  gap: 4px;
  height: 100%;
}

.chat-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  align-items: center;
  padding-top: 4px;
  flex-shrink: 0;
}

.chat-sidebar__panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

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

.chat-sidebar__top-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.88rem;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
}

.chat-sidebar__top-btn .material {
  font-size: 20px;
  color: var(--chat-muted);
}

.chat-sidebar__top-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-sidebar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 8px;
  padding: 0 12px;
  height: 38px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  flex-shrink: 0;
}

.chat-sidebar__search .material {
  font-size: 18px;
  color: var(--chat-muted);
  flex-shrink: 0;
}

.chat-sidebar__search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.82rem;
  outline: none;
}

.chat-sidebar__search input::placeholder {
  color: #666;
}

.chat-sidebar__history-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 0 8px;
}

.chat-sidebar__group {
  margin-bottom: 12px;
}

.chat-sidebar__group.is-empty {
  display: none;
}

.chat-sidebar__group-title {
  margin: 0;
  padding: 6px 8px 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--chat-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-sidebar__history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chat-sidebar__history-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.88rem;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-sidebar__history-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-sidebar__history-item.is-active {
  background: rgba(255, 255, 255, 0.1);
}

.chat-sidebar__footer {
  flex-shrink: 0;
  padding: 8px 10px 12px;
  border-top: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-sidebar__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-bottom: 4px;
  margin-top: auto;
}

.chat-sidebar__premium-wrap {
  position: relative;
  width: 100%;
}

.chat-sidebar__premium-wrap.is-hidden {
  display: none;
}

.chat-sidebar__premium-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.15), rgba(124, 58, 237, 0.06));
  color: #d8b4fe;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0 12px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.15);
}

.chat-sidebar__premium-full .material {
  font-size: 18px;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.chat-sidebar__premium-full:hover {
  border-color: rgba(192, 132, 252, 0.75);
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.25), rgba(124, 58, 237, 0.1));
  color: #f3e8ff;
}

.chat-sidebar__premium--icon {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(168, 85, 247, 0.55);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.18), rgba(124, 58, 237, 0.08));
  color: #c084fc;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.22);
}

.chat-sidebar__premium--icon .material {
  font-size: 20px;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.chat-sidebar__premium--icon:hover {
  border-color: rgba(192, 132, 252, 0.85);
  color: #e9d5ff;
}

.chat-sidebar__premium--icon.is-hidden {
  display: none;
}

/* User pill — Гость + ring + menu */
.chat-sidebar__user-wrap {
  position: relative;
  width: 100%;
  z-index: 55;
}

.chat-sidebar__user-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 40px;
  padding: 0 4px 0 2px;
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.chat-sidebar__user-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 2px 4px 6px;
  text-align: left;
}
.chat-sidebar__user-main .material {
  font-size: 18px;
  color: var(--chat-muted);
  flex-shrink: 0;
}
.chat-sidebar__user-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.chat-sidebar__user-ring {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.chat-sidebar__user-ring-bg {
  stroke: rgba(255, 255, 255, 0.12);
}
.chat-sidebar__user-ring-fg {
  stroke: #ececec;
  stroke-dasharray: 50.27;
  stroke-dashoffset: 50.27;
  transition: stroke-dashoffset 0.3s;
}
.chat-sidebar__user-more {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.chat-sidebar__user-more:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
}
.chat-sidebar__user-more .material { font-size: 16px; }

.chat-sidebar__usage-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  padding: 10px 12px;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  z-index: 65;
}
.chat-sidebar__usage-popover::after {
  content: '';
  position: absolute;
  left: 18px;
  bottom: -5px;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  background: #2a2a2a;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.chat-sidebar__user-wrap:hover .chat-sidebar__usage-popover,
.chat-sidebar__user-wrap:focus-within .chat-sidebar__usage-popover {
  opacity: 1;
  visibility: visible;
}
.chat-sidebar__usage-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--chat-muted);
  margin-bottom: 8px;
}
.chat-sidebar__usage-head span:last-child {
  color: var(--chat-text);
  font-weight: 500;
}
.chat-sidebar__usage-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}
.chat-sidebar__usage-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: #ececec;
  border-radius: 999px;
  transition: width 0.3s;
}

.chat-sidebar__user-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 70;
}
.chat-sidebar__user-wrap:has(.chat-sidebar__user-dropdown:not([hidden])) .chat-sidebar__usage-popover {
  opacity: 0;
  visibility: hidden;
}
.chat-sidebar__user-dropdown button,
.chat-sidebar__user-dropdown a {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.82rem;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.chat-sidebar__user-dropdown button:hover,
.chat-sidebar__user-dropdown a:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-sidebar__btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  text-decoration: none;
  padding: 0;
}
.chat-sidebar__btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
}
.chat-sidebar__btn:disabled { opacity: 0.35; cursor: default; }

/* Main */
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  position: relative;
}
.chat-main__header {
  display: none;
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 20;
}
body.user-logged-in .chat-main__header {
  display: block;
}
.chat-main__menu-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.chat-main__menu-btn:hover { color: var(--chat-text); }
.chat-main__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: #2a2a2a;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.chat-main__dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.88rem;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.chat-main__dropdown button .material { font-size: 18px; color: var(--chat-muted); }
.chat-main__dropdown button:hover { background: rgba(255, 255, 255, 0.06); }
.chat-main__dropdown button.is-danger { color: #ff6b6b; }
.chat-main__menu-wrap { position: relative; }
.chat-main__scroll {
  flex: 1;
  overflow: auto;
  scroll-behavior: smooth;
  position: relative;
}
.chat-main__brand {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 16px 0 8px;
  pointer-events: none;
}
.chat-main__brand span {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #ffd426;
  color: #111;
  font-size: 0.62rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.chat-thread {
  max-width: var(--chat-thread-max);
  margin: 0 auto;
  padding: 8px 24px 160px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.chat-welcome {
  padding-top: 8px;
}
.chat-welcome.is-hidden {
  display: none;
}
.chat-welcome__text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--chat-text);
}
.chat-welcome__text strong {
  font-weight: 600;
  color: #fff;
}

/* Messages */
.chat-msg--user {
  display: flex;
  justify-content: flex-end;
}
.chat-msg__bubble {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--chat-user-bubble);
  color: var(--chat-text);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg--assistant .chat-msg__text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--chat-text);
  word-break: break-word;
}
.chat-msg--assistant .chat-msg__text:not(.chat-msg__text--md) {
  white-space: pre-wrap;
}
.chat-msg--assistant .chat-msg__text--md p {
  margin: 0 0 0.75em;
}
.chat-msg--assistant .chat-msg__text--md p:last-child {
  margin-bottom: 0;
}
.chat-msg--assistant .chat-msg__text--md ul {
  margin: 0 0 0.75em;
  padding-left: 1.35em;
}
.chat-msg--assistant .chat-msg__text--md li {
  margin-bottom: 0.35em;
}
.chat-msg--assistant .chat-msg__text--md strong {
  font-weight: 600;
  color: #fff;
}
.chat-msg--assistant .chat-msg__text--md h1,
.chat-msg--assistant .chat-msg__text--md h2,
.chat-msg--assistant .chat-msg__text--md h3 {
  margin: 0 0 0.5em;
  font-size: 1rem;
  font-weight: 600;
}
.chat-msg--assistant .chat-msg__text--md code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
}
.chat-msg--assistant .chat-msg__text--md pre {
  margin: 0 0 0.75em;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  overflow-x: auto;
}
.chat-msg--assistant .chat-msg__text--md pre code {
  background: none;
  padding: 0;
}
.chat-msg--assistant .chat-msg__text--md a {
  color: #8ab4ff;
  text-decoration: underline;
}
.chat-msg--assistant .chat-msg__text.streaming::after {
  content: '▍';
  animation: chat-blink 1s step-end infinite;
}
@keyframes chat-blink { 50% { opacity: 0; } }

.chat-msg__actions {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.chat-msg--assistant:hover .chat-msg__actions { opacity: 1; }
.chat-msg__actions button {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.chat-msg__actions button .material { font-size: 18px; }
.chat-msg__actions button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
}
.chat-msg__actions button.is-active {
  color: #ffd426;
}
.chat-msg__actions button.is-success {
  color: #6ee7a0;
}

.chat-composer__mic.is-recording {
  color: #ff6b6b;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  50% { opacity: 0.55; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%) translateY(12px);
  background: #333;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  max-width: min(90vw, 360px);
  text-align: center;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.auth-logged-in {
  text-align: center;
  margin-bottom: 8px;
}
.auth-logged-in__email {
  margin: 0 0 12px;
  color: #ccc;
  font-size: 0.95rem;
  word-break: break-all;
}

/* Composer */
.chat-composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 24px 24px;
  background: linear-gradient(transparent, var(--chat-bg) 40%);
  pointer-events: none;
}
.chat-composer__hint {
  max-width: var(--chat-thread-max);
  margin: 0 auto 6px;
  font-size: 0.72rem;
  color: var(--chat-muted);
  text-align: center;
  pointer-events: none;
}
.widget-chat__error {
  display: none;
  max-width: var(--chat-thread-max);
  margin: 0 auto 8px;
  color: #ff6b6b;
  font-size: 0.82rem;
  text-align: center;
  pointer-events: auto;
}
.widget-chat__error.show { display: block; }

.chat-composer {
  max-width: var(--chat-thread-max);
  margin: 0 auto;
  pointer-events: auto;
}
.chat-composer__attach {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.chat-composer__attach:hover { color: var(--chat-text); }
.chat-composer__attach .material { font-size: 20px; }

.chat-composer__box {
  width: 100%;
  background: var(--chat-composer-bg);
  border: 1px solid var(--chat-border);
  border-radius: 22px;
  padding: 14px 16px 10px;
  min-width: 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}
.chat-composer__box textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 160px;
  line-height: 1.5;
  padding: 0;
}
.chat-composer__box textarea::placeholder { color: #666; }

.chat-composer__toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.chat-composer__spacer {
  flex: 1;
  min-width: 8px;
}
.chat-composer__model {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 220px;
}
.chat-composer__model-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 999px;
  padding: 6px 28px 6px 12px;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}
.chat-composer__model-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.chat-composer__model select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.chat-model-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 260px;
  max-width: 320px;
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.chat-model-menu:not([hidden]) { display: block; }
.chat-model-menu__item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--chat-text);
  cursor: pointer;
  line-height: 1.35;
}
.chat-model-menu__item:hover,
.chat-model-menu__item.is-active {
  background: rgba(255, 255, 255, 0.08);
}
.chat-model-menu__item.is-active {
  color: #ffd426;
}
.chat-composer__model-arrow {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px !important;
  color: var(--chat-muted);
  pointer-events: none;
}
.chat-composer__mic {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.chat-composer__mic:hover { color: var(--chat-text); }
.chat-composer__send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #ececec;
  color: #111;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.chat-composer__send:hover { background: #fff; }
.chat-composer__send:disabled { opacity: 0.35; cursor: default; background: #555; color: #aaa; }
.chat-composer__send .material { font-size: 20px; }

/* Auth modal (shared) */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-modal.is-open { display: flex; }
.auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}
.auth-modal__box {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #2a2a2a;
  border-radius: 16px;
  padding: 32px 28px 24px;
  color: #fff;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}
.auth-modal__close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: #888;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.auth-modal__title {
  margin: 0 0 24px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
}
.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
.auth-btn--google { background: #fff; color: #333; border: none; }
.auth-btn--outline {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.auth-btn--primary {
  background: #e8e8e8;
  color: #111;
  border: none;
  margin-bottom: 0;
}
.auth-btn--submit { background: #ffd426; color: #111; border: none; margin-bottom: 0; }
.auth-modal__back {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: none;
  border: none;
  color: #888;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
  padding: 8px 0;
}
.auth-modal__back:hover { color: #ccc; }
.auth-modal__forgot {
  text-align: right;
  margin: -4px 0 4px;
}
.auth-modal__forgot button {
  background: none;
  border: none;
  color: #888;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
}
.auth-modal__forgot button:hover { color: #ccc; }
.auth-logged-in__name {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
}
.auth-logged-in__email {
  margin: 0 0 16px;
  color: #aaa;
  font-size: 0.9rem;
  text-align: center;
  word-break: break-all;
}
.auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 12px;
}
.auth-email-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1e1e1e;
  color: #fff;
  font: inherit;
}
.auth-modal__error {
  color: #ff6b6b;
  font-size: 0.85rem;
  text-align: center;
  margin: 0 0 8px;
}
.auth-modal__switch {
  text-align: center;
  margin: 16px 0 0;
  font-size: 0.9rem;
  color: #888;
}
.auth-modal__switch button {
  background: none;
  border: none;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
}

/* Topup modal */
.topup-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.topup-modal.is-open { display: flex; }
.topup-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
.topup-modal__box {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow: auto;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px 22px 20px;
  color: #fff;
}
.topup-modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: #888;
  font-size: 1.4rem;
  cursor: pointer;
}
.topup-modal__title {
  margin: 0 0 18px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
}
.topup-packages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.topup-package {
  display: block;
  cursor: pointer;
}
.topup-package input { position: absolute; opacity: 0; pointer-events: none; }
.topup-package__body {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: #252525;
  position: relative;
}
.topup-package input:checked + .topup-package__body {
  border-color: #fff;
  background: #2e2e2e;
}
.topup-package__name {
  font-weight: 600;
  font-size: 0.92rem;
}
.topup-package__tokens {
  grid-column: 1;
  color: #aaa;
  font-size: 0.82rem;
}
.topup-package__price {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}
.topup-package__price s {
  display: block;
  color: #666;
  font-size: 0.78rem;
  font-weight: 400;
  text-align: right;
}
.topup-package__badge {
  position: absolute;
  top: -8px;
  right: 12px;
  background: #ff8c42;
  color: #111;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.topup-features {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.topup-features li {
  font-size: 0.82rem;
  color: #bbb;
  line-height: 1.4;
  padding-left: 28px;
  position: relative;
}
.topup-features__icon {
  position: absolute;
  left: 0;
  top: 0;
}
.topup-modal__pay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: #e8e8e8;
  color: #111;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.topup-modal__pay:hover { background: #fff; }
.topup-modal__secure {
  text-align: center;
  margin: 12px 0 6px;
  font-size: 0.82rem;
  color: #aaa;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px;
  border-radius: 8px;
}
.topup-modal__legal {
  text-align: center;
  margin: 0;
  font-size: 0.72rem;
  color: #666;
  line-height: 1.45;
}
.topup-modal__legal a { color: #888; }
.topup-modal__error {
  color: #ff6b6b;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 10px;
}
/* Share chat modal */
.share-chat-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.share-chat-modal.is-open { display: flex; }
.share-chat-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
.share-chat-modal__box {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #1a1a1a;
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  padding: 24px 22px;
  color: #fff;
}
.share-chat-modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #888;
  font-size: 1.4rem;
  cursor: pointer;
}
.share-chat-modal__title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
}
.share-chat-modal__desc {
  margin: 0 0 18px;
  color: #aaa;
  font-size: 0.88rem;
  line-height: 1.45;
}
.share-chat-modal__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--chat-border);
  border-bottom: 1px solid var(--chat-border);
  margin-bottom: 14px;
  cursor: pointer;
  font-size: 0.92rem;
}
.share-chat-modal__toggle input { position: absolute; opacity: 0; }
.share-chat-modal__switch {
  width: 44px;
  height: 24px;
  background: #444;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}
.share-chat-modal__switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.share-chat-modal__toggle input:checked + .share-chat-modal__switch {
  background: #6ee7a0;
}
.share-chat-modal__toggle input:checked + .share-chat-modal__switch::after {
  transform: translateX(20px);
}
.share-chat-modal__link-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.share-chat-modal__link-wrap input {
  flex: 1;
  background: #252525;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: #ccc;
  font: inherit;
  font-size: 0.82rem;
}
.share-chat-modal__link-wrap button {
  width: 40px;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  background: #252525;
  color: #fff;
  cursor: pointer;
}
.share-chat-modal__copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #e8e8e8;
  color: #111;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

body.share-page {
  background: #0a0a0a;
  color: #ececec;
  font-family: Inter, system-ui, sans-serif;
}
.share-page__main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.share-page__title {
  font-size: 1.35rem;
  margin: 0 0 24px;
}
.share-page__error { color: #ff6b6b; }
.share-page__cta {
  margin-top: 32px;
  text-align: center;
}
.share-page__cta a { color: #8ab4ff; }

@media (max-width: 640px) {
  :root { --chat-sidebar-w: 44px; }
  .chat-thread { padding: 32px 16px 150px; }
  .chat-composer-wrap { padding: 0 12px 16px; }
  .chat-msg__actions { opacity: 1; }
}
