:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #151815;
  --muted: #66716b;
  --line: #dfe4df;
  --teal: #177e72;
  --teal-dark: #0f5e56;
  --amber: #c97921;
  --red: #b73e3e;
  --shadow: 0 18px 50px rgba(21, 24, 21, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 64px);
  background: rgba(246, 247, 244, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 17px;
  font-weight: 740;
}

.brand-symbol {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 15px;
}

.topbar-actions {
  color: var(--muted);
  font-size: 14px;
}

.service-state {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--teal-dark);
  font-weight: 650;
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 18px auto 42px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(520px, 1.22fr);
  gap: 18px;
  align-items: start;
}

.workspace > *,
.result-preview > *,
.right-rail {
  min-width: 0;
}

.right-rail {
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel,
.status-panel,
.recent-panel {
  padding: 22px;
}

.status-panel,
.recent-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.compact-heading {
  margin-bottom: 12px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
  font-weight: 780;
}

h2 {
  font-size: 18px;
  font-weight: 760;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

label {
  display: block;
  margin: 16px 0 8px;
  color: #323832;
  font-size: 13px;
  font-weight: 720;
}

textarea,
input[type="url"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  min-height: 150px;
  padding: 14px 15px;
  resize: vertical;
}

input[type="url"],
input[type="password"] {
  height: 44px;
  padding: 0 14px;
}

textarea:focus,
input:focus {
  border-color: rgba(23, 126, 114, 0.55);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(23, 126, 114, 0.11);
}

.dropzone {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 18px;
  border: 1px dashed #b8c3bb;
  border-radius: 8px;
  background: #fbfcfa;
  cursor: pointer;
}

.dropzone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dropzone-title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 760;
}

.dropzone-meta {
  color: var(--muted);
  font-size: 13px;
}

button,
.downloads a {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 18px;
  background: var(--teal);
  color: #ffffff;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.step-dot {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: #e7ebe6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.timeline li.is-done .step-dot {
  background: rgba(23, 126, 114, 0.14);
  color: var(--teal-dark);
}

.timeline li.is-active {
  border-color: rgba(23, 126, 114, 0.45);
  background: rgba(23, 126, 114, 0.04);
}

.timeline li.is-active .step-dot {
  background: var(--teal);
  color: #ffffff;
}

.step-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 760;
}

.step-key {
  display: none;
}

.job-message {
  min-height: 0;
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  background: #fff8ee;
  color: #5a4227;
  font-size: 13px;
  line-height: 1.55;
}

.job-message.error {
  border-left-color: var(--red);
  background: #fff2f2;
  color: #6d2929;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.downloads a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(23, 126, 114, 0.24);
  background: rgba(23, 126, 114, 0.08);
  color: var(--teal-dark);
  font-size: 13px;
}

.result-preview {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.05fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.preview-media,
.preview-text {
  min-height: 520px;
}

.preview-media {
  padding: 16px;
}

.preview-text {
  padding: 16px;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.preview-heading h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 780;
}

.preview-heading a {
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 720;
}

.preview-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.preview-tabs button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 0;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
}

.preview-tabs button.active {
  background: var(--teal);
  color: #ffffff;
}

.preview-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

#video-preview {
  width: 100%;
  max-height: 520px;
  border-radius: 8px;
  background: #111411;
}

#preview-content {
  height: 430px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #242b25;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.75;
}

.empty-note {
  margin: 0;
  padding: 16px;
  border: 1px dashed #b8c3bb;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.recent-panel {
  margin-top: 0;
}

.table-wrap {
  max-height: 260px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 0;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

td {
  color: #2e352e;
}

th,
td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th:nth-child(3),
td:nth-child(3) {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr[data-job-id] {
  cursor: pointer;
}

tr[data-job-id]:hover {
  background: #fbfcfa;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef1ed;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.status-chip.completed {
  background: rgba(23, 126, 114, 0.12);
  color: var(--teal-dark);
}

.status-chip.failed {
  background: #ffe9e9;
  color: var(--red);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  margin-bottom: 24px;
  color: var(--teal-dark);
  font-size: 15px;
  font-weight: 780;
}

.login-form button {
  width: 100%;
  margin-top: 18px;
  background: var(--ink);
  color: #ffffff;
}

.form-error {
  margin: 12px 0 0;
  color: var(--red);
  font-size: 14px;
}

@media (max-width: 860px) {
  .workspace,
  .result-preview {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .preview-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
