:root{
  --red-dark:#7a1210;
  --red:#c31f1c;
  --red-darker:#4a0906;
  --cream:#fdf3e2;
  --cream-line:#e8d9b8;
  --gold:#f3c518;
  --gold-dark:#d4a90f;
  --text-brown:#3a1408;
  --text-sub:#5b0e0b;
  --ok:#2e7d32;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:#f2ede1;
  color:var(--text-brown);
  padding-bottom:84px; /* leave room for fixed action bar */
}

/* ---------- Topbar ---------- */
.topbar{
  position:sticky; top:0; z-index:20;
  background:var(--red-dark);
  color:#fff;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px;
  box-shadow:0 2px 8px rgba(0,0,0,.25);
}
.topbar h1{font-size:17px; margin:0; letter-spacing:.3px; font-weight:700;}
.ghost-btn{
  background:transparent; border:1.5px solid rgba(255,255,255,.6);
  color:#fff; border-radius:20px; padding:7px 12px;
  font-size:12px; font-weight:600; cursor:pointer;
}
.ghost-btn:active{background:rgba(255,255,255,.15);}

/* ---------- Editor ---------- */
main{padding:12px;}
.editor{max-width:640px; margin:0 auto;}

.section-card{
  background:#fff;
  border-radius:12px;
  margin-bottom:12px;
  overflow:hidden;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
  border:1px solid #eadfc8;
}
.section-card > summary{
  list-style:none;
  cursor:pointer;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px;
  background:linear-gradient(180deg,var(--red) 0%,var(--red-dark) 100%);
  color:#fff;
  font-weight:800;
  font-size:15px;
  letter-spacing:.3px;
}
.section-card > summary::-webkit-details-marker{display:none;}
.section-card > summary .chev{transition:transform .2s;}
.section-card[open] > summary .chev{transform:rotate(180deg);}
.section-card .badge-count{
  font-size:11px; font-weight:600; background:rgba(255,255,255,.2);
  padding:3px 8px; border-radius:10px; margin-left:8px;
}

.item-edit-row{
  display:flex; align-items:center; gap:10px;
  padding:10px 16px;
  border-bottom:1px solid #f2ece0;
}
.item-edit-row:last-child{border-bottom:none;}
.item-edit-label{flex:1; min-width:0;}
.item-edit-label .n{font-size:14px; font-weight:600; display:block;}
.item-edit-label .note{font-size:11.5px; color:#8a7256; font-style:italic; display:block; margin-top:1px;}

.price-input-wrap{
  display:flex; align-items:center; gap:2px;
  background:#fbf6ea; border:1.5px solid #e3d3ab;
  border-radius:8px; padding:4px 8px;
  flex-shrink:0;
}
.price-input-wrap span{font-size:13px; color:#8a7256; font-weight:600;}
.price-input-wrap input{
  width:62px; border:none; background:transparent;
  font-size:15px; font-weight:700; color:var(--text-brown);
  text-align:right; outline:none;
  -moz-appearance:textfield;
}
.price-input-wrap input::-webkit-outer-spin-button,
.price-input-wrap input::-webkit-inner-spin-button{-webkit-appearance:none; margin:0;}

/* ---------- Preview ---------- */
.preview-wrap{
  padding:4px 12px 20px;
}
.preview-scroll{
  max-width:640px; margin:0 auto;
  border-radius:10px;
  overflow:hidden;
  box-shadow:0 4px 18px rgba(0,0,0,.18);
  border:1px solid #ddd0ac;
}
.preview-scroll{position:relative;}

/* The poster itself is rendered at a fixed "true" resolution (1024px wide)
   and then visually scaled down with CSS transform to fit the phone screen.
   html2canvas renders it at the true resolution, ignoring the scale. */
.poster{
  width:1024px;
  background:var(--cream);
  padding:26px;
  transform-origin:top left;
  font-family:-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}

.poster-header{
  background:linear-gradient(160deg,#8a1613 0%,var(--red-dark) 55%,var(--red-darker) 100%);
  border-radius:10px 10px 0 0;
  text-align:center;
  padding:26px 20px 34px;
  position:relative;
}
.poster-header h1{
  margin:0;
  font-size:70px;
  font-weight:900;
  color:#fdf3e2;
  letter-spacing:3px;
  text-shadow:3px 3px 0 var(--red-darker), 0 0 22px rgba(0,0,0,.3);
  font-family:'Arial Black',Impact,sans-serif;
}
.poster-header .deco{color:var(--gold); font-size:34px; vertical-align:middle; margin:0 14px;}
.ribbon-yellow{
  display:inline-block;
  background:linear-gradient(180deg,#ffe062,var(--gold) 60%,var(--gold-dark));
  padding:10px 34px;
  border-radius:3px;
  transform:rotate(-1deg);
  margin-top:8px;
  box-shadow:0 3px 0 rgba(0,0,0,.15);
}
.ribbon-yellow span{
  display:block; transform:rotate(1deg);
  color:var(--text-sub); font-weight:800; font-size:27px;
  letter-spacing:.5px; font-family:'Arial Black',Impact,sans-serif;
}

.poster-body{
  border:4px dashed var(--red-dark);
  border-top:none;
  border-radius:0 0 10px 10px;
  padding:18px;
  background:var(--cream);
}

.top-grid{display:grid; grid-template-columns:1.32fr 1fr; gap:16px;}
.right-stack{display:flex; flex-direction:column; gap:16px;}
.bottom-grid{display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:16px;}

.box{
  background:#fffaf0;
  border:3px dashed var(--red);
  border-radius:12px;
  padding:16px 16px 14px;
  position:relative;
  display:flex;
  flex-direction:column;
}
.box-header{
  text-align:center;
  margin:-16px -16px 14px;
  padding:14px 10px 10px;
  background:linear-gradient(160deg,#8a1613,var(--red-dark) 70%);
  border-radius:9px 9px 0 0;
}
.box-header h2{
  margin:0; color:#fdf3e2; font-size:30px; font-weight:900;
  letter-spacing:1px; font-family:'Arial Black',Impact,sans-serif;
  text-shadow:2px 2px 0 rgba(0,0,0,.25);
}
.box-header .subribbon{
  display:inline-block; background:var(--gold); color:var(--text-sub);
  font-weight:800; font-size:16px; letter-spacing:.5px;
  padding:3px 16px; border-radius:4px; margin-top:6px;
  font-family:'Arial Black',Impact,sans-serif;
}
.box-header .plain-title{
  color:#fdf3e2; font-size:30px; font-weight:900; letter-spacing:1px;
  font-family:'Arial Black',Impact,sans-serif;
  text-shadow:2px 2px 0 rgba(0,0,0,.25);
}
.box-header .badge{
  display:inline-block; background:var(--gold); color:var(--text-sub);
  font-weight:800; font-size:12px; padding:2px 10px; border-radius:10px;
  margin-left:8px; vertical-align:middle;
}
.box-note{
  text-align:center; font-size:12px; font-weight:700; color:var(--text-sub);
  margin:0 0 10px; line-height:1.35;
}

.cols{display:grid; gap:0 18px;}
.cols.c2{grid-template-columns:1fr 1fr;}
.cols.c2 .col + .col{border-left:1.5px solid var(--cream-line); padding-left:18px;}

.item-row{
  display:flex; align-items:baseline; gap:6px;
  margin-bottom:6px; font-size:12.6px; line-height:1.25;
}
.item-row .name{font-weight:700; white-space:nowrap; color:var(--text-brown);}
.item-row .note{font-size:9.5px; font-style:italic; font-weight:500; color:#7a5f3d; margin-left:2px;}
.item-row .dots{
  flex:1; min-width:8px;
  border-bottom:2px dotted #b98b4a;
  margin:0 2px 3px;
  transform:translateY(-2px);
}
.item-row .price{
  background:var(--red);
  color:#fff; font-weight:800; font-size:12px;
  padding:2px 9px; border-radius:4px; white-space:nowrap;
  box-shadow:0 1px 0 rgba(0,0,0,.2);
}

.box-photo{
  margin:10px -4px -2px;
  margin-top:auto;
  padding-top:10px;
  text-align:center;
}
.box-photo img{
  max-width:100%;
  display:inline-block;
  border-radius:6px;
}

.poster-footer{
  margin-top:18px;
  background:linear-gradient(160deg,#8a1613,var(--red-dark) 70%);
  color:var(--gold);
  text-align:center;
  font-weight:900; font-size:20px; letter-spacing:.5px;
  padding:14px; border-radius:10px;
  font-family:'Arial Black',Impact,sans-serif;
  text-shadow:1px 1px 0 rgba(0,0,0,.3);
}
.poster-footer .star{color:#fdf3e2;}
.poster-footer .accent{color:#fdf3e2;}

/* ---------- Action bar ---------- */
.actionbar{
  position:fixed; bottom:0; left:0; right:0;
  background:#fff;
  border-top:1px solid #eadfc8;
  padding:10px 16px calc(10px + env(safe-area-inset-bottom));
  z-index:30;
}
.primary-btn{
  width:100%; max-width:640px; margin:0 auto; display:block;
  background:linear-gradient(180deg,var(--red) 0%,var(--red-dark) 100%);
  color:#fff; border:none; border-radius:12px;
  padding:15px; font-size:16px; font-weight:800;
  letter-spacing:.3px; cursor:pointer;
  box-shadow:0 2px 6px rgba(122,18,16,.4);
}
.primary-btn:active{transform:translateY(1px);}
.primary-btn:disabled{opacity:.6;}

@media (min-width:700px){
  .editor,.preview-scroll,.primary-btn{max-width:680px;}
}
