:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --duration-press: 140ms;
  --duration-fast: 160ms;
  --duration-panel: 240ms;
  --blue-shadow: 0 16px 40px rgba(24, 32, 48, 0.06);
}

body.home-page,
body.image-page,
body.publish-page,
body.results-page,
body.settings-page,
body.mobile-upload-page,
body.mobile-share-page,
body.admin-page {
  background: var(--bg);
}

.topbar {
  background: rgba(255, 255, 255, 0.96);
  border-bottom-color: var(--line);
  box-shadow: 0 4px 18px rgba(24, 32, 48, 0.04);
}

.tab,
.settings-button,
.history-button,
.card-tab {
  color: var(--soft-ink);
  background: transparent;
}

.tab:hover,
.settings-button:hover,
.history-button:hover,
.card-tab:hover,
.tab.active,
.settings-button.active,
.history-button.active,
.card-tab.active {
  color: var(--red);
  background: var(--red-soft);
}

.primary,
.simple-auth .primary,
.image-ai-button {
  background: linear-gradient(180deg, #3b91ff, var(--red));
  box-shadow: 0 12px 26px rgba(22, 119, 255, 0.22);
}

.primary:hover,
.simple-auth .primary:hover,
.image-ai-button:hover {
  background: linear-gradient(180deg, #2b83f2, var(--red-dark));
}

.secondary-action,
.ghost-button,
.settings-head button,
.history-button,
.image-toggle-button,
.text-toggle-button {
  border-color: #d7e4f3;
  background: #ffffff;
  color: var(--red);
}

.secondary-action:hover,
.ghost-button:hover,
.settings-head button:hover,
.history-button:hover,
.image-toggle-button:hover,
.text-toggle-button:hover {
  border-color: #9fc3ef;
  background: var(--red-soft);
  color: var(--red-dark);
}

.link-card,
.note-card,
.empty-card,
.job-prompt-card,
.image-generator-card,
.image-session-composer,
.image-job-card,
.publish-mini-card,
.single-image-card,
.settings-card,
.admin-panel,
.admin-metric-card,
.admin-config-card,
.mobile-upload-card-main,
.image-history-card,
.prompt-card,
.prompt-template-item.active,
.publish-qr-panel {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--blue-shadow);
}

.collect-panel-hidden {
  display: none !important;
}

.app-store-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 22px 26px 0;
}

.app-store-country-label {
  display: grid;
  gap: 6px;
  color: var(--soft-ink);
  font-size: 13px;
  white-space: nowrap;
}

.app-store-country-label select,
.app-store-search-row input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

.app-store-search-row .primary {
  min-height: 44px;
  padding-inline: 24px;
}

.app-store-hint {
  margin: 12px 26px 0;
  color: var(--soft-ink);
  font-size: 13px;
}

.app-store-hint.bad {
  color: #df4237;
}

.app-store-results {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  margin: 16px 26px 0;
}

.app-store-result {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.app-store-result:hover {
  border-color: #9fc3ef;
  background: #f7fbff;
}

.app-store-result img,
.app-store-detail-head img {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  object-fit: cover;
  background: #eef3f8;
}

.app-store-result-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.app-store-result-copy strong,
.app-store-result-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-store-result-copy small,
.app-store-rating,
.app-store-meta,
.app-store-copyright {
  color: var(--soft-ink);
  font-size: 12px;
}

.app-store-rating {
  white-space: nowrap;
}

.app-store-empty {
  padding: 24px;
  color: var(--soft-ink);
  text-align: center;
}

.app-store-detail {
  margin: 18px 26px 26px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.app-store-detail-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.app-store-detail-head img {
  width: 64px;
  height: 64px;
  border-radius: 15px;
}

.app-store-detail-head h3 {
  margin: 0 0 5px;
}

.app-store-detail-head p,
.app-store-description {
  margin: 4px 0 0;
  color: var(--soft-ink);
  line-height: 1.65;
}

.app-store-availability-trigger {
  margin-left: 4px;
  padding: 1px 0;
  border: 0;
  border-bottom: 1px dashed #86abd7;
  color: #397bb8;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
}

.app-store-availability-trigger:hover,
.app-store-availability-trigger:focus-visible {
  border-bottom-style: solid;
  color: #17639f;
  outline: none;
}

.app-store-availability-trigger:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-store-availability:empty {
  display: none;
}

.app-store-availability {
  margin-top: 13px;
  padding: 11px 12px;
  border: 1px solid #d9e7f4;
  border-radius: 10px;
  background: #f7fbff;
}

.app-store-availability-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 9px;
  color: var(--ink);
  font-size: 12px;
}

.app-store-availability-head span,
.app-store-availability-loading,
.app-store-availability-error {
  color: var(--soft-ink);
  font-size: 11px;
}

.app-store-availability-error {
  color: #d44d42;
}

.app-store-availability-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.app-store-country-chip {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid #dbe2e9;
  border-radius: 7px;
  color: #77818d;
  background: #fff;
  font-size: 11px;
  line-height: 1;
}

.app-store-country-chip b,
.app-store-country-chip em {
  font: inherit;
  white-space: nowrap;
}

.app-store-country-chip em {
  font-size: 10px;
  font-style: normal;
}

.app-store-country-chip.available {
  border-color: #a9ddbd;
  color: #247a48;
  background: #f0fcf4;
}

.app-store-country-chip.unavailable {
  color: #8a9199;
  background: #fbfcfd;
}

.app-store-country-chip.unknown {
  border-color: #efd7a7;
  color: #9b6e24;
  background: #fff9ee;
}

.app-store-description {
  max-height: 150px;
  overflow: auto;
  white-space: pre-line;
}

.app-store-screenshots {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 14px;
  padding-bottom: 4px;
}

.app-store-screenshots img {
  flex: 0 0 auto;
  width: 92px;
  height: 164px;
  border: 1px solid var(--line);
  border-radius: 9px;
  object-fit: contain;
  background: #eef3f8;
}

.app-store-screenshot-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 92px;
  height: 164px;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #eef3f8;
  cursor: zoom-in;
}

.app-store-screenshot-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  object-fit: contain;
}

.app-store-screenshot-thumb span {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 3px 5px;
  border-radius: 5px;
  color: #fff;
  background: rgba(20, 28, 42, 0.72);
  font-size: 10px;
  line-height: 1;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.app-store-screenshot-thumb:hover span,
.app-store-screenshot-thumb:focus-visible span {
  opacity: 1;
  transform: translateY(0);
}

.app-store-lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.app-store-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 16, 28, 0.76);
  backdrop-filter: blur(7px);
}

.app-store-lightbox-panel {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(900px, 100%);
  height: min(900px, calc(100vh - 48px));
}

.app-store-lightbox-image {
  display: block;
  max-width: min(78vw, 760px);
  max-height: calc(100vh - 96px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
}

.app-store-lightbox-close,
.app-store-lightbox-nav {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 0;
  color: #fff;
  background: rgba(15, 24, 38, 0.72);
}

.app-store-lightbox-close {
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 25px;
}

.app-store-lightbox-nav {
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translateY(-50%);
  font-size: 35px;
  line-height: 1;
}

.app-store-lightbox-nav.prev { left: 0; }
.app-store-lightbox-nav.next { right: 0; }

.app-store-lightbox-counter {
  position: absolute;
  bottom: 0;
  left: 50%;
  padding: 6px 11px;
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 24, 38, 0.72);
  font-size: 12px;
  font-weight: 800;
  transform: translateX(-50%);
}

.app-store-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.app-store-detail-actions button,
.app-store-detail-actions a {
  min-height: 40px;
}

.app-store-copyright {
  margin: 14px 0 0;
}

.collect-upload-placeholder {
  padding: 48px 26px;
  color: var(--soft-ink);
  text-align: center;
}

.card-tabs,
.prompt-footer,
.detail-footer,
.image-options-row,
.image-job-meta,
.image-job-actions {
  border-color: var(--line);
  background: #ffffff;
}

.compose-statusbar {
  justify-content: flex-end;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.compose-statusbar .status-right {
  justify-content: flex-end;
}

.field-block,
.images-block,
.compose-input,
.compose-textarea,
.tag-editor,
.image-manager-grid,
.single-image-body textarea,
.reference-upload > button,
.image-history-thumb,
.image-job-stage,
.detail-image-stage,
.qr-image-wrap,
.mobile-upload-status {
  border-color: var(--line);
  background: var(--panel-strong);
}

.simple-auth.login-page {
  background:
    radial-gradient(circle at 48% 42%, rgba(255, 255, 255, 0.7), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #edf4fb 100%);
}

.simple-auth.login-page::before {
  background:
    linear-gradient(90deg, rgba(148, 176, 210, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(148, 176, 210, 0.16) 1px, transparent 1px);
  opacity: 0.42;
}

.simple-auth.login-page::after {
  background: radial-gradient(circle, rgba(22, 119, 255, 0.12), transparent 62%);
}

.simple-auth .auth-card {
  border-color: #dfe9f5;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 72px rgba(24, 32, 48, 0.1);
}

.simple-auth .auth-title,
.simple-auth .login-form label {
  color: var(--ink);
}

.simple-auth .auth-subtitle,
.simple-auth .auth-toggle {
  color: var(--soft-ink);
}

.simple-auth .login-form input {
  border-color: var(--line);
  background: #ffffff;
}

.simple-auth .login-form input::placeholder {
  color: #9aa8b8;
}

.simple-auth .login-form input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.12);
}

.simple-auth .secondary-action {
  border-color: #cfe0f4;
  background: var(--red-soft);
  color: var(--red);
}

.admin-page,
.admin-sidebar {
  background: var(--bg);
}

.admin-sidebar {
  border-right-color: var(--line);
}

.admin-table tbody tr:hover,
.admin-table tbody tr.selected {
  background: var(--red-soft);
}

.admin-status-pill.bad,
.mobile-upload-page-status.error {
  background: #fff1f0;
  color: #d4382f;
}

.admin-status-pill.good,
.publish-mini-card .mini-foot em {
  background: #eaf8ef;
  color: #197a3b;
}

.editor-image-card.drag-over,
.image-manager-grid.upload-drag-over,
.mobile-drop-area.dragging {
  background: var(--red-soft);
  border-color: #9fc3ef;
}

.editor-image-card.selected .editor-thumb,
.editor-image-card:hover .editor-thumb {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

.editor-thumb {
  display: grid;
  place-items: center;
  height: auto;
  min-height: 118px;
  max-height: none;
  overflow: hidden;
  background: #f8fbff;
}

.editor-thumb img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}

.image-card-footer {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 118px;
  min-height: 30px;
  padding: 2px 0;
  background: var(--panel-strong);
}

.image-ratio-text {
  min-width: 0;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.image-card-footer .image-toggle-button,
.image-card-footer .origin-label {
  flex: 0 0 auto;
}

.image-card-footer .image-toggle-button {
  position: relative;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 8px;
  white-space: nowrap;
}

.editor-image-card:hover,
.editor-image-card.selected:hover {
  background: linear-gradient(180deg, #edf5ff, #f8fbff);
  box-shadow: 0 16px 32px rgba(22, 119, 255, 0.14);
}

.editor-image-card:hover .editor-thumb img {
  filter: brightness(0.78) saturate(0.96);
  transform: none;
}

/* Keep the image action anchored to a stable thumbnail box. */
.editor-thumb-wrap {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 118px;
  height: 154px;
  min-width: 118px;
  min-height: 154px;
  flex: 0 0 154px;
}

.editor-thumb-wrap .editor-thumb {
  width: 118px;
  height: 154px;
  min-height: 0;
  max-height: none;
  box-sizing: border-box;
  overflow: hidden;
}

.editor-thumb-wrap .editor-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-ai-button {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78px;
  height: 30px;
  min-width: 78px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, background 160ms ease;
}

.editor-thumb-wrap:hover .image-ai-button,
.editor-thumb-wrap:focus-within .image-ai-button {
  opacity: 1;
  pointer-events: auto;
}

.editor-image-card.loading .image-ai-button {
  opacity: 1;
  pointer-events: none;
  cursor: wait;
}

/* Keep the action anchored while hover, focus, and loading state change. */
.editor-image-card,
.editor-image-card:hover,
.editor-image-card.selected:hover,
.editor-thumb,
.editor-image-card:hover .editor-thumb,
.editor-thumb img,
.editor-image-card:hover .editor-thumb img {
  transform: none !important;
}

.editor-image-card.loading .image-ai-button {
  transform: translate(-50%, -50%) !important;
}

.image-ai-label {
  white-space: nowrap;
}

.image-ai-loading {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.editor-image-card.loading .image-ai-label {
  display: none;
}

.editor-image-card.loading .image-ai-loading {
  display: block;
}

/* Manual image editor */
.image-viewer-stage.editor-active {
  width: min(1440px, calc(100vw - 28px)) !important;
  max-width: none;
  height: min(900px, calc(100vh - 44px)) !important;
  padding: 0;
  border-radius: 0;
  background: transparent;
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 12px;
}

.image-editor-canvas {
  display: block;
  max-width: 100%;
  max-height: min(68vh, 680px);
  width: auto;
  height: auto;
  touch-action: none;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  background: #fff;
}

.tui-image-editor-host {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  order: 2;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
}

.tui-image-editor-host.hidden { display: none; }
.tui-image-editor-host .tui-image-editor-container { height: 100%; }
.tui-image-editor-host .tui-image-editor-wrap { display: flex; align-items: flex-start; justify-content: center; }
.tui-image-editor-host .tui-image-editor-size-wrap,
.tui-image-editor-host .tui-image-editor-align-wrap { display: flex !important; align-items: flex-start; justify-content: center; }
.tui-image-editor-host .tui-image-editor-main { top: 0; }
.tui-image-editor-host .tui-image-editor-menu { background: #202631; }
.tui-image-editor-host .tui-image-editor-controls { display: none; }

.image-editor-panel {
  position: relative;
  z-index: 3;
  width: 320px;
  max-width: 100%;
  max-height: 100%;
  align-self: flex-start;
  margin-top: 6px;
  flex: 0 0 320px;
  order: 1;
  overflow-y: auto;
  color: #1f2937;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
  padding: 10px 12px;
}

.image-editor-tools,
.image-editor-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.image-editor-tools { align-content: flex-start; }
.editor-text-controls { width: 100%; }

.editor-tool-group { display: flex; gap: 4px; }
.editor-text-controls,
.editor-brush-controls,
.editor-inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.editor-template-picker { width: 100%; margin-top: 3px; padding-top: 8px; border-top: 1px solid #edf0f5; }
.editor-template-picker-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; color: #344054; font-size: 12px; }
.editor-template-picker-head span { color: #98a2b3; }
.editor-template-grid { display: grid; grid-template-columns: repeat(8, minmax(88px, 1fr)); gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.editor-template-card { min-height: 58px; display: grid; place-items: center; gap: 4px; padding: 7px 6px 5px; border: 1px solid #e1e7ef; border-radius: 8px; background: #20232b; color: #fff; cursor: pointer; transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.editor-template-card:hover { transform: translateY(-1px); border-color: #8dbdff; }
.editor-template-card.active { border-color: #1677ff; box-shadow: 0 0 0 2px rgba(22,119,255,.16); }
.editor-template-card small { color: #cbd5e1; font-size: 10px; white-space: nowrap; }
.template-sample { display: inline-block; max-width: 100%; overflow: hidden; font-size: 17px; line-height: 1.15; white-space: nowrap; }
.template-plain { color: #fff; font-weight: 700; }
.template-title { color: #fff; font-size: 18px; font-weight: 900; text-shadow: 2px 2px 0 #111827, -1px -1px 0 #111827; }
.template-outline { color: #fff; font-weight: 900; -webkit-text-stroke: 2px #e56b35; text-shadow: 0 2px 0 #e56b35; }
.template-label { padding: 5px 8px; border-radius: 999px; background: #ef6c35; color: #fff; font-weight: 700; }
.template-magazine { color: #fef08a; font-family: Georgia, serif; font-size: 20px; font-weight: 900; }
.template-soft { padding: 5px 8px; border-radius: 6px; background: #fef3c7; color: #172033; font-weight: 700; }
.template-neon { color: #67e8f9; font-weight: 900; text-shadow: 0 0 5px #22d3ee, 0 0 10px #2563eb; }
.template-handwritten { color: #f9a8d4; font-family: KaiTi, STKaiti, cursive; font-size: 18px; transform: rotate(-4deg); }
.editor-text-content input { width: 180px; }
.wechat-text-style-row { display: flex; align-items: flex-start; gap: 10px; width: 100%; min-height: 42px; padding: 8px 0 4px; border-top: 1px solid #edf0f5; }
.wechat-text-mode {
  width: 34px; height: 34px; flex: 0 0 34px; border: 0; border-radius: 7px;
  background: transparent; color: #fff; font: 800 25px/1 Arial, sans-serif;
  cursor: pointer; text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.wechat-text-mode.mode-outline { -webkit-text-stroke: 3px #111827; color: var(--text-mode-color, #fff); }
.wechat-text-mode.mode-background { color: #fff; background: var(--text-mode-color, #1677ff); font-size: 22px; border-radius: 9px; }
.wechat-text-mode.mode-solid { color: var(--text-mode-color, #fff); font-weight: 900; }
.wechat-text-mode:hover { transform: translateY(-1px); }
.wechat-color-swatches { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; min-width: 0; padding: 3px 2px 5px; }
.wechat-color-swatch {
  width: 30px; height: 30px; flex: 0 0 30px; padding: 0; border: 3px solid #fff; border-radius: 50%;
  background: var(--swatch-color); box-shadow: 0 0 0 1px rgba(16,24,40,.18); cursor: pointer;
}
.wechat-color-swatch.active { box-shadow: 0 0 0 2px #1677ff, 0 0 0 4px rgba(22,119,255,.18); }
.editor-text-controls .editor-add-text { width: 100%; min-height: 38px; margin-top: 6px; white-space: nowrap; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.editor-add-text { border-color: #1677ff; color: #1677ff; font-weight: 700; }
.editor-inline-actions { margin-left: auto; }
.editor-toggle { min-width: 30px; height: 30px; border: 1px solid #d8e0eb; border-radius: 6px; background: #fff; color: #344054; font-weight: 800; }
.editor-toggle[aria-pressed="true"] { border-color: #1677ff; background: #eef6ff; color: #1677ff; }
.editor-control output { min-width: 30px; color: #667085; font-variant-numeric: tabular-nums; }
.editor-mode-button,
.editor-secondary,
.editor-primary,
.editor-stickers button {
  min-height: 32px;
  border: 1px solid #d8e0eb;
  border-radius: 7px;
  background: #fff;
  color: #344054;
  padding: 5px 10px;
  font-size: 13px;
}
.editor-mode-button.active { color: #fff; border-color: #1677ff; background: #1677ff; }
.editor-control { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.editor-control input[type="text"] { width: 160px; height: 32px; border: 1px solid #d8e0eb; border-radius: 6px; padding: 0 8px; }
.editor-control select { height: 32px; border: 1px solid #d8e0eb; border-radius: 6px; background: #fff; padding: 0 5px; }
.editor-control input[type="color"] { width: 32px; height: 30px; padding: 2px; border: 1px solid #d8e0eb; border-radius: 6px; }
.editor-stickers { display: flex; gap: 4px; }
.editor-stickers button { min-width: 34px; padding: 3px; font-size: 18px; }
.image-editor-actions { justify-content: flex-end; margin-top: 9px; padding-top: 9px; border-top: 1px solid #edf0f5; }
.editor-primary { border-color: #1677ff; color: #fff; background: #1677ff; font-weight: 700; }
.viewer-tool.edit { left: 12px; font-size: 17px; }
.image-editor-panel.hidden,
.image-editor-canvas.hidden { display: none; }

.image-editor-panel { max-height: 100%; overflow: auto; }

.editor-thumb-wrap:hover .image-ai-button,
.editor-thumb-wrap:focus-within .image-ai-button {
  opacity: 1;
  pointer-events: auto;
}

.image-icon-button.delete {
  background: rgba(212, 56, 47, 0.92);
}

.image-job-loader i,
.image-spinner {
  border-color: #cfe0f4;
  border-top-color: var(--red);
}

.image-preview-modal {
  opacity: 1;
  transition: opacity var(--duration-panel) var(--ease-out);
}

.image-preview-backdrop {
  opacity: 1;
  transition: opacity var(--duration-panel) var(--ease-out);
}

.image-preview-target {
  opacity: 1;
  transform: scale(1);
  transition:
    opacity var(--duration-panel) var(--ease-out),
    transform var(--duration-panel) var(--ease-out);
}

@starting-style {
  .image-preview-modal:not(.hidden) {
    opacity: 0;
  }

  .image-preview-modal:not(.hidden) .image-preview-backdrop {
    opacity: 0;
  }

  .image-preview-modal:not(.hidden) .image-preview-target {
    opacity: 0;
    transform: scale(0.97);
  }
}

.image-job-card-enter {
  animation: imageJobCardEnter 240ms var(--ease-out) both;
}

@keyframes imageJobCardEnter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

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

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):active,
  a.primary:active,
  .ghost-button:active,
  .secondary-action:active,
  .settings-button:active,
  .history-button:active,
  .image-toggle-button:active,
  .text-toggle-button:active {
    transform: scale(0.97);
    transition: transform var(--duration-press) var(--ease-out);
  }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(22, 119, 255, 0.22);
  outline-offset: 3px;
}

@media (hover: none), (pointer: coarse) {
  .editor-image-card:hover,
  .editor-image-card.selected:hover {
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  .editor-image-card:hover .editor-thumb {
    border-color: var(--line);
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  .editor-image-card:hover .editor-thumb img,
  .image-history-thumb:hover img {
    filter: none;
    transform: none;
  }

  .upload-card:hover {
    border-color: var(--line);
    background: #ffffff;
    box-shadow: none;
    transform: none;
  }

  .editor-image-card:focus-within .image-ai-button,
  .editor-image-card:focus-within .image-card-tools {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .image-session-composer {
    position: sticky;
    left: auto;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: 100%;
    max-height: min(48vh, 360px);
    margin-top: 20px;
    overflow-y: auto;
    transform: none;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .image-session-composer textarea {
    max-height: 132px;
    resize: vertical;
  }

  .image-result-shell {
    padding-bottom: 40px;
  }

  .image-composer-actions {
    justify-content: stretch;
  }

  .image-composer-actions > * {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-page::before,
  .login-orb,
  .image-job-loader i,
  .image-spinner {
    animation: none !important;
  }

  .image-job-card-enter {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  .image-preview-modal,
  .image-preview-backdrop,
  .image-preview-target {
    transition: opacity 200ms ease !important;
  }

  .image-preview-target {
    transform: none !important;
  }

  .editor-image-card:hover,
  .editor-image-card:hover .editor-thumb,
  .editor-image-card:hover .editor-thumb img,
  .image-history-thumb:hover img {
    transform: none !important;
    filter: none !important;
  }
}

/* Image generation result actions stay quiet until the card is inspected. */
.image-result-page .image-result-shell {
  padding-top: 38px;
}

.image-result-page .image-result-head {
  display: none;
}

.image-result-page .image-job-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  overflow: visible;
  height: auto;
  min-height: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.image-result-page .image-job-card.regenerated {
  grid-column: 1 / -1;
}

.image-result-page .image-job-stage {
  position: relative;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.image-result-page .image-job-preview {
  display: inline-grid;
  place-items: center;
  width: auto;
  height: auto;
  max-width: min(100%, 215px);
  padding: 0;
  overflow: visible;
  border-radius: 0;
}

.image-result-page .image-job-preview.image-load-failed {
  position: relative;
  min-width: 168px;
  min-height: 168px;
  border-radius: 18px;
  background: #f8fafc;
}

.image-result-page .image-job-preview.image-load-failed img {
  opacity: 0;
}

.image-result-page .image-job-preview.image-load-failed::after {
  content: "图片加载失败";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.image-result-page .image-job-stage img {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: min(100%, 215px);
  max-height: min(34vh, 310px);
  object-fit: contain !important;
  border-radius: 0;
  box-shadow: none;
}

.generated-card {
  display: grid;
  place-items: center;
  background: #f8fbff;
}

.generated-card img {
  width: 100%;
  height: auto;
  max-height: min(52vh, 420px);
  aspect-ratio: auto;
  object-fit: contain;
}

.image-result-page .image-job-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  display: flex;
  gap: 7px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.image-result-page .image-job-tool {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 10px;
  color: #ffffff;
  background: rgba(15, 35, 64, 0.72);
  box-shadow: 0 8px 18px rgba(15, 35, 64, 0.18);
  backdrop-filter: blur(10px);
  transition: transform var(--duration-press) var(--ease-out), background var(--duration-fast) ease, color var(--duration-fast) ease;
}

.image-result-page .image-job-tool svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.image-result-page .image-job-tool.favorite svg {
  fill: transparent;
}

.image-result-page .image-job-tool.favorite.is-favorite {
  color: #9fc3ef;
}

.image-result-page .image-job-tool.favorite.is-favorite svg {
  fill: currentColor;
}

.image-result-page .image-job-tool:hover {
  background: rgba(22, 119, 255, 0.88);
}

.image-result-page .image-job-tool:active {
  transform: scale(0.96);
}

.image-result-page .image-job-tool.is-loading {
  color: #9fc3ef;
}

.image-result-page .image-job-tool.is-loading svg {
  animation: imageToolSpin 700ms linear infinite;
}

.image-result-page .image-job-actions {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  min-height: 0;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.image-result-page .image-job-actions .primary,
.image-result-page .image-job-actions .secondary-action {
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
}

.image-result-page .image-job-loader {
  min-height: 100%;
}

.image-result-page .image-job-loader span {
  display: none;
}

.image-result-page .image-job-pending {
  display: block;
  max-width: 280px;
  margin: 10px auto 0;
  color: #7b8492;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}

.image-result-page .image-job-error {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px 16px;
  color: #b42318;
  text-align: center;
}

.image-result-page .image-job-error strong {
  font-size: 14px;
}

.image-result-page .image-job-error span {
  max-width: 280px;
  color: #8c2d24;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.image-result-page .image-composer-input {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-height: 108px;
  padding: 14px 14px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, background var(--duration-fast) ease;
}

.image-result-page .image-composer-input:focus-within,
.image-result-page .image-composer-input.dragging {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.image-result-page .image-composer-input.dragging {
  border-style: dashed;
}

/* Keep each result aligned with its prompt instead of centered in the page. */
.image-result-page .session-prompt-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
}

.image-result-page .session-prompt-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 0;
  flex-wrap: wrap;
}

.image-result-page .session-prompt-card p {
  flex: 0 1 auto;
  max-width: min(100%, 760px);
  color: var(--ink);
  line-height: 1.6;
}

.image-result-page .session-prompt-meta {
  margin-left: 2px;
}

.image-result-page .session-prompt-references {
  position: relative;
  display: inline-block;
  flex: 0 0 58px;
  width: 58px;
  height: 72px;
  margin-right: 2px;
}

.image-result-page .session-prompt-reference {
  position: absolute;
  top: 4px;
  left: 2px;
  display: block;
  width: 46px;
  height: 58px;
  overflow: hidden;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 7px;
  background: #eef2f7;
  box-shadow: 0 8px 16px rgba(24, 32, 48, 0.1);
  transform: translateX(calc(var(--reference-index) * 4px)) translateY(calc(var(--reference-index) * -2px)) rotate(var(--reference-rotate));
}

.image-result-page .session-prompt-reference img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-result-page .session-grid {
  justify-content: start;
  justify-items: start;
}

.image-result-page .session-grid:has(.image-job-card:only-child) {
  width: 100%;
  grid-template-columns: minmax(0, 430px);
  margin: 0;
}

.image-result-page .image-session-card {
  gap: 8px;
}

.image-result-page .image-composer-input textarea {
  width: 100%;
  min-height: 80px;
  padding: 5px 0 0;
  margin-bottom: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: 0;
  resize: none;
}

.image-result-page .image-composer-input textarea:hover,
.image-result-page .image-composer-input textarea:focus {
  border: 0 !important;
  box-shadow: none !important;
  outline: 0 !important;
  background: transparent;
}

.image-result-page .composer-plus-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 64px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  color: #6b7a90;
  background: linear-gradient(180deg, #f0f3f8, #e7ecf3);
  box-shadow: 0 8px 18px rgba(24, 32, 48, 0.08);
  font-size: 22px;
  line-height: 1;
  transform: rotate(-6deg);
  transform-origin: center;
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) ease, color var(--duration-fast) ease;
}

.image-result-page .composer-plus-button:hover {
  color: var(--red);
  border-color: #c7d1df;
  background: linear-gradient(180deg, #edf2f8, #dfe6ef);
  box-shadow: 0 12px 24px rgba(22, 119, 255, 0.12);
  transform: rotate(-4deg) scale(1.05);
}

.image-result-page .composer-plus-button:active {
  transform: rotate(-4deg) scale(0.98);
}

.image-result-page .next-reference-strip {
  grid-column: 2;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 2px;
}

.image-result-page .next-reference-thumb {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #cfe0f4;
  border-radius: 9px;
  background: #f6f9ff;
}

.image-result-page .next-reference-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-result-page .next-reference-thumb span {
  position: absolute;
  top: 2px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(15, 35, 64, 0.76);
  font-size: 13px;
  line-height: 1;
}

.image-result-page .composer-native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-result-page .composer-options-wrap {
  position: relative;
  margin-right: 0;
}

.image-result-page .result-preset-wrap {
  position: relative;
  flex: 0 0 auto;
  margin-right: auto;
}

.image-result-page .result-preset-button {
  cursor: pointer;
  white-space: nowrap;
}

.image-result-page .result-preset-menu {
  position: absolute;
  z-index: 82;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 190px;
  max-width: min(280px, calc(100vw - 24px));
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(24, 32, 48, 0.16);
  box-sizing: border-box;
}

.image-result-page .result-preset-menu.hidden {
  display: none;
}

.image-result-page .composer-option-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid #d7e4f3;
  border-radius: 10px;
  color: #334155;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(24, 32, 48, 0.04);
  font-size: 13px;
  font-weight: 800;
  transition: transform var(--duration-press) var(--ease-out), border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.image-result-page .composer-option-toggle:hover {
  border-color: #9fc3ef;
  box-shadow: 0 10px 20px rgba(22, 119, 255, 0.1);
}

.image-result-page .composer-option-toggle:active {
  transform: scale(0.97);
}

.image-result-page .composer-send-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: #d7dde6;
  box-shadow: none;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  transition: transform var(--duration-press) var(--ease-out), background var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.image-result-page .composer-send-button.ready {
  background: #111827;
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.18);
}

.image-result-page .composer-send-button.ready:hover {
  background: #020617;
  transform: translateY(-1px) scale(1.03);
}

.image-result-page .composer-send-button.ready:active {
  transform: scale(0.96);
}

.image-result-page .composer-send-button:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.image-result-page .composer-option-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  z-index: 70;
  display: grid;
  width: min(390px, calc(100vw - 36px));
  gap: 15px;
  padding: 16px;
  border: 1px solid #edf1f6;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 80px rgba(24, 32, 48, 0.16);
  transform-origin: left bottom;
  transition: opacity var(--duration-popover) var(--ease-out), transform var(--duration-popover) var(--ease-out);
}

.image-result-page .composer-option-panel.hidden {
  display: none;
}

.image-result-page .composer-option-panel section {
  display: grid;
  gap: 8px;
}

.image-result-page .composer-option-panel p {
  margin: 0;
  color: #8a99ad;
  font-size: 12px;
  font-weight: 800;
}

.image-result-page .option-chip-grid,
.image-result-page .option-segment-grid,
.image-result-page .option-count-grid,
.image-result-page .option-size-grid {
  display: grid;
  gap: 7px;
  padding: 5px;
  border-radius: 12px;
  background: #f6f8fb;
}

.image-result-page .ratio-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.image-result-page .option-segment-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.image-result-page .option-count-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.image-result-page .option-size-grid {
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
}

.image-result-page .option-chip-grid button,
.image-result-page .option-segment-grid button,
.image-result-page .option-count-grid button,
.image-result-page .option-size-grid span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  color: #44546a;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.image-result-page .option-chip-grid button {
  gap: 5px;
}

.image-result-page .option-chip-grid i {
  display: block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.image-result-page [data-option-value="3:4"] i {
  width: 11px;
  height: 15px;
}

.image-result-page [data-option-value="4:3"] i {
  width: 15px;
  height: 11px;
}

.image-result-page [data-option-value="16:9"] i {
  width: 17px;
  height: 10px;
}

.image-result-page [data-option-value="9:16"] i {
  width: 10px;
  height: 17px;
}

.image-result-page .option-chip-grid button.active,
.image-result-page .option-segment-grid button.active,
.image-result-page .option-count-grid button.active {
  color: #0f172a;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(24, 32, 48, 0.08);
}

.image-result-page .option-size-grid span {
  justify-content: start;
  padding: 0 10px;
  color: #8a99ad;
  background: #ffffff;
}

.image-result-page .option-size-grid strong {
  margin-left: 8px;
  color: #475569;
}

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

@media (hover: hover) and (pointer: fine) {
  .image-result-page .image-job-card:hover .image-job-tools,
  .image-result-page .image-job-card:focus-within .image-job-tools {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}

@media (hover: none), (pointer: coarse) {
  .image-result-page .image-job-tools {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

@media (max-width: 760px) {
  .image-result-page .image-result-shell {
    padding-top: 24px;
  }

  .image-result-page .image-job-stage {
    height: auto;
  }

  .image-result-page .image-job-preview,
  .image-result-page .image-job-stage img {
    max-width: min(100%, 215px);
    max-height: min(34vh, 310px);
  }

  .image-result-page .image-composer-actions {
    justify-content: stretch;
  }

  .image-result-page .composer-options-wrap {
    margin-right: 0;
  }

  .image-result-page .composer-option-toggle,
  .image-result-page .composer-options-wrap {
    width: 100%;
  }

  .image-result-page .composer-option-panel {
    left: 50%;
    transform: translateX(-50%);
    transform-origin: center bottom;
  }

  .image-result-page .image-composer-input {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
  }

  .image-result-page .composer-plus-button {
    width: 42px;
    height: 58px;
  }

  .image-result-page .composer-send-button {
    width: 100%;
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-result-page .image-job-tools,
  .image-result-page .image-composer-input,
  .image-result-page .composer-plus-button,
  .image-result-page .composer-option-toggle,
  .image-result-page .composer-option-panel,
  .image-result-page .composer-send-button {
    transition: none;
  }

  .image-result-page .image-job-tool.is-loading svg {
    animation: none;
  }
}

/* Stacked reference images live where the upload card used to be. */
.image-result-page .composer-reference-slot {
  position: relative;
  width: 58px;
  min-height: 72px;
}

.image-result-page .image-composer-input.has-references .composer-plus-button {
  opacity: 0;
  pointer-events: none;
  transform: rotate(-6deg) scale(0.96);
}

.image-result-page .next-reference-strip {
  grid-column: auto;
  position: absolute;
  inset: 0 auto auto 0;
  display: block;
  width: 58px;
  height: 72px;
  overflow: visible;
  padding: 0;
  cursor: pointer;
  outline: 0;
}

.image-result-page .next-reference-strip.hidden {
  display: none;
}

.image-result-page .next-reference-thumb {
  position: absolute;
  top: 4px;
  left: 2px;
  display: block;
  width: 46px;
  height: 58px;
  overflow: visible;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 7px;
  background: #eef2f7;
  box-shadow: 0 10px 20px rgba(24, 32, 48, 0.12);
  transform: translateX(calc(var(--reference-index) * 4px)) translateY(calc(var(--reference-index) * -2px)) rotate(var(--reference-rotate));
  transform-origin: center;
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease;
}

.image-result-page .next-reference-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 6px;
  object-fit: cover;
}

.image-result-page .reference-plus-badge {
  position: absolute;
  right: -8px;
  bottom: -8px;
  z-index: 12;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  color: #334155;
  background: #f8fafc;
  box-shadow: 0 8px 18px rgba(24, 32, 48, 0.18);
  font-size: 16px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
}

.image-result-page .reference-delete-button {
  position: absolute;
  top: -9px;
  right: -9px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.88);
  box-shadow: 0 8px 16px rgba(24, 32, 48, 0.22);
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
  transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.image-result-page .next-reference-strip:hover .next-reference-thumb,
.image-result-page .next-reference-strip:focus-visible .next-reference-thumb {
  transform: translateX(calc(var(--reference-index) * 46px)) translateY(0) rotate(var(--reference-rotate));
  box-shadow: 0 14px 28px rgba(24, 32, 48, 0.16);
}

.image-result-page .next-reference-strip:hover .next-reference-thumb:hover {
  z-index: 80 !important;
  transform: translateX(calc(var(--reference-index) * 46px)) translateY(-2px) rotate(var(--reference-rotate)) scale(1.06);
}

.image-result-page .next-reference-strip:hover .next-reference-thumb:hover .reference-delete-button {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.image-result-page .composer-send-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

@media (hover: none), (pointer: coarse) {
  .image-result-page .next-reference-strip .next-reference-thumb {
    transform: translateX(calc(var(--reference-index) * 10px)) translateY(calc(var(--reference-index) * -2px)) rotate(var(--reference-rotate));
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-result-page .next-reference-thumb,
  .image-result-page .reference-delete-button {
    transition: none;
  }
}

/* Final blue-white polish pass: keep the product visually consistent. */
.topbar,
.admin-top {
  color: #111827;
}

.topbar-actions {
  gap: 10px;
}

.account-menu {
  align-items: center;
  gap: 10px;
}

.account-credits {
  min-height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: #eef6ff;
  color: #0958d9;
  font-size: 14px;
  font-weight: 900;
}

.account-button {
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #111827;
}

.account-button:active {
  transform: scale(0.98);
}

.account-dropdown {
  grid-template-columns: minmax(0, 1fr);
  border-color: #e5eaf2;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(24, 32, 48, 0.12);
  transform-origin: right top;
}

.account-dropdown button {
  border-bottom-color: #edf1f6;
}

.note-card,
.empty-card,
.field-block,
.rewrite-box,
.settings-card,
.settings-workspace,
.cookie-card,
.endpoint-list-panel,
.combo-editor-panel,
.admin-panel,
.publish-mini-card,
.publish-detail-panel,
.image-generator-card,
.image-history-card {
  background: #ffffff !important;
  border-color: #e5eaf2 !important;
  box-shadow: 0 10px 28px rgba(24, 32, 48, 0.05) !important;
}

.rewrite-box,
.images-block,
.compose-input,
.compose-textarea,
.tag-editor,
.image-manager-grid,
.single-image-body textarea,
.reference-upload > button {
  background: #f8fbff !important;
  color: #1f2937;
}

.image-prompt-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.image-prompt-label select {
  min-width: 72px;
  height: 30px;
  border: 1px solid #d7e4f3;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  padding: 0 8px;
  font: inherit;
  font-size: 13px;
}

.soft-red-action,
.ghost,
.secondary-action,
.history-button,
.settings-button,
.image-toggle-button,
.text-toggle-button {
  border-color: #d7e4f3 !important;
  background: #ffffff !important;
  color: #1677ff !important;
}

.soft-red-action:hover,
.ghost:hover,
.secondary-action:hover,
.history-button:hover,
.settings-button:hover,
.image-toggle-button:hover,
.text-toggle-button:hover {
  border-color: #9fc3ef !important;
  background: #eaf3ff !important;
  color: #0958d9 !important;
}

.image-result-page .image-result-shell {
  width: min(1080px, calc(100vw - 28px));
  padding-top: 34px;
  padding-bottom: 230px;
}

.image-result-page .image-session-list {
  display: grid;
  gap: 24px;
}

.image-result-page .image-session-card {
  display: grid;
  gap: 6px;
}

.image-result-page .session-prompt-line {
  gap: 8px;
}

.image-result-page .session-prompt-card p {
  max-width: min(100%, 720px);
  margin: 0;
  font-size: 14px;
}

.image-result-page .session-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 200px));
  gap: 14px;
  justify-content: start;
  justify-items: start;
}

.image-result-page .session-grid:has(.image-job-card:only-child) {
  grid-template-columns: minmax(0, 200px);
}

.image-result-page .image-job-card {
  gap: 12px;
  max-width: 200px;
}

.image-result-page .image-job-stage,
.image-result-page .image-job-preview {
  max-width: min(100%, 200px);
}

.image-result-page .image-job-stage img {
  max-width: min(100%, 200px);
  max-height: min(33vh, 300px);
}

.image-result-page .image-job-loader {
  width: 168px;
  min-height: 168px;
  border-radius: 18px;
  background: #f8fbff;
}

.image-result-page .image-job-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  margin-top: 1px;
  width: auto;
}

.image-result-page .image-job-actions .primary,
.image-result-page .image-job-actions .secondary-action {
  flex: 0 0 82px;
  width: 82px !important;
  min-width: 0 !important;
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  justify-content: center;
}

.image-result-page .image-session-composer {
  bottom: 18px;
  width: min(840px, calc(100vw - 36px));
  border-color: #dce6f2;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 36px rgba(24, 32, 48, 0.08);
  backdrop-filter: blur(16px);
}

.image-result-page .image-composer-input {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.image-result-page .image-composer-input textarea {
  background: transparent !important;
}

.image-result-page .composer-plus-button {
  background: linear-gradient(180deg, #f1f5f9, #e8eef6);
  border-color: #d3dce8;
}

.image-result-page .composer-send-button.ready {
  background: #111827;
}

.image-result-page .image-result-toast {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 120;
  max-width: min(320px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid #cfe0f4;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: #0958d9;
  box-shadow: 0 18px 48px rgba(24, 32, 48, 0.12);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 180ms var(--ease-out),
    transform 180ms var(--ease-out);
}

.image-result-page .image-result-toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (max-width: 760px) {
  .image-result-page .session-grid,
  .image-result-page .session-grid:has(.image-job-card:only-child) {
    grid-template-columns: repeat(auto-fit, minmax(140px, 180px));
  }

  .image-result-page .image-job-card,
  .image-result-page .image-job-stage,
  .image-result-page .image-job-preview,
  .image-result-page .image-job-stage img {
    max-width: min(100%, 180px);
  }

  .image-result-page .image-result-toast {
    top: auto;
    right: 14px;
    bottom: 168px;
  }
}

.results-shell-with-sessions {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 16px 18px 80px 0;
}

.results-workspace {
  min-width: 0;
}

.rewrite-session-sidebar {
  position: sticky;
  top: 74px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 92px);
  overflow: visible;
  padding: 14px;
  border: 1px solid #e5eaf2;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(24, 32, 48, 0.05);
  backdrop-filter: blur(14px);
}

.rewrite-session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rewrite-session-head strong {
  color: #111827;
  font-size: 15px;
}

.rewrite-session-head span {
  color: #667085;
  font-size: 12px;
  font-weight: 800;
}

.new-collect-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfe0f4;
  border-radius: 12px;
  background: #eef6ff;
  color: #1677ff;
  font-size: 13px;
  font-weight: 900;
  font-family: inherit;
  transition:
    transform 140ms var(--ease-out),
    border-color 160ms ease,
    background 160ms ease;
}

.collect-session-card {
  display: grid;
  gap: 16px;
  width: min(860px, 100%);
  min-height: 360px;
  padding: 26px;
  border: 1px solid #e5eaf2;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(24, 32, 48, 0.06);
}

.collect-session-head {
  display: grid;
  gap: 8px;
}

.collect-session-head span {
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1677ff;
  font-size: 12px;
  font-weight: 900;
}

.collect-session-head h2 {
  max-width: 620px;
  color: #111827;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.25;
}

.collect-session-card textarea {
  width: 100%;
  min-height: 160px;
  padding: 16px;
  border: 1px solid #dce6f2;
  border-radius: 16px;
  background: #f8fbff;
  color: #111827;
  line-height: 1.6;
  resize: vertical;
}

.collect-session-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.collect-session-actions p {
  margin: 0;
  color: #667085;
  font-size: 13px;
}

.collect-session-actions p.bad {
  color: #df4237;
  font-weight: 800;
}

.collect-session-actions .primary {
  min-width: 140px;
}

.collect-session-home {
  width: min(980px, calc(100vw - 300px));
  margin: 0 auto;
  padding: clamp(64px, 10vh, 120px) 0 96px;
  text-align: center;
}

.collect-session-hero {
  margin: 0 auto 36px;
}

.collect-session-hero .pill {
  margin-bottom: 24px;
  border-color: #cfe0f4;
  background: rgba(255, 255, 255, 0.82);
  color: #1677ff;
  box-shadow: 0 10px 28px rgba(22, 119, 255, 0.08);
}

.collect-session-hero h1 {
  max-width: 780px;
  margin: 0 auto;
  color: #111827;
}

.collect-session-hero .subtitle {
  max-width: 760px;
  margin: 18px auto 0;
  color: #667085;
  line-height: 1.75;
}

.collect-link-card {
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(24, 32, 48, 0.08);
}

.collect-link-card .card-tabs {
  background: rgba(255, 255, 255, 0.95);
}

.collect-link-card .card-tab {
  font-family: inherit;
}

.collect-link-card textarea {
  min-height: 148px;
  color: #111827;
}

.collect-link-card textarea:focus {
  outline: 0;
}

.collect-link-card .card-actions {
  padding-bottom: 28px;
}

.collect-link-card .card-actions p.bad {
  color: #df4237;
  font-weight: 800;
}

@media (max-width: 640px) {
  .app-store-search-row {
    grid-template-columns: 1fr auto;
    padding-inline: 16px;
  }

  .app-store-hint,
  .app-store-results,
  .app-store-detail {
    margin-left: 16px;
    margin-right: 16px;
  }

  .app-store-result {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .app-store-result img {
    width: 42px;
    height: 42px;
  }

  .app-store-rating {
    display: none;
  }

}

.new-collect-button:hover {
  border-color: #9fc3ef;
  background: #e4f0ff;
}

.new-collect-button:active {
  transform: scale(0.98);
}

.rewrite-session-list {
  display: grid;
  gap: 9px;
  overflow-y: auto;
  padding-right: 2px;
}

.rewrite-session-empty {
  padding: 18px 10px;
  border: 1px dashed #d7e4f3;
  border-radius: 14px;
  color: #98a2b3;
  text-align: center;
  font-size: 13px;
}

.rewrite-session-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid #edf1f6;
  border-radius: 14px;
  background: #ffffff;
  transition:
    transform 160ms var(--ease-out),
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.rewrite-session-card:hover {
  border-color: #cfe0f4;
  background: #f8fbff;
  box-shadow: 0 10px 24px rgba(24, 32, 48, 0.06);
  transform: translateY(-1px);
}

.rewrite-session-card.active {
  border-color: #9fc3ef;
  background: #eef6ff;
  box-shadow: 0 10px 24px rgba(22, 119, 255, 0.10);
}

.rewrite-session-card.running::before {
  content: "";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #1677ff;
  box-shadow: 0 0 0 5px rgba(22, 119, 255, 0.12);
}

.rewrite-session-main {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.rewrite-session-main strong {
  overflow: hidden;
  color: #111827;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rewrite-session-main small {
  color: #667085;
  font-size: 12px;
}

.rewrite-session-status {
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f2f6fb;
  color: #667085;
  font-size: 11px;
  font-weight: 900;
}

.rewrite-session-card.active .rewrite-session-status,
.rewrite-session-card.running .rewrite-session-status {
  background: #ffffff;
  color: #1677ff;
}

.rewrite-session-actions {
  display: grid;
  gap: 5px;
  opacity: 0;
  transform: translateX(4px);
  transition:
    opacity 160ms var(--ease-out),
    transform 160ms var(--ease-out);
}

.rewrite-session-card:hover .rewrite-session-actions,
.rewrite-session-card:focus-within .rewrite-session-actions {
  opacity: 1;
  transform: translateX(0);
}

.rewrite-session-actions button {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid #d7e4f3;
  border-radius: 9px;
  background: #ffffff;
  color: #667085;
  font-size: 14px;
  font-weight: 900;
  transition:
    transform 140ms var(--ease-out),
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease;
}

.rewrite-session-actions button:hover {
  border-color: #9fc3ef;
  background: #eef6ff;
  color: #1677ff;
}

.rewrite-session-actions button:active {
  transform: scale(0.94);
}

@media (max-width: 1180px) {
  .results-shell-with-sessions {
    grid-template-columns: 1fr;
  }

  .collect-session-home {
    width: min(940px, 100%);
    padding-top: 48px;
  }

  .rewrite-session-sidebar {
    position: relative;
    top: auto;
    max-height: none;
  }

  .rewrite-session-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 220px);
    overflow-x: auto;
    overflow-y: visible;
    padding: 0 0 4px;
  }
}

/* AI image prompt presets: hover for a compact switcher, click for full editing. */
.image-preset-wrap {
  position: relative;
  flex: 0 0 auto;
}

.image-preset-menu {
  position: fixed;
  z-index: 80;
  min-width: 190px;
  max-width: min(280px, calc(100vw - 24px));
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(24, 32, 48, 0.16);
  box-sizing: border-box;
}

.image-preset-menu.hidden {
  display: none;
}

.image-preset-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.image-preset-option:hover,
.image-preset-option.active {
  background: var(--red-soft);
  color: var(--red-dark);
}

.image-preset-option b {
  color: var(--red);
  font-size: 11px;
  white-space: nowrap;
}

.image-preset-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preset-modal .prompt-card {
  width: min(820px, calc(100vw - 32px));
}

.image-preset-modal .prompt-editor-panel {
  align-content: start;
}

.image-preset-modal .prompt-editor-panel label {
  display: grid;
  gap: 7px;
  color: var(--soft-ink);
  font-size: 13px;
  font-weight: 800;
}

.image-preset-modal .prompt-editor-panel input,
.image-preset-modal .prompt-editor-panel textarea,
.image-preset-modal .prompt-editor-panel select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.image-preset-modal .prompt-editor-panel textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.65;
}

.image-preset-reference-editor {
  display: grid;
  gap: 9px;
}

.image-preset-reference-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--soft-ink);
  font-size: 13px;
  font-weight: 800;
}

.image-preset-reference-heading small {
  color: var(--soft-ink);
  font-size: 11px;
  font-weight: 600;
}

.image-preset-reference-drop {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px dashed #b9cce4;
  border-radius: 11px;
  background: #f8fbff;
  color: var(--soft-ink);
  font-size: 12px;
  transition: border-color 160ms ease, background 160ms ease;
}

.image-preset-reference-drop.dragging {
  border-color: var(--red);
  background: var(--red-soft);
}

.image-preset-reference-drop .secondary-action {
  min-height: 34px;
  padding-inline: 12px;
}

.image-preset-reference-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.image-preset-reference-preview button {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #eef3f8;
  cursor: pointer;
}

.image-preset-reference-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preset-reference-preview button span {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(15, 24, 38, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

@media (max-width: 640px) {
  .image-preset-modal .prompt-body {
    grid-template-columns: 1fr;
  }

  .image-preset-modal .prompt-list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .image-preset-modal .prompt-template-list {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .image-preset-reference-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .image-preset-reference-drop {
    align-items: flex-start;
    flex-direction: column;
  }

  .image-preset-reference-preview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Compact AI image composer: references, prompt and send action stay in one surface. */
.image-page .image-shell {
  width: min(900px, calc(100vw - 32px));
}

.image-page .image-generator-card {
  width: min(840px, 100%);
  overflow: visible;
  border-radius: 16px;
}

.image-composer-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 132px;
  padding: 24px 26px 14px;
  border-radius: 16px 16px 0 0;
  background: #fff;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.image-reference-slot {
  position: relative;
  flex: 0 0 60px;
  width: 60px;
  min-height: 72px;
}

.image-composer-main.dragging {
  background: #f4f9ff;
  box-shadow: inset 0 0 0 2px #8cbbf0;
}

.image-composer-main.uploading {
  cursor: progress;
}

.image-reference-trigger {
  display: grid;
  place-items: center;
  width: 60px;
  height: 64px;
  margin-top: 2px;
  border: 1px solid #d5e2f1;
  border-radius: 8px;
  background: #f5f9ff;
  color: #5c7799;
  cursor: pointer;
  transform: rotate(-5deg);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.image-reference-trigger:hover:not(:disabled),
.image-reference-trigger:focus-visible {
  border-color: #86b6eb;
  background: #eaf4ff;
  color: var(--red);
  outline: 0;
  transform: rotate(0deg) translateY(-1px);
}

.image-reference-trigger:disabled {
  cursor: wait;
  opacity: 0.55;
}

.image-reference-trigger svg,
.image-generate-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.image-composer-main textarea {
  flex: 1 1 auto;
  min-width: 150px;
  min-height: 94px;
  margin: 0;
  padding: 7px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
  resize: none;
}

.image-composer-main textarea:focus {
  outline: 0;
  box-shadow: none;
}

.image-composer-references {
  position: absolute;
  inset: 0 auto auto 0;
  display: block;
  width: 60px;
  height: 72px;
  overflow: visible;
  padding: 0;
}

.image-composer-references.hidden {
  display: none;
}

.image-composer-main:has(.image-composer-references:not(.hidden)) .image-reference-trigger {
  opacity: 0;
  pointer-events: none;
}

.image-composer-reference {
  position: relative;
  position: absolute;
  top: 4px;
  left: 2px;
  display: block;
  width: 50px;
  height: 64px;
  overflow: visible;
  border: 1px solid #d7e4f3;
  border-radius: 8px;
  background: #edf3fa;
  padding: 0;
  box-shadow: 0 10px 20px rgba(24, 32, 48, 0.12);
  transform: translateX(calc(var(--reference-index) * 4px)) translateY(calc(var(--reference-index) * -2px)) rotate(var(--reference-rotate));
  transform-origin: center;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.image-composer-reference img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  object-fit: cover;
}

.image-reference-delete {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(20, 32, 49, 0.7);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.75);
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, transform 150ms ease;
}

.image-composer-references:hover .image-composer-reference {
  transform: translateX(calc(var(--reference-index) * 42px)) translateY(0) rotate(var(--reference-rotate));
  box-shadow: 0 14px 28px rgba(24, 32, 48, 0.16);
}

.image-composer-reference:hover .image-reference-delete,
.image-composer-reference:focus-within .image-reference-delete {
  opacity: 1;
}

.image-reference-add {
  position: absolute;
  right: -8px;
  bottom: -8px;
  z-index: 12;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: 0 8px 18px rgba(24, 32, 48, 0.18);
  color: #334155;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.image-page .image-options-row {
  position: relative;
  min-height: 54px;
  overflow: visible;
  justify-content: flex-start;
  gap: 8px;
  border-top: 0;
  border-radius: 0 0 16px 16px;
  padding: 0 16px 14px;
}

.image-options-wrap {
  position: relative;
  flex: 0 0 auto;
}

.image-options-toggle {
  min-height: 34px;
  border: 1px solid #d4e2f2;
  border-radius: 8px;
  background: #fff;
  color: #41546d;
  padding: 0 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.image-options-toggle:hover,
.image-options-toggle:focus-visible,
.image-options-toggle[aria-expanded="true"] {
  border-color: #8cb8e8;
  background: #f4f9ff;
  color: var(--red);
  outline: 0;
}

.image-options-panel {
  position: absolute;
  z-index: 81;
  bottom: calc(100% + 8px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 10px;
  width: min(360px, calc(100vw - 48px));
  padding: 12px;
  border: 1px solid #d7e4f3;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 16px 38px rgba(24, 32, 48, 0.14);
}

.image-options-panel.hidden {
  display: none;
}

.image-options-panel label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--soft-ink);
  font-size: 12px;
  font-weight: 800;
}

.image-options-panel .count-control {
  display: grid;
  gap: 5px;
}

.image-options-panel .count-control span {
  font-size: 12px;
}

.image-page .image-options-panel select,
.image-page .image-options-panel .count-custom-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border-radius: 7px;
  font-size: 13px;
}

.image-options-panel .count-custom-input {
  grid-column: 1 / -1;
  width: 100%;
}

.image-page #presetPromptButton {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  color: #5b6c82;
  font-size: 13px;
}

.image-page #presetPromptButton:hover,
.image-page #presetPromptButton:focus-visible {
  color: var(--red);
}

.image-generate-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: #d9e1ec;
  color: #fff;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.image-generate-icon:hover,
.image-generate-icon:focus-visible {
  background: var(--red);
  box-shadow: 0 8px 18px rgba(22, 119, 255, 0.25);
  outline: 0;
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .image-page .image-shell {
    width: min(100% - 24px, 900px);
    padding-top: 96px;
  }

  .image-composer-main {
    gap: 11px;
    min-height: 122px;
    padding: 18px 16px 8px;
  }

  .image-reference-trigger {
    width: 48px;
    height: 56px;
  }

  .image-reference-slot {
    flex-basis: 48px;
    width: 48px;
    min-height: 64px;
  }

  .image-composer-references {
    width: 48px;
    height: 64px;
  }

  .image-composer-main textarea {
    min-height: 86px;
    font-size: 14px;
  }

  .image-options-panel {
    grid-template-columns: 1fr;
    width: min(240px, calc(100vw - 48px));
  }

  .image-options-panel .count-custom-input {
    grid-column: auto;
  }
}
/* 预设方案：编辑器按钮 + 悬停下拉 + 管理弹窗 */
.prompt-modal.preset-modal { z-index: 60; }
.editor-preset-wrap { position: relative; }
.editor-preset-button { white-space: nowrap; }
.editor-preset-menu {
  display: none;
  position: fixed;
  min-width: 220px;
  max-width: 320px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #d8e0eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
  z-index: 65;
}
.editor-preset-menu.open { display: block; }
.editor-preset-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #1f2937;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.editor-preset-menu button:hover { background: #eef6ff; color: #1677ff; }
.editor-preset-menu button small { display: block; margin-top: 2px; color: #98a2b3; font-size: 11px; }
.editor-preset-empty { padding: 10px; color: #98a2b3; font-size: 12px; text-align: center; }
.preset-hint { margin: 8px 0 0; color: #667085; font-size: 12px; line-height: 1.6; }
.preset-items { display: grid; gap: 10px; margin: 10px 0; }
.preset-item-row { display: grid; gap: 8px; padding: 10px; border: 1px solid #e1e7ef; border-radius: 10px; background: #f8fafc; }
.preset-item-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #667085; }
.preset-remove-item { border: 0; background: transparent; color: #d43847; font-size: 12px; cursor: pointer; }
.preset-item-text { width: 100%; height: 32px; border: 1px solid #d8e0eb; border-radius: 6px; padding: 0 8px; font-size: 13px; }
.preset-item-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.preset-item-fields label { display: inline-flex; align-items: center; gap: 4px; color: #475467; font-size: 12px; white-space: nowrap; }
.preset-item-fields input[type="number"] { width: 60px; height: 30px; border: 1px solid #d8e0eb; border-radius: 6px; padding: 0 6px; }
.preset-item-fields input[type="color"] { width: 34px; height: 30px; padding: 2px; border: 1px solid #d8e0eb; border-radius: 6px; }
.preset-item-fields select { height: 30px; border: 1px solid #d8e0eb; border-radius: 6px; background: #fff; padding: 0 4px; }
.preset-list-empty { padding: 12px; color: #98a2b3; font-size: 12px; text-align: center; }
/* 预设方案：封面预览 */
.preset-preview-wrap {
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid #e1e7ef;
  border-radius: 10px;
  background: #f8fafc;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.preset-preview-canvas {
  width: 240px;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e1e7ef;
  display: block;
}
/* 参考图删除按钮：仅右上角红叉可点击删除 */
.reference-preview span {
  width: 22px;
  height: 22px;
  font-size: 13px;
  cursor: pointer;
}
/* 提示词模板：共享/私有标识与只读态 */
.prompt-tpl-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  vertical-align: middle;
}
.prompt-tpl-badge.shared { background: #eef2f7; color: #5b6b7f; border: 1px solid #d8e0eb; }
.prompt-tpl-badge.mine { background: #e8f4ff; color: #1677ff; border: 1px solid #b5d7ff; }
.prompt-editor-readonly input,
.prompt-editor-readonly textarea,
.prompt-editor-readonly select { opacity: .62; pointer-events: none; background: #f5f6f8; }
.prompt-editor-readonly .reference-upload { display: none; }
.prompt-editor-readonly .reference-preview span { display: none; }

/* AI 生成按钮：彻底钉死位置，常驻显示，修复按钮躲鼠标的问题 */
.editor-thumb-wrap .image-ai-button {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  transform: translate(-50%, -50%) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transition: none !important;
}
.editor-image-card.loading .editor-thumb-wrap .image-ai-button,
.editor-thumb-wrap .image-ai-button:disabled {
  opacity: 1 !important;
  pointer-events: auto !important;
  cursor: progress !important;
}
