:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --text: #19212a;
  --muted: #627181;
  --line: #d9e0e7;
  --accent: #116b5f;
  --accent-dark: #0b4f45;
  --warning: #946200;
  --done: #18603a;
  --processing: #1e5f9f;
  --shadow: 0 10px 30px rgba(23, 37, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

.form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 11px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(17, 107, 95, 0.2);
  border-color: var(--accent);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  white-space: nowrap;
}

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

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

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover {
  background: var(--surface-muted);
}

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

.main-view {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.topbar h1 {
  font-size: 28px;
  line-height: 1.25;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

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

.panel {
  padding: 18px;
}

.panel h2,
.task-header h2 {
  font-size: 18px;
  line-height: 1.3;
  margin-bottom: 14px;
}

.file-hint {
  color: var(--muted);
  font-size: 13px;
}

.upload-progress {
  display: grid;
  gap: 7px;
}

.upload-progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.upload-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms ease;
}

.upload-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.task-section {
  overflow: hidden;
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 18px 0;
}

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

.task-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

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

.task-table th {
  color: var(--muted);
  font-weight: 600;
  background: #fbfcfd;
}

.task-table td:nth-child(2) {
  max-width: 340px;
  word-break: break-all;
}

.task-code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  color: #315463;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  background: var(--surface-muted);
}

.status-pending {
  color: var(--warning);
}

.status-processing {
  color: var(--processing);
}

.status-completed {
  color: var(--done);
}

.status-failed {
  color: #a33a2a;
}

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

.error-message {
  max-width: 420px;
  margin-top: 5px;
  color: #a33a2a;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.empty-state {
  display: none;
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
}

.empty-state.is-visible {
  display: block;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  max-width: min(520px, calc(100% - 32px));
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  background: #17212b;
  color: #ffffff;
  border-radius: 6px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 20, 28, 0.56);
}

.preview-modal {
  width: min(820px, 100%);
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.preview-header h2 {
  font-size: 18px;
  line-height: 1.3;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-muted);
}

.preview-video {
  width: 100%;
  max-height: min(62vh, 560px);
  background: #000000;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 760px) {
  .main-view {
    padding: 16px;
  }

  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .modal-backdrop {
    padding: 10px;
    align-items: end;
  }

  .preview-modal {
    max-height: calc(100vh - 20px);
  }

  .preview-video {
    max-height: 58vh;
  }

  .preview-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
