:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #202123;
  --muted: #6b6c70;
  --line: #e5e5e5;
  --hover: #f7f7f8;
  --soft: #f9f9f9;
  --accent: #202123;
  --danger: #b42318;
  --success: #137333;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

@keyframes softIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  background: #fff;
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar,
.settings-panel,
.workspace {
  min-width: 0;
  background: #fff;
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden auto;
  border-right: 1px solid var(--line);
  padding: 12px;
}

.app-shell.sidebar-collapsed .sidebar {
  padding: 0;
  border-right: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 4px 6px 12px;
}

.brand-mark,
.empty-logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
}

.sidebar-note small,
.history-item small,
.field span,
.topbar p,
.result-meta,
.history-empty {
  color: var(--muted);
}

.brand span {
  margin-top: 2px;
  font-size: 12px;
}

.brand strong {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-link:hover {
  background: var(--hover);
}

.new-chat-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  margin: 0 0 14px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-size: 14px;
}

.new-chat-button:hover {
  background: var(--hover);
}

.new-chat-icon {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}

.new-chat-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 1.5px;
  right: -3px;
  top: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-35deg);
  transform-origin: center;
}

.sidebar-section {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.sidebar-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 4px;
  font-size: 13px;
  font-weight: 600;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.text-button:hover {
  color: var(--text);
}

#clearHistory {
  display: none;
}

.history-list {
  display: grid;
  gap: 3px;
}

.history-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-radius: 8px;
}

.history-row:hover {
  background: var(--hover);
}

.history-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 54px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.history-item:hover {
  background: var(--hover);
}

.history-row:hover .history-item {
  background: transparent;
}

.history-menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
}

.history-menu-button span,
.history-menu-button span::before,
.history-menu-button span::after {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.history-menu-button span {
  position: relative;
}

.history-menu-button span::before,
.history-menu-button span::after {
  content: "";
  position: absolute;
  top: 0;
}

.history-menu-button span::before {
  left: -6px;
}

.history-menu-button span::after {
  right: -6px;
}

.history-row:hover .history-menu-button,
.history-menu-button:focus-visible {
  opacity: 1;
}

.history-menu-button:hover {
  color: #000;
  background: #fff;
}

.history-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 4px;
  z-index: 10;
  display: grid;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: softIn 140ms ease;
}

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

.history-menu-action {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}

.history-menu-action:hover {
  background: var(--hover);
}

.history-menu-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-menu-action.danger {
  color: #d92d20;
}

.history-item span,
.history-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span {
  font-size: 14px;
}

.history-item small,
.history-empty {
  font-size: 12px;
}

.history-empty {
  padding: 10px;
}

.sidebar-note {
  margin: 18px 8px 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.sidebar-note span,
.sidebar-note small {
  display: block;
}

.sidebar-note small {
  margin-top: 6px;
  line-height: 1.45;
}

.retention-note {
  margin: auto 8px 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  position: relative;
  height: 100vh;
  overflow: auto;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 10px 18px;
  border-bottom: 0;
}

.topbar-actions,
.account-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-actions {
  position: relative;
}

.account-summary {
  justify-content: flex-end;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  min-height: 36px;
  padding: 0 10px;
}

.account-summary:hover {
  background: var(--hover);
}

.account-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-summary strong {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 13px;
}

.topbar h1,
.topbar p,
.panel-head h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 18px;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 2px;
  font-size: 13px;
}

.icon-button,
.settings-button,
.file-button,
.lookup-row button,
.pill-button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.recharge-button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.recharge-button:hover {
  background: #2b2b2b;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 18px;
}

.sidebar-toggle-floating {
  visibility: hidden;
}

.app-shell.sidebar-collapsed .sidebar-toggle-floating {
  visibility: visible;
}

.icon-button:hover,
.settings-button:hover,
.file-button:hover,
.lookup-row button:hover,
.pill-button:hover {
  background: var(--hover);
}

.settings-button,
.file-button,
.lookup-row button,
.pill-button,
.primary-button {
  min-height: 36px;
  padding: 0 12px;
}

.conversation {
  min-height: calc(100vh - 52px);
  padding: 36px min(8vw, 110px) 180px;
  background: #fff;
}

.empty-state {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 100%;
  padding-bottom: 0;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0;
}

.empty-state p {
  margin: 0;
}

.message {
  display: grid;
  gap: 10px;
  max-width: 820px;
  margin: 0 auto 22px;
  animation: softIn 180ms ease;
}

.bubble {
  width: fit-content;
  max-width: min(720px, 100%);
  padding: 12px 14px;
  border-radius: 18px;
  background: #fff;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user {
  justify-items: end;
}

.message.user .bubble {
  background: var(--soft);
}

.user-bubble {
  display: grid;
  gap: 10px;
  justify-items: end;
  padding: 0;
  background: transparent !important;
}

.user-message-text {
  position: relative;
  max-width: min(720px, 100%);
  padding: 12px 50px 12px 16px;
  border-radius: 18px;
  background: var(--soft);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.user-message-content {
  white-space: pre-wrap;
}

.user-prompt-copy {
  top: 8px;
  right: 8px;
}

.user-message-text:hover .user-prompt-copy,
.user-prompt-copy:hover,
.user-prompt-copy:focus-visible {
  opacity: 1;
}

.user-attachment-grid {
  display: flex;
  max-width: min(520px, 100%);
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-attachment-button {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: zoom-in;
}

.user-attachment-grid img {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--soft);
}

.message.system .bubble {
  width: 100%;
  border-radius: 8px;
}

.generating-message {
  justify-items: start;
}

.generating-card {
  width: min(480px, 100%);
  min-height: 260px;
  padding: 24px;
  border-radius: 28px;
  background: #f7f7f8;
  color: var(--muted);
  overflow: hidden;
}

.generating-title {
  font-size: 15px;
  line-height: 1.4;
}

.generating-dots {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
  width: min(320px, 82%);
  margin: 82px auto 0;
  opacity: 0.68;
}

.generating-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #b8babd;
  animation: dotPulse 1800ms ease-in-out infinite;
  animation-delay: calc((var(--i) % 24) * 45ms);
}

@keyframes dotPulse {
  0%,
  100% {
    transform: scale(0.55);
    opacity: 0.25;
  }

  45% {
    transform: scale(1.35);
    opacity: 0.9;
  }
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #d8d8d8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

.result-grid {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.result-card {
  display: inline-flex;
  max-width: 100%;
  flex-direction: column;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  animation: softIn 180ms ease;
}

.result-card img,
.result-card video {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  background: transparent;
}

.result-card img {
  width: auto;
  border-radius: 24px;
}

.result-card video {
  width: min(100%, 760px);
  border-radius: 16px;
  background: #111;
}

.result-media-button {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  cursor: zoom-in;
}

.result-card a {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.88);
}

.image-lightbox img,
.image-editor-canvas {
  display: block;
  max-width: min(100%, 1200px);
  max-height: calc(100vh - 56px);
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
}

.image-lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 26px;
  line-height: 1;
}

.image-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.image-editor {
  width: min(100%, 1240px);
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  justify-items: center;
}

.image-editor-toolbar {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.editor-colors,
.editor-tools,
.image-editor-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.editor-color {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--color);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.editor-color.active {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.58),
    0 0 0 5px rgba(255, 255, 255, 0.18);
}

.editor-tool {
  display: grid;
  place-items: center;
  gap: 5px;
  min-width: 62px;
  border: 0;
  border-radius: 18px;
  padding: 8px 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.editor-tool.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.editor-tool svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.image-editor-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  position: relative;
  cursor: crosshair;
  touch-action: none;
}

.image-editor-stage > * {
  grid-area: 1 / 1;
}

.image-editor-preview {
  display: block;
  max-width: min(100%, 1200px);
  max-height: calc(100vh - 150px);
  object-fit: contain;
  opacity: 1;
  transition: opacity 160ms ease;
}

.image-editor-stage.ready .image-editor-preview {
  opacity: 1;
}

.image-editor-canvas {
  width: auto;
  height: auto;
  max-height: calc(100vh - 150px);
  pointer-events: auto;
  cursor: crosshair;
  touch-action: none;
}

.image-editor-canvas.context-pass-through {
  pointer-events: none;
}

.image-editor-stage.text-mode {
  cursor: text;
}

.image-editor-actions {
  display: none;
}

.editor-use {
  color: #fff;
  background: transparent;
}

.editor-use:hover,
.editor-use:focus-visible {
  background: rgba(255, 255, 255, 0.14);
}

.editor-use:active {
  transform: scale(0.97);
}

.inline-text-annotation {
  position: absolute;
  z-index: 2;
  min-width: 120px;
  max-width: min(360px, 70vw);
  min-height: 42px;
  padding: 6px 10px;
  border: 2px solid var(--annotation-color);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  font: 600 22px/1.25 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  outline: none;
  resize: both;
  transform: translateY(-2px);
}

.lightbox-open {
  overflow: hidden;
}

.result-meta {
  padding: 4px 0 10px;
  font-size: 12px;
}

.composer {
  width: min(820px, calc(100% - 28px));
  position: fixed;
  left: calc(260px + (100vw - 260px) / 2);
  bottom: 42%;
  transform: translateX(-50%);
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.07);
  transition:
    bottom 260ms ease,
    transform 260ms ease,
    width 180ms ease,
    border-radius 180ms ease,
    padding 180ms ease,
    box-shadow 180ms ease;
  z-index: 3;
}

.composer:focus-within {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

.app-shell.sidebar-collapsed .composer {
  left: 50%;
}

.has-conversation .composer {
  bottom: 22px;
  transform: translateX(-50%);
}

.composer-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transition:
    border-radius 180ms ease,
    min-height 180ms ease,
    padding 180ms ease;
}

.composer:has(#promptInput.is-expanded),
.composer:has(.attachment-thumb) {
  border-radius: 28px;
  padding: 12px 12px 10px 14px;
}

.composer:has(#promptInput.is-expanded) .composer-bar {
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "prompt prompt"
    "asset actions";
  align-items: end;
  padding: 0;
}

.composer:has(#promptInput.is-expanded) #openAssetMenu {
  grid-area: asset;
}

.composer:has(#promptInput.is-expanded) #promptInput {
  grid-area: prompt;
  padding: 3px 4px 8px;
}

.composer:has(#promptInput.is-expanded) .composer-right {
  grid-area: actions;
}

.round-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.round-button:hover,
.mode-button:hover {
  background: var(--hover);
}

#urlInput,
#promptInput,
.field input,
.field select,
.field textarea,
.menu-field input,
.lookup-row input,
#modelSelect,
#ratioSelect,
#resolutionSelect,
#countSelect {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

#urlInput {
  min-height: 36px;
  padding: 0 12px;
}

#promptInput {
  display: block;
  min-height: 34px;
  max-height: 180px;
  resize: none;
  overflow-y: hidden;
  padding: 7px 4px;
  border: 0;
  border-radius: 0;
  line-height: 1.5;
  font-size: 16px;
  transition: height 160ms ease;
}

.composer-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.mode-button {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.mode-button span:first-child {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.chevron {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-top: -2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.popover {
  position: absolute;
  bottom: calc(100% + 10px);
  display: grid;
  gap: 10px;
  width: min(240px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 8;
  animation: softIn 150ms ease;
}

.popover[hidden] {
  display: none;
}

.popover.switching {
  animation: menuIn 150ms ease;
}

.asset-menu {
  left: 0;
}

.model-menu {
  right: 0;
  width: min(320px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 130px));
  overflow: auto;
}

.account-menu {
  top: calc(100% + 8px);
  right: 0;
  bottom: auto;
  width: min(320px, calc(100vw - 32px));
  max-height: min(430px, calc(100vh - 90px));
  overflow: auto;
}

.menu-action,
.menu-field {
  display: grid;
  gap: 7px;
}

.menu-group {
  display: grid;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.menu-group:last-child {
  border-bottom: 0;
}

.menu-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.menu-action {
  min-height: 34px;
  align-items: center;
  padding: 0 9px;
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
}

.menu-action:hover {
  background: var(--hover);
}

.menu-action input {
  display: none;
}

.menu-field span {
  color: var(--muted);
  font-size: 12px;
}

#modelSelect,
#ratioSelect,
#resolutionSelect,
#countSelect {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.model-menu .menu-field,
.model-menu .menu-field span,
.model-menu .menu-field input,
.model-menu .menu-field select,
.model-menu .menu-field button {
  font-size: 13px;
  line-height: 1.2;
}

.model-menu .menu-field span {
  color: var(--muted);
  font-size: 12px;
}

.model-menu .menu-field input,
.model-menu .menu-field select {
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  min-height: 38px;
  padding: 0 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.model-menu .checkbox-field {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.model-menu .checkbox-field span {
  color: var(--text);
  font-size: 13px;
}

.model-menu .checkbox-field input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--accent);
}

#modelSelect {
  min-width: 0;
}

#ratioSelect,
#resolutionSelect,
#countSelect {
  min-width: 0;
}

#modelSelect:hover,
#ratioSelect:hover,
#resolutionSelect:hover,
#countSelect:hover,
#modelSelect:focus,
#ratioSelect:focus,
#resolutionSelect:focus,
#countSelect:focus {
  border-color: #cfcfcf;
  background: var(--hover);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

#modelSelect:focus,
#ratioSelect:focus,
#resolutionSelect:focus,
#countSelect:focus {
  transform: translateY(-1px);
}

.model-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  animation: metaFade 180ms ease;
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes metaFade {
  from {
    opacity: 0.4;
  }

  to {
    opacity: 1;
  }
}

.send-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  margin: 0 0 10px;
  padding-left: 2px;
  align-items: center;
}

.attachment-strip:empty {
  display: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  overflow: hidden;
  font-size: 12px;
}

.attachment-thumb {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  width: 142px;
  height: 142px;
  max-width: 42vw;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--soft);
}

.attachment-preview-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: zoom-in;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  object-fit: cover;
  background: var(--soft);
}

.attachment-chip span {
  position: absolute;
  inset: auto 0 0 0;
  padding: 18px 8px 7px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove-button {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  line-height: 1;
}

.attachment-remove-button:hover {
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
}

.history-prompt {
  position: relative;
  max-width: 720px;
  margin: 0 0 28px;
  padding: 13px 44px 13px 14px;
  border-radius: 14px;
  background: #f4f4f5;
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
}

.history-reference-grid {
  display: flex;
  max-width: min(520px, 100%);
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.history-reference-thumb {
  display: block;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--soft);
  overflow: hidden;
  cursor: zoom-in;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.history-reference-thumb:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
}

.history-reference-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-prompt-text {
  white-space: pre-wrap;
}

.history-prompt-copy {
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  opacity: 0;
  transition: opacity 140ms ease, color 140ms ease, background 140ms ease;
}

.history-prompt:hover .history-prompt-copy,
.history-prompt-copy:hover,
.history-prompt-copy:focus-visible {
  opacity: 1;
}

.history-prompt-copy:hover,
.history-prompt-copy.copied {
  color: #000;
  background: #ececef;
}

.history-prompt-copy svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-prompt-copy::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  z-index: 5;
  padding: 5px 8px;
  border-radius: 7px;
  background: #050505;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -2px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.history-prompt-copy:hover::after,
.history-prompt-copy:focus-visible::after,
.history-prompt-copy.copied::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.settings-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(380px, 92vw);
  overflow: auto;
  border-left: 1px solid var(--line);
  padding: 18px;
  transform: translateX(100%);
  transition: transform 180ms ease;
  z-index: 10;
  box-shadow: var(--shadow);
}

.settings-panel.open {
  transform: translateX(0);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field span {
  font-size: 13px;
}

.field input,
.field select,
.field textarea,
.menu-field input,
.lookup-row input {
  min-height: 38px;
  padding: 8px 10px;
}

.field textarea {
  min-height: 74px;
  resize: vertical;
}

.param-grid {
  display: grid;
  gap: 2px;
}

.billing-card,
.cost-preview {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.billing-card.compact,
.cost-preview.compact {
  margin: 0;
}

.model-menu .cost-preview {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.billing-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.billing-card span,
.cost-preview span,
.cost-preview small,
.price-list span,
.auth-help {
  color: var(--muted);
  font-size: 12px;
}

.billing-card strong,
.cost-preview strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.cost-preview small {
  line-height: 1.45;
}

.price-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.price-list div {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.price-list div:last-child {
  border-bottom: 0;
}

.transaction-list {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

.transaction-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.transaction-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-item strong {
  font-size: 13px;
}

.transaction-item small,
.transaction-empty {
  color: var(--muted);
  font-size: 12px;
}

.transaction-item small {
  grid-column: 1 / -1;
}

.auth-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.auth-card,
.recharge-card {
  animation: modalIn 180ms ease;
}

.recharge-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  z-index: 22;
}

.recharge-modal[hidden] {
  display: none;
}

.recharge-card {
  width: min(700px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.18);
}

.recharge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.recharge-head h2 {
  margin: 0;
  font-size: 22px;
}

.recharge-head .icon-button {
  color: var(--muted);
  background: transparent;
}

.recharge-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 28px;
  padding: 24px 28px;
}

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

.recharge-plan {
  display: grid;
  gap: 8px;
  min-height: 118px;
  align-content: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f8;
  color: var(--text);
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.recharge-plan.active {
  border-color: #111;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.recharge-plan strong {
  font-size: 28px;
}

.recharge-plan span,
.recharge-plan small,
.payment-panel small,
.recharge-tips {
  color: var(--muted);
}

.payment-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #f7f7f8;
}

.agreement-panel,
.qr-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: 100%;
}

.agreement-panel[hidden],
.qr-panel[hidden] {
  display: none !important;
}

.agreement-link {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.agreement-box {
  width: 100%;
  max-height: 176px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #555;
  font-size: 12px;
  line-height: 1.55;
}

.agreement-box[hidden] {
  display: none;
}

.agreement-box p {
  margin: 0 0 8px;
}

.agreement-box p:last-child {
  margin-bottom: 0;
}

.agreement-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #555;
  font-size: 12px;
  line-height: 1.45;
}

.agreement-check input {
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  accent-color: #18b86b;
}

.qr-box {
  display: grid;
  place-items: center;
  width: 176px;
  height: 176px;
  border-radius: 4px;
  background: #fff;
  color: #555;
  text-align: center;
  font-size: 13px;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.pay-methods {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #555;
  font-size: 12px;
}

.pay-methods button {
  padding: 7px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.pay-methods button.active {
  background: #18b86b;
  color: #fff;
}

.payment-status {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  background: #f2f4f7;
  color: #555;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.payment-status[hidden] {
  display: none;
}

.payment-status.error {
  background: #fff1f0;
  color: #d92d20;
}

.payment-status.success {
  background: #ecfdf3;
  color: #07803d;
}

.recharge-tips {
  display: grid;
  gap: 6px;
  padding: 14px 28px 22px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
}

.recharge-tips strong {
  color: var(--text);
}

@media (max-width: 720px) {
  .recharge-body {
    grid-template-columns: 1fr;
  }

  .recharge-plans {
    grid-template-columns: 1fr;
  }

  .payment-panel {
    border-radius: 12px;
  }
}

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

.auth-card {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.auth-tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.auth-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.auth-help {
  min-height: 34px;
  margin: 4px 0 12px;
  line-height: 1.45;
}

.auth-resend,
.auth-forgot {
  justify-self: start;
  margin: -8px 0 12px;
  padding: 0;
}

.primary-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

.raw-box {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.raw-box summary {
  cursor: pointer;
  color: var(--muted);
}

pre {
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  white-space: pre-wrap;
}

.lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}

.notice {
  border-left: 3px solid var(--success);
}

.error {
  border-left: 3px solid var(--danger);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }

}

@media (max-width: 760px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(286px, 88vw);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    z-index: 5;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    padding: 10px 12px;
  }

  .conversation {
    padding: 24px 14px;
  }

  .composer {
    width: calc(100% - 24px);
    left: 50%;
    bottom: 40%;
    border-radius: 22px;
  }

  .has-conversation .composer {
    bottom: 14px;
  }

  .composer-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    border-radius: 24px;
  }

  .mode-button span:first-child {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
