:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  background: #f2f3f1;
  color: #191b1b;
  font-size: 16px;
  --ink: #191b1b;
  --muted: #707472;
  --line: #d6d9d6;
  --paper: #ffffff;
  --mint: #76e6c2;
  --mint-dark: #136b57;
  --orange: #ff805d;
  --stage: #242726;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f2f3f1; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 76px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--ink); color: var(--mint); font-weight: 800; border-radius: 6px; }
.brand h1 { font-size: 1.05rem; line-height: 1.2; margin: 0; }
.brand p { color: var(--muted); font-size: .75rem; margin: 3px 0 0; }
.local-state { font-size: .78rem; color: #4f5552; display: flex; align-items: center; gap: 7px; }
.local-state i { width: 7px; height: 7px; border-radius: 50%; background: #1ca779; box-shadow: 0 0 0 4px #daf5ec; }

.workspace { min-height: calc(100vh - 76px); display: grid; grid-template-columns: minmax(360px, 440px) 1fr; }
.controls { padding: 30px 32px 36px; background: var(--paper); border-right: 1px solid var(--line); overflow-y: auto; }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-heading span { color: var(--mint-dark); font-size: .72rem; font-weight: 800; border: 1px solid #9ddcca; padding: 3px 5px; border-radius: 3px; }
.section-heading h2 { margin: 0; font-size: .95rem; }
.settings-heading { margin-top: 28px; }

.format-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 17px; }
.format-option { min-height: 52px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #555a57; cursor: pointer; text-align: left; transition: border-color .18s, background .18s, color .18s; }
.format-option strong, .format-option span { display: block; }
.format-option strong { font-size: .875rem; color: var(--ink); }
.format-option span { margin-top: 3px; font-size: .75rem; color: var(--muted); }
.format-option:hover { border-color: #8f9692; }
.format-option.active { border-color: var(--ink); background: var(--ink); }
.format-option.active strong { color: #fff; }
.format-option.active span { color: #b9c1bd; }
.format-option:focus-visible { outline: 3px solid #b8f1df; outline-offset: 2px; }

.dropzone { min-height: 146px; border: 1px dashed #a9afac; border-radius: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; cursor: pointer; background: #fafbfa; transition: border-color .18s, background .18s; }
.dropzone:hover, .dropzone.dragging { border-color: var(--mint-dark); background: #f1fbf7; }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-weight: 700; }
.dropzone strong { font-size: .9rem; }
.dropzone small { color: var(--muted); font-size: .72rem; }

.source-summary { position: relative; padding: 13px 42px 13px 14px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfa; display: grid; gap: 7px; }
.source-summary > div { min-width: 0; display: grid; grid-template-columns: 48px 1fr; align-items: baseline; gap: 8px; }
.source-summary span { color: var(--muted); font-size: .72rem; }
.source-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; font-weight: 600; }
.icon-button { position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; border: 0; background: transparent; color: #656a68; cursor: pointer; font-size: 1.25rem; border-radius: 4px; }
.icon-button:hover { background: #eceeec; color: var(--ink); }

.preset-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 17px; }
.preset { min-height: 34px; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; cursor: pointer; font-size: .76rem; color: #555a57; }
.preset:hover { border-color: #8f9692; }
.preset.active { border-color: var(--ink); background: var(--ink); color: #fff; }

.dimension-grid { display: grid; grid-template-columns: 1fr 34px 1fr; gap: 8px; align-items: end; }
.dimension-grid label > span, .setting-row > label { display: block; font-size: .76rem; font-weight: 700; margin-bottom: 7px; }
.input-unit { position: relative; }
.input-unit input { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 5px; padding: 0 40px 0 11px; outline: none; }
.input-unit input:focus, select:focus { border-color: var(--mint-dark); box-shadow: 0 0 0 3px #dff7ef; }
.input-unit em { position: absolute; right: 11px; top: 12px; color: var(--muted); font-size: .72rem; font-style: normal; }
.ratio-button { width: 34px; height: 42px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--muted); cursor: pointer; font-size: .72rem; }
.ratio-button.active { color: var(--mint-dark); border-color: #8fcfbc; background: #effbf7; }

.setting-row { margin-top: 18px; }
select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 5px; background: #fff; padding: 0 11px; outline: none; }
.compression-row label { display: flex; justify-content: space-between; }
.compression-row output { color: var(--mint-dark); }
input[type="range"] { width: 100%; accent-color: var(--mint-dark); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .7rem; margin-top: 2px; }
.size-note { margin: 17px 0; color: var(--muted); font-size: .73rem; line-height: 1.65; border-left: 2px solid var(--orange); padding-left: 10px; }

.primary-button, .download-button { min-height: 46px; border: 0; border-radius: 6px; background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; display: grid; place-items: center; text-decoration: none; }
.primary-button { width: 100%; }
.primary-button:not(:disabled):hover, .download-button:hover { background: #303433; }
.primary-button:disabled { background: #d7dad8; color: #929794; cursor: not-allowed; }

.stage { min-width: 0; min-height: calc(100vh - 76px); padding: 34px; background: var(--stage); color: #f7f8f7; display: grid; place-items: center; position: relative; }
.stage::before { content: ""; position: absolute; inset: 0; opacity: .08; pointer-events: none; background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px); background-size: 48px 48px; }
.stage-empty, .progress-view, .error-view { position: relative; z-index: 1; text-align: center; width: min(460px, 100%); }
.frame-corners { width: 180px; aspect-ratio: 16/10; display: block; margin: 0 auto 22px; border: 1px solid #4a4f4c; background: #202221; position: relative; }
.frame-corners::before, .frame-corners::after { content: ""; position: absolute; width: 24px; height: 24px; border-color: var(--mint); }
.frame-corners::before { top: -4px; left: -4px; border-top: 2px solid var(--mint); border-left: 2px solid var(--mint); }
.frame-corners::after { right: -4px; bottom: -4px; border-right: 2px solid var(--mint); border-bottom: 2px solid var(--mint); }
.empty-symbol { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); font-size: .75rem; letter-spacing: 0; color: #727976; }
.stage h2 { margin: 0 0 8px; font-size: 1rem; }
.stage p { margin: 0; color: #9ca39f; font-size: .8rem; }

.source-preview, .result-view { position: relative; z-index: 1; width: min(920px, 100%); }
.source-preview video, .result-media { display: block; width: 100%; max-height: calc(100vh - 190px); object-fit: contain; background: #101211; border: 1px solid #414643; }
.source-preview video { aspect-ratio: 16/9; }
.preview-caption, .result-bar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid #3f4441; color: #aab0ad; font-size: .75rem; }
.preview-caption strong { color: #f6f7f6; }

.spinner { width: 48px; height: 48px; margin: 0 auto 22px; border: 3px solid #4a504d; border-top-color: var(--mint); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-label { color: #fff !important; font-size: .92rem !important; margin-bottom: 8px !important; }
.progress-view > strong { font-size: 1.9rem; }
.progress-track { height: 5px; margin: 22px 0 12px; background: #444946; overflow: hidden; border-radius: 4px; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--mint); transition: width .25s; }
.progress-track i.indeterminate { width: 34%; animation: progress-slide 1.1s ease-in-out infinite; }
@keyframes progress-slide { from { transform: translateX(-110%); } to { transform: translateX(300%); } }
.progress-view > span { color: #909793; font-size: .72rem; }
.secondary-button { display: block; min-width: 112px; height: 38px; margin: 22px auto 0; border: 1px solid #59605c; border-radius: 5px; background: transparent; color: #e7e9e8; cursor: pointer; }
.secondary-button:hover { border-color: #9ca39f; }

.result-media { min-height: 240px; display: grid; place-items: center; overflow: hidden; }
.result-media img { display: block; max-width: 100%; max-height: calc(100vh - 215px); object-fit: contain; }
.result-bar > div { display: grid; gap: 4px; }
.result-bar span { color: var(--mint); font-size: .72rem; font-weight: 700; }
.result-bar strong { color: #fff; font-size: .8rem; }
.download-button { min-width: 132px; min-height: 40px; padding: 0 18px; background: var(--mint); color: #10251e; }
.download-button:hover { background: #9af0d5; }
.error-view > span { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 18px; color: #ffb39e; border: 1px solid #9f5541; }

[hidden] { display: none !important; }

@media (max-width: 820px) {
  .topbar { height: 68px; padding: 0 18px; }
  .local-state { font-size: 0; }
  .workspace { grid-template-columns: 1fr; }
  .controls { border-right: 0; padding: 24px 18px 28px; }
  .stage { min-height: 520px; padding: 22px 16px; }
  .source-preview video { max-height: 65vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
