:root {
  --paper: #fff8e7;
  --cream: #fff2c4;
  --ink: #1f1a14;
  --soft-ink: #5d554d;
  --line: rgba(31, 26, 20, 0.12);
  --accent: #ffcf33;
  --accent-deep: #f2b300;
  --ok: #1f7a4d;
  --warn: #9d6500;
  --error: #b42318;
  --card: rgba(255, 255, 255, 0.82);
  --shadow: 0 24px 60px rgba(56, 42, 0, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 214, 72, 0.6), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 179, 0, 0.24), transparent 20%),
    linear-gradient(180deg, #ffe45b 0%, #fff8e7 34%, #fffdf7 100%);
}

.page {
  width: min(760px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  padding: 8px 2px 20px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft-ink);
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 54px);
  line-height: 1.02;
}

.intro {
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--soft-ink);
}

.panel {
  backdrop-filter: blur(16px);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.label {
  font-size: 14px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  font: inherit;
  line-height: 1.6;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
}

textarea:focus {
  outline: 2px solid rgba(255, 207, 51, 0.55);
  border-color: rgba(255, 207, 51, 0.9);
}

button,
.download-btn {
  border: 0;
  border-radius: 999px;
  min-height: 54px;
  padding: 0 22px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button {
  background: linear-gradient(135deg, var(--ink), #3c3127);
  color: white;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.status-card,
.result-card {
  margin-top: 18px;
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
}

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

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(31, 26, 20, 0.08);
}

.badge.queued {
  background: rgba(157, 101, 0, 0.12);
  color: var(--warn);
}

.badge.processing {
  background: rgba(255, 207, 51, 0.22);
  color: #7b5c00;
}

.badge.completed {
  background: rgba(31, 122, 77, 0.12);
  color: var(--ok);
}

.badge.failed {
  background: rgba(180, 35, 24, 0.12);
  color: var(--error);
}

.status-detail {
  margin-top: 12px;
  color: var(--soft-ink);
  line-height: 1.6;
}

.result-head {
  display: grid;
  gap: 6px;
}

.preview-frame {
  margin-bottom: 16px;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, rgba(255, 214, 72, 0.28), rgba(31, 26, 20, 0.08));
}

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

.history-preview img.broken {
  opacity: 0.18;
}

.result-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft-ink);
}

.result-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.result-grid {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.result-grid dt {
  font-size: 12px;
  color: var(--soft-ink);
  margin-bottom: 6px;
}

.result-grid dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-all;
}

.result-grid a {
  color: var(--ink);
}

.download-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--ink);
}

.history-section {
  margin-top: 18px;
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
}

.history-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.history-head h2 {
  margin: 0;
  font-size: 24px;
}

.ghost-btn {
  min-height: 42px;
  padding: 0 16px;
  background: rgba(31, 26, 20, 0.06);
  color: var(--ink);
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-empty {
  padding: 16px 14px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  color: var(--soft-ink);
  background: rgba(255, 255, 255, 0.62);
  line-height: 1.6;
}

.history-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.history-card.is-live {
  border-style: dashed;
  background: rgba(255, 252, 237, 0.95);
}

.history-card.is-failed {
  border-color: rgba(180, 35, 24, 0.28);
}

.history-preview {
  overflow: hidden;
  border-radius: 14px;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, rgba(255, 214, 72, 0.28), rgba(31, 26, 20, 0.08));
}

.history-preview-placeholder {
  display: grid;
  place-items: center;
}

.history-preview-placeholder span {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(31, 26, 20, 0.08);
  color: var(--ink);
}

.history-content {
  display: grid;
  gap: 8px;
}

.history-content h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--soft-ink);
}

.history-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  background: rgba(31, 26, 20, 0.08);
}

.history-pill.queued {
  background: rgba(157, 101, 0, 0.12);
  color: var(--warn);
}

.history-pill.processing {
  background: rgba(255, 207, 51, 0.22);
  color: #7b5c00;
}

.history-pill.completed {
  background: rgba(31, 122, 77, 0.12);
  color: var(--ok);
}

.history-pill.failed {
  background: rgba(180, 35, 24, 0.12);
  color: var(--error);
}

.history-message {
  margin: 0;
  color: var(--soft-ink);
  line-height: 1.6;
}

.history-link {
  color: var(--soft-ink);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
}

.history-download {
  margin-top: 4px;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255, 207, 51, 0.96), rgba(242, 179, 0, 0.92));
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.history-actions .history-download {
  margin-top: 0;
  flex: 1 1 180px;
}

.history-delete {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 999px;
  background: rgba(180, 35, 24, 0.06);
  color: var(--error);
}

.history-delete:disabled {
  opacity: 0.6;
  cursor: wait;
}

.hidden {
  display: none;
}

@media (min-width: 720px) {
  .page {
    padding-top: 42px;
  }

  .panel {
    padding: 26px;
  }

  .result-grid {
    grid-template-columns: 1fr 180px;
    align-items: start;
  }

  .history-card {
    grid-template-columns: 220px 1fr;
    align-items: start;
  }
}
