*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #FAF8F5;
  --panel: #FFFFFF;
  --ink: #1A1A1A;
  --muted: #6b655c;
  --rule: #E0D8CC;
  --accent: #1B3A5C;
  --label-ink: #23201d; /* warm near-black for the printed frame + text */
  --scale: 0.8;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Open Sans", "Helvetica Neue", Arial, sans-serif;
  min-height: 100%;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.app-header h1 {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
}
.app-header p { font-size: 0.8rem; color: var(--muted); }
.back { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.back:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: start;
}

.editor {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1.5rem;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field > span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.field input, .field textarea {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.5rem 0.6rem;
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: #fff;
}

.print-btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.65rem 1rem;
  border-radius: 3px;
  cursor: pointer;
}
.print-btn:hover { filter: brightness(1.08); }
.hint { font-size: 0.72rem; color: var(--muted); line-height: 1.5; }

/* ── Preview / sheet ─────────────────────────────────────────────────── */
.preview { min-width: 0; }
.stage { position: relative; }

.sheet {
  position: relative;
  width: 210mm;
  height: 297mm;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.16);
  transform: scale(var(--scale));
  transform-origin: top left;
  display: grid;
  grid-template-columns: 105mm 105mm;
  grid-auto-rows: 74.25mm;
}

/* Dotted fold / cut guides */
.folds {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.folds line {
  stroke: #b3ada3;
  stroke-width: 0.3;
  stroke-dasharray: 0.7 1.3;
  stroke-linecap: round;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── The label itself ────────────────────────────────────────────────── */
.label {
  position: relative;
  width: 70mm;
  height: 62mm;
}
.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.frame-outer, .frame-inner {
  fill: none;
  stroke: var(--label-ink);
  vector-effect: non-scaling-stroke;
}
.frame-outer { stroke-width: 4.2; }
.frame-inner { stroke-width: 1.4; }

.ltext {
  position: absolute;
  inset: 8mm 10mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--label-ink);
  font-family: Georgia, "Times New Roman", serif;
  gap: 1.4mm;
}
.l-maker {
  font-size: 3.1mm;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.l-loc {
  font-size: 2.3mm;
  font-style: italic;
  color: #4a453d;
  letter-spacing: 0.02em;
  margin-top: 0.6mm;
  max-width: 48mm;
}
.l-rule {
  width: 14mm;
  height: 0;
  border-top: 0.3mm solid var(--label-ink);
  opacity: 0.6;
  margin: 1.2mm 0 0.2mm;
}
.l-jam {
  font-size: 8.2mm;
  font-weight: 700;
  font-style: italic;
  line-height: 1.02;
}
.l-year {
  font-size: 3.6mm;
  letter-spacing: 0.05em;
}
.l-ing {
  font-size: 2.5mm;
  line-height: 1.3;
  color: #4a453d;
  font-family: "Open Sans", Arial, sans-serif;
  max-width: 46mm;
}
.l-disc {
  font-size: 1.55mm;
  line-height: 1.22;
  color: #8a857c;
  font-family: "Open Sans", Arial, sans-serif;
  max-width: 50mm;
  margin-top: 1.6mm;
  text-wrap: balance;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .editor { position: static; }
}

/* ── Print: just the sheet, exact size, one page ─────────────────────── */
@media print {
  @page { size: A4; margin: 0; }
  html, body {
    width: 210mm;
    height: 297mm;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;          /* clamp to a single page — no phantom page 2 */
    background: #fff;
  }
  .app-header, .editor { display: none !important; }
  .app { display: block !important; margin: 0 !important; padding: 0 !important; }
  .preview { margin: 0 !important; padding: 0 !important; }
  .stage { height: auto !important; margin: 0 !important; padding: 0 !important; }
  .sheet {
    transform: none !important;
    box-shadow: none !important;
    width: 210mm;
    height: 297mm;
    margin: 0 !important;
    overflow: hidden;
  }
  .frame-outer, .frame-inner, .ltext, .l-ing, .folds line {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
