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

:root {
  --bg: #0f1726;
  --bg-deep: #08111f;
  --surface: rgba(16, 25, 45, 0.72);
  --surface-solid: #121a2a;
  --surface2: rgba(18, 31, 53, 0.58);
  --surface3: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(148, 163, 184, 0.34);
  --accent: #94a3b8;
  --accent-hover: #cbd5e1;
  --accent-glow: rgba(148, 163, 184, 0.18);
  --text: #f5dfd6;
  --text-muted: #b8c4d1;
  --text-dim: #7b8798;
  --danger: #ef4444;
  --success: #34d399;
  --selected-bg: rgba(148, 163, 184, 0.1);
  --selected-border: rgba(203, 213, 225, 0.42);
  --warn: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --glass-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 54px rgba(0, 0, 0, 0.18);
}

html,
body {
  height: 100%;
  background:
    radial-gradient(circle at 76% 18%, rgba(37, 99, 145, 0.22) 0%, transparent 34%),
    radial-gradient(circle at 52% 108%, rgba(30, 41, 75, 0.24) 0%, transparent 42%),
    linear-gradient(112deg, #151a33 0%, #11233f 48%, #0e355d 100%);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.starfield::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), transparent 72%);
}

.starfield-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Layout ── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  background:
    radial-gradient(circle at 48% 20%, rgba(148, 163, 184, 0.07), transparent 30%),
    linear-gradient(90deg, rgba(8, 17, 31, 0.35), rgba(8, 17, 31, 0.08));
}

/* ── Left sidebar ── */
.sidebar {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  width: min(980px, calc(100vw - 72px));
  min-height: 0;
  flex-shrink: 0;
  background: rgba(13, 24, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 10px 12px 12px;
  color: var(--text);
}

.logo {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 0;
  flex: 0 0 auto;
  min-width: 0;
  margin-bottom: 0;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
}

.logo-icon {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease-in-out;
}

.logo-icon img:hover {
  transform: scale(1.1);
}

.logo-text {
  font-family: var(--font-display, "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif);
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  padding-right: 0;
  color: #f5dfd6;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 22px rgba(0, 0, 0, 0.22);
}

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

.sidebar-scroll {
  flex: none;
  overflow: visible;
  padding: 0;
  scrollbar-width: none;
  display: grid;
  grid-template-columns: 170px 132px 126px minmax(152px, 1fr) 116px auto;
  grid-template-rows: auto auto;
  gap: 6px 10px;
  align-items: end;
}

.sidebar-scroll::-webkit-scrollbar {
  display: none;
}

/* ── Form sections ── */
.section {
  margin-bottom: 0;
  min-width: 0;
}

.section-label {
  font-size: 0;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  margin-bottom: 0;
}

.sidebar-scroll > .divider,
.horizon-experimental-section {
  display: none !important;
}

.prompt-section {
  grid-column: 1 / -1;
  grid-row: 1;
}

.model-section {
  grid-column: 1;
  grid-row: 2;
}

.size-control-section {
  grid-column: 2;
  grid-row: 2;
  position: relative;
}

.quality-section {
  grid-column: 3;
  grid-row: 2;
}

.format-control-section {
  grid-column: 4;
  grid-row: 2;
}

.compression-control-section {
  grid-column: 4 / 5;
  grid-row: 2;
  align-self: start;
  transform: translateY(36px);
  z-index: 2;
}

.compression-control-section .section-label {
  display: none;
}

.compression-control-section .slider-wrap {
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(18, 31, 53, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.count-section {
  grid-column: 5;
  grid-row: 2;
}

.generate-section {
  grid-column: 6;
  grid-row: 2;
  display: flex;
  align-items: end;
  justify-self: end;
  gap: 6px;
}

.composer-select-display {
  width: 100%;
  max-width: 170px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(18, 31, 53, 0.74);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font: inherit;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: rgba(30, 44, 67, 0.9);
  color: var(--text-muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.composer-icon-btn svg {
  width: 20px;
  height: 20px;
}

.composer-icon-btn:hover {
  background: rgba(44, 60, 88, 0.92);
  color: var(--text);
}

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

.size-summary {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(18, 31, 53, 0.74);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.size-summary:hover {
  border-color: var(--border-hover);
  background: rgba(24, 39, 64, 0.9);
}

.size-summary span:first-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.size-summary strong {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.size-summary em {
  font-style: normal;
  font-size: 13px;
  color: var(--text-muted);
}

.size-summary-action {
  flex-shrink: 0;
  font-size: 0;
  color: var(--text-muted);
}

.size-summary-action::after {
  content: "⌄";
  font-size: 14px;
  line-height: 1;
}

#sizeSection.size-section-collapsed {
  display: none !important;
}

#sizeSection.size-section-expanded {
  display: block !important;
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  width: min(380px, calc(100vw - 40px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(13, 24, 42, 0.95);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(16px);
  z-index: 40;
}

/* ── 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);
}

.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 {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(18, 31, 53, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.prompt-editor.ref-drop-active {
  border-color: rgba(14, 165, 233, 0.44);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.prompt-toolbar {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 0;
  border-bottom: none;
  background: transparent;
}

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

.prompt-tool-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border);
}

.prompt-tool-btn svg {
  flex-shrink: 0;
  opacity: 0.9;
  width: 16px;
  height: 16px;
}

.prompt-tool-btn span {
  display: none;
}

.prompt-box {
  position: relative;
}

.prompt-box textarea {
  width: 100%;
  min-height: 38px;
  height: 38px;
  max-height: 130px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 8px 110px 7px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.45;
  transition: border-color 0.15s;
}

.prompt-box textarea:focus {
  box-shadow: none;
}

.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 {
  display: none;
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.count-max-hint {
  display: none;
  margin-top: 5px;
  font-size: 10px;
  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: 10px;
  padding: 8px 6px 7px;
  background: rgba(18, 31, 53, 0.72);
  text-align: center;
  transition: all 0.15s;
  user-select: none;
  color: var(--text);
}

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

.size-option.active {
  border-color: var(--selected-border);
  background: var(--selected-bg);
}

.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(--text-muted);
  opacity: 0.7;
}

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

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

/* ── Segmented control ── */
.seg {
  display: flex;
  min-height: 32px;
  background: rgba(18, 31, 53, 0.74);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.seg-btn {
  flex: 1;
  text-align: center;
  padding: 5px 7px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  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: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

#sizeModeSeg {
  margin-bottom: 8px !important;
  min-height: 34px;
}

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

.slider-wrap input[type=range] {
  flex: 1;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.22);
  outline: none;
  cursor: pointer;
}

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

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

/* ── Stepper ── */
.stepper {
  display: flex;
  align-items: center;
  min-height: 32px;
  background: rgba(18, 31, 53, 0.74);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

.stepper button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

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

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

/* ── Generate button ── */
.gen-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  background: rgba(30, 44, 67, 0.9);
  color: var(--text-muted);
  border: none;
  border-radius: 9px;
  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;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  white-space: nowrap;
}

.gen-btn:hover {
  background: rgba(44, 60, 88, 0.92);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

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

.gen-btn span {
  display: none;
}

.gen-btn text,
.gen-btn .label {
  display: none;
}

.gen-btn svg {
  width: 18px;
  height: 18px;
  transform: translateX(1px);
}

.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;
}

/* ── Canvas ── */
.canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(8, 17, 31, 0.22);
  width: 100%;
}

.canvas-toolbar {
  position: relative;
  height: 52px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(8, 17, 31, 0.54), rgba(8, 17, 31, 0.18)),
    radial-gradient(circle at 72% 0%, rgba(148, 163, 184, 0.08), transparent 44%);
  backdrop-filter: blur(3px);
}

.top-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: clamp(28px, 4vw, 58px);
  padding: 0 10px;
  border: none;
  border-radius: 0;
  background: transparent;
}

.top-nav-link {
  min-height: 36px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #c8d2df;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s, text-shadow 0.15s;
}

.top-nav-link:hover {
  color: var(--text);
  background: transparent;
  text-decoration: none;
  text-shadow: 0 0 18px rgba(203, 213, 225, 0.2);
}

.top-nav-link.active {
  color: var(--text);
  background: transparent;
}

.toolbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  flex: 1;
  opacity: 0;
  pointer-events: none;
}

.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);
}

.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 6px 12px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.04);
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}

.balance-pill:hover {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}

.balance-icon {
  width: 16px;
  height: 16px;
  color: #16a34a;
  flex-shrink: 0;
}

.balance-value {
  color: #16a34a;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
}

.balance-pill.is-loading .balance-value {
  color: rgba(22, 163, 74, 0.72);
}

.balance-pill.is-error .balance-value {
  color: var(--danger);
}

.balance-pill.is-error {
  border-color: rgba(239, 68, 68, 0.34);
  background: rgba(239, 68, 68, 0.1);
}

.toolbar-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 12px;
  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 0 118px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.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: rgba(16, 25, 45, 0.7);
  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: rgba(16, 25, 45, 0.78);
  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.is-dragging {
  opacity: 0.62;
}

.image-card img {
  user-select: none;
  -webkit-user-drag: element;
}

.image-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36), 0 0 24px var(--accent-glow);
}

.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(122, 240, 196, 0.35);
  color: var(--accent);
  background: rgba(122, 240, 196, 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);
}

/* ── 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(122, 240, 196, 0);
  }

  50% {
    border-color: var(--accent-hover);
    box-shadow: 0 0 12px 1px rgba(122, 240, 196, 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(122, 240, 196, 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(122, 240, 196, 0.18);
  border-top-color: var(--accent);
  border-right-color: rgba(122, 240, 196, 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(122, 240, 196, 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(122, 240, 196, 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);
}

/* ── 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 {
  position: static;
  margin-left: 0;
  background: rgba(8, 17, 31, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  pointer-events: auto;
}

.settings-btn:hover {
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--text-muted);
  background: rgba(8, 17, 31, 0.78);
}

.settings-btn.has-key {
  border-color: rgba(148, 163, 184, 0.24);
  color: var(--text-muted);
}

/* ── Shortcut hint ── */
.shortcut-hint {
  display: none;
  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(8, 17, 31, 0.72);
  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: rgba(16, 25, 45, 0.94);
  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);
  backdrop-filter: blur(8px);
  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-field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.apikey-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: color 0.15s;
  white-space: nowrap;
}

.apikey-link:hover {
  color: var(--text);
  text-decoration: none;
}

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

.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);
}

.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);
}

/* 示例卡：底部信息叠在图上，下实上透明渐变 */
.example-gallery-card {
  position: relative;
  overflow: hidden;
}

.example-gallery-card .modal-card-media-23 {
  position: relative;
}

.example-gallery-card-footer.modal-gallery-card-footer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  border-top: none;
  margin: 0;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 5px;
  min-height: 0;
  background: linear-gradient(to top, var(--surface) 0%, transparent 100%);
  /* 渐变层不抢点击，事件落到下层图片（大图预览） */
  pointer-events: none;
}

.example-gallery-card-footer .modal-gallery-actions {
  pointer-events: auto;
}

.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;
}

.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;
}

.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 {
  display: none;
  position: absolute;
  left: 44px;
  bottom: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  pointer-events: auto;
}

.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: 10px;
  padding: 8px;
  background: rgba(18, 31, 53, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
  align-items: flex-start;
}

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

.ref-images-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  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(122, 240, 196, 0.06);
}

.ref-upload-zone.ref-upload-drag {
  border-color: var(--accent);
  background: rgba(122, 240, 196, 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: 7px;
}

.size-ratio-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 4px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: rgba(18, 31, 53, 0.74);
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  user-select: none;
}

.size-ratio-chip:hover {
  border-color: var(--border-hover);
  background: rgba(24, 39, 64, 0.9);
}

.size-ratio-chip.active {
  border-color: var(--selected-border);
  background: rgba(148, 163, 184, 0.16);
}

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

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

.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-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.size-ratio-chip.active .size-ratio-thumb-auto {
  border-color: var(--text-muted);
  color: var(--text);
  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: 9px;
  background: rgba(18, 31, 53, 0.74);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.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: rgba(8, 17, 31, 0.52);
  border: 1px solid var(--border);
  border-radius: 8px;
  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: rgba(71, 85, 105, 0.72);
  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: rgba(100, 116, 139, 0.82);
}

.size-custom-hint {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-muted);
  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(148, 163, 184, 0.2);
  border-color: var(--selected-border);
}

.toggle-row input[type="checkbox"]:checked~.toggle-switch::after {
  background: var(--text-muted);
  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;
  }

  .sidebar {
    left: 10px;
    right: auto;
    bottom: 10px;
    transform: none;
    width: calc(100vw - 20px);
    min-height: 0;
    padding: 12px;
    border-radius: 20px;
  }

  .sidebar-scroll {
    max-height: none;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 10px;
  }

  .prompt-section {
    grid-column: 1 / -1;
  }

  .model-section,
  .size-control-section,
  .quality-section,
  .format-control-section,
  .count-section {
    grid-column: auto;
    grid-row: auto;
  }

  .generate-section {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-content: flex-end;
  }

  .prompt-box textarea {
    height: 56px;
    min-height: 56px;
    padding: 15px 118px 12px 16px;
    font-size: 16px;
  }

  .prompt-tool-btn {
    width: 28px;
    height: 28px;
  }

  .prompt-tool-btn svg {
    width: 17px;
    height: 17px;
  }

  .section-label {
    font-size: 11px;
    margin-bottom: 5px;
  }

  .composer-select-display,
  .size-summary,
  .seg,
  .stepper {
    min-height: 42px;
    border-radius: 14px;
  }

  .seg-btn,
  .size-summary strong,
  .size-summary em,
  .composer-select-display,
  .stepper span {
    font-size: 14px;
  }

  .composer-icon-btn,
  .gen-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  html,
  body {
    overflow: hidden;
  }

  .canvas-body {
    min-height: 60vh;
    padding-bottom: 270px;
  }

  .chat-feed {
    width: 100%;
    margin: 0;
  }

  .chat-row {
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-left,
  .chat-right {
    padding-left: 0;
    padding-right: 0;
  }
}

/* ── Chat feed (对话流) ── */
.chat-feed {
  display: flex;
  flex-direction: column;
  width: min(100%, 1180px);
  margin: 0 auto;
}

.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 32px 16px;
  animation: chatRowIn 0.2s ease-out;
}

@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;
  padding-right: clamp(24px, 7vw, 120px);
}

/* ── Left side: A avatar + image output ── */
.chat-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-left: clamp(24px, 7vw, 120px);
}

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

/* ── 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: var(--surface3, #1a1a2e);
  box-shadow: 0 2px 8px var(--accent-glow);
  overflow: hidden;
  padding: 0;
}

.av-a img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.av-u {
  background: linear-gradient(135deg, #256391, #34d399);
  color: #fff;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.28);
}

/* ── 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: 12px;
}

.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;
}

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

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

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