:root {
  --canvas: #e9eeec;
  --surface: #f8faf9;
  --surface-2: #eef3f1;
  --ink: #10252b;
  --muted: #66767a;
  --line: #d6dfdc;
  --green: #176854;
  --green-dark: #0c493d;
  --mint: #d9eee6;
  --coral: #d95e49;
  --danger: #8f352b;
  --shadow: 0 18px 50px rgba(16, 37, 43, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 8% 5%, rgba(23,104,84,.08), transparent 26rem), var(--canvas); font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif; }
button, input { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px max(24px, calc((100vw - 1640px) / 2)); color: #fff; background: var(--ink); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: var(--ink); background: #b9e2d3; border-radius: 10px; font: 900 14px/1 ui-monospace, monospace; }
.brand > span:last-child { display: grid; gap: 3px; }
.brand b { font-size: 17px; }
.brand small { color: rgba(255,255,255,.58); font-size: 11px; }
.runtime-state { display: flex; align-items: center; gap: 9px; color: rgba(255,255,255,.68); font-size: 12px; }
.runtime-state i { width: 8px; height: 8px; background: #d6bb66; border-radius: 50%; box-shadow: 0 0 0 5px rgba(214,187,102,.12); }
.runtime-state.is-ready { color: #c5efdf; }
.runtime-state.is-ready i { background: #69c8a3; box-shadow: 0 0 0 5px rgba(105,200,163,.12); }
.runtime-state.is-error { color: #ffc0b5; }
.runtime-state.is-error i { background: var(--coral); }

.workspace { width: min(1640px, calc(100% - 48px)); margin: 0 auto; padding: 32px 0 44px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font: 800 11px/1.2 ui-monospace, monospace; letter-spacing: .16em; }
h1 { max-width: 850px; margin: 0; font-size: clamp(27px, 3vw, 43px); line-height: 1.18; letter-spacing: -.035em; }
.privacy-note { display: flex; align-items: center; gap: 11px; min-width: 330px; padding: 13px 16px; color: var(--green-dark); background: var(--mint); border-radius: 11px; }
.privacy-note > span { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--green); border-radius: 50%; font-weight: 900; }
.privacy-note p { display: grid; gap: 3px; margin: 0; }
.privacy-note small { color: #537068; }

.flow { min-height: 655px; display: grid; grid-template-columns: minmax(350px,1fr) 270px minmax(350px,1fr); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.stage { min-width: 0; display: flex; flex-direction: column; padding: 24px; }
.stage-head { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.step { min-width: 32px; color: var(--green); font: 900 13px/1 ui-monospace, monospace; }
.stage-head h2, .action-stage h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.stage-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.video-frame { position: relative; min-height: 390px; flex: 1; display: grid; place-items: center; overflow: hidden; background: #09161b; border-radius: 12px; }
.video-frame video { width: 100%; height: 100%; max-height: 510px; object-fit: contain; background: #09161b; }
.drop-zone { width: calc(100% - 28px); height: calc(100% - 28px); min-height: 360px; display: grid; place-items: center; align-content: center; gap: 9px; color: #d9e4e1; border: 1px dashed rgba(217,228,225,.34); border-radius: 9px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.drop-zone:hover, .drop-zone.is-dragging { background: rgba(185,226,211,.08); border-color: #b9e2d3; }
.upload-icon { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 5px; color: var(--ink); background: #b9e2d3; border-radius: 50%; font-size: 30px; }
.drop-zone strong { color: #fff; font-size: 20px; }
.drop-zone small { color: rgba(255,255,255,.62); }
.drop-zone em { margin-top: 8px; color: rgba(255,255,255,.4); font: normal 11px/1.2 ui-monospace, monospace; }
.replace-button { position: absolute; top: 12px; right: 12px; z-index: 3; min-height: 38px; padding: 0 13px; color: #fff; background: rgba(9,22,27,.82); border: 1px solid rgba(255,255,255,.24); border-radius: 8px; cursor: pointer; backdrop-filter: blur(8px); }

.media-meta { margin-top: 14px; padding: 14px; background: var(--surface-2); border-radius: 10px; }
.media-meta > div { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.media-meta > div span { color: var(--green); font-size: 11px; font-weight: 800; }
.media-meta > div b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.media-meta dl { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin: 12px 0 0; }
.media-meta dl div { display: grid; gap: 3px; padding: 9px; background: rgba(255,255,255,.7); border-radius: 7px; }
.media-meta dt { color: var(--muted); font-size: 10px; }
.media-meta dd { margin: 0; font: 700 12px/1.2 ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.action-stage { display: flex; flex-direction: column; justify-content: center; padding: 28px 22px; background: var(--surface-2); }
.action-line { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 9px; margin-bottom: 14px; color: var(--green); font: 900 12px/1 ui-monospace, monospace; }
.action-line i { height: 1px; background: var(--line); }
.action-stage h2 { text-align: center; }
.mode-options { display: grid; gap: 7px; margin: 17px 0; }
.mode-options label { cursor: pointer; }
.mode-options input { position: absolute; opacity: 0; pointer-events: none; }
.mode-options span { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 13px; color: #506267; background: rgba(255,255,255,.72); border: 1px solid transparent; border-radius: 9px; }
.mode-options b { font-size: 13px; }
.mode-options small { font-size: 10px; }
.mode-options input:checked + span { color: var(--green-dark); background: #fff; border-color: var(--green); box-shadow: inset 4px 0 0 var(--green); }
.mode-options input:focus-visible + span { outline: 3px solid rgba(23,104,84,.22); outline-offset: 2px; }
.primary-button { min-height: 64px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 14px; color: #fff; background: var(--green); border: 0; border-radius: 10px; box-shadow: 0 9px 20px rgba(23,104,84,.22); cursor: pointer; font-weight: 800; transition: transform .16s ease, background .16s ease, opacity .16s ease; }
.primary-button:not(:disabled):hover { background: var(--green-dark); transform: translateY(-2px); }
.primary-button:disabled { opacity: .38; box-shadow: none; cursor: not-allowed; }
.shield { font-size: 21px; }
.progress-wrap { margin-top: 14px; }
.progress-wrap > div { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.progress-wrap progress { width: 100%; height: 7px; margin-top: 7px; accent-color: var(--green); }
.process-status { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; background: #9aabaa; border-radius: 50%; }
.process-status.is-ready .status-dot, .process-status.is-success .status-dot { background: #2d9b73; }
.process-status.is-working .status-dot { background: var(--coral); animation: pulse 1s ease-in-out infinite; }
.process-status.is-error .status-dot { background: var(--danger); }
@keyframes pulse { 50% { transform: scale(1.8); opacity: .45; } }
.preserve-copy { margin: 4px 0 0; color: #738185; font-size: 10px; line-height: 1.65; text-align: center; }

.result-frame { background: #13242a; }
.result-empty, .processing-visual { display: grid; place-items: center; gap: 8px; color: rgba(255,255,255,.55); text-align: center; }
.result-empty > span { color: rgba(185,226,211,.68); font-size: 56px; }
.result-empty strong, .processing-visual strong { color: rgba(255,255,255,.85); font-size: 17px; }
.result-empty small, .processing-visual small { font-size: 12px; }
.scan-face { position: relative; width: 76px; height: 76px; margin-bottom: 8px; border: 2px solid #b9e2d3; border-radius: 22px; overflow: hidden; }
.scan-face::before, .scan-face::after { content: ""; position: absolute; left: 21px; right: 21px; border: 2px solid #b9e2d3; border-width: 2px 0 0; border-radius: 50%; }
.scan-face::before { top: 24px; height: 18px; }
.scan-face::after { bottom: 15px; height: 15px; }
.scan-face i { position: absolute; left: 5px; right: 5px; height: 2px; top: 8px; background: var(--coral); box-shadow: 0 0 12px var(--coral); animation: scan 1.6s ease-in-out infinite alternate; }
@keyframes scan { to { transform: translateY(56px); } }
.download-button { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 12px; padding: 0 18px; color: #fff; background: var(--green); border-radius: 9px; text-decoration: none; font-weight: 800; }
.download-button:hover { background: var(--green-dark); }
.download-button b { font-size: 22px; }

.support-note { display: flex; align-items: baseline; gap: 14px; margin-top: 17px; padding: 14px 17px; color: var(--muted); background: rgba(255,255,255,.48); border-radius: 10px; font-size: 12px; }
.support-note b { color: var(--ink); white-space: nowrap; }
.support-note p { margin: 0; line-height: 1.65; }
.error-banner { position: fixed; left: 50%; bottom: 24px; z-index: 20; width: min(680px,calc(100% - 32px)); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 15px 17px; color: #fff; background: #762f28; border-radius: 11px; box-shadow: 0 18px 50px rgba(0,0,0,.25); transform: translateX(-50%); }
.error-banner span { color: rgba(255,255,255,.78); font-size: 13px; }
.error-banner button { width: 32px; height: 32px; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; cursor: pointer; }

@media (max-width: 1120px) {
  .flow { grid-template-columns: 1fr; }
  .stage { min-height: 570px; }
  .action-stage { padding: 24px; }
  .mode-options { grid-template-columns: repeat(3,1fr); width: min(720px,100%); margin-inline: auto; }
  .primary-button, .progress-wrap, .process-status, .preserve-copy { width: min(720px,100%); margin-left: auto; margin-right: auto; }
}
@media (max-width: 680px) {
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .brand b { font-size: 15px; }
  .runtime-state { max-width: 130px; font-size: 10px; text-align: right; }
  .workspace { width: calc(100% - 20px); padding-top: 22px; }
  .intro { align-items: stretch; flex-direction: column; }
  .privacy-note { min-width: 0; }
  h1 { font-size: 27px; }
  .flow { border-radius: 13px; }
  .stage { min-height: auto; padding: 16px; }
  .video-frame { min-height: 390px; }
  .drop-zone { min-height: 360px; }
  .mode-options { grid-template-columns: 1fr; }
  .media-meta dl { grid-template-columns: 1fr 1fr; }
  .support-note { align-items: flex-start; flex-direction: column; gap: 4px; }
  .error-banner { grid-template-columns: 1fr auto; }
  .error-banner span { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
