/*
 * gpt-theme.css — ChatGPT 风格的界面层（2026-11-05）
 * 叠加在 styles.css 之后加载，只改外观和布局，不改任何交互逻辑。
 * 回滚：删掉 index.html 里这一行 <link> 即可恢复旧界面。
 */

:root {
  --gpt-bg: #ffffff;
  --gpt-sidebar: #f9f9f9;
  --gpt-hover: #ececec;
  --gpt-active: #e3e3e3;
  --gpt-ink: #0d0d0d;
  --gpt-muted: #5d5d5d;
  --gpt-faint: #666666;
  --gpt-line: #e5e5e5;
  --gpt-bubble: #f4f4f4;
  --gpt-chip: #f4f4f4;
  --gpt-blue: #0169cc;
  --gpt-blue-soft: #e5f1ff;
  --gpt-surface: #ffffff;
  --gpt-on-ink: #ffffff;
  --gpt-ink-hover: #2f2f2f;
  --gpt-disabled: #d7d7d7;
  --gpt-on-disabled: #ffffff;
  --gpt-overlay: rgba(255, 255, 255, 0.88);
  --gpt-press: rgba(0, 0, 0, 0.06);
  --gpt-input-border: #d9d9d9;
  --gpt-error-bg: #fdecea;
  --gpt-shimmer: rgba(255, 255, 255, 0.55);
  --gpt-sidebar-width: 260px;
  --gpt-chat-column: 768px;
  --gpt-image-column: 880px;
  --gpt-radius-composer: 28px;
  --gpt-shadow-composer: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 4px 18px rgba(0, 0, 0, 0.06);
  --gpt-shadow-menu: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 12px 32px rgba(0, 0, 0, 0.12);
  --chat-column: var(--gpt-chat-column);
  --image-column: var(--gpt-image-column);
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", Helvetica, Arial, sans-serif;
}

html.is-theme-switching *,
html.is-theme-switching *::before,
html.is-theme-switching *::after {
  transition: none !important;
}

html[data-pre-session-type="chat"] body:not([data-session-type]) #settingsRow,
html[data-pre-session-type="chat"] body:not([data-session-type]) .model-control {
  display: none !important;
}

html body {
  background: var(--gpt-bg);
  color: var(--gpt-ink);
  -webkit-font-smoothing: antialiased;
}

html body[data-session-type="chat"] {
  --composer: var(--gpt-chat-column);
}

html body[data-session-type="image"] {
  --composer: var(--gpt-image-column);
}

/* ---------- 侧边栏 ---------- */

html body .rail {
  background: var(--gpt-sidebar);
  border-right: 0;
  gap: 8px;
  padding: 10px 8px;
}

html body .rail-btn,
html body .rail-account,
html body .rail-api-key {
  border-radius: 10px;
  color: var(--gpt-muted);
}

html body .rail-btn:hover,
html body .rail-account:hover,
html body .rail-api-key:hover {
  background: var(--gpt-hover);
  color: var(--gpt-ink);
}

html body .history-panel {
  gap: 2px;
  padding: 8px 8px 10px;
  border-right: 0;
  background: var(--gpt-sidebar);
  font-size: 14px;
}

html body .history-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 4px 0 8px;
  margin-bottom: 6px;
}

html body .sidebar-logo {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  flex: 0 0 auto;
}

html body .sidebar-logo img {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: block;
}

html body .history-head strong {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

html body .history-head .icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-muted);
}

html body .history-head .icon-btn:hover {
  background: var(--gpt-hover);
  color: var(--gpt-ink);
}

html body .new-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

html body .new-chat-wide,
html body .sidebar-api-docs-btn {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-ink);
  font-size: 14px;
  font-weight: 400;
  box-shadow: none;
}

html body .new-chat-wide:hover,
html body .sidebar-api-docs-btn:hover {
  background: var(--gpt-hover);
}

html body .new-chat-wide svg,
html body .sidebar-api-docs-btn svg,
html body .new-chat-wide i,
html body .sidebar-api-docs-btn i {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  color: var(--gpt-ink);
}

html body .sidebar-api-key-btn.is-active {
  color: var(--gpt-blue);
}

html body .sidebar-api-key-btn.is-active svg {
  color: var(--gpt-blue);
}

html body .history-tools {
  gap: 4px;
  margin-top: 2px;
}

html body .history-search {
  min-height: 36px;
  padding: 0 10px;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

html body .history-search:hover {
  background: var(--gpt-hover);
}

html body .history-search:focus-within {
  background: var(--gpt-surface);
  box-shadow: 0 0 0 1px var(--gpt-line);
}

html body .history-search input {
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 14px;
}

html body .history-search svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

html body .history-filters {
  gap: 4px;
  padding: 4px 6px 0;
}

html body .history-filter {
  min-height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--gpt-muted);
  font-size: 12px;
  font-weight: 500;
}

html body .history-filter:hover {
  background: var(--gpt-hover);
}

html body .history-filter.is-active {
  background: var(--gpt-active);
  color: var(--gpt-ink);
}

html body .history-pack-actions {
  gap: 4px;
  padding: 0 6px;
}

html body .history-mini-btn {
  min-height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gpt-faint);
  font-size: 12px;
  font-weight: 500;
}

html body .history-mini-btn:hover {
  background: var(--gpt-hover);
  color: var(--gpt-ink);
}

html body .history-mini-btn svg {
  width: 14px;
  height: 14px;
}

html body .conversation-list {
  gap: 0;
  padding: 0;
  margin-top: 6px;
}

html body .conversation-group-label {
  padding: 14px 10px 6px;
  color: var(--gpt-faint);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
}

html body .conversation-group-label:first-child {
  padding-top: 6px;
}

html body .conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

html body .conversation-item:hover {
  background: var(--gpt-hover);
}

html body .conversation-item.is-active {
  background: var(--gpt-active);
}

html body .conversation-open {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: transparent;
  text-align: left;
}

html body .conversation-open span {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--gpt-ink);
  font-size: 14px;
  font-weight: 400;
}

html body .conversation-open span svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  color: var(--gpt-faint);
}

html body .conversation-open small {
  display: none;
}

html body .conversation-actions {
  position: absolute;
  top: 50%;
  right: 4px;
  display: flex;
  gap: 0;
  padding-left: 18px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, var(--gpt-hover) 16px);
  border-radius: 0 10px 10px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

html body .conversation-item.is-active .conversation-actions {
  background: linear-gradient(90deg, transparent, var(--gpt-active) 16px);
}

html body .conversation-item:hover .conversation-actions,
html body .conversation-item:focus-within .conversation-actions {
  opacity: 1;
  pointer-events: auto;
}

html body .conversation-mini,
html body .conversation-delete {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gpt-muted);
}

html body .conversation-mini:hover,
html body .conversation-delete:hover {
  background: var(--gpt-press);
  color: var(--gpt-ink);
}

html body .conversation-delete:hover {
  color: #d03a2f;
}

html body .conversation-mini svg,
html body .conversation-delete svg {
  width: 15px;
  height: 15px;
}

html body .conversation-empty {
  padding: 14px 10px;
  color: var(--gpt-faint);
  font-size: 13px;
}

html body .history-foot {
  gap: 2px;
  padding-top: 8px;
  border-top: 0;
}

html body .balance-card,
html body .user-row {
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
}

html body .balance-card:hover,
html body .user-row:hover {
  background: var(--gpt-hover);
}

html body .balance-card small,
html body .user-row small {
  color: var(--gpt-faint);
  font-size: 12px;
  font-weight: 400;
}

html body .balance-card strong,
html body .user-row strong {
  color: var(--gpt-ink);
  font-size: 14px;
  font-weight: 500;
}

html body .avatar-small {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

html body .history-backdrop.is-open {
  background: rgba(0, 0, 0, 0.28);
}

/* 桌面端：侧边栏展开时就是 ChatGPT 的 260px 侧栏，收起时退化成窄图标栏 */
@media (min-width: 861px) {
  html body .app-shell.history-pinned {
    --rail: 0px;
    --history-width: var(--gpt-sidebar-width);
    grid-template-columns: var(--gpt-sidebar-width) minmax(0, 1fr);
  }

  html body .app-shell.history-pinned > .rail {
    display: none;
  }

  html body .app-shell.history-pinned .history-panel,
  html body .app-shell.history-pinned #sidebar.history-panel {
    grid-column: 1;
    border-right: 0;
    background: var(--gpt-sidebar);
  }

  html body .app-shell.history-pinned .workspace {
    grid-column: 2;
  }

  html body .app-shell:not(.history-pinned) .history-panel {
    width: var(--gpt-sidebar-width);
  }
}

/* ---------- 顶栏（登录后也显示，和 ChatGPT 一样左上角是模型切换） ---------- */

html body .workspace {
  grid-template-rows: 56px minmax(0, 1fr) auto;
  background: var(--gpt-bg);
}

html body .app-shell:not(.is-guest) .workspace {
  grid-template-rows: 56px minmax(0, 1fr) auto;
}

html body .app-shell:not(.is-guest) .workspace > .topbar,
html body .workspace > .topbar {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 0 12px 0 14px;
  border-bottom: 0;
  background: var(--gpt-bg);
  position: relative;
  z-index: calc(var(--z-dropdown) + 5);
}

html body .brand-switch {
  display: flex;
  align-items: center;
  gap: 4px;
}

html body .brand-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--gpt-ink);
  font-size: 18px;
  font-weight: 500;
}

html body .brand-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body .topbar .chat-model-picker {
  position: relative;
  display: none;
}

html body[data-session-type="chat"] .app-shell:not(.is-guest) .topbar .chat-model-picker {
  display: block;
}

html body[data-session-type="chat"] .app-shell:not(.is-guest) .topbar .brand-name {
  display: none;
}

html body .topbar .chat-model-btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-ink);
  font-size: 18px;
  font-weight: 500;
  box-shadow: none;
}

html body .topbar .chat-model-btn:hover,
html body .topbar .chat-model-btn[aria-expanded="true"] {
  background: var(--gpt-bubble);
}

html body .topbar .chat-model-btn svg {
  width: 16px;
  height: 16px;
  color: var(--gpt-faint);
}

html body .topbar .chat-model-menu {
  position: absolute;
  top: calc(100% + 6px);
  bottom: auto;
  right: auto;
  left: 0;
  min-width: 300px;
  max-height: min(460px, 70vh);
  padding: 6px;
  border: 0;
  border-radius: 16px;
  box-shadow: var(--gpt-shadow-menu);
}

html body .top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

html body .top-actions .plain-btn,
html body .top-actions .outline-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
}

html body .top-actions .outline-btn {
  border: 1px solid var(--gpt-line);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
}

html body .top-actions .outline-btn:hover {
  background: var(--gpt-bubble);
}

html body #guestActions .plain-btn {
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
}

html body #guestActions .plain-btn:hover {
  background: var(--gpt-ink-hover);
}

html body #userActions .plain-btn {
  background: transparent;
  color: var(--gpt-muted);
}

html body #userActions .plain-btn:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body .api-docs-top-btn {
  border: 0 !important;
  background: transparent !important;
  color: var(--gpt-muted) !important;
}

html body .api-docs-top-btn:hover {
  background: var(--gpt-bubble) !important;
  color: var(--gpt-ink) !important;
}

html body .api-docs-top-btn svg {
  width: 16px;
  height: 16px;
}

html body .topbar .balance-pill {
  position: static;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font-size: 13px;
  font-weight: 500;
  box-shadow: none;
}

html body .topbar .balance-pill:hover {
  background: var(--gpt-hover);
}

html body .topbar .balance-pill[hidden] {
  display: none;
}

/* 悬浮的 API 文档按钮会挡住顶栏，入口已在顶栏和侧栏 */
html body .developer-docs-btn {
  display: none !important;
}

@media (min-width: 861px) {
  html body .app-shell.history-pinned #logoutTopBtn {
    display: none;
  }
}

/* ---------- 消息区 ---------- */

html body .messages,
html body[data-session-type="chat"] .messages,
html body[data-session-type="image"] .messages,
html body[data-session-type="chat"] .app-shell.history-pinned .messages,
html body[data-session-type="image"] .app-shell.history-pinned .messages {
  padding: 20px max(20px, calc((100% - var(--composer)) / 2)) 32px;
}

html body .message {
  margin-bottom: 24px;
}

html body .assistant-mark,
html body[data-session-type="chat"] .chat-message.chat-assistant .assistant-mark {
  display: none;
}

html body .message.assistant,
html body[data-session-type="chat"] .chat-message.chat-assistant {
  display: block;
}

html body .message.user .message-body,
html body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
  max-width: min(70%, 560px);
  padding: 10px 18px;
  border: 0;
  border-radius: 22px;
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
  box-shadow: none;
}

html body .message.user .message-body p,
html body[data-session-type="chat"] .chat-message.chat-user .chat-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
}

html body[data-session-type="chat"] .chat-message.chat-assistant .chat-bubble {
  width: 100%;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

html body .chat-markdown {
  color: var(--gpt-ink);
  font-size: 16px;
  line-height: 1.75;
}

html body .chat-markdown p {
  margin: 0 0 14px;
}

html body .chat-markdown p:last-child {
  margin-bottom: 0;
}

html body .chat-markdown h1,
html body .chat-markdown h2,
html body .chat-markdown h3,
html body .chat-markdown h4 {
  margin: 22px 0 10px;
  font-weight: 600;
  line-height: 1.4;
}

html body .chat-markdown h1 { font-size: 24px; }
html body .chat-markdown h2 { font-size: 20px; }
html body .chat-markdown h3 { font-size: 18px; }

html body .chat-markdown ul,
html body .chat-markdown ol {
  margin: 4px 0 14px;
  padding-left: 1.5em;
}

html body .chat-markdown li {
  margin: 4px 0;
}

html body .chat-markdown strong {
  font-weight: 600;
}

html body .chat-markdown :not(pre) > code {
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: var(--gpt-hover);
  color: var(--gpt-ink);
  font-size: 0.875em;
}

html body .chat-markdown blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--gpt-line);
  color: var(--gpt-muted);
}

html body .chat-markdown table {
  border-collapse: collapse;
  margin: 6px 0 16px;
  font-size: 14px;
}

html body .chat-markdown th,
html body .chat-markdown td {
  padding: 8px 14px;
  border: 0;
  border-bottom: 1px solid var(--gpt-line);
  text-align: left;
}

html body .chat-markdown th {
  font-weight: 600;
}

html body .chat-markdown hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid var(--gpt-line);
}

html body .code-block {
  margin: 8px 0 16px;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #171717;
}

html body .code-block .token.inserted {
  color: #7ec699;
}

html body .code-block-head {
  min-height: 38px;
  padding: 0 14px;
  background: #2f2f2f;
  color: #cdcdcd;
  font-size: 12px;
  font-weight: 500;
}

html body .code-block-head button {
  border-radius: 8px;
  color: #cdcdcd;
  font-size: 12px;
}

html body .code-block pre {
  margin: 0;
  padding: 16px;
  background: transparent;
  font-size: 13.5px;
  line-height: 1.6;
}

html body .chat-message-actions,
html body .image-user-actions {
  gap: 2px;
  margin-top: 6px;
}

html body .chat-action-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gpt-muted);
  box-shadow: none;
}

html body .chat-action-btn:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body .chat-action-btn svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

html body .scroll-bottom-btn {
  border: 1px solid var(--gpt-line);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

/* ---------- 生图结果 ---------- */

html body .message-meta {
  gap: 8px;
  margin-bottom: 6px;
  color: var(--gpt-faint);
  font-size: 13px;
}

html body .message-meta strong {
  color: var(--gpt-ink);
  font-size: 14px;
  font-weight: 600;
}

html body .image-assistant-message .message-body > p {
  margin: 6px 0 0;
  color: var(--gpt-ink);
  font-size: 16px;
  line-height: 1.7;
}

html body .generation-settings {
  gap: 6px;
  margin: 2px 0 6px;
}

html body .generation-settings span:not(.generation-status-dot) {
  min-height: 24px;
  padding: 0 9px;
  border: 0;
  background: var(--gpt-chip);
  color: var(--gpt-muted);
  font-size: 12px;
  font-weight: 500;
}

html body .image-grid {
  gap: 10px;
  margin-top: 12px;
}

html body .image-card {
  border: 0;
  border-radius: 18px;
  background: var(--gpt-chip);
  box-shadow: none;
  overflow: hidden;
}

html body .image-card img,
html body .image-skeleton,
html body .image-missing {
  border-radius: 18px;
}

html body .image-card img {
  background: var(--gpt-chip);
  cursor: zoom-in;
}

html body .image-skeleton {
  background: var(--gpt-chip);
}

/* 操作按钮回到图片右上角悬浮，跟 ChatGPT 生图一致 */
html body .image-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  left: auto;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px;
  border: 0;
  border-radius: 12px;
  background: var(--gpt-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

html body .image-card:hover .image-actions,
html body .image-card:focus-within .image-actions {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: none) {
  html body .image-actions {
    opacity: 1;
    transform: none;
  }
}

html body .image-actions .icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--gpt-ink);
  box-shadow: none;
}

html body .image-actions .icon-btn:hover {
  background: var(--gpt-press);
}

@media (max-width: 860px) {
  html body .image-actions .icon-btn { min-width: 44px; min-height: 44px; }
  html body .image-actions { gap: 8px; flex-wrap: wrap; }
  html body #loginForm input, html body #historySearch, html body #imageLibrarySearch { font-size: 16px; }
}
html body #micBtn[hidden], html body #loginForm [hidden] { display: none; }

html body .image-caption {
  padding: 8px 12px;
  border-top: 0;
  background: transparent;
  color: var(--gpt-faint);
  font-size: 12px;
}

html body .image-card-missing .image-caption,
html body .image-card .image-skeleton + .image-caption {
  background: transparent;
}

html body .image-result-actions {
  gap: 6px;
  margin-top: 10px;
}

html body .image-result-action {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font-size: 13px;
  font-weight: 500;
}

html body .image-result-action:hover {
  background: var(--gpt-hover);
}

/* ---------- 输入框（ChatGPT 式：上面输入，下面一排工具 + 发送） ---------- */

html body .composer-dock {
  gap: 6px;
  padding: 0 16px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--gpt-bg) 22px);
}

html body .composer,
html body.has-attachments .composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "attach attach attach attach"
    "text text text text"
    "settings settings settings settings"
    "plus tools mic send";
  align-items: center;
  column-gap: 4px;
  row-gap: 4px;
  padding: 10px 10px 10px;
  border: 0;
  border-radius: var(--gpt-radius-composer);
  background: var(--gpt-surface);
  box-shadow: var(--gpt-shadow-composer);
}

html body .composer:focus-within {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 6px 22px rgba(0, 0, 0, 0.08);
}

html body .composer > .attachment-row {
  grid-area: attach;
  padding: 0 4px 4px;
}

html body .composer > .prompt-row {
  display: contents;
}

html body .composer-feature-picker {
  grid-area: plus;
  align-self: end;
}

html body .prompt-row textarea {
  grid-area: text;
  width: 100%;
  min-height: 44px;
  max-height: 40vh;
  padding: 8px 10px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--gpt-ink);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
}

html body .prompt-row textarea::placeholder {
  color: var(--gpt-faint);
}

html body .prompt-row textarea:focus {
  border: 0;
  box-shadow: none;
}

html body .composer #micBtn {
  grid-area: mic;
  align-self: end;
}

html body .composer #sendBtn {
  grid-area: send;
  align-self: end;
}

html body .composer > .chat-toolbar {
  grid-area: tools;
  width: auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 0;
  overflow: visible;
}

html body .composer > .chat-toolbar[hidden] {
  display: none;
}

html body .composer > .settings-row {
  grid-area: settings;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 4px;
}

/* 纯生图对话：默认把精简参数放在 + 号右边，开启自定义像素尺寸时占满独立参数行 */
html body .composer:has(> .chat-toolbar[hidden]) > .settings-row {
  grid-area: tools;
  min-width: 0;
  max-width: 100%;
  padding: 0;
}

html body .composer:has(> .chat-toolbar[hidden]):has(> .settings-row > #customSizeControl:not([hidden])) {
  grid-template-areas:
    "attach attach attach attach"
    "text text text text"
    "settings settings settings settings"
    "plus tools mic send";
}

html body .composer:has(> .chat-toolbar[hidden]):has(> .settings-row > #customSizeControl:not([hidden])) > .settings-row {
  grid-area: settings;
  width: 100%;
  padding: 2px 4px 4px;
}

html body .composer:has(> .chat-toolbar[hidden]) {
  grid-template-areas:
    "attach attach attach attach"
    "text text text text"
    "plus tools mic send";
}

html body .composer:has(> .image-notify-prompt:not([hidden])) {
  grid-template-areas:
    "notify notify notify notify"
    "attach attach attach attach"
    "text text text text"
    "settings settings settings settings"
    "plus tools mic send";
}

html body .composer:has(> .chat-toolbar[hidden]):has(> .image-notify-prompt:not([hidden])) {
  grid-template-areas:
    "notify notify notify notify"
    "attach attach attach attach"
    "text text text text"
    "plus tools mic send";
}

html body .composer:has(> .chat-toolbar[hidden]):has(> .settings-row > #customSizeControl:not([hidden])):has(> .image-notify-prompt:not([hidden])) {
  grid-template-areas:
    "notify notify notify notify"
    "attach attach attach attach"
    "text text text text"
    "settings settings settings settings"
    "plus tools mic send";
}

html body .composer .icon-btn,
html body .composer #attachBtn,
html body .composer #micBtn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--gpt-ink);
  box-shadow: none;
}

html body .composer #attachBtn {
  border: 1px solid var(--gpt-line);
}

html body .composer #micBtn[hidden] {
  display: none !important;
}

html body .composer .icon-btn:hover,
html body .composer #attachBtn:hover,
html body .composer #micBtn:hover {
  background: var(--gpt-bubble);
}

html body .composer .icon-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}

html body .send-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
  box-shadow: none;
}

html body .send-btn:hover:not(:disabled) {
  background: var(--gpt-ink-hover);
  box-shadow: none;
  transform: none;
}

html body .send-btn:disabled {
  background: var(--gpt-disabled);
  color: var(--gpt-on-disabled);
  opacity: 1;
}

html body .send-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

/* 工具按钮：幽灵按钮，图标为主 */
html body .composer .chat-tool-toggle,
html body .composer .chat-mode-btn,
html body .composer .chat-reasoning-btn,
html body .composer .tool-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--gpt-muted);
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
}

html body .composer .chat-tool-toggle {
  width: 36px;
  padding: 0;
  justify-content: center;
}

html body .composer .chat-tool-toggle > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

html body .composer .chat-tool-toggle:hover,
html body .composer .chat-mode-btn:hover,
html body .composer .chat-reasoning-btn:hover,
html body .composer .tool-pill:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body .composer .chat-tool-toggle.is-active,
html body .composer .chat-mode-btn.is-active,
html body .composer .chat-reasoning-btn.is-active {
  background: var(--gpt-blue-soft);
  color: var(--gpt-blue);
}

html body .composer .chat-tool-toggle svg,
html body .composer .chat-mode-btn svg,
html body .composer .chat-reasoning-btn svg,
html body .composer .tool-pill svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

html body .composer .chat-mode-btn svg:last-child,
html body .composer .chat-reasoning-btn svg:last-child {
  width: 14px;
  height: 14px;
}

html body .composer .chat-mode-picker,
html body .composer .chat-reasoning-picker {
  position: relative;
}

html body .composer .chat-mode-menu,
html body .composer .chat-reasoning-menu,
html body .composer-feature-menu,
html body .model-menu,
html body .choice-menu {
  border: 0;
  border-radius: 16px;
  box-shadow: var(--gpt-shadow-menu);
  z-index: calc(var(--z-dropdown) + 40);
}

/* 生图参数：灰色小胶囊 */
html body .composer .setting-control {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 2px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--gpt-chip);
}

html body .composer .setting-control:hover {
  background: var(--gpt-hover);
}

html body .composer .setting-control > span {
  color: var(--gpt-faint);
  font-size: 13px;
  font-weight: 400;
}

html body .composer .model-menu-btn,
html body .composer .choice-btn {
  width: auto;
  max-width: 220px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--gpt-ink);
  box-shadow: none;
}

html body .composer .model-menu-btn strong,
html body .composer .choice-btn strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 500;
}

html body .composer .model-menu-btn small {
  display: none;
}

html body .composer .model-menu-btn svg,
html body .composer .choice-btn svg {
  width: 14px;
  height: 14px;
  color: var(--gpt-faint);
}

html body .composer .settings-row .tool-pill {
  min-height: 36px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font-size: 13px;
}

html body .composer .settings-row .tool-pill:hover {
  background: var(--gpt-hover);
}

html body .cost-preview {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

html body .style-drawer {
  gap: 6px;
  flex-wrap: wrap;
}

html body .style-chip {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font-size: 13px;
  font-weight: 500;
}

html body .style-chip:hover {
  background: var(--gpt-hover);
}

html body .style-chip.is-active {
  border: 0;
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
}

html body .dock-note {
  margin: 2px 0 0;
  color: var(--gpt-faint);
  font-size: 12px;
  text-align: center;
}

html body .image-recovery-banner {
  border: 0;
  border-radius: 16px;
  background: var(--gpt-chip);
}

html body .zero-balance-banner {
  border: 1px solid rgba(217, 119, 6, 0.42);
  background: rgba(254, 243, 199, 0.94);
  color: #78350f;
}

html body .zero-balance-banner strong {
  color: #78350f;
}

html body .zero-balance-banner span {
  color: #92400e;
}

html body .zero-balance-banner .image-recovery-action {
  border-color: rgba(217, 119, 6, 0.35);
  background: #fffbeb;
  color: #92400e;
}

html body .zero-balance-banner .image-recovery-action:hover {
  background: #fef3c7;
}

/* ---------- 空白页：标题 + 输入框居中（桌面端） ---------- */

html body .empty-state {
  gap: 14px;
}

html body .empty-state h1 {
  margin: 0;
  color: var(--gpt-ink);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0;
}

html body .empty-state p {
  max-width: 520px;
  margin: 0;
  color: var(--gpt-muted);
  font-size: 15px;
  line-height: 1.6;
  text-wrap: balance;
}

html body .suggestion-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 760px;
  margin-top: 6px;
}

html body .suggestion-card {
  max-width: 360px;
  min-height: 0;
  padding: 9px 16px;
  border: 1px solid var(--gpt-line);
  border-radius: 999px;
  background: var(--gpt-surface);
  color: var(--gpt-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
  box-shadow: none;
}

html body .suggestion-card:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

@media (min-width: 861px) {
  html body .workspace:has(> .messages > .empty-state) {
    grid-template-rows: 56px minmax(0, 1fr) auto minmax(0, 1.15fr);
  }

  html body .workspace:has(> .messages > .empty-state) > .messages {
    align-self: end;
    overflow: visible;
    padding-bottom: 26px;
  }

  html body .workspace:has(> .messages > .empty-state) .empty-state {
    min-height: 0;
    padding-bottom: 0;
  }

  html body .workspace:has(> .messages > .empty-state) .composer-dock {
    position: relative;
    z-index: 30;
    align-self: start;
    background: transparent;
  }

  html body .workspace:has(> .messages > .empty-state) .dock-note {
    visibility: visible;
  }
}

/* ---------- 弹窗 / 菜单统一圆角 ---------- */

html body .auth-card {
  border: 0;
  border-radius: 24px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 24px 64px rgba(0, 0, 0, 0.16);
}

html body .auth-card .primary-btn {
  border-radius: 999px;
  background: var(--gpt-ink);
}

html body .auth-card .field input {
  border-radius: 12px;
}

/* ---------- 手机端 ---------- */

@media (max-width: 860px) {
  html body .workspace,
  html body .app-shell:not(.is-guest) .workspace {
    grid-template-rows: 52px minmax(0, 1fr) auto;
  }

  html body .app-shell:not(.is-guest) .workspace > .topbar,
  html body .workspace > .topbar {
    min-height: 52px;
    padding: env(safe-area-inset-top) 8px 0 6px;
  }

  html body .mobile-menu {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--gpt-ink);
  }

  html body .topbar .chat-model-btn,
  html body .brand-name {
    font-size: 17px;
  }

  html body .api-docs-top-btn span {
    display: none;
  }

  html body .messages,
  html body[data-session-type="chat"] .messages,
  html body[data-session-type="image"] .messages {
    padding: 12px 14px 20px;
  }

  html body .message.user .message-body,
  html body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
    max-width: 85%;
  }

  html body .composer-dock {
    padding: 0 10px calc(8px + env(safe-area-inset-bottom));
  }

  html body .composer {
    border-radius: 24px;
  }

  html body .history-panel {
    width: min(300px, 86vw);
    inset: 0 auto 0 0;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
  }

  html body .conversation-actions {
    opacity: 1;
    pointer-events: auto;
    position: static;
    transform: none;
    background: transparent;
    padding-left: 0;
  }

  html body .conversation-item.is-active .conversation-actions {
    background: transparent;
  }

  html body .conversation-item:not(.is-active) .conversation-actions .conversation-mini {
    display: none;
  }

  html body .conversation-item.is-active .conversation-actions .conversation-mini {
    display: inline-flex;
  }
}

/* ---------- 生图网格：多张两列，单张限制尺寸 ---------- */

html body .image-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  justify-content: stretch;
}

html body .image-grid:has(> .image-card:only-child) {
  grid-template-columns: minmax(0, min(var(--image-card-max, 640px), 100%));
}

html body .image-grid > .image-card {
  width: 100%;
  max-width: 100%;
}

html body[data-session-type="chat"] .chat-markdown table {
  border: 0;
  border-radius: 0;
  overflow: visible;
}

html body[data-session-type="chat"] .chat-markdown th,
html body[data-session-type="chat"] .chat-markdown td {
  border: 0;
  border-bottom: 1px solid var(--gpt-line);
  background: transparent;
}

html body .composer .prompt-row textarea {
  min-height: 40px;
  padding: 8px 10px;
  line-height: 24px;
}

/* 空白页建议：聊天用胶囊，生图提示较长用两列卡片 */
html body .empty-state .suggestion-grid {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  grid-template-columns: none;
  width: min(760px, 100%);
}

html body[data-session-type="image"] .empty-state .suggestion-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(720px, 100%);
}

html body[data-session-type="image"] .empty-state .suggestion-card {
  max-width: none;
  padding: 12px 16px;
  border-radius: 16px;
  text-align: left;
}

@media (min-width: 861px) {
  html body .workspace:has(> .messages > .empty-state) {
    grid-template-rows: 56px minmax(max-content, 1fr) auto minmax(0, 1.15fr);
  }
}

@media (max-width: 520px) {
  html body[data-session-type="image"] .empty-state .suggestion-grid {
    grid-template-columns: 1fr;
  }
}

/* 菜单按触发器上下视口可用空间自适应向上或向下展开，避免窄高屏向下裁切；默认向上 */
@media (min-width: 521px) {
  html body .composer .model-menu[data-open-dir="up"],
  html body .composer .chat-mode-menu[data-open-dir="up"],
  html body .composer .chat-reasoning-menu[data-open-dir="up"],
  html body .composer .composer-feature-menu[data-open-dir="up"] {
    bottom: calc(100% + 8px);
    top: auto;
    margin-left: var(--menu-shift-x, 0px);
    transform-origin: left bottom;
  }

  html body .composer .model-menu[data-open-dir="down"],
  html body .composer .chat-mode-menu[data-open-dir="down"],
  html body .composer .chat-reasoning-menu[data-open-dir="down"],
  html body .composer .composer-feature-menu[data-open-dir="down"] {
    top: calc(100% + 8px);
    bottom: auto;
    margin-left: var(--menu-shift-x, 0px);
    transform-origin: left top;
  }
}

/* ---------- 手机端：顶栏常驻（菜单 / 标题 / 余额），生图参数单独一行两列 ---------- */
@media (max-width: 860px) {
  html body .app-shell:not(.is-guest) .workspace,
  html body .workspace {
    grid-template-rows: calc(52px + env(safe-area-inset-top)) minmax(0, 1fr) auto;
  }

  html body .app-shell:not(.is-guest) .workspace > .topbar {
    position: relative;
    inset: auto;
    width: auto;
    display: flex;
    min-height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 8px 0 6px;
    background: var(--gpt-bg);
    box-shadow: none;
  }

  html body .app-shell:not(.is-guest) .workspace > .topbar .brand-name {
    display: inline-flex;
  }

  html body[data-session-type="chat"] .app-shell:not(.is-guest) .workspace > .topbar .brand-name {
    display: none;
  }

  html body .app-shell:not(.is-guest) .workspace > .topbar .top-actions {
    display: flex;
  }

  html body .app-shell:not(.is-guest) .workspace > .topbar .top-actions.is-hidden {
    display: none;
  }

  html body .app-shell:not(.is-guest) .workspace > .topbar .mobile-menu {
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  html body #userActions .api-docs-top-btn,
  html body #userActions .mobile-account {
    display: none;
  }

  html body .topbar .chat-model-menu {
    min-width: min(300px, calc(100vw - 24px));
  }

  html body .composer-dock,
  html body[data-session-type="chat"] .composer-dock,
  html body[data-session-type="image"] .composer-dock {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    padding: 0 10px calc(8px + env(safe-area-inset-bottom));
  }

  html body .composer,
  html body[data-session-type="chat"] .composer,
  html body[data-session-type="image"] .composer {
    width: min(var(--composer), calc(100vw - 20px));
    max-width: 100%;
    box-sizing: border-box;
  }

  html body #guestActions #signupBtn.outline-btn {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    height: 40px;
    white-space: nowrap;
  }

  html body #guestActions .api-docs-top-btn span {
    display: none;
  }

  /* 移动端顶栏（320px/360px/375px/390px 全模式防溢出）：保留 24x24 品牌 Logo 与完整品牌名，对齐 40-44px 触控热区 */
  html body[data-session-type="image"] .app-shell.is-guest .topbar:has(.model-control .model-menu-btn:not([hidden])) .brand-name {
    display: none;
  }

  html body .app-shell.is-guest .topbar .brand-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 0 1 auto;
    max-width: 100%;
    min-height: 40px;
    height: 40px;
    padding: 0 4px;
    font-size: 16px;
  }

  html body .app-shell.is-guest .topbar .brand-name .brand-name-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body .app-shell.is-guest .topbar .model-control .model-menu-btn {
    max-width: min(156px, calc(100vw - 216px));
    min-height: 40px;
    height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body .app-shell.is-guest .topbar #guestActions {
    gap: 4px;
    flex-shrink: 0;
  }

  html body .app-shell.is-guest .topbar #guestActions .icon-btn:not(.topbar-theme-btn),
  html body .app-shell.is-guest .topbar #guestActions .api-docs-top-btn,
  html body .app-shell.is-guest .topbar #guestActions .studio-top-btn {
    min-width: auto;
    width: auto;
    min-height: 40px;
    height: 40px;
    padding: 0 8px;
    gap: 4px;
    font-size: 12px;
    white-space: nowrap;
  }

  html body .app-shell .topbar .studio-top-btn .studio-top-label-full {
    display: none;
  }

  html body .app-shell .topbar .studio-top-btn .studio-top-label-short {
    display: inline;
  }

  html body .app-shell:not(.is-guest) .topbar #userActions .studio-top-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    height: 40px;
    padding: 0 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  html body .app-shell:not(.is-guest) .topbar #userActions .studio-top-btn .studio-top-label-full {
    display: none;
  }

  html body .app-shell.is-guest .topbar #guestActions #loginOpenBtn,
  html body .app-shell.is-guest .topbar #guestActions #signupBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    height: 40px;
    padding: 0 10px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
  }

  @media (max-width: 520px) {
    html body .app-shell.is-guest .topbar #guestActions #consoleTopGuestBtn,
    html body .app-shell.is-guest .topbar #guestActions #apiDocsTopGuestBtn {
      display: none;
    }

    html body .app-shell.is-guest .topbar .model-control .model-menu-btn {
      max-width: min(132px, calc(100vw - 208px));
    }
  }

  html body #topMoreMenu .top-more-item > span {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: nowrap;
    display: inline;
  }

  html body .composer,
  html body .composer:has(> .chat-toolbar[hidden]) {
    grid-template-areas:
      "attach attach attach attach"
      "text text text text"
      "settings settings settings settings"
      "plus tools mic send";
  }

  html body .composer:has(> .image-notify-prompt:not([hidden])),
  html body .composer:has(> .chat-toolbar[hidden]):has(> .image-notify-prompt:not([hidden])) {
    grid-template-areas:
      "notify notify notify notify"
      "attach attach attach attach"
      "text text text text"
      "settings settings settings settings"
      "plus tools mic send";
  }

  html body .composer > .settings-row,
  html body .composer:has(> .chat-toolbar[hidden]) > .settings-row,
  html body[data-session-type="image"] .composer > .settings-row {
    grid-area: settings;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 0 2px 4px;
  }

  html body .composer > .settings-row[hidden] {
    display: none !important;
  }

  html body .composer .settings-row .model-control {
    grid-column: 1 / -1;
  }

  html body .composer .setting-control,
  html body .composer .settings-row .tool-pill {
    width: 100%;
    min-width: 0;
  }

  html body .composer .setting-control {
    justify-content: space-between;
  }

  html body .composer .settings-row .tool-pill {
    justify-content: center;
  }

  html body .composer .model-menu-btn,
  html body[data-session-type="image"] .composer .model-menu-btn {
    width: auto;
    max-width: calc(100% - 44px);
  }

  /* 不能用横向滚动：会把向上弹出的菜单裁掉 */
  html body .composer > .chat-toolbar {
    flex-wrap: wrap;
    overflow: visible;
  }

  html body .composer .chat-mode-btn span,
  html body .composer .chat-reasoning-btn span {
    white-space: nowrap;
  }
}

/* 手机端聊天工具：单独一行；文件库 / 项目 / 提醒在 + 菜单里已有，这里隐藏 */
@media (max-width: 860px) {
  html body .composer:has(> .chat-toolbar:not([hidden])) {
    grid-template-areas:
      "attach attach attach attach"
      "text text text text"
      "settings settings settings settings"
      "tools tools tools tools"
      "plus . mic send";
  }

  html body .composer > .chat-toolbar {
    padding: 0 2px;
  }

  html body .composer #chatFilesBtn,
  html body .composer #chatProjectBtn,
  html body .composer #chatTasksBtn {
    display: none;
  }
}

@media (max-width: 860px) {
  html body .composer .chat-tool-toggle {
    width: 36px;
    min-height: 36px;
  }

  html body .composer .chat-mode-btn,
  html body .composer .chat-reasoning-btn {
    min-height: 36px;
    gap: 4px;
    padding: 0 8px;
    font-size: 13px;
  }
}

/* 窄屏：思考强度只留图标（非默认时按钮变蓝），保证工具一行放得下 */
@media (max-width: 520px) {
  html body .composer #chatReasoningLabel {
    display: none;
  }
}

@media (max-width: 860px) {
  html body .composer > .chat-toolbar > .chat-tool-toggle {
    flex: 0 0 32px;
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    padding: 0;
  }
}

/* ======================= v2（2026-11-06）======================= */

/* ---------- 登录弹窗：ChatGPT 式居中卡片 ---------- */

html body .auth-gate {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

html body .auth-card {
  width: min(400px, 100%);
  gap: 14px;
  padding: 36px 32px 26px;
  border: 0;
  border-radius: 24px;
  scrollbar-gutter: auto;
  scrollbar-width: thin;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}

html body .auth-card .auth-mark {
  justify-self: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--gpt-ink);
}

html body #loginForm .auth-mark img {
  width: 48px;
  height: 48px;
  display: block;
}

html body .auth-2fa .auth-mark {
  background: var(--gpt-chip);
  color: var(--gpt-ink);
}

html body .auth-2fa .auth-mark svg {
  color: var(--gpt-ink);
}

html body .auth-card .eyebrow {
  display: none;
}

html body .auth-card h1 {
  margin: 2px 0 0;
  color: var(--gpt-ink);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

html body .auth-card .auth-copy {
  margin: -4px 0 6px;
  color: var(--gpt-muted);
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
}

html body .auth-card .field {
  gap: 6px;
  color: var(--gpt-ink);
  font-size: 13px;
  font-weight: 500;
}

html body .auth-card .field-optional {
  margin-left: 4px;
  color: var(--gpt-faint);
  font-size: 12px;
  font-weight: 400;
}

html body .auth-card .field input {
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--gpt-input-border);
  border-radius: 12px;
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  font-size: 15px;
  font-weight: 400;
  box-shadow: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

html body .auth-card .field input:focus {
  border-color: var(--gpt-ink);
  box-shadow: 0 0 0 3px rgba(13, 13, 13, 0.08);
}

html[data-resolved-theme="dark"] body .auth-card .field input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14);
}

html body .auth-card a.auth-link-btn {
  justify-self: end;
  font-size: 13px;
}

html body .auth-card .field input::placeholder {
  color: var(--gpt-faint);
  font-weight: 400;
}

/* 2FA 输入框：打字时等宽加字距，占位文字保持正常大小 */
html body #loginTotpCode,
html body #twoFactorCode {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.24em;
}

html body #loginTotpCode::placeholder,
html body #twoFactorCode::placeholder {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
}

html body .auth-card .captcha-field {
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 8px;
}

html body .auth-card .captcha-image-btn {
  height: 48px;
  grid-template-columns: minmax(0, 1fr) 44px;
  border: 1px solid var(--gpt-input-border);
  border-radius: 12px;
}

html body .auth-card .captcha-image-btn img:not([src]),
html body .auth-card .captcha-image-btn img[src=""] {
  display: none;
}

html body .auth-card .captcha-image-btn span {
  border-left: 1px solid var(--gpt-line);
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font-size: 12px;
  font-weight: 500;
}

html body .auth-card .captcha-image-btn:has(> img:not([src])) > span,
html body .auth-card .captcha-image-btn:has(> img[src=""]) > span {
  grid-column: 1 / -1;
  border-left: 0;
}

html body .auth-card .captcha-image-btn:hover span {
  background: var(--gpt-hover);
}

/* 只读的连接信息对用户没用，收起不占位置 */
html body .auth-card .endpoint-details {
  display: none;
}

html body .auth-card .primary-btn {
  min-height: 50px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
  font-size: 15px;
  font-weight: 600;
  box-shadow: none;
}

html body .auth-card .primary-btn:hover:not(:disabled) {
  background: var(--gpt-ink-hover);
}

html body .auth-card .fine-print {
  margin: 0;
  color: var(--gpt-faint);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

html body .auth-card .auth-error {
  margin: 0;
  border: 0;
  border-radius: 12px;
  background: var(--gpt-error-bg);
  font-weight: 500;
}

html body .auth-close {
  top: 14px;
  right: 14px;
  color: var(--gpt-muted);
}

html body .auth-back {
  top: 14px;
  left: 14px;
  font-weight: 500;
}

@media (max-width: 520px) {
  html body .auth-gate {
    padding: 12px;
  }

  html body .auth-card {
    padding: 30px 20px 22px;
  }

  html body .auth-card .captcha-field {
    grid-template-columns: minmax(0, 1fr) 136px;
  }
}

/* ---------- 侧边栏细节 ---------- */

/* 悬停操作按钮：仅在桌面悬停设备启用滑出隐藏；移动端与触屏保持可见可点 */
@media (min-width: 861px) and (hover: hover) {
  html body .conversation-item .conversation-actions,
  html body .conversation-item:hover .conversation-actions,
  html body .conversation-item.is-active .conversation-actions,
  html body .conversation-item:focus-within .conversation-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: auto;
    min-width: 0;
    height: auto;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 4px 0 22px;
    border: 0;
    border-radius: 0 10px 10px 0;
    box-shadow: none;
    transform: none;
  }

  html body .conversation-item .conversation-actions {
    opacity: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--gpt-hover) 20px);
  }

  html body .conversation-item:hover .conversation-actions,
  html body .conversation-item:focus-within .conversation-actions {
    opacity: 1;
    pointer-events: auto;
  }

  html body .conversation-item.is-active .conversation-actions {
    background: linear-gradient(90deg, transparent, var(--gpt-active) 20px);
  }

  html body .conversation-item.is-active:not(:hover):not(:focus-within) .conversation-actions {
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 860px), (hover: none) {
  html body .conversation-item .conversation-actions,
  html body .conversation-item.is-active .conversation-actions,
  html body .conversation-item.is-active:not(:hover):not(:focus-within) .conversation-actions {
    position: static;
    opacity: 1;
    pointer-events: auto;
    background: transparent;
    width: auto;
    min-width: 0;
    padding-left: 0;
  }
}

/* 筛选 + 导入导出合成一行，不再换行占三行 */
html body .history-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 4px;
  row-gap: 2px;
}

html body .history-tools > .history-search {
  grid-column: 1 / -1;
}

html body .history-tools > .history-filters {
  flex-wrap: wrap;
  row-gap: 4px;
  column-gap: 4px;
  overflow-x: visible;
  scrollbar-width: none;
  padding: 2px 4px;
}

html body .history-tools > .history-filters::-webkit-scrollbar {
  display: none;
}

html body .history-filter {
  flex: 0 0 auto;
  white-space: nowrap;
}

html body .history-tools > .history-pack-actions {
  flex-wrap: nowrap;
  gap: 0;
  padding: 0;
}

html body .history-pack-actions .history-mini-btn {
  width: 28px;
  padding: 0;
  justify-content: center;
}

html body .history-pack-actions .history-mini-btn span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 未登录时左下角是“未登录”行，弱化成一个登录入口 */
html body .app-shell.is-guest .history-foot .balance-card {
  display: none;
}

/* ---------- 生图结果细节 ---------- */

html body .image-assistant-message .message-meta {
  flex-wrap: wrap;
  row-gap: 2px;
}

html body .image-assistant-message .message-meta span {
  white-space: nowrap;
}

html body .image-card .image-caption {
  padding: 8px 12px 10px;
  line-height: 1.5;
}

/* 原来的气泡化 hover 操作按钮，统一成幽灵按钮 */
html body .image-user-actions {
  opacity: 0;
  transition: opacity 0.12s ease;
}

html body .message.user:hover .image-user-actions,
html body .message.user:focus-within .image-user-actions {
  opacity: 1;
}

@media (hover: none) {
  html body .image-user-actions {
    opacity: 1;
  }
}

html body #loginTotpCode {
  text-align: left;
}

html body .auth-link-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gpt-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ======================= v3（2026-11-06）======================= */

/* 1. 屏幕矮时列表不压缩分组标题和对话行 */
html body .conversation-list > * {
  flex-shrink: 0;
}

/* 2. 生图结果：一行简要信息 + 折叠的「生成详情」 */
html body .generation-brief {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  color: var(--gpt-faint);
  font-size: 13px;
}

html body .generation-brief .generation-status-dot {
  width: 7px;
  height: 7px;
  box-shadow: none;
}

html body .generation-brief-status {
  color: var(--gpt-muted);
  font-weight: 500;
}

html body .generation-brief-status[data-status="failed"] {
  color: #d03a2f;
}

html body .generation-details {
  margin-top: 8px;
  color: var(--gpt-faint);
  font-size: 12px;
}

html body .generation-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

html body .generation-details > summary::-webkit-details-marker {
  display: none;
}

html body .generation-details > summary::after {
  content: "›";
  font-size: 14px;
  line-height: 1;
  transition: transform 0.15s ease;
}

html body .generation-details[open] > summary::after {
  transform: rotate(90deg);
}

html body .generation-details > summary:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body .generation-details[open] {
  padding: 8px 10px 4px;
  border-radius: 12px;
  background: var(--gpt-sidebar);
}

html body .generation-details[open] > summary {
  margin: -4px 0 6px -6px;
}

html body .generation-details .message-meta {
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 12px;
}

html body .generation-details .message-meta strong {
  font-size: 12px;
}

html body .image-assistant-message .image-result-actions {
  margin-top: 10px;
}

/* 3. 生成中：柔和流动的渐变占位，代替灰块 */
html body .image-skeleton {
  background: linear-gradient(120deg, #eef0f3, #f7f4ef, #eef3f1, #f3eef6, #eef0f3);
  background-size: 400% 400%;
  animation: gpt-image-pending 6s ease-in-out infinite;
  filter: saturate(1.05);
}

html body .image-skeleton::after {
  background: linear-gradient(90deg, transparent, var(--gpt-shimmer), transparent);
}

html body .image-card:has(.image-skeleton) .image-caption {
  color: var(--gpt-muted);
  font-size: 13px;
}

@keyframes gpt-image-pending {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  html body .image-skeleton {
    animation: none;
  }
}

/* 4. 生图模型选择器在顶栏左上角（和聊天一致），比例/质量/数量留在输入框 */
html body .topbar .model-control {
  position: relative;
  display: none;
  min-height: 40px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
}

html body[data-session-type="image"] .topbar .model-control,
html body[data-session-type="image"] .app-shell.is-guest .topbar .model-control:has(.model-menu-btn:not([hidden])),
html body[data-session-type="chat"] .app-shell:not(.is-guest) .topbar .model-control:has(.model-menu-btn:not([hidden])) {
  display: inline-flex;
}

html body[data-session-type="image"] .app-shell:not(.is-guest) .topbar .brand-name,
html body[data-session-type="image"] .app-shell.has-image-access .topbar .brand-name {
  display: none;
}

html body .model-menu.is-guest-preview {
  min-width: min(360px, calc(100vw - 24px));
  padding: 10px;
}

html body .guest-model-preview-head {
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--gpt-line);
  margin-bottom: 6px;
}

html body .guest-model-preview-head strong {
  display: block;
  font-size: 13px;
  color: var(--gpt-ink);
}

html body .guest-model-preview-head span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--gpt-muted);
}

html body .guest-model-preview-list {
  display: grid;
  gap: 6px;
}

html body .guest-model-preview-item {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--gpt-line);
  background: var(--gpt-chip);
}

html body .guest-model-preview-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

html body .guest-model-preview-item-top strong {
  font-size: 13px;
  color: var(--gpt-ink);
}

html body .guest-model-preview-item-top em {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gpt-blue);
}

html body .guest-model-preview-item span {
  font-size: 12px;
  line-height: 1.45;
  color: var(--gpt-muted);
}

html body .guest-model-preview-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--gpt-line);
}

html body .guest-model-preview-cta {
  flex: 1 1 auto;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
}

html body .topbar .brand-switch {
  flex: 1 1 auto;
  min-width: 0;
}

html body .topbar .model-control,
html body .topbar .chat-model-picker {
  min-width: 0;
}

html body .topbar .model-control > span {
  display: none;
}

html body .topbar .model-control .model-menu-btn {
  width: auto;
  max-width: min(360px, 50vw);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-ink);
  box-shadow: none;
}

html body .topbar .model-control .model-menu-btn[hidden] {
  display: none;
}

html body .topbar .model-control .model-menu-btn:hover,
html body .topbar .model-control .model-menu-btn[aria-expanded="true"] {
  background: var(--gpt-bubble);
}

html body .topbar .model-control .model-menu-btn strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 18px;
  font-weight: 500;
}

html body .topbar .model-control .model-menu-btn small {
  display: none;
}

html body .topbar .model-control .model-menu-btn svg {
  width: 16px;
  height: 16px;
  color: var(--gpt-faint);
  transform: rotate(180deg);
}

html body .topbar .model-menu {
  top: calc(100% + 6px);
  bottom: auto;
  left: 0;
  max-height: min(480px, calc(100dvh - 90px));
  border: 0;
  border-radius: 16px;
  box-shadow: var(--gpt-shadow-menu);
}

html body .composer .settings-row .tool-pill {
  width: 36px;
  min-width: 36px;
  padding: 0;
  gap: 0;
  justify-content: center;
  font-size: 0;
}

html body .composer .settings-row .tool-pill svg {
  width: 18px;
  height: 18px;
}

/* 5. 顶栏「…」菜单 */
html body .top-more {
  position: relative;
  display: none;
}

html body[data-session-type="chat"] .top-more {
  display: block;
}

html body .top-more-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-muted);
}

html body .top-more-btn:hover,
html body .top-more-btn[aria-expanded="true"] {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body .top-more-btn svg {
  width: 20px;
  height: 20px;
}

html body .top-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 200px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border-radius: 16px;
  background: var(--gpt-surface);
  box-shadow: var(--gpt-shadow-menu);
}

html body .top-more-menu[hidden] {
  display: none;
}

html body .top-more-menu .top-more-item {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-ink);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  box-shadow: none;
}

html body .top-more-menu .top-more-item:hover {
  background: var(--gpt-bubble);
}

html body .top-more-menu .top-more-item svg {
  width: 18px;
  height: 18px;
  color: var(--gpt-muted);
}

html body .top-more-menu .top-more-item.is-active svg {
  color: var(--gpt-blue);
}

html body .top-more-menu .top-more-item.is-active::after {
  content: "";
  width: 6px;
  min-width: 0;
  height: 6px;
  padding: 0;
  margin-left: auto;
  border-radius: 999px;
  background: var(--gpt-blue);
}

/* 6. 自己消息的 编辑/重试/删除 放到气泡下方（右对齐），桌面悬停显示 */
html body .message.user,
html body[data-session-type="chat"] .chat-message.chat-user {
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 2px;
}

html body .message.user > .message-body {
  order: 1;
}

html body .message.user > .image-user-actions,
html body .message.user > .chat-user-actions {
  order: 2;
  display: flex;
  justify-content: flex-end;
  gap: 0;
  margin: 0;
}

html body .message.user > .chat-user-actions {
  opacity: 0;
  transition: opacity 0.12s ease;
}

html body .message.user:hover > .chat-user-actions,
html body .message.user:focus-within > .chat-user-actions {
  opacity: 1;
}

@media (hover: none) {
  html body .message.user > .chat-user-actions,
  html body .message.user > .image-user-actions {
    opacity: 1;
  }

  html body .message.user .chat-action-btn {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 860px) {
  html body .topbar .model-control .model-menu-btn strong {
    font-size: 16px;
  }

  html body .topbar .model-control .model-menu-btn,
  html body .topbar .chat-model-btn {
    max-width: 100%;
  }

  html body .topbar .model-menu {
    width: min(338px, calc(100vw - 20px));
  }

  /* 工具少了，思考强度的文字可以放回来 */
  html body .composer #chatReasoningLabel {
    display: inline;
  }
}

/* 7. 图片库 */
html body .image-library {
  position: fixed;
  inset: 0;
  z-index: var(--z-session-modal);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

html body .image-library[hidden] {
  display: none;
}

html body .image-library-panel {
  width: min(1180px, 100%);
  height: min(860px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  background: var(--gpt-bg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}

html body .image-library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px 24px;
}

html body .image-library-head h2 {
  margin: 0;
  color: var(--gpt-ink);
  font-size: 20px;
  font-weight: 600;
}

html body .image-library-head p {
  margin: 2px 0 0;
  color: var(--gpt-faint);
  font-size: 13px;
}

html body .image-library-head .icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-muted);
}

html body .image-library-head .icon-btn:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body .image-library-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 24px 24px;
  columns: 4 220px;
  column-gap: 10px;
}

html body .image-library-tile {
  position: relative;
  margin: 0 0 10px;
  overflow: hidden;
  break-inside: avoid;
  border-radius: 14px;
  background: var(--gpt-chip);
}

html body .image-library-tile img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

html body .image-library-tile figcaption {
  position: absolute;
  inset: auto 0 0;
  max-height: 60%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  padding: 26px 12px 10px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.62));
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

html body .image-library-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100% - 16px);
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--gpt-overlay);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transition: opacity 0.15s ease;
}

html body .image-library-actions .icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gpt-ink);
}

@media (hover: none), (max-width: 860px) {
  html body .image-library-actions {
    gap: 3px;
    padding: 4px;
  }

  html body .image-library-actions .icon-btn {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
  }
}

html body .image-library-actions .icon-btn:hover {
  background: var(--gpt-press);
}

html body .image-library-actions svg {
  width: 16px;
  height: 16px;
}

html body .image-library-tile:hover figcaption,
html body .image-library-tile:hover .image-library-actions,
html body .image-library-tile:focus-within .image-library-actions {
  opacity: 1;
}

@media (hover: none) {
  html body .image-library-actions {
    opacity: 1;
  }
}

html body .image-library-pages {
  column-span: all;
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 4px;
}

html body .image-library-filter {
  min-height: 36px;
  max-width: 196px;
  padding: 0 10px;
  border: 1px solid var(--gpt-line);
  border-radius: 10px;
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

html body .image-library-reload-btn {
  margin-top: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
}

html body .image-library-empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 80px 20px;
  color: var(--gpt-faint);
  text-align: center;
  column-span: all;
}

html body .image-library-empty svg {
  width: 36px;
  height: 36px;
}

@media (max-width: 860px) {
  html body .image-library {
    padding: 0;
  }

  html body .image-library-panel {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  html body .image-library-head {
    padding: calc(12px + env(safe-area-inset-top)) 12px 8px 16px;
  }

  html body .image-library-grid {
    padding: 4px 12px calc(16px + env(safe-area-inset-bottom));
    columns: 2 140px;
    column-gap: 8px;
  }

  html body #logoutTopBtn {
    display: none;
  }
}

/* 8. 深色模式（ChatGPT 深色配色）。theme.js 把「跟随系统」解析成 data-resolved-theme */
:root[data-resolved-theme="dark"] {
  color-scheme: dark;
  --gpt-bg: #212121;
  --gpt-sidebar: #171717;
  --gpt-hover: #424242;
  --gpt-active: #474747;
  --gpt-ink: #ececec;
  --gpt-muted: #b8b8b8;
  --gpt-faint: #ababab;
  --gpt-line: rgba(255, 255, 255, 0.11);
  --gpt-bubble: #303030;
  --gpt-chip: #383838;
  --gpt-blue: #48aaff;
  --gpt-blue-soft: rgba(72, 170, 255, 0.18);
  --gpt-surface: #2c2c2c;
  --gpt-on-ink: #0d0d0d;
  --gpt-ink-hover: #d0d0d0;
  --gpt-disabled: #4a4a4a;
  --gpt-on-disabled: #8f8f8f;
  --gpt-overlay: rgba(40, 40, 40, 0.92);
  --gpt-press: rgba(255, 255, 255, 0.09);
  --gpt-input-border: #484848;
  --gpt-error-bg: rgba(208, 58, 47, 0.22);
  --gpt-shimmer: rgba(255, 255, 255, 0.07);
  --gpt-shadow-composer: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 18px rgba(0, 0, 0, 0.34);
  --gpt-shadow-menu: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 12px 32px rgba(0, 0, 0, 0.54);
  /* 旧样式表的变量 */
  --bg: #212121;
  --surface: #2c2c2c;
  --surface-soft: #353535;
  --surface-hover: #424242;
  --surface-active: #474747;
  --ink: #ececec;
  --ink-soft: #b8b8b8;
  --muted: #b8b8b8;
  --faint: #ababab;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --rail-bg: #171717;
  --accent: #34c79a;
  --accent-soft: rgba(52, 199, 154, 0.16);
  --danger: #ff7b72;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.54);
}

html[data-resolved-theme="dark"] body,
html[data-resolved-theme="dark"] body .workspace,
html[data-resolved-theme="dark"] body .messages,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .workspace,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .messages,
html[data-resolved-theme="dark"] body .app-shell {
  background: var(--gpt-bg);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .composer-dock,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .composer-dock,
html[data-resolved-theme="dark"] body[data-session-type="image"] .composer-dock {
  background: linear-gradient(180deg, transparent, var(--gpt-bg) 22px);
}

html[data-resolved-theme="dark"] body .composer,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .composer,
html[data-resolved-theme="dark"] body .history-search:focus-within {
  background: var(--gpt-surface);
}

html[data-resolved-theme="dark"] body .history-panel,
html[data-resolved-theme="dark"] body .app-shell.history-pinned .history-panel,
html[data-resolved-theme="dark"] body .rail {
  background: var(--gpt-sidebar);
}

html[data-resolved-theme="dark"] body .topbar,
html[data-resolved-theme="dark"] body .workspace > .topbar,
html[data-resolved-theme="dark"] body .app-shell:not(.is-guest) .workspace > .topbar {
  background: var(--gpt-bg);
}

html[data-resolved-theme="dark"] body input,
html[data-resolved-theme="dark"] body select,
html[data-resolved-theme="dark"] body textarea {
  background-color: transparent;
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .auth-card .field input,
html[data-resolved-theme="dark"] body .settings-textarea,
html[data-resolved-theme="dark"] body .canvas-editor {
  border-color: var(--gpt-input-border);
  background: var(--gpt-bg);
}

/* 菜单、弹窗、卡片 */
html[data-resolved-theme="dark"] body .model-menu,
html[data-resolved-theme="dark"] body .choice-menu,
html[data-resolved-theme="dark"] body .composer-feature-menu,
html[data-resolved-theme="dark"] body .image-key-menu,
html[data-resolved-theme="dark"] body .chat-model-menu,
html[data-resolved-theme="dark"] body .chat-mode-menu,
html[data-resolved-theme="dark"] body .chat-reasoning-menu,
html[data-resolved-theme="dark"] body .top-more-menu,
html[data-resolved-theme="dark"] body .auth-card,
html[data-resolved-theme="dark"] body .session-settings-card,
html[data-resolved-theme="dark"] body .prompt-assist-card,
html[data-resolved-theme="dark"] body .project-memory-card,
html[data-resolved-theme="dark"] body .asset-library-card,
html[data-resolved-theme="dark"] body .task-card,
html[data-resolved-theme="dark"] body .canvas-panel {
  border-color: var(--gpt-line);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .image-library-panel {
  background: var(--gpt-bg);
}

html[data-resolved-theme="dark"] body .auth-gate,
html[data-resolved-theme="dark"] body .image-library,
html[data-resolved-theme="dark"] body .session-settings,
html[data-resolved-theme="dark"] body .asset-library-modal,
html[data-resolved-theme="dark"] body .project-memory-modal,
html[data-resolved-theme="dark"] body .task-modal,
html[data-resolved-theme="dark"] body .prompt-assist-modal,
html[data-resolved-theme="dark"] body .history-backdrop.is-open {
  background: rgba(0, 0, 0, 0.62);
}

html[data-resolved-theme="dark"] body .feature-option:hover {
  background: var(--gpt-hover);
}

html[data-resolved-theme="dark"] body .feature-option.is-active {
  background: var(--gpt-blue-soft);
  color: var(--gpt-blue);
}

html[data-resolved-theme="dark"] body .model-option-side em {
  background: var(--gpt-blue-soft);
  color: var(--gpt-blue);
}

html[data-resolved-theme="dark"] body .toast {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #262629;
  color: #f3f3f4;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-resolved-theme="dark"] body .toast.is-error {
  background: #dc2626;
  color: #ffffff;
}

/* 消息 */
html[data-resolved-theme="dark"] body .message.user .message-body,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .chat-message.chat-user .chat-bubble {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .chat-markdown :not(pre) > code,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .chat-markdown :not(pre) > code {
  background: #424242;
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body[data-session-type="chat"] .chat-markdown th,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .chat-markdown td {
  background: transparent;
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .chat-file-attachment,
html[data-resolved-theme="dark"] body[data-session-type="chat"] .chat-file-attachment,
html[data-resolved-theme="dark"] body .chat-file-icon,
html[data-resolved-theme="dark"] body .attachment-file-icon {
  border-color: var(--gpt-line);
  background: var(--gpt-chip);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .image-caption,
html[data-resolved-theme="dark"] body .image-card .image-caption {
  background: transparent;
  color: var(--gpt-faint);
}

html[data-resolved-theme="dark"] body .image-skeleton {
  background: linear-gradient(120deg, #2a2a2a, #33302c, #2b302e, #312c34, #2a2a2a);
  background-size: 400% 400%;
}

html[data-resolved-theme="dark"] body .image-actions .icon-btn,
html[data-resolved-theme="dark"] body .image-library-actions .icon-btn {
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .code-block {
  background: #171717;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* 顶栏与侧栏按钮 */
html[data-resolved-theme="dark"] body .top-actions .outline-btn {
  border-color: var(--gpt-input-border);
}

html[data-resolved-theme="dark"] body .conversation-mini[data-tooltip]::after,
html[data-resolved-theme="dark"] body .conversation-delete[data-tooltip]::after {
  background: #ececec;
  color: #0d0d0d;
}

html[data-resolved-theme="dark"] body .scroll-bottom-btn {
  border-color: var(--gpt-line);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .suggestion-card {
  border-color: var(--gpt-line);
}

html[data-resolved-theme="dark"] body .style-chip.is-active {
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
}

/* 验证码图片在深色模式下适度柔化刺眼白底，同时保持字符对比度 */
html[data-resolved-theme="dark"] body .captcha-image-btn {
  border-color: rgba(255, 255, 255, 0.16);
  background: #e6ebf2;
}

html[data-resolved-theme="dark"] body .captcha-image-btn img {
  background: #e6ebf2;
  filter: brightness(0.92) contrast(1.06);
}

html[data-resolved-theme="dark"] body .theme-icon-slot svg,
html[data-resolved-theme="dark"] body .new-chat-wide svg,
html[data-resolved-theme="dark"] body .sidebar-api-docs-btn svg {
  color: var(--gpt-ink);
}

html body .theme-icon-slot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

html body .theme-icon-slot svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

/* 旧样式里聊天模式专用规则（body[data-session-type="chat"] ...）权重更高，这里同等前缀再覆盖一次，浅色/深色都走变量 */
html body[data-session-type] .composer {
  border: 0;
  background: var(--gpt-surface);
  box-shadow: var(--gpt-shadow-composer);
}

html body[data-session-type] .composer:focus-within {
  box-shadow: 0 0 0 1px var(--gpt-input-border), 0 6px 22px rgba(0, 0, 0, 0.08);
}

html body[data-session-type] .chat-markdown,
html body[data-session-type] .chat-markdown p,
html body[data-session-type] .chat-markdown li,
html body[data-session-type] .chat-markdown h1,
html body[data-session-type] .chat-markdown h2,
html body[data-session-type] .chat-markdown h3,
html body[data-session-type] .chat-markdown h4,
html body[data-session-type] .chat-markdown strong,
html body[data-session-type] .chat-file-text small,
html body[data-session-type] .prompt-row textarea {
  color: var(--gpt-ink);
}

html body[data-session-type] .chat-markdown :not(pre) > code {
  border: 0;
  background: var(--gpt-hover);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body[data-session-type] .chat-markdown :not(pre) > code {
  border: 0;
  background: #3d3d3d;
}

html[data-resolved-theme="dark"] body[data-session-type] .chat-image-job-hint {
  color: var(--gpt-muted);
}

html body[data-session-type] .chat-user-actions .chat-action-btn:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body[data-session-type] .composer .chat-tool-toggle,
html body[data-session-type] .composer .chat-mode-btn,
html body[data-session-type] .composer .chat-reasoning-btn {
  border: 0;
  background: transparent;
  color: var(--gpt-muted);
}

html body[data-session-type] .composer .chat-tool-toggle:hover,
html body[data-session-type] .composer .chat-mode-btn:hover,
html body[data-session-type] .composer .chat-reasoning-btn:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body[data-session-type] .composer .chat-tool-toggle.is-active,
html body[data-session-type] .composer .chat-mode-btn.is-active,
html body[data-session-type] .composer .chat-reasoning-btn.is-active {
  border: 0;
  background: var(--gpt-blue-soft);
  color: var(--gpt-blue);
}

html body[data-session-type] .topbar .chat-model-btn {
  border: 0;
  background: transparent;
  color: var(--gpt-ink);
}

html body[data-session-type] .topbar .chat-model-btn:hover,
html body[data-session-type] .topbar .chat-model-btn[aria-expanded="true"] {
  background: var(--gpt-bubble);
}

html body[data-session-type] .top-more-menu .top-more-item {
  border: 0;
  background: transparent;
  color: var(--gpt-ink);
}

html body[data-session-type] .top-more-menu .top-more-item:hover {
  background: var(--gpt-bubble);
}

html body[data-session-type] .chat-message.chat-user .chat-text,
html body[data-session-type] .message.user .message-body p {
  color: var(--gpt-ink);
}

html body[data-session-type] .dock-note {
  color: var(--gpt-faint);
}

html body[data-session-type="chat"] .chat-empty-state h1 {
  color: var(--gpt-ink);
}

html body[data-session-type="chat"] .chat-empty-state .suggestion-card {
  border: 1px solid var(--gpt-line);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
}

html body[data-session-type="chat"] .chat-empty-state .suggestion-card:hover {
  background: var(--gpt-hover);
  border-color: var(--gpt-input-border);
}

html body[data-session-type="chat"] .chat-message.chat-assistant .chat-text,
html body[data-session-type="chat"] .chat-message.chat-assistant .streaming-cursor,
html body[data-session-type="chat"] .chat-file-text strong {
  color: var(--gpt-ink);
}

html body[data-session-type="chat"] .chat-markdown blockquote {
  border-left-color: var(--gpt-input-border);
  color: var(--gpt-muted);
}

html body[data-session-type="chat"] .chat-markdown hr {
  border-top-color: var(--gpt-line);
}

html body[data-session-type="chat"] .chat-attachments img {
  border-color: var(--gpt-line);
  background: var(--gpt-surface);
}

html body[data-session-type="chat"] .send-btn {
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
}

html body[data-session-type="chat"] .send-btn:hover:not(:disabled) {
  background: var(--gpt-ink-hover);
}

html body[data-session-type="chat"] .send-btn:disabled {
  background: var(--gpt-disabled);
  color: var(--gpt-on-disabled);
}

html body[data-session-type="chat"] .scroll-bottom-btn {
  border-color: var(--gpt-line);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .generation-brief-status[data-status="failed"],
html[data-resolved-theme="dark"] body .chat-model-empty.is-error,
html[data-resolved-theme="dark"] body .auth-card .auth-error {
  color: #ff8a80;
}

/* 手机：生图参数一行排开（比例 / 质量 / 数量 + 两个图标），去掉小标签省空间 */
@media (max-width: 860px) {
  html body .composer > .settings-row,
  html body .composer:has(> .chat-toolbar[hidden]) > .settings-row,
  html body[data-session-type="image"] .composer > .settings-row {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }

  html body .composer .setting-control,
  html body[data-session-type="image"] .composer .setting-control {
    width: auto;
    flex: 0 0 auto;
    padding: 0 2px 0 4px;
  }

  html body .composer .setting-control:not(.custom-size-control) > span {
    display: none;
  }

  html body .composer .settings-row .tool-pill,
  html body[data-session-type="image"] .composer .settings-row .tool-pill {
    width: 36px;
    flex: 0 0 36px;
  }

  html body .composer .settings-row #styleBtn .style-btn-label {
    display: none;
  }
}

html body .composer .settings-row #styleBtn.is-active {
  background: var(--gpt-blue-soft);
  color: var(--gpt-blue);
}

/* 2026-11-21 UI polish: Canvas overlay alignment, dark mode completeness & modal inputs */
html body #topMoreMenu .top-more-item > span {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  display: inline;
}

@media (min-width: 861px) {
  html body .app-shell.has-canvas .canvas-panel {
    z-index: calc(var(--z-floating-control) + 10);
    top: 56px;
    padding: 14px 16px 16px;
  }

  html body[data-session-type="chat"] .app-shell.history-pinned.has-canvas .messages {
    padding-right: max(calc(var(--canvas-space, 430px) + 16px), calc((100vw - var(--rail) - var(--history-width) - var(--composer)) / 2));
  }

  html body[data-session-type="chat"] .app-shell.history-pinned.has-canvas .composer-dock {
    width: min(var(--composer), calc(100vw - var(--rail) - var(--history-width) - var(--canvas-space, 430px) - 36px));
    margin-left: 0;
    margin-right: var(--canvas-space, 430px);
  }
}

@media (min-width: 861px) and (max-width: 1180px) {
  html body .app-shell.history-pinned.has-canvas .canvas-panel {
    box-shadow: var(--gpt-shadow-menu);
  }

  html body[data-session-type="chat"] .app-shell.history-pinned.has-canvas .messages,
  html body[data-session-type="chat"] .app-shell.history-pinned.has-canvas .composer-dock {
    width: min(var(--composer), calc(100% - 44px));
    margin-right: 0;
    padding-right: max(20px, calc((100vw - var(--rail) - var(--history-width) - var(--chat-column)) / 2));
  }
}

@media (min-width: 861px) and (max-height: 740px) {
  html body .workspace:has(> .messages > .empty-state) {
    grid-template-rows: 56px minmax(0, 1fr) auto 0fr;
  }

  html body .workspace:has(> .messages > .empty-state) .messages {
    overflow-y: auto;
  }
}

@media (max-width: 860px) {
  html body .app-shell.has-canvas .canvas-panel {
    z-index: calc(var(--z-history) - 10);
    inset: calc(58px + env(safe-area-inset-top)) 10px calc(18px + env(safe-area-inset-bottom)) 10px;
  }
}

html body ::selection {
  background: rgba(1, 105, 204, 0.22);
}

html[data-resolved-theme="dark"] {
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

html[data-resolved-theme="dark"] body ::selection {
  background: rgba(72, 170, 255, 0.34);
}

html[data-resolved-theme="dark"] body ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html[data-resolved-theme="dark"] body ::-webkit-scrollbar-track {
  background: transparent;
}

html[data-resolved-theme="dark"] body ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

html[data-resolved-theme="dark"] body select option {
  background: #2b2b2b;
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .image-recovery-banner {
  background: rgba(47, 47, 47, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .image-recovery-banner strong {
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .image-recovery-banner span {
  color: var(--gpt-muted);
}

html[data-resolved-theme="dark"] body .image-recovery-action {
  background: var(--gpt-surface);
  border-color: var(--gpt-line);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .zero-balance-banner {
  background: rgba(120, 53, 15, 0.34);
  border-color: rgba(245, 158, 11, 0.38);
  color: #fde68a;
}

html[data-resolved-theme="dark"] body .zero-balance-banner strong {
  color: #fef3c7;
}

html[data-resolved-theme="dark"] body .zero-balance-banner span {
  color: #fcd34d;
}

html[data-resolved-theme="dark"] body .zero-balance-banner .image-recovery-action {
  background: rgba(30, 30, 30, 0.72);
  border-color: rgba(245, 158, 11, 0.42);
  color: #fde68a;
}

html[data-resolved-theme="dark"] body .studio-secret-toggle,
html[data-resolved-theme="dark"] body .settings-input {
  background: var(--gpt-chip);
  border-color: var(--gpt-input-border);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .chat-status-badge.is-stopped {
  background: rgba(255, 255, 255, 0.08);
  color: var(--gpt-muted);
}

html[data-resolved-theme="dark"] body .chat-status-badge.is-error {
  background: rgba(208, 58, 47, 0.22);
  color: #ff9e96;
}

html body .studio-modal-card .solid-btn,
html body .prompt-assist-card .solid-btn,
html[data-resolved-theme="dark"] body .studio-modal-card .solid-btn,
html[data-resolved-theme="dark"] body .prompt-assist-card .solid-btn {
  background: var(--gpt-ink);
  border-color: var(--gpt-ink);
  color: var(--gpt-on-ink);
}

html body .studio-modal-card .outline-btn,
html body .prompt-assist-card .outline-btn,
html body .image-library-pages .outline-btn,
html[data-resolved-theme="dark"] body .studio-modal-card .outline-btn,
html[data-resolved-theme="dark"] body .prompt-assist-card .outline-btn,
html[data-resolved-theme="dark"] body .image-library-pages .outline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: var(--gpt-input-border);
  color: var(--gpt-ink);
}

html body .studio-modal-card .plain-btn,
html body .prompt-assist-card .plain-btn,
html[data-resolved-theme="dark"] body .studio-modal-card .plain-btn,
html[data-resolved-theme="dark"] body .prompt-assist-card .plain-btn {
  background: transparent;
  color: var(--gpt-muted);
  border: 0;
}

html body .studio-modal-card .plain-btn:hover,
html body .prompt-assist-card .plain-btn:hover,
html[data-resolved-theme="dark"] body .studio-modal-card .plain-btn:hover,
html[data-resolved-theme="dark"] body .prompt-assist-card .plain-btn:hover {
  background: var(--gpt-hover);
  color: var(--gpt-ink);
}

@media (max-width: 860px) {
  html body[data-session-type] .composer .setting-control {
    min-width: 0;
    max-width: none;
  }

  html body[data-session-type] .composer .choice-btn {
    width: auto;
    min-width: 0;
    padding: 0 8px 0 6px;
  }
}

/* 热修复 v3.1：旧手机样式把 .model-menu 设成 position: fixed（贴着输入框弹出），
   挪到顶栏后 top: 100% 变成了屏幕底部以外 → 手机上点了看不到菜单，无法选生图模型 */
html body .topbar .model-menu,
html body[data-session-type] .topbar .model-menu {
  position: absolute;
  top: calc(100% + 6px);
  bottom: auto;
  left: 0;
  right: auto;
  transform: none;
}

@media (max-width: 860px) {
  html body .topbar .model-menu,
  html body[data-session-type] .topbar .model-menu {
    width: min(338px, calc(100vw - 20px));
    max-height: min(70vh, calc(100dvh - 80px));
  }

  html body .topbar .model-menu.is-guest-preview,
  html body[data-session-type] .topbar .model-menu.is-guest-preview,
  html body .model-menu.is-guest-preview {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 54px);
    bottom: auto;
    left: 12px;
    right: 12px;
    min-width: 0;
    width: auto;
    max-width: calc(100vw - 24px);
    transform: none;
    box-sizing: border-box;
  }
}

html body .generation-ratio-hint {
  margin: 4px 0 6px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--gpt-chip);
  color: var(--gpt-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* 失败任务的计费核对状态（2026-11-22）：原因写在正文里，这里只显示“是否扣费”的核对进度 */
html body .image-billing-status {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  margin: 6px 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--gpt-line);
  border-radius: 12px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
}

html body .image-billing-status strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

html body .image-billing-status p {
  margin: 3px 0 0;
  color: var(--gpt-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

html body .image-billing-status small {
  display: block;
  margin-top: 4px;
  color: var(--gpt-faint);
  font-size: 11.5px;
  word-break: break-all;
  user-select: all;
}

html body .image-billing-status[data-billing-status="not_charged"] strong,
html body .image-billing-status[data-billing-status="refunded"] strong {
  color: #0f7b4f;
}

html[data-resolved-theme="dark"] body .image-billing-status[data-billing-status="not_charged"] strong,
html[data-resolved-theme="dark"] body .image-billing-status[data-billing-status="refunded"] strong {
  color: #4cc38a;
}

html body .image-billing-refresh {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--gpt-input-border);
  border-radius: 999px;
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

html body .image-billing-refresh:hover {
  background: var(--gpt-hover);
}

html body .image-billing-refresh:disabled {
  opacity: 0.6;
  cursor: wait;
}

html body .image-billing-refresh svg,
html body .image-billing-refresh i {
  width: 14px;
  height: 14px;
}

@media (max-width: 520px) {
  html body .image-billing-status {
    flex-direction: column;
    gap: 8px;
  }
}

/* 2026-11-23 studio UX: billed content rejection, billing actions, upload cancel, expired images */
html body .image-billing-status[data-billing-status="charged"] strong {
  color: #b4540a;
}

html[data-resolved-theme="dark"] body .image-billing-status[data-billing-status="charged"] strong {
  color: #f0a35e;
}

html body .image-billing-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

html body .chat-action-btn.is-waiting-billing:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

html body .image-upload-cancel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px auto 10px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--gpt-input-border);
  border-radius: 999px;
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

html body .image-upload-cancel:hover {
  background: var(--gpt-hover);
}

html body .image-upload-cancel svg,
html body .image-upload-cancel i {
  width: 14px;
  height: 14px;
}

html body .image-card-expired .image-missing p {
  color: var(--gpt-muted);
}

/* 生成完成后的图片下载进度（2026-11-22）：以前是一块没有任何提示的灰底 */
html body .image-card-loading {
  position: relative;
}

/* 贴在卡片顶部：图片卡片常常比可视区域高，放在底部会被输入框挡住 */
html body .image-loading-progress {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--gpt-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--gpt-ink);
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
}

html body .image-loading-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--gpt-press);
  overflow: hidden;
}

html body .image-loading-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--gpt-ink);
  transition: width 0.2s ease;
}

/* 生成前显示预计费用：以前这一项在所有宽度下都被隐藏，用户点生成前看不到价格 */
html body[data-session-type="image"] .composer .settings-row .cost-preview:not(.is-hidden),
html body[data-session-type="chat"][data-chat-image-mode="true"] .composer .settings-row .cost-preview:not(.is-hidden) {
  display: inline-flex;
  flex: 0 0 auto;
  width: auto;
  margin-left: 0;
  font-variant-numeric: tabular-nums;
}

/* 侧栏固定时输入框宽度按工作区算。原来按整个窗口宽度算：窗口宽 861–1176px 时（例如 1366 屏幕开 125% 缩放）
   输入框比工作区还宽，整页出现横向滚动条，发送按钮被挤到屏幕外。 */
@media (min-width: 861px) {
  html body[data-session-type="image"] .composer {
    width: min(var(--composer), 100%);
  }
}

/* 手机上价格标签随参数行排布，不再用绝对定位覆盖底部按钮 */
@media (max-width: 860px) {
  html body[data-session-type="image"] .composer .settings-row .cost-preview:not(.is-hidden),
  html body[data-session-type="chat"][data-chat-image-mode="true"] .composer .settings-row .cost-preview:not(.is-hidden) {
    position: static;
    flex: 0 0 auto;
    margin-left: auto;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* 图片库顶部的保存期说明与搜索栏 */
html body .image-library-head .image-library-note {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--gpt-muted);
}

html body .image-library-head-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

html body .image-library-size-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--gpt-line);
  background: var(--gpt-chip);
  color: var(--gpt-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

html body .image-library-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--gpt-line);
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-muted);
}

html body .image-library-search:focus-within {
  border-color: var(--gpt-input-border);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
}

html body .image-library-search svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

html body .image-library-search input {
  width: 170px;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--gpt-ink);
  font-size: 13px;
}

html body .image-library-expired {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 168px;
  padding: 20px 12px;
  color: var(--gpt-faint);
  font-size: 12px;
  text-align: center;
}

html body .image-library-expired svg {
  width: 24px;
  height: 24px;
}

html body .image-library-history-btn {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 860px) {
  html body .image-library-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  html body .image-library-head-tools {
    width: 100%;
    justify-content: space-between;
  }

  html body .image-library-search {
    flex: 1 1 auto;
  }

  html body .image-library-search input {
    width: 100%;
  }
}

/* “下载全部”旁边的一小句：服务器那份保存到哪天 */
html body .image-result-actions .image-result-note {
  align-self: center;
  margin-left: 4px;
  color: var(--gpt-faint);
  font-size: 12px;
  line-height: 1.4;
}

/* 模型菜单里的“型号 · 最高清晰度 · 单价”可以在分隔处换行，但不要把“$0.05/张”拆开 */
html body .model-option-main small span {
  white-space: nowrap;
}

/* 比例选择器 3 列可视画幅面板 + 紧凑参数选项 */
html body .composer [data-setting="ratio"] .choice-menu {
  width: min(416px, calc(100vw - 24px));
  min-width: 0;
  padding: 8px;
  gap: 0;
}

@media (max-width: 520px) {
  html body .composer [data-setting="ratio"] .choice-menu {
    width: auto;
  }
}

html body .choice-ratio-section {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

html body .choice-menu-divider {
  margin: 7px 4px 5px;
  padding-top: 6px;
  border-top: 1px solid var(--gpt-line);
  color: var(--gpt-faint);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

html body .choice-option.choice-option-ratio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 5px;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: center;
}

html body .choice-option.choice-option-ratio:hover {
  background: var(--gpt-hover);
}

html body .choice-option.choice-option-ratio.is-selected {
  border-color: var(--gpt-blue, #0a6542);
  background: var(--gpt-blue-soft, rgba(16, 163, 127, 0.1));
  color: var(--gpt-blue, #0a6542);
}

html body .choice-ratio-slot {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  margin-bottom: 1px;
  color: var(--gpt-muted);
}

html body .choice-option.choice-option-ratio.is-selected .choice-ratio-slot {
  color: currentColor;
}

html body .choice-ratio-frame {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  background: color-mix(in srgb, currentColor 10%, transparent);
  box-sizing: border-box;
}

html body .choice-option.choice-option-ratio strong {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
}

html body .choice-option.choice-option-ratio small {
  max-width: 100%;
  font-size: 10.5px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--gpt-faint);
}

html body .choice-option.choice-option-ratio.is-selected small {
  color: currentColor;
  opacity: 0.85;
}

html body .choice-option {
  color: var(--gpt-ink);
}

html body .choice-option:hover {
  background: var(--gpt-hover);
}

html body .choice-option.is-selected {
  background: var(--gpt-blue-soft, rgba(16, 163, 127, 0.1));
  color: var(--gpt-blue, #0a6542);
}

html body .choice-option small {
  color: var(--gpt-faint);
  white-space: normal;
  overflow-wrap: anywhere;
}

html[data-resolved-theme="dark"] body .choice-option.choice-option-ratio.is-selected {
  border-color: var(--gpt-blue);
  background: var(--gpt-blue-soft);
  color: var(--gpt-blue);
}

/* 桌面端顶栏已展示「账户余额 / API 文档 / 返回控制台」，侧栏去掉重复入口，把空间留给历史对话列表 */
@media (min-width: 861px) {
  html body #apiDocsPanelBtn,
  html body #sidebarConsoleBtn,
  html body .history-foot .balance-card {
    display: none;
  }

  html body .history-panel .new-chat-wide,
  html body .history-panel .sidebar-api-docs-btn {
    min-height: 34px;
  }
}

/* ==== 2026-11-26 Final UX & Accessibility Polish ==== */
html body .top-actions .plain-btn,
html body .top-actions .outline-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

html body .topbar .topbar-theme-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--gpt-muted);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

html body .topbar .topbar-theme-btn:hover {
  background: var(--gpt-bubble);
  color: var(--gpt-ink);
}

html body .empty-state .suggestion-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(720px, 100%);
}

html body .empty-state .suggestion-card {
  max-width: none;
  width: 100%;
  padding: 12px 16px;
  border-radius: 16px;
  text-align: left;
}

html body .chat-thinking {
  margin: 0 0 10px;
  border: 1px solid var(--gpt-line);
  border-radius: 12px;
  background: var(--gpt-bubble);
  padding: 6px 12px;
  font-size: 13px;
}

html body .chat-thinking summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  color: var(--gpt-muted);
  list-style: none;
  padding: 2px 0;
  user-select: none;
}

html body .chat-thinking summary::-webkit-details-marker {
  display: none;
}

html body .chat-thinking summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.16s ease;
}

html body .chat-thinking[open] summary::after {
  transform: rotate(45deg);
}

html body .chat-thinking.is-thinking summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gpt-blue);
  animation: luchiPulseDot 1.2s ease-in-out infinite;
}

@keyframes luchiPulseDot {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

html body .chat-thinking-body {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--gpt-line);
  color: var(--gpt-muted);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 280px;
  overflow-y: auto;
}

html body .chat-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 10px 0;
  border-radius: 10px;
}

html body[data-session-type] .chat-markdown .chat-table-wrap > table {
  display: table;
  width: max-content;
  min-width: 100%;
  margin: 0;
}

html body[data-session-type] .chat-markdown .katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

html body[data-session-type] .chat-markdown .code-block {
  border-radius: 14px;
  overflow: hidden;
}

html body .code-block-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

html body .code-block-action {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b4b4b4;
  cursor: pointer;
}

html body .code-block-action:hover,
html body .code-block-action[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

html body .code-block-action svg {
  width: 14px;
  height: 14px;
}

html body .chat-stream-md:empty,
html body .chat-stream-tail:empty {
  display: none;
}

html body .chat-stream-tail > :last-child {
  margin-bottom: 0;
}

@media (max-width: 860px), (pointer: coarse) {
  html body[data-session-type] .chat-markdown .code-block {
    overflow: visible;
  }

  html body[data-session-type] .chat-markdown .code-block-head {
    border-radius: 14px 14px 0 0;
    overflow: visible;
  }

  html body[data-session-type] .chat-markdown .code-block pre {
    border-radius: 0 0 14px 14px;
  }

  html body .code-block-actions {
    gap: 14px;
  }

  html body .code-block-action,
  html body .chat-markdown .code-block-copy {
    position: relative;
  }

  html body .code-block-action {
    width: 30px;
    height: 28px;
  }

  html body .code-block-action::after,
  html body .chat-markdown .code-block-copy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: max(100%, 44px);
    height: max(100%, 44px);
  }
}

html body .code-block.is-wrapped pre,
html body .code-block.is-wrapped pre code {
  white-space: pre-wrap;
  word-break: break-word;
}

html body .chat-message-actions {
  flex-wrap: wrap;
}

html body[data-session-type] .chat-message-actions .chat-action-btn.chat-continue-btn {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  gap: 5px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
}

html body .empty-state p a,
html body .generation-details a {
  color: var(--gpt-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

html body[data-session-type] .model-option:hover,
html body[data-session-type] .model-option.is-selected,
html body[data-session-type] .chat-key-option:hover,
html body[data-session-type] .chat-key-option.is-active,
html body[data-session-type] .chat-model-option:hover,
html body[data-session-type] .chat-model-option.is-active,
html body[data-session-type] .chat-mode-option:hover,
html body[data-session-type] .chat-mode-option.is-active,
html body[data-session-type] .chat-reasoning-option:hover,
html body[data-session-type] .chat-reasoning-option.is-active {
  background: var(--gpt-hover);
}

html body[data-session-type="chat"] .send-btn.is-stop {
  box-shadow: none;
}

html body .composer-dock:has(.is-open, [aria-expanded="true"]) {
  z-index: calc(var(--z-dropdown) + 40);
}

html body .composer:has(textarea:focus-visible) {
  box-shadow: 0 0 0 2px var(--gpt-blue), var(--gpt-shadow-composer);
}

html body .composer textarea#promptInput:focus-visible {
  outline: none;
}

html body .scroll-bottom-btn {
  position: absolute;
  bottom: calc(var(--composer-dock-height, 124px) + 14px);
  right: 24px;
  z-index: 40;
}

html body .app-shell.has-canvas .scroll-bottom-btn {
  right: calc(var(--canvas-space, 430px) + 24px);
}

html body .attachment-preview-trigger {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

html body .attachment-order-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(15, 18, 22, 0.78);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}

html body .attachment-order-actions {
  position: absolute;
  left: 3px;
  top: 3px;
  display: inline-flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.14s ease;
  z-index: 2;
}

html body .attachment-chip:hover .attachment-order-actions,
html body .attachment-chip:focus-within .attachment-order-actions {
  opacity: 1;
}

@media (hover: none) {
  html body .attachment-order-actions {
    opacity: 1;
  }
}

html body .attachment-move-btn {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(15, 18, 22, 0.72);
  color: #fff;
  cursor: pointer;
}

html body .attachment-move-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

html body .attachment-move-btn svg {
  width: 12px;
  height: 12px;
}

html body .attachment-chip.is-file .attachment-order-actions {
  position: static;
  opacity: 1;
  flex: 0 0 auto;
}

html body .attachment-count-pill {
  align-self: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

html body .attachment-is-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.36);
  color: #fff;
}

html body .app-shell.is-dragging-files::after {
  content: "松开即可添加参考图或文件（最多 10 个）";
  position: fixed;
  inset: 24px;
  z-index: calc(var(--z-session-modal) - 10);
  display: grid;
  place-items: center;
  border: 2px dashed var(--gpt-blue);
  border-radius: 24px;
  background: rgba(1, 105, 204, 0.08);
  backdrop-filter: blur(4px);
  color: var(--gpt-blue);
  font-size: 18px;
  font-weight: 600;
  pointer-events: none;
}

html body .session-running-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--gpt-blue);
  vertical-align: middle;
  animation: luchiPulseDot 1.2s ease-in-out infinite;
}

html body .cost-preview.is-low-balance {
  color: var(--danger);
  font-weight: 650;
  cursor: pointer;
  text-decoration: underline dotted;
}

html body .image-result-action.is-primary-retry {
  background: var(--gpt-ink);
  border-color: var(--gpt-ink);
  color: var(--gpt-on-ink);
}

html body .image-result-action.is-primary-retry:hover {
  background: var(--gpt-ink-hover);
}

html[data-resolved-theme="dark"] body .chat-user .chat-bubble {
  background: #2f2f2f;
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .chat-thinking {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--gpt-line);
}

html[data-resolved-theme="dark"] body .chat-thinking summary,
html[data-resolved-theme="dark"] body .chat-thinking-body {
  color: var(--gpt-muted);
}

html[data-resolved-theme="dark"] body[data-session-type] .chat-message-actions .chat-action-btn,
html[data-resolved-theme="dark"] body[data-session-type] .chat-user-actions .chat-action-btn,
html[data-resolved-theme="dark"] body .topbar .topbar-theme-btn {
  color: var(--gpt-muted);
}

html[data-resolved-theme="dark"] body[data-session-type] .chat-message-actions .chat-action-btn:hover,
html[data-resolved-theme="dark"] body[data-session-type] .chat-user-actions .chat-action-btn:hover,
html[data-resolved-theme="dark"] body .topbar .topbar-theme-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .auth-card,
html[data-resolved-theme="dark"] body .session-settings-card,
html[data-resolved-theme="dark"] body .studio-modal-card,
html[data-resolved-theme="dark"] body .prompt-assist-card {
  background: var(--gpt-surface);
  border-color: var(--gpt-line);
  color: var(--gpt-ink);
}

html body :is(button, a, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid #2684ff;
  outline-offset: 2px;
}

@media (max-width: 860px) {
  html body[data-session-type] .empty-state .suggestion-grid {
    grid-template-columns: 1fr;
  }

  html body .topbar .topbar-theme-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  html body .composer .tool-pill,
  html body .composer .chat-mode-btn,
  html body .composer .chat-reasoning-btn,
  html body .composer .chat-tool-toggle,
  html body .style-chip,
  html body .image-library-filter,
  html body .image-result-action {
    min-height: 44px;
  }

  html body .image-library-head-tools {
    flex-wrap: nowrap;
    gap: 8px;
  }

  html body .image-library-filter {
    max-width: 44vw;
  }

  html body[data-session-type] .composer-dock {
    overflow: visible;
    padding-bottom: calc(10px + env(safe-area-inset-bottom) + var(--composer-keyboard-inset, 0px));
  }

  html body .composer [data-setting] .choice-menu.is-open,
  html body .composer .image-group-menu.is-open {
    position: fixed;
    left: 50%;
    right: auto;
    top: auto;
    bottom: calc(var(--composer-dock-offset, 120px) + 8px);
    transform: translateX(-50%);
    animation: none;
    width: min(360px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(62dvh, 420px);
    overflow-y: auto;
    z-index: calc(var(--z-dropdown) + 40);
  }

  html body .composer .image-group-menu[hidden] {
    display: none !important;
  }

  html body .topbar .top-more-menu,
  html body .topbar .chat-model-menu,
  html body .composer .chat-mode-menu,
  html body .composer .chat-reasoning-menu {
    max-width: calc(100vw - 20px);
    max-height: min(65dvh, 420px);
    overflow-y: auto;
  }

  html body[data-session-type] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  html body[data-session-type] .prompt-row textarea,
  html body[data-session-type] textarea,
  html body[data-session-type] select {
    font-size: 16px;
  }

  html body .chat-action-btn,
  html body .icon-btn,
  html body .mobile-menu,
  html body .image-actions .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  html body .style-drawer.is-open {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  html body .style-drawer .style-chip {
    width: 100%;
    justify-content: center;
    padding: 0 6px;
    white-space: nowrap;
  }

  html body .image-library-head-tools {
    flex-wrap: wrap;
  }

  html body .image-library-filter {
    flex: 1 1 132px;
    max-width: none;
  }
}

@media (max-width: 520px) {
  html body .image-lightbox-tools {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: calc(100vw - 88px);
    scrollbar-width: none;
    justify-content: flex-start;
    gap: 6px;
  }

  html body .image-lightbox-tools::-webkit-scrollbar {
    display: none;
  }

  html body .image-lightbox-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 10px;
    min-height: 36px;
    font-size: 12px;
  }
}

/* 460px 及以下窄屏顶栏防拥挤：隐藏与侧栏重复的主题按钮，完整显示品牌名与 24×24 Logo，统一 40-44px 触控热区 */
@media (max-width: 460px) {
  html body .app-shell:not(.is-guest) .workspace > .topbar,
  html body .workspace > .topbar {
    gap: 4px;
    padding: env(safe-area-inset-top) 6px 0 4px;
  }

  html body .app-shell:not(.is-guest) .topbar .topbar-theme-btn {
    display: none;
  }

  html body .topbar .brand-switch {
    min-width: 0;
    flex: 1 1 auto;
    gap: 4px;
  }

  html body .topbar .mobile-menu {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  html body .topbar .chat-model-btn,
  html body .topbar .model-control .model-menu-btn {
    max-width: min(196px, calc(100vw - 172px));
    min-height: 40px;
    height: 40px;
    padding: 0 6px;
    gap: 4px;
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body .topbar .top-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  html body .app-shell.is-guest .topbar #guestActions .studio-top-btn {
    padding: 0 7px;
  }

  html body .app-shell.is-guest .topbar #guestActions #loginOpenBtn,
  html body .app-shell.is-guest .topbar #guestActions #signupBtn {
    padding: 0 9px;
  }

  html body .topbar .balance-pill {
    min-height: 40px;
    height: 40px;
    padding: 0 8px;
    font-size: 12px;
  }

  html body .history-panel {
    width: min(304px, calc(100vw - 20px));
  }
}

html body .empty-state .guest-plaza-link {
  white-space: nowrap;
}

@media (max-width: 860px), (pointer: coarse) {
  html body .new-chat-wide,
  html body .sidebar-api-docs-btn,
  html body .history-panel .user-row,
  html body .history-panel .balance-card,
  html body .conversation-open,
  html body .history-filter {
    min-height: 44px;
  }

  html body .history-pack-actions .history-mini-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

html body .image-lightbox-stage,
html body .image-lightbox-img {
  touch-action: none;
}

html body .editing-context-banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  margin: 6px 10px 0;
  border-radius: 12px;
  background: var(--gpt-chip, var(--surface-soft));
  border: 1px solid var(--gpt-line, var(--line));
  font-size: 12.5px;
  color: var(--gpt-muted, var(--ink-soft));
}

html body .editing-context-banner[hidden] {
  display: none !important;
}

html body .editing-context-cancel {
  border: 0;
  background: transparent;
  color: var(--gpt-blue, var(--accent));
  font-size: 12.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}

html body .editing-context-cancel:hover {
  background: rgba(37, 99, 235, 0.1);
}

html body .guest-avatar-icon {
  display: block;
  flex-shrink: 0;
}

html body .empty-guest-hint {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--text-secondary, #64748b);
}

html body .empty-guest-hint a {
  color: var(--accent, #2563eb);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* 登录前按预置 token 标记避免访客按钮与默认头像闪烁 */
html[data-has-token="1"] #guestActions {
  visibility: hidden;
}

/* 2026-11-28 Studio audit F1-F11 UI components */
html body .image-group-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 28px;
  padding: 2px 6px 2px 10px;
  border: 1px solid var(--gpt-line);
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font-size: 12px;
  font-weight: 500;
}

html body .image-group-pill[hidden] {
  display: none !important;
}

html body .image-group-current-btn,
html body .image-group-current-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

html body .image-group-current-btn {
  cursor: pointer;
}

html body .image-group-current-btn span,
html body .image-group-current-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

html body .image-group-current-btn svg,
html body .image-group-current-btn i {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  color: var(--gpt-muted);
}

html body .image-group-switch-btn {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

html body .image-group-switch-btn:hover {
  background: var(--gpt-ink-hover);
}

html body .image-group-switch-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

html body .image-group-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: calc(var(--z-dropdown) + 40);
  display: grid;
  gap: 2px;
  min-width: min(290px, calc(100vw - 32px));
  max-width: min(360px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--gpt-line);
  border-radius: 14px;
  background: var(--gpt-surface);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
}

html body .image-group-menu[hidden] {
  display: none;
}

html[data-resolved-theme="dark"] body .image-group-menu {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

html body .image-group-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gpt-ink);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

html body .image-group-option:hover,
html body .image-group-option.is-selected {
  background: var(--gpt-hover);
}

html body .image-group-option-name em {
  font-style: normal;
  font-size: 11px;
  color: var(--gpt-muted);
  margin-left: 4px;
}

html body .image-group-option small {
  flex: 0 0 auto;
  color: var(--gpt-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

html body .cost-tier-note {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(180, 84, 10, 0.1);
  color: #b4540a;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

html body .cost-tier-note[hidden] {
  display: none !important;
}

html[data-resolved-theme="dark"] body .cost-tier-note {
  background: rgba(240, 163, 94, 0.14);
  color: #f0a35e;
}

html body .image-notify-prompt {
  grid-area: notify;
  grid-column: 1 / -1;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
  padding: 8px 12px;
  border: 1px solid var(--gpt-line);
  border-radius: 12px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font-size: 12.5px;
}

html body .image-notify-prompt[hidden] {
  display: none !important;
}

html body .image-notify-prompt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

html body .image-notify-btn {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--gpt-input-border);
  border-radius: 999px;
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

html body .image-notify-btn.is-accept {
  border-color: var(--gpt-ink);
  background: var(--gpt-ink);
  color: var(--gpt-on-ink);
}

html body .image-result-action.is-stop-remaining {
  border-color: rgba(208, 58, 47, 0.35);
  color: #c62828;
}

html[data-resolved-theme="dark"] body .image-result-action.is-stop-remaining {
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

html body .generation-stop-note {
  margin: 4px 0 8px;
  color: var(--gpt-muted);
  font-size: 12.5px;
}

html body .generation-route-note {
  margin: 6px 0 0;
  color: var(--gpt-muted);
  font-size: 12px;
  line-height: 1.5;
}

html body .image-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 10px;
}

html body .external-image-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  padding: 8px 12px;
  border: 1px dashed var(--gpt-input-border);
  border-radius: 10px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

html body .external-image-placeholder:hover {
  background: var(--gpt-hover);
}

html body .generation-brief-status[data-status="cancelled"] {
  color: var(--gpt-muted);
}

html body .generation-status-dot[data-status="cancelled"] {
  background: var(--gpt-faint);
}

html body .custom-size-control,
html body .composer .setting-control.custom-size-control,
html body[data-session-type] .composer .setting-control.custom-size-control,
html body[data-session-type="image"] .composer .setting-control.custom-size-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--gpt-input-border);
  border-radius: 14px;
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  font-size: 12.5px;
  white-space: normal;
  box-sizing: border-box;
}

html body .custom-size-control[hidden],
html body .composer .setting-control.custom-size-control[hidden],
html body[data-session-type] .composer .setting-control.custom-size-control[hidden],
html body[data-session-type="image"] .composer .setting-control.custom-size-control[hidden] {
  display: none !important;
}

html body .custom-size-control > span:first-child {
  color: var(--gpt-muted);
  font-size: 12px;
  white-space: nowrap;
}

html body .custom-size-inputs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

html body .custom-size-inputs input {
  width: 68px;
  min-width: 0;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--gpt-line);
  border-radius: 7px;
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

html body .custom-size-inputs input:focus {
  outline: none;
  border-color: var(--gpt-ink);
  background: var(--gpt-surface);
}

html body .custom-size-inputs input::-webkit-outer-spin-button,
html body .custom-size-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

html body .custom-size-swap-btn,
html body .custom-size-lock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--gpt-muted);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

html body .custom-size-swap-btn:hover,
html body .custom-size-lock-btn:hover {
  border-color: var(--gpt-line);
  background: var(--gpt-chip);
  color: var(--gpt-ink);
}

html body .custom-size-lock-btn.is-locked {
  border-color: var(--gpt-blue, #0a6542);
  background: var(--gpt-blue-soft, rgba(16, 163, 127, 0.12));
  color: var(--gpt-blue, #0a6542);
}

html body .custom-size-fix-btn {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(198, 40, 40, 0.35);
  border-radius: 999px;
  background: rgba(198, 40, 40, 0.08);
  color: #c62828;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

html body .custom-size-fix-btn[hidden] {
  display: none !important;
}

html body .custom-size-fix-btn:hover {
  background: rgba(198, 40, 40, 0.14);
}

html body .custom-size-presets {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

html body .custom-size-preset-btn {
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--gpt-line);
  border-radius: 999px;
  background: var(--gpt-chip);
  color: var(--gpt-muted);
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
}

html body .custom-size-preset-btn:hover {
  border-color: var(--gpt-input-border);
  color: var(--gpt-ink);
}

html body .custom-size-preset-btn.is-active {
  border-color: var(--gpt-blue, #0a6542);
  background: var(--gpt-blue-soft, rgba(16, 163, 127, 0.12));
  color: var(--gpt-blue, #0a6542);
  font-weight: 600;
}

html body .custom-size-hint {
  color: var(--gpt-muted);
  font-size: 11.5px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}

html body .custom-size-hint:empty {
  display: none;
}

html body .custom-size-hint.is-error {
  color: #c62828;
}

html[data-resolved-theme="dark"] body .custom-size-control {
  background: var(--gpt-surface);
  border-color: var(--gpt-input-border);
}

html[data-resolved-theme="dark"] body .custom-size-inputs input {
  background: var(--gpt-chip);
  border-color: var(--gpt-line);
  color: var(--gpt-ink);
}

html[data-resolved-theme="dark"] body .custom-size-fix-btn {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.14);
  color: #f87171;
}

html[data-resolved-theme="dark"] body .custom-size-hint.is-error {
  color: #f87171;
}

@media (max-width: 860px) {
  html body .custom-size-control,
  html body .composer .setting-control.custom-size-control,
  html body[data-session-type] .composer .setting-control.custom-size-control,
  html body[data-session-type="image"] .composer .setting-control.custom-size-control {
    display: flex;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    white-space: normal;
    border-radius: 12px;
    padding: 6px 8px;
  }

  html body .custom-size-control[hidden],
  html body .composer .setting-control.custom-size-control[hidden],
  html body[data-session-type] .composer .setting-control.custom-size-control[hidden],
  html body[data-session-type="image"] .composer .setting-control.custom-size-control[hidden] {
    display: none !important;
  }

  html body .custom-size-control .custom-size-inputs {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }

  html body[data-session-type] .custom-size-inputs input,
  html body .custom-size-inputs input {
    width: 78px;
    height: 32px;
    font-size: 16px;
  }

  html body .custom-size-swap-btn,
  html body .custom-size-lock-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  html body .custom-size-presets,
  html body .custom-size-control .custom-size-presets {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }

  html body .custom-size-hint,
  html body .custom-size-control .custom-size-hint {
    display: block;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  html body .image-group-pill {
    max-width: 100%;
  }

  html body .image-group-current-btn span,
  html body .image-group-current-text {
    max-width: 180px;
  }

  html body .image-notify-prompt {
    flex-direction: column;
    align-items: flex-start;
  }
}

#confirmModal,
#confirmModal.studio-modal {
  z-index: var(--z-confirm-modal);
}

html body .image-user-doc-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, 100%);
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid var(--gpt-line);
  background: var(--gpt-surface);
  color: var(--gpt-ink);
}

html body .image-user-doc-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(1, 105, 204, 0.12);
  color: var(--gpt-blue);
}

html body .image-user-doc-icon svg {
  width: 18px;
  height: 18px;
}

html body .image-user-doc-meta {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 2px;
}

html body .image-user-doc-meta strong {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body .image-user-doc-meta small {
  font-size: 11.5px;
  color: var(--gpt-muted);
}

html body .image-user-doc-badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--gpt-chip);
  border: 1px solid var(--gpt-line);
  font-size: 11px;
  font-weight: 600;
  color: var(--gpt-muted);
}

html body .attachment-edit-btn {
  position: absolute;
  left: 3px;
  bottom: 3px;
  z-index: 2;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: rgba(15, 18, 22, 0.76);
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

html body .attachment-edit-btn:hover {
  background: rgba(15, 18, 22, 0.92);
}

html body .attachment-edit-btn svg {
  width: 11px;
  height: 11px;
}

html body .attachment-mask-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 2;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(1, 105, 204, 0.9);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  pointer-events: none;
}

html body .image-expiry-badge,
html body .image-library-expiry-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(180, 83, 9, 0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

html body .image-library-toggle-btn {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--gpt-line);
  background: var(--gpt-chip);
  color: var(--gpt-ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

html body .image-library-toggle-btn[aria-pressed="true"] {
  border-color: var(--gpt-blue);
  background: rgba(1, 105, 204, 0.12);
  color: var(--gpt-blue);
  font-weight: 600;
}

html body .image-library-batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gpt-line);
  background: var(--gpt-chip);
}

html body .image-library-batch-bar[hidden] {
  display: none;
}

html body .image-library-batch-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--gpt-ink);
}

html body .image-library-batch-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

html body .image-library-tile {
  position: relative;
}

html body .image-library-tile.is-selecting {
  cursor: pointer;
}

html body .image-library-tile.is-selecting.is-expired {
  cursor: not-allowed;
  opacity: 0.72;
}

html body .image-library-tile.is-selecting:focus-visible {
  outline: 2px solid var(--gpt-blue);
  outline-offset: 2px;
}

html body .image-library-tile.is-selected {
  outline: 2.5px solid var(--gpt-blue);
  outline-offset: -2px;
}

html body .image-library-tile-select {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 3;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: rgba(15, 18, 22, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

html body .image-library-tile.is-selected .image-library-tile-select {
  background: var(--gpt-blue);
}

html body .image-library-tile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

html body .image-mask-modal-card {
  width: min(720px, calc(100vw - 24px));
  max-height: min(92dvh, 840px);
}

html body .image-mask-editor-body {
  display: grid;
  gap: 10px;
}

html body .image-mask-mode-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--gpt-chip);
  width: fit-content;
}

html body .image-mask-tab {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--gpt-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

html body .image-mask-tab.is-active {
  background: var(--gpt-surface);
  color: var(--gpt-ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

html body .image-mask-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

html body .image-mask-toolbar[hidden] {
  display: none;
}

html body .image-mask-slider-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gpt-ink);
}

html body .image-mask-crop-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

html body .image-mask-stage {
  position: relative;
  width: 100%;
  min-height: 220px;
  max-height: min(52dvh, 460px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--gpt-line);
  background: repeating-conic-gradient(rgba(128, 128, 128, 0.1) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  touch-action: none;
}

html body .image-mask-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(50dvh, 440px);
  border-radius: 8px;
  user-select: none;
}

html body .image-mask-canvas.is-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: crosshair;
  touch-action: none;
}

@media (max-width: 860px), (pointer: coarse) {
  html body .attachment-chip {
    width: 124px;
    height: 124px;
  }

  html body .attachment-order-actions {
    gap: 6px;
  }

  html body .attachment-move-btn,
  html body .attachment-chip-remove,
  html body .attachment-edit-btn {
    min-width: 44px;
    min-height: 44px;
  }

  html body .attachment-edit-btn {
    padding: 0 10px;
  }

  html body .custom-size-inputs {
    gap: 8px;
  }

  html body .custom-size-swap-btn,
  html body .custom-size-lock-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  html body .custom-size-preset-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 6px 12px;
  }

  html body .image-group-switch-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
  }

  html body .image-mask-tab,
  html body .image-mask-toolbar .outline-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
  }

  html body .toast-action-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
  }

  html body .image-lightbox-btn,
  html body .image-lightbox-close {
    min-width: 44px;
    min-height: 44px;
  }

  html body .conversation-mini,
  html body .conversation-delete {
    min-width: 40px;
    min-height: 40px;
  }

  html body .image-library-actions .icon-btn,
  html body[data-session-type] .chat-message-actions .chat-action-btn.chat-continue-btn,
  html body .chat-continue-btn {
    min-width: 44px;
    min-height: 44px;
    height: auto;
  }
}

html body .cost-preview {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 2px 6px;
  border-radius: 999px;
}

html body .cost-preview:disabled {
  cursor: default;
  opacity: 1;
}

html body .cost-preview.is-low-balance {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

html body .sidebar-studio-btn {
  text-decoration: none;
}

html body .sidebar-studio-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

html body .topbar .studio-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-decoration: none;
  font-weight: 600;
  color: inherit;
  border-color: rgba(15, 23, 42, 0.22);
  background: rgba(15, 23, 42, 0.05);
}

html body .topbar .studio-top-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

html[data-resolved-theme="dark"] body .topbar .studio-top-btn {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #f4f4f5;
}

@media (min-width: 861px) {
  html body .topbar .studio-top-btn .studio-top-label-short {
    display: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --gpt-line: #8c8c8c;
    --gpt-input-border: #595959;
    --gpt-muted: #2f2f2f;
    --gpt-faint: #454545;
  }

  :root[data-resolved-theme="dark"] {
    --gpt-line: rgba(255, 255, 255, 0.34);
    --gpt-input-border: #8c8c8c;
    --gpt-muted: #dedede;
    --gpt-faint: #c9c9c9;
  }

  :focus-visible {
    outline: 2px solid var(--gpt-blue) !important;
    outline-offset: 2px !important;
  }
}
