:root {
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
  color: #171a1f;
  background: #eef1f4;
  font-synthesis: none;
  --ink: #171a1f;
  --muted: #6b717a;
  --line: #dfe3e8;
  --surface: #ffffff;
  --accent: #e84a5f;
  --accent-dark: #c9364b;
  --green: #16845b;
  --amber: #b56a13;
  --radius: 8px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.app-shell { min-height: 100vh; background: #f5f6f8; padding-bottom: 76px; }
.topbar { position: sticky; top: 0; z-index: 20; height: 58px; display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top) 16px 0; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 750; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: white; background: var(--ink); border-radius: 7px; font-size: 15px; }
.icon-btn { width: 38px; height: 38px; border: 0; background: transparent; border-radius: 7px; font-size: 22px; color: var(--ink); }
.icon-btn:active { background: #eceff2; }

.content { width: min(100%, 720px); margin: 0 auto; padding: 14px 14px 28px; }
.hero { position: relative; min-height: 172px; overflow: hidden; border-radius: var(--radius); background: #15171b url("assets/drama-hero.png") center/cover no-repeat; color: white; padding: 22px 20px; display: flex; flex-direction: column; justify-content: flex-end; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,12,15,.86), rgba(10,12,15,.3)); }
.hero > * { position: relative; }
.hero h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.2; letter-spacing: 0; }
.hero p { margin: 0 0 16px; max-width: 340px; color: rgba(255,255,255,.78); font-size: 13px; line-height: 1.55; }

.btn { min-height: 42px; border: 1px solid transparent; border-radius: 7px; padding: 0 16px; font-weight: 650; background: #eceff2; color: var(--ink); }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:active { background: var(--accent-dark); }
.btn.outline { border-color: var(--line); background: white; }
.btn.dark { background: var(--ink); color: white; }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.btn.full { width: 100%; }
.hero .btn { align-self: flex-start; }

.section-head { margin: 22px 2px 10px; display: flex; align-items: end; justify-content: space-between; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head span { color: var(--muted); font-size: 12px; }
.project-list { display: grid; gap: 10px; }
.project-row { display: grid; grid-template-columns: 82px 1fr auto; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.project-cover { width: 82px; aspect-ratio: 16/10; object-fit: cover; border-radius: 6px; background: #222; }
.project-row h3 { margin: 0 0 5px; font-size: 15px; }
.project-row p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.status { display: inline-flex; margin-top: 7px; padding: 3px 7px; border-radius: 4px; font-size: 10px; color: var(--green); background: #e8f5ef; }
.row-arrow { color: #9298a1; font-size: 22px; }

.workspace-head { margin: 2px 0 12px; display: flex; gap: 10px; align-items: center; }
.workspace-head .icon-btn { flex: 0 0 auto; }
.workspace-head h1 { margin: 0; font-size: 20px; }
.workspace-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.steps { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 12px; }
.steps::-webkit-scrollbar { display: none; }
.step { flex: 0 0 auto; border: 1px solid var(--line); background: white; color: var(--muted); border-radius: 6px; padding: 8px 11px; font-size: 12px; }
.step.active { color: white; border-color: var(--ink); background: var(--ink); }
.step.done::before { content: "✓ "; color: var(--green); }
.step.active.done::before { color: white; }

.panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 10px; }
.panel h2 { margin: 0 0 5px; font-size: 17px; }
.panel-desc { margin: 0 0 15px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.field { display: grid; gap: 7px; margin: 14px 0; }
.field label { font-size: 12px; font-weight: 700; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; background: #fafbfc; padding: 12px; outline: none; }
.field textarea { min-height: 170px; resize: vertical; line-height: 1.7; }
.field input:focus, .field textarea:focus { border-color: #aeb5bf; background: white; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }

.asset-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 12px; padding: 4px; background: #eceff2; border-radius: 7px; }
.asset-tab { height: 36px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 13px; }
.asset-tab.active { background: white; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.asset-grid { display: grid; gap: 10px; }
.asset-card { display: grid; grid-template-columns: 82px 1fr; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.asset-preview { width: 82px; height: 106px; object-fit: cover; border-radius: 6px; background: #e8ebef; }
.asset-result { position: relative; width: 82px; height: 106px; overflow: hidden; padding: 0; border: 0; border-radius: 6px; background: #e8ebef; }
.asset-result span { position: absolute; right: 4px; bottom: 4px; padding: 2px 5px; border-radius: 3px; color: white; background: rgba(0,0,0,.7); font-size: 9px; }
.asset-card.asset-expanded .asset-result { grid-column: 1 / -1; width: 100%; height: auto; aspect-ratio: 16/9; }
.asset-card.asset-expanded .asset-preview { width: 100%; height: 100%; }
.asset-card.asset-expanded .asset-main { grid-column: 1 / -1; }
.asset-placeholder { width: 82px; height: 106px; display: grid; place-items: center; border: 1px dashed #c7ccd3; border-radius: 6px; color: #9298a1; font-size: 28px; background: #f7f8fa; }
.asset-card h3 { margin: 2px 0 4px; font-size: 15px; }
.asset-card p { margin: 0 0 9px; min-height: 36px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.asset-main { min-width: 0; }
.asset-prompt { width: 100%; min-height: 58px; margin: 2px 0 8px; padding: 8px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; color: #3f454d; background: #fafbfc; font-size: 11px; line-height: 1.45; }
.asset-ai-row { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.confirmed { color: var(--green); font-size: 10px; }
.reference-head { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 5px; font-size: 10px; }
.reference-head span { font-weight: 700; }
.reference-head em { color: var(--muted); font-style: normal; text-align: right; }
.reference-preview { position: relative; width: 48px; height: 48px; margin-bottom: 6px; }
.reference-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; }
.reference-preview button { position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; padding: 0; border: 1px solid white; border-radius: 50%; color: white; background: #333840; }
.source-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.source-btn { height: 34px; border: 1px solid var(--line); background: white; border-radius: 6px; color: #454b54; font-size: 11px; }
.source-btn.glasses { border-color: #f2bbc3; color: var(--accent-dark); background: #fff5f6; }
.asset-state { margin-top: 8px; color: var(--green); font-size: 11px; }

.shot-list { display: grid; gap: 10px; }
.shot { display: grid; grid-template-columns: 104px 1fr; gap: 11px; padding: 10px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot-thumb { position: relative; width: 104px; aspect-ratio: 16/10; overflow: hidden; align-self: start; padding: 0; border: 0; border-radius: 6px; background: #e8ebef; }
.shot-thumb span { position: absolute; inset: 0; display: grid; place-items: center; color: white; background: rgba(0,0,0,.28); font-size: 20px; opacity: 0; }
.shot-thumb.ready span { opacity: 1; }
.shot-thumb.ready:active span { background: rgba(0,0,0,.48); }
.shot-thumb.playing img { animation: inline-video 4s ease-in-out infinite alternate; }
.shot-thumb.playing span { background: rgba(0,0,0,.08); opacity: 0; }
.shot-thumb.playing:active span { opacity: 1; }
.shot-thumb i { position: absolute; right: 4px; bottom: 4px; padding: 2px 4px; border-radius: 3px; color: white; background: rgba(0,0,0,.72); font-size: 9px; font-style: normal; }
@keyframes inline-video { from { transform: scale(1); } to { transform: scale(1.12); } }
.shot h3 { margin: 0 0 4px; font-size: 14px; }
.shot p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.shot-meta { display: flex; gap: 8px; margin-top: 8px; color: #4d535b; font-size: 10px; }
.shot-body { min-width: 0; }
.shot-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 9px; }
.shot-status { margin-right: auto; color: var(--muted); font-size: 10px; }
.shot-status.generating { color: #9a6810; }
.shot-status.done { color: var(--green); }
.frame-card { align-items: start; }
.frame-card .shot-thumb span { inset: auto 5px 5px; display: block; padding: 2px 5px; border-radius: 3px; color: white; background: rgba(0,0,0,.68); font-size: 9px; opacity: 1; }
.frame-preview { position: relative; width: 104px; aspect-ratio: 16/10; overflow: hidden; align-self: start; padding: 0; border: 0; border-radius: 6px; background: #e8ebef; }
.frame-preview img { width: 100%; height: 100%; object-fit: cover; }
.frame-preview span { position: absolute; right: 5px; bottom: 5px; padding: 2px 5px; border-radius: 3px; color: white; background: rgba(0,0,0,.68); font-size: 9px; }
.frame-preview.ratio-16-9, .frame-placeholder.ratio-16-9 { aspect-ratio: 16/9; }
.frame-preview.ratio-9-16, .frame-placeholder.ratio-9-16 { width: 68px; aspect-ratio: 9/16; justify-self: center; }
.frame-preview.ratio-1-1, .frame-placeholder.ratio-1-1 { width: 86px; aspect-ratio: 1; justify-self: center; }
.frame-card.frame-expanded .frame-preview { grid-column: 1 / -1; width: 100%; max-height: 520px; justify-self: center; }
.frame-card.frame-expanded .frame-preview.ratio-9-16 { width: min(100%, 280px); }
.frame-card.frame-expanded .frame-preview.ratio-1-1 { width: min(100%, 420px); }
.frame-card.frame-expanded .shot-body { grid-column: 1 / -1; }
.montage { color: #353a42 !important; }
.montage-label { display: block; margin: 5px 0 4px; color: var(--muted); font-size: 9px; font-weight: 700; }
.montage-editor { width: 100%; min-height: 58px; padding: 7px; resize: vertical; border: 1px solid var(--line); border-radius: 5px; color: #353a42; background: #fafbfc; font-size: 10px; line-height: 1.5; }
.element-groups { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.element-groups span { padding: 3px 5px; border-radius: 4px; color: #555c65; background: #f1f3f5; font-size: 9px; }
.element-groups b { margin-right: 3px; color: #24282e; }
.ratio-setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 14px; }
.ratio-setting > span { font-size: 12px; font-weight: 700; }
.ratio-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border-radius: 6px; background: #eceff2; }
.ratio-control button { min-width: 54px; height: 32px; padding: 0 9px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 11px; }
.ratio-control button.active { color: white; background: var(--ink); }
.confirmed-ratio { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 9px 10px; border-radius: 6px; background: #f3f5f7; font-size: 11px; }
.confirmed-ratio span { color: var(--muted); }
.confirmed-ratio strong { font-size: 13px; }
.confirmed-ratio button { margin-left: auto; padding: 4px 7px; border: 0; color: var(--accent-dark); background: transparent; font-size: 11px; }
.video-thumb.ratio-16-9 { aspect-ratio: 16/9; }
.video-thumb.ratio-9-16 { width: 68px; aspect-ratio: 9/16; justify-self: center; }
.video-thumb.ratio-1-1 { width: 86px; aspect-ratio: 1; justify-self: center; }
.duration-bar { position: relative; display: flex; align-items: baseline; justify-content: space-between; overflow: hidden; margin: 0 0 13px; padding: 10px 12px 13px; background: #f3f5f7; border-radius: 6px; }
.duration-bar strong { font-size: 16px; }
.duration-bar span { color: var(--muted); font-size: 11px; }
.duration-bar i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.btn:disabled { opacity: .55; cursor: wait; filter: saturate(.55); }
.btn-loading { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
.spinner { width: 14px; height: 14px; flex: 0 0 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: button-spin .7s linear infinite; }
@keyframes button-spin { to { transform: rotate(360deg); } }
.progress { height: 6px; overflow: hidden; margin: 14px 0 8px; background: #e8ebef; border-radius: 3px; }
.progress > span { display: block; width: 68%; height: 100%; background: var(--accent); }
.final-preview { width: 100%; max-height: 440px; margin: 12px auto; background: #17191d url("assets/drama-hero.png") center/cover; border-radius: var(--radius); display: grid; place-items: center; color: white; }
.final-preview.ratio-16-9 { aspect-ratio: 16/9; }
.final-preview.ratio-9-16 { width: min(100%, 248px); aspect-ratio: 9/16; }
.final-preview.ratio-1-1 { width: min(100%, 400px); aspect-ratio: 1; }
.play { width: 58px; height: 58px; border: 0; border-radius: 50%; color: white; background: rgba(0,0,0,.68); font-size: 22px; }

.bottom-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); }
.nav-btn { border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.nav-btn strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 19px; font-weight: 500; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active strong { color: var(--accent); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 84px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 14px; color: white; background: rgba(23,26,31,.94); border-radius: 6px; font-size: 12px; }
.media-viewer { position: fixed; z-index: 100; inset: 0; display: grid; grid-template-rows: calc(54px + env(safe-area-inset-top)) 1fr; color: white; background: rgba(8,10,13,.96); }
.media-viewer-head { display: flex; align-items: center; gap: 12px; padding: env(safe-area-inset-top) 14px 0; }
.media-viewer-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.media-viewer-head button { width: 42px; height: 42px; margin-left: auto; padding: 0; border: 0; color: white; background: transparent; font-size: 30px; line-height: 1; }
.media-viewer-body { min-width: 0; min-height: 0; display: grid; place-items: center; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.media-viewer-body img { width: 100%; height: 100%; object-fit: contain; }
.media-viewer-body video { width: 100%; height: 100%; max-height: calc(100vh - 62px - env(safe-area-inset-top)); object-fit: contain; background: #000; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.auth-shell { padding-bottom: 0; }
.auth-main { min-height: calc(100vh - 58px); display: grid; place-items: center; padding: 18px; }
.login-panel { width: min(100%, 380px); padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.login-panel h1 { margin: 0 0 6px; font-size: 21px; }
.login-panel > p { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.login-panel form { display: grid; gap: 12px; }
.login-panel label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; }
.login-panel input { height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfc; }
.login-panel small { display: block; margin-top: 12px; color: var(--muted); text-align: center; }
.form-error { padding: 8px 10px; border-radius: 5px; color: #a22d3d; background: #fff0f2; font-size: 11px; }

@media (min-width: 720px) {
  .content { padding-top: 20px; }
  .hero { min-height: 220px; }
  .asset-grid { grid-template-columns: 1fr 1fr; }
  .bottom-nav { left: 50%; width: 720px; transform: translateX(-50%); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (max-width: 420px) {
  .shot { grid-template-columns: 86px 1fr; }
  .shot-thumb { width: 86px; }
  .frame-preview { width: 86px; }
  .shot-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .shot-actions .btn { min-height: 32px; }
}
