:root {
  --bg: #0d1017;
  --bg-soft: #141a24;
  --panel: rgba(23, 30, 42, 0.86);
  --panel-line: rgba(255, 255, 255, 0.08);
  --text: #e8edf6;
  --text-dim: #9aa8bd;
  --text-faint: #6b7a92;
  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --accent-3: #35d6c4;
  --ok: #3ddc97;
  --warn: #ffb84d;
  --danger: #ff6b6b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 620px at 12% -10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(900px 520px at 92% 0%, rgba(255, 92, 138, 0.16), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(13, 16, 23, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--panel-line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 13px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(124, 92, 255, 0.42);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; letter-spacing: 0.3px; }
.brand-text small { color: var(--text-faint); font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-line);
  white-space: nowrap;
}
.pill-ok { color: var(--ok); border-color: rgba(61, 220, 151, 0.32); background: rgba(61, 220, 151, 0.1); }
.pill-warn { color: var(--warn); border-color: rgba(255, 184, 77, 0.32); background: rgba(255, 184, 77, 0.1); }
.pill-bad { color: var(--danger); border-color: rgba(255, 107, 107, 0.32); background: rgba(255, 107, 107, 0.1); }

/* ---------------- 布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  max-width: 1420px;
  margin: 0 auto;
  padding: 22px 24px 60px;
}

@media (max-width: 1060px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

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

.panel-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text);
}
.panel-subtitle {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.panel-preview { position: sticky; top: 84px; }
@media (max-width: 1060px) { .panel-preview { position: static; } }

/* ---------------- 表单 ---------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.field-hint { font-size: 11.5px; color: var(--text-faint); }

textarea, input[type="text"], select {
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(9, 12, 18, 0.72);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 74px; line-height: 1.6; }

textarea:focus, input[type="text"]:focus, select:focus {
  border-color: rgba(124, 92, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.16);
}

select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 100%; height: 36px; padding: 2px;
  background: rgba(9, 12, 18, 0.72);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* 开关 */
.switch { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.switch input { display: none; }
.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 40px; height: 22px;
  margin-top: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--panel-line);
  transition: background 0.18s;
}
.switch-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}
.switch input:checked + .switch-track { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch-text { font-size: 13px; color: var(--text); display: flex; flex-direction: column; }
.switch-text small { color: var(--text-faint); font-size: 11.5px; }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.16s, opacity 0.16s, background 0.16s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(124, 92, 255, 0.32);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 30px rgba(255, 92, 138, 0.36); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--panel-line);
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.btn-small { padding: 8px 13px; font-size: 12.5px; }
.btn-emoji { font-size: 15px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 6px; }
.actions .btn-primary { flex: 1 1 190px; }

/* ---------------- 示例 chips ---------------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip {
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { color: #fff; border-color: rgba(124, 92, 255, 0.6); background: rgba(124, 92, 255, 0.18); }

/* ---------------- 进度 ---------------- */

.progress { margin: 16px 0 4px; padding: 14px; border-radius: var(--radius-sm); background: rgba(9, 12, 18, 0.55); border: 1px solid var(--panel-line); }
.progress-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.progress-track { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.progress-bar { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3)); transition: width 0.35s ease; }
.progress-note { margin: 10px 0 0; font-size: 11.5px; color: var(--text-faint); }

.steps { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-faint); }
.steps li i {
  width: 14px; height: 14px; flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  transition: all 0.2s;
}
.steps li.active { color: var(--text); }
.steps li.active i { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.16); }
.steps li.done { color: var(--ok); }
.steps li.done i { border-color: var(--ok); background: var(--ok); }

/* ---------------- 分镜卡 ---------------- */

.plan-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(9, 12, 18, 0.55);
  border: 1px solid var(--panel-line);
}
.plan-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.badge {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.9), rgba(255, 92, 138, 0.9));
}
.plan-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.plan-tags span { font-size: 11.5px; color: var(--text-faint); background: rgba(255, 255, 255, 0.05); padding: 3px 9px; border-radius: 999px; }
.plan-list { display: grid; grid-template-columns: 56px 1fr; gap: 6px 10px; margin: 0; font-size: 12.5px; }
.plan-list dt { color: var(--text-faint); }
.plan-list dd { margin: 0; color: var(--text); word-break: break-all; }
.plan-details { margin-top: 12px; }
.plan-details summary { font-size: 12px; color: var(--text-dim); cursor: pointer; }
.plan-details pre {
  margin: 8px 0 0;
  padding: 10px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
}
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(255, 255, 255, 0.25); }

/* 姿势清单 */
.pose-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pose-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-line);
  font-size: 12px;
}
.pose-list b {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.pose-list .pose-text { flex: 1 1 auto; color: var(--text); line-height: 1.5; }
.pose-list em { flex: 0 0 auto; font-style: normal; color: var(--accent-3); font-size: 11px; white-space: nowrap; padding-top: 1px; }

.upload-row { margin-top: 14px; }
.upload-row .btn { width: 100%; }

/* ---------------- 预览 ---------------- */

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-line);
  background:
    conic-gradient(from 90deg at 50% 50%, rgba(255,255,255,0.045) 0 25%, transparent 0 50%, rgba(255,255,255,0.045) 0 75%, transparent 0) 0 0 / 22px 22px,
    rgba(6, 9, 14, 0.6);
}
.preview-stage canvas, .preview-stage img {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 420px;
  border-radius: 10px;
  image-rendering: auto;
  background:
    conic-gradient(from 90deg at 50% 50%, #1b2230 0 25%, #141a24 0 50%, #1b2230 0 75%, #141a24 0) 0 0 / 18px 18px;
}
.preview-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-faint); text-align: center; }
.preview-empty span { font-size: 40px; }
.preview-empty p { margin: 0; font-size: 13px; }
.preview-empty small { color: #55627a; font-size: 11.5px; }

.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 14px 0 4px; }
.preview-meta { font-size: 12px; color: var(--text-faint); }
.preview-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.encode-progress { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.encode-progress .progress-track { flex: 1; }
.encode-progress span { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }

.controls { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--panel-line); }

/* 动效选择 */
.motion-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 620px) { .motion-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.motion-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  font-size: 11.5px;
  color: var(--text-dim);
  background: rgba(9, 12, 18, 0.6);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.motion-btn span { font-size: 17px; line-height: 1; }
.motion-btn:hover { color: var(--text); border-color: rgba(124, 92, 255, 0.5); }
.motion-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.85), rgba(255, 92, 138, 0.75));
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.28);
}

/* ---------------- 历史 ---------------- */

.history { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--panel-line); }
.history-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.history-item {
  flex: 0 0 auto;
  width: 78px;
  cursor: pointer;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(9, 12, 18, 0.6);
  transition: border-color 0.15s, transform 0.12s;
}
.history-item:hover { border-color: rgba(124, 92, 255, 0.7); transform: translateY(-2px); }
.history-item img { display: block; width: 100%; height: 64px; object-fit: contain; background: #0f151f; }
.history-item .history-placeholder {
  display: grid;
  place-items: center;
  height: 64px;
  font-size: 11px;
  color: var(--text-faint);
  background: #0f151f;
}
.history-item p { margin: 0; padding: 5px 6px; font-size: 10.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  color: #fff;
  background: rgba(24, 30, 42, 0.96);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
}
.toast.err { background: rgba(120, 26, 34, 0.96); border-color: rgba(255, 107, 107, 0.5); }
.toast.ok { background: rgba(18, 82, 60, 0.96); border-color: rgba(61, 220, 151, 0.5); }
