:root {
  --page-bg: #eef3fb;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --card-bg: #ffffff;
  --card-soft: #f8fbff;
  --border: #d9e3f2;
  --border-strong: #c9d7eb;
  --text: #172033;
  --text-soft: #4f5f76;
  --muted: #8090a8;
  --primary: #5b75f6;
  --primary-hover: #4764ea;
  --primary-soft: #edf2ff;
  --success: #16a34a;
  --error: #dc2626;
  --shadow: 0 18px 46px rgba(40, 67, 112, 0.12);
  --soft-shadow: 0 8px 24px rgba(40, 67, 112, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0f172a;
  --topbar-bg: rgba(15, 23, 42, 0.92);
  --card-bg: #111827;
  --card-soft: #172033;
  --border: #263449;
  --border-strong: #334155;
  --text: #e5edf8;
  --text-soft: #b8c3d4;
  --muted: #7f8da3;
  --primary: #818cf8;
  --primary-hover: #6d7bf4;
  --primary-soft: rgba(129, 140, 248, 0.16);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  --soft-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

html,
body,
button,
input,
select,
textarea,
option {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.9) 0, rgba(255, 255, 255, 0) 360px),
    linear-gradient(180deg, #f6f8fc 0%, var(--page-bg) 100%);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 50% 0%, rgba(67, 56, 202, 0.18) 0, rgba(67, 56, 202, 0) 380px),
    linear-gradient(180deg, #111827 0%, var(--page-bg) 100%);
}

body.modal-open {
  overflow: hidden;
}

/* 顶部导航：参考图中的白色细导航栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(320px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 0 32px;
  background: var(--topbar-bg);
  border-bottom: 1px solid #e0e7f2;
  backdrop-filter: blur(16px);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-title {
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.08em;
  color: #253042;
}

.brand-subtitle {
  color: #79869a;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 3px;
  border: 1px solid #d8e0ee;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 1px 2px rgba(65, 84, 118, 0.06);
}

.top-tab {
  min-width: 78px;
  height: 28px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #273449;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.top-tab.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #273449;
  font-size: 13px;
  white-space: nowrap;
}

.notify-dot {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #5a6678;
  font-size: 16px;
}

.notify-dot i {
  position: absolute;
  top: -8px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.action-chip,
.coin-chip,
.user-chip {
  height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #e0e7f1;
  background: rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(48, 73, 114, 0.04);
}

.action-chip {
  padding: 0 14px;
  font-weight: 700;
}

.action-chip.strong {
  color: #182235;
}

.coin-chip {
  padding: 0 14px;
  gap: 6px;
  color: var(--primary);
}

.coin-chip::first-letter {
  color: #f2a900;
}

.user-chip {
  padding: 0 14px;
  min-width: 118px;
  justify-content: center;
  color: #3f4c60;
}

/* 主工作区：居中、宽度接近参考图 */
.workspace {
  width: min(1200px, calc(100vw - 48px));
  margin: 22px auto 56px;
}

.coupon-card {
  height: 88px;
  margin: 0 0 10px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(360px, 1.5fr) minmax(180px, 0.8fr) auto;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.coupon-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.coupon-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 12px;
  padding: 0;
  background: var(--primary-soft);
  color: var(--primary);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.coupon-icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(91, 117, 246, 0.16);
}

.coupon-icon:focus-visible {
  outline: 3px solid rgba(91, 117, 246, 0.24);
  outline-offset: 2px;
}

.theme-logo {
  width: 24px;
  height: 24px;
  display: block;
}

.theme-logo-sun {
  display: none;
  color: #f59e0b;
}

.theme-logo-sun circle {
  fill: #fde68a;
  stroke: #f59e0b;
  stroke-width: 1.6;
}

.theme-logo-sun path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.theme-logo-moon {
  display: block;
  color: #a5b4fc;
}

.theme-logo-moon path:first-child {
  fill: #c7d2fe;
  stroke: #818cf8;
  stroke-linejoin: round;
  stroke-width: 1.3;
}

.theme-logo-moon path:last-child {
  fill: #f8fafc;
  stroke: none;
}

:where(html[data-theme="dark"], body[data-theme="dark"], .dark, .dark-mode) .coupon-icon {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

:where(html[data-theme="dark"], body[data-theme="dark"], .dark, .dark-mode) .theme-logo-sun {
  display: block;
}

:where(html[data-theme="dark"], body[data-theme="dark"], .dark, .dark-mode) .theme-logo-moon {
  display: none;
}

html[data-theme="dark"] .coupon-card,
html[data-theme="dark"] .composer-surface,
html[data-theme="dark"] .task-panel {
  background: rgba(17, 24, 39, 0.94);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .coupon-card-title h2,
html[data-theme="dark"] .section-title h2,
html[data-theme="dark"] .empty-state h3,
html[data-theme="dark"] .pending-card-content strong {
  color: #e5edf8;
}

html[data-theme="dark"] .coupon-card-title p,
html[data-theme="dark"] .coupon-input-wrap span,
html[data-theme="dark"] .section-title span,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .empty-state p,
html[data-theme="dark"] .pending-card-content,
html[data-theme="dark"] .pending-card-content small {
  color: #9aa8bb;
}

html[data-theme="dark"] .coupon-input-wrap input,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] select,
html[data-theme="dark"] .tool-pill,
html[data-theme="dark"] .param-option {
  background: #0f172a;
  border-color: #334155;
  color: #e5edf8;
}

html[data-theme="dark"] .coupon-input-wrap input::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] .composer-textarea::placeholder {
  color: #73839b;
}

html[data-theme="dark"] .composer-textarea {
  color: #e5edf8;
}

html[data-theme="dark"] .coupon-query-result,
html[data-theme="dark"] .upload-tile,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .pending-task-card {
  background: rgba(15, 23, 42, 0.76);
  border-color: #334155;
  color: #9aa8bb;
}

html[data-theme="dark"] .coupon-query-result:empty::before {
  color: #73839b;
}

html[data-theme="dark"] .param-menu,
html[data-theme="dark"] .task-modal-dialog,
html[data-theme="dark"] .image-preview-dialog {
  background: #111827;
  border-color: #334155;
}

html[data-theme="dark"] .param-trigger:hover,
html[data-theme="dark"] .param-dropdown.open .param-trigger,
html[data-theme="dark"] .param-option:hover,
html[data-theme="dark"] .param-option.active {
  background: rgba(129, 140, 248, 0.16);
  border-color: #6472dd;
  color: #c7d2fe;
}

html[data-theme="dark"] .dropdown-arrow {
  background: rgba(129, 140, 248, 0.16);
}

html[data-theme="dark"] .upload-icon,
html[data-theme="dark"] .upload-text {
  color: #a5b4fc;
}

html[data-theme="dark"] .purchase-btn {
  background: linear-gradient(90deg, #f59e0b 0%, #ea580c 100%);
  box-shadow: 0 8px 18px rgba(234, 88, 12, 0.26);
}

.coupon-card-title h2 {
  margin: 0;
  color: #142238;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 900;
}

.coupon-card-title p {
  margin: 4px 0 0;
  color: #7d8da6;
  font-size: 12px;
  line-height: 1.35;
}

.coupon-query-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.coupon-input-wrap {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.coupon-input-wrap span {
  flex: 0 0 auto;
  color: #526176;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.coupon-input-wrap input {
  width: 100%;
  height: 38px;
  border: 1px solid #cddbf0;
  background: #f8fbff;
  color: #172033;
  border-radius: 9px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.coupon-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 117, 246, 0.14);
}

.coupon-query-btn {
  height: 38px;
  border: none;
  border-radius: 999px;
  padding: 0 18px;
  background: linear-gradient(90deg, #657df7 0%, #5671f5 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(91, 117, 246, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.coupon-query-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--primary-hover);
  box-shadow: 0 12px 22px rgba(91, 117, 246, 0.28);
}

.coupon-query-btn:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.coupon-query-result {
  height: 56px;
  min-height: 56px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #f8fbff;
  color: #7b8ba2;
  border: 1px dashed #cddbf0;
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
  overflow: hidden;
}

.coupon-query-result:empty::before {
  content: "查询结果会显示在这里";
  color: #9aa8bb;
}

.coupon-query-result.loading {
  border-style: solid;
  background: #f7faff;
  color: #526176;
}

.coupon-query-result.success {
  border-style: solid;
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.coupon-query-result.error {
  border-style: solid;
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.purchase-btn {
  height: 38px;
  min-width: 78px;
  border: none;
  border-radius: 999px;
  padding: 0 16px;
  background: linear-gradient(90deg, #ff9f43 0%, #f97316 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(249, 115, 22, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.purchase-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(249, 115, 22, 0.32);
}

.purchase-btn:focus-visible {
  outline: 3px solid rgba(249, 115, 22, 0.24);
  outline-offset: 2px;
}

.composer-panel {
  position: relative;
  z-index: 20;
  margin: 0 0 10px;
}

.composer-form {
  margin: 0;
}

.composer-surface {
  min-height: 282px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: visible;
}

.composer-textarea {
  width: 100%;
  flex: 1;
  min-height: 190px;
  resize: none;
  border: none;
  outline: none;
  padding: 17px 18px 10px;
  background: transparent;
  color: #1e293b;
  font-size: 15px;
  line-height: 1.7;
}

.composer-textarea::placeholder {
  color: #8aa0bd;
  letter-spacing: 0.04em;
}

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

.composer-toolbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 0 8px 7px;
}

.toolbar-left {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}

.reference-upload-list {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.reference-preview-list {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-tile,
.reference-preview-item {
  width: 104px;
  height: 104px;
  flex: 0 0 auto;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.upload-tile {
  border: 1px dashed #b9cff1;
  background: #f8fbff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #6689c8;
  cursor: pointer;
  transition: all 0.18s ease;
}

.upload-tile:hover {
  border-color: var(--primary);
  background: #f1f5ff;
  transform: translateY(-1px);
}

.upload-tile input[type="file"] {
  display: none;
}

.upload-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #5b79bb;
  font-size: 32px;
  line-height: 1;
}

.upload-text {
  color: #6f86ad;
  font-size: 12px;
  font-weight: 800;
}

.reference-preview-item {
  border: 1px solid #cddbf0;
  background: #eef3fb;
  box-shadow: 0 3px 10px rgba(60, 89, 137, 0.08);
  cursor: zoom-in;
}

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

.reference-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.reference-preview-item:hover .reference-remove-btn {
  opacity: 1;
  transform: scale(1);
}

.reference-remove-btn:hover {
  background: rgba(220, 38, 38, 0.92);
}

.upload-preview {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #fff;
}

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

.hidden {
  display: none !important;
}

.toolbar-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.tool-pill {
  height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #cddbf0;
  border-radius: 8px;
  background: #f7fbff;
  color: #1f3554;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(60, 89, 137, 0.04);
}

.param-dropdown {
  position: relative;
  display: inline-flex;
  z-index: 40;
}

.param-dropdown[data-dropdown="ratio"] .param-trigger {
  width: 132px;
}

.param-dropdown[data-dropdown="size"] .param-trigger {
  width: 112px;
}

.param-trigger {
  cursor: pointer;
  gap: 8px;
  justify-content: space-between;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

.param-trigger > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.param-trigger:hover,
.param-dropdown.open .param-trigger {
  border-color: #abc0ff;
  background: #f2f6ff;
  box-shadow: 0 4px 12px rgba(91, 117, 246, 0.12);
}

.dropdown-arrow {
  width: 18px;
  height: 18px;
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(180deg, #eef3ff 0%, #e2eaff 100%);
  color: var(--primary);
  font-size: 0;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(91, 117, 246, 0.08);
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.dropdown-arrow::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.18s ease, margin 0.18s ease;
}

.param-dropdown.open .dropdown-arrow {
  background: linear-gradient(180deg, #e1e9ff 0%, #d4defd 100%);
  box-shadow: inset 0 0 0 1px rgba(91, 117, 246, 0.16);
  transform: translateY(-1px);
}

.param-dropdown.open .dropdown-arrow::before {
  margin-top: 2px;
  transform: rotate(225deg);
}

.param-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 100;
  display: none;
  width: max-content;
  max-width: min(520px, calc(100vw - 48px));
  padding: 10px;
  border: 1px solid #d7e2f2;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(40, 67, 112, 0.18);
}

.param-dropdown[data-dropdown="ratio"] .param-menu {
  width: 316px;
  max-width: calc(100vw - 48px);
}

.param-dropdown.open .param-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.param-dropdown[data-dropdown="ratio"].open .param-menu {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.param-dropdown[data-dropdown="ratio"] .param-option {
  width: 100%;
}

.param-option {
  height: 30px;
  min-width: 44px;
  padding: 0 10px;
  border: 1px solid #cddbf0;
  border-radius: 8px;
  background: #f7fbff;
  color: #29405f;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.param-option:hover,
.param-option.active {
  border-color: #9bb7ff;
  background: #edf2ff;
  color: var(--primary);
}

.generate-btn {
  height: 38px;
  min-width: 132px;
  border: none;
  border-radius: 999px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(90deg, #657df7 0%, #5671f5 100%);
  color: white;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(91, 117, 246, 0.26);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--primary-hover);
  box-shadow: 0 14px 26px rgba(91, 117, 246, 0.32);
}

.generate-btn:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.generate-icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.coin-cost {
  font-weight: 800;
  opacity: 0.95;
}

/* 接口配置折叠为工具箱，避免左侧栏破坏参考图布局 */
.settings-drawer {
  margin: 10px 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #dfe7f2;
  border-radius: 12px;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.settings-drawer summary {
  min-height: 48px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: #1d2a3f;
  font-weight: 800;
}

.settings-drawer summary::-webkit-details-marker {
  display: none;
}

.settings-drawer summary::after {
  content: "⌄";
  margin-left: auto;
  color: #71829b;
  transition: transform 0.18s ease;
}

.settings-drawer[open] summary::after {
  transform: rotate(180deg);
}

.settings-drawer summary small {
  color: #8391a8;
  font-size: 12px;
  font-weight: 500;
}

.settings-grid {
  padding: 0 18px 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.settings-grid label span {
  color: #526176;
  font-size: 12px;
  font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  height: 38px;
  border: 1px solid #d4e0f0;
  background: #fff;
  color: #172033;
  border-radius: 9px;
  padding: 0 11px;
  font-size: 13px;
  outline: none;
}

input::placeholder {
  color: #9aa8bb;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 117, 246, 0.14);
}

.primary-btn {
  align-self: end;
  height: 38px;
  border: none;
  border-radius: 9px;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* 任务列表卡片：白色容器 + 等宽图片网格 */
.task-panel {
  position: relative;
  margin-top: 10px;
  padding: 22px 20px 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #dfe7f2;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.section-title h2 {
  margin: 0;
  color: #142238;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.06em;
}

.section-title span {
  color: #8b99ae;
  font-size: 13px;
}

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

.history-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border: 1px solid #e1e8f2;
  border-radius: 9px;
  background: #eef3fb;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(54, 78, 118, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.history-card:hover {
  transform: translateY(-2px);
  border-color: #cbd8eb;
  box-shadow: 0 12px 28px rgba(54, 78, 118, 0.12);
}

.history-main-image {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
  padding: 0;
  color: #8b99ae;
  text-decoration: none;
  cursor: pointer;
}

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

/* 让透明 PNG 的观感更接近参考图中的浅色/棋盘格区域 */
.history-main-image {
  background-color: #eef3fb;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.55) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.55) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.55) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.55) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.placeholder-card {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.history-overlay {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 9px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.16), rgba(15, 23, 42, 0.78));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.history-card:hover .history-overlay {
  opacity: 1;
  transform: translateY(0);
  pointer-events: none;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  margin-bottom: 6px;
}

.history-meta time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-text {
  margin: 0 0 8px;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #29405f;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
}

.subtle-tag {
  color: var(--primary);
}

.pending-task-card {
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: #b9cff1;
  background: #f8fbff;
}

.failed-task-card {
  border-color: #fecaca;
  background: #fff7f7;
}

.failed-placeholder {
  padding: 12px;
  color: #991b1b;
  background: #fef2f2;
  text-align: center;
  line-height: 1.5;
  word-break: break-word;
}

.pending-card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #526176;
  text-align: center;
}

.pending-card-content strong {
  color: #253042;
  font-size: 16px;
}

.pending-card-content small {
  color: #7b8ba2;
  font-size: 12px;
}

.pending-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #dfe7ff;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: pendingSpin 0.8s linear infinite;
}

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

.empty-state {
  min-height: 220px;
  border: 1px dashed #cbd8eb;
  border-radius: 14px;
  background: #f8fbff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #6f7f96;
  text-align: left;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 28px;
}

.empty-state h3 {
  margin: 0 0 4px;
  color: #253042;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* 任务详情弹窗：点击任务框图后展示生成信息 */
.task-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.task-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}

.task-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px 22px 24px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 28px 72px rgba(15, 23, 42, 0.28);
  outline: none;
}

.task-modal-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #8793a6;
  font-size: 34px;
  line-height: 28px;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
}

.task-modal-close:hover {
  background: #f1f5fb;
  color: #1f2937;
}

.task-modal-dialog h2 {
  margin: 0 42px 28px 0;
  color: #253042;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.task-progress-line {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  color: #344154;
  font-size: 16px;
}

.modal-section-title {
  margin: 0 0 12px;
  color: #657288;
  font-size: 13px;
  font-weight: 700;
}

.modal-result-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 2px;
}

.modal-result-card {
  position: relative;
  width: 176px;
  min-height: 176px;
  border: 1px solid #dfe6ef;
  border-radius: 10px;
  background-color: #f8fbff;
  background-image:
    linear-gradient(45deg, rgba(226, 232, 240, 0.55) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(226, 232, 240, 0.55) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(226, 232, 240, 0.55) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(226, 232, 240, 0.55) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  overflow: hidden;
}

.modal-result-card img {
  width: 100%;
  height: 176px;
  display: block;
  object-fit: contain;
}

.modal-image-actions {
  position: absolute;
  left: 50%;
  bottom: 8px;
  display: inline-flex;
  gap: 8px;
  transform: translateX(-50%);
}

.modal-image-actions a {
  height: 30px;
  min-width: 70px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e0e7f2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #526176;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  transition: color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.modal-image-actions a:hover {
  border-color: #b9c8df;
  color: var(--primary);
  transform: translateY(-1px);
}

.task-info-box {
  margin: 2px 6px 10px 0;
  padding: 12px;
  border: 1px solid #e0e7f2;
  border-radius: 10px;
  color: #526176;
  font-size: 14px;
}

.task-prompt-block strong {
  display: block;
  margin-bottom: 8px;
  color: #273449;
}

.task-prompt-block p {
  margin: 0 0 14px;
  color: #69788f;
  line-height: 1.65;
  word-break: break-word;
}

.task-detail-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  color: #273449;
}

.task-detail-row.compact {
  margin-top: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.task-detail-row strong {
  color: #253042;
}

.modal-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.modal-reference-list a {
  width: 76px;
  height: 76px;
  border: 1px solid #e0e7f2;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fbff;
}

.modal-reference-list img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.task-modal-footer {
  display: none;
}

/* 参考图点击预览弹窗 */
.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.image-preview-modal.open {
  display: flex;
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(3px);
}

.image-preview-dialog {
  position: relative;
  z-index: 1;
  max-width: min(860px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 14px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 28px 72px rgba(15, 23, 42, 0.34);
}

.image-preview-dialog img {
  display: block;
  max-width: calc(100vw - 76px);
  max-height: calc(100vh - 96px);
  object-fit: contain;
  border-radius: 12px;
  background: #f8fbff;
}

.image-preview-close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid #e0e7f2;
  border-radius: 999px;
  background: #ffffff;
  color: #526176;
  font-size: 26px;
  line-height: 28px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.image-preview-close:hover {
  color: var(--primary);
}

.reuse-task-btn,
.delete-task-btn {
  height: 38px;
  border-radius: 999px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.reuse-task-btn {
  border: none;
  background: #2f3b4f;
  color: #ffffff;
}

.delete-task-btn {
  border: 1px solid #e0e7f2;
  background: #ffffff;
  color: #3f4c60;
}

.reuse-task-btn:hover {
  background: #1f2937;
}

.delete-task-btn:hover {
  border-color: #cbd8eb;
  color: var(--primary);
}

/* Toast */
.flash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-list {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.flash-item {
  position: relative;
  overflow: hidden;
  padding: 12px 14px 16px;
  border-radius: 12px;
  border: 1px solid #dfe7f2;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--soft-shadow);
  color: #263449;
  animation: toastFadeOut 3s linear forwards;
}

.flash-item.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.flash-item.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.flash-item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.55;
  transform-origin: left center;
  animation: toastProgress 3s linear forwards;
}

@keyframes toastProgress {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

@keyframes toastFadeOut {
  0%,
  82% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-8px);
    visibility: hidden;
  }
}

.floating-helper {
  position: fixed;
  right: 18px;
  bottom: 200px;
  z-index: 80;
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(45, 69, 108, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 23px;
  cursor: pointer;
}

/* 兼容旧类名，避免后续模板局部回退时样式丢失 */
.app-layout,
.sidebar,
.main-content,
.panel,
.page-header,
.stack-form,
.history-panel,
.history-body,
.reference-strip,
.image-label {
  color: inherit;
}

@media (max-width: 1280px) {
  .workspace {
    width: min(1120px, calc(100vw - 40px));
  }

  .history-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: 60px;
    padding: 10px 20px;
  }

  .top-tabs {
    order: 3;
    grid-column: 1 / -1;
    justify-self: center;
  }

  .top-actions {
    gap: 6px;
  }

  .action-chip,
  .coin-chip,
  .user-chip {
    padding: 0 10px;
  }

  .coupon-card {
    height: auto;
    grid-template-columns: 1fr;
  }

  .purchase-btn {
    width: 100%;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .brand {
    width: 100%;
  }

  .top-tabs {
    order: initial;
    width: 100%;
    overflow-x: auto;
  }

  .top-tab {
    flex: 1;
  }

  .top-actions {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  .workspace {
    width: min(100% - 24px, 640px);
    margin-top: 12px;
  }

  .coupon-query-form {
    align-items: stretch;
    flex-direction: column;
  }

  .coupon-input-wrap {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .coupon-query-btn {
    width: 100%;
  }

  .composer-surface {
    min-height: 250px;
  }

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

  .toolbar-left {
    align-items: flex-start;
    flex-direction: column;
  }

  .reference-upload-list,
  .reference-preview-list {
    align-items: flex-start;
  }

  .upload-tile,
  .reference-preview-item {
    width: 88px;
    height: 88px;
  }

  .toolbar-pills {
    width: 100%;
  }

  .tool-pill {
    flex: 1 1 auto;
    justify-content: center;
  }

  .generate-btn {
    width: 100%;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-title h2 {
    font-size: 24px;
  }

  .task-modal {
    padding: 12px;
  }

  .task-modal-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 22px 14px;
  }

  .task-modal-dialog h2 {
    font-size: 24px;
  }

  .task-detail-row,
  .task-detail-row.compact {
    grid-template-columns: 1fr;
  }

  .modal-result-card {
    width: 150px;
    min-height: 150px;
  }

  .modal-result-card img {
    height: 150px;
  }

  .task-modal-footer {
    flex-direction: column;
  }

  .reuse-task-btn,
  .delete-task-btn {
    width: 100%;
  }

  .floating-helper {
    right: 12px;
    bottom: 90px;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 24px;
  }

  .brand-subtitle {
    display: none;
  }

  .composer-textarea {
    min-height: 160px;
    font-size: 14px;
  }

  .history-grid {
    grid-template-columns: 1fr;
  }

  .task-panel {
    padding: 18px 14px;
  }
}
