:root {
  --bg: #0f0f11;
  --bg-2: #18181b;
  --panel: rgba(28, 28, 32, 0.86);
  --panel-solid: #1c1c20;
  --border: rgba(255, 255, 255, 0.06);
  --text: #f2f2f5;
  --text-dim: #9ca3af;
  --primary: #d97757;
  --primary-2: #e9957a;
  --accent: #81b29a;
  --success: #7eb693;
  --danger: #d97757;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 15, 17, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--primary);
}
.logo-icon svg { width: 22px; height: 22px; }
.logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}
.subtitle { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }

.back-home {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
  transition: all 0.2s;
}
.back-home svg { width: 15px; height: 15px; }
.back-home:hover {
  color: var(--text);
  border-color: var(--primary);
  background: rgba(217, 119, 87, 0.08);
}

/* ===== 顶栏右侧（登录/配额） ===== */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}
.quota-text {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 7px 12px;
  border-radius: 999px;
}
.login-area { display: flex; align-items: center; }
.login-btn {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(217, 119, 87, 0.3);
}
.login-btn:hover { background: var(--primary-2); transform: translateY(-1px); }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 7px 12px;
  border-radius: 999px;
}
.logout-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 0 2px 10px;
  border-left: 1px solid var(--border);
  transition: color 0.2s;
}
.logout-btn:hover { color: var(--primary); }

/* ===== 主容器 ===== */
.container { max-width: 1000px; margin: 0 auto; padding: 28px 24px 80px; }

/* ===== 标签页 ===== */
.tabs {
  display: flex;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 22px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(217, 119, 87, 0.32);
}
.tab-icon { width: 18px; height: 18px; }

/* ===== 引擎选择 ===== */
.engine-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.engine-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.engine-options {
  display: inline-flex;
  gap: 6px;
  background: rgba(0,0,0,0.18);
  border-radius: 10px;
  padding: 4px;
}
.engine-opt {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.engine-opt:hover { color: var(--text); }
.engine-opt.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 12px rgba(217, 119, 87, 0.3);
}
.engine-hint {
  font-size: 12.5px;
  color: var(--text-dim);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 面板 ===== */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.mode-pane { display: none; }
.mode-pane.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 18px 0 8px;
}

.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.input:hover { border-color: rgba(255,255,255,0.12); }
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}
.prompt-input { resize: vertical; line-height: 1.6; min-height: 90px; }
select.input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.row { display: flex; gap: 14px; margin-top: 18px; }
.field { display: flex; flex-direction: column; }
.field.grow { flex: 1; }
.field .field-label { margin-top: 0; }

/* ===== 随机种子说明 ===== */
.seed-hint {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.75;
  margin-top: 10px;
  line-height: 1.5;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon { width: 17px; height: 17px; }
.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 18px rgba(217, 119, 87, 0.3);
}
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); background: var(--primary-2); box-shadow: 0 6px 22px rgba(217, 119, 87, 0.4); }
.btn.primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.18); }
.btn.full { width: 100%; }

/* ===== 上传框 ===== */
.upload-box {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-2);
  position: relative;
  overflow: hidden;
}
.upload-box:hover { border-color: var(--primary); background: rgba(217, 119, 87, 0.04); }
.upload-box.dragover { border-color: var(--accent); background: rgba(129, 178, 154, 0.06); }
.upload-placeholder { text-align: center; padding: 24px; color: var(--text-dim); transition: transform 0.2s; }
.upload-box:hover .upload-placeholder { transform: translateY(-2px); }
.upload-icon { width: 36px; height: 36px; display: block; margin: 0 auto 10px; }
.upload-placeholder .hint { font-size: 12px; margin-top: 6px; opacity: 0.6; }
.upload-preview img { width: 100%; max-height: 280px; object-fit: contain; border-radius: 9px; display: block; }
.remove-btn {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.remove-btn svg { width: 14px; height: 14px; }
.remove-btn:hover { background: var(--danger); transform: rotate(90deg); }

/* ===== 关键帧列表 ===== */
.kf-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.kf-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--bg-2);
}
.kf-item img { width: 100%; height: 80px; object-fit: cover; display: block; }
.kf-idx {
  position: absolute;
  top: 4px; left: 4px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: rgba(217, 119, 87, 0.9);
  color: #fff;
  border-radius: 999px;
}
.kf-del {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kf-del:hover { background: var(--danger); }
.switch-ml { margin-left: 22px; }
.i2i-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

/* ===== 开关 ===== */
.switch-row { display: flex; align-items: center; margin-bottom: 14px; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { display: none; }
.slider {
  width: 46px; height: 24px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  transition: all 0.2s;
}
.slider::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 18px; height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s;
}
.switch input:checked + .slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .slider::after { left: 24px; background: #fff; }
.switch-label { font-size: 14px; font-weight: 600; }

/* ===== 状态区 ===== */
.status {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-top: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-title { font-size: 15px; font-weight: 700; }
.status-hint { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.status-body { flex: 1; }
.progress-track {
  width: 100%;
  height: 24px;
  background: var(--bg-2);
  border-radius: 999px;
  margin-top: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.5s ease;
  position: relative;
  min-width: 34px;
}
.progress-text {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
.status-stage {
  font-size: 13px;
  color: var(--primary-2);
  margin-top: 8px;
  font-weight: 600;
}
.status-stage.error { color: var(--danger); }
.status-elapsed {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ===== 结果卡片 ===== */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease;
  transition: transform 0.2s, box-shadow 0.2s;
}
.result-card:hover { transform: translateY(-3px); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.42); }
.result-media {
  position: relative;
  background: #000;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.result-media img, .result-media video { width: 100%; max-height: 420px; object-fit: contain; display: block; }
.result-media img.clickable-img { cursor: zoom-in; }
.zoom-hint {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 3px 9px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.result-card:hover .zoom-hint { opacity: 1; }
.result-info { padding: 16px; }
.result-tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(217, 119, 87, 0.15);
  color: var(--primary-2);
  font-weight: 700;
  margin-bottom: 8px;
}
.result-prompt {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
  word-break: break-all;
}
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.result-actions .btn { flex: 1; padding: 10px; font-size: 14px; min-width: 88px; }

.btn.download {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.download:hover { border-color: var(--accent); color: var(--accent); }
.btn.to-i2i {
  background: rgba(217, 119, 87, 0.12);
  border: 1px solid rgba(217, 119, 87, 0.4);
  color: var(--primary-2);
}
.btn.to-i2i:hover { background: rgba(217, 119, 87, 0.2); border-color: var(--primary); color: #fff; }
.btn.to-video {
  background: rgba(129, 178, 154, 0.12);
  border: 1px solid rgba(129, 178, 154, 0.4);
  color: var(--accent);
}
.btn.to-video:hover { background: rgba(129, 178, 154, 0.22); border-color: var(--accent); color: #fff; }
.btn.retry { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn.retry:hover { color: var(--text); background: rgba(255,255,255,0.03); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 100;
  font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(217, 119, 87, 0.5); color: var(--danger); }

/* ===== 登录弹窗 ===== */
.login-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  backdrop-filter: blur(4px);
  padding: 24px;
}
.login-modal.show { opacity: 1; visibility: visible; }
.login-modal-box {
  width: 100%;
  max-width: 380px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 28px 26px;
  position: relative;
  animation: fadeIn 0.25s ease;
}
.login-modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-2);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.login-modal-close svg { width: 16px; height: 16px; }
.login-modal-close:hover { background: var(--primary); color: #fff; }
.login-modal-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-modal-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.login-modal .field-label { margin-top: 16px; }
.login-submit { margin-top: 22px; }
.login-error {
  font-size: 13px;
  color: var(--danger);
  background: rgba(217, 119, 87, 0.1);
  border: 1px solid rgba(217, 119, 87, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 12px;
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.user-chip { cursor: pointer; transition: border-color 0.2s; }
.user-chip:hover { border-color: var(--primary); }
.profile-box { max-width: 360px; text-align: center; padding: 28px 24px; }
.profile-avatar-wrap { margin: 12px auto 16px; }
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  background: var(--bg-2);
}
.profile-info { text-align: left; margin-bottom: 20px; }
.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.profile-row:last-child { border-bottom: none; }
.profile-label { color: var(--text-dim); font-size: 13px; }
#profileLogoutBtn { margin-top: 4px; }
.login-switch {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}
.login-switch a { color: var(--primary-2); text-decoration: none; }
.login-switch a:hover { color: var(--primary); text-decoration: underline; }
.reg-code-row { display: flex; gap: 8px; }
.reg-code-row .btn { white-space: nowrap; }
.captcha-img {
  width: 100%;
  max-width: 240px;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  margin: 12px auto 0;
  display: block;
  background: var(--bg-2);
}
.captcha-box .login-modal-sub { margin-bottom: 4px; }

/* ===== 图片放大灯箱 ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  cursor: zoom-out;
  padding: 24px;
}
.lightbox.show { opacity: 1; visibility: visible; }
.lightbox img {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); transform: rotate(90deg); }
.lightbox-close svg { width: 20px; height: 20px; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 32px 24px 48px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.hidden { display: none !important; }

@media (max-width: 720px) {
  .topbar { padding: 16px 18px; }
  .container { padding: 18px 14px 50px; }
  .row { flex-direction: column; gap: 14px; }
  .panel { padding: 20px; }
  .tabs { gap: 6px; padding: 6px; }
  .tab { font-size: 13.5px; padding: 11px 8px; }
  .progress-track { width: 100%; }
  .results { grid-template-columns: 1fr; }
  .status { flex-direction: column; align-items: flex-start; gap: 14px; }
}
