* { box-sizing: border-box; }
:root { --ink:#0f172a; --line:#e2e8f0; --accent:#7c3aed; --accent2:#ec4899; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% 0%, #f5f3ff 0%, #fdf2f8 55%, #eff6ff 100%);
  padding: 20px;
}
.lab { max-width: 760px; margin: 0 auto; }
.lab-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark { font-size: 26px; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.score { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 7px 15px; font-weight: 700; }
.score span { color: var(--accent); }

.hero-title { text-align: center; margin: 6px 0 18px; font-size: 26px; }

.stage { display: flex; flex-direction: column; align-items: center; }

.canvas-wrap { position: relative; width: 100%; max-width: 560px; aspect-ratio: 1; background: #fff; border: 4px solid var(--ink); border-radius: 26px; overflow: hidden; box-shadow: 0 18px 40px rgba(15,23,42,.12); }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.brushbar { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; background: rgba(255,255,255,.9); padding: 8px; border-radius: 999px; box-shadow: 0 4px 14px rgba(15,23,42,.14); }
.brush { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.brush.on { box-shadow: 0 0 0 3px var(--accent); }
.tinybar { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; }
.tool { width: 40px; height: 40px; border: none; background: rgba(255,255,255,.92); border-radius: 12px; font-size: 17px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 14px rgba(15,23,42,.14); }
.tool:hover { color: var(--accent); }

.pencil-loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; background: rgba(255,255,255,.86); backdrop-filter: blur(2px); text-align: center; font-weight: 700; }
.pencil-loading[hidden] { display: none; }
.pencil { font-size: 46px; animation: wiggle 900ms ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-12deg) translateX(-8px); } 50% { transform: rotate(12deg) translateX(8px); } }
@media (prefers-reduced-motion: reduce) { .pencil { animation: none; } }

.controls { width: 100%; max-width: 560px; margin-top: 16px; }
.prompt-row { display: flex; gap: 10px; }
#wish { flex: 1; border: 2px solid var(--line); border-radius: 16px; padding: 15px 18px; font-size: 16px; font-weight: 600; outline: none; }
#wish:focus { border-color: var(--accent); }
.make { border: none; border-radius: 16px; padding: 0 22px; font-size: 16px; font-weight: 800; color: #fff; cursor: pointer; white-space: nowrap; background: linear-gradient(90deg, var(--accent), var(--accent2)); box-shadow: 0 8px 20px rgba(124,58,237,.3); }
.make:hover { filter: brightness(1.05); }
.hint { margin: 10px 2px 0; color: #64748b; font-size: 14px; text-align: center; }

.result { width: 100%; max-width: 560px; margin: 20px 0 0; }
.result[hidden] { display: none; }
.result img { width: 100%; border-radius: 20px; border: 4px solid var(--ink); box-shadow: 0 16px 34px rgba(15,23,42,.18); animation: pop 260ms ease-out; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .result img { animation: none; } }
.result-actions { display: flex; gap: 10px; margin-top: 10px; }
.result-actions button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px; font-weight: 800; cursor: pointer; }
.result-actions button:hover { border-color: var(--accent); }

.gallery { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 20px; width: 100%; max-width: 560px; }
.g-card { position: relative; margin: 0; }
.g-card img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.g-dl { position: absolute; right: 4px; bottom: 4px; border: none; background: rgba(15,23,42,.75); color: #fff; border-radius: 8px; width: 24px; height: 24px; cursor: pointer; font-size: 13px; }
