@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap");

:root {
  --ink: #201d18;
  --muted: #706b62;
  --line: #e7e2d8;
  --paper: #fff;
  --canvas: #f6f3ed;
  --gold: #a67c32;
  --gold-dark: #806022;
  --gold-soft: #f5ecdc;
  --shadow: 0 22px 55px rgba(49, 39, 22, 0.11);
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, textarea { font: inherit; }
button { color: inherit; }
.form-honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; }

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(400px, 35%) minmax(560px, 65%);
}

.config-panel {
  background: var(--paper);
  padding: 42px clamp(28px, 4vw, 64px) 80px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand img { filter: drop-shadow(0 6px 14px rgba(166,124,50,.18)); }
.eyebrow { margin: 0 0 3px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { font-family: "Playfair Display", Georgia, serif; margin: 0; letter-spacing: -.02em; }
h1 { font-size: clamp(28px, 2.5vw, 38px); }
h2 { font-size: 28px; }
.intro { color: var(--muted); line-height: 1.65; margin: 22px 0 34px; max-width: 520px; }

.form-section { border: 0; border-top: 1px solid var(--line); padding: 26px 0 4px; margin: 0 0 20px; }
.form-section legend { padding: 0 10px 0 0; font-weight: 700; font-size: 15px; }
.form-section legend span {
  display: inline-grid; place-items: center; width: 25px; height: 25px; margin-right: 9px;
  border-radius: 50%; background: var(--gold-soft); color: var(--gold-dark); font-size: 12px;
}

.choice-grid, .quantity-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.customer-type-grid { grid-template-columns: repeat(2, 1fr); }
.customer-type-card { min-height: 82px; }
.choice-card {
  min-height: 72px; border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  display: flex; align-items: center; gap: 11px; cursor: pointer; transition: .2s ease;
}
.choice-card:hover { border-color: #c9b384; transform: translateY(-1px); }
.choice-card:has(input:checked) { border-color: var(--gold); background: #fffcf6; box-shadow: 0 0 0 3px var(--gold-soft); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-dot { width: 17px; height: 17px; border: 1.5px solid #aaa297; border-radius: 50%; flex: 0 0 auto; }
.choice-card:has(input:checked) .radio-dot { border: 5px solid var(--gold); }
.choice-card strong, .choice-card small { display: block; }
.choice-card small { color: var(--muted); margin-top: 3px; font-size: 11px; }

.upload-zone {
  margin-top: 18px; min-height: 112px; border: 1.5px dashed #cfc7b8; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; gap: 13px; padding: 18px;
  background: #fbfaf7; cursor: pointer; text-align: left; transition: .2s ease;
}
.upload-zone:hover, .upload-zone.dragging { border-color: var(--gold); background: #fffaf0; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-zone strong, .upload-zone small { display: block; }
.upload-zone small { color: var(--muted); margin-top: 4px; font-size: 12px; }
.upload-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--gold-dark); background: var(--gold-soft); font-size: 20px; }
.text-button { margin-left: auto; padding: 7px 9px; border: 0; background: transparent; color: #9b3f32; cursor: pointer; }

.field { display: block; margin-top: 16px; }
.field > span { display: flex; justify-content: space-between; color: #4c4841; font-size: 12px; font-weight: 600; margin-bottom: 7px; }
.field > span small { color: #9b958b; font-weight: 400; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px;
  outline: 0; background: #fff; resize: vertical; transition: .2s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.field input.invalid { border-color: #b74c3c; }
.field[hidden] { display: none; }
.field-hint { margin: 9px 0 0; color: #918a7f; font-size: 11px; line-height: 1.45; }

.quantity-grid { grid-template-columns: repeat(4, 1fr); }
.quantity-grid button {
  border: 1px solid var(--line); border-radius: 11px; padding: 11px 4px; background: #fff; cursor: pointer; font-weight: 600; transition: .2s ease;
}
.quantity-grid button:hover { border-color: #c9b384; }
.quantity-grid button.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.custom-quantity { max-width: 180px; }
.price-context { margin: 12px 0 0; color: var(--gold-dark); font-size: 11px; font-weight: 600; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.contact-grid .full { grid-column: 1 / -1; }
.order-consents { margin: 10px 0 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fbfaf7; }
.consent-field { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: 11px; line-height: 1.5; cursor: pointer; }
.consent-field + .consent-field { margin-top: 12px; }
.consent-field input { width: 17px; height: 17px; flex: 0 0 auto; margin: 1px 0 0; accent-color: var(--gold-dark); }
.consent-field a { color: var(--gold-dark); font-weight: 700; text-underline-offset: 2px; }
.consent-field a:hover { text-decoration: underline; }

.preview-panel {
  min-height: 100dvh; padding: 42px clamp(28px, 5vw, 80px) 34px;
  background: radial-gradient(circle at 50% 40%, #fff 0, #f7f3eb 40%, #eee8dc 100%);
  display: flex; flex-direction: column; position: sticky; top: 0; overflow-y: auto;
}
.preview-header { display: flex; justify-content: space-between; align-items: center; }
.live-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); background: rgba(255,255,255,.75); padding: 7px 10px; border-radius: 99px; }
.live-badge i { width: 7px; height: 7px; background: #62a36a; border-radius: 50%; box-shadow: 0 0 0 4px rgba(98,163,106,.14); }
.bag-stage { flex: 1; min-height: 900px; display: grid; place-items: center; padding: 22px 0; }
.bag-canvas {
  width: min(48vw, 680px, calc(100% - 24px)); aspect-ratio: 1088 / 1451; position: relative;
  filter: drop-shadow(0 25px 30px rgba(39,31,18,.2)); transition: transform .35s ease;
}
.bag-canvas:hover { transform: translateY(-3px) scale(1.006); }
.bag-image { display: block; width: 100%; height: 100%; object-fit: contain; }

/* Jediná pozicovaná oblast kopíruje prázdnou horní část fyzické etikety.
   Její vnitřní prvky se skládají výhradně Flexboxem. */
.custom-label {
  position: absolute; left: 29.4%; top: 25.6%; width: 41.8%; height: 33%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  gap: 1.6%; padding: 2.5% 6% 1.5%; overflow: hidden; text-align: center; color: #2a2926;
}
.label-title {
  flex: 1 1 20%; width: 100%; min-height: 0; max-height: 20%; display: flex; align-items: center; justify-content: center;
  font-family: "Playfair Display", Georgia, serif; font-size: clamp(13px, 1.7vw, 23px); font-weight: 700;
  line-height: 1.05; overflow-wrap: anywhere; overflow: hidden;
}
.photo-frame {
  flex: 0 0 auto; width: 82%; max-width: 180px; aspect-ratio: 1;
  border: 2px solid transparent; border-radius: 8px;
  overflow: hidden; background: transparent;
}
.photo-frame.has-photo { border-color: #eee9de; }
.photo-frame img {
  width: 100%; height: 100%; object-fit: cover; display: none;
  filter: grayscale(1) contrast(1.04); transition: filter .2s ease;
}
.photo-frame.has-photo img { display: block; }
.label-subtitle {
  flex: 1 1 14%; width: 100%; min-height: 0; max-height: 14%; display: flex; align-items: center; justify-content: center;
  font-size: clamp(8px, .9vw, 12px); line-height: 1.2; overflow-wrap: anywhere; overflow: hidden;
}
.flavor-pill {
  flex: 0 0 auto; max-width: 100%; padding: 2.5% 8%; border-radius: 99px;
  background: #24221f; color: #fff; font-size: clamp(6px, .65vw, 9px); font-weight: 700; letter-spacing: .15em;
}

.order-summary {
  display: grid; grid-template-columns: 1fr 1fr 1.25fr; align-items: center;
  padding: 17px 20px; border-radius: 16px; background: rgba(255,255,255,.82); box-shadow: 0 12px 35px rgba(58,44,20,.08);
}
.order-summary > div { padding: 0 17px; border-right: 1px solid var(--line); }
.order-summary > div:first-child { padding-left: 0; }
.order-summary > div:last-child { border: 0; padding-right: 0; }
.order-summary span, .order-summary strong { display: block; }
.order-summary span { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.order-summary strong { font-size: 15px; }
.order-summary .total strong { color: var(--gold-dark); font-size: 22px; }
.primary-button {
  width: 100%; margin-top: 12px; border: 0; border-radius: 13px; padding: 15px 18px;
  background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; transition: .22s ease;
}
.primary-button:hover { background: var(--gold-dark); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(128,96,34,.22); }
.primary-button:disabled { cursor: wait; opacity: .72; transform: none; box-shadow: none; }
.primary-button.sent { cursor: default; opacity: 1; background: #47724d; }
.primary-button span { float: right; transition: transform .2s ease; }
.primary-button:hover span { transform: translateX(4px); }
.order-note { max-width: 680px; margin: 9px auto 0; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
.order-note.success { color: #47724d; font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 5; transform: translate(-50%, 20px);
  opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 10px; background: #211f1b; color: #fff;
  box-shadow: var(--shadow); transition: .25s ease; font-size: 13px;
}
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .app-shell { display: flex; flex-direction: column; }
  .config-panel { order: 1; overflow: visible; padding: 28px 20px 42px; }
  .preview-panel { order: 2; position: static; min-height: auto; padding: 32px 20px; }
  .bag-stage { min-height: 0; padding: 24px 0; }
  .bag-canvas { width: min(88vw, 520px); }
  .label-title { font-size: clamp(13px, 4vw, 23px); }
  .label-subtitle { font-size: clamp(8px, 2.2vw, 12px); }
  .flavor-pill { font-size: clamp(6px, 1.6vw, 9px); }
}

@media (max-width: 520px) {
  .choice-grid, .contact-grid { grid-template-columns: 1fr; }
  .contact-grid .full { grid-column: auto; }
  .quantity-grid { grid-template-columns: repeat(4, 1fr); }
  .order-summary { padding: 14px 10px; }
  .order-summary > div { padding: 0 9px; }
  .order-summary .total strong { font-size: 18px; }
  .preview-header h2 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
