:root {
  --beige: #D8BDA0;
  --beige-2: #E9DCCB;
  --bg: #F5EFE7;
  --dark: #333333;
  --ink: #26221e;
  --muted: #776c61;
  --orange: #F08242;
  --orange-ink: #D9692A;
  --line: #E6DACB;
  --white: #ffffff;
  --ok: #2f7d4f;
  --err: #c0392b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(51, 40, 30, .04), 0 8px 24px rgba(51, 40, 30, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; -webkit-appearance: none; appearance: none; }

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }

/* ── Header ── */
.top {
  background: var(--white);
  border-top: 3px solid var(--orange);
  box-shadow: 0 1px 0 var(--line);
}
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo img { height: 38px; width: auto; display: block; }
.divider { width: 1px; height: 30px; background: var(--line); flex: none; }
.app-name {
  font-size: 11px; font-weight: 600; line-height: 1.3; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.site {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--dark); text-decoration: none;
  padding: 8px 14px; border-radius: 999px; background: var(--bg);
  transition: background .15s;
}
.site svg { width: 14px; height: 14px; stroke-width: 2.2; }
.site:hover { background: var(--beige-2); }

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
  gap: 40px;
  padding-block: 32px 56px;
  align-items: start;
}
.preview-col { position: sticky; top: 24px; min-width: 0; }
.form-col { min-width: 0; }

/* ── Preview ── */
.stage {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--beige);
  box-shadow: 0 2px 6px rgba(51, 40, 30, .08), 0 24px 48px rgba(51, 40, 30, .14);
  max-width: 600px;
  margin-inline: auto;
}
#poster { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; touch-action: none; }
#poster.draggable { cursor: grab; }
#poster.dragging { cursor: grabbing; }

.pager { display: flex; align-items: center; gap: 8px; }
.nav {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; flex: none;
  display: grid; place-items: center; padding: 0;
  background: var(--white); color: var(--dark); border: 1.5px solid var(--line);
  transition: transform .1s, border-color .15s;
}
.nav svg { width: 18px; height: 18px; stroke-width: 2.4; }
.nav:hover { border-color: var(--dark); }
.nav:active { transform: scale(.92); }

.hint {
  position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  background: rgba(38, 34, 30, .82); color: var(--white); font-size: 12px; font-weight: 500;
  padding: 7px 12px; border-radius: 999px; pointer-events: none;
  transition: opacity .3s;
}
.hint svg { width: 14px; height: 14px; }
.hint.fade { opacity: 0; }

.toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  max-width: 600px; margin: 14px auto 0;
}
.counter { min-width: 104px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.zoom { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Size slider */
.zoom input[type=range] {
  flex: 1; min-width: 0; height: 24px; margin: 0; background: transparent;
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
.zoom input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--orange) var(--fill, 45%), var(--beige-2) var(--fill, 45%));
}
.zoom input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--beige-2); }
.zoom input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--orange); }
.zoom input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%;
  background: var(--white); border: 2px solid var(--orange); box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
.zoom input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--white); border: 2px solid var(--orange); box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
.zoom-label { display: none; }
/* Inside the photo card (big screens) */
#zoomSlot .zoom {
  flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
}
#zoomSlot .zoom-label { display: block; flex-basis: 100%; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.zoom input[type=range]:focus { outline: none; }
.zoom input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(240, 130, 66, .25); }
.zoom input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(240, 130, 66, .25); }
.zi { width: 20px; height: 20px; color: var(--muted); stroke-width: 1.8; }
.zi.sm { width: 14px; height: 14px; }
.link { background: none; border: 0; color: var(--orange-ink); font-weight: 600; font-size: 13px; cursor: pointer; padding: 6px 4px; }

/* ── Form ── */
.intro h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; font-weight: 700; letter-spacing: -.01em; }
.intro p { margin: 0 0 22px; color: var(--muted); font-size: 15px; line-height: 1.55; }

.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.num {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--dark); color: var(--beige);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}

/* Designs: quote cards, scroll sideways */
.designs {
  display: grid; grid-auto-flow: column; grid-auto-columns: 172px; gap: 10px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 18px;
  margin: 0 -18px; padding: 0 18px 10px;
  scrollbar-width: thin; scrollbar-color: var(--beige) transparent;
}
.design {
  position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden;
  cursor: pointer; background: #9b9790; scroll-snap-align: start;
  aspect-ratio: 480 / 150;
  transition: filter .15s;
}
.design img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Selection ring drawn inside the card so the scroll strip can't clip it */
.design::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  border: 2px solid transparent; transition: border-color .15s;
  pointer-events: none;
}
.design span {
  position: absolute; right: 6px; top: 6px; z-index: 1; font-size: 10px; font-weight: 700; line-height: 1.4;
  background: rgba(38, 34, 30, .78); color: var(--white); padding: 1px 6px; border-radius: 4px;
}
.design:hover { filter: brightness(1.06); }
.design:focus-visible { outline: none; }
.design:focus-visible::after { border-color: var(--dark); }
.design.active::after { border: 3px solid var(--orange); }
.design.active span { background: var(--orange); }

/* Upload */
.upload {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  border: 1.5px dashed #D3BFA6; border-radius: 12px; padding: 12px;
  background: #FBF7F2; transition: border-color .15s, background .15s;
}
.upload:hover, .upload.over { border-color: var(--orange); background: #FFF4EC; }
.upload input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.upload-thumb {
  flex: none; width: 52px; height: 52px; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center; background: var(--beige-2); color: var(--dark);
}
.upload-thumb svg { width: 24px; height: 24px; stroke-width: 1.7; }
.upload-thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--beige); }
.upload-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.upload-text b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-text small { font-size: 12px; color: var(--muted); }
.upload-btn {
  flex: none; font-size: 13px; font-weight: 600; color: var(--white); background: var(--dark);
  padding: 8px 14px; border-radius: 999px;
}
.upload.has-file { border-style: solid; border-color: var(--line); background: var(--white); }
.upload.has-file .upload-btn { background: var(--beige-2); color: var(--dark); }

.status { margin-top: 12px; font-size: 12px; color: var(--muted); }
.bar { height: 5px; border-radius: 3px; background: var(--beige-2); overflow: hidden; margin-bottom: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--orange); transition: width .2s; }
.status.indeterminate .bar i { width: 35%; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* Toggle switch */
.switch { display: flex; align-items: center; gap: 12px; margin-top: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track {
  flex: none; width: 42px; height: 24px; border-radius: 999px; background: #D7CCBF;
  position: relative; transition: background .2s;
}
.track i {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--white); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + .track { background: var(--orange); }
.switch input:checked + .track i { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(240, 130, 66, .3); }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text b { font-size: 14px; font-weight: 600; }
.switch-text small { font-size: 12px; color: var(--muted); }

/* Floating-label fields */
.field { position: relative; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field input {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  padding: 22px 14px 8px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.field label {
  position: absolute; left: 15px; top: 16px; font-size: 15px; color: var(--muted);
  pointer-events: none; transition: all .15s;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label { top: 7px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.field input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 4px rgba(240, 130, 66, .12); }
.field label .opt { font-weight: 400; color: #A0958A; }
.field input:focus + label .opt,
.field input:not(:placeholder-shown) + label .opt { font-weight: 500; }
.field .eg { display: block; font-size: 11px; color: #A0958A; margin: 5px 2px 0; }
.field input.invalid { border-color: var(--err); }
/* Keep a focused field clear of the sticky download bar on phones */
.field input, .upload { scroll-margin-bottom: 190px; scroll-margin-top: 16px; }
.field input.invalid + label { color: var(--err); }

/* Actions */
.actions { margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; cursor: pointer; font-weight: 600; transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; stroke-width: 2.2; }
.btn.primary {
  width: 100%; padding: 16px; font-size: 16px; color: var(--white); background: var(--orange);
  box-shadow: 0 6px 16px rgba(240, 130, 66, .32);
}
.btn.primary:hover { filter: brightness(.96); }
.btn.primary:disabled { opacity: .7; cursor: wait; box-shadow: none; }
.btn.ghost { padding: 8px 12px; font-size: 12px; border-radius: 999px; white-space: nowrap; background: var(--white); color: var(--dark); border: 1.5px solid var(--line); }

.msg {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; line-height: 1.4; margin: 0 0 10px;
  padding: 10px 12px; border-radius: 10px;
}
.msg:empty { display: none; }
.msg.err { color: var(--err); background: #FCEDEB; }
.msg.err::before {
  content: '!'; flex: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--err); color: var(--white); font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.upload.invalid { border-color: var(--err); background: #FDF5F4; }

.done {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #EAF5EE; border-radius: 12px; padding: 8px 8px 8px 12px; margin-bottom: 10px;
}
.done[hidden] { display: none; }
.done-text { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ok); line-height: 1.3; }
.done-text svg { width: 18px; height: 18px; stroke-width: 2.6; flex: none; }
.done-btns { display: flex; gap: 6px; flex: none; }

.fine { font-size: 11px; color: #A0958A; line-height: 1.5; margin: 14px 2px 0; }

/* ── Phone ── */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 16px; padding-bottom: 24px; }
  .preview-col { position: static; }
  .stage { max-width: min(420px, 100%); }
  .toolbar { max-width: min(420px, 100%); flex-direction: column; align-items: stretch; gap: 10px; }
  .pager { justify-content: space-between; }
  .zoom { padding: 0 2px; }
  .intro h1 { font-size: 22px; }
  .intro p { font-size: 14px; margin-bottom: 16px; }
  .card { padding: 16px; }
  .designs { margin: 0 -16px; padding-inline: 16px; scroll-padding: 0 16px; grid-auto-columns: 160px; }
  .top-inner { height: 58px; }
  .logo img { height: 32px; }
  .brand { gap: 12px; }
  .divider { height: 26px; }
  .app-name { font-size: 10px; }
  .site { display: none; }

  /* Download button stays in reach while filling the form */
  .actions {
    position: sticky; bottom: 0; z-index: 5;
    margin: 18px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, rgba(245, 239, 231, 0), var(--bg) 22%);
  }
}
