:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --text: #1e1f1c;
  --muted: #62645e;
  --line: #dedbd3;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --accent-soft: #e3ece8;
  --danger: #a3372b;
  --warn-bg: #fbf3dc;
  --warn-text: #6b5512;
  --ok-bg: #e3f1e6;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171816;
    --card: #222420;
    --text: #ecebe6;
    --muted: #a3a59d;
    --line: #3a3c36;
    --accent: #79b39f;
    --accent-text: #10201a;
    --accent-soft: #263630;
    --danger: #e57a6c;
    --warn-bg: #3a3220;
    --warn-text: #f0dca0;
    --ok-bg: #22372a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 960px; margin: 0 auto; padding: 14px 16px;
}
.top h1 { font-size: 1.25rem; margin: 0; letter-spacing: -0.01em; }
.who { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 0.95rem; }

main { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card.narrow { max-width: 380px; margin: 40px auto; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 22px 0 8px; }
p { margin: 0 0 10px; }
.intro { margin-bottom: 6px; }
.note { color: var(--muted); font-size: 0.9rem; }
.usage { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; }

label { display: block; }
input[type=text], input[type=password], input:not([type]), input[type=number] {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
form > label { margin-bottom: 12px; }
input:focus-visible, button:focus-visible, a:focus-visible, .slot:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; font: inherit; font-size: 0.95rem;
  color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; text-decoration: none;
}
button:hover:not(:disabled), .button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.primary:hover:not(:disabled) { border-color: var(--accent); filter: brightness(1.06); }
.danger { color: var(--danger); }
.link { background: none; border: 0; padding: 4px; min-height: 0; color: var(--accent); text-decoration: underline; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.error { background: var(--warn-bg); color: var(--warn-text); }
.flash.ok { background: var(--ok-bg); }

.tips { margin: 0 0 14px; padding-left: 20px; color: var(--muted); font-size: 0.92rem; }
.tips li { margin-bottom: 2px; }

.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.slot {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 4px; min-height: 190px; padding: 12px 8px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--bg);
}
.slot:hover { border-color: var(--accent); }
.slot.filled { border-style: solid; border-color: var(--accent); }
.slot svg { width: 70px; height: 70px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.slot svg circle { fill: var(--muted); stroke: none; }
.slot.filled svg { display: none; }
.slot img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; }
.slot-title { font-weight: 600; font-size: 0.95rem; }
.slot-title em { display: block; font-style: normal; font-weight: 400; font-size: 0.8rem; color: var(--accent); }
.slot-hint { font-size: 0.8rem; color: var(--muted); }
.slot input[type=file] { width: 100%; font-size: 0.75rem; margin-top: auto; color: var(--muted); }

.check { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 4px; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.notice { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 0.92rem; }
.notice p { margin: 0; }
#upload-btn { margin-top: 12px; }

.job-head { display: flex; justify-content: space-between; align-items: center; }
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 4px 0 10px; counter-reset: s; }
.steps li {
  counter-increment: s; padding: 5px 10px 5px 8px; border-radius: 999px; font-size: 0.85rem;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.steps li::before { content: counter(s) ". "; }
.steps li.done { color: var(--accent); border-color: var(--accent); }
.steps li.done::before { content: "✓ "; }
.steps li.current { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.steps li.failed { color: var(--danger); border-color: var(--danger); }
.stage { color: var(--muted); min-height: 1.5em; }
.error { color: var(--danger); font-weight: 600; }
.warnings { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 12px 10px 30px; font-size: 0.92rem; }

.prepared { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.prepared figure { margin: 0; text-align: center; font-size: 0.85rem; color: var(--muted); }
.prepared img {
  width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 8px; border: 1px solid var(--line);
  background-color: #ececec;
  background-image: linear-gradient(45deg, #dadada 25%, transparent 25%, transparent 75%, #dadada 75%),
                    linear-gradient(45deg, #dadada 25%, transparent 25%, transparent 75%, #dadada 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}

.settings fieldset { border: 0; padding: 0; margin: 16px 0 0; }
.settings legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.settings fieldset > label { display: inline-block; width: calc(50% - 6px); margin-right: 8px; vertical-align: top; }
.settings fieldset > label:last-child { margin-right: 0; }
.radios { display: flex; flex-wrap: wrap; gap: 8px; }
.radios label {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; flex: 1 1 200px;
}
.radios label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radios label.disabled { opacity: 0.6; cursor: default; }
.radios small { flex-basis: 100%; color: var(--muted); font-size: 0.8rem; }
.cost { margin: 16px 0 10px; font-size: 1.05rem; }

.viewer-wrap { background: var(--bg); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
model-viewer { width: 100%; height: 420px; background: transparent; --poster-color: transparent; }
#preview-png { display: block; width: 100%; max-height: 420px; object-fit: contain; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 14px 0 0; font-size: 0.95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.adjust { display: grid; gap: 8px; }
.adjust-row { display: grid; grid-template-columns: 130px 1fr 1fr; gap: 8px; align-items: center; }
.adjust-row span { color: var(--muted); font-size: 0.92rem; }
.adjust-summary { font-size: 0.9rem; color: var(--muted); min-height: 1.4em; margin: 4px 0 0; }
.adjust-actions { display: flex; gap: 10px; align-items: center; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.job-actions { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }

.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history img, .thumb-empty { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--bg); flex: none; }
.h-info { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 0.92rem; }
.h-info span { color: var(--muted); }
.h-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.h-actions button, .h-actions .button { min-height: 34px; padding: 4px 10px; font-size: 0.85rem; }

@media (max-width: 680px) {
  .slots, .prepared { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 14px; }
  model-viewer { height: 340px; }
  .adjust-row { grid-template-columns: 1fr 1fr; }
  .adjust-row span { grid-column: 1 / -1; }
  .settings fieldset > label { width: 100%; margin-right: 0; margin-bottom: 8px; }
  .history li { flex-wrap: wrap; }
  .h-actions { width: 100%; justify-content: flex-start; }
}
