:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #5c6275;
  --line: #d8dcea;
  --paper: #fffaf0;
  --panel: #ffffff;
  --accent: #ff3d7f;
  --accent-dark: #0a7fd9;
  --teal: #00b8a9;
  --sun: #ffd23f;
  --coral: #ff6b4a;
  --lime: #73d13d;
  --warn: #ffb703;
  --shadow: rgba(20, 33, 61, 0.18);
  --red: #e11d2a;
  --red-strong: #b00d1a;
  --editor-bg: #101b34;
  --ink-soft: #4a5878;
  --card: #fffdf8;
  --stamp: #d8c6a0;
  --navy: #101b34;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 61, 127, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(10, 127, 217, 0.1) 1px, transparent 1px),
    linear-gradient(135deg, #fff7d6 0%, #e8fbff 38%, #fff0f7 74%, #efffe9 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

button,
input,
textarea {
  font: inherit;
}

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
}

.home-hero {
  position: relative;
  width: min(1120px, 100%);
  min-height: min(760px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.84fr);
  gap: 36px;
  align-items: center;
}

.home-hero::before,
.home-hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.home-hero::before {
  inset: 5% auto auto 48%;
  width: min(44vw, 520px);
  aspect-ratio: 1;
  border: 18px solid rgba(255, 210, 63, 0.72);
  border-radius: 28px;
  transform: rotate(14deg);
}

.home-hero::after {
  right: -10px;
  bottom: 42px;
  width: 300px;
  height: 120px;
  background:
    linear-gradient(90deg, var(--coral), var(--coral)) 0 0 / 100% 16px no-repeat,
    linear-gradient(90deg, var(--teal), var(--teal)) 38px 46px / 78% 16px no-repeat,
    linear-gradient(90deg, var(--accent), var(--accent)) 88px 92px / 60% 16px no-repeat;
  border-radius: 999px;
  transform: rotate(-8deg);
}

.home-copy {
  position: relative;
  z-index: 1;
}

.home-logo {
  width: min(560px, 100%);
  height: auto;
  display: block;
  margin: 0 0 12px;
  filter: drop-shadow(0 18px 22px rgba(20, 33, 61, 0.18));
}

.brand,
.brand-link {
  margin: 0 0 16px;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 0.9;
  letter-spacing: 0;
  text-wrap: balance;
}

.lede {
  max-width: 530px;
  color: #30384f;
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.5;
  font-weight: 720;
}

.primary,
button {
  border: 0;
  border-radius: 8px;
  padding: 12px 17px;
  color: #fff;
  background: var(--red);
  cursor: pointer;
  font-weight: 800;
  box-shadow:
    0 2px 0 var(--red-strong),
    0 10px 20px rgba(225, 29, 42, 0.26);
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: background 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
}

button:hover,
a.primary:hover,
.primary:hover {
  background: var(--red-strong);
}

button:active,
.primary:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 var(--red-strong),
    0 6px 14px rgba(225, 29, 42, 0.22);
}

/* Secondary editor actions (generate, lucky): red outline so the filled red
   primary actions stay dominant. */
.ghost {
  background: #fff;
  color: var(--red);
  border: 2px solid var(--red);
  box-shadow: none;
}

.ghost:hover {
  background: var(--red);
  color: #fff;
}

.cta-wrap {
  position: relative;
  display: inline-block;
  margin-top: 22px;
}

.cta-wrap::before,
.cta-wrap::after {
  content: "♥";
  position: absolute;
  pointer-events: none;
  color: #ff1744;
  font-size: 30px;
  line-height: 1;
  text-shadow:
    -64px -6px 0 #ff5fa2,
    -36px -34px 0 #ff1744,
    28px -38px 0 #ff7a00,
    72px -12px 0 #ff1744,
    42px 42px 0 #ff5fa2;
  filter: drop-shadow(0 0 12px rgba(255, 23, 68, 0.55));
  opacity: 0.92;
}

.cta-wrap::before {
  left: 22px;
  top: -10px;
  transform: rotate(-13deg);
}

.cta-wrap::after {
  right: 18px;
  bottom: -16px;
  color: #ff5fa2;
  font-size: 24px;
  text-shadow:
    -38px 32px 0 #ff1744,
    18px 40px 0 #ff7a00,
    62px 8px 0 #ff1744;
  transform: rotate(12deg);
}

.home-cta {
  position: relative;
  z-index: 1;
  min-height: 74px;
  padding: 20px 34px;
  border: 4px solid #ffffff;
  border-radius: 8px;
  color: #ffffff;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.38), transparent 28%),
    linear-gradient(135deg, #ff1744 0%, #ff3131 48%, #c90020 100%);
  box-shadow:
    0 0 0 7px rgba(255, 23, 68, 0.16),
    0 0 34px rgba(255, 23, 68, 0.78),
    0 18px 38px rgba(201, 0, 32, 0.36);
  font-size: 22px;
  font-weight: 950;
}

.hero-postcard {
  position: relative;
  z-index: 1;
  min-height: 470px;
  padding: 36px;
  border: 8px solid #fff;
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255, 210, 63, 0.9), transparent 36%),
    linear-gradient(150deg, #ffffff 0%, #fff8e8 100%);
  box-shadow: 0 28px 70px var(--shadow);
  transform: rotate(5deg);
}

.hero-postcard::before,
.hero-postcard::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.hero-postcard::before {
  left: -26px;
  top: 52px;
  width: 120px;
  height: 18px;
  background: var(--teal);
  transform: rotate(-18deg);
}

.hero-postcard::after {
  right: 26px;
  bottom: -18px;
  width: 170px;
  height: 18px;
  background: var(--accent);
  transform: rotate(-7deg);
}

.hero-stamp {
  position: absolute;
  right: 30px;
  top: 28px;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 8px dashed #ff3d7f;
  color: #ffffff;
  background: var(--teal);
  font-weight: 950;
}

.hero-photo {
  width: 70%;
  aspect-ratio: 1.16;
  border: 7px solid #fff;
  border-radius: 8px;
  background:
    radial-gradient(circle at 70% 28%, #ffd23f 0 13%, transparent 14%),
    linear-gradient(160deg, #0a7fd9 0 50%, #00b8a9 51% 100%);
  box-shadow: 0 15px 30px rgba(20, 33, 61, 0.18);
  transform: rotate(-7deg);
}

.hero-photo span {
  display: block;
  width: 58%;
  height: 44%;
  margin: 33% 0 0 10%;
  border-radius: 60% 60% 8px 8px;
  background: linear-gradient(135deg, #73d13d, #009f87);
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-lines {
  position: absolute;
  right: 34px;
  top: 150px;
  display: grid;
  gap: 18px;
}

.hero-lines i {
  display: block;
  width: 150px;
  height: 8px;
  border-radius: 999px;
  background: #0a7fd9;
}

.hero-lines i:nth-child(2) {
  width: 120px;
  background: #ff6b4a;
}

.hero-lines i:nth-child(3) {
  width: 165px;
  background: #00b8a9;
}

.hero-postcard strong {
  position: absolute;
  left: 32px;
  right: 32px;
  bottom: 36px;
  color: #ff3d7f;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
  text-wrap: balance;
}

.editor-shell {
  min-height: 100vh;
  display: grid;
  /* Even 50/50 split: editor on the left, preview on the right.
     minmax(0, …) lets each column shrink instead of overflowing on wide content. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  padding: 24px;
  /* One flat, high-contrast backdrop so the white editing panel, the
     off-white postcard preview, and the red buttons all stand out. */
  background: var(--editor-bg);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(20, 33, 61, 0.08);
}

.editor {
  padding: 22px;
  overflow: auto;
}

.minimal-editor {
  display: grid;
  gap: 24px;
  margin-top: 22px;
}

.simple-field {
  display: grid;
  gap: 10px;
}

.simple-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  text-transform: lowercase;
}

.simple-label > span {
  margin-right: auto;
}

.simple-label button {
  min-width: 0;
  padding: 9px 12px;
  white-space: nowrap;
}

.simple-field textarea {
  min-height: 120px;
}

.simple-field textarea[name="address_text"] {
  min-height: 140px;
}

.quiet-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* "X / N generations used" budget hint under the front prompt. */
.gen-counter {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.gen-counter.maxed {
  color: var(--red);
}

.hidden-field,
.hidden-controls {
  display: none;
}

/* Example/placeholder text shown in empty back-message and address fields.
   Greyed + italic so it reads as a sample, not real content; cleared on focus. */
.simple-field textarea.is-example {
  color: var(--muted);
  font-style: italic;
}

.editor-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.next {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 900;
}

.editor-actions .quiet-status {
  text-align: center;
}

.progress {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 18px 0 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.progress i {
  height: 2px;
  background: var(--line);
}

.progress span {
  white-space: nowrap;
}

.progress .active {
  color: var(--accent-dark);
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  color: #3f4442;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

.file-input input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.camera-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.camera-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111;
  object-fit: cover;
}

.file-input span {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed #aab3af;
  border-radius: 6px;
  color: var(--accent-dark);
  background: #f7faf8;
}

.grid {
  display: grid;
  gap: 10px;
}

.two {
  grid-template-columns: 1fr 120px;
}

.three {
  grid-template-columns: 1fr 80px 110px;
}

.send-step p {
  color: var(--muted);
}

.send-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.subtle-link a {
  color: var(--accent-dark);
  font-weight: 850;
}

.preview-wrap {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto 1fr 1fr;
  gap: 14px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.postcard {
  position: relative;
  min-height: 0;
  aspect-ratio: 6 / 4;
  width: min(100%, 850px);
  border: 1px solid #cdd5d1;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(32, 33, 36, 0.12);
  overflow: hidden;
}

.front img {
  width: 100%;
  height: 100%;
  /* Show the entire image rather than cropping. `fill` stretches to the 6:4
     postcard aspect, which matches what the xelatex render does with
     `keepaspectratio=false` — so the preview lines up with the printed PDF. */
  object-fit: fill;
  display: block;
}

.front.generating img,
.front.generating .empty-image {
  filter: saturate(0.78) brightness(0.72);
}

.front.generating::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  top: calc(50% - 30px);
  width: 56px;
  height: 56px;
  border: 6px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-right-color: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(255, 61, 127, 0.48);
  transform: translate(-50%, -50%);
  animation: postcard-spin 0.82s linear infinite;
}

.front.generating::after {
  content: "Generating postcard...";
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 84px;
  color: #fff;
  background:
    radial-gradient(circle at center, rgba(255, 61, 127, 0.34), transparent 34%),
    rgba(20, 33, 61, 0.62);
  font-size: clamp(18px, 2.6vw, 30px);
  font-weight: 950;
  text-align: center;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

@keyframes postcard-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .front.generating::before {
    animation: none;
  }
}

.empty-image {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(15, 139, 112, 0.1), rgba(242, 184, 75, 0.18)),
    var(--paper);
}

/* Image-generation failure shown over the front preview, with red letters on a
   contrasting panel so it's clear the front prompt needs to change. */
.front-error {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 26px;
  text-align: center;
  color: var(--red);
  background: rgba(255, 255, 255, 0.96);
  border: 3px solid var(--red);
  border-radius: 8px;
}

.front-error-title {
  font-size: clamp(18px, 2.6vw, 28px);
  font-weight: 950;
  letter-spacing: -0.01em;
}

.front-error-detail {
  max-width: 36ch;
  color: #7a1018;
  font-size: clamp(13px, 1.5vw, 16px);
  font-weight: 700;
  line-height: 1.4;
}

/* The front textarea flashes red when its prompt was the reason generation
   failed, so the fix is unmistakable. */
textarea.prompt-rejected {
  border-color: var(--red);
  animation: prompt-flash 1s ease-in-out infinite;
}

@keyframes prompt-flash {
  0%,
  100% {
    border-color: var(--red);
    box-shadow: 0 0 0 0 rgba(225, 29, 42, 0);
  }
  50% {
    border-color: #ff6b75;
    box-shadow: 0 0 0 3px rgba(225, 29, 42, 0.38);
  }
}

@media (prefers-reduced-motion: reduce) {
  textarea.prompt-rejected {
    animation: none;
    box-shadow: 0 0 0 2px rgba(225, 29, 42, 0.45);
  }
}

.back {
  display: grid;
  grid-template-columns: 1fr 1px 0.82fr;
  gap: 28px;
  padding: 34px;
}

.message {
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: clamp(15px, 1.8vw, 22px);
}

.divider {
  background: #c9d1cd;
}

address {
  align-self: center;
  font-style: normal;
  line-height: 1.6;
  color: #2f3432;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .home {
    place-items: start center;
  }

  .home-hero {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .home-hero::before {
    inset: 14% -70px auto auto;
    width: 300px;
    border-width: 12px;
  }

  .home-hero::after {
    right: -110px;
    bottom: 28%;
  }

  .hero-postcard {
    min-height: 390px;
    transform: rotate(2deg);
  }

  .editor-shell {
    grid-template-columns: 1fr;
  }

  .preview-wrap {
    position: static;
    height: auto;
  }
}

@media (max-width: 560px) {
  .editor-shell,
  .home {
    padding: 12px;
  }

  .editor {
    padding: 18px;
  }

  .home-logo {
    width: min(100%, 440px);
  }

  h1 {
    font-size: clamp(38px, 13vw, 56px);
  }

  .home-cta {
    width: 100%;
  }

  .hero-postcard {
    min-height: 320px;
    padding: 22px;
    border-width: 6px;
  }

  .hero-stamp {
    right: 18px;
    top: 18px;
    width: 72px;
    height: 72px;
    border-width: 6px;
  }

  .hero-photo {
    width: 72%;
    border-width: 5px;
  }

  .hero-lines {
    right: 20px;
    top: 114px;
    gap: 13px;
  }

  .hero-lines i {
    width: 105px;
    height: 7px;
  }

  .hero-lines i:nth-child(2) {
    width: 86px;
  }

  .hero-lines i:nth-child(3) {
    width: 115px;
  }

  .hero-postcard strong {
    left: 22px;
    right: 22px;
    bottom: 26px;
  }

  .two,
  .three {
    grid-template-columns: 1fr;
  }

  .back {
    gap: 14px;
    padding: 20px;
  }
}

/* ===== Admin page (/a) ===== */
.admin-shell {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.admin-header {
  display: flex;
  align-items: baseline;
  gap: 24px;
  margin-bottom: 20px;
}
.admin-header h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
}
.admin-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 16px;
}
.admin-empty {
  color: var(--muted);
  padding: 40px 0;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e9e7;
  vertical-align: top;
}
.admin-table th {
  font-weight: 700;
  color: var(--muted);
  background: #f5f7f6;
  position: sticky;
  top: 0;
}
.admin-thumb img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.admin-id code {
  font-size: 12px;
  color: var(--muted);
}
.admin-msg,
.admin-addr {
  max-width: 280px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.admin-ts {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.admin-links {
  white-space: nowrap;
  font-size: 12px;
}
.admin-placeholder {
  color: var(--muted);
}

/* ============================================================
   Wizard editor (single-view maker). Everything is scoped under
   .card-editor so the global button/panel rules can't pollute it,
   and it can't leak onto the home page. Replaces the old split editor.
   ============================================================ */
.card-editor {
  height: 100vh; height: 100dvh; width: 100vw;
  display: flex; flex-direction: column; overflow: hidden;
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(22,34,61,0.05) 1px, transparent 0),
    radial-gradient(1200px 600px at 8% -10%, rgba(255,200,61,0.18), transparent 60%),
    radial-gradient(1100px 700px at 108% 0%, rgba(15,174,158,0.12), transparent 55%);
  background-size: 22px 22px, auto, auto;
}

.card-editor .app-header { flex: none; padding: 14px clamp(18px,4vw,48px) 12px; border-bottom: 1px solid var(--line); background: rgba(255,253,248,0.86); backdrop-filter: blur(6px); }
.card-editor .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-editor .brand { font-family: "Fraunces", serif; font-weight: 900; font-size: 21px; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }
.card-editor .brand b { color: var(--red); }
.card-editor .stamp { display: grid; place-items: center; width: 46px; height: 52px; color: var(--ink); background: repeating-linear-gradient(0deg, transparent 0 6px, rgba(255,255,255,.6) 6px 7px), var(--stamp); border: 2px dashed #b9a577; border-radius: 4px; transform: rotate(6deg); font-family: "Fraunces", serif; font-weight: 900; font-size: 11px; line-height: 1; text-align: center; }
.card-editor .stamp span { font-size: 8px; letter-spacing: .08em; }

.card-editor .stepper { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); max-width: 860px; margin: 0 auto; }
.card-editor .stepper::before { content: ""; position: absolute; top: 16px; left: 8%; right: 8%; height: 3px; background: var(--line); border-radius: 3px; }
.card-editor .stepper-fill { position: absolute; top: 16px; left: 8%; height: 3px; background: linear-gradient(90deg, var(--red), var(--red-strong)); border-radius: 3px; transition: width .45s cubic-bezier(.5,.1,.2,1); }
.card-editor .step { position: relative; z-index: 1; display: grid; justify-items: center; gap: 6px; background: none; border: 0; box-shadow: none; cursor: pointer; padding: 0; font: inherit; color: var(--ink-soft); }
.card-editor .step:hover { background: none; }
.card-editor .step:disabled { cursor: not-allowed; opacity: .5; }
.card-editor .dot { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--card); border: 3px solid var(--line); font-weight: 800; font-size: 13px; color: var(--ink-soft); transition: transform .25s, border-color .25s, background .25s, color .25s; }
.card-editor .step .label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.card-editor .step.is-done .dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.card-editor .step.is-current .dot { background: var(--red); border-color: var(--red); color: #fff; transform: scale(1.12); box-shadow: 0 8px 16px rgba(225,29,42,.32); }
.card-editor .step.is-current .label { color: var(--ink); }

.card-editor .app-main { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; overflow: hidden; padding: clamp(14px,2.4vh,26px) clamp(18px,4vw,48px); }
.card-editor .content { width: min(1080px, 100%); height: 100%; }
.card-editor .panel { display: none; height: 100%; flex-direction: column; min-height: 0; animation: wz-fade .35s ease both; background: none; border: 0; box-shadow: none; padding: 0; }
.card-editor .panel.active { display: flex; }
@keyframes wz-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card-editor .head { flex: none; margin-bottom: 12px; }
.card-editor .head h2 { font-family: "Fraunces", serif; font-weight: 900; font-size: clamp(22px,3.4vw,32px); line-height: 1.02; margin: 0; letter-spacing: -0.015em; }
.card-editor .head .sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }
.card-editor .body { flex: 1 1 auto; min-height: 0; }
.card-editor .form-narrow { max-width: 640px; }

.card-editor label.field { display: grid; gap: 6px; margin-bottom: 12px; }
.card-editor .field-name { font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); }
.card-editor input[type=text], .card-editor textarea { width: 100%; font: inherit; color: var(--ink); background: #fffefb; border: 1.5px solid var(--line); border-radius: 11px; padding: 11px 13px; transition: border-color .15s, box-shadow .15s; }
.card-editor textarea { resize: none; line-height: 1.5; }
.card-editor input:focus, .card-editor textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px rgba(225,29,42,.12); }

.card-editor .front-body { display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; }
.card-editor .picture { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; border-radius: 14px; overflow: hidden; border: 1.5px solid var(--line); background: repeating-linear-gradient(45deg, #f4ead4 0 12px, #f0e4ca 12px 24px); display: grid; place-items: center; }
.card-editor .picture img { width: 100%; height: 100%; object-fit: fill; display: block; }
.card-editor .picture .empty { text-align: center; color: #a08f6b; font-weight: 700; }
.card-editor .picture .empty .big { font-family: "Fraunces", serif; font-size: 26px; color: #b6a47c; display: block; margin-bottom: 4px; }
.card-editor .picture.is-busy::after { content: "generating…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(16,27,52,.62); color: #fff; font-weight: 800; backdrop-filter: blur(2px); }
.card-editor .picture.is-busy .spin { position: absolute; z-index: 2; top: calc(50% - 30px); left: 50%; width: 38px; height: 38px; margin-left: -19px; border: 5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: wz-spin .8s linear infinite; }
@keyframes wz-spin { to { transform: rotate(360deg); } }
.card-editor .camera-preview { width: 100%; max-height: 38vh; aspect-ratio: 16/9; border-radius: 12px; border: 1.5px solid var(--line); background: #111; object-fit: cover; flex: none; }
.card-editor .front-controls { flex: none; display: grid; gap: 10px; }
.card-editor .btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.card-editor .counter { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.card-editor .quiet-status { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }

.card-editor .btn { font: inherit; font-weight: 800; border: 0; border-radius: 11px; padding: 11px 18px; cursor: pointer; color: #fff; background: var(--red); box-shadow: 0 2px 0 var(--red-strong), 0 8px 16px rgba(225,29,42,.22); transition: transform .06s, background .14s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.card-editor .btn:hover { background: var(--red-strong); }
.card-editor .btn:active { transform: translateY(1px); }
.card-editor .btn.ghost { background: #fff; color: var(--red); border: 2px solid var(--red); box-shadow: none; }
.card-editor .btn.ghost:hover { background: var(--red); color: #fff; }
.card-editor .btn.subtle { background: rgba(255,255,255,.12); color: #fff; border: 1.5px solid rgba(255,255,255,.5); box-shadow: none; font-weight: 700; }
.card-editor .btn.subtle:hover { background: rgba(255,255,255,.22); }
.card-editor .btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }

.card-editor .preview-grid { display: grid; grid-template-columns: 1.5fr 0.85fr; gap: clamp(16px,2.4vw,30px); height: 100%; min-height: 0; }
.card-editor .pv-stack { display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; align-items: center; justify-content: center; }
.card-editor .pv-card { aspect-ratio: 3/2; max-height: calc(50% - 6px); width: auto; max-width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid #d9cdb4; background: #fffaf0; box-shadow: 0 14px 30px rgba(28,22,12,.16); }
.card-editor .pv-card.front img, .card-editor .pv-card.front .empty { width: 100%; height: 100%; }
.card-editor .pv-card.front img { object-fit: fill; display: block; }
.card-editor .pv-card.front .empty { display: grid; place-items: center; color: #b6a47c; font-weight: 700; background: repeating-linear-gradient(45deg,#f4ead4 0 12px,#f0e4ca 12px 24px); }
.card-editor .pv-card.back { display: grid; grid-template-columns: 1.1fr 1px .9fr; gap: 4%; padding: 4%; }
.card-editor .pv-card.back .msg { white-space: pre-wrap; overflow: hidden; line-height: 1.4; font-size: clamp(11px,1.4vw,16px); font-family: "Fraunces", serif; color: #25324d; }
.card-editor .pv-card.back .rule { background: #d9cdb4; }
.card-editor .pv-card.back .addr { align-self: center; white-space: pre-wrap; line-height: 1.45; font-size: clamp(10px,1.2vw,14px); color: #2c3a57; }
.card-editor .pv-card.back .addr .stamp-sq { width: 34px; height: 40px; float: right; margin: 0 0 4px 6px; border: 2px dashed #c2ad80; border-radius: 3px; background: repeating-linear-gradient(0deg,transparent 0 5px,rgba(0,0,0,.04) 5px 6px), #efe3c8; }
.card-editor .ph { color: #a99; font-style: italic; opacity: .7; }
.card-editor .status-col { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.card-editor .status-col h3 { margin: 0; font-family: "Fraunces", serif; font-size: 18px; }
.card-editor .check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; border: 1.5px solid var(--line); background: #fffefb; box-shadow: none; font-weight: 700; font-size: 13.5px; cursor: pointer; text-align: left; width: 100%; color: var(--ink); }
.card-editor .check:hover { background: #fffefb; }
.card-editor .check .mark { width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: #fff; }
.card-editor .check.ok { border-color: rgba(15,174,158,.5); background: rgba(15,174,158,.08); }
.card-editor .check.ok .mark { background: var(--teal); }
.card-editor .check.bad { border-color: rgba(225,29,42,.45); background: rgba(225,29,42,.06); }
.card-editor .check.bad .mark { background: var(--red); }
.card-editor .check .hint { margin-left: auto; font-weight: 700; font-size: 12px; color: var(--ink-soft); }

.card-editor .center-col { height: 100%; display: grid; place-items: center; }
.card-editor .pay-card { width: min(460px,100%); border: 1.5px dashed var(--line); border-radius: 16px; padding: 24px; background: #fffefb; display: grid; gap: 14px; }
.card-editor .pay-row { display: flex; justify-content: space-between; align-items: baseline; }
.card-editor .pay-row .price { font-family: "Fraunces", serif; font-weight: 900; font-size: 34px; }
.card-editor .muted { color: var(--ink-soft); font-size: 14px; }
.card-editor .sent { text-align: center; }
.card-editor .sent .plane { font-size: 56px; animation: wz-fly 1.4s ease-in-out infinite alternate; display: inline-block; }
.card-editor .sent h2 { font-family: "Fraunces", serif; font-size: 32px; margin: 10px 0 6px; }
@keyframes wz-fly { from { transform: translate(-6px,2px) rotate(-4deg); } to { transform: translate(6px,-6px) rotate(4deg); } }

.card-editor .app-footer { flex: none; display: flex; align-items: center; gap: 16px; padding: 14px clamp(18px,4vw,48px); background: var(--navy); color: #fff; box-shadow: 0 -10px 30px rgba(16,27,52,.18); }
.card-editor .app-footer .note { font-size: 12.5px; font-weight: 700; color: #ffd7da; }
.card-editor .app-footer .spacer { flex: 1; }
.card-editor .app-footer .next-big { font-size: 16px; padding: 13px 24px; }

@media (max-width: 620px) {
  .card-editor .step .label { display: none; }
  .card-editor .preview-grid { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .card-editor .pv-card.back { grid-template-columns: 1fr; }
  .card-editor .pv-card.back .rule { display: none; }
}

/* The wizard's .btn/display rules override the `hidden` attribute's default
   display:none; restore it so hidden controls (camera capture, file input,
   camera preview) stay hidden until activated. */
.card-editor [hidden] { display: none !important; }

/* Structured address steps (to/from): scrollable column + city/state/zip row. */
.card-editor .addr-scroll { height: 100%; min-height: 0; overflow: auto; display: grid; gap: 10px; align-content: start; padding-right: 6px; }
.card-editor .addr-scroll label.field { margin: 0; }
.card-editor .addr-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
