:root {
  --paper: #EDF0EB;      /* 页面底色：冷调的浅灰绿 */
  --surface: #F8F9F6;    /* 面板 */
  --ink: #1C2333;        /* 正文、取景框 */
  --muted: #5D6474;      /* 次要文字 */
  --line: #CBD1CF;       /* 分隔、描边 */
  --cobalt: #2D47C8;     /* 主要操作 */
  --cobalt-soft: #E3E8FA;
  --rec: #E0484E;        /* 只用于"正在生成" */
  --ok: #217A52;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --radius-frame: 14px;
  --radius-control: 999px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 页头 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1240px; margin: 0 auto; padding: 18px 24px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font: 600 22px/1 var(--serif); letter-spacing: 0.04em; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); }
.account { position: relative; }
.account-btn {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px;
  color: var(--muted);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: 14px;
}
.account-menu {
  position: absolute; right: 0; top: 44px; min-width: 140px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; z-index: 30;
}
.account-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.account-menu button:hover { background: var(--paper); }

/* ---------- 主体布局 ---------- */
.layout {
  max-width: 1240px; margin: 0 auto; padding: 8px 24px 48px;
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 40px; align-items: start;
}

/* ---------- 创作区 ---------- */
.studio h1 { font: 600 30px/1.3 var(--serif); margin: 18px 0 6px; }
.studio .lede { color: var(--muted); margin: 0 0 22px; }

.modes { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.mode {
  border: 1px solid var(--line); background: transparent; border-radius: var(--radius-control);
  padding: 7px 16px; color: var(--muted);
}
.mode[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.mode-help { color: var(--muted); font-size: 14px; margin: 0 0 12px; min-height: 1.6em; }

/* 取景框：页面唯一的视觉重点 */
.viewfinder {
  position: relative; aspect-ratio: 1344 / 768; width: 100%;
  background: var(--ink); color: #EEF1F6; border-radius: var(--radius-frame); overflow: hidden;
}
.viewfinder::before, .viewfinder::after,
.vf-corners::before, .vf-corners::after {
  content: ""; position: absolute; width: 26px; height: 26px; border: 2px solid rgba(238, 241, 246, 0.55);
  pointer-events: none; z-index: 3;
}
.viewfinder::before { top: 14px; left: 14px; border-right: 0; border-bottom: 0; }
.viewfinder::after { top: 14px; right: 14px; border-left: 0; border-bottom: 0; }
.vf-corners::before { bottom: 14px; left: 14px; border-right: 0; border-top: 0; }
.vf-corners::after { bottom: 14px; right: 14px; border-left: 0; border-top: 0; }
.vf-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.vf-text {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; resize: none; border: 0;
  background: transparent; color: inherit; padding: 44px 48px 52px; font-size: 20px; line-height: 1.7;
}
.vf-text::placeholder { color: rgba(238, 241, 246, 0.48); }
.vf-text:focus-visible { outline: none; }
.viewfinder:focus-within { box-shadow: 0 0 0 3px var(--cobalt); }
.vf-meta {
  position: absolute; left: 48px; right: 48px; bottom: 16px; z-index: 2; display: flex; justify-content: space-between;
  font-size: 13px; color: rgba(238, 241, 246, 0.6); font-variant-numeric: tabular-nums; pointer-events: none;
}
.vf-upload {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; text-align: center;
  border: 0; background: transparent; color: rgba(238, 241, 246, 0.8); padding: 24px;
}
.vf-upload strong { display: block; font: 600 20px/1.4 var(--serif); color: #fff; margin-bottom: 4px; }
.vf-photo-actions { position: absolute; top: 16px; right: 52px; z-index: 4; display: flex; gap: 8px; }
.chip-dark {
  border: 0; border-radius: var(--radius-control); padding: 4px 12px; font-size: 13px;
  background: rgba(28, 35, 51, 0.72); color: #fff;
}

/* 照片模式下，文字写在取景框下面 */
.below-frame { margin-top: 12px; }
.text-field {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  padding: 12px 14px; resize: vertical; min-height: 88px;
}

.ideas { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; align-items: center; }
.ideas-label { color: var(--muted); font-size: 14px; margin-right: 4px; }
.idea {
  border: 1px dashed var(--line); background: transparent; border-radius: var(--radius-control);
  padding: 4px 12px; font-size: 14px; color: var(--ink);
}
.idea:hover { border-color: var(--ink); }
.polish { border: 0; background: none; color: var(--cobalt); font-size: 14px; padding: 4px 0; margin-left: auto; }

/* 素材 */
#cast-wrap { margin-top: 14px; }
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.asset {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface);
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; color: var(--muted); text-align: center;
}
.asset img { width: 100%; height: 100%; object-fit: cover; }
.asset .order {
  position: absolute; left: 6px; top: 6px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 20px;
}
.asset .remove {
  position: absolute; right: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(28, 35, 51, 0.72); color: #fff; line-height: 1;
}
.asset-add { border-style: dashed; background: transparent; color: var(--ink); }
.asset-help { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* 选项 */
.options { margin-top: 22px; display: grid; gap: 18px; }
.option-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.option-name { width: 72px; color: var(--muted); font-size: 14px; flex: none; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-control); padding: 3px; background: var(--surface); }
.segmented button {
  border: 0; background: transparent; border-radius: var(--radius-control); padding: 5px 16px; color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.hint { color: var(--muted); font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; }
.switch-track { width: 40px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: background 0.15s; }
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.15s;
}
.switch[aria-checked="true"] .switch-track { background: var(--cobalt); }
.switch[aria-checked="true"] .switch-track::after { transform: translateX(16px); }
.dialogue { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: -6px 0 0 88px; }
.dialogue input, .dialogue select {
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 9px 12px;
}

/* 生成按钮 */
.go { margin-top: 26px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.go-btn {
  border: 0; border-radius: var(--radius-control); background: var(--cobalt); color: #fff;
  padding: 13px 34px; font-size: 17px; font-weight: 600;
}
.go-btn:hover { background: #2238A8; }
.go-btn:disabled { background: #9AA6D9; cursor: not-allowed; }
.queue-note { color: var(--muted); font-size: 14px; }
.form-error { color: var(--rec); font-size: 14px; margin: 10px 0 0; min-height: 1.6em; }

/* ---------- 作品区 ---------- */
.works { padding-top: 18px; }
.works-head { display: flex; align-items: baseline; justify-content: space-between; margin: 10px 0 14px; }
.works-head h2 { font: 600 20px/1.4 var(--serif); margin: 0; }
.works-head span { color: var(--muted); font-size: 14px; }
.work-list { display: grid; gap: 18px; }
.work { display: grid; grid-template-columns: 168px 1fr; gap: 14px; align-items: start; border: 0; background: none; padding: 0; text-align: left; width: 100%; }
.poster {
  position: relative; aspect-ratio: 1344 / 768; border-radius: 8px; overflow: hidden; background: var(--ink);
}
.poster-art { position: absolute; inset: 0; }
.poster .len {
  position: absolute; right: 6px; bottom: 6px; padding: 0 6px; border-radius: 4px; font-size: 12px; line-height: 20px;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-variant-numeric: tabular-nums;
}
.poster .state {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 13px; text-align: center;
  background: rgba(28, 35, 51, 0.62); padding: 8px;
}
.rec-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rec); margin-right: 6px; vertical-align: 1px; }
.recording .rec-dot { animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--rec); transition: width 0.4s linear; }
.work-text { min-width: 0; }
.work-prompt {
  margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.work-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.work-meta .failed { color: var(--rec); }
.work:hover .work-prompt { text-decoration: underline; text-underline-offset: 3px; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 28px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font: 600 17px/1.5 var(--serif); margin-bottom: 4px; }

/* ---------- 播放弹层 ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(28, 35, 51, 0.55); z-index: 40; display: grid; place-items: center; padding: 24px; }
.sheet {
  width: min(880px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface); border-radius: 16px;
}
.sheet { position: relative; }
.sheet .poster { border-radius: 16px 16px 0 0; }
.sheet-close {
  position: absolute; top: 12px; right: 12px; z-index: 5; border: 0; border-radius: var(--radius-control);
  padding: 4px 12px; background: rgba(28, 35, 51, 0.72); color: #fff; font-size: 14px;
}
.sheet .play {
  position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); font-size: 22px;
}
.sheet-body { padding: 18px 22px 22px; }
.sheet-body p { margin: 0 0 6px; font-size: 16px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-control); padding: 8px 18px;
}
.btn-primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn-quiet { border-color: transparent; color: var(--muted); margin-left: auto; }
.btn small { display: block; font-size: 12px; color: var(--muted); }
.btn:has(small) { border-radius: 12px; text-align: left; padding: 8px 16px; }
.btn-primary small { color: #D7DEFA; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; display: flex; gap: 14px; align-items: center;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px; box-shadow: 0 10px 30px rgba(28, 35, 51, 0.3);
}
.toast button { border: 0; background: none; color: #B8C4FF; padding: 0; }

/* ---------- 手机 ---------- */
.tabbar { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0 16px 96px; }
  .topbar { padding: 14px 16px 4px; }
  .studio h1 { font-size: 24px; margin-top: 8px; }
  .studio .lede { margin-bottom: 16px; }
  .vf-text { padding: 30px 28px 40px; font-size: 17px; }
  .vf-meta { left: 46px; right: 46px; bottom: 16px; }
  .vf-photo-actions { right: 40px; }
  .viewfinder { aspect-ratio: 4 / 3; } /* 手机上给文字多留点高度 */
  .viewfinder.has-photo { aspect-ratio: 1344 / 768; }
  .option-name { width: auto; }
  .dialogue { margin-left: 0; grid-template-columns: 1fr; }
  .go { position: sticky; bottom: calc(56px + env(safe-area-inset-bottom)); z-index: 20; background: var(--paper);
         padding: 12px 0 10px; margin-top: 12px; }
  .go-btn { flex: 1; }
  .queue-note { width: 100%; text-align: center; order: 2; }
  .view-hidden { display: none; }
  .work { grid-template-columns: 132px 1fr; }
  .tabbar {
    display: grid; grid-template-columns: 1fr 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button { border: 0; background: none; height: 56px; color: var(--muted); font-size: 14px; }
  .tabbar button[aria-current="page"] { color: var(--ink); font-weight: 600; }
  .tabbar .badge { display: inline-block; min-width: 18px; height: 18px; border-radius: 9px; background: var(--rec); color: #fff; font-size: 11px; line-height: 18px; padding: 0 5px; margin-left: 4px; }
  .sheet-backdrop { place-items: end stretch; padding: 0; }
  .sheet { border-radius: 16px 16px 0 0; max-height: 92vh; }
  .sheet-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .sheet-actions .btn-primary:first-child { grid-column: 1 / -1; padding: 12px; }
  .btn-quiet { margin-left: 0; grid-column: 1 / -1; }
  .toast { bottom: 84px; width: calc(100% - 32px); justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 真实版本新增 ---------- */
a.btn { display: inline-block; text-decoration: none; color: inherit; text-align: center; }
a.btn-primary { color: #fff; }
.mode:disabled { opacity: 0.45; cursor: not-allowed; }
.seed-note {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 0; padding: 8px 12px; border-radius: 10px;
  background: var(--cobalt-soft); color: var(--ink); font-size: 14px;
}
.seed-note button { border: 0; background: none; color: var(--cobalt); padding: 0; margin-left: auto; }
.poster-art { background: var(--ink); }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster .kind { position: absolute; left: 10px; top: 8px; font-size: 12px; color: rgba(255, 255, 255, 0.7); }
.progress.indeterminate { width: 35%; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { from { left: -35%; } to { left: 100%; } }
.sheet video { display: block; width: 100%; aspect-ratio: 1344 / 768; background: #000; border-radius: 16px 16px 0 0; }
.work-user { color: var(--cobalt); }
.detail-error { color: var(--rec); }
.detail-files { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.detail-files img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.detail-files span {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.go-btn[aria-busy="true"] { opacity: 0.8; cursor: progress; }
.notice { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #FBE9E9; color: #8A2B2F; font-size: 14px; }

/* 登录 */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card { width: min(420px, 100%); }
.login-card .viewfinder { aspect-ratio: auto; padding: 44px 40px 40px; }
.login-card h1 { font: 600 26px/1.3 var(--serif); margin: 0 0 6px; color: #fff; }
.login-card p { margin: 0 0 22px; color: rgba(238, 241, 246, 0.7); font-size: 14px; }
.login-card label { display: block; font-size: 13px; color: rgba(238, 241, 246, 0.7); margin: 12px 0 6px; }
.login-card input {
  width: 100%; border: 1px solid rgba(238, 241, 246, 0.25); border-radius: 10px; background: rgba(255, 255, 255, 0.06);
  color: #fff; padding: 11px 12px; font-size: 16px;
}
.login-card .go-btn { width: 100%; margin-top: 22px; }
.login-card .form-error { color: #FFB4B6; }
.login-brand { display: flex; align-items: center; gap: 10px; font: 600 22px/1 var(--serif); margin-bottom: 18px; }
