:root {
  --red: #b0161f;
  --yellow: #f2ea25;
  --text: #111111;
  --paper: #ffffff;
  --ui: #f6f6f6;
  --border: #dedede;
  --shadow: 0 16px 40px rgba(0,0,0,.12);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #ececec;
}

body { min-height: 100vh; }
.app {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 100vh;
}

.panel { background: white; }
.controls {
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  height: 100vh;
}
.controls-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.controls h1 { margin: 0; font-size: 28px; }
.muted { color: #666; margin: 4px 0 0; }
.section {
  background: var(--ui);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px;
}
.section h2 {
  font-size: 16px;
  margin: 0 0 10px;
}
label { display: block; font-weight: 700; margin: 12px 0 6px; }
input, select, textarea, button { width: 100%; font: inherit; }
input, select, textarea {
  padding: 11px 12px;
  border: 1px solid #bbb;
  border-radius: 12px;
  background: white;
}
textarea { resize: vertical; min-height: 74px; }
input[type="range"] { padding: 0; }
input[type="color"] { min-height: 44px; padding: 4px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid-2.compact label { font-size: 13px; }
.buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.sticky-actions {
  position: static;
  background: transparent;
  padding-top: 0;
  margin-top: 6px;
}
button {
  padding: 12px 14px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  background: #111;
  color: white;
  font-weight: 700;
}
button.secondary { background: #ddd; color: #111; }
button.ghost { background: #fff; color: #111; border: 1px solid #cfcfcf; }
button.danger { color: #7a1111; border-color: #e6bcbc; }
.hint { margin-top: 12px; color: #666; font-size: 13px; line-height: 1.45; }
.free-block-controls.is-disabled {
  opacity: .55;
  pointer-events: none;
}

.preview-wrap {
  background: #efefef;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 18px;
  border-bottom: 1px solid #ddd;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  font-size: 13px;
  color: #444;
}
.preview-stage {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
}

.sheet {
  position: relative;
  width: 794px;
  min-height: 1123px;
  transform: scale(var(--zoom, .72));
  transform-origin: top center;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: visible;
}
.format-A5 { width: 560px; min-height: 794px; }
.format-A6 { width: 397px; min-height: 560px; }
.format-LINEAR {
  width: 1123px;
  min-height: 265px;
  border: 2px solid #111;
  margin-bottom: 60px;
}
.theme-yellow { background: var(--yellow); }
.theme-white { background: var(--paper); }

.block,
.logo {
  position: absolute;
}
.banner {
  background: var(--banner-color, var(--red));
  color: var(--banner-text-color, #fff);
  text-align: center;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 60px 24px 42px;
  font-size: 96px;
  line-height: .95;
  user-select: text;
}
.format-LINEAR .banner {
  padding: 18px 24px 16px;
  font-size: 40px;
  line-height: 1;
  letter-spacing: .8px;
  text-align: center;
}
.logo {
  max-width: 160px;
  max-height: 90px;
  object-fit: contain;
}
.format-LINEAR .logo {
  max-width: 96px;
  max-height: 52px;
}
.hidden { display: none !important; }
.brand {
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  text-align: center;
}
.percent {
  font-size: 52px;
  line-height: 1;
  font-weight: 900;
  text-align: center;
}
.description {
  text-align: center;
  font-size: 34px;
  line-height: 1.2;
}
.bundle {
  font-size: 54px;
  line-height: 1;
  font-weight: 900;
  text-align: center;
}
.old-price {
  font-size: 52px;
  text-decoration: line-through;
  font-weight: 700;
  text-align: center;
}
.price {
  font-size: 50px;
  line-height: .9;
  font-weight: 900;
  text-align: center;
}
.footer {
  text-align: center;
  font-size: 24px;
  line-height: 1.2;
}
.free-block {
  min-height: 40px;
  text-align: center;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 700;
  white-space: pre-wrap;
  word-break: break-word;
}
.selected-free-block {
  outline: 3px solid rgba(34, 100, 255, .65) !important;
  outline-offset: 8px;
}

.edit-mode .draggable {
  cursor: move;
}
.edit-mode .editable:hover,
.edit-mode .editable:focus {
  outline: 2px dashed rgba(17,17,17,.35);
  outline-offset: 6px;
}
.edit-mode .draggable::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px dashed rgba(17,17,17,.18);
  pointer-events: none;
}
.edit-mode .banner::after {
  inset: 6px;
}

.field-group.is-hidden {
  display: none;
}

.template-price-only .old-price,
.template-price-only .percent,
.template-price-only .bundle { display: none; }
.template-strikethrough .bundle,
.template-strikethrough .percent { display: none; }
.template-percent .bundle,
.template-percent .old-price { display: none; }
.template-two-for .old-price,
.template-two-for .percent,
.template-two-for .price { display: none; }
.template-three-for .old-price,
.template-three-for .percent,
.template-three-for .price { display: none; }
.template-month .percent,
.template-month .bundle { display: none; }
.template-month .banner { background: #8a3b00; }
.template-new .old-price,
.template-new .percent,
.template-new .bundle { display: none; }
.template-new .banner { background: #006b4f; }
.template-new .brand {
  line-height: .95;
  font-weight: 900;
}
.template-new .description {
  line-height: 1.08;
  font-weight: 700;
}
.template-new .price {
  line-height: .82;
  font-weight: 900;
}
.template-free .percent,
.template-free .bundle,
.template-free .old-price { display: none; }

.format-LINEAR .brand {
  font-size: 42px;
  text-align: left;
  line-height: .95;
  letter-spacing: -.6px;
  font-weight: 900;
}
.format-LINEAR .description {
  font-size: 26px;
  text-align: left;
  line-height: 1.08;
  color: #222;
}
.format-LINEAR .old-price {
  font-size: 30px;
  text-align: right;
  opacity: .5;
  font-weight: 700;
}
.format-LINEAR .price {
  font-size: 96px;
  text-align: right;
  line-height: .85;
  letter-spacing: -2.5px;
  padding-left: 0; 
  border-left: none;
  font-weight: 900;
}
.format-LINEAR .percent {
  font-size: 28px;
  text-align: center;
  border: 2px solid #111;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 900;
}
.format-LINEAR.template-percent .percent {
  background: #111;
  color: #fff;
}
.format-LINEAR.template-strikethrough .old-price,
.format-LINEAR.template-price-only .price,
.format-LINEAR.template-percent .price {
  text-align: right;
}
.format-LINEAR.template-strikethrough .old-price {
  width: 150px !important;
}
.format-LINEAR.template-strikethrough .price {
  width: 270px !important;
}
.format-LINEAR.template-price-only .price,
.format-LINEAR.template-percent .price {
  width: 270px !important;
}
.format-LINEAR.template-two-for .bundle {
  font-size: 34px;
  text-align: right;
  font-weight: 900;
}
.format-LINEAR.template-two-for .description {
  width: 470px !important;
}
.format-LINEAR.template-two-for .bundle {
  width: 280px !important;
}
.format-LINEAR .footer {
  font-size: 18px;
  text-align: left;
  color: #444;
}
.format-LINEAR .bundle {
  font-size: 32px;
  text-align: right;
  font-weight: 900;
}
.format-LINEAR .free-block { font-size: 26px; }

.action-grid {
  margin-top: 10px;
}

#savedLabelsList {
  min-height: 132px;
  background: #fff;
}

#storageStatus {
  font-weight: 700;
}

.print-container {
  display: none;
}

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .controls { border-right: none; border-bottom: 1px solid var(--border); }
}

@media print {
  @page { size: auto; margin: 0; }
  html, body { background: white !important; }
  body > .app { display: none !important; }
  .print-container {
    display: block !important;
  }
  .print-container .sheet,
  .print-container .sheet * {
    visibility: visible;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .print-container .sheet {
    position: relative;
    left: auto;
    top: auto;
    transform: scale(1) !important;
    box-shadow: none;
    margin: 0 0 0 0;
    break-after: page;
    page-break-after: always;
  }
  .print-container .sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  .print-container .draggable::after,
  .print-container .selected-free-block {
    outline: none !important;
    border: none !important;
  }
}
.banner {
  transition: font-size 0.2s ease;
}

.price {
  transition: color 0.2s ease;
}

/* Ligne de découpe pointillée pour le mode linéaire */
.format-LINEAR::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 38px); /* ≈ 1 cm sous la ligne noire */
  border-top: 3px dashed #000;
  pointer-events: none;
}
