:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #17202a;
  --muted: #687385;
  --accent: #0f8f86;
  --accent-strong: #0a6f69;
  --danger: #b93535;
  --warning: #a86a00;
  --soft: #edf3f2;
}

* {
  box-sizing: border-box;
}

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

button,
textarea {
  font: inherit;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.workbench,
.results-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary span,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.input-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  padding: 20px 24px 24px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px 24px 0;
}

.tab-button {
  min-height: 36px;
  border-radius: 8px 8px 0 0;
  border-bottom-color: transparent;
  background: #f8fafb;
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.input-panel {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  background: #fbfcfd;
  line-height: 1.6;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 134, 0.14);
}

.side-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}

.stat {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.actions {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.inline-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #fff;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
}

.results-section {
  margin-top: 18px;
}

.hidden {
  display: none;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

#statusText {
  color: var(--muted);
  font-size: 14px;
}

#videoStatusText {
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

th:nth-child(1),
td:nth-child(1) {
  width: 54px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 130px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 150px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 116px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 86px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 92px;
}

.title-cell {
  width: 330px;
  line-height: 1.45;
}

.link-cell {
  width: 280px;
  word-break: break-all;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.badge {
  border-radius: 999px;
}

.badge.success {
  background: #e7f6f3;
  color: #087165;
}

.badge.partial {
  background: #fff3d9;
  color: var(--warning);
}

.badge.failed {
  background: #fdeaea;
  color: var(--danger);
}

.empty-row td {
  height: 96px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 20px 24px 24px;
}

.video-inputs {
  display: grid;
  gap: 12px;
  align-content: start;
}

#videoUrl {
  min-height: 150px;
}

.video-card {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.video-cover {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #eef2f5;
  background-position: center;
  background-size: cover;
  color: var(--muted);
  font-weight: 700;
  overflow: hidden;
}

.video-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.video-meta div {
  display: grid;
  gap: 4px;
}

.video-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.video-meta dd {
  margin: 0;
  line-height: 1.45;
  word-break: break-word;
}

.download-link {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.download-link:hover {
  background: var(--accent-strong);
  color: #fff;
  text-decoration: none;
}

.download-link.disabled {
  pointer-events: none;
  border-color: var(--line);
  background: #eef1f4;
  color: var(--muted);
}

.subtitle-output {
  min-height: 300px;
  border: 0;
  border-radius: 0 0 8px 8px;
  background: #fbfcfd;
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 10px;
  }

  .masthead,
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .input-grid,
  .video-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .side-panel {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 24px;
  }
}
