:root {
  --bg: #f4f6f8;
  --paper: #ffffff;
  --ink: #171a1f;
  --muted: #687282;
  --line: #e3e7ee;
  --accent: #16745f;
  --accent-dark: #105746;
  --danger: #d9483d;
  --shadow: 0 22px 70px rgba(18, 28, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(22, 116, 95, 0.08), transparent 380px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.lightbox-open,
body.modal-open {
  overflow: hidden;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(244 246 248 / 92%);
  backdrop-filter: blur(8px);
}

.access-gate[hidden] {
  display: none;
}

.access-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.access-card input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.access-card p:last-child {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.app {
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px);
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3.2vw, 38px);
  line-height: 1.12;
  font-weight: 850;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.2;
}

.server-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(18, 28, 38, 0.08);
}

.server-pill span {
  width: 10px;
  height: 10px;
  background: #c7ced8;
  border-radius: 50%;
}

.history-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 13px;
  color: var(--accent-dark);
  font-weight: 850;
  background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(18, 28, 38, 0.08);
  cursor: pointer;
}

.history-trigger span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.server-pill.online span {
  background: #17a56b;
}

.server-pill.offline span {
  background: var(--danger);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.upload-panel,
.result-panel {
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.dropzone {
  display: grid;
  min-height: 300px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: color-mix(in srgb, var(--accent) 7%, var(--paper));
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 8px;
  cursor: pointer;
}

.dropzone input {
  display: none;
}

.video-preview {
  width: 100%;
  max-height: 300px;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  background: #101418;
  border-radius: 8px;
}

.video-preview[hidden] {
  display: none;
}

.drop-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  color: #fff;
  font-size: 32px;
  line-height: 1;
  background: var(--accent);
  border-radius: 8px;
}

.dropzone strong {
  font-size: 20px;
}

.dropzone em {
  color: var(--muted);
  font-style: normal;
}

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

.field span {
  font-weight: 800;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  line-height: 1.6;
}

textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-color: var(--accent);
}

.primary-button {
  min-height: 50px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.ghost-button {
  min-height: 46px;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 8px;
  cursor: pointer;
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.result-panel {
  overflow: hidden;
}

.history-panel {
  width: min(760px, calc(100vw - 36px));
  max-height: min(720px, calc(100vh - 72px));
  overflow: hidden;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgb(12 18 24 / 56%);
}

.history-modal[hidden] {
  display: none;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-close {
  width: 38px;
  height: 38px;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.history-head span {
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 0;
  max-height: calc(min(720px, 100vh - 72px) - 92px);
  overflow: auto;
}

.history-empty {
  margin: 0;
  padding: 22px 24px;
  color: var(--muted);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 24px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.history-item:hover {
  background: #f8fafb;
}

.history-item.selected {
  background: color-mix(in srgb, var(--accent) 9%, var(--paper));
  box-shadow: inset 4px 0 0 var(--accent);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item strong,
.history-item em {
  display: block;
}

.history-item strong {
  color: var(--ink);
  font-size: 15px;
}

.history-item em {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.history-status {
  flex: 0 0 auto;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.history-status.completed {
  color: var(--accent-dark);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.history-status.running {
  color: #9a5b00;
  border-color: #e9c46a;
}

.history-status.failed,
.history-status.cancelled {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.result-head span {
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.steps {
  display: grid;
  gap: 0;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.steps[hidden] {
  display: none;
}

.frame-strip {
  padding: 18px 24px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.frame-strip[hidden] {
  display: none;
}

.frame-strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.frame-strip-head strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
}

.frame-strip-head span {
  color: var(--muted);
  font-size: 13px;
}

.frame-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
}

.frame-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  aspect-ratio: 16 / 10;
  background: #101828;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: zoom-in;
}

.frame-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.frame-card span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  background: rgb(16 24 40 / 72%);
  border-radius: 999px;
}

.frame-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent);
  outline-offset: 2px;
}

.frame-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgb(12 18 24 / 82%);
}

.frame-lightbox[hidden] {
  display: none;
}

.frame-lightbox figure {
  width: min(980px, 100%);
  margin: 0;
}

.frame-lightbox img {
  width: 100%;
  max-height: 82vh;
  display: block;
  object-fit: contain;
  background: #05070a;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 36%);
}

.frame-lightbox figcaption {
  margin-top: 12px;
  color: #fff;
  font-size: 14px;
  text-align: center;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 20px;
  width: 42px;
  height: 42px;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  background: rgb(255 255 255 / 12%);
  border: 1px solid rgb(255 255 255 / 26%);
  border-radius: 8px;
  cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgb(255 255 255 / 20%);
  outline: none;
}

.step-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  position: relative;
  padding: 0 0 18px;
  color: var(--muted);
}

.step-item:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 20px;
  left: 8px;
  width: 2px;
  height: calc(100% - 20px);
  background: var(--line);
}

.step-item > span {
  z-index: 1;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  background: #d0d5dd;
  border: 3px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

.step-item strong,
.step-item em {
  display: block;
}

.step-item strong {
  color: var(--ink);
}

.step-item em {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.step-item.done > span {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.step-item.active > span {
  background: #fff;
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  animation: spin 800ms linear infinite;
}

.step-item.active strong {
  color: var(--accent-dark);
}

.step-item.failed > span {
  background: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.result-body {
  min-height: 560px;
  max-height: calc(100vh - 190px);
  padding: 24px;
  overflow: auto;
  color: #27313d;
  font-size: 15px;
  line-height: 1.78;
  white-space: normal;
}

.result-body p {
  margin: 0 0 14px;
}

.result-body h3 {
  margin: 28px 0 12px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.35;
}

.result-body .review-section-title {
  padding-bottom: 8px;
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 30%, var(--line));
}

.result-body h4 {
  margin: 18px 0 8px;
  font-size: 18px;
  color: var(--ink);
}

.result-body ul {
  margin: 0 0 18px;
  padding-left: 22px;
}

.result-body li {
  margin: 0 0 10px;
  padding-left: 2px;
}

.result-body strong {
  color: var(--ink);
  font-weight: 850;
}

.result-body hr {
  display: none;
}

.result-body table {
  width: 100%;
  margin: 12px 0 22px;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.55;
}

.result-body th,
.result-body td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--line);
}

.result-body th {
  color: var(--ink);
  font-weight: 850;
  background: #f8fafb;
}

.waiting-copy {
  display: grid;
  align-content: center;
  min-height: 220px;
  color: var(--muted);
}

.waiting-copy strong {
  color: var(--ink);
  font-size: 22px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .topbar,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .tool-grid {
    display: grid;
  }

  .dropzone {
    min-height: 240px;
  }

  .result-body {
    min-height: 420px;
    max-height: none;
  }
}
