:root {
  --page-bg: linear-gradient(to bottom, #4d4d4d, #949597);
  --gold: linear-gradient(135deg, #F1F2F5 0%, #f7f2e6 40%, #d4b980 100%);
  --gold-shadow: 0 6px 6px rgba(184, 173, 147, 0.3);
  --ink: #242833;
  --label: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f9fafb;
  --ok-bg: #d1fae5;
  --ok-ink: #065f46;
  --err-bg: #fee2e2;
  --err-ink: #991b1b;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
input, button { accent-color: #4a4a4a; font-family: inherit; }
.page { max-width: 640px; margin: 0 auto; padding: 40px 20px; }

.hero {
  background: var(--gold);
  color: var(--ink);
  padding: 20px 24px;
  border-radius: 16px;
  margin-bottom: 20px;
}
.hero h1 { margin: 0; font-size: 32px; font-weight: 700; }
.hero p { margin: 10px 0 0; font-size: 16px; opacity: 0.9; }

.card {
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.intro { margin: 0 0 24px; color: var(--muted); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }

.field { margin: 0 0 20px; padding: 0; border: 0; min-width: 0; }
label, legend { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; color: var(--label); }
input[type="file"] {
  display: block; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff;
}
input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  color: var(--muted); background: #f3f4f6; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.grid .hint { min-height: 36px; } /* two lines, so both thumbnails start at the same height */

.thumb {
  margin-top: 12px; width: 50%; aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center;
  background: var(--soft); border: 1px dashed #d1d5db; border-radius: 8px; overflow: hidden;
}
.thumb span { font-size: 12px; color: #9ca3af; padding: 8px; text-align: center; }
.thumb canvas { max-width: 100%; max-height: 100%; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); }
.thumb.loaded { border-style: solid; background: #e9eaee; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .options { grid-template-columns: 1fr; } }
.option {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin: 0; font-weight: 400; cursor: pointer;
  background: var(--soft); border: 1px solid var(--line); border-radius: 8px;
}
.option:has(input:checked) { background: #e5e5e5; border-color: #888; }
.option input { margin: 3px 0 0; flex: none; }
.option strong { display: block; color: var(--label); }
.option small { display: block; color: var(--muted); font-size: 12px; }

button#run {
  width: 100%; margin-top: 10px; padding: 16px;
  font-size: 16px; font-weight: 600; color: var(--ink);
  background: var(--gold); border: 0; border-radius: 8px; cursor: pointer;
  box-shadow: var(--gold-shadow);
}
button#run:disabled { background: #9ca3af; box-shadow: none; cursor: not-allowed; }

.progress { margin-top: 16px; }
.progress-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress-track { background: var(--line); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, #d4b980, #a3c4bc); border-radius: 99px; transition: width 0.3s ease; }

.status { margin-top: 16px; padding: 12px; border-radius: 8px; font-size: 14px; text-align: center; white-space: pre-line; }
.status.ok { background: var(--ok-bg); color: var(--ok-ink); }
.status.err { background: var(--err-bg); color: var(--err-ink); }

.download {
  display: block; margin-top: 12px; padding: 14px; text-align: center;
  font-size: 15px; font-weight: 600; color: var(--ink); text-decoration: none;
  background: var(--gold); border-radius: 8px; box-shadow: var(--gold-shadow);
}

.tips { margin-top: 24px; padding: 20px; background: var(--soft); border-radius: 8px; color: var(--muted); }
.tips h3 { margin: 0 0 10px; font-size: 16px; color: var(--label); }
.tips ul { margin: 0; padding-left: 20px; }

.footer { margin-top: 20px; text-align: center; font-size: 13px; color: #e5e7eb; }
.footer strong { color: #fff; }

[hidden] { display: none !important; }
.footer a { color: inherit; text-decoration: none; }
.footer a:hover strong { text-decoration: underline; }
