:root {
  --bg: #ffffff;
  --bg-subtle: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-hover: #ebebef;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: #1d1d1f;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-inverse: #ffffff;
  --accent: #0066cc;
  --accent-tint: #eef4fc;
  --success: #1a7f37;
  --warning: #b25000;
  --danger: #d70015;
  --radius: 22px;
  --radius-sm: 14px;
  --pill: 980px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --page: 1080px;
  --gutter: 22px;
  --nav-h: 52px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
img, video { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h1:focus { outline: none; }
h1, h2, h3 { text-wrap: balance; }
.lead, .fineprint, .tpl-desc { text-wrap: pretty; }

/* ---------- 导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter);
  height: var(--nav-h); display: flex; align-items: center; justify-content: space-between;
}
.brand-wrap { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.build { font-size: 12px; color: var(--text-tertiary); letter-spacing: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nav-links { display: flex; gap: 28px; font-size: 14px; }
.nav-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-secondary); transition: color .2s var(--ease); }
.nav-links a:hover, .nav-links a.active { color: var(--text-primary); }

/* ---------- 页面 ---------- */
.page { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter) 140px; }
.page.enter { animation: fade .45s var(--ease); }
.page:has(.wizard) { padding-bottom: 24px; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { padding: 120px 0 72px; }
.hero-compact { padding: 96px 0 40px; }
.hero h1, .status-hero h1, .confirm h1 {
  font-size: clamp(40px, 6vw, 64px); font-weight: 600; line-height: 1.07; letter-spacing: -0.03em;
}
.lead { font-size: clamp(19px, 2.2vw, 24px); color: var(--text-secondary); margin-top: 16px; line-height: 1.4; }
.eyebrow { font-size: 15px; color: var(--text-secondary); margin-bottom: 14px; overflow-wrap: anywhere; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }

/* ---------- 按钮 ---------- */
.btn-primary, .btn-secondary, .btn-text {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 30px; border-radius: var(--pill);
  font-size: 17px; font-weight: 500; white-space: nowrap;
  transition: background .2s var(--ease), color .2s var(--ease), opacity .2s var(--ease), transform .1s var(--ease);
}
.btn-primary { background: var(--text-primary); color: var(--text-inverse); }
.btn-primary:hover { background: #3a3a3c; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.25; cursor: default; transform: none; background: var(--text-primary); }
.btn-secondary { background: var(--bg-subtle); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-text { padding: 0 18px; color: var(--text-secondary); }
.btn-text:hover { color: var(--text-primary); }
.btn-text.armed { color: var(--danger); }
.btn-text:disabled { opacity: 0.4; cursor: default; }
.link-btn { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); font-size: 15px; }
.link-btn:hover { text-decoration: underline; }

.actions { margin-top: 40px; display: flex; justify-content: flex-end; }
.actions-start { justify-content: flex-start; }
.actions-split { justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.action-group { display: flex; align-items: center; gap: 8px; }
.fineprint { font-size: 14px; color: var(--text-secondary); }

/* ---------- 新建视频：一屏一步，横向切换 ---------- */
.wizard-head { padding-top: 56px; }
.wizard-steps { list-style: none; display: flex; gap: 32px; }
.wizard-steps button {
  display: inline-flex; align-items: baseline; gap: 8px; min-height: 36px;
  font-size: 15px; color: var(--text-tertiary); transition: color .2s var(--ease);
}
.wizard-steps .num { font-size: 13px; font-variant-numeric: tabular-nums; }
.wizard-steps li.done button { color: var(--text-secondary); }
.wizard-steps li.done button:hover { color: var(--text-primary); }
.wizard-steps li.current button { color: var(--text-primary); font-weight: 600; cursor: default; }
.wizard-steps button:disabled { cursor: default; }

.wizard { --panel-gap: 64px; overflow: hidden; padding: 6px; margin: 0 -6px; transition: height .4s var(--ease); }
.wizard-track { display: flex; gap: var(--panel-gap); align-items: flex-start; transition: transform .55s var(--ease); }
.wizard-track.instant { transition: none; }
.panel { flex: 0 0 100%; min-width: 0; padding-top: 28px; transition: opacity .45s var(--ease); }
.panel:not(.active) { opacity: 0; }
.panel-title {
  font-size: clamp(40px, 6vw, 64px); font-weight: 600; line-height: 1.07; letter-spacing: -0.03em; margin-bottom: 40px;
}
.panel-title:focus { outline: none; }
.panel-foot { margin-top: 36px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.btn-back { margin-left: -18px; }
.btn-back::before { content: "‹"; margin-right: 6px; font-size: 20px; line-height: 1; margin-top: -2px; }

/* 选项横向排列，选项多时左右滑动 */
.rail {
  display: flex; gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 4px; margin: -4px; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: none; scroll-snap-align: start; }

.tick {
  position: absolute; top: 16px; right: 16px; width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .25s var(--ease), border-color .25s var(--ease);
}
.selected .tick { background: var(--text-primary); border-color: var(--text-primary); }
.selected .tick::after {
  content: ""; position: absolute; left: 9px; top: 5px; width: 6px; height: 12px;
  border: solid var(--text-inverse); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* 模板卡 */
.tpl-card {
  position: relative; width: min(720px, 100%); text-align: left;
  background: var(--bg-subtle); border-radius: var(--radius); overflow: hidden;
  box-shadow: inset 0 0 0 1.5px transparent;
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.tpl-card:hover { transform: translateY(-2px); }
.tpl-card.selected { box-shadow: 0 0 0 2px var(--border-strong); }
.tpl-media { aspect-ratio: 16 / 9; background: #0a0f14; }
.tpl-media img { width: 100%; height: 100%; object-fit: cover; }
.tpl-body { padding: 24px 28px 28px; }
.tpl-body h3 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.tpl-spec { margin-top: 4px; font-size: 15px; color: var(--text-secondary); }
.tpl-desc { margin-top: 12px; font-size: 16px; line-height: 1.55; color: var(--text-secondary); }

/* 形象卡 */
.char-card {
  position: relative; width: 260px; text-align: left; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-subtle); box-shadow: inset 0 0 0 1.5px transparent;
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.char-card:hover { transform: translateY(-2px); }
.char-card.selected { box-shadow: 0 0 0 2px var(--border-strong); }
.char-media { aspect-ratio: 4 / 5; }
.char-media img { width: 100%; height: 100%; object-fit: cover; }
.char-name { display: block; padding: 18px 22px 20px; font-size: 21px; font-weight: 600; }

/* 脚本输入 */
.composer {
  background: var(--bg-subtle); border-radius: var(--radius); padding: 28px 28px 18px;
  box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .2s var(--ease), background .2s var(--ease);
}
.composer:focus-within { box-shadow: inset 0 0 0 1.5px var(--text-tertiary); }
.composer.dragging { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-tint); }
.composer textarea {
  display: block; width: 100%; min-height: 220px; resize: none; overflow: hidden;
  border: 0; outline: none; background: transparent;
  font-size: 19px; line-height: 1.75;
}
.composer textarea::placeholder { color: var(--text-tertiary); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 4px 4px 4px 14px; border-radius: var(--pill); background: var(--bg-elevated);
  font-size: 14px; box-shadow: 0 0 0 1px var(--border); transition: opacity .2s var(--ease);
}
.chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.uploading { opacity: 0.55; }
.chip.uploading span::after { content: " · 上传中"; color: var(--text-tertiary); }
.chip button {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  color: var(--text-secondary); font-size: 17px; line-height: 1;
}
.chip button:hover { background: var(--bg-subtle); color: var(--text-primary); }
.composer-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border);
}
.composer-hint { font-size: 14px; color: var(--text-tertiary); }
.composer-count { margin-left: auto; font-size: 14px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.composer-count.note, .script-meta.note { color: var(--text-primary); }
.composer-count.warn, .script-meta.warn { color: var(--warning); }

/* 开关 */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin-top: 16px; padding: 20px 28px; border-radius: var(--radius); background: var(--bg-subtle); cursor: pointer;
}
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text strong { font-weight: 600; }
.switch-text span { font-size: 14px; color: var(--text-secondary); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer;
  width: 51px; height: 31px; border-radius: 31px; background: #e3e3e8; position: relative;
  transition: background .25s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: var(--bg-elevated); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); transition: transform .25s var(--ease);
}
.switch:checked { background: var(--text-primary); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- 单条视频 ---------- */
.status-hero, .confirm { padding-top: 80px; }
.status-hero .lead { max-width: 720px; }

.stepper { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 64px; max-width: 720px; }
.stepper li { position: relative; display: flex; flex-direction: column; gap: 12px; color: var(--text-tertiary); font-size: 15px; }
.stepper li::before {
  content: ""; position: absolute; top: 5px; left: 12px; right: 0; height: 1.5px; background: var(--border);
}
.stepper li:last-child::before { display: none; }
.stepper li.done::before { background: var(--text-primary); }
.stepper .dot {
  position: relative; z-index: 1; width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--border);
}
.stepper li.done .dot { background: var(--text-primary); box-shadow: none; }
.stepper li.done, .stepper li.current { color: var(--text-primary); }
.stepper li.current .dot { background: var(--text-primary); box-shadow: 0 0 0 5px rgba(29, 29, 31, 0.1); animation: pulse 1.8s var(--ease) infinite; }
.stepper li.current .label { font-weight: 600; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(29, 29, 31, 0.04); } }

.script-editor {
  margin-top: 48px; background: var(--bg-subtle); border-radius: var(--radius); padding: 36px 40px 20px;
  box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .2s var(--ease);
}
.script-editor:focus-within { box-shadow: inset 0 0 0 1.5px var(--text-tertiary); }
.script-editor textarea {
  display: block; width: 100%; min-height: 200px; resize: none; overflow: hidden; border: 0; outline: none; background: transparent;
  font-size: 21px; line-height: 1.85; letter-spacing: 0;
}
.script-editor textarea:read-only { color: var(--text-secondary); }
.script-meta { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-secondary); text-align: right; font-variant-numeric: tabular-nums; }

/* 确认页：预计成片时长（放大显示） */
.estimate { margin-top: 32px; }
.estimate-label { font-size: 15px; color: var(--text-secondary); }
.estimate-value { margin-top: 4px; font-size: clamp(36px, 5vw, 52px); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.estimate-note { margin-top: 8px; font-size: 14px; color: var(--text-secondary); }
.estimate-hint { margin-top: 6px; font-size: 15px; color: var(--warning); }

.script-peek { margin-top: 64px; max-width: 760px; border-top: 1px solid var(--border); padding-top: 20px; }
.script-peek summary { display: inline-flex; align-items: center; min-height: 32px; cursor: pointer; font-size: 15px; color: var(--accent); list-style: none; }
.script-peek summary::-webkit-details-marker { display: none; }
.script-peek summary::after { content: "›"; margin-left: 6px; display: inline-block; transition: transform .2s var(--ease); }
.script-peek[open] summary::after { transform: rotate(90deg); }
.script-peek p { margin-top: 16px; font-size: 17px; line-height: 1.85; color: var(--text-secondary); overflow-wrap: anywhere; }

/* 成片：播放器在常见笔记本屏幕上与下载按钮同屏 */
.result { padding-top: 40px; }
.result-title { max-width: 900px; font-size: clamp(30px, 4.2vw, 48px); font-weight: 600; line-height: 1.1; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.stage { margin-top: 28px; width: min(100%, max(480px, calc((100vh - 330px) * 16 / 9))); }
.player { border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.player video { width: 100%; height: 100%; object-fit: contain; }
.result-bar { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.result-actions { display: flex; gap: 12px; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--pill); background: var(--bg-subtle); }
.segmented button {
  min-height: 38px; padding: 0 20px; border-radius: var(--pill); font-size: 14px; color: var(--text-secondary);
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
.segmented button[aria-pressed="true"] { background: var(--bg-elevated); color: var(--text-primary); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }

/* ---------- 我的视频 ---------- */
.job-list { list-style: none; border-top: 1px solid var(--border); }
.job-list li { border-bottom: 1px solid var(--border); }
.job-row { display: grid; grid-template-columns: 176px 1fr auto; gap: 28px; align-items: center; padding: 24px 0; }
.job-row:hover h3 { color: var(--accent); }
.thumb { aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-subtle); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { background: linear-gradient(135deg, #f5f5f7, #e8e8ed); }
.job-main { min-width: 0; }
.job-main h3 { font-size: 21px; font-weight: 600; letter-spacing: -0.015em; transition: color .2s var(--ease); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { margin-top: 6px; font-size: 14px; color: var(--text-secondary); }
.job-status { font-size: 14px; color: var(--text-secondary); white-space: nowrap; }
.job-status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; background: var(--text-tertiary); }
.s-awaiting_confirm { color: var(--accent); font-weight: 600; }
.s-awaiting_confirm::before { background: var(--accent); }
.s-refining::before, .s-producing::before, .s-qc::before { background: var(--accent); animation: blink 1.6s ease-in-out infinite; }
.s-done::before { background: var(--success); }
.s-on_hold { color: var(--warning); }
.s-on_hold::before { background: var(--warning); }
.s-failed { color: var(--danger); }
.s-failed::before { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.3; } }
.empty { padding: 40px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 28px; }

/* ---------- 访问密钥 ---------- */
.gate { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 24px; animation: fade .6s var(--ease); }
.gate-inner { width: 100%; max-width: 420px; text-align: center; }
.gate-brand { font-size: clamp(48px, 9vw, 72px); font-weight: 600; letter-spacing: -0.04em; }
.gate-form { margin-top: 48px; display: flex; flex-direction: column; gap: 14px; }
.gate-form input {
  height: 56px; padding: 0 22px; border-radius: var(--radius-sm); border: 0; outline: none;
  background: var(--bg-subtle); font-size: 17px; text-align: center; letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .2s var(--ease);
}
.gate-form input:focus { box-shadow: inset 0 0 0 1.5px var(--text-tertiary); }
.gate-form input::placeholder { letter-spacing: 0; color: var(--text-tertiary); }
.gate-form .btn-primary { min-height: 52px; }
.gate-error { margin-top: 18px; min-height: 21px; font-size: 14px; color: var(--danger); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 20;
  padding: 12px 22px; border-radius: var(--pill); background: rgba(29, 29, 31, 0.92); color: var(--text-inverse); font-size: 14px;
  transition: opacity .25s var(--ease), transform .25s var(--ease); max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 734px) {
  :root { --gutter: 16px; --radius: 18px; }
  .nav-links { gap: 16px; }
  .brand { font-size: 17px; }
  .build { font-size: 11px; }
  .brand-wrap { gap: 6px; }
  .hero { padding: 72px 0 48px; }
  .hero-compact { padding: 64px 0 28px; }
  .status-hero, .confirm { padding-top: 56px; }
  .wizard-head { padding-top: 32px; }
  .wizard-steps { gap: 20px; }
  .wizard { --panel-gap: 32px; }
  .panel-title { margin-bottom: 28px; }
  .rail { gap: 12px; }
  .tpl-card { width: 100%; }
  .tpl-body { padding: 18px 20px 22px; }
  .tpl-body h3 { font-size: 21px; }
  .char-card { width: 62vw; max-width: 260px; }
  .char-name { padding: 14px 18px 16px; font-size: 19px; }
  .composer { padding: 20px 18px 14px; }
  .composer textarea { font-size: 17px; min-height: 180px; }
  .composer-hint { display: none; }
  .link-btn { min-height: 44px; }
  .chip button { width: 32px; height: 32px; }
  .switch-row { padding: 16px 18px; }
  .actions .btn-primary, .panel-foot .btn-primary { flex: 1; }
  .actions-split { flex-direction: column-reverse; align-items: stretch; }
  .action-group { flex-direction: column-reverse; align-items: stretch; }
  .script-editor { padding: 24px 20px 16px; margin-top: 36px; }
  .script-editor textarea { font-size: 18px; }
  .stepper { margin-top: 48px; }
  .result { padding-top: 28px; }
  .stage { width: 100%; }
  .result-bar { flex-direction: column; align-items: stretch; }
  .result-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .segmented { align-self: flex-start; }
  .job-row { grid-template-columns: 112px 1fr; gap: 16px; padding: 18px 0; }
  .job-status { grid-column: 2; margin-top: -8px; }
  .job-main h3 { font-size: 17px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
