.memorial-builder-page {
  background: linear-gradient(180deg, #f8f4ee 0%, #f2ece3 100%);
}
.builder-shell {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 70px;
}
.builder-intro {
  max-width: 860px;
  margin: 0 auto 28px;
  text-align: center;
}
.builder-intro h1 {
  margin: 4px 0 12px;
  font-family: 'SPHeading', Georgia, serif;
  font-size: clamp(2.15rem, 5vw, 4rem);
  line-height: 1.02;
}

/* The preview name is a secondary heading, while retaining the memorial title styling. */
#preview-name {
  margin: 8px 0 12px;
  font-family: 'SPHeading', Georgia, serif;
  font-size: clamp(2.8rem, 5vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: 0.02em;
}
.builder-intro > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}
.builder-test-note {
  margin: 18px auto 0;
  padding: 14px 18px;
  max-width: 760px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffaf4;
  color: var(--muted);
  line-height: 1.45;
}
.builder-workspace {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.builder-controls {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 116px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}
.builder-section {
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(64,43,24,.07);
}
.builder-section-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.builder-section-heading > span {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.builder-section-heading h2 {
  margin: 0 0 2px;
  font-family: 'SPHeading', Georgia, serif;
  font-size: 1.45rem;
}
.builder-section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: .94rem;
}
.builder-section label {
  display: block;
  margin: 0 0 14px;
  color: var(--text);
  font-weight: 700;
}
.builder-section input[type="text"],
.builder-section input[type="email"],
.builder-section textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid #cdbda9;
  border-radius: 13px;
  padding: 12px 13px;
  background: white;
  color: var(--text);
  font: 1rem 'SPBody', Georgia, serif;
  outline: none;
  resize: vertical;
}
.builder-section input[type="text"]:focus,
.builder-section input[type="email"]:focus,
.builder-section textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,99,60,.12);
}
.optional {
  color: var(--muted);
  font-weight: 400;
  font-size: .88rem;
}
.character-count {
  margin: -8px 2px 0;
  text-align: right;
  color: var(--muted);
  font-size: .85rem;
}
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.photo-upload-label,
.gallery-photo-button {
  display: block;
  width: 100%;
  border: 1.5px dashed #b79e80;
  border-radius: 15px;
  background: #faf5ee;
  padding: 16px;
  cursor: pointer;
  text-align: center;
  transition: .2s ease;
}
.photo-upload-label:hover,
.gallery-photo-button:hover {
  border-color: var(--accent);
  background: #fffaf4;
}
.photo-upload-title {
  display: block;
  font-weight: 700;
  color: var(--text);
}
.photo-upload-help {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .87rem;
  font-weight: 400;
}
.small-action {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
}
.gallery-upload-controls {
  display: grid;
  gap: 12px;
}
.gallery-upload-row {
  border: 1px solid #dfd1c0;
  border-radius: 15px;
  padding: 12px;
  background: #fffdf9;
}
.gallery-upload-row .row-top {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.gallery-upload-row strong {
  font-size: .95rem;
}
.gallery-upload-row input[type="text"] {
  margin-top: 8px;
}
.gallery-photo-button {
  padding: 11px 12px;
  font-weight: 700;
  font-size: .92rem;
}
.builder-submit-section .button + .button {
  margin-top: 10px;
}
.submit-note {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.4;
  margin: 10px 0 0;
  text-align: center;
}
.builder-preview {
  min-width: 0;
}
.preview-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin: 0 2px 14px;
}
.preview-heading h2 {
  margin: 2px 0 0;
  font-family: 'SPHeading', Georgia, serif;
  font-size: 1.7rem;
}
.preview-private-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #e9dccd;
  color: var(--accent-dark);
  font-size: .85rem;
  font-weight: 700;
}
.builder-memorial-card,
.builder-gallery-card,
.builder-wall-preview {
  margin-bottom: 22px;
}
.builder-photo-slot,
.builder-gallery-viewer {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  background: #e9dfd2;
}
.builder-photo-slot .hero-image,
.builder-gallery-viewer > img {
  width: 100%;
  height: 100%;
  min-height: 340px;
  object-fit: cover;
}
.photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 20px;
  text-align: center;
  color: #78624f;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,.8), rgba(255,255,255,0) 45%),
    linear-gradient(135deg, #e8deD1, #f4ede4);
}
.placeholder-icon {
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
}
.photo-placeholder small {
  color: var(--muted);
}
.large-placeholder {
  min-height: 420px;
}
.builder-gallery-viewer {
  min-height: 420px;
}
.builder-gallery-viewer > img {
  min-height: 420px;
}
.builder-thumb-grid .thumb {
  position: relative;
  min-height: 90px;
  background: #efe5d7;
}
.builder-thumb-grid .thumb.empty {
  display: grid;
  place-items: center;
  border: 1px dashed #b79e80;
  color: #8a725d;
  font-size: .8rem;
  padding: 8px;
}
.builder-thumb-grid .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-actions {
  pointer-events: none;
}
.preview-button {
  cursor: default;
}
.builder-candle-preview select,
.builder-candle-preview button {
  pointer-events: none;
}
.published-feature-note {
  margin-top: 20px;
  padding: 14px;
  border-radius: 14px;
  background: #fff9f0;
  border: 1px solid var(--line);
  text-align: center;
}
.published-feature-note p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}
.sample-candle-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 640px;
  margin: 0 auto 16px;
}
.wall-candle.sample {
  pointer-events: none;
}
.wall-candle.sample.faded {
  opacity: .72;
}
@media (max-width: 1050px) {
  .builder-workspace {
    grid-template-columns: 1fr;
  }
  .builder-controls {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .builder-preview {
    scroll-margin-top: 90px;
  }
}
@media (max-width: 680px) {
  .builder-shell {
    width: min(100% - 18px, 1500px);
    padding-top: 22px;
  }
  .builder-intro h1 {
    font-size: 2.25rem;
  }
  .builder-section {
    padding: 16px;
    border-radius: 18px;
  }
  .preview-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .builder-photo-slot,
  .builder-photo-slot .hero-image {
    min-height: 280px;
  }
  .builder-gallery-viewer,
  .builder-gallery-viewer > img,
  .large-placeholder {
    min-height: 300px;
  }
  .sample-candle-row {
    grid-template-columns: 1fr;
  }
}

/* Builder test v2 — clearer photo selection feedback and iPhone-safe preview states */
.photo-selection-status,
.gallery-file-status {
  margin: 8px 2px 2px;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.photo-selection-status.is-selected,
.gallery-file-status.is-selected {
  color: var(--accent-dark);
  font-weight: 700;
}
.photo-selection-status.is-error,
.gallery-file-status.is-error {
  color: #8a3f32;
  font-weight: 700;
}
.photo-upload-label.has-photo,
.gallery-photo-button.has-photo,
.gallery-upload-row.has-photo {
  border-style: solid;
  border-color: var(--accent);
  background: #fff9f0;
}
.builder-thumb-grid .thumb.preview-unavailable {
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  font-weight: 700;
  background: #fff9f0;
  border-color: var(--accent);
}

/* Builder test v3 — visible thumbnail confirmation beside every selected photo */
.selected-photo-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 4px;
  padding: 9px;
  border: 1px solid #d7c4ad;
  border-radius: 13px;
  background: #fffdf9;
}
.selected-photo-preview[hidden] {
  display: none !important;
}
.selected-photo-preview img {
  width: 74px;
  height: 74px;
  flex: 0 0 74px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #eee5d9;
}
.selected-photo-preview > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.selected-photo-preview strong {
  color: var(--text);
  font-size: .94rem;
}
.selected-photo-preview span {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.25;
}
.photo-selection-status.is-selected,
.gallery-file-status.is-selected {
  font-size: .82rem;
}
.builder-photo-slot > img,
.builder-gallery-viewer > img {
  position: relative;
  z-index: 2;
}
.builder-photo-slot .photo-placeholder,
.builder-gallery-viewer .photo-placeholder {
  z-index: 1;
}
@media (max-width: 680px) {
  .selected-photo-preview img {
    width: 68px;
    height: 68px;
    flex-basis: 68px;
  }
}

/* Builder caption fix: show the optional caption clearly below the featured photo. */
.builder-gallery-viewer .featured-caption {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: 4;
  display: block;
  margin: 0;
  padding: 12px 16px 14px;
  color: var(--text);
  background: #f8f2e9;
  border-radius: 0;
  border-top: 1px solid var(--line);
  font-size: 1rem;
  line-height: 1.4;
  text-align: center;
}
.builder-gallery-viewer .featured-caption[hidden] {
  display: none !important;
}


/* Gentle gallery transition: fade each memory photograph out and the next one in. */
.builder-gallery-viewer #builder-featured-photo,
.builder-gallery-viewer #builder-featured-caption {
  opacity: 1;
  transition: opacity 550ms ease-in-out;
}
.builder-gallery-viewer #builder-featured-photo.is-fading-out,
.builder-gallery-viewer #builder-featured-caption.is-fading-out {
  opacity: 0;
}


/* Builder test v4 — purchase action below the memorial preview */
.builder-preview-column {
  min-width: 0;
}
.builder-purchase-panel {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 8px 24px rgba(64,43,24,.07);
  text-align: center;
}
.builder-purchase-panel h2 {
  margin: 6px 0 10px;
  font-family: 'SPHeading', Georgia, serif;
  font-size: 1.7rem;
}
.builder-purchase-panel > p:not(.builder-only-label):not(.submit-note) {
  max-width: 780px;
  margin: 0 auto 18px;
  color: var(--muted);
  line-height: 1.55;
}
.builder-purchase-panel .button {
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}
.builder-only-label {
  display: inline-block;
  margin: 0;
  padding: 7px 11px;
  border-radius: 999px;
  background: #eee3d5;
  color: var(--accent-dark);
  font-size: .82rem;
  font-weight: 700;
}
@media (max-width: 680px) {
  .builder-purchase-panel {
    padding: 18px 16px;
    border-radius: 18px;
  }
}


/* Builder test v5 — visible memorial reference number */
.reference-result {
  max-width: 440px;
  margin: 18px auto 10px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf3;
}
.reference-result[hidden] {
  display: none;
}
.reference-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}
.reference-number {
  margin: 0;
  font-family: 'SPHeading', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--accent-dark);
}
.reference-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}


/* Etsy purchase hand-off */
.etsy-handoff {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid #dfcfba;
  text-align: left;
}
.etsy-handoff-title {
  margin: 0 0 18px;
  font-weight: 700;
  font-size: clamp(1.2rem, 4vw, 1.55rem);
  color: #4b3525;
}
.etsy-handoff-step {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 18px 0 12px;
}
.etsy-step-number {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #875528;
  color: #fff;
  font-weight: 700;
}
.etsy-handoff-step strong { color: #4b3525; }
.etsy-handoff-step p {
  margin: 5px 0 0;
  line-height: 1.5;
  color: #756357;
}
.copy-reference-status {
  min-height: 1.4em;
  margin: 8px 0 0;
  text-align: center;
  color: #47644b;
  font-weight: 700;
}
.etsy-purchase-button {
  text-align: center;
  text-decoration: none;
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.etsy-handoff-note {
  margin: 18px 0 0;
  padding: 16px;
  border-radius: 16px;
  background: #f5ecdf;
  line-height: 1.5;
  color: #624b3a;
}

/* Premium pill treatment for builder utility actions */
.small-action{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:38px;
  padding:7px 14px!important;
  border:1px solid #c79c65!important;
  border-radius:999px!important;
  background:linear-gradient(135deg,#fffdf8 0%,#f8ead8 55%,#efddc5 100%)!important;
  color:#654326!important;
  text-decoration:none!important;
  font-weight:700;
  box-shadow:0 4px 10px rgba(94,61,30,.09);
}
.small-action:hover,
.small-action:focus-visible{
  background:linear-gradient(135deg,#fff 0%,#f4e1c7 55%,#e8cba5 100%)!important;
  transform:translateY(-1px);
}


/* Final review step — optional blank-section reminder */
.spellcheck-helper {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.4;
}
.builder-section.needs-review {
  border-color: #b78343;
  box-shadow: 0 0 0 3px rgba(183,131,67,.13), 0 8px 24px rgba(64,43,24,.07);
}
.builder-section .field-needs-review {
  border-color: #b78343 !important;
  background: #fffaf0 !important;
}
.blank-review-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32,25,20,.58);
  backdrop-filter: blur(3px);
}
.blank-review-overlay[hidden] { display: none !important; }
.review-dialog-open { overflow: hidden; }
.blank-review-dialog {
  width: min(620px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  padding: clamp(22px, 5vw, 36px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fffaf3;
  box-shadow: 0 24px 70px rgba(0,0,0,.25);
  text-align: center;
}
.blank-review-dialog h2 {
  margin: 4px 0 12px;
  font-family: 'SPHeading', Georgia, serif;
  font-size: clamp(1.65rem, 5vw, 2.25rem);
}
.blank-review-dialog > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}
.blank-review-list {
  margin: 18px auto 22px;
  padding: 0;
  max-width: 430px;
  list-style: none;
  text-align: left;
}
.blank-review-list li {
  margin: 8px 0;
  padding: 10px 12px 10px 38px;
  position: relative;
  border: 1px solid #dfc7a8;
  border-radius: 13px;
  background: #fff6e7;
}
.blank-review-list li::before {
  content: '•';
  position: absolute;
  left: 16px;
  top: 7px;
  color: #8b6237;
  font-size: 1.35rem;
}
.blank-review-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}
.blank-review-actions .button {
  min-width: 210px;
  cursor: pointer;
}
.blank-review-note {
  margin: 16px auto 0 !important;
  font-size: .85rem;
}
@media (max-width: 600px) {
  .blank-review-actions .button { width: 100%; min-width: 0; }
}


/* Private customer-side spelling and grammar review */
.builder-proofread-box {
  max-width: 620px;
  margin: 18px auto 20px;
  padding: 16px;
  border: 1px solid #dfcfba;
  border-radius: 18px;
  background: #fffaf3;
}
.builder-proofread-box .button { margin-bottom: 10px; }
.builder-proofread-help {
  margin: 0 !important;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}
.builder-proofread-results {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #d9b989;
  border-radius: 14px;
  background: #fff5e5;
  text-align: left;
}
.builder-proofread-results[hidden] { display: none !important; }
.builder-proofread-results.is-clear {
  border-color: #b9ccb8;
  background: #f3f8f1;
}
.builder-proofread-results h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--accent-dark);
}
.builder-proofread-results p { margin: 0 !important; }
.builder-proofread-results ul { margin: 0; padding-left: 20px; }
.builder-proofread-results li { margin: 7px 0; line-height: 1.4; }
