:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --ink: #16130f;
  --muted: #6d665c;
  --line: #e7e1d8;
  --accent: #d9542b;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --warn: #a8670b;
  --err: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --surface: #1e1b17;
    --ink: #f3efe8;
    --muted: #a59d90;
    --line: #2f2a24;
    --accent: #ef6a3f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }

main { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.intro { padding: 32px 0 8px; }
.intro h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); line-height: 1.1; margin: 0 0 10px; letter-spacing: -.02em; }
.intro p { color: var(--muted); margin: 0; max-width: 60ch; }

.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 20px 0;
}
.step h2 { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 0 0 14px; }
.num {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-size: .85rem;
}

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 36px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); outline: none; }
.drop-inner { display: grid; gap: 4px; }
.drop-inner strong { font-size: 1.05rem; }
.drop-inner span, .drop-inner small { color: var(--muted); }

.preview { display: grid; grid-template-columns: 160px 1fr; gap: 16px; align-items: center; margin-top: 16px; }
.checker {
  width: 160px; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center;
  background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}
.checker img { width: 100%; height: 100%; object-fit: contain; }
.status { margin: 0 0 10px; font-size: .95rem; }
.status[data-kind="ok"] { color: var(--ok); }
.status[data-kind="warn"] { color: var(--warn); }
.status[data-kind="error"] { color: var(--err); }
.status[data-kind="busy"]::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.style-chip {
  display: grid; gap: 2px; text-align: left;
  padding: 12px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
  cursor: pointer; font: inherit;
  transition: border-color .15s, transform .1s;
}
.style-chip:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.style-chip[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.style-chip .emoji { font-size: 1.4rem; }
.style-chip .name { font-weight: 650; }
.style-chip .hint { font-size: .8rem; color: var(--muted); }

.options { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
.options label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); min-width: 0; }
.options .grow { flex: 1 1 260px; }
select, input[type="text"] {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input[type="range"] { accent-color: var(--accent); width: 160px; margin-top: 10px; }

.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: 999px;
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); padding: 12px 22px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: .88rem; }

.results-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.results-head h2 { margin: 0; }
.muted { color: var(--muted); font-size: .92rem; }

.grid { --ratio: 1 / 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { margin: 0; display: grid; gap: 8px; }
.frame {
  position: relative; aspect-ratio: var(--ratio); border-radius: 12px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.frame img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.frame .label { position: relative; color: var(--muted); font-size: .9rem; }
.shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--ink) 7%, transparent) 50%, transparent 70%) var(--bg);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.tag {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; padding: 3px 8px; border-radius: 999px;
}
.card figcaption { display: flex; gap: 6px; flex-wrap: wrap; }

dialog#lightbox {
  border: 0; padding: 0; background: transparent; max-width: min(92vw, 900px); max-height: 92vh;
}
dialog#lightbox::backdrop { background: rgba(0,0,0,.8); }
dialog#lightbox img { display: block; max-width: 100%; max-height: 80vh; border-radius: 12px; margin: 0 auto; }
.lb-actions { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.lb-actions .ghost { color: #fff; border-color: rgba(255,255,255,.4); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow); z-index: 20;
}

.foot { max-width: 980px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: .8rem; }

.num { min-width: 26px; width: auto; padding: 0 6px; border-radius: 13px; }
textarea {
  font: inherit; color: var(--ink); background: var(--bg); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical;
}
.field-head { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; font-weight: 600; font-size: .92rem; }
.field-head .muted { font-weight: 400; margin-left: auto; }
.field-head .muted:empty { display: none; }
.field-head .btn { margin-left: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
#describe .actions { align-items: center; }
#desc-out[data-by]::before { content: attr(data-by); display: block; margin-top: 8px; font-size: .8rem; color: var(--muted); }

.update {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; z-index: 21;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  padding: 10px 12px 10px 16px; border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}
.update[hidden] { display: none; }

@media (max-width: 560px) {
  .step { padding: 16px; }
  .preview { grid-template-columns: 110px 1fr; }
  .checker { width: 110px; }
  .grid { gap: 10px; }
  .card figcaption .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
