:root {
  --bg: #0f1210;
  --panel: #171c19;
  --panel-2: #202720;
  --panel-3: #101411;
  --line: #334239;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #edf5ee;
  --muted: #93a297;
  --faint: #66736a;
  --accent: #ffd166;
  --accent-2: #38d8b8;
  --danger: #ff6b6b;
  --ok: #63e6be;
  --shadow: 0 28px 92px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(56, 216, 184, 0.09), transparent 30%),
    linear-gradient(180deg, #121613 0%, var(--bg) 54%, #0a0c0b 100%);
  color: var(--text);
  font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1540px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.brand,
.top-actions,
.section-title,
.field-head,
.results-toolbar,
.card-top,
.dialog-head,
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  justify-content: flex-start;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(56, 216, 184, 0.55);
  background: #10211d;
  color: var(--accent-2);
  border-radius: 8px;
  font-weight: 950;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(23, 28, 25, 0.86);
  color: var(--muted);
  padding: 0 12px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(99, 230, 190, 0.55);
}

.pill.bad {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.55);
}

.link-pill {
  color: var(--accent);
}

.workbench {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 18px;
  align-items: start;
  padding-top: 18px;
}

.control-panel,
.viewer,
.detail-dialog {
  background: rgba(23, 28, 25, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.panel-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(16, 20, 17, 0.62);
}

.section-title span {
  color: var(--accent);
  font-weight: 950;
  font-size: 13px;
}

.section-title h2 {
  margin-right: auto;
  font-size: 16px;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 170px;
  padding: 18px;
  border: 1px dashed rgba(56, 216, 184, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(56, 216, 184, 0.1), transparent 45%),
    rgba(32, 39, 32, 0.72);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(255, 209, 102, 0.12);
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 209, 102, 0.55);
  border-radius: 999px;
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.drop-title {
  font-size: 18px;
  font-weight: 900;
}

.drop-subtitle {
  color: var(--muted);
  max-width: 280px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.input-actions,
.compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ghost,
.primary,
.icon-button {
  border-radius: 8px;
  cursor: pointer;
}

.ghost {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.ghost:disabled {
  cursor: not-allowed;
  color: var(--faint);
  border-color: var(--line-soft);
  opacity: 0.62;
}

.ghost:not(:disabled):hover,
.method-option:hover,
.result-card:hover {
  border-color: rgba(255, 209, 102, 0.62);
}

.primary {
  min-height: 52px;
  border: 0;
  background: linear-gradient(90deg, var(--accent), #ffad5c);
  color: #17140d;
  font-weight: 950;
}

.primary:disabled {
  cursor: wait;
  opacity: 0.65;
  filter: grayscale(0.45);
}

.compare-entry {
  min-height: 46px;
  border-color: rgba(56, 216, 184, 0.5);
  color: var(--accent-2);
  font-weight: 900;
}

.compare-entry:disabled {
  border-color: var(--line);
  color: var(--faint);
}

.method-grid {
  display: grid;
  gap: 8px;
}

.method-option {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  text-align: left;
  cursor: pointer;
}

.method-option.is-active {
  border-color: rgba(56, 216, 184, 0.78);
  background: #13231f;
}

.method-option strong {
  color: var(--text);
  font-size: 14px;
}

.method-option span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

output {
  color: var(--accent);
  font-weight: 900;
}

input[type="number"] {
  width: 100%;
  min-height: 42px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.viewer {
  min-height: 720px;
  padding: 16px;
}

.viewer-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.workspace-pane {
  min-height: 690px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 17, 0.58);
}

.pane-head {
  min-height: 48px;
  margin-bottom: 14px;
}

.viewer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.media-button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--accent);
}

.job-meta {
  color: var(--muted);
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 590px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #080a09;
  background-size: 28px 28px;
  overflow: hidden;
}

.result-video-stage {
  display: grid;
  place-items: center;
  min-height: 590px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(56, 216, 184, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(56, 216, 184, 0.035) 1px, transparent 1px),
    #080a09;
  background-size: 28px 28px;
  overflow: hidden;
}

.preview-empty,
.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

#videoPreview,
#imagePreview,
#resultVideoPreview {
  display: block;
  width: 100%;
  max-height: 590px;
  object-fit: contain;
  background: #050605;
}

.progress-wrap {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
}

.progress-line {
  height: 8px;
  border-radius: 999px;
  background: #2a332d;
  overflow: hidden;
}

.progress-line span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 320ms ease;
}

.progress-wrap p {
  margin: 8px 0 0;
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.summary-strip div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: var(--panel-3);
}

.summary-strip span,
.results-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.summary-strip strong {
  color: var(--text);
  font-size: 18px;
}

.empty {
  min-height: 590px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 17, 0.62);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  max-height: 520px;
  overflow: auto;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111512;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.result-card:hover {
  transform: translateY(-1px);
}

.result-card.is-selected {
  border-color: rgba(56, 216, 184, 0.88);
  box-shadow: inset 0 0 0 1px rgba(56, 216, 184, 0.4);
}

.card-top {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.method {
  color: var(--accent);
  font-weight: 950;
}

.frame-index {
  color: var(--muted);
  font-size: 12px;
}

figure {
  margin: 0;
  background: #050605;
}

img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

figcaption {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.metrics,
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border-top: 1px solid var(--line);
}

.metrics div,
.detail-metrics div {
  padding: 10px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child,
.detail-metrics div:last-child {
  border-right: 0;
}

dt {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

dd {
  margin: 0;
  font-weight: 900;
}

.detail-dialog {
  width: min(1120px, calc(100vw - 36px));
  color: var(--text);
  padding: 0;
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 26px;
  line-height: 1;
}

.detail-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
}

.detail-images img {
  aspect-ratio: 4 / 3;
}

.source-dialog {
  width: min(1180px, calc(100vw - 36px));
}

.frame-browser {
  min-height: auto;
  margin-top: 14px;
}

.frame-browser-body {
  display: grid;
  gap: 12px;
}

.frame-browser .summary-strip {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 0;
}

.frame-browser .empty {
  min-height: 170px;
}

.compare-dialog {
  width: min(1320px, calc(100vw - 36px));
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  max-height: min(72vh, 760px);
  overflow: auto;
  padding: 16px;
}

.compare-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111512;
  overflow: hidden;
}

.compare-card img {
  aspect-ratio: 4 / 3;
}

.compare-loading {
  min-height: 220px;
  display: grid;
  place-items: center;
  grid-column: 1 / -1;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 17, 0.72);
  text-align: center;
  padding: 24px;
}

.source-stage {
  display: grid;
  place-items: center;
  min-height: 520px;
  background: #050605;
}

#sourceVideo,
#sourceImage {
  display: block;
  width: 100%;
  max-height: min(72vh, 720px);
  object-fit: contain;
  background: #050605;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
  }

  .topbar,
  .workbench {
    display: grid;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .viewer-actions {
    justify-content: flex-start;
  }

  .summary-strip,
  .detail-images {
    grid-template-columns: 1fr;
  }

  .frame-browser .summary-strip {
    grid-template-columns: 1fr;
  }

  .viewer-split {
    grid-template-columns: 1fr;
  }

  .workspace-pane {
    min-height: auto;
  }

  .preview-stage,
  .result-video-stage,
  .empty {
    min-height: 320px;
  }
}
