*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --ui-scale: 1;
  --bg: #0d0d0f;
  --surface: #18181c;
  --surface2: #1f1f25;
  --surface3: #26262e;
  --border: #2e2e38;
  --border-hover: #44445a;
  --accent: #7c6aff;
  --accent-hover: #9180ff;
  --accent-glow: rgba(124, 106, 255, 0.25);
  --text: #f0f0f8;
  --text-muted: #8a8aa0;
  --text-dim: #56566e;
  --danger: #ff5f5f;
  --success: #4ade80;
  --warn: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 10.5px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Layout ── */
.app {
  display: flex;
  width: calc(100vw / var(--ui-scale));
  height: calc(100vh / var(--ui-scale));
  transform: scale(var(--ui-scale));
  transform-origin: top left;
}

/* ── Left sidebar ── */
.sidebar {
  width: 255px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 20px 0;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.logo-text-wrap {
  flex: 1;
  min-width: 0;
}

.logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  scrollbar-gutter: stable;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── Form sections ── */
.section {
  margin-bottom: 20px;
}

.section-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.task-queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.task-queue-empty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12px;
}

.task-queue-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  padding: 10px 12px;
}

.task-queue-item[data-deletable="true"] {
  cursor: context-menu;
}

.task-queue-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.task-queue-status,
.task-queue-time {
  font-size: 11px;
  color: var(--text-muted);
}

.task-queue-item-prompt {
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

.task-queue-item-error {
  margin-top: 6px;
  font-size: 11px;
  color: var(--danger);
  line-height: 1.4;
}

.task-queue-running {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.task-queue-done {
  opacity: 0.8;
}

.task-queue-failed {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
}

.task-queue-context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 136px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.task-queue-context-menu-item {
  width: 100%;
  border: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  padding: 8px 10px;
  cursor: pointer;
}

.task-queue-context-menu-item:hover {
  background: var(--surface2);
}

/* ── Input wrap ── */
.input-wrap {
  position: relative;
}

.input-wrap input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 36px 9px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: "SF Mono", "Fira Code", monospace;
  outline: none;
  transition: border-color 0.15s;
}

.input-wrap input[type="text"] {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", sans-serif;
  padding-right: 12px;
}

.input-wrap input:focus {
  border-color: var(--accent);
}

.input-wrap input::placeholder {
  color: var(--text-dim);
}

.modal-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.input-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-dim);
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 2px;
}

.input-eye:hover {
  color: var(--text-muted);
}

/* ── Prompt editor ── */
.prompt-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface2);
}

.prompt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface3);
}

.prompt-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  font-family: inherit;
}

.prompt-tool-btn:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}

.prompt-tool-btn svg {
  flex-shrink: 0;
  opacity: 0.9;
}

.prompt-box {
  position: relative;
}

.prompt-box textarea {
  width: 100%;
  min-height: 180px;
  max-height: 520px;
  background: var(--surface2);
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.6;
  transition: border-color 0.15s;
}

.prompt-box textarea:focus {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.prompt-box textarea::placeholder {
  color: var(--text-dim);
}

/* Reference image button states */
#refImageBtn.ref-supported {
  opacity: 1;
  cursor: pointer;
}

#refImageBtn.ref-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#refImageBtn.ref-disabled:hover {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.char-count {
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.count-max-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
}

.count-max-hint #maxCount {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Size selector ── */
.size-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.size-option {
  cursor: pointer;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px 8px;
  background: var(--surface2);
  text-align: center;
  transition: all 0.15s;
  user-select: none;
}

.size-option:hover {
  border-color: var(--border-hover);
}

.size-option.active {
  border-color: var(--accent);
  background: rgba(124, 106, 255, 0.08);
}

.size-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  height: 36px;
}

.size-rect {
  background: var(--border);
  border-radius: 2px;
  transition: background 0.15s;
}

.size-option.active .size-rect {
  background: var(--accent);
  opacity: 0.7;
}

.size-label {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
}

.size-option.active .size-label {
  color: var(--accent);
}

/* ── Segmented control ── */
.seg {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
  border: none;
  background: none;
}

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

.seg-btn.active {
  background: var(--surface3);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.seg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--text-dim);
}

.seg-btn:disabled:hover {
  color: var(--text-dim);
}

/* ── Slider ── */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-wrap input[type=range] {
  flex: 1;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.slider-wrap input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.slider-val {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

/* ── Stepper ── */
.stepper {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}

.stepper button {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.stepper button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stepper span {
  min-width: 36px;
  text-align: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 6px 4px;
}

/* ── Generate button ── */
.gen-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.gen-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

.gen-btn:active {
  transform: scale(0.98);
}

.gen-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.gen-btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 20px;
}

/* Workspace */
.workspace {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  background: radial-gradient(circle at top, rgba(124, 106, 255, 0.08), transparent 30%), var(--bg);
}

.workbench,
.history-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(24, 24, 28, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(16px);
}

.workbench {
  min-height: 0;
}

.history-panel {
  padding: 11px;
}

.history-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.history-panel-title {
  font-size: 15px;
  font-weight: 700;
}

.history-panel-sub {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.history-panel-body {
  flex: 3 1 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.collection-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
}

.collection-panel-body {
  flex: 1 1 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  grid-auto-rows: min-content;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  max-height: min(24vh, 220px);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.collection-panel-empty {
  grid-column: 1 / -1;
  padding: 18px;
  color: var(--text-dim);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 14px;
}

.collection-panel-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.collection-panel-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.collection-panel-item-meta {
  padding: 8px;
}

.collection-panel-item-title {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-panel-empty {
  padding: 18px;
  color: var(--text-dim);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 14px;
}

.history-panel-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: stretch;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.history-panel-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

.history-panel-thumb {
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface2);
  min-height: 88px;
}

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

.history-panel-meta {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.history-panel-prompt {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.history-panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.history-panel-tags span {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
}

/* ── Canvas ── */
.canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.canvas-toolbar {
  height: 40px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
}

.toolbar-title {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  flex: 1;
}

.toolbar-badge {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.toolbar-badge:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.toolbar-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 4px 9px;
  font-size: 9px;
  cursor: pointer;
  transition: all 0.15s;
}

.toolbar-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.canvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.workbench-body {
  padding-bottom: 14px;
}

.canvas-body::-webkit-scrollbar {
  width: 6px;
}

.canvas-body::-webkit-scrollbar-track {
  background: transparent;
}

.canvas-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Empty state ── */
.empty-state {
  height: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-dim);
  padding: 24px;
  box-sizing: border-box;
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}

.empty-state p {
  font-size: 13px;
  max-width: 280px;
  text-align: center;
  line-height: 1.7;
}

/* ── Image grid ── */
.image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

/* ── Image card (completed) ── */
@keyframes cardAppear {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.image-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.image-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.image-card:hover .card-del-btn {
  opacity: 1;
}

.card-del-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: all 0.2s;
  z-index: 10;
}

.card-del-btn:hover {
  background: var(--danger);
  transform: scale(1.1);
}

.image-card img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.image-card-footer {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  gap: 6px;
}

.image-meta {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-meta:hover {
  color: var(--accent);
}

.image-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Channel badge on card footer */
.card-channel-tag {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.card-channel-tag.async {
  border-color: rgba(124, 106, 255, 0.35);
  color: var(--accent);
  background: rgba(124, 106, 255, 0.08);
}

.card-channel-tag.custom {
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--warn);
  background: rgba(245, 158, 11, 0.08);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
}

.icon-btn:hover {
  background: var(--surface3);
  color: var(--text);
}

.image-fav-btn.active {
  color: #f7c948;
}

/* ── Pending image card (async task in progress) ── */
.image-card-pending {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  animation: pendingBorderPulse 2.4s ease-in-out infinite;
}

@keyframes pendingBorderPulse {

  0%,
  100% {
    border-color: var(--accent);
    box-shadow: 0 0 0 0 rgba(124, 106, 255, 0);
  }

  50% {
    border-color: var(--accent-hover);
    box-shadow: 0 0 12px 1px rgba(124, 106, 255, 0.18);
  }
}

.pending-img-area {
  position: relative;
  background: linear-gradient(160deg, var(--surface2) 0%, var(--surface) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 20px;
  overflow: hidden;
}

.pending-img-area::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(124, 106, 255, 0.07) 50%,
      transparent 100%);
  transform: translateX(-120%);
  animation: pendingShimmer 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pendingShimmer {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(120%);
  }
}

.pending-spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid rgba(124, 106, 255, 0.18);
  border-top-color: var(--accent);
  border-right-color: rgba(124, 106, 255, 0.45);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  z-index: 1;
}

.pending-label {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  min-height: 18px;
  z-index: 1;
  animation: pendingLabelBreath 2.4s ease-in-out infinite;
}

@keyframes pendingLabelBreath {

  0%,
  100% {
    opacity: 0.65;
  }

  50% {
    opacity: 1;
  }
}

.pending-progress {
  font-size: 12px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-height: 18px;
  text-align: center;
  z-index: 1;
}

.pending-track {
  height: 3px;
  background: rgba(124, 106, 255, 0.12);
  overflow: hidden;
}

.pending-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  transition: width 0.8s ease;
  min-width: 0;
}

.pending-footer {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  gap: 6px;
}

.pending-meta {
  font-size: 11px;
  color: var(--text-dim);
  flex: 1;
}

.pending-cancel-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  padding: 3px 8px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.pending-cancel-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.image-card-pending.is-paused {
  animation: none;
  border-color: var(--border);
  opacity: 0.7;
}

.image-card-pending.is-paused .pending-img-area::after {
  animation: none;
}

.image-card-pending.is-paused .pending-spinner {
  display: none;
}

.image-card-pending.is-paused .pending-label {
  animation: none;
  opacity: 0.5;
}

.image-card-pending.is-paused .pending-cancel-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.image-card-pending.is-paused .pending-cancel-btn:hover {
  background: rgba(124, 106, 255, 0.1);
  border-color: var(--accent-hover);
  color: var(--accent-hover);
}

/* ── Skeleton loading ── */
.skeleton-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.skeleton-img {
  background: var(--surface2);
  position: relative;
  overflow: hidden;
}

.skeleton-generating-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-dim);
  z-index: 1;
  pointer-events: none;
}

.skeleton-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.04) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.skeleton-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.skeleton-line {
  background: var(--surface2);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.skeleton-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.04) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
  padding: 0 16px;
  box-sizing: border-box;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastSlideIn 0.22s ease;
  max-width: min(420px, calc(100vw - 32px));
  width: max-content;
}

@keyframes toastSlideIn {
  from {
    transform: translateY(-12px);
    opacity: 0;
  }

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

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

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

.toast.info {
  border-left: 3px solid var(--accent);
}

.toast.warn {
  border-left: 3px solid var(--warn);
}

/* 同步生成中：底部居中持久提醒（danger / error 风格） */
.sync-gen-toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  max-width: min(440px, calc(100vw - 32px));
  width: max-content;
  pointer-events: none;
  padding: 0 16px;
  box-sizing: border-box;
}

.sync-gen-toast-wrap .sync-gen-toast {
  pointer-events: auto;
  margin: 0;
  border: 1px solid rgba(255, 95, 95, 0.4);
  border-left: 4px solid var(--danger);
  background: linear-gradient(180deg, rgba(255, 95, 95, 0.14) 0%, var(--surface) 55%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: syncGenToastIn 0.26s ease;
}

@keyframes syncGenToastIn {
  from {
    transform: translateY(14px);
    opacity: 0;
  }

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

/* ── Lightbox ── */
/* ── Viewer.js dark theme overrides ── */
.viewer-backdrop {
  background: rgba(0, 0, 0, 0.75);
}

.viewer-toolbar>ul>li {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.viewer-toolbar>ul>li:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.viewer-button {
  background-color: rgba(255, 255, 255, 0.1);
}

.viewer-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* ── Token info ── */
.token-info {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.token-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Settings button in logo row ── */
.settings-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.settings-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.settings-btn.has-key {
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--success);
}

/* ── Shortcut hint ── */
.shortcut-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 12px;
  letter-spacing: 0.02em;
}

.shortcut-hint kbd {
  display: inline-block;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: inherit;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#detailModal.modal-overlay {
  z-index: 520;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 620px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.18s ease;
}

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

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

.modal-header {
  display: flex;
  align-items: center;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--surface3);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.5;
}

.download-dir-section {
  margin-top: 14px;
}

.download-dir-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.download-dir-row .btn-ghost {
  flex-shrink: 0;
  white-space: nowrap;
}

.download-dir-input-wrap {
  flex: 1;
  min-width: 0;
}

.download-dir-input-wrap input[readonly] {
  cursor: default;
  color: var(--text-muted);
}

.modal-footer {
  padding: 12px 20px 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.release-notes-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.release-notes-ver {
  font-weight: 600;
  color: var(--text);
}

.release-notes-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.release-notes-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: min(48vh, 320px);
  overflow-y: auto;
}

.release-notes-item {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.release-notes-item:last-child {
  border-bottom: none;
}

.release-notes-type {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.release-notes-item.release-notes-empty {
  color: var(--text-dim);
  font-size: 12px;
  border: none;
}

/* Link inside modal labels */
.modal-link {
  font-size: 12px;
  font-weight: 400;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0;
  transition: color 0.15s;
}

.modal-link:hover {
  color: var(--accent-hover);
}

/* 宽弹窗：历史画廊 */
.modal.modal-gallery {
  width: min(1040px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

.prompt-polish-modal {
  width: min(720px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

.prompt-polish-editor {
  min-height: 280px;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-polish-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(124, 106, 255, 0.18);
}

.detail-modal-shell {
  width: min(1120px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

#detailModalBody {
  height: min(76vh, 860px);
  max-height: min(76vh, 860px);
  overflow: hidden;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.9fr);
  gap: 18px;
  height: 100%;
  align-items: start;
}

.detail-preview,
.detail-meta {
  min-width: 0;
}

.detail-preview {
  display: grid;
  gap: 12px;
}

.detail-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.detail-nav-btn:hover:not(:disabled) {
  border-color: var(--border-hover);
}

.detail-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.detail-page-info {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.detail-preview-stage {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  min-height: 320px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1117;
  padding: 14px;
}

.detail-preview-download-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

.detail-preview-download-btn {
  width: 68px;
  height: 68px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 17, 23, 0.46);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
  transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.detail-preview-stage.has-image:hover .detail-preview-download-btn,
.detail-preview-stage.has-image .detail-preview-download-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.detail-preview-download-btn:hover {
  border-color: var(--border-hover);
  background: rgba(20, 23, 31, 0.62);
}

.detail-preview-download-btn svg {
  width: 32px;
  height: 32px;
}

.detail-preview-image {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 12px;
  object-fit: contain;
  display: block;
}

.detail-preview-empty,
.detail-empty-text {
  font-size: 12px;
  color: var(--text-dim);
}

.detail-meta {
  display: grid;
  gap: 14px;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.detail-meta::-webkit-scrollbar {
  width: 4px;
}

.detail-meta::-webkit-scrollbar-track {
  background: transparent;
}

.detail-meta::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.detail-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.detail-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.detail-section-head h3 {
  margin-bottom: 0;
}

.detail-section-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.detail-section-meta-gap {
  display: inline-block;
  width: 18px;
}

.detail-param-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 10px;
  align-items: start;
}

.detail-param-row + .detail-param-row {
  margin-top: 8px;
}

.detail-param-label {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-param-value {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
}

.detail-param-requested {
  font-size: 11px;
  color: var(--text-dim);
}

.detail-text-block {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  font-family: inherit;
}

.modal-gallery-body {
  max-height: min(80vh, 920px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-gallery-body::-webkit-scrollbar {
  width: 4px;
}

.modal-gallery-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-gallery-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.modal-gallery-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  margin-bottom: 4px;
  padding-bottom: 4px;
}

.modal-gallery-pageinfo {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 52px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.modal-gallery-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  align-items: start;
}

.modal-gallery-grid>.image-card {
  width: 100%;
  max-width: 100%;
}

.modal-gallery-card-compact.image-card:hover {
  transform: translateY(-1px);
}

.modal-gallery-card-footer {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}

.modal-gallery-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  line-clamp: 1;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.modal-gallery-sub {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 1px;
}

.modal-gallery-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px !important;
  font-size: 10px !important;
  flex: 1;
  min-width: 0;
}

.viewer-nav-overlay {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 72px;
  border: none;
  border-radius: 18px;
  background: rgba(16, 18, 24, 0.34);
  color: rgba(255, 255, 255, 0.92);
  font-size: 38px;
  line-height: 1;
  cursor: pointer;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, opacity 0.18s ease;
  backdrop-filter: blur(10px);
}

.viewer-nav-overlay:hover:not(:disabled) {
  background: rgba(16, 18, 24, 0.54);
}

.viewer-nav-overlay:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.viewer-nav-prev {
  left: 22px;
}

.viewer-nav-next {
  right: 22px;
}

.modal-card-media-23.modal-card-media-sm {
  max-height: 172px;
}

.modal-card-media-23 {
  aspect-ratio: 2 / 3;
  background: var(--surface2);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}

.modal-card-media-23 img {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.modal-card-media-placeholder {
  font-size: 12px;
  color: var(--text-dim);
  padding: 16px;
  text-align: center;
  line-height: 1.5;
}

.history-search-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 14px;
  min-width: 0;
}

.history-search-input {
  width: min(420px, 100%);
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}

.history-search-input::placeholder {
  color: var(--text-dim);
}

.history-search-input:focus {
  border-color: var(--accent);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Buttons ── */
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-ghost.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* ── Key status dot ── */
.key-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.key-dot.active {
  background: var(--success);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

/* ── Reference image strip ── */
.ref-images {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: flex-start;
}

.ref-images-label {
  width: 100%;
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.ref-images-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.ref-images-clear:hover {
  color: var(--danger);
}

.ref-img-item {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.ref-img-item:hover {
  border-color: var(--border-hover);
}

.ref-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ref-img-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: rgba(0, 0, 0, 0.72);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}

.ref-img-item:hover .ref-img-del {
  opacity: 1;
}

/* ── Reference image upload modal ── */
.ref-upload-expire-note {
  margin-bottom: 14px;
}

.ref-upload-expire-note #refUploadExpire {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ref-upload-zone {
  display: block;
  position: relative;
  min-height: 140px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

.ref-upload-zone:hover,
.ref-upload-zone:focus-visible {
  border-color: var(--accent);
  background: rgba(124, 106, 255, 0.06);
}

.ref-upload-zone.ref-upload-drag {
  border-color: var(--accent);
  background: rgba(124, 106, 255, 0.1);
}

.ref-upload-zone.ref-upload-disabled {
  pointer-events: none;
  opacity: 0.65;
  cursor: wait;
}

.ref-upload-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  text-align: center;
}

.ref-upload-zone-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.ref-upload-zone-title {
  font-size: 14px;
  color: var(--text);
}

.ref-upload-zone-hint {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
}

.ref-upload-zone-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ── 比例 chip 网格 ── */
.size-ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.size-ratio-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 4px 7px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface2);
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  user-select: none;
}

.size-ratio-chip:hover {
  border-color: var(--border-hover);
}

.size-ratio-chip.active {
  border-color: var(--accent);
  background: rgba(124, 106, 255, 0.08);
}

.size-ratio-chip.active .size-rect {
  background: var(--accent);
  opacity: 0.7;
}

.size-ratio-chip.active .size-ratio-label {
  color: var(--accent);
}

.size-ratio-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
}

.size-ratio-thumb-auto {
  width: 18px;
  height: 18px;
  border: 1.5px dashed var(--text-dim);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.size-ratio-chip.active .size-ratio-thumb-auto {
  border-color: var(--accent);
  color: var(--accent);
  opacity: 0.7;
}

.size-ratio-label {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1;
  white-space: nowrap;
}

/* ── 自定义尺寸输入 ── */
.size-custom-panel {
  margin-top: 10px;
  padding: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.size-custom-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.size-custom-row input[type="number"] {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", monospace;
  outline: none;
  transition: border-color 0.15s;
  appearance: textfield;
  -moz-appearance: textfield;
}

.size-custom-row input[type="number"]::-webkit-inner-spin-button,
.size-custom-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.size-custom-row input[type="number"]:focus {
  border-color: var(--accent);
}

.size-custom-sep {
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.size-custom-apply {
  padding: 6px 10px;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}

.size-custom-apply:hover {
  background: var(--accent-hover);
}

.size-custom-hint {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.45;
}

.size-custom-error {
  margin-top: 4px;
  font-size: 11px;
  color: var(--danger);
  line-height: 1.4;
}

/* ── Beta badge ── */
.beta-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--warn);
  border-radius: 3px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Experimental feature toggles ── */
.experimental-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
  user-select: none;
}

.toggle-row:hover {
  border-color: var(--border-hover);
}

.toggle-row input[type="checkbox"] {
  display: none;
}

.toggle-label {
  font-size: 12px;
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--surface3);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-dim);
  top: 2px;
  left: 2px;
  transition: transform 0.15s, background 0.15s;
}

.toggle-row input[type="checkbox"]:checked~.toggle-switch {
  background: rgba(124, 106, 255, 0.2);
  border-color: var(--accent);
}

.toggle-row input[type="checkbox"]:checked~.toggle-switch::after {
  background: var(--accent);
  transform: translateX(14px);
}

/* Skeleton with partial-image preview */
.skeleton-img.has-partial::after {
  opacity: 0.08;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .app {
    flex-direction: column;
    width: 100%;
    height: auto;
    transform: none;
  }

  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-scroll {
    max-height: 50vh;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .history-panel {
    order: 2;
  }

  .workbench {
    order: 1;
  }

  html,
  body {
    overflow: auto;
  }

  .canvas-body {
    min-height: 60vh;
  }

  .composer-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-send {
    width: 100%;
    justify-content: center;
  }

  .detail-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .detail-preview-stage {
    min-height: 220px;
  }

  #detailModalBody {
    height: auto;
    max-height: min(76vh, 860px);
    overflow-y: auto;
  }

  .detail-meta {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .detail-param-row {
    grid-template-columns: 72px 1fr;
  }
}

/* ── Chat feed (对话流) ── */
.chat-feed {
  display: flex;
  flex-direction: column;
}

.chat-row:last-child {
  padding-bottom: 32px;
}

/* ── Time divider ── */
.chat-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px 6px;
}

.chat-divider-text {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 12px;
  white-space: nowrap;
  user-select: none;
}

/* ── Chat row ── */
.chat-row {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px 24px 16px;
  animation: chatRowIn 0.2s ease-out;
}

.chat-row-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chat-row-user {
  justify-content: flex-start;
}

.chat-row-ai {
  align-items: flex-start;
  margin-top: -4px;
}

@keyframes chatRowIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

/* ── Right side: user bubble row (align right) ── */
.chat-right {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 12px;
}

/* ── Left side: A avatar + image output ── */
.chat-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chat-col-images {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  margin-top: 0;
}

/* ── Avatars ── */
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 40px;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

.av-a {
  background: linear-gradient(135deg, #f2f4ff, #d7ddff);
  color: #5e65d8;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ── User bubble ── */
.chat-bubble-params {
  max-width: 480px;
  background: var(--surface2);
  border: 1px solid var(--border-hover);
  border-radius: 14px;
  border-top-right-radius: 4px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  margin-top: 0;
}

.chat-prompt {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  display: -webkit-box;
  line-clamp: 4;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.chat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chat-tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: nowrap;
}

.composer-panel {
  padding: 0 16px 16px;
}

.composer-shell {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 12px;
}

.composer-prompt-editor {
  background: var(--surface);
}

.composer-prompt-box textarea {
  min-height: 120px;
  max-height: 240px;
}

.composer-ref-images {
  margin-top: 10px;
}

.composer-meta {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-meta-left {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.composer-chip {
  font-size: 8px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}

.composer-chip-stats {
  color: var(--text-dim);
}

.composer-send {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #5f58d9);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.composer-send:hover {
  box-shadow: 0 0 20px var(--accent-glow);
}

/* .chat-tag.ch-cnd {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-tag.ch-cnd {
  border-color: var(--warn);
  color: var(--warn);
}

.chat-tag.ch-custom {
  border-color: var(--success);
  color: var(--success);
} */

/* ════════════════════════════════════════════════════════════════════════════
   电商场景模板（预置提示词库）
   ════════════════════════════════════════════════════════════════════════════ */

/* 侧栏：行业分类 chip */
.scene-cat-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.scene-cat-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.scene-cat-chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface2));
}

.scene-cat-chip:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* 侧栏：「全部场景」按钮 */
.scene-library-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--surface2)), var(--surface2));
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.scene-library-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

/* 空状态：快捷场景 chip */
.scene-quick-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.scene-quick-label {
  font-size: 12px;
  color: var(--text-dim);
}

.scene-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 360px;
}

.scene-quick-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.scene-quick-chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface2));
}

/* 场景库弹窗：分类过滤栏 */
.scene-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.scene-filter-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.scene-filter-tab:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.scene-filter-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* 场景库弹窗：商品/品类输入 */
.scene-product-row {
  margin-bottom: 14px;
}

.scene-product-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s;
}

.scene-product-input::placeholder {
  color: var(--text-dim);
}

.scene-product-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* 场景库弹窗：卡片网格 */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.scene-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  transition: all 0.15s;
}

.scene-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.scene-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scene-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.scene-card-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
}

.scene-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.scene-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.scene-card-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.scene-card-use {
  padding: 5px 12px;
  font-size: 12px;
  flex-shrink: 0;
}

.scene-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 0;
}


/* ════════════════════════════════════════════════════════════════════════════
   生成参数：比例 / 分辨率 / 张数 / 并发（picnow 风格）
   ════════════════════════════════════════════════════════════════════════════ */

.seg-aspect .seg-btn { padding: 6px 2px; }

.size-resolved {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.count-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
  cursor: pointer;
}

.count-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.12s;
}

.count-slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.count-slider-row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.count-slider-val {
  font-size: 12px;
  color: var(--text);
  min-width: 42px;
  text-align: right;
}
