/* ============================================================
   Customizer Layout & Components
   ============================================================ */

/* --- Split-Pane Layout --- */
.customizer {
  display: flex;
  min-height: calc(100vh - 57px);
}

.preview-pane {
  flex: 0 0 58%;
  background: #1a1714;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  gap: var(--space-lg);
  /* Stick to viewport while form scrolls */
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  /* Gallery wall: a warm spotlight lifts the area right behind the frame so a
     black molding reads clearly against it, then falls to a soft dark vignette
     at the edges — premium and lit, not muddy or flat-dark. */
  background:
    radial-gradient(ellipse 88% 74% at 50% 40%,
      rgba(140, 125, 108, 0.56) 0%,
      rgba(108, 95, 80, 0.30) 45%,
      transparent 78%),
    linear-gradient(168deg, #2f2820 0%, #1c1712 80%);
}

.form-pane {
  flex: 0 0 42%;
  background: var(--color-surface);
  padding: var(--space-2xl) var(--space-xl);
  border-left: 1px solid var(--color-border);
}

/* The stage holds the frame + zoom/swap controls. On desktop it's a passive
   column wrapper (spacing identical to before). On mobile it becomes the ONLY
   pinned element, so the selectors beneath it can scroll away and the form
   stays reachable. */
.preview-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  width: 100%;
}

/* Short desktop viewports: the frame + selectors can outgrow the fixed-height
   sticky pane, stranding the frame chooser below the fold with no way to reach
   it (the pane itself never scrolled). Top-align and let the pane scroll
   internally; tall viewports keep the centered gallery look. */
@media (min-width: 1025px) and (max-height: 950px) {
  .preview-pane {
    justify-content: flex-start;
    overflow-y: auto;
  }
}

/* "Scroll to choose your frame" — sits under the preview controls (last child
   of the stage's column) until the chooser has actually been seen
   (customizer.js dissolves it via IntersectionObserver). */
.frame-scroll-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: calc(-1 * var(--space-sm));
  padding: 6px 14px;
  background: rgba(20, 16, 12, 0.78);
  border: 1px solid rgba(196, 168, 130, 0.55);
  border-radius: 999px;
  color: #FAF8F5;
  font-family: var(--font-body);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  z-index: 22;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.frame-scroll-hint.dismissed { opacity: 0; pointer-events: none; }
.frame-scroll-hint-chev {
  font-size: 0.9rem;
  line-height: 1;
  color: #C4A882;
  animation: frame-hint-bob 1.6s ease-in-out infinite;
}
@keyframes frame-hint-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

/* ============================================================
   CSS FRAME RENDERING – Matted frame around canvas panels
   ============================================================ */

.frame-preview {
  --frame-width: 18px;
  --mat-padding: 22px;
  --panel-gap: 3px;
  /* Fill the preview pane instead of floating small in it. The frame grows to
     whichever is smaller: a hard width cap, or the height the pane can spare
     once the controls/selectors below take their share (the 320px reserve) —
     scaled by the frame's real aspect ratio (--frame-ar, set per size/layout
     in preview.js) so a tall portrait never overflows the viewport. Mobile
     media queries below override this with a small fixed cap. */
  max-width: min(900px, calc((100vh - 57px - 300px) * var(--frame-ar, 1.27)));
  width: 100%;
  border-radius: 2px;
  position: relative;
}

/* Glass reflection – subtle diagonal shine across the entire framed piece */
.frame-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  border-radius: 2px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.02) 30%,
    transparent 55%,
    transparent 80%,
    rgba(255, 255, 255, 0.015) 100%
  );
}

.frame-preview .frame-border {
  padding: var(--frame-width);
  border-radius: 2px;
  position: relative;
}

.frame-preview .mat-board {
  padding: var(--mat-padding);
}

.preview-panels {
  display: grid;
  gap: var(--panel-gap);
  position: relative;
  /* Default 2-panel side-by-side (JS overrides via inline styles) */
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "photo tribute";
  aspect-ratio: 5 / 3.2;
}

.panel {
  overflow: hidden;
  position: relative;
  min-width: 0;
  min-height: 0;
}

.panel-photo { grid-area: photo; }
.panel-tribute { grid-area: tribute; }
.panel-panel2 { grid-area: panel2; }

/* Single mat-opening bevel – one continuous 45-degree cut around the entire print.
   Real WHCC mats have a single opening; the composite print shows through it. */
.preview-panels::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  /* Top/left darker (shadow side), bottom/right lighter (mat core catching light) */
  border-top: 3px solid rgba(0, 0, 0, 0.45);
  border-left: 3px solid rgba(0, 0, 0, 0.3);
  border-bottom: 3px solid rgba(200, 185, 155, 0.35);
  border-right: 3px solid rgba(200, 185, 155, 0.25);
  box-shadow:
    inset 0 6px 14px -4px rgba(0, 0, 0, 0.35),
    inset 5px 0 10px -4px rgba(0, 0, 0, 0.18),
    inset 0 -5px 10px -4px rgba(200, 185, 155, 0.12),
    inset -4px 0 8px -4px rgba(200, 185, 155, 0.06);
}

.panel canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── On-photo reposition affordance ─────────────────────────────
   Signals that an uploaded photo can be dragged + zoomed, right on the
   photo (the cue used to live buried in the form pane). */
/* Empty photo panel reads as a click target that opens the uploader. */
.panel-photo:not(.is-adjustable),
.panel-photo:not(.is-adjustable) canvas { cursor: pointer; }
.panel.is-adjustable,
.panel.is-adjustable canvas { cursor: grab; }
.panel.is-adjustable.dragging,
.panel.is-adjustable.dragging canvas { cursor: grabbing; }

/* Fading "Drag to reposition" pill, centered near the bottom of the photo. */
.photo-adjust-hint {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 60px);   /* never runs under the zoom buttons */
  padding: 4px 10px;
  background: rgba(20, 16, 12, 0.72);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.66rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border-radius: 999px;
  pointer-events: none;      /* never blocks the drag */
  z-index: 8;
  opacity: 1;
  transition: opacity 0.55s ease;
}
.photo-adjust-hint.dismissed { opacity: 0; }
.photo-adjust-ico { font-size: 0.85rem; line-height: 1; opacity: 0.9; }

/* +/- zoom buttons, bottom-right corner — kept off the pet's face (usually
   centered/upper), diagonally opposite the drag hint so they never overlap. */
.photo-zoom-ctrl {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 9;
}
.photo-zoom-ctrl button {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: rgba(20, 16, 12, 0.66);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.photo-zoom-ctrl button:hover { background: rgba(20, 16, 12, 0.9); }
.photo-zoom-ctrl button:active { transform: translateY(1px); }

/* ============================================================
   DIVIDER HANDLES – Draggable resize between panels
   ============================================================ */

.divider-handle {
  position: absolute;
  z-index: 10;
  background: transparent;
}

.divider-handle.col {
  cursor: col-resize;
  width: 12px;
  top: 0;
  bottom: 0;
  margin-left: -6px;
}

.divider-handle.row {
  cursor: row-resize;
  height: 12px;
  left: 0;
  right: 0;
  margin-top: -6px;
}

/* Gold line on hover */
.divider-handle::after {
  content: '';
  position: absolute;
  background: rgba(200, 160, 80, 0);
  transition: background 0.15s;
  border-radius: 1px;
}

.divider-handle.col::after {
  width: 2px;
  top: 10%;
  bottom: 10%;
  left: 50%;
  margin-left: -1px;
}

.divider-handle.row::after {
  height: 2px;
  left: 10%;
  right: 10%;
  top: 50%;
  margin-top: -1px;
}

.divider-handle:hover::after {
  background: rgba(200, 160, 80, 0.6);
}

.divider-handle.dragging::after {
  background: rgba(200, 160, 80, 0.9);
}

/* Touch devices: hide the resize handles entirely. Dragging a thin divider on
   the small mobile preview is impractical, and the always-visible treatment
   painted a gold bar straight across the artwork — a poor first impression of
   the product. The Landscape/Portrait presets cover layout on touch; fine
   photo/poem resizing stays a desktop (hover) nicety. */
@media (hover: none) {
  .divider-handle { display: none; }
}

/* ============================================================
   THIRD PANEL CONTROLS
   ============================================================ */

.add-panel-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: #9B9590;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.add-panel-btn:hover {
  color: var(--color-warm);
  border-color: rgba(200, 160, 80, 0.3);
  background: rgba(200, 160, 80, 0.08);
}

.add-panel-btn .icon {
  font-size: 0.9rem;
}

/* ============================================================
   LAYOUT ICON THUMBNAILS – CSS Grid mini-layouts
   ============================================================ */

/* 3-panel layout icons use CSS Grid */
.layout-option-grid {
  display: grid;
  gap: 1.5px;         /* thin cream gap reads as a mat line between panels */
  padding: 0;         /* the frame is the border; paper fills to the edge */
}

.layout-option-grid .layout-icon-block {
  min-height: 0;
  min-width: 0;
}

/* Photo block – a warm grey plate, like a photo sitting on the paper */
.layout-option-grid .layout-icon-photo {
  background: #cfc7ba;
}

/* Tribute block – cream paper carrying faint horizontal "text" lines so the
   thumbnail clearly reads as photo + poem (our differentiator), not two boxes */
.layout-option-grid .layout-icon-tribute {
  background-color: #FAF7F2;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(20, 16, 12, 0.42) 0, rgba(20, 16, 12, 0.42) 1px,
    transparent 1px, transparent 4px
  );
  background-position: center;
  background-size: 62% 100%;
  background-repeat: no-repeat;
}

/* Second photo block (3-panel layouts) – a lighter plate */
.layout-option-grid .layout-icon-panel2 {
  background: #ded7cc;
}

/* --- Classic Dark Theme --- */
.frame-preview.theme-classic-dark .frame-border {
  background: linear-gradient(145deg, #232323, #2e2e2e 15%, #101010 40%, #1c1c1c 70%, #0a0a0a);
  box-shadow:
    /* Wall-mount depth – frame floats on the wall */
    0 10px 45px rgba(0, 0, 0, 0.55),
    0 3px 15px rgba(0, 0, 0, 0.35),
    /* Top/left edge catching light */
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 1px 0 0 rgba(255, 255, 255, 0.05),
    /* Bottom/right inner depth */
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    inset -1px 0 0 rgba(0, 0, 0, 0.2);
}
.frame-preview.theme-classic-dark .mat-board {
  background: #0a0908;
  border: 1px solid #181410;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 -1px 0 rgba(255, 255, 255, 0.03);
}
.frame-preview.theme-classic-dark .preview-panels {
  background: #0a0908;
}

/* --- Auto Theme: the pet tribute in the customer's chosen frame ---
   A real picture-frame look: uniform molding on all four sides whose width
   SCALES with the print size and the frame's real face width. The width comes
   from --frame-width (face / (print + 2·face), set per size in preview.js),
   so an 8x10 reads chunky (~9%) and a 20x30 reads slim (~3%), and a 3" ornate
   signature frame reads far wider than the 0.875" standard — exactly as they
   print. The molding gradient is set inline from the chosen frame's `molding`.
   The photo + poem sit on light paper recessed into the frame (rabbet). */
.frame-preview.theme-auto .frame-border {
  padding: 0;
  border-radius: 2px;
  position: relative;
  /* Photographic frame via 9-slice border-image (real mitered corners + wood
     grain, generated in /images/frames). border-image needs a px border width,
     so --fw-px is computed from the rendered size in preview.js (updateFrameWidthPx)
     and recomputed on resize; --frame-tex + --frame-fallback are set per chosen
     frame in setFrame(). If the image fails to load, the solid fallback shows. */
  border-style: solid;
  border-color: var(--frame-fallback, #2a2a2a);
  border-width: var(--fw-px, 22px);
  border-image-source: var(--frame-tex, none);
  border-image-slice: 46;
  border-image-repeat: round;
  box-shadow:
    0 14px 46px rgba(0, 0, 0, 0.42),
    0 4px 14px rgba(0, 0, 0, 0.28);
  transition: border-width 0.35s ease;
}
/* Frameless products: no molding at all. */
.frame-preview.no-frame.theme-auto .frame-border {
  border-width: 0;
  border-image: none;
  box-shadow: none;
}
/* Rabbet: the print sits recessed behind the frame face, so the molding casts
   a soft shadow onto the print's top and left edges. A directional inset
   shadow on the paper itself sells the recess and aligns on any aspect ratio
   (unlike a %-inset ring, whose top/side percentages resolve differently). */
.frame-preview.theme-auto .mat-board {
  margin: 0;
  padding: 4px;
  background: #FAF7F2;
  box-shadow:
    inset 0 4px 9px -2px rgba(0, 0, 0, 0.34),
    inset 4px 0 9px -2px rgba(0, 0, 0, 0.2),
    inset 0 -2px 5px -2px rgba(255, 255, 255, 0.35),
    inset -2px 0 5px -2px rgba(255, 255, 255, 0.22);
}
.frame-preview.theme-auto .preview-panels {
  background: #FAF7F2;
}
.frame-preview.theme-auto .preview-panels::before { content: none; }
.frame-preview.theme-auto .panel { box-shadow: none; }

/* --- Frameless (print-only / digital keepsake) ---
   No frame ships with these products, so the preview shows the bare print:
   paper edge and a soft lift off the wall, no molding, no engraved rails. */
.frame-preview.no-frame .frame-border {
  background: none;
  box-shadow: none;
}
.frame-preview.no-frame.theme-auto .frame-name,
.frame-preview.no-frame.theme-auto .frame-dates {
  display: none;
}
.frame-preview.no-frame.theme-auto .mat-board {
  margin: 0;
  box-shadow:
    0 10px 35px rgba(0, 0, 0, 0.28),
    0 2px 10px rgba(0, 0, 0, 0.16);
}

/* Engraved-symbol picker (none / paw / heart) */
.icon-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: var(--space-sm, 0.75rem);
  flex-wrap: wrap;
}
.icon-picker-label {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--color-muted, #8a8378);
  text-transform: uppercase;
}
.icon-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 38px;
  height: 32px;
  padding: 0 0.7rem;
  border: 1px solid #ddd6cc;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  color: #4a4038;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.icon-opt svg { width: 16px; height: 16px; fill: currentColor; }
.icon-opt:hover { border-color: var(--color-warm, #C4A882); }
.icon-opt.active {
  border-color: var(--color-warm, #C4A882);
  background: #faf6ee;
  box-shadow: 0 0 0 1px rgba(196, 168, 130, 0.35);
}

/* Custom color override (frame + engraving) */
.swatch-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.4rem;
}
.swatch-custom-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--color-muted, #8a8378);
  cursor: pointer;
}
.swatch-custom-item input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  border: 1px solid #ddd6cc;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: none;
}
.swatch-custom-item input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch-custom-item input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.swatch-custom-item input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }

/* --- Swatch Row (auto-matched colors with override) --- */
.style-selector.swatch-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: var(--space-sm, 0.75rem);
}
.swatch-row-label {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--color-muted, #8a8378);
  text-transform: uppercase;
}
.swatch-row-items {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.swatch-chip {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.swatch-chip:hover {
  transform: scale(1.12);
}
.swatch-chip.active {
  border-color: var(--color-warm, #C4A882);
  box-shadow: 0 0 0 2px rgba(196, 168, 130, 0.35);
}
.swatch-chip.auto {
  width: auto;
  height: 32px;
  border-radius: 16px;
  padding: 0 0.8rem;
  font-size: 0.78rem;
  background: transparent;
  color: var(--color-muted, #8a8378);
}
.swatch-chip.auto.active {
  color: var(--color-warm, #C4A882);
}

/* --- Warm Natural Theme --- */
.frame-preview.theme-warm-natural .frame-border {
  background: linear-gradient(145deg, #b8956a, #c9a87c 15%, #a0804f 40%, #c4a06d 70%, #96783f);
  box-shadow:
    0 10px 45px rgba(0, 0, 0, 0.3),
    0 3px 15px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 1px 0 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    inset -1px 0 0 rgba(0, 0, 0, 0.1);
}
.frame-preview.theme-warm-natural .mat-board {
  background: #F5EDE0;
  border: 1px solid #E0D8CC;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.12),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5);
}
.frame-preview.theme-warm-natural .preview-panels {
  background: #E8DDD0;
}
/* Warm mat-opening bevel – cream mat with white core */
.frame-preview.theme-warm-natural .preview-panels::before {
  border-top-color: rgba(0, 0, 0, 0.12);
  border-left-color: rgba(0, 0, 0, 0.08);
  border-bottom-color: rgba(255, 255, 255, 0.55);
  border-right-color: rgba(255, 255, 255, 0.4);
  box-shadow:
    inset 0 6px 12px -4px rgba(0, 0, 0, 0.1),
    inset 5px 0 10px -4px rgba(0, 0, 0, 0.05),
    inset 0 -5px 10px -4px rgba(255, 255, 255, 0.35),
    inset -4px 0 8px -4px rgba(255, 255, 255, 0.18);
}

/* --- Soft Light Theme --- */
.frame-preview.theme-soft-light .frame-border {
  background: linear-gradient(145deg, #e8e4e0, #f0ece8 15%, #d8d4d0 40%, #ece8e4 70%, #d0ccc8);
  box-shadow:
    0 10px 45px rgba(0, 0, 0, 0.14),
    0 3px 15px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 1px 0 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    inset -1px 0 0 rgba(0, 0, 0, 0.04);
}
.frame-preview.theme-soft-light .mat-board {
  background: #FFFFFF;
  border: 1px solid #ebe8e4;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.05),
    inset 0 -1px 0 rgba(255, 255, 255, 0.8);
}
.frame-preview.theme-soft-light .preview-panels {
  background: #EDEBE8;
}
/* Light mat-opening bevel – white mat, ultra-subtle */
.frame-preview.theme-soft-light .preview-panels::before {
  border-top-color: rgba(0, 0, 0, 0.07);
  border-left-color: rgba(0, 0, 0, 0.04);
  border-bottom-color: rgba(255, 255, 255, 0.7);
  border-right-color: rgba(255, 255, 255, 0.5);
  box-shadow:
    inset 0 6px 12px -4px rgba(0, 0, 0, 0.05),
    inset 5px 0 10px -4px rgba(0, 0, 0, 0.025),
    inset 0 -5px 10px -4px rgba(255, 255, 255, 0.4),
    inset -4px 0 8px -4px rgba(255, 255, 255, 0.2);
}

/* ============================================================
   STYLE VARIANT SELECTOR – 3 clickable frame thumbnails
   ============================================================ */

/* ============================================================
   LAYOUT SELECTOR – Horizontal vs Vertical toggle
   ============================================================ */

.layout-selector {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  align-items: flex-end;     /* frames of different heights share a baseline */
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

/* Each thumbnail is a miniature of the real framed piece: a dark molding
   border around cream paper, sized to the layout's true orientation by
   inline width/height (see layoutIconBoxStyle). Landscape reads wide, portrait
   reads tall — the shape carries the choice. */
.layout-option {
  box-sizing: border-box;
  border: 3px solid #1c1c1c;
  border-radius: 2px;
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
  background: #FAF7F2;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.layout-option:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.5);
}

.layout-option.active {
  box-shadow:
    0 0 0 2px var(--color-warm),
    0 4px 10px rgba(0, 0, 0, 0.45);
}

/* Horizontal icon – two side-by-side boxes */
.layout-option-horizontal .layout-icon-block {
  flex: 1;
  height: 100%;
  border-radius: 2px;
}

.layout-option-horizontal .layout-icon-block:first-child {
  background: rgba(255, 255, 255, 0.25);
}

.layout-option-horizontal .layout-icon-block:last-child {
  background: rgba(196, 168, 130, 0.35);
}

/* Vertical icon – two stacked boxes */
.layout-option-vertical {
  flex-direction: column;
}

.layout-option-vertical .layout-icon-block {
  width: 100%;
  flex: 1;
  border-radius: 2px;
}

.layout-option-vertical .layout-icon-block:first-child {
  background: rgba(255, 255, 255, 0.25);
}

.layout-option-vertical .layout-icon-block:last-child {
  background: rgba(196, 168, 130, 0.35);
}

.layout-label {
  font-size: 0.65rem;
  color: #9B9590;
  text-align: center;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

/* ============================================================
   PHOTO SWAP + PANEL TOGGLE ACTIONS
   ============================================================ */

.panel-toggle-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.swap-photos-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.82rem;
  background: transparent;
  color: var(--color-warm);
  border: 1px solid rgba(196, 168, 130, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.swap-photos-btn:hover {
  background: rgba(196, 168, 130, 0.1);
  border-color: var(--color-warm);
}

.swap-photos-btn .icon {
  font-size: 1.1em;
}

/* ============================================================
   STYLE VARIANT SELECTOR
   ============================================================ */

.style-selector {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

.style-thumb {
  width: 64px;
  height: 50px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.style-thumb:hover {
  transform: scale(1.05);
}

.style-thumb.active {
  border-color: var(--color-warm);
}

.style-thumb-inner {
  width: 52px;
  height: 38px;
  border-radius: 2px;
  overflow: hidden;
}

/* Thumb: Classic Dark */
.style-thumb-dark .style-thumb-inner {
  background: linear-gradient(145deg, #232323, #0a0a0a);
  display: flex;
  padding: 3px;
}
.style-thumb-dark .style-thumb-inner::before {
  content: '';
  flex: 1;
  background: #1a1a1a;
  margin: 2px;
}

/* Thumb: Warm Natural */
.style-thumb-warm .style-thumb-inner {
  background: linear-gradient(145deg, #b8956a, #96783f);
  display: flex;
  padding: 3px;
}
.style-thumb-warm .style-thumb-inner::before {
  content: '';
  flex: 1;
  background: #F5EDE0;
  margin: 2px;
}

/* Thumb: Soft Light */
.style-thumb-light .style-thumb-inner {
  background: linear-gradient(145deg, #e8e4e0, #d0ccc8);
  display: flex;
  padding: 3px;
}
.style-thumb-light .style-thumb-inner::before {
  content: '';
  flex: 1;
  background: #FFFFFF;
  margin: 2px;
}

.style-thumb-label {
  position: absolute;
  bottom: -16px;
  font-size: 0.6rem;
  color: #9B9590;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* ============================================================
   UPLOAD ZONE
   ============================================================ */

.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--color-bg);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-warm);
  background: rgba(196, 168, 130, 0.04);
}

.upload-zone-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.upload-zone-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--color-primary);
  margin-bottom: var(--space-xs);
}

.upload-zone-hint {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.upload-zone input[type="file"] {
  display: none;
}

/* Uploaded photo preview */
.upload-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.upload-preview img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.upload-preview-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upload-replace-btn {
  font-size: 0.8rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

.quality-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}
.quality-badge.excellent { background: var(--color-success); color: #fff; }
.quality-badge.good { background: var(--color-secondary); color: #fff; }
.quality-badge.usable { background: var(--color-warm); color: #fff; }
.quality-badge.low { background: var(--color-error); color: #fff; }

.quality-message {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: var(--space-sm);
  font-style: italic;
}

.photo-assurance {
  font-size: 0.8rem;
  color: var(--color-warm);
  margin-top: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.crop-hint {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: var(--space-sm);
  text-align: center;
  font-style: italic;
}

/* ============================================================
   FORM FIELDS – Guided emotional flow
   ============================================================ */

.form-section {
  margin-bottom: var(--space-2xl);
}

.form-section-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--color-primary);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.form-intro {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--color-primary);
  text-align: center;
  padding: var(--space-md) 0 var(--space-lg);
  line-height: 1.4;
}

.form-intro span {
  color: var(--color-muted);
  font-size: 1rem;
  display: block;
  margin-top: var(--space-sm);
}

/* --- Gift / Self toggle --- */
.order-type-toggle {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-2xl);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.order-type-option {
  flex: 1;
  padding: 0.75rem 1rem;
  text-align: center;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-muted);
  background: var(--color-bg);
  border: none;
  transition: all 0.2s;
}

.order-type-option:first-child {
  border-right: 1px solid var(--color-border);
}

.order-type-option.active {
  background: var(--color-warm);
  color: #fff;
}

.order-type-option:not(.active):hover {
  background: rgba(196, 168, 130, 0.08);
  color: var(--color-primary);
}

.order-type-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: calc(-1 * var(--space-lg));
  margin-bottom: var(--space-xl);
  font-style: italic;
}

.field-group {
  margin-bottom: var(--space-xl);
}

.field-group label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
  color: var(--color-primary);
}

.field-group .sublabel {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: var(--space-sm);
}

.field-group input[type="text"],
.field-group textarea,
.field-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-primary);
  background: var(--color-bg);
  transition: border-color 0.2s;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--color-warm);
  box-shadow: 0 0 0 3px rgba(196, 168, 130, 0.15);
}

.field-group textarea {
  resize: vertical;
  min-height: 80px;
}

.char-count {
  font-size: 0.8rem;
  color: var(--color-muted);
  text-align: right;
  margin-top: var(--space-xs);
}

.field-error {
  font-size: 0.85rem;
  color: var(--color-error);
  margin-top: var(--space-xs);
}

/* ============================================================
   POEM GENERATION – The climax moment
   ============================================================ */

.poem-climax {
  text-align: center;
  padding: var(--space-xl) 0;
}

.poem-climax h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--color-primary);
  margin-bottom: var(--space-lg);
}

.poem-generate-btn {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  background: var(--color-warm);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.poem-generate-btn:hover {
  background: #b89a74;
}

.poem-generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.poem-result {
  margin-top: var(--space-xl);
  padding: var(--space-xl);
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.poem-result-text {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-primary);
  white-space: pre-line;
  text-align: center;
  margin-bottom: var(--space-lg);
}

.poem-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

.poem-actions button {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  transition: all 0.2s;
}

.poem-regenerate-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-primary);
}
.poem-regenerate-btn:hover {
  border-color: var(--color-warm);
  color: var(--color-warm);
}

.poem-edit-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-primary);
}

.poem-edit-textarea {
  width: 100%;
  min-height: 180px;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-primary);
  resize: vertical;
  margin-bottom: var(--space-md);
}

.poem-library-link {
  color: var(--color-muted);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-body);
}

/* Poem library modal */
.poem-library-panel {
  margin-top: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.poem-library-panel select {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 1rem;
}

.poem-library-preview {
  padding: var(--space-md);
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--color-muted);
  white-space: pre-line;
  max-height: 200px;
  overflow-y: auto;
}

.regen-count {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: var(--space-sm);
}

/* --- Poem version tabs --- */
.poem-version-tabs {
  display: flex;
  gap: var(--space-xs);
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.poem-version-tab {
  padding: 0.35rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.poem-version-tab:hover {
  border-color: var(--color-warm);
  color: var(--color-warm);
}

.poem-version-tab.active {
  background: var(--color-warm);
  border-color: var(--color-warm);
  color: #fff;
}

/* --- Gift-mode detail note --- */
.gift-detail-note {
  font-size: 0.9rem;
  color: var(--color-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  background: rgba(196, 168, 130, 0.06);
  border-radius: var(--radius);
  border: 1px solid rgba(196, 168, 130, 0.12);
}

/* --- Gift note assist --- */
.gift-note-assist {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-xs);
}

.gift-note-assist-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--color-accent, #B8975E);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.gift-note-assist-btn:hover { opacity: 0.8; }

.gift-note-assist-btn:disabled {
  opacity: 0.5;
  cursor: default;
  text-decoration: none;
}

.gift-note-assist-status {
  font-size: 0.85rem;
  color: var(--color-muted);
  font-style: italic;
}

/* --- Animated poem reveal --- */
.poem-generating {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
}

/* The waiting line cross-fades between honest status messages (customizer.js
   toggles .fading around the swap) instead of snapping to new copy. */
.poem-generating-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--color-muted);
  margin-bottom: var(--space-lg);
  transition: opacity 0.4s ease;
}

.poem-generating-text.fading { opacity: 0; }

.poem-generating-dots {
  display: inline-flex;
  gap: 6px;
}

.poem-generating-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-warm);
  animation: poemDotPulse 1.4s ease-in-out infinite;
}

.poem-generating-dots span:nth-child(2) { animation-delay: 0.2s; }
.poem-generating-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes poemDotPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Each line rises and settles rather than popping in. The long ease-out tail
   is the point: the line arrives quickly, then comes to rest slowly, which
   reads as writing rather than loading. Duration is mirrored by
   REVEAL_LINE_DURATION in customizer.js — change both together. */
.poem-result-text .poem-line {
  display: block;
  opacity: 0;
  transform: translateY(10px);
  animation: poemLineReveal 1s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@keyframes poemLineReveal {
  to { opacity: 1; transform: translateY(0); }
}

/* The afterglow — one quiet line under the finished tribute naming where the
   words came from. Deliberately smaller and softer than the poem: it should
   be noticed a second after the poem is read, not alongside it. */
.poem-afterglow {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--color-muted);
  text-align: center;
  margin: calc(-1 * var(--space-sm)) 0 var(--space-lg);
  animation: poemAfterglowIn 1.1s ease forwards;
}

@keyframes poemAfterglowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Someone who has asked their OS for less motion is often asking for a reason.
   The poem still arrives — it just arrives whole, without drift or pulse. */
@media (prefers-reduced-motion: reduce) {
  .poem-result-text .poem-line {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .poem-afterglow { animation: none; }
  .poem-generating-dots span { animation: none; opacity: 0.55; }
}

/* ============================================================
   PRODUCT SELECTOR
   ============================================================ */

.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}

.product-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.product-option:hover {
  border-color: var(--color-warm);
}

.product-option.selected {
  border-color: var(--color-warm);
  background: rgba(196, 168, 130, 0.05);
}

.product-option-label {
  font-weight: 600;
}

.product-option-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: var(--color-warm);
  color: #fff;
  border-radius: 4px;
  margin-left: var(--space-sm);
}

.product-option-price {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* Secondary line under a product label ("ready for your own frame", …) */
.product-option-sublabel {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--color-muted, #8a8378);
  line-height: 1.35;
  margin-top: 2px;
}

/* Quiet tier: the unframed rungs sit below the framed sizes, deliberately
   understated — available, never advertised. */
.product-grid-divider {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted, #8a8378);
  margin: var(--space-sm, 0.75rem) 0 0;
}

.product-option-quiet {
  opacity: 0.85;
  padding: calc(var(--space-md) * 0.7) var(--space-md);
}

.product-option-quiet .product-option-label {
  font-weight: 500;
  font-size: 0.95em;
}

.product-option-quiet .product-option-price {
  font-size: 1rem;
}

.product-option-quiet.selected {
  opacity: 1;
}

/* --- Poem readability note ---------------------------------
   Sits under the size chooser, where the fix is one click away. Deliberately
   the same voice and visual weight as .quality-message on the photo: quiet
   italic aside, never a warning box, never anything that colours the page
   red. The firmer tier only darkens the ink a little. */
.poem-fit-note {
  margin-top: var(--space-md);
  animation: poem-fit-note-in 500ms ease both;
}

.poem-fit-note[hidden] {
  display: none;
}

.poem-fit-note-text {
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--color-muted);
  font-style: italic;
  margin: 0;
}

.poem-fit-note.is-firm .poem-fit-note-text {
  color: var(--color-primary);
}

.poem-fit-note-action {
  display: inline-block;
  margin-top: var(--space-sm);
  padding: 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-warm);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--color-warm);
  cursor: pointer;
}

.poem-fit-note-action:hover {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

@keyframes poem-fit-note-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .poem-fit-note { animation: none; }
}

/* ============================================================
   CART ACTION
   ============================================================ */

.cart-action {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-xl);
}

.cart-action .btn {
  width: 100%;
}

/* Reassurance at the moment of payment — the strongest risk-reversal messages
   ride right alongside the button, where checkout anxiety peaks. */
.checkout-reassurance {
  list-style: none;
  margin: var(--space-md) 0 var(--space-sm);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.checkout-reassurance li {
  position: relative;
  padding-left: 1.6rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-primary);
}

.checkout-reassurance li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--color-success);
  font-weight: 700;
}

.checkout-securely {
  text-align: center;
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--color-muted);
}

/* ============================================================
   MOBILE: Stacked layout with sticky preview
   ============================================================ */

@media (max-width: 1024px) {
  .customizer {
    flex-direction: column;
    /* Dark canvas behind the promoted preview + selectors (see display:contents
       below); the form pane paints its own light surface over its region. */
    background: #1a1714;
  }

  /* The live preview must float the whole way down the form so you watch the
     tribute build as you type. Promote it out of its short pane
     (display:contents) so the sticky stage pins relative to the entire
     customizer column, not just the preview region. Not while zoomed — the
     fullscreen reader needs a real positioned box. */
  .preview-pane:not(.zoomed) {
    display: contents;
  }

  .preview-stage {
    position: sticky;
    top: 57px; /* matches .site-header height — a larger value opens a gap */
    z-index: 21;
    width: 100%;
    background: #1a1714;
    padding: var(--space-md) var(--space-md) var(--space-sm);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    transition: padding 0.25s ease;
  }

  /* Bigger by default at the top of the flow (the preview was too small)… */
  .frame-preview {
    --frame-width: 12px;
    --mat-padding: 14px;
    max-width: 340px;
    transition: max-width 0.25s ease;
  }

  /* …then shrink to a compact live thumbnail once you scroll into the form, so
     the tribute stays visible without stealing the form's screen. Toggled by
     initMobilePreviewPin() in customizer.js. */
  .preview-stage.mini {
    padding: 6px var(--space-md);
  }
  .preview-stage.mini .frame-preview { max-width: 150px; }
  .preview-stage.mini .preview-controls { display: none; }
  /* On the tiny pinned thumbnail the on-photo drag hint + zoom buttons are
     clutter you can't meaningfully use — hide them until the preview is full. */
  .preview-stage.mini .photo-adjust-hint,
  .preview-stage.mini .photo-zoom-ctrl { display: none; }
  /* Once the user is scrolling, the scroll hint has done its job. */
  .preview-stage.mini .frame-scroll-hint { display: none; }

  /* Focused inputs scroll to just below the pinned preview, never behind it. */
  html { scroll-padding-top: 210px; }

  /* Thinner molding on small screens so the frame stays compact in the sticky pane. */
  .frame-preview.theme-auto {
    --molding: 24px;
  }

  .form-pane {
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--color-border);
    padding: var(--space-xl) var(--space-md);
  }

  .style-selector {
    gap: var(--space-sm);
  }

  .style-thumb {
    width: 48px;
    height: 38px;
  }

  .style-thumb-inner {
    width: 40px;
    height: 30px;
  }

  .style-thumb-label {
    display: none;
  }

  /* Size is set inline per orientation (layoutIconBoxStyle); keep the frame
     border here so the thumbnails stay legible as framed minis on mobile. */

  .divider-handle.col {
    width: 24px;
    margin-left: -12px;
  }

  .divider-handle.row {
    height: 24px;
    margin-top: -12px;
  }

  .add-panel-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }

  /* Prevent iOS zoom on form focus */
  .field-group input[type="text"],
  .field-group textarea,
  .field-group select {
    font-size: 16px;
  }
}

/* Small mobile (375px and below) */
@media (max-width: 480px) {
  .preview-pane {
    padding: 0 0 var(--space-sm);
  }

  .preview-stage {
    padding: var(--space-sm) var(--space-sm) var(--space-xs);
  }

  .frame-preview {
    --frame-width: 8px;
    --mat-padding: 10px;
    max-width: 300px;
  }
  .preview-stage.mini .frame-preview { max-width: 132px; }

  .frame-preview.theme-auto {
    --molding: 18px;
  }

  .form-pane {
    padding: var(--space-md) var(--space-sm);
  }

  .form-section-title {
    font-size: 1.15rem;
  }

  .poem-generate-btn {
    font-size: 1rem;
    padding: 0.85rem 1.5rem;
  }
}

/* ── Preview zoom (magnifier for small tribute text) ─────────── */
.preview-zoom-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(26, 23, 20, 0.85);
  color: #FAF8F5;
  font-size: 0.85rem;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.preview-zoom-btn:hover { background: rgba(255, 255, 255, 0.12); }
.preview-pane.zoomed {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: block;
  max-width: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 56px 16px 80px;
  background: rgba(18, 15, 13, 0.98);
}
/* In fullscreen zoom the stage stops pinning so the enlarged frame scrolls. */
.preview-pane.zoomed .preview-stage {
  position: static;
  width: auto;
  background: none;
  box-shadow: none;
  padding: 0;
}
.preview-pane.zoomed .frame-preview {
  width: 175%;
  max-width: 1500px;
  margin: 0 auto;
}
.preview-pane.zoomed .layout-selector,
.preview-pane.zoomed .style-selector,
.preview-pane.zoomed #panel-toggle-wrap { display: none; }
/* When zoomed to READ, only the Close button is pinned top-right. The swap
   button shares the .preview-zoom-btn class, so it must be hidden here —
   otherwise it stacks exactly on Close and traps the viewer (can't exit). */
.preview-pane.zoomed #poem-flip-btn { display: none; }
.preview-pane.zoomed #preview-zoom-btn {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 1001;
}
body.preview-zoom-open { overflow: hidden; }
@media (max-width: 900px) {
  .preview-pane.zoomed .frame-preview { width: 220%; }
}

/* ── Frame selector ───────────────────────────────────────────── */
.frame-selector { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.frame-group-label {
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-muted); margin-bottom: 7px;
}
.frame-group-up { color: var(--color-accent, #C4A882); font-weight: 600; letter-spacing: 0; text-transform: none; }
.frame-group-note {
  font-size: 0.8rem; line-height: 1.5; color: var(--color-muted);
  margin: -2px 0 9px; max-width: 46ch;
}
.frame-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.frame-chip {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.03);
  border-radius: 999px; padding: 5px 12px 5px 6px; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.frame-chip:hover { border-color: rgba(255,255,255,0.35); }
.frame-chip.active { border-color: var(--color-accent, #C4A882); background: rgba(196,168,130,0.12); }
.frame-chip-sw {
  width: 20px; height: 20px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), 0 1px 3px rgba(0,0,0,0.4);
  flex: 0 0 auto;
}
.frame-chip-label { font-size: 0.85rem; color: var(--color-text, #FAF8F5); white-space: nowrap; }

/* ── Preview controls row (zoom + poem flip) ──────────────────── */
.preview-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.preview-zoom-btn.active { border-color: var(--color-accent, #C4A882); background: rgba(196,168,130,0.14); }

/* ============================================================
   PROOF APPROVAL — the last look before payment
   ============================================================
   The customer's real, watermarked proof, shown large enough to actually
   read, with one tick that sends it to print. Visual language follows the
   tribute lightbox in store.css (.tl-*): a softly lit gallery, warm gold
   accents, the piece itself carrying the light.
   ------------------------------------------------------------ */

/* --- Waiting on the proof (inline, beside the purchase button) --- */
.proof-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin: var(--space-md) 0 0;
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-muted);
}
.proof-note[hidden] { display: none; }
.proof-note.is-error { color: var(--color-error, #C47070); }

/* A spinner inside the purchase button, so it never reads as dead. */
.btn.is-preparing::before {
  content: "";
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pf-spin 0.8s linear infinite;
}
.btn.is-preparing:disabled { opacity: 0.85; cursor: progress; }

@keyframes pf-spin { to { transform: rotate(360deg); } }

/* --- Backdrop --- */
body.pf-open { overflow: hidden; }

.pf-root {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0px, 2vw, 32px);
  background:
    radial-gradient(120% 90% at 50% 30%, rgba(66, 56, 44, 0.5) 0%, rgba(15, 13, 11, 0.95) 62%),
    rgba(15, 13, 11, 0.97);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  overscroll-behavior: contain;
  opacity: 0;
  transition: opacity 0.24s ease;
}
.pf-root.is-open { opacity: 1; }
.pf-root[hidden] { display: none; }

/* --- Dialog shell --- */
.pf-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1040px;
  max-height: 100%;
  min-height: 0;
  background: var(--color-dark-surface, #1a1714);
  border: 1px solid rgba(196, 168, 130, 0.22);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  outline: none;
  transform: translateY(14px) scale(0.985);
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.pf-root.is-open .pf-dialog { transform: none; }
.pf-dialog:focus-visible {
  outline: 2px solid rgba(196, 168, 130, 0.6);
  outline-offset: -4px;
}

/* --- Close (keep editing) --- */
.pf-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 17, 14, 0.75);
  border: 1px solid rgba(196, 168, 130, 0.32);
  border-radius: 50%;
  color: #EDE7DF;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.pf-close:hover {
  background: rgba(196, 168, 130, 0.18);
  border-color: rgba(196, 168, 130, 0.65);
  color: #fff;
}
.pf-close:focus-visible {
  outline: 2px solid var(--color-warm, #C4A882);
  outline-offset: 3px;
}
.pf-close:disabled { opacity: 0.4; cursor: default; }
.pf-close .pf-x { font-family: var(--font-body); font-size: 1.6rem; line-height: 1; margin-top: -2px; }

/* --- Scrolling body (heading + the proof itself) --- */
.pf-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: clamp(var(--space-lg), 4vw, var(--space-2xl)) clamp(var(--space-md), 3vw, var(--space-2xl)) var(--space-md);
}

.pf-head {
  max-width: 60ch;
  margin: 0 auto clamp(var(--space-md), 2.4vw, var(--space-lg));
  text-align: center;
  padding-right: 44px;
  padding-left: 44px;
}
.pf-eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-warm, #C4A882);
  margin: 0 0 var(--space-xs);
}
.pf-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.45rem, 4.6vw, 2.05rem);
  line-height: 1.2;
  color: #F6F1E9;
  margin: 0 0 var(--space-sm);
}
.pf-lede {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.65;
  color: rgba(246, 241, 233, 0.72);
  margin: 0;
}

/* --- The proof --- */
.pf-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.32);
}
.pf-img {
  display: block;
  max-width: 100%;
  max-height: 74vh;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  cursor: zoom-in;
}
.pf-img:not([src]) { visibility: hidden; min-height: 200px; }

/* Zoomed: the proof spills wider than the frame and the frame scrolls, so
   the poem can be read at a comfortable size even on a 375px phone. */
.pf-frame.is-zoomed { align-items: flex-start; justify-content: flex-start; }
.pf-frame.is-zoomed .pf-img {
  max-width: none;
  max-height: none;
  width: 215%;
  cursor: zoom-out;
}
@media (min-width: 900px) {
  .pf-frame.is-zoomed .pf-img { width: 150%; }
}

.pf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: rgba(246, 241, 233, 0.7);
}
.pf-loading[hidden] { display: none; }
.pf-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(196, 168, 130, 0.35);
  border-top-color: var(--color-warm, #C4A882);
  border-radius: 50%;
  animation: pf-spin 0.9s linear infinite;
}

.pf-tools { display: flex; justify-content: center; margin-top: var(--space-md); }
.pf-zoom {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(196, 168, 130, 0.35);
  border-radius: 999px;
  color: #EDE7DF;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.pf-zoom:hover { background: rgba(196, 168, 130, 0.16); border-color: rgba(196, 168, 130, 0.6); }
.pf-zoom:focus-visible { outline: 2px solid var(--color-warm, #C4A882); outline-offset: 3px; }
.pf-zoom[aria-pressed="true"] { background: rgba(196, 168, 130, 0.16); }

/* --- The approval (always visible, never scrolls away) --- */
.pf-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: clamp(var(--space-md), 2.6vw, var(--space-lg)) clamp(var(--space-md), 3vw, var(--space-xl));
  border-top: 1px solid rgba(196, 168, 130, 0.2);
  background: rgba(15, 13, 11, 0.94);
}

.pf-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  cursor: pointer;
}
.pf-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--color-warm, #C4A882);
  cursor: pointer;
}
.pf-check input[type="checkbox"]:disabled { cursor: default; opacity: 0.5; }
.pf-check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-warm, #C4A882);
  outline-offset: 3px;
}
.pf-check-text {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.45;
  color: #F2ECE3;
}

/* Plain fact, quietly said — not a warning. */
.pf-final {
  margin: var(--space-sm) 0 0;
  padding-left: calc(22px + var(--space-md));
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(242, 236, 227, 0.62);
  max-width: 68ch;
}

.pf-actions { display: flex; flex-direction: column; gap: var(--space-sm); }

.pf-confirm {
  order: 1;
  background: var(--color-warm, #C4A882);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 16px 24px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.pf-confirm:hover:not(:disabled) { background: #b89a74; }
.pf-confirm:disabled {
  background: rgba(196, 168, 130, 0.2);
  color: rgba(242, 236, 227, 0.55);
  cursor: not-allowed;
}
.pf-confirm:focus-visible { outline: 2px solid var(--color-warm, #C4A882); outline-offset: 3px; }
.pf-confirm.is-busy { cursor: progress; }

.pf-back {
  order: 2;
  background: transparent;
  border: 1px solid rgba(196, 168, 130, 0.35);
  border-radius: var(--radius);
  color: rgba(242, 236, 227, 0.85);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 13px 22px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.pf-back:hover { border-color: rgba(196, 168, 130, 0.7); color: #fff; background: rgba(196, 168, 130, 0.1); }
.pf-back:focus-visible { outline: 2px solid var(--color-warm, #C4A882); outline-offset: 3px; }
.pf-back:disabled { opacity: 0.45; cursor: default; }

.pf-nudge {
  order: 3;
  margin: 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.4;
  color: rgba(242, 236, 227, 0.5);
}
.pf-nudge[hidden] { display: none; }

.pf-status {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 clamp(var(--space-md), 3vw, var(--space-xl)) var(--space-md);
  background: rgba(15, 13, 11, 0.94);
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.5;
  color: rgba(242, 236, 227, 0.62);
}
.pf-status:empty { display: none; }
.pf-status.is-error { color: #E7B4A5; }

/* --- Roomier viewports: the approval sits in one calm row --- */
@media (min-width: 860px) {
  .pf-foot {
    flex-direction: row;
    align-items: center;
    gap: var(--space-xl);
  }
  .pf-approve { flex: 1 1 auto; min-width: 0; }
  .pf-actions { flex: 0 0 auto; width: min(320px, 40vw); }
}

/* --- Phones: the proof gets the whole screen --- */
@media (max-width: 640px) {
  .pf-root { padding: 0; }
  .pf-dialog {
    max-width: none;
    height: 100%;
    border: none;
    border-radius: 0;
  }
  .pf-head { padding-right: 40px; padding-left: 40px; }
  .pf-img { max-height: 62vh; }
  .pf-final { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pf-root,
  .pf-dialog,
  .pf-close,
  .pf-zoom,
  .pf-confirm,
  .pf-back {
    transition: none !important;
  }
  .pf-root { opacity: 1; }
  .pf-dialog { transform: none !important; }
  /* The spinners still turn — they are the only signal that work is
     happening — but slowly enough not to pull at the eye. */
  .pf-spinner,
  .btn.is-preparing::before { animation-duration: 2.4s; }
}

/* ============================================================
   GUIDED FORM — invitation, sections, reassurance, the reveal
   ============================================================
   All of it template-driven (customizer.js renders these only when the
   template's JSON carries intro / sections / reassurance / formLabels), so a
   template without them looks exactly as before. */

/* The invitation — an arrival, not a form header. */
.form-invitation {
  text-align: center;
  padding: var(--space-lg) 0 var(--space-xl);
}

.form-invitation-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 300;
  line-height: 1.25;
  color: var(--color-primary);
  margin: 0 0 var(--space-md);
}

.form-invitation-body {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--color-muted);
  max-width: 46ch;
  margin: 0 auto;
}

/* Pause-and-return: a quiet fact, not a feature announcement. */
.form-resume-note {
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--color-muted);
  margin: 0 0 var(--space-2xl);
}

/* A section's opening line, directly under its title. */
.form-section .section-intro {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--color-muted);
  margin: calc(-1 * var(--space-sm)) 0 var(--space-md);
}

/* Reassurance microcopy — quiet, muted, smaller than everything around it. */
.section-reassurance,
.field-reassurance {
  font-size: 0.8rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--color-muted);
}

.section-reassurance { margin: 0 0 var(--space-lg); }
.field-reassurance { margin: var(--space-xs) 0 0; }

/* The reveal, framed in the template's own words (revealHeading/revealNote).
   The heading sits above the words; the note sits between them and the
   refine actions, so "tell us, we'll refine it" reads as the invitation the
   buttons answer. */
.poem-reveal-heading {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--color-primary);
  margin: 0 0 var(--space-md);
}

.poem-reveal-note {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-muted);
  margin: calc(-1 * var(--space-xs)) 0 var(--space-md);
}

/* ── Human tribute pacing ──
   Same components, slower rhythm: more air between sections, slightly larger
   questions, a more unhurried invitation. Keyed off body.category-human,
   which customizer.js sets from template.category — nothing here names a
   product. The pet flow keeps its current density. */
body.category-human .form-invitation {
  padding: var(--space-xl) 0 var(--space-2xl);
}

body.category-human .form-invitation-title { font-size: 2.1rem; }

body.category-human .form-invitation-body {
  font-size: 1rem;
  line-height: 1.8;
}

body.category-human .form-pane .form-section {
  margin-bottom: calc(var(--space-2xl) * 1.5);
}

body.category-human .form-section-title {
  font-size: 1.45rem;
  margin-bottom: var(--space-xl);
}

body.category-human .form-section .section-intro {
  margin-bottom: var(--space-lg);
}

body.category-human .field-group {
  margin-bottom: calc(var(--space-xl) * 1.2);
}

body.category-human .field-group label {
  font-size: 1.02rem;
  line-height: 1.45;
}

@media (max-width: 480px) {
  .form-invitation-title { font-size: 1.55rem; }
  body.category-human .form-invitation-title { font-size: 1.7rem; }
  body.category-human .form-section-title { font-size: 1.3rem; }
}

/* ============================================================
   STEPPED FLOW — sectioned templates, one step at a time
   ============================================================
   customizer.js adds body.stepped-flow only for templates with a sections
   array; flat templates never match anything below. Hidden steps are
   display:none, never removed, so every input keeps its value and its
   preview binding. */

/* Only the active step owns the screen. */
.form-step { display: none; }
.form-step.active { display: block; }

/* Size + checkout close the flow, alongside the words step. */
#step-tail { display: none; }
#step-tail.active { display: block; }

/* The quiet step list — titles only, plain text. Steps already reached are
   links back; steps still ahead sit inert. Nothing counts, nothing fills. */
.step-list {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  row-gap: 2px;
  margin: 0 0 var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.step-item {
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--color-muted);
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}

.step-item.is-current {
  color: var(--color-primary);
  font-weight: 600;
}

button.step-item.is-done {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(196, 168, 130, 0.55);
}

button.step-item.is-done:hover {
  color: var(--color-primary);
  text-decoration-color: var(--color-warm);
}

.step-item.is-upcoming { opacity: 0.65; }

.step-sep { color: var(--color-border); font-size: 0.78rem; }

/* Per-step controls: one warm Continue, one quiet Back. */
.step-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.step-continue {
  width: 100%;
  padding: 0.9rem 2rem;
  font-size: 1.02rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: #fff;
  background: var(--color-warm);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.step-continue:hover { background: #b89a74; }

.step-back {
  align-self: center;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.step-back:hover { color: var(--color-primary); }

/* On the words step Back sits above the reveal, out of the moment's way. */
.step-back-top {
  display: inline-block;
  align-self: flex-start;
  margin-bottom: var(--space-md);
}

/* The step owns the screen: the section inside it can sit closer to its own
   Continue than the stacked sections ever sat to each other. */
body.stepped-flow .form-step .form-section { margin-bottom: var(--space-lg); }

/* The always-visible zone above the steps — invitation, resume note, order
   toggle — stays, but compact, so the active step keeps the room. */
body.stepped-flow .form-invitation { padding: var(--space-md) 0 var(--space-lg); }
body.stepped-flow .form-invitation-title { font-size: 1.5rem; }
body.stepped-flow .form-invitation-body { font-size: 0.9rem; line-height: 1.65; }
body.stepped-flow .form-resume-note { margin-bottom: var(--space-lg); }
body.stepped-flow .form-intro { font-size: 1.15rem; padding: 0 0 var(--space-md); }
body.stepped-flow .form-intro span { font-size: 0.85rem; margin-top: var(--space-xs); }
body.stepped-flow .order-type-toggle { margin-bottom: var(--space-md); }
body.stepped-flow .order-type-hint {
  margin-top: 0;
  margin-bottom: var(--space-lg);
}
body.stepped-flow .gift-detail-note { margin-bottom: var(--space-lg); }

/* With the form column short, the preview holds one stable, generous size on
   mobile instead of shrinking to a thumbnail mid-scroll (customizer.js also
   stops toggling .mini in stepped flows; the .mini rules here are the
   belt-and-braces for a class applied before this file's JS settles).
   The vh term keeps a tall portrait frame from swallowing the screen. */
@media (max-width: 1024px) {
  body.stepped-flow .frame-preview,
  body.stepped-flow .preview-stage.mini .frame-preview {
    max-width: min(320px, calc(36vh * var(--frame-ar, 1.27)));
  }
}

@media (max-width: 480px) {
  body.stepped-flow .frame-preview,
  body.stepped-flow .preview-stage.mini .frame-preview {
    max-width: min(300px, calc(34vh * var(--frame-ar, 1.27)));
  }
}
