:root {
  color-scheme: dark;
  --base: #111118;
  --panel: #1a1a24;
  --field: #14141d;
  --line: #2c2d3b;
  --text: #f3f1fb;
  --muted: #a9a8ba;
  --accent: #c2b1ff;
  --primary: #bca8ff;
  --danger: #ff9ca9;
  font: 400 16px/1.5 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--base);
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; min-height: 100vh; background: radial-gradient(ellipse 810px 340px at 47% 0, #232035 0, transparent 75%); }
button, select, textarea, input { font: inherit; color: inherit; }
button, a, select, .drop, .modes label { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.0625rem; font-weight: 650; }
.topbar { background: #14141bee; border-bottom: 1px solid #2a2937; }
.topbar-inner { max-width: 1256px; margin: auto; min-height: 67px; padding: 0 36px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 720; letter-spacing: .07em; white-space: nowrap; }
.brand-icon { width: 31px; height: 31px; display: flex; align-items: center; justify-content: center; gap: 3px; background: #bca8ff; border-radius: 9px; }
.brand-icon i { height: 12px; width: 3px; background: #1a142c; border-radius: 3px; transform: skewY(-22deg); }
.brand-icon i:nth-child(2) { height: 17px; }
.brand-icon i:nth-child(3) { height: 8px; }
.access { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #1a1923; font-size: .875rem; white-space: nowrap; }
.access:hover, .secondary:hover { color: var(--text); border-color: #6a5e8a; }
.lock { position: relative; width: 12px; height: 9px; border: 1.5px solid currentColor; border-radius: 2px; margin-top: 4px; }
.lock::before { content: ''; position: absolute; left: 2px; top: -6px; width: 5px; height: 6px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }
.access[data-authorized="true"] { color: #cdbfff; cursor: default; }
.shell { max-width: 1256px; padding: 47px 36px 64px; margin: auto; }
.page-title { margin-bottom: 29px; }
.page-title h1 { font-size: clamp(1.85rem, 4vw, 2.65rem); font-weight: 730; line-height: 1.16; letter-spacing: -.03em; }
.page-title p { color: var(--muted); margin-top: 11px; }
.layout { display: grid; align-items: start; grid-template-columns: minmax(0, 436px) minmax(0, 1fr); gap: 20px; }
.results { min-width: 0; display: grid; gap: 18px; }
.panel { min-width: 0; border-radius: 17px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 14px 48px #07071037; }
.composer { padding: 22px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.model { border: 1px solid #453957; border-radius: 7px; padding: 3px 8px; color: #ded3ff; background: #2b233c; font-size: .8125rem; white-space: nowrap; }
.spark { color: var(--accent); }
#generator { display: grid; gap: 19px; margin-top: 21px; }
.field { min-width: 0; }
.mode-field { border: 0; padding: 0; margin: 0; }
.mode-field legend, .label-row { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 8px; padding: 0; }
.label-row { min-height: 21px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border: 1px solid var(--line); background: var(--field); border-radius: 10px; }
.modes label { text-align: center; cursor: pointer; }
.modes input, .file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.modes span { min-height: 39px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 7px; color: var(--muted); font-size: .875rem; }
.modes input:checked + span { color: #eee8ff; background: #33294a; border-color: #56436e; font-weight: 650; }
.modes input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.text-button { background: transparent; border: 0; color: var(--accent); padding: 0 0 0 8px; font-size: .875rem; min-height: 28px; }
.text-button:hover { text-decoration: underline; }
.prompt-wrap { border: 1px solid var(--line); border-radius: 10px; background: var(--field); padding-bottom: 8px; }
.prompt-wrap:focus-within { border-color: #a18bd6; }
textarea { display: block; resize: vertical; width: 100%; min-height: 115px; padding: 12px 13px 4px; border: 0; background: transparent; outline: 0; }
textarea:focus-visible { outline: 0; }
textarea::placeholder { color: #89889f; }
.count { display: block; margin-right: 12px; color: var(--muted); text-align: right; font-size: .75rem; font-variant-numeric: tabular-nums; }
.muted, .hint { color: var(--muted); }
.small, .hint { font-size: .8125rem; font-weight: 400; }
.hint { margin-top: 8px; }
.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.settings label { color: var(--muted); font-size: .875rem; }
.select-wrap { display: block; position: relative; margin-top: 4px; }
.select-wrap::after { content: ''; position: absolute; right: 12px; top: 16px; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
select { appearance: none; width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); padding: 0 23px 0 10px; font-size: .925rem; }
select:disabled { color: var(--muted); }
.drop { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 65px; border: 1px dashed #535067; border-radius: 9px; color: #ddd4f9; background: #181621; cursor: pointer; font-size: .875rem; }
.drop:hover, .drop:has(+ input:focus-visible) { border-color: var(--accent); background: #222034; }
.drop span { color: var(--accent); font-size: 1.13rem; }
.frame-uploads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.reference-preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.reference-preview:not(:empty) { margin-top: 8px; }
.thumb { height: 66px; display: block; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--field); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 36px; height: 36px; border: 0; border-radius: 6px; background: #14111fe8; font-size: 1.3rem; }
.primary { min-height: 47px; border: 1px solid transparent; border-radius: 9px; padding: 8px 15px; color: #191125; background: var(--primary); font-weight: 760; }
.primary:hover:not(:disabled) { background: #cfbfff; }
.generate { display: flex; align-items: center; justify-content: center; gap: 8px; }
.generate > span:first-child { font-size: 1.15rem; }
.error { color: var(--danger); overflow-wrap: anywhere; font-size: .875rem; }
.form-error { padding: 9px 11px; border-radius: 7px; background: #422331; }
.preview { padding: 17px; scroll-margin-top: 12px; }
.preview .panel-heading { padding: 2px 4px 14px; }
.task-status { display: inline-flex; align-items: center; gap: 6px; color: #ded2ff; font-size: .8125rem; }
.task-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.task-status[data-kind="succeeded"]::before { background: #82d9b3; }
.task-status[data-kind="failed"]::before, .task-status[data-kind="cancelled"]::before { background: var(--danger); }
.stage { width: 100%; min-width: 0; border: 1px solid #2d2b3b; border-radius: 11px; display: grid; place-items: center; aspect-ratio: 16/9; min-height: 252px; position: relative; isolation: isolate; overflow: hidden; background: radial-gradient(ellipse at 50% 46%, #29263b 0, #1a1927 44%, #14141e 76%); }
.stage::before { content: ''; position: absolute; inset: 0; opacity: .48; z-index: -1; background-image: radial-gradient(#504864 1px, transparent 1px); background-size: 23px 23px; mask-image: radial-gradient(ellipse at center, transparent 12%, black 55%); }
.stage:has(video:not([hidden])) { background: #0a090f; }
.stage:has(video:not([hidden])) .viewfinder, .stage:has(video:not([hidden]))::before { display: none; }
.viewfinder { pointer-events: none; position: absolute; inset: 19px; }
.viewfinder i { width: 17px; height: 17px; position: absolute; border: 1px solid #74668e; }
.viewfinder i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.viewfinder i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.viewfinder i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.viewfinder i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.stage-state { max-width: 100%; padding: 25px; text-align: center; }
.stage-icon { display: grid; place-items: center; width: 57px; height: 47px; margin: 0 auto 15px; border: 1px solid #73629b; border-radius: 12px; background: #322a4b; box-shadow: 0 0 32px #a78aee29; }
.stage-icon i { display: block; width: 0; height: 0; border-left: 10px solid #c7b2ff; border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 3px; }
.stage-icon[data-busy="true"] i { width: 17px; height: 17px; margin: 0; border: 2px solid #695984; border-top-color: #ecddff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .stage-icon[data-busy="true"] i { animation: none; } }
.stage-title { font-size: 1.0625rem; font-weight: 650; }
.stage-note { margin-top: 6px; font-size: .875rem; color: var(--muted); overflow-wrap: anywhere; }
video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.preview-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 13px; }
.meta { color: var(--muted); font-size: .8125rem; overflow-wrap: anywhere; }
.secondary { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; background: #242131; color: var(--text); font-size: .875rem; }
.download { color: #dfd3ff; }
.history { padding: 17px 20px; }
.empty-history { margin-top: 12px; color: var(--muted); font-size: .875rem; }
.history-list { padding: 0; margin: 9px 0 0; list-style: none; }
.history-list li + li { border-top: 1px solid var(--line); }
.history-list button { display: grid; width: 100%; min-height: 45px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px; background: transparent; text-align: left; border: 0; border-radius: 6px; font-size: .875rem; padding: 5px 6px; }
.history-list button:hover, .history-list button[aria-current="true"] { background: #2a2538; }
.history-list .history-prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-list .history-state { font-size: .8125rem; color: var(--muted); white-space: nowrap; }
dialog { color: var(--text); width: min(420px, calc(100% - 32px)); padding: 23px; border: 1px solid #484057; border-radius: 16px; background: var(--panel); }
dialog::backdrop { background: #080710b8; }
#login-form { display: grid; gap: 12px; }
#login-form label { font-size: .875rem; }
#login-form input { width: 100%; min-height: 44px; border: 1px solid var(--line); background: var(--field); border-radius: 8px; padding: 0 10px; }
.close { min-width: 42px; min-height: 42px; border: 0; border-radius: 8px; background: transparent; font-size: 1.6rem; color: var(--muted); }
.close:hover { background: #292539; }
@media (max-width: 840px) {
  .shell, .topbar-inner { padding-left: 23px; padding-right: 23px; }
  .layout { grid-template-columns: minmax(0, 385px) minmax(0, 1fr); gap: 13px; }
  .composer { padding: 17px; }
  .preview { padding: 13px; }
  .stage { min-height: 224px; }
}
@media (max-width: 700px) {
  .topbar-inner { min-height: 57px; padding-left: 15px; padding-right: 15px; }
  .shell { padding: 29px 14px 38px; }
  .page-title { margin: 0 2px 22px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .results { gap: 14px; }
  .panel { border-radius: 13px; }
  .stage { min-height: 200px; }
  .viewfinder { inset: 13px; }
  .history { padding: 15px; }
  .modes span { min-height: 43px; }
  select { font-size: 1rem; }
}
