:root {
  --red: #F22222;
  --bg: #f4f3f0;
  --panel: #fbfaf8;
  --ink: #202124;
  --muted: #6c6e72;
  --line: #deddd8;
  --radius: 10px;
  --tap: 44px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { font-size: 14px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: 100dvh; }

/* Vorschau */
.stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 32px 20px; min-width: 0; min-height: 0; overflow: hidden; }
.frame { position: relative; flex: 1 1 0; width: 100%; min-height: 0; display: grid; place-items: center; }
.frame-inner { position: relative; }
canvas { display: block; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.12); touch-action: none; cursor: crosshair; background: #fff; }
canvas.pan { cursor: grab; }
canvas.pan.dragging { cursor: grabbing; }
.handles { position: absolute; inset: 0; pointer-events: none; }
.handle { position: absolute; width: var(--tap); height: var(--tap); margin: calc(var(--tap) / -2) 0 0 calc(var(--tap) / -2); border: 0; padding: 0; background: transparent; pointer-events: auto; touch-action: none; cursor: grab; border-radius: 50%; }
.handle::before { content: attr(data-n); position: absolute; inset: 9px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.92); color: var(--ink); font-size: 12px; font-weight: 600; box-shadow: 0 0 0 1.5px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.25); }
.handle:active { cursor: grabbing; }
.drop-hint { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(32,33,36,.55); color: #fff; font-weight: 600; pointer-events: none; }
.hint { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

/* Panel */
.panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 8px 20px 32px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 14px 0 6px; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .01em; }
.block { padding: 16px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.block:last-child { border-bottom: 0; }
details.block > summary { cursor: pointer; font-weight: 600; min-height: 28px; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::after { content: "+"; color: var(--muted); font-size: 18px; font-weight: 400; }
details.block[open] > summary::after { content: "–"; }
.muted { color: var(--muted); }
.small { font-size: 12px; margin: 0; }
.error { margin: 0; padding: 8px 10px; border-radius: 8px; background: #fde8e8; color: #8a1111; font-size: 13px; }

.btn { min-height: var(--tap); padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: #bdbcb6; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: #d81818; }
.btn.big { min-height: 52px; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn.icon { padding: 0; width: var(--tap); font-size: 22px; line-height: 1; flex: none; }
kbd { font: inherit; font-size: 11px; font-weight: 500; opacity: .75; border: 1px solid rgba(255,255,255,.55); border-radius: 5px; padding: 1px 6px; }
.seed-row { display: flex; gap: 6px; }
.seed-row input { flex: 1; min-width: 0; height: var(--tap); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; font: inherit; font-variant-numeric: tabular-nums; text-align: center; background: #fff; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; padding: 0 8px; }

/* Slider */
.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; }
.slider label { font-weight: 500; }
.slider output { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.slider input { grid-column: 1 / -1; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: var(--tap); background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; background: var(--red); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15), 0 2px 5px rgba(0,0,0,.25); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--red); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15), 0 2px 5px rgba(0,0,0,.25); }
.sliders { gap: 4px; }

/* Segmente */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset > legend { padding: 0; margin-bottom: 6px; font-weight: 500; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.seg.wrap { grid-template-columns: repeat(3, 1fr); }
.seg label { position: relative; display: block; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; font-weight: 500; text-align: center; }
.seg input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.sw { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); flex: none; }
.sw.img { background: linear-gradient(135deg, #7aa7c7, #3d5a4a 60%, #d9b27a); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--red); flex: none; }
.check small { color: var(--muted); }
.free { display: flex; align-items: flex-end; gap: 8px; }
.free label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; }
.free input { height: var(--tap); width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; font: inherit; color: var(--ink); background: #fff; }
.free span { padding-bottom: 12px; color: var(--muted); }
#imageControls { display: flex; flex-direction: column; gap: 10px; }

/* Mobil: Vorschau oben (sticky), Steuerung darunter */
@media (max-width: 799px) {
  html, body { height: auto; }
  .app { display: block; height: auto; }
  .stage { position: sticky; top: 0; z-index: 5; height: 46dvh; padding: 14px 16px 6px; background: var(--bg); }
  .hint { margin-top: 6px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 4px 16px max(32px, env(safe-area-inset-bottom)); }
  kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
