:root {
  --bg: #0a0c12;
  --panel: rgba(16, 20, 32, 0.88);
  --panel-2: rgba(22, 28, 44, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #a78bfa;
  --accent-2: #38bdf8;
  --accent-3: #5eead4;
  --danger: #fb7185;
  --ok: #86efac;
  --warn: #fde68a;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body { position: relative; overflow-x: hidden; }

.bg-glow {
  position: fixed;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.32;
  pointer-events: none;
  z-index: 0;
}

.bg-glow-a { top: -100px; left: -60px; background: #6d28d9; }
.bg-glow-b { right: -80px; bottom: -100px; background: #0369a1; }

.shell { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 8px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0f1020;
}

.brand h1 { margin: 0; font-size: 1.3rem; font-weight: 650; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.86rem; }

.status-row { display: flex; gap: 8px; flex-wrap: wrap; }

.status-pill {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.78rem;
  color: var(--muted);
}

.status-pill.ok { color: var(--ok); border-color: rgba(134, 239, 172, 0.25); }
.status-pill.warn { color: var(--warn); }

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 28px 12px;
  overflow-x: auto;
}

.tab-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: 0.15s ease;
}

.tab-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.16); }
.tab-btn.active {
  color: #0f1020;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  font-weight: 600;
}

.main { flex: 1; padding: 0 28px 24px; }

.view { display: none; }
.view.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.layout-2col {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 18px;
  align-items: stretch;
  min-height: calc(100vh - 168px);
}

@media (max-width: 960px) {
  .layout-2col {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.panel.preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.controls { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.field-label-row label {
  margin-bottom: 0;
}

.btn-translate {
  flex-shrink: 0;
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-translate:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.22);
  border-color: rgba(167, 139, 250, 0.55);
}

.btn-translate:disabled {
  opacity: 0.55;
  cursor: wait;
}

.translate-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.field textarea { min-height: 88px; resize: vertical; line-height: 1.45; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field-note { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); line-height: 1.4; }

.slider-row label { display: flex; justify-content: space-between; align-items: center; }
.slider-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mode-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.82rem;
}

.mode-tab.active {
  color: var(--text);
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.12);
}

.btn-primary,
.btn-ghost,
.btn-danger {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0f1020;
  font-weight: 650;
}

.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-ghost:disabled,
.btn-ghost.is-muted {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost.is-ready {
  border-color: rgba(167, 139, 250, 0.45);
  color: #e9e0ff;
}

.btn-danger { background: rgba(251, 113, 133, 0.15); color: var(--danger); border: 1px solid rgba(251, 113, 133, 0.25); }

.preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
  padding: 0;
  position: relative;
}

.preview-stage {
  flex: 1;
  min-height: 520px;
  border-radius: 0 0 var(--radius) var(--radius);
  border: none;
  background-color: rgba(0, 0, 0, 0.32);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  display: block;
  position: relative;
  overflow: hidden;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
  pointer-events: none;
}

.empty-state p { margin: 6px 0; }

.preview-viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
}

.preview-viewport.is-downloadable {
  cursor: pointer;
}

.preview-viewport.is-downloadable.is-panning {
  cursor: grabbing;
}

.preview-viewport.is-downloadable.is-magnifier {
  cursor: crosshair;
}

.preview-viewport.is-panning { cursor: grabbing; }
.preview-viewport.is-hand-off { cursor: default; }
.preview-viewport.is-magnifier { cursor: crosshair; }
.preview-viewport.is-pannable { cursor: grab; }

.preview-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.preview-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.preview-layer.is-active { opacity: 1; }

.compare-float {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  border: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.82);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.compare-float.is-pressed { background: rgba(167, 139, 250, 0.25); }

.dropzone {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s ease;
  outline: none;
}

.dropzone:hover, .dropzone.dragover, .dropzone.paste-flash {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(167, 139, 250, 0.06);
}

.dropzone.is-paste-target {
  border-color: rgba(167, 139, 250, 0.75);
  background: rgba(167, 139, 250, 0.1);
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.25), 0 0 0 2px rgba(167, 139, 250, 0.12);
}

.drop-select-hint {
  display: none;
  margin: 8px 0 0;
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 600;
}

.drop-select-hint.is-active { display: block; }

.dropzone-browse {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
}

.dropzone-browse:hover {
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.1);
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.upload-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.upload-preview-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.upload-preview-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-remove, .ref-remove {
  border: none;
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.76rem;
  cursor: pointer;
  flex-shrink: 0;
}

.upload-remove:hover, .ref-remove:hover {
  background: rgba(248, 113, 113, 0.28);
}

.drop-icon { font-size: 1.4rem; margin-bottom: 6px; }
.drop-title { margin: 0; font-weight: 600; }
.drop-hint { margin: 6px 0 0; color: var(--muted); font-size: 0.78rem; }

.quality-options { display: flex; flex-direction: column; gap: 8px; }
.check-row { display: flex; gap: 8px; align-items: flex-start; font-size: 0.84rem; color: var(--muted); }
.check-row input { margin-top: 3px; accent-color: var(--accent); }

.progress-inline { margin-top: 4px; }
.progress-inline-head { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.progress-track { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-3)); transition: width 0.2s ease; }
.progress-hint { margin: 6px 0 0; font-size: 0.76rem; color: var(--muted); }

.meta {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.82rem;
}

.meta div { display: flex; justify-content: space-between; gap: 12px; }
.meta dt { color: var(--muted); margin: 0; }
.meta dd { margin: 0; text-align: right; }

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.model-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  transition: 0.15s ease;
}

.model-card:hover { border-color: rgba(167, 139, 250, 0.35); }
.model-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35); }

.model-card h3 { margin: 0 0 6px; font-size: 0.98rem; }
.model-card p { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.4; }

.model-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.history-layout {
  display: flex;
  gap: 24px;
  align-items: stretch;
  min-height: min(95vh, 1440px);
}

.history-layout-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: min(95vh, 1440px);
  padding-right: 6px;
}

.history-card.is-preview-active {
  border-color: rgba(167, 139, 250, 0.65);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35);
}

.history-hover-preview {
  width: min(63vw, 945px);
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 27px;
  min-height: 630px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: min(95vh, 1440px);
}

.history-hover-preview-empty {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
  line-height: 1.5;
  padding: 54px 27px;
}

.history-hover-preview-img {
  width: 100%;
  max-height: calc(min(95vh, 1440px) - 198px);
  object-fit: contain;
  border-radius: 8px;
  background: #0a0a10;
}

.history-hover-preview-meta {
  width: 100%;
  margin-top: 10px;
  text-align: center;
}

.history-hover-preview-title {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.history-hover-preview-caption {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .history-layout {
    flex-direction: column;
    min-height: 0;
  }

  .history-hover-preview {
    width: 100%;
    position: static;
    max-height: min(95vh, 900px);
  }

  .history-layout-main {
    max-height: none;
  }
}

.history-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.history-filter-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
}

.history-filter-btn.active {
  color: #fff;
  border-color: rgba(167, 139, 250, 0.55);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.55), rgba(168, 85, 247, 0.45));
}

.history-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.history-card-media {
  position: relative;
}

.history-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }

.history-zoom-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(10, 10, 20, 0.72);
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.history-zoom-btn:hover { background: rgba(30, 30, 50, 0.88); }

.history-card .info { padding: 10px; font-size: 0.76rem; color: var(--muted); }
.history-card-title { color: var(--text); font-weight: 600; margin-bottom: 4px; }

.history-lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
}

.history-lightbox.hidden { display: none; }

.history-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}

.history-lightbox-dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.history-lightbox-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.history-lightbox-title { font-size: 0.95rem; }
.history-lightbox-meta { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); }

.history-lightbox-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.history-lightbox-body {
  padding: 10px;
  overflow: auto;
  display: grid;
  place-items: center;
  background: #0a0a12;
}

.history-lightbox-img {
  max-width: 100%;
  max-height: calc(92vh - 88px);
  object-fit: contain;
}

.inpaint-wrap { position: relative; width: 100%; max-width: 100%; }
.inpaint-wrap canvas, .inpaint-wrap img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.inpaint-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.footer {
  padding: 12px 28px 20px;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(15, 16, 32, 0.95);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 99;
  max-width: min(90vw, 520px);
  text-align: center;
  font-size: 0.86rem;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

.settings-block { padding: 18px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; }

.preview-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line);
}

.preview-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.toolbar-btn {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.78rem;
}

.toolbar-btn.is-active { background: rgba(167, 139, 250, 0.25); }

.zoom-label { font-size: 0.76rem; color: var(--muted); }

.preview-lens {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.lens-tag {
  position: absolute;
  bottom: 8px;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
}

.lens-tag-before { left: 8px; }
.lens-tag-after { right: 8px; }

.compare-tip {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.74rem;
  color: var(--muted);
}

/* 魔镜换脸 */
.mirror-intro { margin: 0 0 8px; line-height: 1.55; }

.mirror-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #a5f3fc;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.35);
  vertical-align: middle;
}

.mirror-intro a {
  color: var(--accent);
}

/* FaceFusion */
.ff-proc-field { margin-top: 4px; }

.ff-proc-grid {
  display: grid;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.ff-proc-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ff-result-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Deep-Live-Cam */
.dlc-badge {
  color: #fde68a;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
}

.dlc-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.dlc-mode-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.86rem;
  cursor: pointer;
}

.dlc-mode-tab.active {
  color: var(--text);
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.08);
}

.dlc-live-wrap {
  position: relative;
  width: 100%;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0f;
  border-radius: 12px;
  overflow: hidden;
}

.dlc-live-out {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.dlc-live-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #fde68a;
  background: rgba(0, 0, 0, 0.55);
}

.dlc-proc-field { margin-top: 4px; }

.dlc-refine-field .slider-row + .slider-row {
  margin-top: 10px;
}

.dlc-skin-field {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border, #d8e3ef);
}

.dlc-nano-field {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border, #d8e3ef);
}

.dlc-nano-field textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 720px) {
  .field-row { grid-template-columns: 1fr; }
}

/* 换脸换装 */
.swap-intro { margin: 0 0 4px; }

/* 豆包多图融合 */
.fusion-intro { margin: 0 0 8px; line-height: 1.55; }

.fusion-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
  vertical-align: middle;
}

.gpt-image-badge {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(129, 140, 248, 0.35);
}

.sd-fusion-badge {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
}

.nanobanana-badge {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.35);
}

.fusion-env-note code {
  font-size: 0.76rem;
  color: var(--accent);
}

.fusion-scope-card.active {
  border-color: rgba(251, 191, 36, 0.75);
  background: rgba(251, 191, 36, 0.08);
}

.fusion-scope-card.active .swap-mode-icon {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.15);
}

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

@media (min-width: 520px) {
  .swap-mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.swap-mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.swap-mode-card:hover { border-color: rgba(167, 139, 250, 0.45); }

.swap-mode-card.active {
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.12);
}

.swap-mode-icon {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(167, 139, 250, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.swap-mode-card strong { font-size: 0.88rem; }

.swap-mode-card span:last-child {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.dropzone-compact { padding: 14px; }

.dropzone-compact .drop-icon { font-size: 1.4rem; }

.dropzone-compact .drop-title { font-size: 0.86rem; }

.ref-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.ref-card {
  position: relative;
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.ref-card img, .ref-empty {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.ref-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  color: var(--muted);
}

.ref-card figcaption {
  font-size: 0.62rem;
  padding: 3px 4px;
  text-align: center;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ref-card.ok { border-color: rgba(52, 211, 153, 0.45); }

.ref-card.bad { border-color: rgba(248, 113, 113, 0.45); }

.ref-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: auto;
  height: auto;
  padding: 2px 6px;
  font-size: 0.68rem;
  line-height: 1.2;
  border-radius: 4px;
}

.target-preview {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: none;
  max-width: none;
  max-height: none;
  margin: 0;
}

.quick-prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.swap-quick-btn { font-size: 0.76rem; padding: 4px 8px; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.face-profile-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.face-profile-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  text-align: left;
  color: var(--text);
}

.face-profile-chip:hover { border-color: rgba(167, 139, 250, 0.45); }

.face-profile-chip.active {
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.1);
}

.face-profile-chip strong { font-size: 0.84rem; }

.face-profile-chip span { font-size: 0.72rem; color: var(--muted); }

.upload-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-picker-modal.hidden { display: none; }

.upload-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.upload-picker-dialog {
  position: relative;
  width: min(840px, 96vw);
  max-height: min(90vh, 1200px);
  background: #14121c;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.upload-picker-dialog--wide {
  width: min(1680px, 98vw);
}

.upload-picker-history-layout {
  display: flex;
  gap: 21px;
  align-items: stretch;
  min-height: 450px;
  max-height: min(95vh, 1350px);
}

.upload-picker-history-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding-right: 3px;
}

.upload-picker-history-layout .history-hover-preview {
  width: min(66%, 855px);
  min-height: 630px;
  max-height: min(95vh, 1350px);
  padding: 27px;
  position: sticky;
  top: 0;
}

.upload-picker-history-layout .history-hover-preview-img {
  max-height: calc(min(95vh, 1350px) - 198px);
}

.upload-picker-item.is-picker-preview-active {
  border-color: rgba(167, 139, 250, 0.65);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35);
}

.upload-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.upload-picker-head h3 { margin: 0; font-size: 1rem; }

.upload-picker-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.upload-picker-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.upload-picker-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
}

.upload-picker-tab.active {
  color: var(--text);
  border-color: var(--line);
  background: rgba(167, 139, 250, 0.08);
}

.upload-picker-tab.hidden { display: none; }

.upload-picker-body { padding: 14px 16px; overflow-y: auto; }

.upload-picker-pane { display: none; }

.upload-picker-pane.active { display: block; }

.upload-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
}

.upload-picker-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  text-align: center;
}

.upload-picker-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
}

.upload-picker-item span { font-size: 0.65rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }

.upload-picker-tag {
  font-size: 0.58rem;
  color: var(--accent);
  opacity: 0.85;
}

.upload-picker-profile .profile-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(167, 139, 250, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
}

.upload-picker-local-btn { width: 100%; margin-top: 8px; }

.mirror-batch-run-btn {
  width: 100%;
  margin-top: 8px;
  border-color: rgba(167, 139, 250, 0.35);
}

.mirror-batch-panel {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  background: rgba(0, 0, 0, 0.18);
}

.mirror-batch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.mirror-batch-head strong {
  font-size: 0.88rem;
}

.mirror-batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mirror-batch-action {
  padding: 4px 10px;
  font-size: 0.78rem;
}

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

@media (max-width: 720px) {
  .mirror-batch-grid {
    grid-template-columns: 1fr;
  }
}

.mirror-batch-card {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
}

.mirror-batch-card.is-active {
  border-color: rgba(167, 139, 250, 0.75);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35);
}

.mirror-batch-card.is-selected {
  border-color: rgba(129, 230, 217, 0.55);
}

.mirror-batch-card.is-error {
  border-color: rgba(248, 113, 113, 0.5);
  cursor: default;
}

.mirror-batch-card.is-running .mirror-batch-thumb {
  opacity: 0.45;
}

.mirror-batch-check {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.mirror-batch-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.35);
}

.mirror-batch-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mirror-batch-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 8px;
  text-align: center;
}

.mirror-batch-meta {
  padding: 6px 8px 8px;
}

.mirror-batch-meta strong {
  display: block;
  font-size: 0.76rem;
  margin-bottom: 2px;
}

.mirror-batch-meta span {
  font-size: 0.65rem;
  color: var(--muted);
}

/* ========== 手机浏览器适配 ========== */
.status-row-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.status-toggle {
  display: none;
}

.mobile-face-nav,
.mobile-primary-bar {
  display: none;
}

.tab-more-btn {
  display: none;
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  :root {
    --mobile-nav-h: calc(58px + env(safe-area-inset-bottom, 0px));
    --mobile-primary-h: 56px;
  }

  html.is-mobile body {
    padding-bottom: var(--mobile-nav-h);
    -webkit-text-size-adjust: 100%;
  }

  .mobile-primary-bar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 30;
    gap: 6px;
    padding: 8px 12px 6px;
    background: linear-gradient(180deg, rgba(10, 12, 18, 0.98) 80%, rgba(10, 12, 18, 0.85));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .mobile-primary-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    cursor: pointer;
    touch-action: manipulation;
    padding: 6px 4px;
  }

  .mobile-primary-btn.active {
    color: var(--text);
    border-color: rgba(167, 139, 250, 0.45);
    background: rgba(167, 139, 250, 0.16);
  }

  .tabs.tabs-mobile-primary {
    display: none;
    position: sticky;
    top: var(--mobile-primary-h);
    z-index: 25;
    padding: 0 10px 8px;
    margin: 0;
    background: rgba(10, 12, 18, 0.96);
    backdrop-filter: blur(8px);
  }

  html.mobile-more-open .tabs.tabs-mobile-primary {
    display: flex;
  }

  .tabs.tabs-mobile-primary .tab-btn.tab-primary {
    display: none;
  }

  .topbar {
    padding: 12px 14px 6px;
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 0.85rem;
  }

  .brand h1 {
    font-size: 1.05rem;
  }

  .brand p {
    display: none;
  }

  .status-row-wrap {
    align-items: stretch;
  }

  .status-toggle {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.78rem;
    cursor: pointer;
    min-height: 44px;
  }

  .status-toggle::after {
    content: "▾";
    font-size: 0.7rem;
    transition: transform 0.15s ease;
  }

  .status-row-wrap:has(.status-row.is-expanded) .status-toggle::after {
    transform: rotate(180deg);
  }

  .status-row {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .status-row.is-expanded {
    display: flex;
  }

  .status-pill {
    font-size: 0.72rem;
    padding: 6px 10px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0 10px 8px;
    margin: 0 -2px;
    background: linear-gradient(180deg, rgba(10, 12, 18, 0.98) 70%, rgba(10, 12, 18, 0));
    backdrop-filter: blur(8px);
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .tab-btn {
    padding: 10px 14px;
    font-size: 0.82rem;
    min-height: 44px;
    scroll-snap-align: start;
  }

  .main {
    padding: 0 12px 16px;
  }

  .controls {
    padding: 14px;
    gap: 12px;
  }

  .panel.preview {
    min-height: 42vh;
  }

  .preview {
    min-height: 42vh;
  }

  .preview-stage {
    min-height: min(42vh, 360px);
  }

  .dropzone {
    padding: 16px 12px;
  }

  .dropzone-browse {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.86rem;
    width: 100%;
    max-width: 280px;
  }

  button,
  .btn-primary,
  .btn-ghost,
  .btn-danger,
  .tab-btn,
  .mode-tab,
  .history-filter-btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  .btn-primary,
  .btn-ghost,
  .btn-danger {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.92rem;
  }

  .compare-float {
    right: 12px;
    bottom: 12px;
    padding: 12px 18px;
    font-size: 0.88rem;
    min-height: 44px;
  }

  .preview-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
  }

  .toolbar-btn {
    min-height: 40px;
    min-width: 44px;
    padding: 8px 12px;
  }

  .field input[type="text"],
  .field input[type="number"],
  .field textarea,
  .field select {
    font-size: 16px;
  }

  .swap-mode-grid {
    grid-template-columns: 1fr;
  }

  .ff-proc-grid {
    grid-template-columns: 1fr;
  }

  .footer {
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    font-size: 0.72rem;
    text-align: center;
  }

  .toast {
    bottom: calc(16px + var(--mobile-nav-h));
    max-width: calc(100vw - 24px);
    font-size: 0.84rem;
  }

  .upload-picker-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 24px);
    margin: 8px;
  }

  .mobile-face-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(10, 12, 18, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    touch-action: manipulation;
    padding: 4px 2px;
  }

  .mobile-nav-btn.active {
    color: var(--text);
    background: rgba(167, 139, 250, 0.14);
  }

  .mobile-nav-icon {
    font-size: 1.1rem;
    line-height: 1;
  }

  .mobile-nav-label {
    font-size: 0.62rem;
    line-height: 1.2;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .history-hover-preview-empty::before {
    content: "点击缩略图可全屏查看";
    display: block;
  }
}

/* 云端 APK 壳：未上云入口降权 */
html.is-cloud-shell .mobile-primary-btn.tab-cloud-off {
  opacity: 0.42;
  filter: grayscale(0.35);
}
html.is-cloud-shell .mobile-primary-btn.tab-cloud-off .mobile-nav-label {
  font-size: 0.55rem;
}
html.is-cloud-shell .tabs.tabs-mobile-primary {
  display: none !important;
}
html.is-cloud-shell .mobile-face-nav {
  display: none !important;
}
