*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* ensure the HTML hidden attribute always hides elements even when CSS sets display */
[hidden] { display: none !important; }

:root {
  --bg:        #eef1f7;
  --surface:   #ffffff;
  --surface2:  #f4f6fb;
  --border:    #d8e0ec;
  --accent:    #5c4ddb;
  --accent2:   #0a8cc4;
  --accent3:   #e85d04;
  --accent-h:  #6f62e8;
  --text:      #1c2333;
  --muted:     #5a6578;
  --danger:    #dc2626;
  --success:   #15803d;
  --radius:    10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ── */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.header-home {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0;
  border: none; background: transparent; padding: 4px 6px; margin: -4px -6px;
  cursor: pointer; font: inherit; color: inherit; border-radius: 8px;
}
.header-home:hover { background: var(--surface2); }
.header-home:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-direction: row; }
.toolbar-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(92, 77, 219, 0.1);
}
.logo { font-size: 1.2rem; font-weight: 700; letter-spacing: -.5px; }
.logo span { color: var(--accent); }
.logo-sub { font-size: .72rem; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; letter-spacing: .3px; }

/* ── Layout ── */
.layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* ── Vendor rail (left) ── */
nav.vendor-rail {
  width: 92px; flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 6px 6px 10px;
  gap: 4px;
  background: var(--surface);
  transition: width 0.2s ease, padding 0.2s ease, border-width 0.2s ease, min-width 0.2s ease;
}
/* ── Config panel ── */
.config-panel {
  width: 300px; flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: 20px 16px 20px;
  gap: 18px;
  background: var(--surface);
}
.section-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.section-title-row .section-title {
  margin-bottom: 0;
}
.model-title-spacer {
  flex: 0 0 auto;
  white-space: pre;
  font-size: .72rem;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}
.config-panel .vendor-rail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.config-panel .vendor-rail-toggle:hover {
  color: var(--text);
  background: var(--surface2);
}
.vendor-rail-toggle-icon {
  display: block;
  transition: transform 0.2s ease;
}
.vendor-rail-toggle-icon.vendor-rail-toggle-icon--collapsed {
  transform: scaleX(-1);
}
.vendor-rail-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.layout.vendor-rail-hidden nav.vendor-rail {
  display: none !important;
}
.vendor-btn {
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted);
  font-size: .72rem; font-weight: 600; line-height: 1.25;
  padding: 10px 6px; cursor: pointer; transition: all .15s; text-align: center;
}
.vendor-btn:hover { color: var(--text); border-color: var(--accent); }
.vendor-btn.active {
  border-color: var(--accent); color: var(--accent);
  background: rgba(92, 77, 219, 0.1);
}
.vendor-btn[data-vendor="gemini"].active { border-color: var(--accent2); color: var(--accent2); background: rgba(10, 140, 196, 0.1); }
.vendor-btn[data-vendor="wan"].active { border-color: var(--accent3); color: var(--accent3); background: rgba(232, 93, 4, 0.1); }

.more-settings { margin-bottom: 4px; }
.more-settings-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; border: none; background: none; padding: 6px 0;
  font-size: .85rem; font-weight: 700; color: var(--text);
  cursor: pointer; user-select: none; text-align: left;
}
.more-settings-toggle:hover { color: var(--accent); }
.more-settings-chevron {
  font-size: .72rem; color: var(--muted); transition: transform .2s; display: inline-block;
}
.more-settings-toggle[aria-expanded="true"] .more-settings-chevron { transform: rotate(180deg); }
.more-settings-body { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }

/* ── Form sections ── */
.section-title { font-size: .72rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); margin-bottom: 8px; }
.field { margin-bottom: 12px; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .85rem;
  padding: 8px 11px; outline: none; font-family: var(--font);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
select option { background: var(--surface2); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.ref-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  background: var(--surface2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ref-zone:hover, .ref-zone.drag { border-color: var(--accent); background: rgba(92, 77, 219, 0.06); }
.ref-zone .ref-plus { font-size: 1.6rem; color: var(--muted); line-height: 1; }
.ref-zone p { font-size: .78rem; color: var(--muted); margin: 6px 0 0; }
.ref-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; justify-content: flex-start; }
.ref-thumb {
  position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface2);
}
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-thumb button {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: .7rem; cursor: pointer; line-height: 1; padding: 0;
}
.ref-thumb button:hover { background: var(--danger); }

.seg-row { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 8px 6px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); font-size: .78rem; cursor: pointer; transition: all .12s;
}
.seg-btn:hover { color: var(--text); border-color: var(--accent); }
.seg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

.ratio-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.ratio-btn {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 4px; font-size: .7rem;
  background: var(--surface2); color: var(--muted); cursor: pointer; text-align: center; transition: all .12s;
}
.ratio-btn:hover { border-color: var(--accent); color: var(--text); }
.ratio-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(92, 77, 219, 0.1); }
.ratio-btn .r-ico { font-size: .85rem; display: block; margin-bottom: 2px; }
.res-est { font-size: .74rem; color: var(--muted); margin-top: 8px; }
.btn-sub { display: block; font-size: .72rem; font-weight: 400; opacity: .9; margin-top: 2px; }

.api-wrap { position: relative; }
.api-wrap input { padding-right: 36px; }
.eye { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); cursor: pointer; font-size: .9rem; padding: 0; }
.eye:hover { color: var(--text); }

/* Model-specific param sections */
.param-section { display: none; }
.param-section.show { display: block; }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toggle-label { font-size: .8rem; color: var(--muted); }
.toggle { position: relative; width: 34px; height: 18px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #e2e8f0; border: 1px solid var(--border); border-radius: 18px; cursor: pointer; transition: .2s; }
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-slider::after { content: ''; position: absolute; width: 12px; height: 12px; left: 2px; top: 50%; transform: translateY(-50%); background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.toggle input:checked + .toggle-slider::after { transform: translate(16px, -50%); background: #fff; }

/* Range input */
input[type=range] { padding: 0; height: 4px; accent-color: var(--accent); }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-val { font-size: .8rem; color: var(--muted); min-width: 28px; text-align: right; }

/* Generate button */
.btn-gen {
  width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 11px; font-size: .9rem; font-weight: 600;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: background .15s, opacity .15s;
}
.btn-gen:hover:not(:disabled) { background: var(--accent-h); }
.btn-gen:disabled { opacity: .45; cursor: not-allowed; }
[data-active-provider="gemini"] .btn-gen { background: var(--accent2); }
[data-active-provider="gemini"] .btn-gen:hover:not(:disabled) { background: #0a9fe0; }
[data-active-provider="wan"] .btn-gen { background: var(--accent3); }
[data-active-provider="wan"] .btn-gen:hover:not(:disabled) { background: #fb923c; }

.note { font-size: .72rem; color: var(--muted); line-height: 1.5; padding: 8px 10px; background: var(--surface2); border-radius: 7px; border: 1px solid var(--border); }
.btn-secondary { border: 1px solid var(--border); background: var(--surface2); color: var(--text); border-radius: 7px; cursor: pointer; font-family: var(--font); transition: border-color .15s; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.bbox-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 4px; align-items: center; margin-bottom: 6px; }
.bbox-row input { font-size: .78rem; padding: 4px 7px; }
.bbox-row .bbox-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: 0 4px; }

.cred-warn {
  display: none;
  font-size: .72rem; color: #9a3412; line-height: 1.45;
  padding: 8px 10px; margin-top: 8px;
  background: #fff7ed;
  border-radius: 7px;
  border: 1px solid #fed7aa;
}
.cred-warn.show { display: block; }

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

.gallery-area > .status-bar { margin: 0 18px; padding-left: 0; padding-right: 0; }

.toolbar-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.toolbar-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── API 配置面板（右上角 popover，不遮住 header）── */
.cred-panel {
  position: fixed; top: 58px; right: 12px; z-index: 300;
  width: min(340px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 8px 32px rgba(28,35,51,.16);
}
.cred-panel-inner { padding: 18px 20px 14px; }
.cred-panel-title { font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.cred-panel-hint { font-size: .73rem; color: var(--muted); line-height: 1.45; margin-bottom: 14px; }
.cred-panel-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }
.cred-panel-actions button {
  padding: 7px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; font-size: .83rem;
}
.cred-panel-actions button:hover { background: var(--accent-h); }

.hist-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(28, 35, 51, 0.25); z-index: 200;
}
.hist-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 210;
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(28, 35, 51, 0.08);
  display: flex; flex-direction: column; overflow: hidden;
}
.hist-drawer-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.hist-drawer-top h2 { font-size: .95rem; font-weight: 600; margin: 0; }
.hist-drawer-close {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.hist-drawer-close:hover { color: var(--danger); border-color: #fecaca; }
.hist-drawer-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }

.status-bar { padding: 10px 18px; font-size: .85rem; display: none; flex-shrink: 0; }
.status-bar.show { display: block; }
.status-bar.loading { background: var(--surface2); color: var(--muted); border-bottom: 1px solid var(--border); }
.status-bar.error { background: #fef2f2; color: var(--danger); border-bottom: 1px solid #fecaca; }
.status-bar.success { background: #f0fdf4; color: var(--success); border-bottom: 1px solid #bbf7d0; }

.gallery { flex: 1; overflow-y: auto; padding: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; align-content: start; }

.empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 80px 0; color: var(--muted); }
.empty .icon { font-size: 3rem; }
.empty p { font-size: .88rem; }

.img-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  overflow: hidden; transition: transform .15s, box-shadow .15s;
}
.img-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(28, 35, 51, 0.08); }
.img-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; background: var(--surface2); }
.img-card .meta { padding: 8px 13px; font-size: .75rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.img-card .meta a { color: var(--accent); text-decoration: none; }
.img-card .meta a:hover { text-decoration: underline; }
.img-card .provider-badge { display: inline-block; font-size: .65rem; padding: 1px 6px; border-radius: 4px; background: var(--surface2); border: 1px solid var(--border); }
.img-card .provider-badge.openai { border-color: var(--accent); color: var(--accent); }
.img-card .provider-badge.gemini { border-color: var(--accent2); color: var(--accent2); }
.img-card .provider-badge.wan { border-color: var(--accent3); color: var(--accent3); }
.img-card .provider-badge.xiangyun { border-color: #8b5cf6; color: #8b5cf6; }
.img-card .revised { padding: 0 13px 8px; font-size: .73rem; color: var(--muted); font-style: italic; line-height: 1.4; }
.img-card .card-actions { padding-left: 14px; padding-bottom: 10px; }

.spinner { width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
.btn-gen .spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 生成中占位（浅色简洁，与主界面一致） ───────────────────── */
.crt-loading-wrap {
  min-width: 0;
  width: 100%;
  display: block;
  padding: 0;
}
.crt-bezel {
  width: 100%;
  max-width: none;
  border-radius: 14px;
  padding: 12px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(28, 35, 51, 0.06);
}
.crt-label {
  font: 600 .62rem ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}
.crt-screen {
  position: relative;
  border-radius: 10px;
  min-height: 200px;
  max-height: 280px;
  background: linear-gradient(165deg, #e8f4fc 0%, #f4f8ff 45%, #eef2fb 100%);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(216, 224, 236, 0.9);
}
.crt-static-flicker {
  display: none;
}
.crt-scanbar {
  position: absolute;
  left: -2%;
  right: -2%;
  height: 18%;
  top: -18%;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(10, 140, 196, 0.06) 35%,
    rgba(10, 140, 196, 0.22) 50%,
    rgba(10, 140, 196, 0.06) 65%,
    transparent 100%
  );
  animation: crt-sweep 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  z-index: 2;
}
.crt-scanbar--trail {
  animation-delay: 0.12s;
  opacity: 0.45;
  height: 22%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(92, 77, 219, 0.08) 42%,
    rgba(92, 77, 219, 0.14) 50%,
    transparent 100%
  );
}
@keyframes crt-sweep {
  0% { top: -18%; }
  100% { top: 100%; }
}
.crt-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(28, 35, 51, 0.025) 4px
  );
  opacity: 0.7;
}
.crt-content {
  position: relative;
  z-index: 4;
  padding: 22px 18px 18px;
  font-family: var(--font);
  color: var(--text);
  animation: crt-fade-pulse 2.8s ease-in-out infinite;
}
@keyframes crt-fade-pulse {
  0%, 100% { opacity: 0.94; }
  50% { opacity: 1; }
}
.crt-title {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent2);
  margin-bottom: 10px;
}
.crt-model {
  font-size: .8rem;
  color: var(--text);
  word-break: break-all;
  margin-bottom: 8px;
  line-height: 1.5;
}
.crt-prompt-preview {
  font-size: .72rem;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 12px;
  max-height: 4.6em;
  overflow: hidden;
  word-break: break-word;
}
.crt-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .78rem;
  color: var(--accent2);
}
.crt-dots { display: inline-flex; gap: 2px; letter-spacing: 0; }
.crt-dots span {
  display: inline-block;
  animation: crt-dot-blink 1.2s ease-in-out infinite;
  opacity: 0.45;
}
.crt-dots span:nth-child(2) { animation-delay: 0.2s; }
.crt-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes crt-dot-blink {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-1px); }
}

@media (prefers-reduced-motion: reduce) {
  .crt-scanbar,
  .crt-scanbar--trail,
  .crt-content,
  .crt-dots span {
    animation: none !important;
  }
  .crt-scanbar,
  .crt-scanbar--trail { display: none; }
  .crt-content { opacity: 1; }
}

@media (max-width: 900px) {
  nav.vendor-rail { width: 72px; padding: 5px 5px 8px; }
  .vendor-btn { font-size: .65rem; padding: 8px 4px; }
  .config-panel { width: 260px; }
}
@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .config-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
}

/* ── History panel ── */
.history-area { flex: 1; overflow-y: auto; display: flex; flex-direction: column; background: var(--bg); }
.hist-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; flex-shrink: 0; }
.hist-header h2 { font-size: .9rem; font-weight: 600; color: var(--text); margin: 0; }
.hist-clear-btn { font-size: .75rem; color: var(--muted); border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.hist-clear-btn:hover { color: var(--danger); border-color: var(--danger); }
.hist-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); padding: 80px 20px; }
.hist-empty .icon { font-size: 2.5rem; }
.hist-empty p { font-size: .85rem; }
.hist-list { padding: 12px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.hist-entry { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.hist-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}
.hist-ts {
  font-size: .72rem;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
}
.hist-entry-header .provider-badge {
  display: inline-block;
  flex-shrink: 0;
  font-size: .65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.hist-entry-header .provider-badge.openai { border-color: var(--accent); color: var(--accent); }
.hist-entry-header .provider-badge.gemini { border-color: var(--accent2); color: var(--accent2); }
.hist-entry-header .provider-badge.wan { border-color: var(--accent3); color: var(--accent3); }
.hist-entry-header .provider-badge.xiangyun { border-color: #8b5cf6; color: #8b5cf6; }
.hist-model {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 0;
}
.hist-del { width: 24px; height: 24px; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: .9rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hist-del:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.hist-prompt {
  padding: 8px 14px;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.45;
  border-bottom: 1px solid var(--border);
}
.hist-prompt-expand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.hist-prompt-expand:not(.hist-prompt-expand--compact) {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.hist-prompt-inner {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
  word-break: break-word;
  width: 100%;
  box-sizing: border-box;
}
.hist-prompt-inner--clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.hist-prompt-expand--compact .hist-prompt-inner--clamped {
  -webkit-line-clamp: 4;
}
.hist-prompt-expand[data-expanded="1"] .hist-prompt-inner {
  display: block;
  -webkit-line-clamp: unset;
  white-space: pre-wrap;
  max-height: min(58vh, 420px);
  overflow-y: auto;
}
.hist-prompt-expand-btn {
  flex-shrink: 0;
  padding: 1px 8px;
  font-size: 0.62rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font);
}
.hist-prompt-expand-btn:hover {
  border-color: var(--accent);
  background: rgba(92, 77, 219, 0.08);
}
.hist-prompt-expand-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.hist-entry--compact .hist-main-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.hist-row-thumb {
  flex-shrink: 0;
  width: 96px;
}
.hist-row-prompt-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
}
.hist-row-prompt {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}
.hist-images--extra {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.hist-status { padding: 8px 14px; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--border); line-height: 1.4; }
.hist-status.hist-status-fail { color: var(--danger); }
.hist-images { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
.hist-img-item { display: flex; flex-direction: column; align-items: center; }
.hist-img-item img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; background: var(--surface2); }
.hist-img-item--inline img { width: 96px; height: 96px; }
.hist-img-item--extra img { width: 52px; height: 52px; }
.hist-img-item--extra a { font-size: .62rem; margin-top: 2px; }
.hist-img-item a { display: block; margin-top: 4px; font-size: .68rem; color: var(--accent); text-decoration: none; }
.hist-img-item a:hover { text-decoration: underline; }
.hist-entry .card-actions {
  margin-top: 0;
  padding: 8px 14px 10px;
}
.hist-load-more-wrap { padding: 0 20px 20px; flex-shrink: 0; }
.hist-load-more-btn {
  width: 100%; padding: 10px 14px; font-size: .82rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer;
}
.hist-load-more-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.hist-load-more-btn:disabled { opacity: 0.55; cursor: default; }

/* ── Task queue (concurrent jobs) ── */
.task-queue-bar {
  flex-shrink: 0;
  margin: 0 16px 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .78rem;
}
.task-queue-bar[hidden] { display: none !important; }
.task-queue-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--muted); font-weight: 600; }
.task-queue-toggle { background: none; border: none; color: var(--accent); cursor: pointer; font-size: .72rem; padding: 2px 6px; }
.task-queue-list { display: flex; flex-direction: column; gap: 6px; }
.task-queue-list.collapsed { display: none; }
.task-pill {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2);
}
.task-pill.running { border-left: 3px solid var(--accent); }
.task-pill.succeeded { border-left: 3px solid var(--success); }
.task-pill.failed { border-left: 3px solid var(--danger); }
.task-pill-meta { flex: 1; min-width: 0; }
.task-pill-model { font-weight: 600; font-size: .74rem; color: var(--text); }
.task-pill-prompt { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-pill-time { font-size: .68rem; color: var(--muted); }
.task-spin { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: tqspin .7s linear infinite; flex-shrink: 0; margin-top: 2px; }
@keyframes tqspin { to { transform: rotate(360deg); } }
.task-pill-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }

/* ── Auth & modals ── */
.auth-wrap { position: relative; }
.auth-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.12); padding: 8px; z-index: 80;
}
.auth-dropdown[hidden] { display: none !important; }
.auth-dropdown-email { font-size: .72rem; color: var(--muted); padding: 6px 8px; word-break: break-all; }
.auth-dropdown-storage { font-size: .72rem; color: var(--muted); padding: 0 8px 6px; cursor: help; }
.auth-dropdown button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; background: none;
  font-size: .82rem; cursor: pointer; border-radius: 6px; color: var(--text); font-family: var(--font);
}
.auth-dropdown button:hover { background: var(--surface2); }

/* 必须高于 .hist-drawer-backdrop(200) / .hist-drawer(210)，否则抽屉打开时登录弹窗会被挡住、按钮点击无响应 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(28,35,51,.45); z-index: 320;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-panel {
  background: var(--surface); border-radius: 14px; border: 1px solid var(--border);
  max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.modal-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.modal-tab {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; font-size: .82rem; font-family: var(--font);
}
.modal-tab.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.modal-actions button {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
  font-family: var(--font); font-size: .82rem; background: var(--surface2); color: var(--text);
}
.modal-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Asset picker (resource library) ── */
.asset-picker-backdrop { align-items: stretch; justify-content: center; padding: 24px 16px; }
.asset-picker-panel {
  display: flex; flex-direction: column; max-width: 960px; width: 100%; max-height: min(88vh, 720px);
  background: var(--surface); border-radius: 14px; border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0,0,0,.2); overflow: hidden;
}
.asset-picker-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.asset-picker-header-main { min-width: 0; flex: 1; }
.asset-picker-title { margin: 0; font-size: 1rem; font-weight: 700; }
.asset-picker-storage { margin: 4px 0 0; font-size: .74rem; color: var(--muted); font-weight: 400; cursor: help; }
.asset-picker-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; position: relative; }
.asset-picker-upload-btn {
  display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 8px; border: none;
  background: var(--accent); color: #fff; font-size: .82rem; cursor: pointer; font-family: var(--font);
}
.asset-picker-upload-btn.is-disabled { opacity: .55; pointer-events: none; cursor: not-allowed; }
/* Off-screen file input: no aria-hidden (Edge blocks change); opened via button click */
.asset-picker-file-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  right: 48px; top: 50%; transform: translateY(-50%);
}
.asset-picker-close {
  width: 32px; height: 32px; border: none; background: transparent; font-size: 1.4rem;
  line-height: 1; cursor: pointer; color: var(--muted); border-radius: 8px;
}
.asset-picker-close:hover { background: var(--surface2); color: var(--text); }
.asset-picker-body { display: flex; flex: 1; min-height: 0; }
.asset-picker-sidebar {
  width: 160px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 14px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.asset-picker-sidebar-title { font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.asset-picker-group-list { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; }
.asset-picker-group-row {
  display: flex; align-items: center; gap: 2px; border-radius: 6px;
}
.asset-picker-group-row.active .asset-picker-group { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.35); color: var(--accent); font-weight: 600; }
.asset-picker-group {
  text-align: left; padding: 5px 8px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; cursor: pointer; font-size: .82rem; font-family: var(--font); color: var(--text);
  line-height: 1.35;
}
.asset-picker-group-row .asset-picker-group {
  flex: 1; min-width: 0;
}
.asset-picker-group-del {
  flex-shrink: 0; width: 0; height: 24px; padding: 0; border: none; border-radius: 4px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; line-height: 1;
  opacity: 0; overflow: hidden; transition: opacity .15s, width .15s;
}
.asset-picker-group-row:hover .asset-picker-group-del,
.asset-picker-group-row:focus-within .asset-picker-group-del {
  width: 24px; opacity: 1;
}
.asset-picker-group-del:hover { background: rgba(239,68,68,.1); color: #ef4444; }
.asset-picker-group-add {
  margin-top: auto; padding: 8px; border-radius: 8px; border: 1px dashed var(--border);
  background: transparent; color: var(--muted); font-size: .78rem; cursor: pointer;
}
.asset-picker-group-add:hover { border-color: var(--accent); color: var(--accent); }
.asset-picker-toolbar-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.asset-picker-move-group {
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); font-size: .78rem; cursor: pointer; font-family: var(--font); color: var(--text);
}
.asset-picker-move-group:hover { border-color: var(--accent); color: var(--accent); }
.asset-picker-move-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 140px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px 0; max-height: 220px; overflow-y: auto;
}
.asset-picker-move-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 14px; border: none; background: none;
  font-size: .82rem; font-family: var(--font); cursor: pointer; color: var(--text);
}
.asset-picker-move-menu button:hover { background: rgba(99,102,241,.08); color: var(--accent); }
.asset-picker-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 16px 8px; }
.asset-picker-content-area {
  flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column;
}
.asset-picker-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.asset-picker-tab {
  padding: 8px 2px; border: none; background: none; cursor: pointer; font-size: .88rem;
  font-family: var(--font); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.asset-picker-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.asset-picker-toolbar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
  font-size: .82rem; color: var(--muted);
}
.asset-picker-refresh {
  padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2);
  cursor: pointer; font-size: .78rem; font-family: var(--font); color: var(--text);
}
.asset-picker-grid {
  flex: 1; min-height: 0; overflow-y: auto; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px; align-content: start;
}
.asset-picker-card {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: var(--surface2);
}
.asset-picker-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-picker-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,.25); }
.asset-picker-card-check {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .72rem; display: none; align-items: center; justify-content: center;
}
.asset-picker-card.selected .asset-picker-card-check { display: flex; }
.asset-picker-empty {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--muted); text-align: center;
  padding: 16px; pointer-events: none;
}
.asset-picker-empty[hidden] { display: none !important; }
.asset-picker-empty-icon { font-size: 2.5rem; opacity: .4; margin-bottom: 8px; }
.asset-picker-empty-hint { font-size: .78rem; margin-top: 4px; }
.asset-picker-msg { font-size: .78rem; color: #f87171; margin: 8px 0 0; }
.asset-picker-footer {
  display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border);
}
.asset-picker-footer button {
  padding: 8px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2);
  cursor: pointer; font-family: var(--font); font-size: .84rem;
}
.asset-picker-footer button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 720px) {
  .asset-picker-sidebar { display: none; }
  .asset-picker-backdrop { padding: 0; }
  .asset-picker-panel { max-height: 100vh; border-radius: 0; }
}

/* ── Community feed ── */
.gallery-area[data-view="community"] .gallery,
.gallery-area[data-view="community"] #task-queue-bar,
.gallery-area[data-view="community"] #status-bar { display: none !important; }
.gallery-area[data-view="community"] .community-view { display: flex !important; }
.community-view {
  display: none; flex-direction: column; flex: 1; min-height: 0; padding: 12px 16px 20px;
}
.community-toolbar { margin-bottom: 12px; }
.community-toolbar h2 { font-size: .95rem; font-weight: 700; margin: 0 0 4px; }
.community-toolbar .sub { font-size: .76rem; color: var(--muted); }
.community-feed-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.community-feed { display: flex; flex-direction: column; gap: 14px; }
.comm-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
}
.comm-card-img { width: 100%; max-height: 360px; object-fit: contain; background: var(--surface2); display: block; }
.comm-card-body { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.comm-card-meta { font-size: .72rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.comm-card-prompt { font-size: .78rem; color: var(--text); line-height: 1.45; max-height: 4.5em; overflow: hidden; }
.comm-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.comm-card-actions button {
  font-size: .74rem; padding: 6px 12px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; font-family: var(--font); color: var(--text);
}
.comm-card-actions button:hover { border-color: var(--accent); color: var(--accent); }
.hist-prompt-locked { color: var(--muted); font-style: italic; }
.hist-pub-row { display: flex; align-items: center; gap: 6px; font-size: .68rem; color: var(--muted); margin-left: auto; flex-shrink: 0; }
.hist-pub-row input { width: 14px; height: 14px; }

/* ── Card quick actions (历史 / 社区 / 预览) ── */
.card-actions {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.card-actions button {
  font-size: .72rem; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; font-family: var(--font); color: var(--text);
}
.card-actions button:hover { border-color: var(--accent); color: var(--accent); }
.img-card { cursor: default; }
.img-card .meta { flex-wrap: wrap; }

/* ── Job detail modal (生成详情) ── */
.job-detail-backdrop {
  position: fixed; inset: 0; z-index: 400; background: rgba(28,35,51,.5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.job-detail-backdrop[hidden] { display: none !important; }
.job-detail-panel {
  position: relative; background: var(--surface); border-radius: 14px;
  max-width: 920px; width: 100%; max-height: calc(100vh - 32px); overflow: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.2);
}
.job-detail-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border: none; border-radius: 8px;
  background: var(--surface2); color: var(--muted); font-size: 1.3rem; line-height: 1;
  cursor: pointer; font-family: var(--font);
}
.job-detail-close:hover { color: var(--text); background: var(--border); }
.job-detail-grid {
  display: grid; grid-template-columns: minmax(200px, 1fr) minmax(260px, 340px); gap: 0;
}
@media (max-width: 720px) {
  .job-detail-grid { grid-template-columns: 1fr; }
}
.job-detail-left {
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 12px;
}
.job-detail-img-wrap {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 12px;
}
.job-detail-img-wrap[hidden] {
  display: none !important;
}
.job-detail-img-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.job-detail-zoom-ico {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(15, 18, 28, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.job-detail-zoom-svg {
  display: block;
}
@media (hover: hover) {
  .job-detail-img-wrap:hover .job-detail-zoom-ico {
    opacity: 1;
  }
}
@media (hover: none) {
  .job-detail-zoom-ico {
    opacity: 0.88;
  }
}
.job-detail-img { max-width: 100%; max-height: min(55vh, 480px); object-fit: contain; display: block; border-radius: 10px; }
.job-detail-right { padding: 20px 44px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.job-detail-title { font-size: 1rem; font-weight: 700; margin: 0 0 4px; padding-right: 28px; }
.job-detail-section { display: flex; flex-direction: column; gap: 8px; }
.job-detail-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.job-detail-label { font-size: .78rem; font-weight: 600; color: var(--muted); }
.job-detail-sec-title { font-size: .78rem; font-weight: 600; color: var(--muted); }
.btn-inline {
  font-size: .74rem; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--accent);
  background: rgba(92, 77, 219, 0.08); color: var(--accent); cursor: pointer; font-family: var(--font); font-weight: 600;
}
.btn-inline:hover { background: rgba(92, 77, 219, 0.15); }
.job-detail-prompt {
  font-size: .84rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; word-break: break-word;
  margin: 0; max-height: 12em; overflow-y: auto;
}
.job-detail-ref-count { font-size: .72rem; color: var(--muted); }
.job-detail-refs,
.tpl-preview-refs {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
}
.detail-ref-thumb,
.tpl-preview-ref-thumb {
  width: 72px; height: 72px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--border); background: #e8ecf4;
}
.detail-refs-empty,
.tpl-preview-refs-empty {
  font-size: .76rem; color: var(--muted); margin: 0;
}
.job-detail-dl { margin: 0; font-size: .8rem; }
.job-detail-dl > div {
  display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; padding: 6px 0;
  border-bottom: 1px solid var(--border); align-items: start;
}
.job-detail-dl dt { color: var(--muted); margin: 0; font-weight: 500; }
.job-detail-dl dd { margin: 0; color: var(--text); word-break: break-all; }
.job-detail-dl .status-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .72rem; font-weight: 600;
}
.job-detail-dl .status-tag.ok { background: #dcfce7; color: #166534; }
.job-detail-dl .status-tag.fail { background: #fee2e2; color: #991b1b; }
.job-detail-dl .status-tag.run { background: #e0e7ff; color: #3730a3; }
.job-detail-footer { margin-top: auto; padding-top: 8px; }
.job-detail-footer-row {
  display: flex; flex-direction: column; gap: 8px;
}
.job-detail-footer .primary,
.job-detail-footer .secondary {
  width: 100%; padding: 10px 16px; border-radius: 10px; font-size: .88rem; font-weight: 600; cursor: pointer; font-family: var(--font);
}
.job-detail-footer .primary {
  border: none; background: var(--accent); color: #fff;
}
.job-detail-footer .primary:hover { filter: brightness(1.05); }
.job-detail-footer .secondary {
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
}
.job-detail-footer .secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ── 模板条（快速选择）── */
.template-field { gap: 8px; }
.template-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.template-section-title {
  display: flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 700; color: var(--text);
}
.template-spark { color: var(--accent3); font-size: .75rem; }
.template-section-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  font-size: .72rem; color: var(--muted);
}
.template-legend {
  flex: 1 1 100%;
  font-size: .66rem;
  line-height: 1.35;
  color: var(--muted);
  opacity: 0.92;
}
.template-count { white-space: nowrap; }
.template-more-btn {
  border: none; background: none; padding: 0; font: inherit; font-size: .72rem; font-weight: 600;
  color: var(--accent); cursor: pointer;
}
.template-more-btn:hover { text-decoration: underline; }
.template-more-btn[hidden] { display: none !important; }
.template-rail-outer {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.template-rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 4px 2px 10px;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
}
.template-rail::-webkit-scrollbar { height: 6px; }
.template-rail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.template-card {
  flex: 0 0 132px;
  width: 132px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.template-card-img-wrap {
  aspect-ratio: 3 / 4;
  background: #e8ecf4;
  position: relative;
}
.template-card-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.template-card-badge {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  font-size: .62rem; font-weight: 700; padding: 2px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.92); color: var(--accent); border: 1px solid rgba(92, 77, 219, 0.35);
}
.template-card-badge-mine {
  left: auto;
  right: 6px;
  color: var(--muted);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.94);
}
.template-card-preview-hit {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: none; padding: 8px; margin: 0; cursor: pointer; font-family: var(--font);
  background: rgba(20, 24, 38, 0.55);
  color: #fff; border-radius: 0;
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
}
.template-card-preview-hit .tpl-hit-eye {
  width: 28px; height: 28px; opacity: 0.95;
}
.template-card-preview-hit .tpl-hit-txt {
  font-size: .72rem; font-weight: 700; letter-spacing: 0.02em;
}
@media (hover: hover) {
  .template-card-img-wrap:hover .template-card-preview-hit {
    opacity: 1; pointer-events: auto;
  }
}
@media (hover: none) {
  .template-card-preview-hit {
    opacity: 0.88; pointer-events: auto;
    background: linear-gradient(to top, rgba(20, 24, 38, 0.72) 0%, rgba(20, 24, 38, 0.2) 45%, transparent 100%);
    justify-content: flex-end; padding-bottom: 10px;
  }
  .template-card-preview-hit .tpl-hit-eye { width: 22px; height: 22px; }
  .template-card-preview-hit .tpl-hit-txt { font-size: .65rem; }
}
.template-card-use {
  width: 100%; border: none; padding: 8px 6px; font-size: .72rem; font-weight: 700;
  background: var(--accent); color: #fff; cursor: pointer; font-family: var(--font);
}
.template-card-use:hover { filter: brightness(1.06); }
.template-card-title {
  font-size: .65rem; color: var(--muted); padding: 4px 8px 0; line-height: 1.25;
  max-height: 2.5em; overflow: hidden;
}
.template-rail-next {
  flex-shrink: 0; align-self: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.1rem; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.template-rail-next:hover { border-color: var(--accent); color: var(--accent); }
.template-rail-empty {
  font-size: .78rem; color: var(--muted); padding: 12px 4px;
}

/* ── 模板预览弹窗（附图1）── */
.tpl-preview-backdrop {
  position: fixed; inset: 0; z-index: 420;
  background: rgba(15, 18, 28, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.tpl-preview-backdrop[hidden] { display: none !important; }
.tpl-preview-panel {
  position: relative;
  width: min(980px, 100%);
  max-height: min(92vh, 900px);
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.tpl-preview-close {
  position: absolute; top: 10px; right: 12px; z-index: 5;
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: var(--surface2); color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.tpl-preview-close:hover { color: var(--text); background: var(--border); }
.tpl-preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 400px);
  gap: 0;
  min-height: 0;
  flex: 1;
}
@media (max-width: 820px) {
  .tpl-preview-grid {
    grid-template-columns: 1fr;
    max-height: min(92vh, 900px);
    overflow-y: auto;
  }
}
.tpl-preview-left {
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 16px;
}
.tpl-preview-img-wrap {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  border-radius: 12px;
}
.tpl-preview-img-wrap[hidden] {
  display: none !important;
}
.tpl-preview-img-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.tpl-preview-zoom-ico {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(15, 18, 28, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.tpl-preview-zoom-svg {
  display: block;
}
@media (hover: hover) {
  .tpl-preview-img-wrap:hover .tpl-preview-zoom-ico {
    opacity: 1;
  }
}
@media (hover: none) {
  .tpl-preview-zoom-ico {
    opacity: 0.88;
  }
}
.tpl-preview-img {
  max-width: 100%;
  max-height: min(70vh, 560px);
  object-fit: contain;
  border-radius: 10px;
  cursor: inherit;
}
.tpl-preview-right {
  padding: 22px 44px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  overflow-y: auto;
}
.tpl-preview-prompt-box {
  font-size: .8rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}
.tpl-preview-kicker {
  font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: 0.03em;
}
.tpl-preview-title {
  font-size: 1.05rem; font-weight: 700; margin: 0; padding-right: 36px; line-height: 1.35;
  color: var(--text);
}
.tpl-preview-visibility {
  font-size: .78rem;
  font-weight: 600;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  line-height: 1.4;
}
.tpl-preview-visibility--public {
  background: rgba(92, 77, 219, 0.1);
  color: var(--accent);
  border: 1px solid rgba(92, 77, 219, 0.22);
}
.tpl-preview-visibility--private {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.tpl-preview-model-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.tpl-preview-chip {
  display: inline-block; font-size: .68rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.tpl-preview-chip-a { background: #dcfce7; color: #166534; }
.tpl-preview-chip-b { background: #ede9fe; color: #5b21b6; }
.tpl-preview-product-line {
  font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.tpl-preview-section { display: flex; flex-direction: column; gap: 8px; }
.tpl-preview-sec-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.tpl-preview-label { font-size: .78rem; font-weight: 600; color: var(--muted); }
.tpl-preview-count { font-size: .72rem; color: var(--muted); }
.tpl-preview-tags {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 1.5em;
}
.tpl-preview-tag-pill {
  font-size: .7rem; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  background: rgba(92, 77, 219, 0.12); color: var(--accent); border: 1px solid rgba(92, 77, 219, 0.25);
}
.tpl-preview-tags-empty { font-size: .76rem; color: var(--muted); }
.tpl-preview-footer { margin-top: auto; padding-top: 6px; }
.tpl-preview-apply {
  width: 100%; padding: 12px 16px; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; font-size: .9rem; font-weight: 700; cursor: pointer; font-family: var(--font);
}
.tpl-preview-apply:hover { filter: brightness(1.05); }

/* ── Ephemeral toast (复制描述等) ── */
.genpic-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 500;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  font-size: .82rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.genpic-toast.genpic-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
