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

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ---------- 深色模式（默认） ---------- */
body {
  background: #0f0e0d;
  background-image: radial-gradient(circle at 20% 30%, #1b1714, #0a0908 80%);
  color: #eae5de;
}

body .app-container {
  width: 100%;
  height: 100vh;
  background: rgba(20, 18, 16, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 20px 28px 24px;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease;
}

/* ---------- 顶部导航（三栏布局） ---------- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 215, 140, 0.06);
  margin-bottom: 20px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-width: 100px;
}

.header-center {
  flex: 1;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 60px;
  justify-content: flex-end;
}

.logo-icon {
  font-size: 1.6rem;
  color: #e8b84c;
  display: inline-block;
  line-height: 1;
}

.logo-text {
  font-family: 'Georgia', 'Times New Roman', 'Noto Serif SC', serif;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #f5e8d8, #e8c86a, #d4a030);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.badge {
  font-size: 0.6rem;
  padding: 2px 10px;
  border-radius: 100px;
  background: rgba(232, 184, 76, 0.15);
  color: #e8b84c;
  border: 1px solid rgba(232, 184, 76, 0.15);
  white-space: nowrap;
  margin-left: 8px;
  vertical-align: middle;
}

body .panel {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 215, 140, 0.05);
}

body .field-group input,
body .field-group textarea,
body .field-group select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 140, 0.1);
  color: #eae5de;
}

body .canvas-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(255, 215, 140, 0.08);
}

body .placeholder {
  color: #4a3f35;
}

body .history-empty {
  color: #4a3f35;
}

/* ---------- 浅色模式 ---------- */
body.light-mode {
  background: #f5f0eb;
  background-image: radial-gradient(circle at 20% 30%, #faf6f0, #e8e0d8 80%);
  color: #1a1612;
}

body.light-mode .app-container {
  background: rgba(255, 252, 248, 0.85);
  backdrop-filter: blur(20px);
}

body.light-mode .header {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .logo-text {
  background: linear-gradient(135deg, #6a5f52, #d4a030, #b8892a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.light-mode .badge {
  color: #8a7a6a;
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .panel {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.04);
}

body.light-mode .panel-title {
  color: #6a5f52;
}

body.light-mode .field-group label {
  color: #6a5f52;
}

body.light-mode .field-group input,
body.light-mode .field-group textarea,
body.light-mode .field-group select {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.1);
  color: #1a1612;
}

body.light-mode .field-group input:focus,
body.light-mode .field-group textarea:focus,
body.light-mode .field-group select:focus {
  border-color: #d4a030;
  background: rgba(255, 255, 255, 0.9);
}

body.light-mode .btn-ghost {
  color: #6a5f52;
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .btn-ghost:hover {
  border-color: #d4a030;
  color: #1a1612;
}

body.light-mode .canvas-box {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .placeholder {
  color: #b0a090;
}

body.light-mode .placeholder-hint {
  color: #c0b0a0;
}

body.light-mode .badge-idle {
  color: #8a7a6a;
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.04);
}

body.light-mode .history-section {
  border-top-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .history-header {
  color: #8a7a6a;
}

body.light-mode .history-empty {
  color: #b0a090;
}

body.light-mode .btn-secondary {
  color: #6a5f52;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .btn-secondary:hover {
  border-color: #d4a030;
  color: #1a1612;
}

body.light-mode .status-text {
  color: #6a5f52;
}

body.light-mode .theme-toggle {
  color: #d4a030;
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .theme-toggle:hover {
  background: rgba(212, 160, 48, 0.08);
  border-color: #d4a030;
}

body.light-mode .error-box {
  color: #c0392b;
}

body.light-mode .history-thumb {
  border-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .history-quality-label {
  background: rgba(255, 255, 255, 0.85);
  color: #d4a030;
}

/* ---------- 通用组件样式 ---------- */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #a09080;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.theme-toggle {
  background: transparent;
  border: 1px solid rgba(255, 215, 140, 0.15);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  color: #e8b84c;
}

.theme-toggle:hover {
  background: rgba(232, 184, 76, 0.1);
  border-color: #e8b84c;
  transform: scale(1.05);
}

/* ===== 主体布局：左右两列 ===== */
.main-grid {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0;
  justify-content: center;
  align-items: flex-start;
}

/* ===== 左侧控制台（固定） ===== */
.control-panel {
  width: 320px;
  flex-shrink: 0;
  gap: 10px;
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 20px;
  align-self: flex-start;
  max-height: calc(100vh - 40px);
}

.control-panel .panel-title {
  flex-shrink: 0;
  margin-bottom: 10px;
}

/* ===== 右侧列 ===== */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 1200px;
  flex-shrink: 0;
  min-height: 0;
}

/* ===== 面板通用 ===== */
.panel {
  border-radius: 20px;
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: #b8a692;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
  flex-shrink: 0;
}

/* ===== 生成结果面板 ===== */
.result-panel {
  flex: 0 0 auto;
  min-height: 0;
  padding: 14px 18px 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.result-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.result-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.result-col-title {
  font-size: 0.7rem;
  color: #8a7a6a;
  font-weight: 500;
}

/* ===== 参考图导航 ===== */
.ref-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ref-nav-btn {
  background: transparent;
  border: 1px solid rgba(255, 215, 140, 0.12);
  border-radius: 4px;
  color: #8a7a6a;
  padding: 0px 6px;
  font-size: 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.6;
}

.ref-nav-btn:hover {
  border-color: #e8b84c;
  color: #eae5de;
}

.ref-index {
  font-size: 0.6rem;
  color: #6a5f52;
  min-width: 28px;
  text-align: center;
}

/* ===== 画布（参考图和生成图共用） ===== */
.result-canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(255, 215, 140, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* ===== 参考图 ===== */
.ref-placeholder {
  text-align: center;
  color: #5a4f42;
}

.ref-placeholder-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 4px;
  opacity: 0.4;
}

.ref-placeholder p {
  font-size: 0.75rem;
}

.ref-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* ===== 生成图（原有） ===== */
.placeholder {
  text-align: center;
  color: #5a4f42;
}

.placeholder p {
  font-size: 0.85rem;
}

.result-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
  margin-top: 8px;
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(255, 215, 140, 0.12);
  border-radius: 12px;
  color: #b8a692;
  padding: 8px 18px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  border-color: #e8b84c;
  color: #eae5de;
}

/* ===== 任务队列面板 ===== */
.task-panel {
  flex-shrink: 0;
  padding: 10px 18px 12px;
  max-height: 140px;
}

.task-queue {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.task-queue-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #8a7a6a;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.task-count {
  color: #b8a692;
  font-weight: 500;
}

.task-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.task-list::-webkit-scrollbar {
  width: 4px;
}

.task-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.task-list::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 140, 0.2);
  border-radius: 4px;
}

.task-empty {
  color: #4a3f35;
  font-size: 0.8rem;
  text-align: center;
  padding: 4px 0;
}

/* ===== 任务网格 ===== */
.task-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  padding-bottom: 2px;
}

.task-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.task-grid-thumb-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 215, 140, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-grid-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-grid-thumb-placeholder {
  font-size: 1rem;
  opacity: 0.3;
}

.task-grid-status-block {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 500;
  color: #fff;
}

.task-grid-status-block.done {
  background: rgba(76, 175, 80, 0.7);
}

.task-grid-status-block.failed {
  background: rgba(200, 50, 50, 0.7);
}

.task-grid-status-badge {
  position: absolute;
  bottom: 1px;
  right: 1px;
  font-size: 0.35rem;
  padding: 0px 3px;
  border-radius: 2px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.3;
}

.task-grid-status-badge.queued {
  background: rgba(255, 215, 140, 0.15);
  color: #8a7a6a;
}

.task-grid-status-badge.running {
  background: rgba(232, 184, 76, 0.2);
  color: #e8b84c;
  animation: statusPulse 1s ease-in-out infinite;
}

.task-grid-prompt {
  font-size: 0.4rem;
  color: #6a5f52;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  line-height: 1.1;
}

.task-grid-delete {
  position: absolute;
  top: 1px;
  right: 2px;
  background: rgba(200, 50, 50, 0.8);
  border: none;
  border-radius: 2px;
  color: #fff;
  width: 12px;
  height: 12px;
  font-size: 0.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 3;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
}

.task-grid-delete:hover {
  background: rgba(220, 30, 30, 1);
  opacity: 1;
  transform: scale(1.1);
}

.task-grid-retry {
  background: transparent;
  border: 1px solid rgba(200, 50, 50, 0.3);
  color: #e8745a;
  cursor: pointer;
  font-size: 0.4rem;
  padding: 0px 3px;
  border-radius: 2px;
  transition: all 0.2s ease;
  line-height: 1.2;
}

.task-grid-retry:hover {
  background: rgba(200, 50, 50, 0.15);
  border-color: #e8745a;
}

.task-grid-timer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: none;
  display: none;
}

.task-grid-timer-circle {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  box-shadow: 0 0 10px rgba(232, 184, 76, 0.08);
  animation: taskTimerGlow 2s ease-in-out infinite;
}

.task-grid-timer-ring {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #e8b84c;
  border-bottom-color: #e8b84c;
  animation: taskTimerSpin 1.8s linear infinite;
}

.task-grid-timer-ring::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-left-color: rgba(232, 184, 76, 0.3);
  border-right-color: rgba(232, 184, 76, 0.3);
  animation: taskTimerSpinReverse 2.4s linear infinite;
}

.task-grid-timer-content {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  z-index: 2;
}

.task-grid-timer-seconds {
  font-size: 0.65rem;
  font-weight: 700;
  color: #e8b84c;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.task-grid-timer-unit {
  font-size: 0.35rem;
  color: #b8a692;
  font-weight: 400;
}

@keyframes taskTimerGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(232, 184, 76, 0.04); }
  50% { box-shadow: 0 0 16px rgba(232, 184, 76, 0.12); }
}

@keyframes taskTimerSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes taskTimerSpinReverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== 历史记录面板 ===== */
.history-panel {
  flex-shrink: 0;
  padding: 10px 18px 12px;
  max-height: 180px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.history-header .panel-title {
  margin-bottom: 0;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-count {
  font-size: 0.7rem;
  color: #5a4f42;
}

.history-btn {
  background: transparent;
  border: 1px solid rgba(255, 215, 140, 0.12);
  border-radius: 6px;
  color: #8a7a6a;
  padding: 2px 10px;
  font-size: 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.history-btn:hover {
  border-color: #e8b84c;
  color: #eae5de;
}

.history-btn.danger:hover {
  border-color: #e8745a;
  color: #e8745a;
}

body.light-mode .history-btn {
  border-color: rgba(0, 0, 0, 0.08);
  color: #8a7a6a;
}

body.light-mode .history-btn:hover {
  border-color: #d4a030;
  color: #1a1612;
}

body.light-mode .history-btn.danger:hover {
  border-color: #c0392b;
  color: #c0392b;
}

/* ---- 历史缩略图区域（紧凑） ---- */
.history-strip {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  padding-bottom: 2px;
  max-height: 120px;
  overflow-y: auto;
  align-content: start;
}

.history-strip::-webkit-scrollbar {
  width: 4px;
}

.history-strip::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.history-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 140, 0.2);
  border-radius: 4px;
}

.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #4a3f35;
  font-size: 0.8rem;
  padding: 4px 0;
}

.history-item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 1px;
}

.history-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 140, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
}

.history-thumb:hover {
  border-color: #e8b84c;
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ---- 分辨率数字（取代原来的 1K/2K/4K 标签） ---- */
.history-resolution {
  font-size: 0.55rem;
  color: #b8a692;
  text-align: center;
  line-height: 1.2;
  margin-top: 1px;
}

body.light-mode .history-resolution {
  color: #8a7a6a;
}

/* ---- 旧版质量标签（兼容旧记录，可保留） ---- */
.history-quality-label {
  position: absolute;
  bottom: 1px;
  right: 3px;
  background: rgba(0, 0, 0, 0.75);
  color: #e8b84c;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 0px 4px;
  border-radius: 2px;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.history-duration {
  font-size: 0.55rem;
  color: #6a5f52;
  text-align: center;
  margin-top: 0px;
  line-height: 1.1;
}

body.light-mode .history-duration {
  color: #8a7a6a;
}

/* ===== 主计时器（画布中心） ===== */
.timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
}

.timer-circle {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 40px rgba(232, 184, 76, 0.12);
  animation: timerGlow 2s ease-in-out infinite;
}

.timer-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #e8b84c;
  border-bottom-color: #e8b84c;
  animation: timerSpin 1.8s linear infinite;
  box-shadow: 0 0 20px rgba(232, 184, 76, 0.08);
}

.timer-ring::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-left-color: rgba(232, 184, 76, 0.3);
  border-right-color: rgba(232, 184, 76, 0.3);
  animation: timerSpinReverse 2.4s linear infinite;
}

.timer-content {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  z-index: 2;
}

.timer-content #timerSeconds {
  font-size: 2rem;
  font-weight: 700;
  color: #e8b84c;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.timer-content .timer-unit {
  font-size: 0.8rem;
  color: #b8a692;
  font-weight: 400;
}

@keyframes timerGlow {
  0%, 100% { box-shadow: 0 0 30px rgba(232, 184, 76, 0.06); }
  50% { box-shadow: 0 0 60px rgba(232, 184, 76, 0.2); }
}

@keyframes timerSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes timerSpinReverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

body.light-mode .timer-circle {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 40px rgba(212, 160, 48, 0.1);
}

body.light-mode .timer-content #timerSeconds {
  color: #d4a030;
}

body.light-mode .timer-content .timer-unit {
  color: #8a7a6a;
}

body.light-mode .timer-ring {
  border-top-color: #d4a030;
  border-bottom-color: #d4a030;
}

body.light-mode .timer-ring::after {
  border-left-color: rgba(212, 160, 48, 0.25);
  border-right-color: rgba(212, 160, 48, 0.25);
}

/* ===== 积分信息 ===== */
.credit-info {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 4px 0 6px 0;
  font-size: 0.8rem;
  color: #b8a692;
  border-bottom: 1px solid rgba(255, 215, 140, 0.06);
  margin-bottom: 8px;
}

.credit-label {
  color: #8a7a6a;
}

.credit-remaining {
  font-weight: 700;
  color: #e8b84c;
  font-size: 0.95rem;
}

body.light-mode .credit-info {
  color: #6a5f52;
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .credit-label {
  color: #8a7a6a;
}

body.light-mode .credit-remaining {
  color: #d4a030;
}

/* ===== 积分消耗提示 ===== */
.cost-hint {
  font-size: 0.7rem;
  color: #8a7a6a;
  text-align: center;
  padding: 2px 0 0px 0;
  letter-spacing: 0.02em;
}

.cost-hint #costAmount {
  color: #e8b84c;
  font-weight: 600;
}

.cost-hint #costResolution {
  color: #b8a692;
  font-weight: 500;
}

body.light-mode .cost-hint {
  color: #8a7a6a;
}

body.light-mode .cost-hint #costAmount {
  color: #d4a030;
}

body.light-mode .cost-hint #costResolution {
  color: #6a5f52;
}

/* ===== 上传区域 ===== */
.upload-zone {
  border: 1px dashed rgba(255, 215, 140, 0.2);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
}

.upload-zone:hover {
  border-color: rgba(255, 215, 140, 0.4);
  background: rgba(255, 255, 255, 0.04);
}

.upload-zone.dragover {
  border-color: #e8b84c;
  background: rgba(232, 184, 76, 0.08);
}

.upload-placeholder p {
  color: #8a7a6a;
  font-size: 0.75rem;
  margin: 0;
}

.upload-hint {
  color: #5a4f42;
  font-size: 0.6rem;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.upload-grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 140, 0.1);
  background: rgba(0, 0, 0, 0.3);
}

.upload-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-grid-item .index-label {
  position: absolute;
  bottom: 2px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.5rem;
  padding: 0px 6px;
  border-radius: 3px;
  font-weight: 500;
  z-index: 2;
}

.upload-grid-item .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(200, 50, 50, 0.9);
  border: none;
  border-radius: 2px;
  color: #fff;
  width: 14px;
  height: 14px;
  font-size: 0.45rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 3;
  line-height: 1;
  padding: 0;
}

.upload-grid-item .remove-btn:hover {
  background: rgba(220, 30, 30, 1);
  transform: scale(1.1);
}

.upload-grid-item.clear-all-item {
  border: 2px dashed rgba(255, 215, 140, 0.15);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.upload-grid-item.clear-all-item:hover {
  border-color: rgba(200, 50, 50, 0.4);
  background: rgba(200, 50, 50, 0.06);
}

.clear-all-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.clear-all-icon {
  font-size: 1rem;
  opacity: 0.6;
  color: #8a7a6a;
}

.clear-all-text {
  font-size: 0.5rem;
  color: #8a7a6a;
  opacity: 0.7;
}

.upload-grid-item.clear-all-item:hover .clear-all-icon {
  opacity: 1;
  color: #e8745a;
}

.upload-grid-item.clear-all-item:hover .clear-all-text {
  color: #e8745a;
  opacity: 1;
}

/* ===== 拖拽排序样式 ===== */
.upload-grid-item.drag-over {
  border-color: #e8b84c;
  box-shadow: 0 0 16px rgba(232, 184, 76, 0.15);
  transform: scale(1.02);
}

.upload-grid-item.dragging {
  opacity: 0.4;
}

body.light-mode .upload-grid-item.drag-over {
  border-color: #d4a030;
  box-shadow: 0 0 16px rgba(212, 160, 48, 0.1);
}

body.light-mode .upload-zone {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.02);
}

body.light-mode .upload-zone:hover {
  border-color: rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .upload-placeholder p {
  color: #6a5f52;
}

body.light-mode .upload-hint {
  color: #a09080;
}

body.light-mode .upload-grid-item.clear-all-item {
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .upload-grid-item.clear-all-item:hover {
  border-color: rgba(200, 50, 50, 0.35);
}

body.light-mode .clear-all-text {
  color: #8a7a6a;
}

body.light-mode .upload-grid-item.clear-all-item:hover .clear-all-text {
  color: #c0392b;
}

/* ===== 分辨率/尺寸按钮 ===== */
.quality-options {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.quality-btn {
  flex: 1;
  padding: 0 12px;
  height: 34px;
  border: 1px solid rgba(255, 215, 140, 0.12);
  border-radius: 10px;
  background: transparent;
  color: #a09080;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  white-space: nowrap;
}

.quality-btn:hover {
  border-color: #e8b84c;
  color: #eae5de;
}

.quality-btn.active {
  background: linear-gradient(145deg, #e8b84c, #d49a2e);
  border-color: #e8b84c;
  color: #0f0e0d;
  box-shadow: 0 4px 12px rgba(212, 154, 46, 0.2);
}

body.light-mode .quality-btn {
  border-color: rgba(0, 0, 0, 0.08);
  color: #8a7a6a;
}

body.light-mode .quality-btn:hover {
  border-color: #d4a030;
  color: #1a1612;
}

body.light-mode .quality-btn.active {
  background: linear-gradient(145deg, #e8b84c, #d49a2e);
  border-color: #e8b84c;
  color: #0f0e0d;
}

/* ===== 2K 推荐标识 ===== */
.quality-btn.recommended {
  position: relative;
}

.quality-btn.recommended::after {
  content: "推荐";
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 0.5rem;
  font-weight: 700;
  background: #e8745a;
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(232, 116, 90, 0.3);
  white-space: nowrap;
}

body.light-mode .quality-btn.recommended::after {
  background: #d94f3a;
  box-shadow: 0 2px 8px rgba(217, 79, 58, 0.3);
}

/* ===== 模型按钮 ===== */
.model-options {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.model-btn {
  flex: 1;
  padding: 0 12px;
  height: 34px;
  border: 1px solid rgba(255, 215, 140, 0.12);
  border-radius: 10px;
  background: transparent;
  color: #a09080;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  white-space: nowrap;
}

.model-btn:hover {
  border-color: #e8b84c;
  color: #eae5de;
}

.model-btn.active {
  background: linear-gradient(145deg, #e8b84c, #d49a2e);
  border-color: #e8b84c;
  color: #0f0e0d;
  box-shadow: 0 4px 12px rgba(212, 154, 46, 0.2);
}

body.light-mode .model-btn {
  border-color: rgba(0, 0, 0, 0.08);
  color: #8a7a6a;
}

body.light-mode .model-btn:hover {
  border-color: #d4a030;
  color: #1a1612;
}

body.light-mode .model-btn.active {
  background: linear-gradient(145deg, #e8b84c, #d49a2e);
  border-color: #e8b84c;
  color: #0f0e0d;
}

/* ===== 尺寸按钮 ===== */
.size-options {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.size-btn {
  flex: 1;
  padding: 0 6px;
  height: 30px;
  border: 1px solid rgba(255, 215, 140, 0.1);
  border-radius: 8px;
  background: transparent;
  color: #a09080;
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  white-space: nowrap;
}

.size-btn:hover {
  border-color: #e8b84c;
  color: #eae5de;
}

.size-btn.active {
  background: linear-gradient(145deg, #e8b84c, #d49a2e);
  border-color: #e8b84c;
  color: #0f0e0d;
  box-shadow: 0 4px 12px rgba(212, 154, 46, 0.2);
}

body.light-mode .size-btn {
  border-color: rgba(0, 0, 0, 0.08);
  color: #8a7a6a;
}

body.light-mode .size-btn:hover {
  border-color: #d4a030;
  color: #1a1612;
}

body.light-mode .size-btn.active {
  background: linear-gradient(145deg, #e8b84c, #d49a2e);
  border-color: #e8b84c;
  color: #0f0e0d;
}

/* ===== 其他表单元素 ===== */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.field-group label {
  font-size: 0.65rem;
  font-weight: 500;
  color: #a09080;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field-group input,
.field-group textarea,
.field-group select {
  border-radius: 10px;
  font-size: 0.8rem;
  padding: 8px 12px;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 140, 0.08);
  color: #eae5de;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  border-color: #e8b84c;
  box-shadow: 0 0 0 3px rgba(232, 184, 76, 0.06);
}

.field-group textarea {
  resize: vertical;
  min-height: 60px;
  flex: 1;
}

.key-input-row {
  display: flex;
  gap: 6px;
}

.key-input-row input {
  flex: 1;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 215, 140, 0.1);
  border-radius: 10px;
  color: #a09080;
  padding: 0 12px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-ghost:hover {
  border-color: #e8b84c;
  color: #eae5de;
}

.btn-primary {
  background: linear-gradient(145deg, #e8b84c, #d49a2e);
  border: none;
  border-radius: 14px;
  color: #0f0e0d;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(212, 154, 46, 0.15);
  flex-shrink: 0;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(212, 154, 46, 0.25);
}

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

.error-box {
  color: #e8745a;
  font-size: 0.75rem;
  border-left: 3px solid #e8745a;
  padding-left: 10px;
  margin-top: 2px;
  flex-shrink: 0;
  min-height: 20px;
}

/* ===== 图片放大查看模态框 ===== */
.image-modal {
  position: fixed;
  z-index: 9999;
  padding: 40px 20px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-modal .modal-content {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  animation: modalFadeIn 0.25s ease;
  cursor: default;
  transition: transform 0.15s ease;
}

.image-modal .modal-close {
  position: fixed;
  top: 20px;
  right: 28px;
  color: #fff;
  font-size: 2.6rem;
  font-weight: 300;
  cursor: pointer;
  transition: all 0.25s ease;
  line-height: 1;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.4);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  border: none;
  padding: 0;
}

.image-modal .modal-close:hover {
  color: #e8b84c;
  background: rgba(0, 0, 0, 0.7);
  transform: rotate(90deg);
}

@keyframes modalFadeIn {
  0% { opacity: 0; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1); }
}

body.light-mode .image-modal {
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.light-mode .image-modal .modal-close {
  color: #1a1612;
  background: rgba(0, 0, 0, 0.06);
}

body.light-mode .image-modal .modal-close:hover {
  color: #d4a030;
  background: rgba(0, 0, 0, 0.1);
}

/* ===== 图片鼠标悬停提示 ===== */
.result-image,
.ref-image,
.history-thumb {
  cursor: pointer;
}

/* ===== 强制隐藏田字框 ===== */
.frame-corner {
  display: none !important;
}

/* ===== 加载状态 ===== */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  color: #b8a692;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(232, 184, 76, 0.1);
  border-top-color: #e8b84c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
  .control-panel {
    width: 280px;
  }
  .right-column {
    width: 600px;
  }
  .task-grid {
    grid-template-columns: repeat(8, 1fr);
  }
  .history-strip {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 900px) {
  .main-grid {
    flex-direction: column;
  }
  .control-panel {
    width: 100%;
    flex-shrink: 0;
    max-height: 380px;
    position: static;
    max-height: none;
  }
  .right-column {
    width: 100%;
    flex-shrink: 1;
  }
  .result-grid {
    grid-template-columns: 1fr 1fr;
  }
  .task-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  .history-strip {
    grid-template-columns: repeat(6, 1fr);
  }
  .header-center .logo-text {
    font-size: 1.4rem;
  }
}

/* ===== 手机端适配（完整版，含上传缩略图修复） ===== */
@media (max-width: 1024px) {
  html, body {
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh;
  }

  .app-container {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100vh;
    padding: 16px;
  }

  .main-grid {
    flex-direction: column !important;
    gap: 16px !important;
  }

  .control-panel {
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    padding: 14px 16px 16px !important;
    position: static !important;
  }

  .right-column {
    width: 100% !important;
    flex-shrink: 0 !important;
    gap: 12px;
  }

  .result-panel {
    padding: 12px 14px 14px !important;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  .result-canvas {
    min-height: 180px !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
  }

  .result-actions {
    flex-wrap: wrap;
    justify-content: center;
  }

  .task-panel {
    max-height: none !important;
    padding: 10px 14px 12px !important;
  }

  .task-grid {
    grid-template-columns: repeat(6, 1fr) !important;
  }

  .history-panel {
    max-height: none !important;
    padding: 10px 14px 12px !important;
  }

  .history-strip {
    grid-template-columns: repeat(5, 1fr) !important;
    max-height: none !important;
  }

  .history-thumb {
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
  }

  .history-item {
    width: 100% !important;
  }

  .result-col-header {
    flex-wrap: wrap;
    gap: 4px;
  }

  .ref-nav {
    gap: 4px;
  }

  .ref-nav-btn {
    padding: 0 4px;
    font-size: 0.5rem;
  }

  .upload-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .upload-grid-item {
    position: relative !important;
    aspect-ratio: 1 / 1 !important;
    min-height: 60px !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    border: 1px solid rgba(255, 215, 140, 0.1) !important;
    background: rgba(0, 0, 0, 0.3) !important;
  }

  .upload-grid-item img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  .upload-zone {
    min-height: 100px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .upload-placeholder {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 80px !important;
    padding: 8px 0 !important;
  }

  .upload-placeholder p {
    display: block !important;
    font-size: 0.8rem !important;
    color: #8a7a6a !important;
    margin: 4px 0 !important;
  }

  .upload-hint {
    display: block !important;
    font-size: 0.65rem !important;
    color: #5a4f42 !important;
  }

  .upload-grid-item.clear-all-item {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2px dashed rgba(255, 215, 140, 0.15) !important;
    cursor: pointer !important;
  }

  .clear-all-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 2px !important;
  }
}

/* 小手机 */
@media (max-width: 600px) {
  .app-container {
    padding: 12px;
  }

  .control-panel {
    padding: 8px 10px 12px !important;
    position: static !important;
  }

  .right-column {
    gap: 8px;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .result-canvas {
    min-height: 120px !important;
  }

  .result-col-header {
    font-size: 0.7rem;
  }

  .result-col-title {
    font-size: 0.6rem;
  }

  .task-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .history-strip {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .field-group textarea {
    min-height: 40px;
  }

  .quality-options {
    gap: 4px;
  }

  .quality-btn {
    font-size: 0.65rem;
    height: 28px;
    padding: 0 6px;
  }

  .size-options {
    gap: 3px;
  }

  .size-btn {
    font-size: 0.55rem;
    height: 26px;
    padding: 0 4px;
  }

  .btn-primary {
    font-size: 0.8rem;
    padding: 10px;
  }

  .header-center .logo-text {
    font-size: 1.1rem;
  }

  .upload-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px !important;
  }

  .upload-grid-item {
    min-height: 50px !important;
  }

  .upload-grid-item img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  .upload-zone {
    min-height: 100px !important;
    padding: 12px 8px !important;
  }

  .upload-placeholder {
    min-height: 60px !important;
  }

  .upload-placeholder p {
    font-size: 0.7rem !important;
  }
}