:root {
  --bg:             #000000;
  --sidebar:        #000000;
  --surface:        #212121;
  --surface-hover:  #212121;
  --composer:       #212121;
  --border:         #212121;
  --border-strong:  #212121;
  --text:           #ffffff;
  --text-dim:       #ffffff;
  --muted:          rgba(255, 255, 255, 0.55);
  --danger:         #ef4444;
  --scrollbar:      #212121;
  --icon:           #ffffff;
  --icon-stroke: 1.875;
  --font: "Vazirmatn", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --thread-w: 48rem;
  --topbar-h: 56px;
  --sidebar-w: 260px;
  --sidebar-rail: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  text-rendering: optimizeLegibility;
}

/* Persian / mixed-script text — only on typed/message content, never the chrome */
html, body, .app, .sidebar, .settings-shell {
  direction: ltr;
}
[dir="rtl"]:not(html):not(body) {
  text-align: right;
  unicode-bidi: plaintext;
}
[dir="ltr"]:not(html):not(body) {
  text-align: left;
  unicode-bidi: plaintext;
}
.msg-text,
.msg-markdown,
.msg-bubble,
.chat-item-title,
#prompt-input,
.reply-context-text {
  font-family: var(--font);
  unicode-bidi: plaintext;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-markdown[dir="rtl"] ul,
.msg-markdown[dir="rtl"] ol {
  padding: 0 1.35em 0 0;
}
.msg.user .msg-bubble[dir="rtl"] {
  text-align: right;
}
.msg.user .msg-bubble[dir="ltr"] {
  text-align: left;
}
.msg.assistant .msg-text[dir="rtl"],
.msg.assistant .msg-markdown[dir="rtl"] {
  text-align: right;
}
.msg-markdown code,
.msg-code,
.msg-code-lang {
  font-family: var(--font-mono);
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

/* ── Icons ─────────────────────────────────────────────── */
/* ── Icons (global) ──────────────────────────────────── */
svg.icon {
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--icon);
}
.icon    { width: 20px; height: 20px; display: block; flex-shrink: 0; color: var(--icon); }
.icon-xs { width: 16px; height: 16px; display: block; flex-shrink: 0; color: var(--icon); }
.icon-sm { width: 18px; height: 18px; display: block; flex-shrink: 0; color: var(--icon); }
.icon-md { width: 22px; height: 22px; display: block; flex-shrink: 0; color: var(--icon); }

.send-btn:not(:disabled) .icon,
.voice-btn .icon { color: #000; stroke-width: 2; }
.send-btn:disabled .icon { color: rgba(255, 255, 255, 0.45); }

/* ── App shell ─────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ── Mobile overlay ────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
}
.sidebar-overlay.open { display: block; }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid #212121;
  padding: 8px 8px 12px;
  z-index: 50;
  overflow: hidden;
  transition: width 0.2s ease;
}
.sidebar.collapsed { width: var(--sidebar-rail); }

/* header row */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: 2px;
  flex-shrink: 0;
  padding: 0 4px 0 6px;
}
.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}

.sidebar-logo-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: default;
  transition: background 0.15s;
}
.sidebar.collapsed .sidebar-logo-btn {
  cursor: pointer;
}
.sidebar.collapsed .sidebar-logo-btn:hover {
  background: var(--surface-hover);
}

.sidebar-logo-img { width: 28px; height: 28px; display: block; }
html[data-theme="light"] .sidebar-logo-img {
  filter: invert(1);
}
.sidebar-panel-icon { display: none; width: 18px; height: 18px; }

.sidebar.collapsed .sidebar-logo-btn:hover .sidebar-logo-img { display: none; }
.sidebar.collapsed .sidebar-logo-btn:hover .sidebar-panel-icon { display: block; }

.sidebar-collapse-wrap { flex-shrink: 0; }
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.sidebar-search-wrap { flex-shrink: 0; }
.sidebar.collapsed .sidebar-header-actions { display: none; }
.sidebar-search .icon,
.sidebar-collapse .icon {
  width: 18px;
  height: 18px;
}

/* hover tooltips below sidebar header buttons */
.sidebar-tip-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-tip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 120;
}

.sidebar-tip-wrap:hover .sidebar-tip,
.sidebar-tip-wrap:focus-within .sidebar-tip {
  opacity: 1;
  visibility: visible;
}

/* logo tooltip only when collapsed */
.logo-tip { display: none; }
.sidebar.collapsed .logo-tip { display: block; }

/* collapse tooltip only when expanded */
.sidebar.collapsed .collapse-tip { display: none; }
.sidebar.collapsed .search-tip { display: none; }

/* ── Sidebar nav items (New chat / Search / Chats) ─────── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap; overflow: hidden;
  text-align: left;
}
.side-item:hover { background: var(--surface-hover); }
.side-item .icon { width: 20px; height: 20px; color: var(--icon); }

.sidebar.collapsed .side-item {
  justify-content: center;
  width: 36px; height: 36px;
  padding: 0; margin: 0 auto;
  border-radius: 8px;
}
.sidebar.collapsed .sidebar-label { display: none; }

/* ── Chat list section ─────────────────────────────────── */
.chat-list-wrap {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar.collapsed .chat-list-wrap { display: none; }

.chat-list-section {
  margin: 14px 0 4px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.chat-folder {
  margin-top: 6px;
}
.chat-folder.is-dragging,
.chat-item.is-dragging {
  opacity: 0.45;
}
.chat-folder.is-drop-target,
.chat-folder-chats.is-drop-target,
.chat-uncategorized.is-drop-target,
.chat-pinned.is-drop-target {
  outline: 1px dashed rgba(255, 255, 255, 0.35);
  outline-offset: -2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.chat-item.drop-before {
  box-shadow: inset 0 2px 0 #19c37d;
}
.chat-item.drop-after {
  box-shadow: inset 0 -2px 0 #19c37d;
}
.chat-folder.drop-before {
  box-shadow: inset 0 2px 0 #19c37d;
}
.chat-folder.drop-after {
  box-shadow: inset 0 -2px 0 #19c37d;
}
.chat-item {
  cursor: grab;
}
.chat-item:active {
  cursor: grabbing;
}
.chat-uncategorized,
.chat-pinned {
  min-height: 8px;
  padding: 2px 0 6px;
  border-radius: 10px;
}
.chat-drop-hint {
  padding: 10px 12px;
  margin: 2px 4px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.chat-list-tip {
  margin: 10px 8px 4px;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.38);
}

.chat-folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-folder-header:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.chat-folder-header .folder-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.chat-folder.is-collapsed .folder-chevron {
  transform: rotate(-90deg);
}
.chat-folder-header .folder-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.chat-folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}
.chat-folder-count {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  min-width: 1.25em;
  text-align: right;
}
.chat-folder-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.chat-folder-header:hover .chat-folder-actions,
.chat-folder-header:focus-within .chat-folder-actions {
  opacity: 1;
}
.chat-folder-action {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chat-folder-action:hover {
  background: var(--surface);
  color: var(--text);
}
.chat-folder-action.is-danger:hover {
  color: var(--danger);
}
.chat-folder-chats {
  display: flex;
  flex-direction: column;
  padding-left: 8px;
}
.chat-folder.is-collapsed .chat-folder-chats {
  display: none;
}
.chat-folder-rename {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.chat-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 0 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.chat-item {
  display: flex; align-items: center; gap: 4px;
  position: relative;
  width: 100%;
  padding: 7px 10px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text-dim);
  font: inherit; font-size: 13px;
  text-align: left; cursor: pointer;
  transition: background 0.15s;
  overflow: hidden;
}
.chat-item-title {
  flex: 1;
  min-width: 0;
  padding-right: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Keep Persian titles left-aligned with English ones in the sidebar */
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
  transition: padding-right 0.12s ease;
}
.chat-item.is-pinned .chat-item-title,
.chat-item-has-status .chat-item-title {
  padding-right: 28px;
}
.chat-item.is-pinned .chat-item-title {
  padding-right: 52px;
}
.chat-item:hover .chat-item-title,
.chat-item:focus-within .chat-item-title {
  padding-right: 52px;
}
.chat-folder-name {
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

.chat-item-title.is-generating {
  background: linear-gradient(
    90deg,
    var(--text-dim) 0%,
    rgba(255, 255, 255, 0.92) 45%,
    var(--text-dim) 90%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: chat-title-shimmer 1.6s linear infinite;
}

.chat-item-title.is-typing {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: var(--text);
  animation: none;
}

.chat-item-title.is-typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 0.9em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: rgba(255, 255, 255, 0.75);
  animation: stream-cursor 1s step-end infinite;
}

@keyframes chat-title-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.chat-item:hover, .chat-item.active {
  background: var(--surface-hover); color: var(--text);
}

.chat-item-actions {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  flex-shrink: 0;
  pointer-events: none;
}

.chat-item-actions > * {
  pointer-events: auto;
}

.chat-item-status,
.chat-item-pin,
.chat-item-del {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: default;
  flex-shrink: 0;
}

.chat-item-status {
  position: absolute;
  right: 0;
  top: 0;
  color: var(--muted);
  transition: opacity 0.15s;
}

.chat-item-status--spin {
  color: var(--text-dim);
  pointer-events: none;
}

.chat-item-spinner {
  animation: chat-item-spin 0.75s linear infinite;
}

@keyframes chat-item-spin {
  to { transform: rotate(360deg); }
}

.chat-item-status--done {
  color: #19c37d;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.chat-item-status--done:hover {
  background: rgba(25, 195, 125, 0.14);
  color: #22d38e;
}

.chat-item-pin,
.chat-item-del {
  position: relative;
  z-index: 2;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.chat-item-more {
  position: relative;
  z-index: 2;
  display: none;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.chat-item-more:hover {
  background: var(--surface);
  color: var(--text);
}
.chat-folder-more {
  display: none !important;
}

.chat-item-pin.is-active {
  opacity: 1;
  color: rgba(255, 255, 255, 0.55);
}

.chat-item.is-pinned {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.chat-item.is-pinned .chat-item-title {
  color: var(--text);
}

.chat-item.is-pinned:hover,
.chat-item.is-pinned.active {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.chat-item:hover .chat-item-pin,
.chat-item:hover .chat-item-del {
  opacity: 1;
}

.chat-item:hover .chat-item-status {
  opacity: 0;
  pointer-events: none;
}

.chat-item-pin:hover {
  background: var(--surface);
  color: rgba(255, 255, 255, 0.7);
}

.chat-item-del:hover {
  background: var(--surface);
  color: var(--danger);
}

.chat-item-has-status .chat-item-status {
  z-index: 1;
}

.chat-item-has-status:not(:hover) .chat-item-pin:not(.is-active),
.chat-item-has-status:not(:hover) .chat-item-del {
  opacity: 0;
}

.chat-item.is-renaming {
  background: var(--surface-hover);
}

.chat-item.is-renaming .chat-item-actions {
  display: none;
}

.chat-item-rename {
  flex: 1;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
}

.chat-item-rename:focus {
  border-color: rgba(255, 255, 255, 0.4);
}

.chat-context-menu {
  position: fixed;
  z-index: 4000;
  min-width: 180px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: #2f2f2f;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

.chat-context-menu[hidden] {
  display: none;
}

.chat-context-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3990;
  background: rgba(0, 0, 0, 0.45);
}
.chat-context-backdrop[hidden] {
  display: none !important;
}

.chat-context-menu.is-sheet {
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100%;
  min-width: 0;
  max-height: min(72vh, 560px);
  overflow-y: auto;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  animation: sheet-up 0.2s ease;
}
.chat-context-menu.is-sheet::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  margin: 2px auto 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}
.chat-context-menu.is-sheet .chat-context-item {
  padding: 13px 12px;
  font-size: 15px;
  border-radius: 12px;
}
@keyframes sheet-up {
  from { transform: translateY(12px); opacity: 0.7; }
  to { transform: translateY(0); opacity: 1; }
}

.chat-context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.chat-context-item .icon {
  color: rgba(255, 255, 255, 0.75);
}

.chat-context-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

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

.chat-context-item.is-danger .icon {
  color: #f87171;
}

.chat-context-item.is-danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

/* ── Sidebar footer ────────────────────────────────────── */
.sidebar-footer { margin-top: auto; padding-top: 8px; flex-shrink: 0; }

.sidebar-user-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
  overflow: hidden; transition: background 0.15s;
}
.sidebar-user-btn:hover { background: var(--surface-hover); }

.sidebar.collapsed .sidebar-user-btn {
  justify-content: center;
  width: 36px; height: 36px;
  padding: 0; margin: 0 auto;
}
.sidebar.collapsed .sidebar-user-text { display: none; }

.user-avatar {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #19c37d;
  color: #fff;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase;
}

.user-name {
  font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Main ──────────────────────────────────────────────── */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  position: relative; overflow: hidden;
}

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
  min-height: var(--topbar-h);
  height: var(--topbar-h);
  padding: 0 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.topbar-left,
.topbar-right,
.topbar-actions {
  display: flex;
  align-items: center;
  min-width: 0;
}
.topbar-left { justify-content: flex-start; }
.topbar-right {
  justify-content: flex-end;
  gap: 2px;
  flex-shrink: 0;
}
.topbar-actions {
  justify-content: flex-end;
  gap: 2px;
  flex-shrink: 0;
}
.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}
.mobile-only { display: none; }

.menu-hamburger-icon {
  width: 26px;
  height: 26px;
}

/* ── Model chip ────────────────────────────────────────── */
.model-picker { position: relative; }

.model-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 8px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 18px; font-weight: 700; line-height: 1.25;
  cursor: pointer; transition: background 0.15s;
}
.model-chip:hover,
.model-chip[aria-expanded="true"] { background: var(--surface-hover); }

.model-menu {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  z-index: 200;
  min-width: 280px; max-height: 360px;
  overflow-y: auto; padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.model-menu[hidden] { display: none; }

.model-option {
  display: flex; flex-direction: column; align-items: stretch;
  width: 100%; padding: 10px 12px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
}
.model-option-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%;
}
.model-option-label { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.model-option-meta {
  font-size: 11px; font-weight: 500; color: var(--muted);
  line-height: 1.35; margin-top: 4px; padding-left: 2px;
}
.model-menu-plan-note {
  font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 6px 10px 8px; line-height: 1.4;
  border-bottom: 1px solid var(--border-strong);
  margin-bottom: 4px;
}
.model-option:disabled { opacity: .55; cursor: not-allowed; }
.model-option:hover { background: var(--surface-hover); }
.model-option.active { background: var(--surface); }

/* ── Icon button ───────────────────────────────────────── */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  padding: 0; border: none; border-radius: 10px;
  background: transparent; color: var(--icon);
  cursor: pointer; transition: background 0.15s; flex-shrink: 0;
}
.icon-btn .icon { width: 20px; height: 20px; color: var(--icon); }
.icon-btn:hover { background: var(--surface-hover); }

/* ── Content area ──────────────────────────────────────── */
.content-area {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  position: relative;
}

/* ── Thread ────────────────────────────────────────────── */
.thread {
  flex: 1;
  overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  padding-bottom: 12px;
}
.thread[hidden] { display: none !important; }

/* ── Messages ──────────────────────────────────────────── */
.msg { width: 100%; }

.msg-inner {
  display: flex;
  max-width: var(--thread-w);
  margin: 0 auto;
  padding: 16px 24px 8px;
}

.msg.assistant .msg-inner {
  justify-content: flex-start;
  padding-top: 20px;
  padding-bottom: 12px;
}
.msg.assistant .msg-body {
  width: 100%;
  max-width: 100%;
}

/* User: compact right-aligned pill + hover actions below */
.msg.user .msg-inner { justify-content: flex-end; }
.msg.user .msg-body-user {
  width: auto;
  max-width: min(70%, 28rem);
  margin-left: auto;
  padding: 0;
  background: transparent;
}
.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.msg.user .msg-bubble {
  width: fit-content;
  max-width: 100%;
  background: var(--surface);
  border-radius: 18px;
  padding: 8px 14px;
}

.msg-body {
  min-width: 0;
  font-size: 16px;
  line-height: 1.65;
}

.msg-text { white-space: pre-wrap; word-break: break-word; color: var(--text); }
.msg-text.streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: rgba(255, 255, 255, 0.75);
  animation: stream-cursor 1s step-end infinite;
}
@keyframes stream-cursor {
  50% { opacity: 0; }
}
.msg-markdown { white-space: normal; }
.msg-markdown p {
  margin: 0 0 1em;
  line-height: 1.65;
  color: var(--text);
}
.msg-markdown p:last-child { margin-bottom: 0; }
.msg-markdown ul,
.msg-markdown ol {
  margin: 0.35em 0 1.1em;
  list-style-position: outside;
}
.msg-markdown ul {
  padding: 0 0 0 1.25em;
  list-style: disc;
}
.msg-markdown ol {
  padding: 0 0 0 1.35em;
  list-style: decimal;
}
.msg-markdown[dir="rtl"] ul,
.msg-markdown[dir="rtl"] ol {
  padding: 0 1.35em 0 0;
}
.msg-markdown li {
  margin: 0.45em 0;
  padding-left: 0.15em;
  line-height: 1.6;
}
.msg-markdown[dir="rtl"] li {
  padding-left: 0;
  padding-right: 0.15em;
}
.msg-markdown h2,
.msg-markdown h3,
.msg-markdown h4 {
  margin: 1.15em 0 0.55em;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}
.msg-markdown h2 { font-size: 1.15em; }
.msg-markdown h3 { font-size: 1.05em; }
.msg-markdown h4 { font-size: 1em; }
.msg-markdown h2:first-child,
.msg-markdown h3:first-child,
.msg-markdown h4:first-child,
.msg-markdown p:first-child { margin-top: 0; }
.msg-markdown strong { font-weight: 700; color: var(--text); }
.msg-markdown em { font-style: italic; color: var(--text-dim); }
.msg-markdown del {
  text-decoration: line-through;
  color: var(--muted);
}
.msg-markdown a {
  color: #7ab7ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg-markdown a:hover { color: #a4cdff; }
.msg-markdown code {
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.msg-code-block {
  margin: 0.85rem 0;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #161616;
  overflow: hidden;
}
.msg-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
}
.msg-code-lang {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: lowercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.msg-code-copy {
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.msg-code-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}
.msg-code-copy.is-copied {
  color: #8fd4b0;
  border-color: rgba(143, 212, 176, 0.35);
}
.msg-code-block .msg-code {
  margin: 0;
  padding: 14px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
}
.msg-code {
  margin: 0.75rem 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-strong);
  overflow-x: auto;
}
.msg-code code {
  display: block;
  padding: 0;
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  word-break: normal;
  overflow-x: auto;
}
.msg-blockquote {
  margin: 0.85em 0;
  padding: 10px 14px;
  border-left: 3px solid rgba(255, 255, 255, 0.22);
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.88);
}
.msg-blockquote p {
  margin: 0;
}
.msg-hr {
  margin: 1.25em 0;
  border: none;
  border-top: 1px solid var(--border-strong);
}
.msg-table-wrap {
  margin: 0.85em 0;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
}
.msg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.msg-table th,
.msg-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  text-align: left;
  vertical-align: top;
}
.msg-table th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: #fff;
}
.msg-table tr:last-child td { border-bottom: none; }
.msg-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
.msg-cite {
  display: inline-block;
  font-size: 0.72em;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  vertical-align: super;
  line-height: 1;
  margin: 0 1px;
  letter-spacing: -0.02em;
}

/* User actions: under bubble, visible on hover */
.msg-actions-user {
  justify-content: flex-end;
  margin-top: 2px;
  margin-right: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.msg-bubble-wrap:hover .msg-actions-user,
.msg-bubble-wrap:focus-within .msg-actions-user {
  opacity: 1;
  pointer-events: auto;
}

/* Assistant actions: always visible */
.msg-actions-assistant {
  opacity: 1;
  pointer-events: auto;
}

.msg-memory-banner {
  margin: 0 0 10px;
}
.msg-memory-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.3;
}
.msg-memory-label .icon {
  opacity: 0.72;
  flex-shrink: 0;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
  margin-left: -6px;
}

.msg-action-wrap {
  position: relative;
  display: inline-flex;
}
.msg-action-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: #2f2f2f;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 5;
}
.msg-action-wrap:hover .msg-action-tip,
.msg-action-wrap:focus-within .msg-action-tip {
  opacity: 1;
  visibility: visible;
}

.msg-variant-pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
}
.msg-variant-label {
  min-width: 3.5rem;
  text-align: center;
  color: var(--text-dim);
  font-weight: 500;
}
.msg-variant-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  transition: background 0.12s;
}
.msg-variant-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.msg-variant-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.msg-action {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--icon);
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.msg-action .icon { width: 18px; height: 18px; color: var(--icon); }
.msg-action:hover { background: var(--surface-hover); color: var(--icon); }
.msg-action.is-liked,
.msg-action.is-liked .icon { color: #22c55e; }
.msg-action.is-liked:hover {
  background: rgba(34, 197, 94, 0.16);
  color: #22c55e;
}
.msg-action.is-liked:hover .icon { color: #22c55e; }
.msg-action.is-disliked,
.msg-action.is-disliked .icon { color: #ef4444; }
.msg-action.is-disliked:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
}
.msg-action.is-disliked:hover .icon { color: #ef4444; }

.msg-attach-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-bottom: 8px;
}

.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.msg-attachments img {
  width: 120px; height: 120px;
  object-fit: cover; border-radius: 10px;
  border: 1px solid var(--border-strong);
}
.msg-image-wrap {
  position: relative;
  display: block;
  margin-top: 8px;
  max-width: 100%;
  cursor: pointer;
}
.msg-image-wrap img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
}

/* Image generation loader — minimalist scanline kinetic text */
.msg-image-loading {
  --loader-text-color: #ffffff;
  --loader-font-size: clamp(1rem, 4vw, 1.75rem);
  --loader-font-weight: 500;
  --loader-letter-spacing: 0.4em;
  --loader-scanline-gap: 5px;
  --loader-scanline-width: 1px;
  --loader-speed-sweep: 3.5s;
  --loader-speed-letter: 3s;
  --loader-glow-color: rgba(255, 255, 255, 0.45);
  --gradient-color-1: #ffffff;
  --gradient-color-2: #e2e8f0;
  --gradient-color-3: #94a3b8;
  --gradient-color-4: #cbd5e1;
  --gradient-color-5: #ffffff;

  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: var(--img-ar, 1 / 1);
  margin-top: 8px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: #141414;
  cursor: default;
  overflow: hidden;
}

.msg-image-loading .loader-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
  width: auto;
  user-select: none;
  font-family: "Space Grotesk", sans-serif;
  font-size: var(--loader-font-size);
  font-weight: var(--loader-font-weight);
  letter-spacing: var(--loader-letter-spacing);
  text-transform: uppercase;
  padding-left: var(--loader-letter-spacing);
}

.msg-image-loading .loader {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  z-index: 1;
  background-color: transparent;
  pointer-events: none;
  mask: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent var(--loader-scanline-gap),
    black var(--loader-scanline-gap),
    black calc(var(--loader-scanline-gap) + var(--loader-scanline-width))
  );
  -webkit-mask: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent var(--loader-scanline-gap),
    black var(--loader-scanline-gap),
    black calc(var(--loader-scanline-gap) + var(--loader-scanline-width))
  );
}

.msg-image-loading .loader::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(circle at 40% 50%, var(--gradient-color-1) 0%, transparent 40%),
    radial-gradient(circle at 48% 50%, var(--gradient-color-2) 0%, transparent 45%),
    radial-gradient(circle at 52% 50%, var(--gradient-color-3) 0%, transparent 45%),
    radial-gradient(circle at 56% 50%, var(--gradient-color-4) 0%, transparent 40%),
    radial-gradient(circle at 60% 50%, var(--gradient-color-5) 0%, transparent 40%);
  mask: radial-gradient(circle at 50% 50%, transparent 10%, black 55%);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 10%, black 55%);
  animation: gen-loader-sweep var(--loader-speed-sweep) infinite alternate;
  animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes gen-loader-sweep {
  0% {
    transform: scaleX(1.4) translate(-40%);
    opacity: 0.15;
    filter: blur(2px);
  }
  50% {
    opacity: 0.85;
    filter: blur(0px);
  }
  100% {
    transform: scaleX(1.4) translate(40%);
    opacity: 0.15;
    filter: blur(2px);
  }
}

.msg-image-loading .loader-letter {
  display: inline-block;
  color: var(--loader-text-color);
  opacity: 0;
  animation: gen-loader-letter var(--loader-speed-letter) infinite cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2;
  filter: blur(4px);
}

@keyframes gen-loader-letter {
  0% {
    opacity: 0;
    filter: blur(6px);
    transform: scale(0.9) translateY(4px);
  }
  12%, 60% {
    opacity: 1;
    filter: blur(0px);
    transform: scale(1) translateY(0px);
    text-shadow: 0 0 16px var(--loader-glow-color);
  }
  75%, 100% {
    opacity: 0;
    filter: blur(8px);
    transform: scale(1.05) translateY(-4px);
  }
}

.msg-image-overlay {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  pointer-events: none;
}
.msg-image-overlay::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 88px;
  border-radius: 0 0 16px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.28), transparent);
  pointer-events: none;
}
.msg-image-overlay .msg-image-edit-btn,
.msg-image-overlay .msg-image-share-btn {
  pointer-events: auto;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.2)),
    rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 4px 16px rgba(0, 0, 0, 0.28),
    0 1px 3px rgba(0, 0, 0, 0.2);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.msg-image-overlay .msg-image-edit-btn:hover,
.msg-image-overlay .msg-image-share-btn:hover {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.28)),
    rgba(0, 0, 0, 0.08);
  border-color: rgba(255, 255, 255, 0.52);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 6px 20px rgba(0, 0, 0, 0.32),
    0 2px 4px rgba(0, 0, 0, 0.22);
}
.msg-image-edit-btn {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 9px 20px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  cursor: pointer;
}
.msg-image-edit-btn:active { transform: scale(0.97); }
.msg-image-share-btn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
}
.msg-image-share-btn:active { transform: scale(0.97); }
.msg-image-share-btn .icon {
  width: 19px;
  height: 19px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}
.msg-image-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.msg.error .msg-text { color: var(--danger); }

/* Typing / status indicator */
.msg-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  transition: color 0.25s ease;
}
.msg-status--searching,
.msg-status--reading {
  color: rgba(147, 197, 253, 0.95);
}
.msg-status--searching .msg-status-dot,
.msg-status--reading .msg-status-dot {
  background: rgba(96, 165, 250, 0.95);
  animation: status-pulse-search 1s ease-in-out infinite;
}
.msg-status--writing {
  color: rgba(167, 243, 208, 0.95);
}
.msg-status--writing .msg-status-dot {
  background: rgba(52, 211, 153, 0.95);
}
.msg-status--image {
  color: rgba(216, 180, 254, 0.95);
}
.msg-status--image .msg-status-dot {
  background: rgba(192, 132, 252, 0.95);
}
.msg-status--word {
  color: rgba(147, 197, 253, 0.95);
}
.msg-status--word .msg-status-dot {
  background: #2b579a;
}
.msg-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  animation: status-pulse 1.2s ease-in-out infinite;
  transition: background 0.25s ease;
}
.msg-status-text {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.45) 0%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0.45) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: status-shimmer 1.8s linear infinite;
  transition: opacity 0.2s ease;
}
.msg-status-text.is-changing {
  opacity: 0.55;
}

.msg-thinking {
  margin: 6px 0 2px;
  max-width: min(100%, 42rem);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
}
.msg-thinking-label {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.62);
  list-style: none;
}
.msg-thinking-label::-webkit-details-marker { display: none; }
.msg-thinking-text {
  padding: 0 12px 10px;
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 180px;
  overflow: auto;
}
html[data-theme="light"] .msg-thinking {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.03);
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .msg-thinking-label {
  color: rgba(0, 0, 0, 0.62);
}
@keyframes status-pulse-search {
  0%, 100% { opacity: 0.5; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes msg-search-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes status-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}
@keyframes status-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.msg-search-activity {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: msg-search-in 0.28s ease-out;
}
.msg-search-query {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.4;
}
.msg-search-urls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.msg-search-urls-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}
.msg-search-url-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.msg-search-url-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.msg-search-url-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.msg-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 4px;
}
.msg-sources-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}
.msg-sources-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.msg-source-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: #2f2f2f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.msg-source-pill:hover {
  background: #3a3a3a;
  border-color: rgba(255, 255, 255, 0.14);
}
.msg-source-favicon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.4s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.9); }
  40%            { opacity: 1;    transform: scale(1); }
}

/* ── Empty / welcome state ─────────────────────────────── */
.welcome-panel {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 0 1rem;
}
.welcome-panel[hidden] { display: none !important; }

.empty-title {
  margin: 0;
  font-size: 28px; font-weight: 600; line-height: 1.25;
  color: var(--text); letter-spacing: -0.01em;
}
.empty-sub {
  margin: 10px 0 0;
  max-width: 34rem;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  font-weight: 400;
}
.empty-sub[hidden] { display: none !important; }

.temp-chat-toggle {
  position: relative;
  display: inline-grid !important;
  place-items: center;
  flex-shrink: 0;
  color: var(--icon);
}
.temp-chat-toggle .temp-chat-icon-off,
.temp-chat-toggle .temp-chat-icon-on {
  width: 22px;
  height: 22px;
  color: var(--icon);
  grid-area: 1 / 1;
}
.temp-chat-toggle .temp-chat-icon-on {
  display: none;
}
.temp-chat-toggle .temp-chat-icon-off {
  display: block;
}
.temp-chat-toggle.is-active .temp-chat-icon-off {
  display: none;
}
.temp-chat-toggle.is-active .temp-chat-icon-on {
  display: block;
}
.temp-chat-toggle.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.temp-chat-toggle.is-active .temp-chat-icon-on {
  color: var(--text);
}
.main.is-temp-chat .model-picker {
  opacity: 0.92;
}
.main.is-temp-chat.is-empty .starters {
  display: none !important;
}
.main.is-temp-chat .composer-inner {
  border-color: rgba(255, 255, 255, 0.14);
}
.main.is-temp-chat #prompt-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.temp-intro-modal {
  max-width: min(94vw, 28rem);
}
.temp-intro-card {
  width: min(94vw, 28rem);
  padding: 22px 22px 18px;
  border-radius: 20px;
  background: #2f2f2f;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.temp-intro-title {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}
.temp-intro-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.temp-intro-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
}
.temp-intro-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.88);
}
.temp-intro-icon .icon {
  width: 22px;
  height: 22px;
  color: inherit;
}
.temp-intro-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.temp-intro-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.55);
}
.temp-intro-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}
.temp-intro-continue {
  padding: 8px 18px;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
.temp-intro-continue:hover {
  background: #ececec;
}

html[data-theme="light"] .temp-chat-toggle.is-active {
  background: rgba(0, 0, 0, 0.06);
}
html[data-theme="light"] .main.is-temp-chat .composer-inner {
  border-color: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .main.is-temp-chat #prompt-input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}
html[data-theme="light"] .temp-intro-card {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .temp-intro-title,
html[data-theme="light"] .temp-intro-item strong {
  color: #0d0d0d;
}
html[data-theme="light"] .temp-intro-item p {
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .temp-intro-icon {
  color: #0d0d0d;
}
html[data-theme="light"] .temp-intro-continue {
  background: #0d0d0d;
  color: #fff;
}
html[data-theme="light"] .temp-intro-continue:hover {
  background: #222;
}

/* Center content+composer block vertically when no messages */
.main.is-empty { justify-content: center; }

.main.is-empty .topbar {
  position: absolute; top: 0; left: 0; right: 0;
  background: transparent;
}
.main.is-empty .content-area {
  flex: 0 0 auto;
  width: 100%;
}
.main.is-empty .welcome-panel { margin-bottom: 20px; }

.main.is-empty .composer-shell {
  flex: 0 0 auto;
  width: 100%;
  max-width: var(--thread-w);
  margin: 0 auto;
  padding: 0 1rem 1.25rem;
  background: transparent;
}

.main:not(.is-empty) .welcome-panel { display: none; }
.main:not(.is-empty) .thread { display: block !important; }
.main:not(.is-empty) .starters { display: none !important; }
.main:not(.is-empty) .composer-shell {
  flex-shrink: 0;
  padding: 0 1rem 1rem;
  background: linear-gradient(transparent, var(--bg) 30%);
}

/* ── Starter pills (ChatGPT-style) ─────────────────────── */
.starters {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: var(--thread-w);
  margin: 10px auto 0;
  padding: 0 1rem;
  cursor: grab;
  touch-action: pan-x pan-y;
}
.starters.is-drag-scroll-active {
  cursor: grabbing;
  user-select: none;
}
.main.is-empty .starters { display: flex; }

.main.is-leaving-empty .welcome-panel {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.main.is-leaving-empty .starters {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.main.is-leaving-empty .thread {
  animation: chat-thread-in 0.34s ease both;
}
@keyframes chat-thread-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.starter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 9999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.starter .icon { width: 18px; height: 18px; color: var(--icon); flex-shrink: 0; }
.starter:hover { background: var(--surface-hover); color: var(--text); }
.starter.is-active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text);
}

.main.is-image-mode-empty .starters { display: none !important; }
.main.is-image-mode-empty .welcome-panel { display: none !important; }

/* ── Image mode: Explore ideas ─────────────────────────── */
.image-ideas {
  width: 100%;
  max-width: var(--thread-w);
  margin: 18px auto 0;
  padding: 0 1rem;
}
.image-ideas[hidden] { display: none !important; }

.image-ideas-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.image-ideas-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.image-ideas-nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.image-ideas-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.image-ideas-nav-btn:hover:not(:disabled) { background: var(--surface-hover); }
.image-ideas-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.image-ideas-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  cursor: grab;
  touch-action: pan-x pan-y;
}
.image-ideas-track.is-drag-scroll-active {
  cursor: grabbing;
  scroll-behavior: auto;
  user-select: none;
}
.image-ideas-track::-webkit-scrollbar { display: none; }

.image-idea-card {
  position: relative;
  flex: 0 0 148px;
  width: 148px;
  height: 196px;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: 16px;
  background: #303030;
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.image-idea-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.image-idea-card:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.image-idea-card.is-upload {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
}
.image-idea-card.is-upload::after { display: none; }

.image-idea-upload-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -58%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: #ffffff;
}
.image-idea-upload-icon .icon { width: 28px; height: 28px; }

.image-idea-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
  transition: transform 0.35s ease;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.image-idea-card,
.starter {
  touch-action: pan-x;
}
.image-idea-card:hover .image-idea-bg {
  transform: scale(1.07);
}

.image-idea-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.42) 34%, rgba(0, 0, 0, 0.08) 58%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

.image-idea-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  margin: 0;
  padding: 14px 12px 13px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.65),
    0 4px 14px rgba(0, 0, 0, 0.55);
}
.image-idea-label::before {
  content: "";
  position: absolute;
  inset: -8px 0 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.28), transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: -1;
  pointer-events: none;
}
.image-idea-card.is-upload .image-idea-label {
  font-weight: 500;
  text-shadow: none;
}
.image-idea-card.is-upload .image-idea-label::before {
  display: none;
}

.main:not(.is-empty) .image-ideas { display: none !important; }

.main.is-leaving-empty .image-ideas {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* ── Composer ──────────────────────────────────────────── */
.composer-shell {
  flex-shrink: 0;
  padding: 0 1rem 1rem;
}

.composer {
  max-width: var(--thread-w);
  margin: 0 auto;
}

.composer-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-height: 52px;
  padding: 10px 12px 10px 16px;
  border-radius: 28px;
  background: var(--composer);
  border: 1px solid var(--border-strong);
}

.composer-controls {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
  flex-wrap: wrap;
}

.composer.has-attachments .composer-inner {
  padding-top: 8px;
}

.composer-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  max-width: min(100%, 220px);
  padding: 6px 8px 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  margin-bottom: 1px;
}
.composer-mode[hidden] {
  display: none !important;
}
.composer-mode-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.composer-mode-icon .icon { width: 16px; height: 16px; color: #93c5fd; }
.composer-mode-label {
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-mode-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(147, 197, 253, 0.85);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.composer-mode-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.composer-inner:has(.composer-mode:not([hidden])) #prompt-input {
  min-width: min(100%, 180px);
  flex: 1 1 180px;
}

.composer-controls:has(.composer-mode:not([hidden])) #prompt-input {
  min-width: min(100%, 180px);
  flex: 1 1 180px;
}

.composer.generating #prompt-input,
.composer.generating .attach-btn,
.composer.generating .composer-mode,
.composer.generating .mic-btn,
.composer.is-transcribing .attach-btn,
.composer.is-transcribing #prompt-input,
.composer.is-transcribing .send-btn {
  opacity: 0.55;
  pointer-events: none;
}
.composer.is-dictating #prompt-input {
  opacity: 0.72;
}

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
}
.attach-preview[hidden] { display: none !important; }

.attach-chip {
  position: relative;
  flex-shrink: 0;
}
.attach-chip--image {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #303030;
}
.attach-chip--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-chip--file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 168px;
  max-width: 240px;
  padding: 10px 36px 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}
.attach-chip--sent.attach-chip--file {
  cursor: pointer;
}
.attach-chip--sent.attach-chip--file:hover {
  background: rgba(255, 255, 255, 0.07);
}
.attach-chip-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
}
.attach-chip-icon .icon {
  width: 18px;
  height: 18px;
  color: #fff;
}
.attach-chip-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.attach-chip-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.attach-chip-type {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}
.attach-chip-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #111;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}
.attach-chip-remove:hover {
  background: #f3f4f6;
}
.attach-chip--file .attach-chip-remove {
  top: 8px;
  right: 8px;
}

.attach-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: transparent; color: var(--icon);
  cursor: pointer; transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
}
.attach-btn:hover { background: var(--surface-hover); color: var(--icon); }
.attach-btn .icon { width: 22px; height: 22px; color: var(--icon); }

#prompt-input {
  flex: 1; resize: none;
  border: none; background: transparent;
  color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.5;
  max-height: 200px;
  padding: 3px 0; margin-bottom: 1px;
  outline: none;
  unicode-bidi: plaintext;
}
#prompt-input[dir="rtl"] { text-align: right; }
#prompt-input[dir="ltr"] { text-align: left; }
#prompt-input::placeholder { color: var(--muted); }

/* mic: plain grey icon, always visible (like ChatGPT dictate) */
.mic-btn {
  position: relative;
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: transparent; color: var(--icon);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  margin-bottom: 1px;
  overflow: visible;
}
.mic-btn:hover { background: var(--surface-hover); color: var(--icon); }
.mic-btn .icon { width: 20px; height: 20px; color: var(--icon); position: relative; z-index: 1; }
.mic-btn .mic-spinner { display: none; width: 20px; height: 20px; color: var(--icon); animation: mic-spin 0.9s linear infinite; position: relative; z-index: 1; }
.mic-btn.is-transcribing .mic-icon { display: none; }
.mic-btn.is-transcribing .mic-spinner { display: block; color: #60a5fa; }

/* send: always visible; enabled (white) when there is content */
.send-btn {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border: none; border-radius: 50%;
  background: #fff; color: #000;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s, opacity 0.12s;
  margin-bottom: 1px;
}
.send-btn .icon { width: 18px; height: 18px; }
.send-btn .stop-icon { display: none; width: 20px; height: 20px; color: #000; }
.composer.is-generating .send-icon { display: none; }
.composer.is-generating .stop-icon { display: block; }
.composer.is-generating .send-btn {
  background: #fff;
  color: #000;
  opacity: 1;
  pointer-events: auto;
}
.composer.is-generating .send-btn:disabled {
  background: #fff;
  opacity: 1;
  cursor: pointer;
}
.send-btn:disabled {
  background: #212121;
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
  opacity: 0.85;
}
.send-btn:disabled svg { color: rgba(255, 255, 255, 0.4); }
.send-btn:not(:disabled):hover { background: #ececec; }
.send-btn:not(:disabled):active { transform: scale(0.92); }

/* Chat composer — bolder attach / mic / send icons */
.composer-controls .attach-btn .icon,
.composer-controls .mic-btn .icon,
.composer-controls .mic-btn .mic-spinner,
.composer-controls .send-btn .icon,
.composer-mode-icon .icon {
  stroke-width: 2.35;
}
.composer-controls .send-btn:not(:disabled) .icon {
  stroke-width: 2.5;
}
.composer-mode-close {
  font-weight: 700;
  font-size: 17px;
}

.footer-note {
  max-width: var(--thread-w);
  margin: 8px auto 0;
  text-align: center; font-size: 12px; color: var(--muted);
}
/* real ChatGPT doesn't show the disclaimer on the empty screen */
.main.is-empty .footer-note { display: none; }

.toast-host {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: start;
  gap: 10px;
  width: 100%;
  padding: 12px 12px 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(36, 36, 36, 0.92);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}
.toast.is-in {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.toast.is-out {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
}
.toast.is-success {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(24, 36, 30, 0.94);
}
.toast.is-error {
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(42, 24, 24, 0.94);
}
.toast-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  flex-shrink: 0;
}
.toast-icon .icon {
  width: 18px;
  height: 18px;
}
.toast.is-success .toast-icon { color: #4ade80; }
.toast.is-error .toast-icon { color: #f87171; }
.toast-text {
  min-width: 0;
  padding-top: 1px;
  color: rgba(255, 255, 255, 0.92);
  word-break: break-word;
}
.toast-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -4px -2px 0 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.toast-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.toast-close .icon {
  width: 14px;
  height: 14px;
}

html[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.08);
  color: #0d0d0d;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.8) inset;
}
html[data-theme="light"] .toast-text {
  color: rgba(0, 0, 0, 0.82);
}
html[data-theme="light"] .toast.is-success {
  background: rgba(240, 253, 244, 0.98);
  border-color: rgba(34, 197, 94, 0.28);
}
html[data-theme="light"] .toast.is-error {
  background: rgba(254, 242, 242, 0.98);
  border-color: rgba(239, 68, 68, 0.25);
}
html[data-theme="light"] .toast.is-success .toast-icon { color: #16a34a; }
html[data-theme="light"] .toast.is-error .toast-icon { color: #dc2626; }
html[data-theme="light"] .toast-close {
  color: rgba(0, 0, 0, 0.45);
}
html[data-theme="light"] .toast-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0d0d0d;
}

/* Reply context (Telegram-style quote) */
.reply-context {
  width: 100%;
  padding: 0 0 8px;
}
.reply-context[hidden] {
  display: none !important;
}
.reply-context-inner {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.reply-context-bar {
  width: 3px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #fff;
}
.reply-context-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.reply-context-label {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.reply-context-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-context-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.reply-context-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* ── Search dialog ─────────────────────────────────────── */
.search-modal { max-width: min(94vw, 34rem); }
.search-card {
  width: min(94vw, 34rem);
  padding: 0;
  overflow: hidden;
}
.search-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.search-head .icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--icon); }
#search-input {
  flex: 1;
  border: none; background: transparent;
  color: var(--text);
  font: inherit; font-size: 15px;
  outline: none;
}
#search-input::placeholder { color: var(--muted); }
.search-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
.search-result {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 14px;
  text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background 0.15s;
}
.search-result:hover { background: var(--surface-hover); }
.search-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Modals ────────────────────────────────────────────── */
.modal {
  border: none; padding: 0;
  background: transparent;
  max-width: min(96vw, 42rem);
  color: var(--text);
}
.modal::backdrop { background: rgba(0,0,0,0.75); }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 20px;
  width: min(96vw, 42rem);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 500; }
.modal-hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.modal-submit { width: auto; padding: 8px 16px; border-radius: 10px; }

.mask-stage { position: relative; margin: 0 auto 12px; width: fit-content; max-width: 100%; }
.mask-stage canvas {
  display: block; border-radius: 8px; border: 1px solid var(--border-strong);
}
#mask-draw { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.mask-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
#mask-prompt {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit; resize: vertical;
}

/* ── Edit image modal (ChatGPT-style) ──────────────────── */
.edit-image-modal {
  max-width: none;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
}
.edit-image-modal::backdrop {
  background: rgba(0, 0, 0, 0.88);
}
.edit-image-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  background: #000;
  color: #fff;
  overflow: hidden;
}
.edit-image-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: calc(52px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 8px 0;
  flex-shrink: 0;
  border-bottom: 1px solid #212121;
}
.edit-image-title {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}
.edit-image-header-spacer { width: 44px; }
.edit-image-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px;
}
.edit-image-stage-wrap {
  flex: 1;
  min-height: min(68vh, 640px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.edit-image-stage {
  position: relative;
  max-width: 100%;
  line-height: 0;
  touch-action: none;
}
.edit-image-stage.is-brush-tool { cursor: none; }
.edit-image-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid #2f2f2f;
}
#mask-highlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#mask-draw {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: none;
}
.mask-brush-cursor {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  z-index: 3;
}
.edit-image-hint {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  max-width: 28rem;
  line-height: 1.45;
}
.edit-image-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #212121;
  border: 1px solid #2f2f2f;
}
.edit-image-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.edit-tool-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s;
}
.edit-tool-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.edit-tool-btn.is-active { background: rgba(255, 255, 255, 0.14); }
.edit-tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.edit-brush-size {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 220px);
  flex: 1;
  justify-content: flex-end;
}
.edit-brush-size-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}
.edit-brush-size input[type="range"] {
  flex: 1;
  min-width: 80px;
  accent-color: #fff;
}
.edit-brush-size-value {
  font-size: 13px;
  font-weight: 600;
  min-width: 1.75rem;
  text-align: right;
  color: rgba(255, 255, 255, 0.85);
}
.edit-image-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.edit-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #2f2f2f;
  background: #212121;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s;
}
.edit-mode-option:has(input:checked) {
  background: #2f2f2f;
  border-color: rgba(255, 255, 255, 0.22);
}
.edit-mode-option input {
  accent-color: #fff;
  margin: 0;
}
.edit-image-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.edit-image-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}
.edit-image-field select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #2f2f2f;
  background: #212121;
  color: #fff;
  font: inherit;
  font-size: 13px;
}
.edit-image-footer {
  flex-shrink: 0;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #212121;
  background: #000;
}
.edit-image-prompt-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 48rem;
  margin: 0 auto;
  padding: 10px 12px 10px 16px;
  border-radius: 28px;
  background: #212121;
  border: 1px solid #2f2f2f;
}
.edit-image-prompt-wrap #mask-prompt {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  padding: 2px 0;
  border: none;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  outline: none;
}
.edit-image-prompt-wrap #mask-prompt::placeholder {
  color: rgba(255, 255, 255, 0.45);
}
.edit-image-submit {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #000;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s, transform 0.1s;
}
.edit-image-submit:not(:disabled):hover { background: #ececec; }
.edit-image-submit:not(:disabled):active { transform: scale(0.92); }
.edit-image-submit:disabled {
  background: #2f2f2f;
  color: rgba(255, 255, 255, 0.35);
  cursor: not-allowed;
}
.edit-image-submit.is-loading {
  opacity: 0.65;
  pointer-events: none;
}
.edit-image-shell.is-full-mode .edit-image-toolbar,
.edit-image-shell.is-full-mode .edit-image-stage-wrap {
  opacity: 0.45;
  pointer-events: none;
}

@media (max-width: 768px) {
  .edit-image-body { padding: 10px 12px; gap: 10px; }
  .edit-image-options {
    grid-template-columns: 1fr;
  }
  .edit-image-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .edit-brush-size {
    justify-content: stretch;
  }
  .edit-tool-btn {
    width: 44px;
    height: 44px;
  }
}

@media (min-width: 769px) {
  .edit-image-modal {
    width: min(1120px, 96vw);
    height: min(94vh, 980px);
    height: min(94dvh, 980px);
    margin: auto;
    border-radius: 16px;
    overflow: hidden;
  }
  .edit-image-shell {
    border-radius: 16px;
    border: 1px solid #2f2f2f;
  }
}

/* Settings */
.settings-modal {
  max-width: none;
  width: min(920px, 96vw);
  height: min(720px, 90vh);
  height: min(720px, 90dvh);
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
}
.settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}
.settings-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  width: 100%;
  height: 100%;
  background: #212121;
  border: 1px solid #2f2f2f;
  border-radius: 16px;
  overflow: hidden;
  color: #fff;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  background: #171717;
  border-right: 1px solid #2a2a2a;
}
.settings-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 14px;
}
.settings-nav-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.settings-nav-item {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.settings-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.settings-nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 550;
}
.settings-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #212121;
}
.settings-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 8px;
  flex-shrink: 0;
}
.settings-main-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.settings-mobile-quick {
  display: none;
}
.settings-quick-plan {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.settings-quick-plan:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}
.settings-quick-plan-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #4f46e5;
  flex-shrink: 0;
}
.settings-quick-plan-icon svg {
  width: 16px;
  height: 16px;
  color: #fff;
}
.settings-quick-plan-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.settings-quick-plan-label {
  font-size: 14px;
  font-weight: 600;
}
.settings-quick-plan-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}
.settings-quick-chevron {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.45);
}
.settings-quick-lang {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}
.settings-quick-lang-label {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.settings-panels {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 20px 24px;
  scrollbar-width: thin;
}
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-panel[hidden] { display: none !important; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-row-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.settings-row-title {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}
.settings-row-desc {
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.5);
}
.settings-select,
.settings-btn {
  flex-shrink: 0;
  font: inherit;
  font-size: 13px;
}
.settings-select {
  min-width: 148px;
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #2f2f2f;
  color: #fff;
  outline: none;
}
.settings-select:focus {
  border-color: rgba(255, 255, 255, 0.28);
}
.settings-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.settings-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.24);
}
.settings-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.settings-btn.danger {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.35);
}
.settings-btn.danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.12);
}
.settings-switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.settings-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.settings-switch-ui {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #3f3f3f;
  transition: background 0.15s;
}
.settings-switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.settings-switch input:checked + .settings-switch-ui {
  background: #19c37d;
}
.settings-switch input:checked + .settings-switch-ui::after {
  transform: translateX(18px);
}
.settings-switch input:disabled + .settings-switch-ui {
  opacity: 0.45;
}
.settings-card {
  margin-top: 6px;
  padding: 14px;
  border-radius: 14px;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}
.settings-card p,
.settings-card-sub {
  margin: 0 0 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.4;
}
.settings-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.settings-textarea-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}
.settings-textarea-field textarea {
  width: 100%;
  min-height: 96px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #2f2f2f;
  color: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}
.settings-textarea-field textarea:focus {
  border-color: rgba(255, 255, 255, 0.28);
}
.settings-chip-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.settings-chip-group:last-child { margin-bottom: 0; }
.settings-chip-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}
.settings-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.settings-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.settings-chip:hover {
  background: rgba(255, 255, 255, 0.06);
}
.settings-chip.active {
  background: #fff;
  color: #111;
  border-color: #fff;
}
.settings-hint-block {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  line-height: 1.45;
}
.settings-account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: #2a2a2a;
}
.settings-account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #19c37d;
  color: #fff;
  font-weight: 600;
}
.settings-account-name {
  font-size: 16px;
  font-weight: 600;
}
.settings-account-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}
.memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.memory-empty {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}
.memory-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #212121;
}
.memory-item-text {
  grid-column: 1;
  font-size: 13px;
  line-height: 1.4;
  color: #fff;
}
.memory-item-meta {
  grid-column: 1;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}
.memory-item-delete {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #f87171;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.memory-item-delete:hover {
  background: rgba(248, 113, 113, 0.12);
}
.archived-card {
  width: min(96vw, 28rem);
  max-height: min(80vh, 32rem);
  display: flex;
  flex-direction: column;
}
.archived-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 24rem;
}
.archived-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.archived-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.archived-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.folder-modal {
  max-width: min(94vw, 26rem);
}
.folder-card {
  width: min(94vw, 26rem);
  padding: 18px 18px 16px;
}
.folder-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}
.folder-field-label {
  font-size: 12px;
  color: var(--muted);
}
.folder-field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #2f2f2f;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  unicode-bidi: plaintext;
}
.folder-field input:focus {
  border-color: rgba(255, 255, 255, 0.3);
}
.folder-create-btn {
  background: #fff !important;
  color: #111 !important;
  border-color: #fff !important;
}
.folder-create-btn:hover:not(:disabled) {
  background: #ececec !important;
}
.folder-card .modal-foot {
  margin-top: 16px;
  gap: 10px;
}

.temp-chat-badge {
  display: none !important;
}
.temp-chat-badge[hidden] { display: none !important; }
.desktop-only { display: inline-grid; }
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
}
html[data-theme="light"] {
  --bg: #f4f4f4;
  --sidebar: #f4f4f4;
  --surface: #e8e8e8;
  --surface-hover: #e0e0e0;
  --composer: #ffffff;
  --border: #e5e5e5;
  --border-strong: #d6d6d6;
  --text: #0d0d0d;
  --text-dim: #2f2f2f;
  --muted: rgba(0, 0, 0, 0.55);
  --scrollbar: #cfcfcf;
  --icon: #0d0d0d;
}
html[data-theme="light"] body,
html[data-theme="light"] .main,
html[data-theme="light"] .sidebar,
html[data-theme="light"] .content-area,
html[data-theme="light"] .thread,
html[data-theme="light"] .composer-shell {
  background: var(--bg);
  color: var(--text);
}
html[data-theme="light"] .sidebar {
  border-right: 1px solid rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .topbar {
  background: var(--bg);
  color: var(--text);
}
html[data-theme="light"] .model-chip {
  color: var(--text);
}
html[data-theme="light"] .model-chip .icon {
  color: var(--icon);
}
html[data-theme="light"] .chat-item,
html[data-theme="light"] .chat-item-title,
html[data-theme="light"] .side-item,
html[data-theme="light"] .sidebar-label,
html[data-theme="light"] .chat-list-section,
html[data-theme="light"] .user-name,
html[data-theme="light"] .empty-title,
html[data-theme="light"] .footer-note,
html[data-theme="light"] .chat-list-tip,
html[data-theme="light"] .chat-drop-hint,
html[data-theme="light"] .chat-folder-name,
html[data-theme="light"] .chat-folder-count,
html[data-theme="light"] .temp-chat-badge,
html[data-theme="light"] #header-model {
  color: var(--text);
}
html[data-theme="light"] .chat-list-section,
html[data-theme="light"] .chat-folder-count,
html[data-theme="light"] .chat-list-tip,
html[data-theme="light"] .chat-drop-hint,
html[data-theme="light"] .footer-note,
html[data-theme="light"] .temp-chat-badge {
  color: var(--muted);
}
html[data-theme="light"] .msg.user .msg-bubble {
  background: #e5e5e5;
  color: var(--text);
}
html[data-theme="light"] .msg-text,
html[data-theme="light"] .msg-markdown,
html[data-theme="light"] .msg-markdown p,
html[data-theme="light"] .msg-markdown li {
  color: var(--text);
}
html[data-theme="light"] .msg-markdown strong,
html[data-theme="light"] .msg-markdown h2,
html[data-theme="light"] .msg-markdown h3,
html[data-theme="light"] .msg-markdown h4 {
  color: #0d0d0d;
}
html[data-theme="light"] .msg-markdown em {
  color: rgba(0, 0, 0, 0.82);
}
html[data-theme="light"] .msg-markdown del {
  color: rgba(0, 0, 0, 0.45);
}
html[data-theme="light"] .msg-action,
html[data-theme="light"] .msg-action .icon,
html[data-theme="light"] .msg-variant-btn,
html[data-theme="light"] .starter,
html[data-theme="light"] .starter .icon,
html[data-theme="light"] .attach-btn,
html[data-theme="light"] .attach-btn .icon,
html[data-theme="light"] .mic-btn,
html[data-theme="light"] .mic-btn .icon,
html[data-theme="light"] .chat-item-pin,
html[data-theme="light"] .chat-item-del,
html[data-theme="light"] .chat-folder-action,
html[data-theme="light"] .folder-chevron,
html[data-theme="light"] .folder-icon,
html[data-theme="light"] .sidebar-logo-btn,
html[data-theme="light"] .sidebar-panel-icon {
  color: var(--icon);
}
html[data-theme="light"] .composer {
  background: transparent;
}
html[data-theme="light"] .composer-inner {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
html[data-theme="light"] .composer-shell {
  background: linear-gradient(transparent, var(--bg) 28%);
}
html[data-theme="light"] .main:not(.is-empty) .composer-shell {
  background: linear-gradient(transparent, var(--bg) 30%);
}
html[data-theme="light"] #prompt-input {
  color: var(--text);
}
html[data-theme="light"] #prompt-input::placeholder {
  color: var(--muted);
}
html[data-theme="light"] .send-btn:disabled {
  background: #e5e5e5;
  color: rgba(0, 0, 0, 0.35);
}
html[data-theme="light"] .send-btn:disabled svg {
  color: rgba(0, 0, 0, 0.35);
}
html[data-theme="light"] .voice-btn {
  background: #0d0d0d;
  color: #fff;
}
html[data-theme="light"] .voice-btn .icon {
  color: #fff;
}
html[data-theme="light"] .send-btn:not(:disabled) .icon {
  color: #000;
}
html[data-theme="light"] .chat-item.is-pinned,
html[data-theme="light"] .chat-item:hover,
html[data-theme="light"] .chat-item.active,
html[data-theme="light"] .side-item:hover,
html[data-theme="light"] .chat-folder-header:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}
html[data-theme="light"] .chat-item-pin.is-active {
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .starter {
  border-color: rgba(0, 0, 0, 0.1);
  background: transparent;
}
html[data-theme="light"] .starter:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
html[data-theme="light"] .msg-code-block,
html[data-theme="light"] .msg-code {
  background: #ececec;
  color: #111;
}
html[data-theme="light"] .msg-code-header {
  color: rgba(0, 0, 0, 0.55);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .msg-sources-label,
html[data-theme="light"] .msg-status-text {
  color: var(--muted);
}
html[data-theme="light"] .msg-search-activity {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .msg-search-query {
  color: var(--muted);
}
html[data-theme="light"] .msg-search-urls-label {
  color: rgba(0, 0, 0, 0.45);
}
html[data-theme="light"] .msg-search-url-pill {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text);
}
html[data-theme="light"] .reply-context-inner {
  background: rgba(0, 0, 0, 0.05);
}
html[data-theme="light"] .reply-context-label,
html[data-theme="light"] .reply-context-text,
html[data-theme="light"] .reply-context-close {
  color: var(--text);
}
html[data-theme="light"] .reply-context-text {
  color: var(--muted);
}
html[data-theme="light"] .chat-context-menu {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .chat-context-menu.is-sheet {
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .chat-context-menu.is-sheet::before {
  background: rgba(0, 0, 0, 0.18);
}
html[data-theme="light"] .chat-context-backdrop {
  background: rgba(0, 0, 0, 0.32);
}
html[data-theme="light"] .chat-item-more {
  color: rgba(0, 0, 0, 0.45);
}
html[data-theme="light"] .chat-context-item {
  color: var(--text);
}
html[data-theme="light"] .chat-context-item:hover {
  background: rgba(0, 0, 0, 0.06);
}
html[data-theme="light"] .chat-context-item .icon {
  color: rgba(0, 0, 0, 0.65);
}
html[data-theme="light"] .chat-folder.is-drop-target,
html[data-theme="light"] .chat-folder-chats.is-drop-target,
html[data-theme="light"] .chat-uncategorized.is-drop-target {
  outline-color: rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.04);
}
html[data-theme="light"] .chat-drop-hint {
  border-color: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .temp-chat-badge {
  background: rgba(0, 0, 0, 0.06);
}
html[data-theme="light"] .composer-mode {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}
html[data-theme="light"] .msg-markdown a {
  color: #1a6fdb;
}
html[data-theme="light"] .starter.is-active {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.18);
}
html[data-theme="light"] .icon-btn,
html[data-theme="light"] .icon-btn .icon,
html[data-theme="light"] svg.icon,
html[data-theme="light"] .search-head .icon,
html[data-theme="light"] .sidebar-collapse .icon,
html[data-theme="light"] .sidebar-search .icon,
html[data-theme="light"] .msg-variant-btn,
html[data-theme="light"] .msg-variant-pager {
  color: var(--icon);
}
html[data-theme="light"] .settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}
html[data-theme="light"] .settings-shell {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0d0d0d;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14);
}
html[data-theme="light"] .settings-nav {
  background: #f7f7f8;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .settings-nav-head h2,
html[data-theme="light"] .settings-main-head h3,
html[data-theme="light"] .settings-card h4,
html[data-theme="light"] .settings-account-name,
html[data-theme="light"] .settings-row-title {
  color: #0d0d0d;
}
html[data-theme="light"] .settings-nav-item {
  color: rgba(0, 0, 0, 0.65);
}
html[data-theme="light"] .settings-nav-item:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #0d0d0d;
}
html[data-theme="light"] .settings-nav-item.active {
  background: rgba(0, 0, 0, 0.08);
  color: #0d0d0d;
}
html[data-theme="light"] .settings-main {
  background: #fff;
}
html[data-theme="light"] .settings-main-head .icon-btn,
html[data-theme="light"] .settings-nav-head .icon-btn,
html[data-theme="light"] .settings-main-head .icon,
html[data-theme="light"] .settings-nav-head .icon {
  color: #0d0d0d;
}
html[data-theme="light"] .settings-row {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .settings-row-desc,
html[data-theme="light"] .settings-card p,
html[data-theme="light"] .settings-card-sub,
html[data-theme="light"] .settings-chip-label,
html[data-theme="light"] .settings-account-meta,
html[data-theme="light"] .memory-empty,
html[data-theme="light"] .memory-item-meta {
  color: rgba(0, 0, 0, 0.5);
}
html[data-theme="light"] .settings-select {
  background: #f4f4f4;
  border-color: rgba(0, 0, 0, 0.12);
  color: #0d0d0d;
}
html[data-theme="light"] .settings-select:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background: #fff;
}
html[data-theme="light"] .settings-select option {
  background: #fff;
  color: #0d0d0d;
}
html[data-theme="light"] .settings-btn {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.14);
  color: #0d0d0d;
}
html[data-theme="light"] .settings-btn:hover:not(:disabled) {
  background: #f4f4f4;
  border-color: rgba(0, 0, 0, 0.22);
}
html[data-theme="light"] .settings-btn.danger {
  color: #c62828;
  border-color: rgba(198, 40, 40, 0.35);
}
html[data-theme="light"] .settings-btn.danger:hover:not(:disabled) {
  background: rgba(198, 40, 40, 0.08);
}
html[data-theme="light"] .settings-switch-ui {
  background: #d1d1d1;
}
html[data-theme="light"] .settings-switch input:checked + .settings-switch-ui {
  background: #19c37d;
}
html[data-theme="light"] .settings-card,
html[data-theme="light"] .settings-account-card {
  background: #f7f7f8;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .settings-textarea-field {
  color: rgba(0, 0, 0, 0.7);
}
html[data-theme="light"] .settings-textarea-field textarea {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #0d0d0d;
}
html[data-theme="light"] .settings-textarea-field textarea:focus {
  border-color: rgba(0, 0, 0, 0.28);
}
html[data-theme="light"] .settings-textarea-field textarea::placeholder {
  color: rgba(0, 0, 0, 0.4);
}
html[data-theme="light"] .settings-chip {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.75);
}
html[data-theme="light"] .settings-chip:hover {
  background: #f4f4f4;
}
html[data-theme="light"] .settings-chip.active {
  background: #0d0d0d;
  color: #fff;
  border-color: #0d0d0d;
}
html[data-theme="light"] .settings-hint-block {
  background: rgba(0, 0, 0, 0.04);
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .memory-item {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .memory-item-text {
  color: #0d0d0d;
}
html[data-theme="light"] .memory-item-delete {
  color: #c62828;
}
html[data-theme="light"] .memory-item-delete:hover {
  background: rgba(198, 40, 40, 0.08);
}
html[data-theme="light"] .archived-item {
  background: rgba(0, 0, 0, 0.04);
  color: #0d0d0d;
}
html[data-theme="light"] .modal-card,
html[data-theme="light"] .search-card,
html[data-theme="light"] .folder-card {
  background: #fff;
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .empty-title,
html[data-theme="light"] .welcome-title,
html[data-theme="light"] .user-menu,
html[data-theme="light"] .user-menu button {
  color: var(--text);
}
html[data-theme="light"] .sidebar {
  border-right-color: rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
  .settings-modal {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    margin: 0;
  }
  .settings-shell {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    border-radius: 0;
    border: none;
    height: 100%;
    min-height: 0;
  }
  .settings-mobile-quick {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
    background: #171717;
    border-bottom: 1px solid #2a2a2a;
  }
  .settings-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border-right: none;
    border-bottom: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    background: #171717;
  }
  .settings-nav-head {
    width: 100%;
    padding: 4px 4px 12px;
  }
  .settings-nav-item[data-settings-tab="billing"] {
    display: none;
  }
  .settings-nav-item {
    width: 100%;
    padding: 14px 14px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .settings-nav-item::after {
    content: "";
    width: 7px;
    height: 7px;
    border-top: 2px solid rgba(255, 255, 255, 0.35);
    border-right: 2px solid rgba(255, 255, 255, 0.35);
    transform: rotate(45deg);
    flex-shrink: 0;
    margin-left: 12px;
  }
  .settings-main {
    display: none;
    flex-direction: column;
    min-height: 0;
  }
  .settings-shell.is-detail .settings-mobile-quick,
  .settings-shell.is-detail .settings-nav {
    display: none;
  }
  .settings-shell.is-detail .settings-main {
    display: flex;
  }
  .settings-shell.is-detail {
    grid-template-rows: 1fr;
  }
  .settings-main-head {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 8px 8px;
    gap: 8px;
  }
  .settings-main-head .icon-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }
  .settings-panels {
    padding: 8px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .settings-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 16px 0;
  }
  .settings-row .settings-select,
  .settings-row .settings-btn {
    width: 100%;
    max-width: none;
    min-height: 44px;
    font-size: 16px;
  }
  .settings-row .settings-btn {
    justify-content: center;
  }
  .settings-card-head {
    align-items: flex-start;
    gap: 10px;
  }
  .settings-card-head > div:first-child {
    min-width: 0;
    flex: 1;
  }
  .settings-card-head .settings-btn {
    width: auto;
    min-height: 0;
    padding: 6px 12px;
    font-size: 13px;
    flex-shrink: 0;
    align-self: flex-start;
  }
  .settings-switch {
    align-self: flex-start;
  }
  .settings-textarea-field textarea {
    min-height: 120px;
    font-size: 16px;
  }
  .settings-chip {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 14px;
  }
  .billing-plans-grid,
  .billing-packs-grid {
    grid-template-columns: 1fr;
  }
  .billing-stats {
    grid-template-columns: 1fr;
  }
  .billing-plan-card {
    padding: 16px;
  }
  .settings-account-card {
    padding: 16px;
  }
}

/* Drag-and-drop attach */
body.is-file-drag {
  cursor: copy;
}
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.drop-overlay[hidden] { display: none !important; }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 36px;
  border-radius: 16px;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  background: rgba(33, 33, 33, 0.92);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
}
.drop-overlay-inner .icon {
  width: 36px;
  height: 36px;
  opacity: 0.9;
}

/* Admin */
.admin-modal { max-width: min(96vw, 72rem); }
.admin-card { width: min(96vw, 72rem); max-height: min(92vh, 52rem); overflow: hidden; display: flex; flex-direction: column; }
.admin-tabs { display: flex; gap: 4px; margin: -4px 0 12px; }
.admin-tab {
  border: none; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.admin-tab.active { background: rgba(255,255,255,.08); color: var(--text); }
.admin-create { display: grid; grid-template-columns: 1.2fr 1.2fr 0.9fr auto; gap: 8px; margin-bottom: 12px; }
.admin-create input, .admin-select, .admin-search, .admin-detail input, .admin-detail select {
  padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); color: var(--text); font: inherit;
}
.admin-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.admin-search { flex: 1; }
.admin-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.admin-layout { display: grid; grid-template-columns: minmax(16rem, 22rem) 1fr; gap: 14px; min-height: 0; flex: 1; }
.admin-users { display: flex; flex-direction: column; gap: 6px; max-height: min(58vh, 34rem); overflow-y: auto; padding-right: 4px; }
.admin-user-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 10px 10px; border: 1px solid var(--border-strong); border-radius: 12px;
  font-size: 13px; cursor: pointer; background: transparent; text-align: left; width: 100%; color: inherit;
}
.admin-user-row:hover { background: rgba(255,255,255,.04); }
.admin-user-row.selected { border-color: rgba(99,102,241,.55); background: rgba(99,102,241,.1); }
.admin-user-row.is-disabled { opacity: .55; }
.admin-user-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-user-name { font-weight: 650; }
.admin-user-meta { font-size: 11.5px; color: var(--muted); }
.admin-pill {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #c4b5fd; white-space: nowrap;
}
.admin-pill.unlimited { background: rgba(16,185,129,.18); color: #34d399; }
.admin-pill.free { background: rgba(99,102,241,.18); color: #a5b4fc; }
.admin-user-actions { display: flex; gap: 6px; }
.admin-detail {
  border: 1px solid var(--border-strong); border-radius: 14px; padding: 14px;
  max-height: min(58vh, 34rem); overflow-y: auto;
}
.admin-detail-empty { margin: 2.5rem 0; text-align: center; color: var(--muted); font-size: 13px; }
.admin-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.admin-detail-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.admin-stat { background: rgba(255,255,255,.04); border-radius: 10px; padding: 8px 10px; }
.admin-stat span { display: block; font-size: 10.5px; color: var(--muted); }
.admin-stat b { font-size: 13px; font-weight: 650; }
.admin-actions { display: grid; gap: 8px; margin-bottom: 14px; }
.admin-action-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-action-row label { font-size: 12px; color: var(--muted); min-width: 4.5rem; }
.admin-btn {
  border: 1px solid var(--border-strong); background: rgba(255,255,255,.06); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.admin-btn:hover { background: rgba(255,255,255,.1); }
.admin-btn.danger { color: #fca5a5; border-color: rgba(248,113,113,.35); }
.admin-btn.good { color: #6ee7b7; border-color: rgba(16,185,129,.35); }
.admin-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.admin-log { margin-top: 8px; }
.admin-log h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 650; }
.admin-log-item { font-size: 12px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.06); color: var(--muted); }
.admin-orders { max-height: min(62vh, 36rem); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.admin-order {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 12px; font-size: 13px;
}
.admin-order.pending { border-color: rgba(251,191,36,.35); }

/* Scrollbars */
.thread::-webkit-scrollbar,
.chat-list::-webkit-scrollbar,
.model-menu::-webkit-scrollbar,
.admin-users::-webkit-scrollbar { width: 5px; }
.thread::-webkit-scrollbar-track,
.chat-list::-webkit-scrollbar-track,
.model-menu::-webkit-scrollbar-track,
.admin-users::-webkit-scrollbar-track { background: transparent; }
.thread::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb,
.model-menu::-webkit-scrollbar-thumb,
.admin-users::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 9999px; }
.thread::-webkit-scrollbar-thumb:hover,
.chat-list::-webkit-scrollbar-thumb:hover { background: var(--scrollbar); }

/* Utilities */
.hidden { display: none !important; }

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --topbar-h: 56px;
    --thread-w: 100%;
  }

  .mobile-only { display: inline-grid; }

  /* Sidebar chat/folder actions work without hover on phones */
  .chat-item-pin,
  .chat-item-del {
    display: none !important;
  }
  .chat-item-more {
    display: grid !important;
    opacity: 1;
    color: rgba(255, 255, 255, 0.55);
  }
  .chat-item-title,
  .chat-item.is-pinned .chat-item-title,
  .chat-item-has-status .chat-item-title,
  .chat-item:hover .chat-item-title,
  .chat-item:focus-within .chat-item-title {
    padding-right: 34px;
  }
  .chat-item.is-pinned .chat-item-more,
  .chat-item.active .chat-item-more {
    color: rgba(255, 255, 255, 0.75);
  }
  .chat-item-has-status .chat-item-status {
    right: 30px;
  }
  .chat-folder-actions {
    opacity: 1;
  }
  .chat-folder-action:not(.chat-folder-more) {
    display: none !important;
  }
  .chat-folder-more {
    display: grid !important;
  }
  .chat-item,
  .chat-folder-header {
    -webkit-touch-callout: none;
    user-select: none;
  }

  /* Sidebar drawer */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px) !important;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: none;
    z-index: 60;
    border-right: 1px solid #212121;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.55);
  }
  .sidebar.collapsed {
    width: min(86vw, 300px) !important;
  }
  .sidebar.collapsed .sidebar-label,
  .sidebar.collapsed .chat-list-wrap,
  .sidebar.collapsed .sidebar-user-text {
    display: flex;
  }
  .sidebar.collapsed .side-item {
    justify-content: flex-start;
    width: 100%;
    height: auto;
    padding: 8px 10px;
    margin: 0;
  }
  .sidebar.collapsed .sidebar-header-actions { display: flex; }
  .sidebar.collapsed .sidebar-collapse-wrap { display: flex; }
  .sidebar.collapsed .sidebar-search-wrap { display: flex; }
  .sidebar.collapsed .sidebar-logo-btn { cursor: default; }
  .sidebar.collapsed .sidebar-logo-btn:hover { background: transparent; }
  .sidebar.collapsed .sidebar-logo-btn:hover .sidebar-logo-img { display: block; }
  .sidebar.collapsed .sidebar-logo-btn:hover .sidebar-panel-icon { display: none; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 55;
  }
  .sidebar-overlay.open {
    display: block !important;
  }

  /* Topbar */
  .topbar {
    min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    height: auto;
    padding: env(safe-area-inset-top, 0px) 6px 0;
    grid-template-columns: 48px 1fr auto;
    grid-template-rows: auto;
    align-items: center;
    gap: 4px;
  }
  .topbar-left { grid-column: 1; grid-row: 1; }
  .topbar-center {
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
  }
  .topbar-right {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
  }
  .topbar .icon-btn {
    width: 40px;
    height: 40px;
  }
  .topbar .icon-btn .icon { width: 22px; height: 22px; }
  .model-chip {
    font-size: 18px;
    font-weight: 600;
    padding: 8px 10px;
    max-width: 100%;
  }
  #header-model {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 9rem;
  }
  .model-menu {
    left: 50%;
    transform: translateX(-50%);
    min-width: min(92vw, 280px);
  }

  /* Content */
  .empty-title { font-size: 22px; padding: 0 8px; }
  .msg-inner { padding: 12px 16px 8px; }
  .msg-body { font-size: 16px; line-height: 1.6; }
  .msg.user .msg-body-user { max-width: min(88%, 22rem); }
  .msg-actions-user { opacity: 1; pointer-events: auto; }
  .msg-action { width: 36px; height: 36px; }
  .msg-sources { gap: 6px; margin-top: 10px; }
  .msg-source-pill { font-size: 11px; padding: 3px 9px; }

  /* Empty / active layout */
  .main.is-empty { justify-content: flex-end; padding-bottom: env(safe-area-inset-bottom, 0); }
  .main.is-empty .topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: transparent;
  }
  .main.is-empty .content-area {
    flex: 1;
    justify-content: center;
    padding: 0 16px;
  }
  .main.is-empty .welcome-panel { margin-bottom: 12px; }

  /* No quick-action chips on mobile */
  .starters,
  .main.is-empty .starters,
  .main.is-empty .starters.is-drag-scroll-active {
    display: none !important;
  }

  .main.is-image-mode-empty .image-ideas {
    margin-top: 12px;
    padding: 0;
  }
  .image-ideas-track {
    padding-left: 2px;
    padding-right: 2px;
  }

  .main:not(.is-empty) .composer-shell {
    padding: 0 12px calc(10px + env(safe-area-inset-bottom, 0));
    background: linear-gradient(transparent, var(--bg) 24%);
  }

  .composer-shell,
  .main.is-empty .composer-shell {
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  }

  /* ChatGPT-style tall mobile composer */
  .composer-inner {
    min-height: 0;
    padding: 12px 12px 6px;
    border-radius: 26px;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: #1f1f1f;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  }
  .composer-controls {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "input input input input"
      "attach mode mic end";
    align-items: end;
    column-gap: 6px;
    row-gap: 6px;
    width: 100%;
    flex-wrap: nowrap;
  }
  #prompt-input {
    grid-area: input;
    width: 100%;
    min-height: 24px;
    max-height: 140px;
    padding: 0 2px 2px;
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
  }
  .attach-btn {
    grid-area: attach;
    width: 34px;
    height: 34px;
    margin: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }
  .attach-btn .icon {
    color: #fff;
    width: 18px;
    height: 18px;
  }
  .composer-mode {
    grid-area: mode;
    justify-self: start;
    align-self: center;
    margin: 0;
    max-width: 100%;
  }
  .mic-btn {
    grid-area: mic;
    width: 34px;
    height: 34px;
    margin: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }
  .mic-btn .icon {
    color: #fff;
    width: 17px;
    height: 17px;
  }
  .send-btn {
    grid-area: end;
    width: 34px;
    height: 34px;
    margin: 0;
    display: grid;
    background: #0a84ff;
    color: #fff;
    opacity: 1;
  }
  .composer.can-send .send-btn,
  .composer.is-generating .send-btn {
    display: grid;
    background: #0a84ff;
    color: #fff;
    opacity: 1;
  }
  .composer.can-send .send-btn .icon,
  .composer.is-generating .send-btn .icon,
  .composer.is-generating .send-btn .stop-icon {
    color: #fff;
  }
  .composer.can-send .send-btn:not(:disabled):hover,
  .composer.is-generating .send-btn:hover {
    background: #0077ea;
  }
  .send-btn:disabled {
    display: grid;
    background: rgba(10, 132, 255, 0.35);
    opacity: 1;
  }
  .send-btn:disabled svg {
    color: rgba(255, 255, 255, 0.55);
  }

  html[data-theme="light"] .composer-inner {
    background: #ececec;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: none;
  }
  html[data-theme="light"] .attach-btn,
  html[data-theme="light"] .mic-btn {
    background: rgba(0, 0, 0, 0.06);
    color: #0d0d0d;
  }
  html[data-theme="light"] .attach-btn .icon,
  html[data-theme="light"] .mic-btn .icon {
    color: #0d0d0d;
  }
  html[data-theme="light"] .voice-btn,
  html[data-theme="light"] .composer.can-send .send-btn,
  html[data-theme="light"] .composer.is-generating .send-btn,
  html[data-theme="light"] .send-btn:disabled {
    background: #0a84ff;
    color: #fff;
  }
  html[data-theme="light"] .voice-btn .icon,
  html[data-theme="light"] .composer.can-send .send-btn .icon,
  html[data-theme="light"] .composer.is-generating .send-btn .icon,
  html[data-theme="light"] .composer.is-generating .send-btn .stop-icon,
  html[data-theme="light"] .send-btn:not(:disabled) .icon {
    color: #fff;
  }

  .footer-note { font-size: 11px; padding: 0 8px; }

  .toast-host {
    top: calc(12px + env(safe-area-inset-top, 0px));
    width: min(420px, calc(100vw - 20px));
  }
  .toast {
    border-radius: 14px;
    padding: 11px 10px 11px 12px;
    font-size: 13.5px;
  }

  .admin-create { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .admin-users, .admin-detail { max-height: 22rem; }
  .search-modal { max-width: 100vw; margin: 0 8px; }
}

@media (min-width: 769px) {
  .topbar {
    display: flex;
    align-items: center;
    padding: 0 12px;
  }
  .topbar-left { display: none; }
  .topbar-center {
    flex: 1;
    justify-content: flex-start;
  }
  .topbar-right {
    display: flex;
    margin-left: auto;
    flex-shrink: 0;
    align-items: center;
    gap: 2px;
  }
  .topbar-actions {
    display: flex;
    flex-shrink: 0;
  }
  .sidebar-overlay { display: none !important; }
}

@media (max-width: 480px) {
  .msg-inner { padding: 10px 14px 6px; }
  .composer-shell,
  .main.is-empty .composer-shell {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* ── Dictation mic state ───────────────────────────────── */
.mic-btn.is-recording {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.35);
}
.mic-btn.is-recording::before,
.mic-btn.is-recording::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(248, 113, 113, 0.45);
  pointer-events: none;
}
.mic-btn.is-recording::before {
  animation: mic-ring-pulse 1.6s ease-out infinite;
}
.mic-btn.is-recording::after {
  animation: mic-ring-pulse 1.6s ease-out 0.55s infinite;
}
.mic-btn.is-recording .icon {
  color: #f87171;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
.mic-btn.is-transcribing {
  background: rgba(59, 130, 246, 0.16);
  color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.28);
}
.mic-btn:disabled,
.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}
@keyframes mic-ring-pulse {
  0% { transform: scale(0.88); opacity: 0.75; }
  100% { transform: scale(1.45); opacity: 0; }
}
@keyframes mic-spin {
  to { transform: rotate(360deg); }
}

/* ── Legacy voice mode (removed) ───────────────────────── */

/* ── Apps modal ────────────────────────────────────────── */
.apps-modal {
  max-width: min(96vw, 40rem);
  width: 100%;
  margin: auto;
  padding: 0;
}
.apps-card {
  width: min(96vw, 40rem);
  padding: 0;
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(180deg, #1a1a1a 0%, #141414 100%);
  border: 1px solid #2a2a2a;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  color: var(--text);
}
.apps-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 8px;
}
.apps-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.apps-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: 32rem;
}
.apps-grid {
  display: grid;
  gap: 12px;
  padding: 12px 16px 20px;
}
.app-tile {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid #2f2f2f;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.app-tile:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #444;
  transform: translateY(-1px);
}
.app-tile-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, #3b82f6, #8b5cf6);
  flex-shrink: 0;
}
.app-tile-icon .icon { width: 22px; height: 22px; color: #fff; }
.app-tile-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.app-tile-title { font-size: 16px; font-weight: 600; color: var(--text); }
.app-tile-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}
.app-tile-cta {
  font-size: 13px;
  font-weight: 600;
  color: #93c5fd;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(147, 197, 253, 0.1);
}
.app-tile.is-coming-soon {
  cursor: default;
  opacity: 0.92;
}
.app-tile.is-coming-soon:hover {
  transform: none;
  background: rgba(255, 255, 255, 0.03);
  border-color: #2f2f2f;
}
.app-tile.is-coming-soon .app-tile-cta {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}

html[data-theme="light"] .apps-modal::backdrop {
  background: rgba(15, 23, 42, 0.35);
}
html[data-theme="light"] .apps-card {
  background: linear-gradient(180deg, #ffffff 0%, #f7f7f8 100%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 24px 64px rgba(15, 23, 42, 0.14);
  color: var(--text);
}
html[data-theme="light"] .apps-head h2 {
  color: #0d0d0d;
}
html[data-theme="light"] .apps-sub {
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .apps-head .icon-btn {
  color: #0d0d0d;
}
html[data-theme="light"] .apps-head .icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}
html[data-theme="light"] .apps-head .icon-btn .icon {
  color: #0d0d0d;
}
html[data-theme="light"] .app-tile {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  color: #0d0d0d;
}
html[data-theme="light"] .app-tile:hover {
  background: #fafafa;
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .app-tile-title {
  color: #0d0d0d;
}
html[data-theme="light"] .app-tile-desc {
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .app-tile-icon {
  background: linear-gradient(145deg, #2563eb, #7c3aed);
}
html[data-theme="light"] .app-tile-cta {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.1);
}

/* ── AI Influencer (chat-native) ───────────────────────── */
.main.is-influencer #starters { display: none !important; }
.main.is-influencer #image-ideas { display: none !important; }
.main.is-empty.is-influencer {
  justify-content: flex-start;
}
.main.is-empty.is-influencer .welcome-panel { display: none !important; }
.main.is-empty.is-influencer .content-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  justify-content: flex-start;
  padding: 56px 16px 8px;
}
.main.is-empty.is-influencer .composer-shell {
  max-width: none;
  width: 100%;
}
.main.is-influencer:not(.is-empty) .inf-workspace:not([hidden]) {
  flex: 0 0 auto;
  max-height: min(58vh, 560px);
  overflow-y: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.inf-workspace {
  width: 100%;
  max-width: var(--thread-w);
  margin: 0 auto;
  padding: 8px 8px 20px;
}
.inf-workspace[hidden] { display: none !important; }
.inf-guide-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.inf-guide .empty-title {
  text-align: left;
  font-size: 28px;
}
.inf-guide-lead {
  margin: 8px 0 0;
  max-width: 36rem;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.inf-steps {
  list-style: none;
  margin: 18px 0 8px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.inf-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}
.inf-step.is-done {
  opacity: 0.72;
}
.inf-step.is-current {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(59, 130, 246, 0.12);
  opacity: 1;
}
.inf-step-n {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
}
.inf-step.is-current .inf-step-n {
  background: #fff;
  color: #111;
}
.inf-step-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.inf-step-copy strong {
  font-size: 13px;
  font-weight: 600;
}
.inf-step-copy small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}
.inf-workspace-body { margin-top: 8px; }
.inf-section-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.inf-cast-wrap { margin-bottom: 14px; }

.composer.is-influencer .composer-mode { display: none !important; }
.composer-inner:has(.inf-context:not([hidden])) {
  padding-top: 8px;
}
.inf-context {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0 0 4px;
  padding: 0 2px 8px 0;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  background: transparent;
}
.inf-context[hidden] { display: none !important; }
.inf-context-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 12px;
  padding: 2px 8px 2px 2px;
}
.inf-context-main:hover { background: rgba(255, 255, 255, 0.05); }
.inf-context-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  overflow: hidden;
  background: #2a2a2a;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}
.inf-context-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.inf-context-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.inf-context-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.inf-context-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inf-context-status {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.inf-context-status.is-locked {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}
.inf-context-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.inf-context-btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.2;
}
.inf-context-btn:hover { background: rgba(255, 255, 255, 0.08); }
.inf-context-btn.danger {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  border-radius: 8px;
}

.inf-cast {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.inf-cast-btn,
.inf-cast-new {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  width: auto;
  min-width: 148px;
  max-width: 200px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.inf-cast-btn:hover,
.inf-cast-new:hover { background: rgba(255,255,255,0.05); }
.inf-cast-btn.active {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.35);
}
.inf-cast-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: #2a2a2a;
  flex-shrink: 0;
}
.inf-cast-avatar.placeholder {
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  color: #ddd;
}
.inf-cast-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inf-cast-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inf-cast-tag { font-size: 11px; color: var(--muted); }
.inf-cast-new.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}
.inf-editor {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  min-width: 0;
}
.inf-look-card { display: flex; flex-direction: column; gap: 10px; }
.inf-look-preview {
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  border: 1px solid #2f2f2f;
  position: relative;
}
.inf-lock-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.9);
  color: #04110a;
}
.inf-look-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.inf-look-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}
.inf-look-actions,
.inf-voice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.inf-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.inf-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.inf-field input,
.inf-field select,
.inf-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #333;
  background: #171717;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.inf-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.inf-btn {
  border: 1px solid #3a3a3a;
  background: #222;
  color: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.inf-btn:hover { background: #2a2a2a; }
.inf-btn.primary {
  background: #fff;
  color: #111;
  border-color: transparent;
}
.inf-btn.primary:hover { background: #ececec; }
.inf-btn.ghost { background: transparent; }
.inf-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.inf-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.inf-provider-status {
  margin: 0;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  line-height: 1.35;
}
#inf-voice-audio {
  width: min(100%, 220px);
  height: 32px;
}

html[data-theme="light"] .inf-context {
  background: transparent;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .inf-context-btn:not(.danger) {
  border-color: rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.03);
}
html[data-theme="light"] .inf-context-main:hover,
html[data-theme="light"] .inf-context-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}
html[data-theme="light"] .inf-context-avatar {
  background: #e5e5e5;
  color: #0d0d0d;
}
html[data-theme="light"] .inf-context-status {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .inf-context-status.is-locked {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}
html[data-theme="light"] .inf-step {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .inf-step.is-current {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.28);
}
html[data-theme="light"] .inf-step-n {
  background: rgba(0, 0, 0, 0.06);
  color: #0d0d0d;
}
html[data-theme="light"] .inf-step.is-current .inf-step-n {
  background: #0d0d0d;
  color: #fff;
}
html[data-theme="light"] .main.is-influencer:not(.is-empty) .inf-workspace:not([hidden]) {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .inf-cast-btn,
html[data-theme="light"] .inf-cast-new {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .inf-cast-btn:hover,
html[data-theme="light"] .inf-cast-new:hover {
  background: rgba(0, 0, 0, 0.04);
}
html[data-theme="light"] .inf-cast-btn.active {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.28);
}
html[data-theme="light"] .inf-cast-avatar,
html[data-theme="light"] .inf-look-preview {
  background: #f3f3f3;
  border-color: rgba(0, 0, 0, 0.08);
  color: #0d0d0d;
}
html[data-theme="light"] .inf-field input,
html[data-theme="light"] .inf-field select,
html[data-theme="light"] .inf-field textarea {
  background: #f7f7f8;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0d0d0d;
}
html[data-theme="light"] .inf-btn {
  background: #f3f3f3;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0d0d0d;
}
html[data-theme="light"] .inf-btn:hover { background: #e9e9e9; }
html[data-theme="light"] .inf-btn.primary {
  background: #0d0d0d;
  color: #fff;
  border-color: transparent;
}
html[data-theme="light"] .inf-btn.primary:hover { background: #2a2a2a; }
html[data-theme="light"] .inf-btn.ghost { background: transparent; }
html[data-theme="light"] .inf-provider-status {
  color: rgba(0, 0, 0, 0.45);
}

.msg-media-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  max-width: min(100%, 360px);
}
.msg-media-stack audio,
.msg-media-stack video {
  width: 100%;
  border-radius: 14px;
  background: #000;
  border: 1px solid #2a2a2a;
}
.msg-media-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.word-doc-card {
  --word-header: #1e3a5f;
  --word-accent: #2b579a;
  --word-paper: #f7f3ea;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 10px;
  max-width: min(100%, 440px);
  padding: 14px;
  border-radius: 18px;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(43, 87, 154, 0.16), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}
.word-doc-preview {
  display: flex;
  align-items: center;
  justify-content: center;
}
.word-doc-sheet {
  width: 76px;
  height: 102px;
  border-radius: 4px 10px 4px 4px;
  background: var(--word-paper);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 10px 24px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  position: relative;
}
.word-doc-sheet::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, 0.08) 50%);
  border-radius: 0 10px 0 0;
}
.word-doc-sheet-header {
  height: 18px;
  background: var(--word-header);
  position: relative;
}
.word-doc-sheet-header::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 22px;
  bottom: 5px;
  height: 2px;
  background: var(--word-accent);
}
.word-doc-sheet-lines {
  padding: 8px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.word-doc-sheet-title {
  display: block;
  font-size: 6px;
  font-weight: 700;
  color: #1a2332;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}
.word-doc-sheet-line {
  display: block;
  height: 3px;
  border-radius: 99px;
  background: rgba(26, 35, 50, 0.12);
}
.word-doc-sheet-line:nth-child(3) { width: 92%; }
.word-doc-sheet-line:nth-child(4) { width: 78%; }
.word-doc-sheet-line:nth-child(5) { width: 86%; }
.word-doc-sheet-line:nth-child(6) { width: 64%; }

.word-doc-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.word-doc-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.word-doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: 6px;
  background: #2b579a;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.word-doc-badge .icon {
  width: 12px;
  height: 12px;
}
.word-doc-ready {
  font-size: 11px;
  color: var(--muted);
}
.word-doc-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--text);
}
.word-doc-subtitle {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
.word-doc-file {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.word-doc-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.word-doc-size {
  flex-shrink: 0;
  opacity: 0.8;
}
.word-doc-download {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: #2b579a;
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
  box-shadow: 0 8px 18px rgba(43, 87, 154, 0.28);
}
.word-doc-download:hover {
  filter: brightness(1.08);
}
.word-doc-download:focus-visible {
  outline: 2px solid var(--word-accent);
  outline-offset: 2px;
}
.word-doc-creating {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--text);
}
.word-doc-card--loading .word-doc-sheet {
  animation: word-paper-float 1.6s ease-in-out infinite;
}
.word-doc-card--loading .word-doc-sheet-title {
  color: transparent;
  background: linear-gradient(90deg, rgba(26, 35, 50, 0.08), rgba(26, 35, 50, 0.2), rgba(26, 35, 50, 0.08));
  background-size: 200% 100%;
  animation: word-shimmer 1.4s linear infinite;
  border-radius: 2px;
  min-height: 7px;
}
.word-doc-card--loading .word-doc-sheet-line {
  background: linear-gradient(90deg, rgba(26, 35, 50, 0.08), rgba(26, 35, 50, 0.18), rgba(26, 35, 50, 0.08));
  background-size: 200% 100%;
  animation: word-shimmer 1.4s linear infinite;
}

@keyframes word-paper-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes word-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

html[data-theme="light"] .word-doc-card {
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(43, 87, 154, 0.08), transparent 55%),
    #fff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .word-doc-download {
  box-shadow: 0 8px 16px rgba(43, 87, 154, 0.18);
}

@media (max-width: 900px) {
  .inf-steps {
    grid-template-columns: 1fr 1fr;
  }
  .inf-editor {
    grid-template-columns: 1fr;
  }
  .inf-look-preview {
    max-width: 180px;
    margin: 0 auto;
  }
}

@media (max-width: 768px) {
  .apps-modal {
    max-width: 100vw;
    width: 100%;
    margin: 0;
    height: 100dvh;
    max-height: 100dvh;
  }
  .apps-card {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }
  .apps-head {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  .apps-grid { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .app-tile {
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto;
  }
  .app-tile-cta {
    grid-column: 2;
    justify-self: start;
  }
  .inf-guide .empty-title { font-size: 22px; }
  .inf-steps {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .inf-step { padding: 10px; }
  .main.is-empty.is-influencer .content-area {
    padding: 56px 12px 8px;
  }
  .main.is-empty.is-video-studio .content-area {
    padding: calc(var(--topbar-h) + 4px) 10px 0;
  }
  .main.is-empty.is-video-studio .composer-shell {
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  }
  .main.is-video-studio .vs-workspace.is-open:not([hidden]) {
    max-height: min(48vh, 420px);
  }
  .main.is-empty.is-video-studio .vs-workspace.is-open:not([hidden]) {
    max-height: none;
  }
  .vs-shell { gap: 12px; }
  .vs-hero-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 14px 12px;
    gap: 10px;
  }
  .vs-hero-title { font-size: 1.35rem; }
  .vs-hero-lead { font-size: .82rem; margin-top: 6px; }
  .vs-hero-pills { margin-top: 10px; gap: 6px; }
  .vs-hero-pill { font-size: .65rem; padding: 4px 8px; }
  .vs-hide-btn { align-self: flex-end; }
  .vs-model-grid { grid-template-columns: 1fr; }
  .vs-prompt-grid { grid-template-columns: 1fr; }
  .vs-fields-row { grid-template-columns: 1fr; }
  .vs-pricing-amount { font-size: 1.15rem; }
  .vs-showcase { grid-template-columns: 1fr; }
  .vs-context {
    margin-bottom: 4px;
    padding: 6px 8px;
    gap: 6px;
  }
  .vs-context-btn:not(.danger) { display: none; }
  .vs-context-label { font-size: .62rem; }
  .vs-context-meta { font-size: .75rem; margin-top: 1px; }
  .inf-context {
    margin-bottom: 2px;
    padding-bottom: 6px;
  }
  .inf-context-label {
    display: none;
  }
  .inf-context-btn:not(.danger) {
    display: none;
  }
  .inf-context-status {
    display: none;
  }
  .inf-field-row { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------------
   Billing UI — Plan tab, Credit HUD, Plan cards, Upsell modal
   ------------------------------------------------------------------- */

.billing-hud {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding-block: 3px;
  padding-inline: 4px 12px;
  margin-inline: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.billing-hud:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.3);
}
.billing-hud-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #4f46e5;
  color: #fff;
  flex-shrink: 0;
}
.billing-hud-glyph { width: 14px; height: 14px; }
.billing-hud-copy {
  display: flex;
  flex-direction: column;
  align-items: start;
  justify-content: center;
  line-height: 1.15;
  min-width: 0;
}
.billing-hud-plan {
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .01em;
  color: inherit;
}
.billing-hud-meta {
  font-size: 10px;
  font-weight: 650;
  color: rgba(255, 255, 255, 0.58);
}
.billing-hud[data-plan="spark"] .billing-hud-icon { background: #4f46e5; }
.billing-hud[data-plan="plus"] .billing-hud-icon { background: #2563eb; }
.billing-hud[data-plan="pro"] .billing-hud-icon { background: #7c3aed; }
.billing-hud[data-plan="ultra"] .billing-hud-icon { background: #d97706; }
.billing-hud[data-plan="lifetime"] .billing-hud-icon { background: #059669; }
.billing-hud[data-plan="admin"] .billing-hud-icon { background: #dc2626; }
.billing-hud[data-plan="lifetime"] {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.12);
}
.billing-hud[data-plan="lifetime"] .billing-hud-meta { color: #6ee7b7; }
.billing-hud[data-plan="spark"].is-free .billing-hud-meta { color: #a5b4fc; }

.billing-plan-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 8px;
}
.billing-plan-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.billing-plan-badge {
  padding: .22rem .7rem;
  border-radius: 2rem;
  font-size: .8rem;
  font-weight: 700;
  background: rgba(99, 102, 241, .16);
  color: #818cf8;
}
.billing-plan-tagline { font-size: .8125rem; color: var(--muted); }
.billing-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.billing-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.billing-stat-label { font-size: .7rem; color: var(--muted); }
.billing-stat-value { font-size: .95rem; font-weight: 650; color: var(--text); }
.billing-renews { display: flex; gap: .5rem; align-items: center; margin-top: 10px; color: var(--muted); }

.billing-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 4px 0 10px;
}

.billing-section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 4px 0 10px;
}

.billing-section-head-row .billing-section-title { margin: 0; }

.billing-pricing-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: #5eead4;
  text-decoration: none;
}

.billing-pricing-link:hover { text-decoration: underline; }

.billing-disclaimer {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.billing-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: 12px;
  margin: 4px 0 20px;
  padding-top: 10px;
}
.billing-plan-tile {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: start;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.billing-plan-tile:hover {
  border-color: #818cf8;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.billing-plan-tile.current {
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
  cursor: default;
}
.billing-plan-rec {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: #7c3aed;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: .02em;
}
.billing-plan-tile-name { font-weight: 750; font-size: 1.05rem; color: var(--text); }
.billing-plan-tile-credits {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}
.billing-plan-tile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.billing-plan-chip {
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.68rem;
  color: var(--muted);
}
.billing-plan-tile-estimate {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.45;
  min-height: 2.2rem;
}
.billing-plan-tile-price { font-size: .8rem; color: var(--muted); font-weight: 600; }
.billing-plan-tile-features {
  list-style: none;
  padding: 0;
  margin: 6px 0 4px;
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
}
.billing-plan-tile-features li {
  padding-inline-start: 12px;
  position: relative;
  margin-bottom: 4px;
}
.billing-plan-tile-features li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: .55em;
  width: 5px;
  height: 5px;
  border-radius: 99px;
  background: #818cf8;
}
.billing-plan-tile-btn {
  margin-top: 8px;
  padding: 8px 0;
  border: none;
  border-radius: 9px;
  background: #111;
  color: #fff;
  font: inherit;
  font-size: .8rem;
  font-weight: 650;
  cursor: pointer;
}
.billing-plan-tile-btn:hover:not(:disabled) { background: #2a2a2a; }
.billing-plan-tile-btn.is-current,
.billing-plan-tile-btn:disabled {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  cursor: default;
  opacity: 1;
}

.billing-packs-section { margin-top: 4px; }
.billing-packs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 10px;
}
.billing-pack-tile {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: .8rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: start;
  transition: border-color .15s, box-shadow .15s;
}
.billing-pack-tile:hover {
  border-color: #818cf8;
  box-shadow: 0 6px 18px rgba(0,0,0,.1);
}
.billing-pack-tile-label { font-weight: 700; color: var(--text); }
.billing-pack-tile-credits {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.billing-pack-tile-estimate {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 0.25rem;
}
.billing-pack-tile-price { color: var(--muted); font-size: .75rem; margin-top: 2px; }
.billing-pack-tile-bonus { color: #059669; font-size: .72rem; font-weight: 650; margin-top: 4px; }
.billing-pack-tile.recommended {
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
  background: rgba(99, 102, 241, 0.08);
}
.billing-pack-rec {
  position: absolute;
  top: -8px;
  inset-inline-start: 10px;
  padding: .12rem .45rem;
  border-radius: 999px;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #6366f1;
  color: #fff;
}

/* Usage coach banner (above composer) */
.usage-coach-banner {
  margin: 0 auto 8px;
  max-width: var(--thread-max, 48rem);
  width: calc(100% - 24px);
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.1);
  color: var(--text);
  animation: coach-slide-in .25s ease;
}
.usage-coach-banner.severity-high {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}
.usage-coach-inner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
}
.usage-coach-text {
  flex: 1;
  margin: 0;
  font-size: .8125rem;
  line-height: 1.45;
  color: var(--text);
}
.usage-coach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.usage-coach-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: .28rem .65rem;
  font-size: .72rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.usage-coach-btn.primary {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}
.usage-coach-btn:hover { filter: brightness(1.08); }
.usage-coach-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}
@keyframes coach-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Billing coach card (settings → billing) */
.billing-coach-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.billing-coach-included-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: .75rem;
  color: var(--muted);
}
.billing-coach-cap-pct { font-weight: 700; color: var(--text); }
.billing-coach-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 8px;
}
.billing-coach-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  transition: width .3s ease;
}
.billing-coach-progress-bar.is-high { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.billing-coach-progress-bar.is-full { background: linear-gradient(90deg, #ef4444, #f87171); }
.billing-coach-meta {
  margin: 8px 0 0;
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.4;
}
.billing-coach-recommended {
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(99, 102, 241, 0.08);
}
.billing-coach-rec-head {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #818cf8;
  margin-bottom: 6px;
}
.billing-coach-rec-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.billing-coach-rec-copy { flex: 1; min-width: 10rem; }
.billing-coach-rec-label { font-weight: 700; font-size: .9rem; }
.billing-coach-rec-reason { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.billing-coach-rec-meta { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.billing-coach-rec-btn {
  border: none;
  background: #6366f1;
  color: #fff;
  border-radius: 999px;
  padding: .45rem .85rem;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.billing-coach-tip {
  font-size: .78rem;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.upsell-pack-recommendation {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.08);
}
.upsell-pack-rec-label { font-weight: 700; font-size: .9rem; }
.upsell-pack-rec-reason { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.upsell-pack-rec-btn {
  margin-top: 10px;
  border: none;
  background: #6366f1;
  color: #fff;
  border-radius: 999px;
  padding: .45rem .9rem;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}

.billing-pending-notice {
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .35);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: .8125rem;
  color: var(--text);
  margin-top: 14px;
  line-height: 1.6;
}
.billing-pending-amount { font-weight: 700; font-size: 1rem; margin-top: .375rem; }

.upsell-modal::backdrop { background: rgba(0,0,0,.55); }
.upsell-card { max-width: 28rem !important; padding: 1.5rem !important; text-align: start; }
.upsell-reason { font-size: .875rem; color: var(--muted); margin-bottom: 1.25rem; line-height: 1.6; }
.upsell-plans { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }
.upsell-plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: .625rem;
  padding: .625rem 1rem;
  background: var(--surface);
  color: var(--text);
}
.upsell-plan-name { font-weight: 600; font-size: .9375rem; }
.upsell-plan-price { font-size: .8rem; color: var(--muted); }
.upsell-foot { display: flex; justify-content: flex-end; gap: .625rem; }
.upsell-upgrade-btn {
  padding: .55rem 1.1rem;
  border: none;
  border-radius: .5rem;
  background: #6366f1;
  color: #fff;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.upsell-upgrade-btn:hover { background: #4f46e5; }

html[data-theme="light"] .billing-hud {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #111;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] .billing-hud:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .billing-hud-plan {
  background: none;
  color: #111;
}
html[data-theme="light"] .billing-hud-meta {
  color: rgba(0, 0, 0, 0.5);
}
html[data-theme="light"] .billing-hud[data-plan="spark"] {
  background: #eef2ff;
  border-color: #c7d2fe;
}
html[data-theme="light"] .billing-hud[data-plan="spark"] .billing-hud-meta { color: #4338ca; }
html[data-theme="light"] .billing-hud[data-plan="plus"] {
  background: #eff6ff;
  border-color: #bfdbfe;
}
html[data-theme="light"] .billing-hud[data-plan="pro"] {
  background: #f5f3ff;
  border-color: #ddd6fe;
}
html[data-theme="light"] .billing-hud[data-plan="ultra"] {
  background: #fffbeb;
  border-color: #fde68a;
}
html[data-theme="light"] .billing-hud[data-plan="lifetime"] {
  background: #ecfdf5;
  border-color: #6ee7b7;
}
html[data-theme="light"] .billing-hud[data-plan="lifetime"] .billing-hud-meta { color: #047857; }
html[data-theme="light"] .billing-hud[data-plan="admin"] {
  background: #fef2f2;
  border-color: #fecaca;
}
html[data-theme="light"] .billing-plan-card {
  background: #f7f7f8;
  border-color: rgba(0,0,0,.1);
  color: #0d0d0d;
}
html[data-theme="light"] .billing-plan-tile,
html[data-theme="light"] .billing-pack-tile {
  background: #fff;
  border-color: rgba(0,0,0,.14);
  color: #0d0d0d;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
html[data-theme="light"] .billing-stat {
  background: #fff;
  border-color: rgba(0,0,0,.1);
}
html[data-theme="light"] .billing-stat-value,
html[data-theme="light"] .billing-plan-tile-name,
html[data-theme="light"] .billing-pack-tile-label {
  color: #0d0d0d;
}
html[data-theme="light"] .billing-stat-label,
html[data-theme="light"] .billing-plan-tagline,
html[data-theme="light"] .billing-section-title,
html[data-theme="light"] .billing-plan-tile-price,
html[data-theme="light"] .billing-plan-tile-features,
html[data-theme="light"] .billing-pack-tile-price {
  color: rgba(0,0,0,.55);
}
html[data-theme="light"] .billing-plan-badge {
  background: rgba(79, 70, 229, .12);
  color: #4f46e5;
}
html[data-theme="light"] .billing-plan-tile:hover,
html[data-theme="light"] .billing-pack-tile:hover {
  border-color: #6366f1;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}
html[data-theme="light"] .billing-plan-tile.current {
  border-color: #4f46e5;
  background: #eef2ff;
}
html[data-theme="light"] .billing-plan-tile-btn {
  background: #111;
  color: #fff;
}
html[data-theme="light"] .billing-plan-tile-btn.is-current,
html[data-theme="light"] .billing-plan-tile-btn:disabled {
  background: #f3f3f3;
  color: rgba(0,0,0,.5);
  border-color: rgba(0,0,0,.12);
}
html[data-theme="light"] .billing-pack-tile-bonus { color: #047857; }
html[data-theme="light"] .billing-renews { color: rgba(0,0,0,.55); }
html[data-theme="light"] .billing-pending-notice {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}
html[data-theme="light"] .settings-quick-plan {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #111;
}
html[data-theme="light"] .settings-quick-plan:hover {
  background: #f7f7f8;
  border-color: rgba(0, 0, 0, 0.18);
}
html[data-theme="light"] .settings-quick-plan-label,
html[data-theme="light"] .settings-quick-lang-label {
  color: #111;
}
html[data-theme="light"] .settings-quick-plan-meta {
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .settings-quick-lang {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .settings-mobile-quick {
  background: #f4f4f4;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .vs-hero {
  background: linear-gradient(145deg, #eef2ff 0%, #f8fafc 55%, #fff 100%);
  border-color: rgba(99, 102, 241, 0.2);
}
html[data-theme="light"] .vs-hero-lead,
html[data-theme="light"] .vs-model-card-desc,
html[data-theme="light"] .vs-model-hint {
  color: rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .vs-model-card,
html[data-theme="light"] .vs-prompt-chip,
html[data-theme="light"] .vs-settings-panel {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .vs-pricing-amount { color: #4338ca; }
html[data-theme="light"] .lang-btn { color: rgba(0,0,0,.5); }
html[data-theme="light"] .lang-btn.active { background: #111; color: #fff; }

/* ── Video Studio (chat-native layout) ─────────────────── */
.main.is-video-studio #starters { display: none !important; }
.main.is-video-studio #image-ideas { display: none !important; }
.main.is-empty.is-video-studio { justify-content: flex-start; }
.main.is-empty.is-video-studio .welcome-panel { display: none !important; }
.main.is-video-studio .content-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.main.is-empty.is-video-studio .content-area {
  padding: calc(var(--topbar-h) + 8px) 16px 0;
  justify-content: flex-start;
}
.main.is-video-studio .composer-shell {
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.main.is-empty.is-video-studio .composer-shell {
  max-width: none;
  width: 100%;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(transparent, var(--bg) 28%);
}
.main.is-video-studio:not(.is-empty) .composer-shell {
  background: linear-gradient(transparent, var(--bg) 24%);
}
.main.is-video-studio .vs-workspace.is-open:not([hidden]) {
  flex: 0 0 auto;
  max-height: min(56vh, 540px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.main.is-empty.is-video-studio .vs-workspace.is-open:not([hidden]) {
  flex: 1;
  min-height: 0;
  max-height: none;
  border-bottom: none;
}
.main.is-video-studio .thread:not([hidden]) {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Video Studio app (LaoZhang / Seedance) */
.vs-workspace {
  width: 100%;
  max-width: var(--thread-w);
  margin: 0 auto;
  padding: 0 0 16px;
  display: none;
  flex-shrink: 0;
}
.vs-workspace[hidden] { display: none !important; }
.vs-workspace.is-open:not([hidden]) { display: block; }
.vs-shell { display: flex; flex-direction: column; gap: 16px; }

.vs-hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(99, 102, 241, 0.28);
  background: linear-gradient(145deg, rgba(30, 27, 75, 0.95) 0%, rgba(15, 15, 20, 0.98) 55%, rgba(10, 10, 12, 1) 100%);
}
.vs-hero-glow {
  position: absolute;
  inset: -40% -20% auto auto;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.35) 0%, transparent 70%);
  pointer-events: none;
}
.vs-hero-inner {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 20px;
}
.vs-eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #a5b4fc;
  margin: 0 0 8px;
}
.vs-hero-title {
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
}
.vs-hero-lead {
  margin: 10px 0 0;
  font-size: .9rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.68);
  max-width: 36rem;
}
.vs-hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.vs-hero-pill {
  font-size: .72rem;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.82);
}
.vs-hide-btn { flex-shrink: 0; align-self: flex-start; }

.vs-section { display: flex; flex-direction: column; gap: 12px; }
.vs-section-title {
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
  margin: 0;
}

.vs-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  gap: 10px;
}
.vs-model-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: start;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.vs-model-card:hover { border-color: rgba(129, 140, 248, 0.45); background: rgba(99, 102, 241, 0.08); }
.vs-model-card.is-active {
  border-color: rgba(129, 140, 248, 0.75);
  background: rgba(99, 102, 241, 0.14);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.2);
}
.vs-model-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vs-model-card-title { font-size: .9rem; font-weight: 650; margin: 0; }
.vs-model-badge {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.2);
  color: #c7d2fe;
}
.vs-model-card-desc { font-size: .75rem; line-height: 1.4; color: rgba(255, 255, 255, 0.58); margin: 0; }
.vs-model-card-meta { font-size: .68rem; color: rgba(255, 255, 255, 0.42); margin-top: 2px; }

.vs-settings-panel {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}
.vs-fields-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 10px;
}
.vs-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: .72rem;
  color: var(--muted);
}
.vs-select {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  border-radius: 10px;
  padding: .5rem .6rem;
  font-size: .8125rem;
}
.vs-model-hidden { display: none !important; }

.vs-pricing-card {
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(129, 140, 248, 0.25);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(15, 15, 20, 0.6) 100%);
}
.vs-pricing-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
}
.vs-pricing-label { font-size: .75rem; color: rgba(255, 255, 255, 0.55); }
.vs-pricing-amount { font-size: 1.35rem; font-weight: 700; color: #e0e7ff; letter-spacing: -0.02em; }
.vs-model-hint { margin: 8px 0 0; font-size: .8125rem; color: rgba(255, 255, 255, 0.52); }
.vs-model-hint[hidden] { display: none; }

.vs-prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 8px;
}
.vs-prompt-chip {
  text-align: start;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.88);
  font-size: .78rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.vs-prompt-chip:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(129, 140, 248, 0.35);
}
.vs-prompt-chip-label {
  display: block;
  font-size: .65rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #a5b4fc;
  margin-bottom: 4px;
}

.vs-showcase {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 12px;
}
.vs-showcase-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
}
.vs-showcase-visual {
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
  background: #0f0f12;
}
.vs-showcase-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.vs-showcase-body { padding: 10px 11px 12px; }
.vs-showcase-title { font-size: .78rem; font-weight: 650; margin: 0 0 3px; }
.vs-showcase-desc {
  font-size: .68rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vs-roadmap-lead { font-size: .8rem; color: var(--muted); margin: 0; line-height: 1.45; }
.vs-roadmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 8px;
}
.vs-roadmap-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
}
.vs-roadmap-item strong { display: block; font-size: .78rem; margin-bottom: 3px; }
.vs-roadmap-item span { font-size: .68rem; color: var(--muted); }

.vs-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: .35rem .75rem;
  font-size: .75rem;
  cursor: pointer;
}
.vs-btn.ghost { background: transparent; }
.vs-context {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.composer.is-video-studio .vs-context.is-active {
  display: flex;
}
.vs-context-main {
  flex: 1;
  border: none;
  background: transparent;
  text-align: start;
  cursor: pointer;
  color: inherit;
  padding: 0;
}
.vs-context-label { display: block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #818cf8; }
.vs-context-meta { display: block; font-size: .8125rem; color: var(--text); margin-top: 2px; }
.vs-context-actions { display: flex; gap: 6px; }
.vs-context-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: .28rem .6rem;
  font-size: .72rem;
  cursor: pointer;
}
.vs-context-btn.danger { color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); }
.vs-context[hidden] { display: none !important; }
.composer.is-video-studio .composer-mode { display: none !important; }
.composer-inner:has(.vs-context.is-active) {
  padding-top: 6px;
}
.composer.is-video-studio { border-color: rgba(99, 102, 241, 0.35); }
.composer.is-video-studio .vs-context.is-active {
  flex-shrink: 0;
}
.vs-context-copy { min-width: 0; }
.vs-context-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  margin-inline-end: 4px;
  background: var(--surface);
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-btn.active {
  background: #fff;
  color: #000;
}

/* -- Model menu tier badges --------------------------------------- */
.model-tier-badge {
  font-size: .65rem;
  font-weight: 700;
  padding: .07rem .4rem;
  border-radius: 2rem;
  margin-right: .35rem;
  letter-spacing: .04em;
  vertical-align: middle;
}
.model-tier-included { background: rgba(52,211,153,.15); color: #34d399; }
.model-tier-credits  { background: rgba(99,102,241,.2); color: #a5b4fc; }
.model-tier-locked   { background: rgba(255,255,255,.08); color: rgba(255,255,255,.35); }
.model-item[data-tier="locked"] { opacity: .55; pointer-events: none; }
html[data-theme="light"] .model-tier-locked { background: rgba(0,0,0,.06); color: rgba(0,0,0,.4); }
