:root {
  --bg: #f5f5f5;
  --ink: #000;
  --paper: #fff;
  --muted: #6b6b6b;
  --line: #d6d6d6;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --gutter: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); overflow-x: clip; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .04em;
  text-align: center;
  line-height: 1.3;
}
.sub { margin: 6px 0 0; text-align: center; color: var(--muted); }

/* App shell: phone column, centred on wider screens */
.app { max-width: 480px; margin: 0 auto; min-height: 100svh; }
.screen {
  min-height: 100svh;
  padding: calc(env(safe-area-inset-top) + 18px) var(--gutter) calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  animation: enter .35s ease both;
}
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.logo { display: block; height: 22px; width: auto; margin: 0 auto 22px; }

/* Buttons: black with white text */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 50px; padding: 0 16px;
  border: 1px solid var(--ink); border-radius: 0;
  background: var(--ink); color: var(--paper);
  font-size: 13px; font-weight: 600; letter-spacing: .12em;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .3; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); }
.link {
  display: block; margin: 14px auto 0; padding: 6px;
  border: 0; background: none; color: var(--ink);
  font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
.link.light { color: var(--paper); }
.actions { display: grid; gap: 10px; margin-top: auto; padding-top: 20px; }
.status { min-height: 1.4em; margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

/* Hero screens (welcome, share) */
.hero { position: relative; color: var(--paper); background: transparent; }
.hero::before, .hero::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
.hero::before { background: #222 url('assets/bg.webp') center / cover no-repeat; }
.hero::after {
  background: linear-gradient(to bottom, rgba(0,0,0,.25), transparent 25%, transparent 50%, rgba(0,0,0,.6));
}
.hero > * { position: relative; z-index: 1; }
.hero-foot { margin-top: auto; display: grid; gap: 14px; text-align: center; }
.hero .sub { color: rgba(255,255,255,.85); margin: -6px 0 4px; }
.hero .btn { background: var(--ink); border-color: var(--ink); }
.hero .status { color: rgba(255,255,255,.85); }

/* Slider */
.slider {
  display: flex; gap: 14px;
  --slide: min(64vw, 300px);
  margin: 22px calc(-1 * var(--gutter)) 0;
  padding: 14px calc(50% - var(--slide) / 2);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  outline: none;
}
.slider::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 var(--slide);
  padding: 0; border: 0; border-radius: 0;
  scroll-snap-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,.14);
  aspect-ratio: 9 / 16;
  background: #e6e6e6;
  overflow: hidden;
  transform: scale(.9);
  opacity: .55;
  transition: transform .3s ease, opacity .3s ease;
}
.slide.active { transform: scale(1); opacity: 1; }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: background .2s, width .2s; }
.dots span.on { background: var(--ink); width: 18px; border-radius: 3px; }

/* Phone preview with live name */
.phone {
  position: relative;
  width: min(58%, 240px);
  aspect-ratio: 9 / 16;
  margin: 18px auto 0;
  overflow: hidden;
  background: #e6e6e6;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  container-type: inline-size;
}
.phone img { width: 100%; height: 100%; object-fit: cover; display: block; }
.name-layer {
  position: absolute; left: 50%; top: 80%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.phone.result { width: min(70%, 300px); }
.phone.result img { -webkit-touch-callout: default; user-select: auto; }

/* Form */
.form { margin-top: 20px; display: grid; gap: 14px; }
.label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .12em; color: #3a3a3a; }
.form input {
  width: 100%; height: 48px; margin-top: -6px; padding: 0 14px;
  border: 1px solid var(--ink); border-radius: 0; background: var(--paper);
  font-size: 16px; /* 16px stops iOS zooming on focus */
}
.count { margin: -6px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
.field { display: grid; gap: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Options are quiet (outline); only the main action per screen is solid black. */
.seg button {
  height: 48px; border: 1px solid var(--line); background: var(--paper);
  font-size: 15px; font-weight: 500; letter-spacing: 0;
  transition: border-color .15s, background .15s;
}
.seg.fonts button { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 13px; }
.seg.fonts .sample { font-size: 13px; line-height: 1; }
.seg.fonts button[data-font="script"] .sample { font-size: 22px; }
.seg button.on { border-color: var(--ink); background: #ebebeb; }
.swatches button { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 13px; }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid #8a8a8a; }
.dot.black { background: var(--ink); border-color: var(--ink); }
.dot.white { background: var(--paper); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }

/* In-app browser hint */
.inapp {
  margin: 14px 0 0; padding: 12px 14px;
  background: var(--paper); border: 1px solid var(--ink);
  text-align: center; font-size: 13px;
}
.inapp strong { display: block; font-size: 14px; letter-spacing: .04em; margin-bottom: 2px; }
.inapp span { color: var(--muted); }

/* Desktop gate */
.desktop {
  min-height: 100svh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
  padding: 40px var(--gutter); text-align: center;
}
.desktop .logo { height: 34px; margin: 0; }
.desktop p { margin: 0; font-size: 16px; max-width: 280px; }
.qr { width: 200px; height: 200px; background: var(--paper); padding: 10px; }

/* Landscape phones: picture on the left, controls on the right, nothing taller than the screen. */
@media (orientation: landscape) and (max-height: 600px) and (min-width: 600px) {
  .app { max-width: none; }
  .screen {
    min-height: 100svh;
    padding: 14px max(24px, env(safe-area-inset-right)) 14px max(24px, env(safe-area-inset-left));
  }
  .logo { height: 18px; margin-bottom: 10px; }
  h1 { font-size: 16px; }

  #personalize, #preview {
    display: grid;
    grid-template-columns: auto minmax(0, 420px);
    justify-content: center;
    align-content: start;
    column-gap: 40px;
  }
  #personalize > *, #preview > * { grid-column: 2; }
  #personalize > .phone, #preview > .phone {
    grid-column: 1; grid-row: 1 / span 20;
    width: auto; height: calc(100svh - 28px); margin: 0;
  }
  #personalize .form { margin-top: 12px; gap: 10px; }
  #preview .actions { margin-top: 16px; padding-top: 0; }

  .slider {
    --slide: calc((100svh - 150px) * 9 / 16);
    margin-top: 10px; padding: 6px 24px;
    justify-content: safe center;
  }
  .dots { margin-top: 8px; }
  #select .actions, .hero-foot { width: 100%; max-width: 380px; margin-left: auto; margin-right: auto; }
  #select .actions { padding-top: 10px; }
}

/* Landscape while typing: keep the whole wallpaper, shrunk to the space above the keyboard
   (--vvh = visible height, set from visualViewport), pinned beside the field. */
@media (orientation: landscape) and (max-height: 600px) and (min-width: 600px) {
  body.typing #personalize { padding-top: 8px; }
  body.typing #personalize > .logo,
  body.typing #personalize > h1,
  body.typing #personalize > .sub { display: none; }
  body.typing #personalize > .phone {
    height: calc(var(--vvh, 100svh) - 16px);
    position: sticky; top: 8px; align-self: start;
  }
}

.form input:focus, .form input:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--ink); }

body.typing #personalize { padding-bottom: 60vh; }

html.photo, html.photo body { background: #141414; }

@media (prefers-reduced-motion: reduce) {
  .screen, .slide, .btn { animation: none; transition: none; }
}
