:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --text: #1d1c1a;
  --muted: #6b675f;
  --border: #dcd7cd;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --error-bg: #fde8e4;
  --error-text: #8a1c0b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --panel: #22201d;
    --text: #ece8e1;
    --muted: #a19b90;
    --border: #3a3732;
    --accent: #f97316;
    --accent-text: #1a0d03;
    --error-bg: #3d1a12;
    --error-text: #ffb4a3;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  padding: 24px 16px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header, main, footer, .notice { max-width: 1200px; margin: 0 auto; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.tagline { margin: 4px 0 20px; color: var(--muted); }
footer { margin-top: 24px; color: var(--muted); font-size: 13px; }
a { color: var(--accent); }

main { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.controls { display: flex; flex-direction: column; gap: 14px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 18px 12px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}
.drop.over, .drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop-title { font-weight: 600; }
.drop-hint, .drop-file { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
form label .hint { font-weight: 400; color: var(--muted); }
form label:has(select), form label:has([name=background]) { grid-column: 1 / -1; }
input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
input:invalid { border-color: var(--accent); }

.buttons { display: flex; gap: 8px; grid-column: 1 / -1; }
button {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}
button[type=submit] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: 0.45; cursor: default; }

.status { font-size: 13px; color: var(--muted); min-height: 1.45em; font-variant-numeric: tabular-nums; }
.status.error, .notice.error { color: var(--error-text); }
.notice.error { background: var(--error-bg); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); transition: width 0.1s linear; }

.images { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .images { grid-template-columns: 1fr; } }
figure { margin: 0; min-width: 0; }
figcaption { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.frame {
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.frame img, .frame canvas { display: block; max-width: 100%; height: auto; }
.empty { color: var(--muted); font-size: 13px; }
.frame :not([hidden]) ~ .empty { display: none; }
