:root {
  --background: #f6f7f9;
  --border: #dfe3ea;
  --card: #ffffff;
  --danger: #dc2626;
  --foreground: #202938;
  --muted: #687386;
  --primary: #202938;
  --primary-text: #ffffff;
  --success: #0f9f6e;
  --warning: #b7791f;
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0, var(--background) 220px),
    var(--background);
  color: var(--foreground);
}

button,
input,
textarea {
  font: inherit;
}

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

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.app-header h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.status-pills span,
.job-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #4f5b6d;
  font-size: 12px;
  white-space: nowrap;
}

.token-panel,
.input-panel,
.jobs-panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--foreground);
  outline: none;
}

textarea:focus,
input:focus {
  border-color: #9aa8bb;
  box-shadow: 0 0 0 3px rgb(32 41 56 / 0.08);
}

textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
}

input {
  height: 38px;
  padding: 0 11px;
}

.token-row,
.action-row {
  display: flex;
  gap: 10px;
}

.token-row input {
  flex: 1;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-text);
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  border-color: var(--border);
  background: #fff;
  color: var(--foreground);
}

button.danger {
  border-color: #fecaca;
  background: #fff;
  color: var(--danger);
}

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

.action-row {
  margin-top: 10px;
}

.help-text {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.panel-title h2 {
  margin: 0;
  font-size: 16px;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.jobs-list {
  display: grid;
  gap: 9px;
}

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

.job-card {
  display: grid;
  gap: 8px;
  position: relative;
  padding: 13px 14px;
  border: 1px solid #e8edf4;
  border-radius: 8px;
  background: #fff;
}

.job-card.ready-download {
  border-color: #d8dee8;
  box-shadow: 0 12px 28px rgb(15 23 42 / 0.08);
}

.job-card.ready-download::before {
  position: absolute;
  inset: 12px auto 12px 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: #e11d2e;
  content: "";
}

.job-card.ready-download .job-status {
  border-color: #d8dee8;
  background: #f8fafc;
  color: #202938;
  font-weight: 800;
}

.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.job-id {
  font-weight: 800;
}

.job-url,
.job-message {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.job-message.error {
  color: #a33b22;
}

.progress-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebf0;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #e11d2e, #202938);
  transition: width 180ms ease;
}

.progress-track.indeterminate .progress-fill {
  width: 40%;
  min-width: 90px;
  animation: sweep 1.15s ease-in-out infinite;
}

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

.job-card.ready-download .job-actions {
  justify-content: space-between;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid #eef2f6;
}

.job-card.ready-download .job-actions::before {
  color: #4f5b6d;
  content: "文件已准备好";
  font-size: 13px;
  font-weight: 700;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: auto;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: #202938;
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 18px rgb(15 23 42 / 0.14);
}

.download-link:hover {
  background: #111827;
}

.download-link:focus-visible {
  outline: 3px solid rgb(32 41 56 / 0.18);
  outline-offset: 2px;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  max-width: 360px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #202938;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 14px 28px rgb(15 23 42 / .18);
}

@keyframes sweep {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(260%);
  }
}

@media (max-width: 720px) {
  .app-header,
  .token-row,
  .action-row,
  .job-head {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pills {
    justify-content: flex-start;
  }

  .download-link {
    width: 100%;
  }

  .job-card.ready-download .job-actions::before {
    width: 100%;
  }
}
