:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1b2321;
  --muted: #5f6b68;
  --line: #dde3e1;
  --accent: #0f7a6c;
  --accent-text: #ffffff;
  --warn-bg: #fff6e0;
  --warn-text: #7a5300;
  --error: #b3261e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --card: #1b2120;
    --text: #e8eeec;
    --muted: #9aa7a3;
    --line: #2e3836;
    --accent: #2bb3a0;
    --accent-text: #06201c;
    --warn-bg: #3a2f12;
    --warn-text: #f3d68a;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent); color: var(--accent-text);
}
.top h1 { font-size: 1.15rem; margin: 0; }
main { max-width: 640px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: .85rem;
}
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; justify-content: center; margin-top: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 1.4rem; cursor: pointer; padding: 4px 8px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.grid:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.thumb .del {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 1rem;
}
.thumb .badge {
  position: absolute; left: 4px; bottom: 4px; padding: 2px 6px; border-radius: 6px;
  background: rgba(0,0,0,.6); color: #fff; font-size: .75rem;
}
.thumb.busy::after {
  content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.35);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .2; } }

.field { display: block; margin-top: 12px; }
.field > span { display: flex; align-items: center; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.field textarea { resize: vertical; }
.copy { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }

.status { min-height: 1.2em; margin: 8px 0 0; font-size: .9rem; color: var(--muted); }
.status.error { color: var(--error); }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: 10px 12px; border-radius: 10px; font-size: .9rem; }

dialog { border: 0; border-radius: 16px; padding: 0; background: var(--card); color: var(--text); width: min(92vw, 520px); }
dialog::backdrop { background: rgba(0,0,0,.5); }
.dlg { padding: 16px; }
.compare img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; display: block; }
code { font-size: .85em; }
