:root {
  --ink: #111;
  --muted: #6b6b6b;
  --line: #e4e4e0;
  --bg: #f4f4f1;
  --card: #fff;
  --font: "Inter", "Noto Sans Bengali", "Hind Siliguri", "Nirmala UI", "Vrinda", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- App shell ---------- */

.topbar { padding: 22px 28px 6px; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.topbar p { margin: 2px 0 0; color: var(--muted); }
.bn { font-weight: 500; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  padding: 18px 28px 40px;
  align-items: start;
}

.panel { display: grid; gap: 14px; position: sticky; top: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.step {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 700;
}

.drop {
  display: grid; gap: 2px; place-items: center; text-align: center;
  padding: 20px 12px;
  border: 1.5px dashed #bdbdb7; border-radius: 12px;
  cursor: pointer; color: var(--muted);
  transition: background .15s, border-color .15s;
}
.drop strong { color: var(--ink); }
.drop:hover, .drop.over { background: #f0f0ec; border-color: var(--ink); }
.drop input { display: none; }

.row-actions { display: flex; gap: 8px; margin-top: 10px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--ink);
  padding: 9px 14px; background: var(--ink); color: #fff;
}
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); flex: 1; font-size: 12.5px; }
.btn.ghost:hover { border-color: var(--ink); }
.btn.small { flex: none; padding: 5px 12px; }
.btn.primary { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.hint code { background: #f0f0ec; padding: 1px 5px; border-radius: 4px; }
.msg { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: #fff4e0; border: 1px solid #f0d9a8; font-size: 12.5px; }

.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input[type=text], .field input[type=number], .field select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
details { margin-top: 4px; }
summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }

/* ---------- Preview stage ---------- */

.stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  min-height: 320px;
}
.stage-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 70px 0; }
.empty p { margin: 4px 0; }

#preview { --zoom: 2; display: flex; flex-wrap: wrap; gap: 18px; }
#preview figure { margin: 0; }
#preview figcaption { margin-top: 6px; font-size: 12px; color: var(--muted); text-align: center; }
#preview .sticker { box-shadow: 0 0 0 1px #d6d6d0, 0 6px 18px rgba(0, 0, 0, .08); border-radius: 3px; }

/* ---------- Sticker (pure black on white; everything scales with the sticker) ---------- */

.sticker {
  width: calc(var(--w) * 1mm * var(--zoom));
  height: calc(var(--h) * 1mm * var(--zoom));
  container-type: size;
  position: relative;
  overflow: hidden;
  flex: none;
  background: #fff;
  color: #000;
  font-family: var(--st-en, "Jost"), var(--st-bn, "Anek Bangla"), "Nirmala UI", "Noto Sans Bengali", system-ui, sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.sticker .frame {
  position: absolute;
  inset: min(2.4cqw, 3.6cqh);
  transform: translate(calc(var(--ox, 0) * 1mm * var(--zoom)), calc(var(--oy, 0) * 1mm * var(--zoom)));
  display: flex;
  flex-direction: column;
  padding: 4cqh 5cqw 3cqh;
  border: 0.9cqmin solid #000;
  border-radius: 4.5cqmin;
}
.sticker .frame.noborder { border-color: transparent; }

.sticker .name {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 750;
  line-height: 1.3;
  font-size: calc(min(12cqw, 17cqh) * var(--fit, 1));
  padding-bottom: 0.4cqh;
}
.sticker .name span { display: block; max-width: 100%; text-wrap: balance; overflow-wrap: anywhere; }

/* price | size : small label over a large value */
.sticker .info {
  flex: none;
  display: flex;
  align-items: stretch;
  margin-top: 1.5cqh;
  white-space: nowrap;
  line-height: 1.15;
  font-size: calc(min(10.5cqw, 17cqh) * var(--fit, 1));
}
.sticker .cell {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 0.3em;
}
.sticker .cell small {
  font-size: 0.5em;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.1em;
}
.sticker .cell small:not(.lat) { font-size: 0.62em; }
.sticker .cell small.lat { text-transform: uppercase; letter-spacing: 0.16em; }
.sticker .cell b { font-weight: 800; }

.sticker .foot {
  flex: none;
  margin-top: 2.2cqh;
  text-align: center;
  white-space: nowrap;
  line-height: 1.3;
  font-size: min(3.4cqw, 5cqh);
}
.sticker .foot div {
  font-size: 0.82em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  margin-right: -0.24em; /* cancel trailing letter-space so it stays centred */
}
.sticker .foot b { display: block; font-weight: 700; letter-spacing: 0.08em; margin-right: -0.08em; }

/* ---------- Print ---------- */

#printSheet { display: none; --zoom: 1; }

@media print {
  html, body { margin: 0; padding: 0; background: #fff; }
  .app { display: none !important; }
  #printSheet { display: block; }
  #printSheet .sticker {
    height: calc(var(--h) * 1mm - 0.15mm);
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
  }
  #printSheet .sticker:last-child { break-after: auto; page-break-after: auto; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 14px 16px 30px; }
  .panel { position: static; }
  .topbar { padding: 18px 16px 4px; }
}
