:root{
  --pink:#ff5ea8; --pink-d:#e23e8c; --purple:#9b5de5; --blue:#4cc9f0;
  --yellow:#ffd166; --mint:#8ef6c8; --ink:#2a2140; --paper:#fff7fc;
  --sheet:#ffffff; --shadow:0 10px 30px rgba(120,40,110,.25);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0; height:100%;}
body{
  font-family:"Baloo 2","Segoe UI",system-ui,sans-serif;
  background:
    radial-gradient(circle at 15% 10%, #ffe0f2 0, transparent 45%),
    radial-gradient(circle at 85% 20%, #dcefff 0, transparent 45%),
    radial-gradient(circle at 50% 100%, #e9dbff 0, transparent 55%),
    var(--paper);
  color:var(--ink);
  display:flex; flex-direction:column;
  overflow:hidden; touch-action:none;
  user-select:none; -webkit-user-select:none;
}

/* ---- Topbar ---- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px calc(10px + env(safe-area-inset-top,0px)) 14px;
  padding-top:calc(10px + env(safe-area-inset-top,0px));
}
.logo{display:flex; align-items:center; gap:8px; font-weight:800; font-size:20px;}
.logo-emoji{font-size:24px;}
.logo-text{background:linear-gradient(90deg,var(--pink),var(--purple));
  -webkit-background-clip:text; background-clip:text; color:transparent;}
.btn-ghost{
  border:none; background:#fff; border-radius:16px; padding:8px 12px;
  font-size:20px; box-shadow:var(--shadow); }

/* ---- Stage ---- */
#editor{flex:1; display:flex; overflow:hidden;}
.stage-wrap{flex:1; display:flex; flex-direction:column; align-items:center;
  justify-content:center; padding:6px 10px 4px;}
.stage{display:flex; align-items:center; justify-content:center; width:100%; flex:1;}

/* A54 verhouding: 158.2 x 76.7 mm  ->  ratio 2.063 (h/w) */
.phone{
  position:relative;
  aspect-ratio:76.7 / 158.2;
  height:min(72vh, 620px);
  max-width:92vw;
  border-radius:34px;
  background:var(--mint);
  box-shadow:0 14px 34px rgba(80,30,90,.28), inset 0 0 0 3px rgba(255,255,255,.5);
  overflow:hidden;
}
.phone-bg{position:absolute; inset:0; z-index:0;}
.camera{position:absolute; top:16px; left:16px; z-index:5;
  display:grid; grid-template-columns:repeat(2,1fr); gap:6px;
  padding:8px; width:56px; border-radius:18px;
  background:rgba(20,15,30,.14); backdrop-filter:blur(2px);}
.camera .lens{width:18px; height:18px; border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #6ad, #234); box-shadow:inset 0 0 3px #000;}
.camera .flash{width:12px; height:12px; border-radius:50%; align-self:center; justify-self:center;
  background:#ffe9a8;}
.layers{position:absolute; inset:0; z-index:2;}

.hint{margin-top:8px; font-size:13px; color:#a06; opacity:.85; font-weight:700;}

/* ---- Sticker item ---- */
.item{position:absolute; top:0; left:0; transform-origin:center center;
  will-change:transform; touch-action:none;}
.item img, .item .emoji-face{display:block; width:100%; height:100%; pointer-events:none;}
.item .emoji-face{display:flex; align-items:center; justify-content:center; line-height:1;}
.item.selected{outline:2px dashed var(--pink); outline-offset:3px; border-radius:6px;}
.handle{
  position:absolute; width:34px; height:34px; border-radius:50%;
  background:#fff; box-shadow:var(--shadow); display:flex; align-items:center;
  justify-content:center; font-size:16px; z-index:20; touch-action:none;}
.handle.rotate{top:-44px; left:50%; transform:translateX(-50%);}
.handle.scale{bottom:-17px; right:-17px;}
.item:not(.selected) .handle{display:none;}

/* ---- Toolbar ---- */
.toolbar{
  display:flex; justify-content:space-around; align-items:stretch;
  background:#fff; margin:0 8px calc(8px + var(--safe-bottom));
  border-radius:22px; box-shadow:var(--shadow); padding:6px;
}
.tool{border:none; background:transparent; display:flex; flex-direction:column;
  align-items:center; gap:2px; padding:8px 4px; border-radius:16px; flex:1; color:var(--ink);}
.tool span{font-size:24px;}
.tool label{font-size:11px; font-weight:700;}
.tool:active{background:#ffe6f3; transform:scale(.94);}

/* ---- Zwevende object-acties ---- */
.obj-actions{position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(96px + var(--safe-bottom)); display:flex; gap:10px;
  background:#fff; padding:8px 12px; border-radius:20px; box-shadow:var(--shadow); z-index:40;}
.obj-actions button{border:none; background:#fff0f8; width:46px; height:46px;
  border-radius:14px; font-size:22px;}
.obj-actions button:active{transform:scale(.9);}

/* ---- Sheets ---- */
.sheet{position:fixed; inset:0; z-index:60; display:flex; align-items:flex-end;
  background:rgba(40,20,50,.42); backdrop-filter:blur(2px);}
.sheet-inner{width:100%; background:var(--sheet);
  border-radius:26px 26px 0 0; padding:18px 16px calc(18px + var(--safe-bottom));
  box-shadow:0 -8px 30px rgba(80,20,80,.25);
  animation:up .22s ease; max-height:92vh; overflow:auto;}
.sheet-inner.tall{min-height:60vh;}
@keyframes up{from{transform:translateY(100%);}to{transform:translateY(0);}}
.sheet-title{font-weight:800; font-size:19px; text-align:center; margin-bottom:14px; color:var(--pink-d);}
.big-choice{display:block; width:100%; border:none; margin:8px 0; padding:16px;
  border-radius:18px; font-size:17px; font-weight:800; color:#fff;
  background:linear-gradient(90deg,var(--pink),var(--purple)); box-shadow:var(--shadow);}
.big-choice.soft{background:linear-gradient(90deg,var(--blue),var(--mint)); color:var(--ink);}
.big-choice.grow{flex:1;}
.big-choice:active{transform:scale(.97);}
.sheet-close{display:block; width:100%; background:#f1e8f5; border:none;
  padding:13px; border-radius:16px; font-weight:800; color:#75577f; margin-top:6px; font-size:15px;}
.sheet-row{display:flex; gap:10px; align-items:center; margin-top:6px;}
.sheet-row.col{flex-direction:column;}
.mini{border:none; background:#f4ecfa; border-radius:14px; padding:10px 12px;
  font-size:14px; font-weight:700; color:#6b4b86;}
.mini.active{background:var(--pink); color:#fff;}

/* ---- Foto & teken canvas ---- */
.photo-canvas-wrap, .draw-canvas-wrap{position:relative; width:100%;
  background:repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0/24px 24px;
  border-radius:16px; overflow:hidden; margin-bottom:12px; touch-action:none;
  display:flex; align-items:center; justify-content:center; min-height:44vh;}
.photo-canvas-wrap canvas, .draw-canvas-wrap canvas{max-width:100%; max-height:52vh; display:block; touch-action:none;}
.mask-canvas{position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);}
.photo-tools, .draw-tools{display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:8px;}
.brush-lab{display:flex; align-items:center; gap:8px; font-weight:700; font-size:13px; flex:1; color:#6b4b86;}
.brush-lab input[type=range]{flex:1;}

/* ---- Swatches ---- */
.swatches{display:flex; gap:8px; flex-wrap:wrap;}
.swatch{width:30px; height:30px; border-radius:50%; border:3px solid #fff; box-shadow:0 2px 6px rgba(0,0,0,.2);}
.swatch.active{outline:3px solid var(--ink);}

/* ---- Emoji grid ---- */
.emoji-grid{display:grid; grid-template-columns:repeat(6,1fr); gap:8px; margin-bottom:12px;}
.emoji-grid button{font-size:30px; border:none; background:#fbf1ff; border-radius:14px; padding:10px 0;}
.emoji-grid button:active{transform:scale(.9); background:#ffe6f3;}

/* ---- Bg grid ---- */
.bg-grid{display:grid; grid-template-columns:repeat(5,1fr); gap:10px; margin-bottom:10px;}
.bg-grid button{height:52px; border:3px solid #fff; border-radius:14px; box-shadow:0 2px 8px rgba(0,0,0,.15);}
.pick-lab{display:flex; align-items:center; gap:10px; font-weight:700; color:#6b4b86; width:100%; justify-content:space-between;}
.pick-lab input[type=color]{width:54px; height:40px; border:none; background:none;}

/* ---- Designs ---- */
.designs-list{display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:12px 0;}
.design-card{background:#fff; border-radius:16px; overflow:hidden; box-shadow:var(--shadow); position:relative;}
.design-card img{width:100%; display:block; aspect-ratio:76.7/158.2; object-fit:cover; background:#f3eaf8;}
.design-card .del{position:absolute; top:4px; right:4px; border:none; background:rgba(255,255,255,.9);
  border-radius:10px; font-size:14px; padding:2px 6px;}
.design-card .name{font-size:11px; text-align:center; padding:4px; font-weight:700; color:#75577f;}

.export-preview{width:60%; margin:0 auto 14px; display:block; border-radius:16px; box-shadow:var(--shadow);}

.toast{position:fixed; bottom:calc(90px + var(--safe-bottom)); left:50%; transform:translateX(-50%);
  background:var(--ink); color:#fff; padding:10px 18px; border-radius:20px; font-weight:700;
  z-index:90; box-shadow:var(--shadow); font-size:14px;}
.toast.show{animation:pop .3s ease;}
@keyframes pop{from{transform:translate(-50%,10px); opacity:0;}to{transform:translate(-50%,0);opacity:1;}}

.text-input{width:100%; border:2px solid #eaddf6; border-radius:16px; padding:12px;
  font-size:18px; font-weight:700; resize:none; box-sizing:border-box; outline:none;
  color:#3a2a52; background:#fbf6ff;}
.text-input:focus{border-color:var(--pink);}
.text-preview{min-height:56px; display:flex; align-items:center; justify-content:center;
  text-align:center; font-size:30px; font-weight:800; margin:12px 0; padding:8px 10px;
  background:repeating-conic-gradient(#f3ecfa 0% 25%, #fff 0% 50%) 0/24px 24px;
  border-radius:16px; word-break:break-word; line-height:1.2;}
.text-tools{display:flex; flex-direction:column; gap:10px; margin-bottom:8px;}
.text-tools select{border:none; background:#f4ecfa; border-radius:12px; padding:8px 10px;
  font-weight:700; color:#6b4b86;}

.hidden{display:none !important;}
