:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --ink: #161616;
  --muted: #6b6760;
  --line: #e2ded6;
  --accent: #111111;
  --accent-ink: #ffffff;
  --warn: #9a5b00;
  --radius: 14px;
  font-family: "Heebo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1d1d1d;
    --ink: #f1efea;
    --muted: #a39f97;
    --line: #333;
    --accent: #f1efea;
    --accent-ink: #111;
    --warn: #e0a64a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand img { width: 36px; height: 36px; border-radius: 50%; background: #fff; }
.icon-btn { background: none; border: 0; font-size: 24px; padding: 6px 10px; cursor: pointer; }

.steps { display: flex; gap: 4px; padding: 10px 16px; overflow-x: auto; }
.steps button {
  flex: 1; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 8px; font-size: 14px; color: var(--muted); white-space: nowrap;
}
.steps button b { margin-inline-end: 4px; }
.steps button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

main { max-width: 560px; margin: 0 auto; padding: 0 16px 32px; }
.screen { display: none; }
.screen.on { display: block; }
h3 { font-size: 15px; margin: 22px 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.warn { color: var(--warn); font-size: 14px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 48px 16px; margin-top: 8px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface);
}
.drop .big { font-size: 44px; }
.drop strong { font-size: 19px; }
.drop small { color: var(--muted); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  flex: 1 1 auto; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 10px 8px; cursor: pointer;
}
.seg button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 700; }

.stage {
  position: relative; margin-top: 8px; border-radius: var(--radius); overflow: hidden;
  background: repeating-conic-gradient(#ddd 0 25%, #eee 0 50%) 50% / 20px 20px;
}
.stage canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: grab; }
.stage .hint {
  position: absolute; bottom: 8px; inset-inline-start: 8px; font-size: 12px;
  background: rgba(0,0,0,.55); color: #fff; padding: 3px 8px; border-radius: 6px; pointer-events: none;
}

.row { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-size: 14px; }
.row input[type=range] { flex: 1; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 16px;
}
.field input[type=color] { padding: 3px; height: 44px; }
.field textarea { resize: vertical; line-height: 1.5; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.manual { margin-top: 10px; }
.manual summary { cursor: pointer; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 12px 16px; cursor: pointer; font-weight: 500;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.nav { display: flex; gap: 10px; margin-top: 24px; }
.nav .btn { flex: 1; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.cap-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
#final { display: block; width: 100%; border-radius: var(--radius); margin-top: 8px; }
.cap-preview {
  white-space: pre-wrap; font-family: inherit; font-size: 14px; line-height: 1.5;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  max-height: 220px; overflow: auto; unicode-bidi: plaintext;
}

.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-body {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 4px; }
.two { display: flex; gap: 10px; }
.two .field { flex: 1; }
.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-row img { width: 56px; height: 56px; border-radius: 50%; background: #fff; border: 1px solid var(--line); object-fit: contain; }

.toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #111; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30;
}
