/* ================================================================
   IMAKE / mobile Cake Builder layout
   Apply AFTER style.css, builder-polish.css and receipt-polish.css.
   Scope: layout + control sizes only. Does NOT restyle .stage .layer,
   placement coordinates, rendering, prices, catalog, or checkout JS.
   ================================================================ */

/* Keep the laptop appearance on tablets, with an honest responsive reflow. */
body.builder-page { min-width: 0; }
body.builder-page .builder,
body.builder-page .builder-choices,
body.builder-page .builder .stage-card,
body.builder-page .step .options { min-width: 0; }
body.builder-page .builder-choices .opt { overflow-wrap: anywhere; }
body.builder-page .step .options .opt .nm,
body.builder-page .step .options .opt .pr { line-height: 1.3; }

/* This accessible toggle is meaningful on small screens only. */
body.builder-page .mobile-preview-toggle { display: none; }

@media (max-width: 960px) {
  body.builder-page > .wrap { width: calc(100% - 28px); }
  body.builder-page .builder { display: flex; flex-direction: column; gap: 15px; }
  body.builder-page .builder-choices { order: 2; width: 100%; }
  body.builder-page .builder .stage-card { order: 1; width: 100%; }
  body.builder-page .step .options {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(min(100%, 122px),1fr));
    gap: 11px;
  }
  body.builder-page .step .opt { min-height: 130px; }
  /* Show the full user experience on tablet, do not make a miniature desktop. */
  body.builder-page .builder .stage-card { position: static; }
}

/* Tablet portrait/landscape: preserve the familiar laptop two-column view.
   At this width the live preview still fits beside component cards. */
@media (min-width: 701px) and (max-width: 960px) {
  body.builder-page .builder {
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(235px,32%);
    gap: 14px;
    align-items: start;
  }
  body.builder-page .builder-choices { order: 0; }
  body.builder-page .builder .stage-card {
    order: 0;
    position: sticky;
    top: calc(var(--fixed-builder-header-height,74px) + 10px);
    max-height: calc(100dvh - var(--fixed-builder-header-height,74px) - 22px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
  }
  body.builder-page .builder .stage-card > .stage { max-width: 245px; }
  body.builder-page .step .options { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body.builder-page .builder .stage-card .stage-actions { gap: 6px; }
  body.builder-page .builder .stage-card .stage-actions .btn { min-width: 0; padding: 8px 5px; font-size: .78rem; }
}

/* On phones, keep both the choice controls and the same rendered cake in view.
   The stage itself is resized only (10:11 aspect ratio stays untouched). */
@media (max-width: 700px) {
  html.builder-root,
  body.builder-page { overflow-x: clip; }
  html.builder-root { scroll-padding-top: calc(var(--fixed-builder-header-height, 78px) + 10px); }
  body.builder-page > .wrap { width: calc(100% - 20px); padding: 12px 0 54px; }
  body.builder-page > .wrap > .lead {
    padding: 12px 15px 13px;
    margin: 0 0 10px;
    border-radius: 18px;
  }
  body.builder-page .lead-kicker { margin-bottom: 3px; padding: 3px 9px; font-size: .68rem; }
  body.builder-page .lead h1 { margin: 2px 0 3px; font-size: clamp(1.45rem, 6vw, 1.85rem); }
  body.builder-page .lead p { font-size: .79rem; line-height: 1.4; }
  body.builder-page .builder { gap: 10px; }

  /* Compact real-time cake preview with its original layered rendering.
     Price and checkout controls remain visible beside the actual cake. */
  body.builder-page .builder .stage-card {
    position: sticky;
    top: calc(var(--fixed-builder-header-height, 78px) + 5px);
    z-index: 35;
    display: grid;
    grid-template-columns: minmax(102px, 42%) minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 7px;
    padding: 11px;
    border-radius: 17px;
    overflow: visible;
    max-height: none;
    width: 100%;
    box-shadow: 0 10px 24px rgba(91,34,59,.15), inset 0 0 0 3px rgba(255,255,255,.78);
    background: rgba(255,250,253,.985);
  }
  body.builder-page .builder .stage-card::before { display: none; }
  body.builder-page .builder .stage-card > .stage {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    max-width: 148px;
    margin: 0 auto;
    /* Stage keeps its original 10:11 ratio and image-layer positions. */
  }
  body.builder-page .builder .stage-card > .price-tag {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    padding: 10px 7px;
    border-radius: 12px;
    font-size: clamp(1.25rem, 5.4vw, 1.55rem);
    line-height: 1.05;
    overflow-wrap: anywhere;
  }
  body.builder-page .builder .stage-card > .price-tag small {
    margin-top: 5px;
    font-size: .62rem;
    letter-spacing: .04em;
  }
  body.builder-page .builder .stage-card > .stage-actions {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1.38fr);
    gap: 6px;
  }
  body.builder-page .builder .stage-card > .stage-actions .btn {
    min-width: 0;
    min-height: 43px;
    white-space: normal;
    padding: 6px 5px;
    line-height: 1.14;
    font-size: clamp(.67rem, 2.9vw, .79rem);
    border-radius: 11px;
    touch-action: manipulation;
  }
  body.builder-page .builder .stage-card > .mobile-preview-toggle {
    display: block;
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    min-height: 36px;
    padding: 5px 3px;
    color: #953c60;
    background: #fff8fb;
    border: 1px solid #e9c1d0;
    border-radius: 10px;
    font-family: inherit; font-size: .72rem; font-weight: 700; line-height: 1.2;
    cursor: pointer;
    touch-action: manipulation;
  }
  body.builder-page .builder .stage-card > .placement-tools {
    grid-column: 1 / -1;
    grid-row: 3;
    max-height: 106px;
    overflow-y: auto;
    padding: 8px 10px;
    font-size: .75rem;
  }
  body.builder-page .builder .stage-card > .placement-tools strong { font-size: .75rem; }
  body.builder-page .builder .stage-card > .placement-tools p { margin: 4px 0; font-size: .72rem; }
  body.builder-page .builder .stage-card > .placement-tools .placement-reset { padding: 6px 9px; font-size: .72rem; }
  body.builder-page .builder .stage-card > .placement-tools[hidden] { display: none !important; }
  /* Enlarge the real stage for detailed decoration dragging; no image transforms. */
  body.builder-page .builder .stage-card.is-expanded {
    position: static;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    justify-items: center;
    gap: 9px;
  }
  body.builder-page .builder .stage-card.is-expanded > .mobile-preview-toggle {
    grid-column: 1; grid-row: 1; justify-self: end; min-width: 122px;
  }
  body.builder-page .builder .stage-card.is-expanded > .stage {
    grid-column: 1; grid-row: 2; width: min(100%, 330px); max-width: 330px;
  }
  body.builder-page .builder .stage-card.is-expanded > .price-tag { grid-column: 1; grid-row: 3; width: 100%; }
  body.builder-page .builder .stage-card.is-expanded > .stage-actions { grid-column: 1; grid-row: 4; width: 100%; }
  body.builder-page .builder .stage-card.is-expanded > .placement-tools { grid-column: 1; grid-row: 5; width: 100%; max-height: none; }

  /* Keep the laptop's component-card look with comfortable touch targets. */
  body.builder-page .builder-choices .step {
    padding: 14px 10px 13px;
    border-radius: 17px;
    margin-bottom: 11px;
  }
  body.builder-page .builder-choices .step .hint { margin: 0 0 10px; }
  body.builder-page .step .options {
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 9px;
  }
  body.builder-page .step .options.options-scrollable {
    max-height: 345px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  body.builder-page .step .opt { min-height: 0; padding: 8px 7px; border-radius: 13px; }
  body.builder-page .step .opt .thumb { width: 100%; aspect-ratio: 1/1; }
  body.builder-page .step .opt .nm { font-size: .82rem; }
  body.builder-page .step .opt .pr { font-size: .77rem; }
  body.builder-page .step .opt.clear { min-height: 115px; }
  body.builder-page .step .step-review-actions .btn { min-height: 44px; }

  /* The mobile header uses the same links and greeting; no clipped Log out. */
  body.builder-page > header.site {
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 4px;
    padding: 7px 10px 8px;
  }
  body.builder-page > header.site .brand { margin-right: 0; }
  body.builder-page > header.site .nav { width: auto; margin-left: auto; gap: 3px; }
  body.builder-page > header.site .nav a { margin: 0; padding: 7px 8px; font-size: .76rem; }
  body.builder-page > header.site .nav .greet-pill { margin: 0; padding: 6px 8px; font-size: .7rem; }
}

@media (max-width: 400px) {
  body.builder-page > header.site .nav { width: 100%; justify-content: center; }
  body.builder-page .builder .stage-card { grid-template-columns: minmax(98px,41%) minmax(0,1fr); }
  body.builder-page .step .options { gap: 7px; }
}

/* Responsive order modal: retain preview, illustrated order list, calendar,
   GCash and existing customer login/draft/receipt workflow. */
@media (max-width: 760px) {
  #modal { padding: 0; align-items: stretch; justify-content: stretch; }
  #modal .checkout-panel {
    width: 100%; max-width: none;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0;
    border-inline: 0;
  }
  #modal .checkout-panel > header {
    flex: 0 0 auto;
    min-height: 58px;
    padding: 9px 14px;
    overflow: visible;
  }
  #modal .checkout-panel > header h2 { font-size: 1.02rem; }
  #modal .checkout-panel > header .x { flex: none; min-width: 40px; min-height: 40px; }
  #modal .checkout-layout {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 10px calc(22px + env(safe-area-inset-bottom,0px));
    gap: 11px;
  }
  #modal .summary-column { min-width: 0; width: 100%; max-width: 100%; }
  #modal .preview-column,
  #modal .order-column,
  #modal .checkout-column { grid-column: auto; grid-row: auto; min-height: 0; height: auto; }
  #modal .preview-card,
  #modal .order-card,
  #modal .checkout-card { width: 100%; max-width: 100%; min-height: 0; }
  #modal .preview-card { position: static; }
  #modal .summary-preview { height: auto; aspect-ratio: 10/11; max-height: 365px; min-height: 0; }
  #modal .order-card .receipt-order-items { max-height: none; overflow: visible; }
  #modal .receipt-order-item .receipt-component-copy { min-width: 0; }
  #modal .checkout-card .field input,
  #modal .checkout-card .field select,
  #modal .checkout-card .field textarea { font-size: 16px; max-width: 100%; }
  #modal .gcash-qr-box { grid-template-columns: minmax(0,1fr); }
  #modal .gcash-grid,
  #modal .compact-grid,
  #modal .gcash-amounts { grid-template-columns: minmax(0,1fr); }
  #modal .checkout-action-box #placeBtn { width: 100%; min-height: 48px; }
  #modal .imake-calendar { max-width: 100%; min-width: 0; }
  #modal .imake-calendar * { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  body.builder-page .builder .stage-card { scroll-behavior: auto; }
}

/* ========================================================================
   IMAKE MOBILE V2 — clean, consistent borders and natural scroll
   These rules intentionally come LAST to correct conflicting legacy checkout
   dimensions. Only layout/UI; no changes to .stage .layer or cake coordinates.
   ======================================================================== */
@media (max-width: 700px) {
  html.builder-root { scroll-padding-top: 12px; }
  body.builder-page {
    overflow-x: clip;
    padding-top: 0; /* Desktop reserves space for a fixed header; mobile is in flow. */
    --mobile-card-line: #e9cbd5;
    --mobile-card-radius: 16px;
  }
  body.builder-page > header.site {
    position: relative; /* Never cover the cake or the checkout modal */
    top: auto;
    left: auto;
    right: auto;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 13px 9px;
    row-gap: 6px;
    border-bottom: 1px solid #e9cbd5;
  }
  body.builder-page > header.site > .brand {
    flex: 0 0 auto;
    font-size: 1.08rem;
    margin: 0;
  }
  body.builder-page > header.site .brand-cake { width: 24px; height: 24px; }
  body.builder-page > header.site > .nav {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    margin: 0;
    justify-content: flex-start;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
  }
  body.builder-page > header.site .nav a,
  body.builder-page > header.site .nav .greet-pill {
    margin: 0;
    padding: 6px 9px;
    font-size: .73rem;
    line-height: 1.25;
    white-space: normal;
  }
  body.builder-page .nav #navLogout { margin-left: auto; }
  body.builder-page > .wrap {
    width: calc(100% - 24px);
    padding: 12px 0 50px;
  }
  body.builder-page > .wrap > .lead {
    margin: 0 0 12px;
    padding: 13px 15px;
    border: 1px solid var(--mobile-card-line);
    border-radius: var(--mobile-card-radius);
    box-shadow: 0 5px 18px rgba(99,39,64,.06);
  }
  body.builder-page .lead h1 { font-size: clamp(1.45rem,5.5vw,1.8rem); }
  body.builder-page .lead p { font-size: .81rem; line-height: 1.45; }
  body.builder-page .builder { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
  body.builder-page .builder-choices { order: 2; width: 100%; }
  /* Static preview prevents sticky cards from covering the option controls. */
  body.builder-page .builder .stage-card {
    order: 1;
    position: relative;
    top: auto;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    gap: 9px 12px;
    align-items: center;
    width: 100%;
    max-width: none;
    padding: 12px;
    border: 1px solid var(--mobile-card-line);
    border-radius: var(--mobile-card-radius);
    background: #fffdfd;
    box-shadow: 0 7px 19px rgba(99,39,64,.075);
    overflow: visible;
  }
  body.builder-page .builder .stage-card::before { display: none; }
  body.builder-page .builder .stage-card > .stage {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 100%;
    max-width: 156px;
    margin: auto;
    border: 1px solid #f0d8e1;
    border-radius: 12px;
    /* No edits to layer rendering, aspect ratio, image scale or position. */
  }
  body.builder-page .builder .stage-card > .price-tag {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    margin: 0;
    padding: 12px 8px;
    border: 1px solid #f3d7e2;
    border-radius: 12px;
    font-size: clamp(1.23rem, 5.1vw, 1.55rem);
    line-height: 1.08;
    text-align: center;
  }
  body.builder-page .builder .stage-card > .price-tag small {
    font-size: .63rem;
    margin-top: 5px;
  }
  body.builder-page .builder .stage-card > .mobile-preview-toggle {
    display: block;
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
    width: 100%;
    min-height: 40px;
    padding: 8px 6px;
    margin: 0;
    font-size: .76rem;
    font-weight: 800;
    border: 1px solid #e9cbd5;
    border-radius: 12px;
    background: #fff;
    color: #963757;
    box-shadow: none;
  }
  body.builder-page .builder .stage-card > .stage-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1.5fr);
    gap: 9px;
    width: 100%;
    margin: 0;
  }
  body.builder-page .builder .stage-card > .stage-actions .btn {
    min-width: 0;
    min-height: 46px;
    padding: 9px 10px;
    border-radius: 12px;
    font-size: .83rem;
    line-height: 1.2;
    white-space: normal;
  }
  body.builder-page .builder .stage-card > .placement-tools {
    grid-column: 1 / -1;
    grid-row: 4;
    max-height: none;
    padding: 10px 12px;
    margin: 0;
    border: 1px solid #f0d4df;
    border-radius: 12px;
    background: #fff8fb;
    overflow: visible;
  }
  body.builder-page .builder .stage-card > .placement-tools[hidden] { display:none !important; }
  body.builder-page .builder .stage-card.is-expanded {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0,1fr);
    grid-template-rows: auto auto auto auto auto;
    justify-items: stretch;
    gap: 10px;
  }
  body.builder-page .builder .stage-card.is-expanded > .mobile-preview-toggle {
    grid-column:1; grid-row:1; width: auto; justify-self:end; min-width:136px;
  }
  body.builder-page .builder .stage-card.is-expanded > .stage {
    grid-column:1;grid-row:2;width:min(100%,320px);max-width:320px;
  }
  body.builder-page .builder .stage-card.is-expanded > .price-tag { grid-column:1;grid-row:3; }
  body.builder-page .builder .stage-card.is-expanded > .stage-actions { grid-column:1;grid-row:4; }
  body.builder-page .builder .stage-card.is-expanded > .placement-tools { grid-column:1;grid-row:5; }
  /* Let the page scroll, not each individual component grid. */
  body.builder-page .builder-choices .step {
    margin-bottom: 12px;
    padding: 13px 12px 15px;
    border: 1px solid var(--mobile-card-line);
    border-radius: var(--mobile-card-radius);
    box-shadow: 0 5px 18px rgba(99,39,64,.055);
  }
  body.builder-page .step .options,
  body.builder-page .step .options.options-scrollable {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 9px;
    max-height: none;
    overflow: visible;
  }
  body.builder-page .step .opt {
    width: 100%;
    min-width: 0;
    padding: 8px;
    min-height: 0;
    border-width: 1.5px;
    border-color: var(--mobile-card-line);
    border-radius: 13px;
  }
  body.builder-page .step .opt.selected {
    border-color: #d781a1;
    box-shadow: 0 0 0 2px rgba(215,129,161,.16);
  }
  body.builder-page .step .opt .thumb { aspect-ratio: 1/1; }
  body.builder-page .step .opt .nm { font-size:.81rem; line-height:1.3; }
  body.builder-page .step .opt .pr { font-size:.78rem; }
}
@media (max-width: 340px) {
  body.builder-page .builder .stage-card { gap:8px;grid-template-columns:minmax(0,39%) minmax(0,1fr);padding:10px; }
  body.builder-page > header.site .nav a,body.builder-page > header.site .nav .greet-pill{font-size:.69rem;padding:6px 7px;}
}

/* Mobile Review & Order: ONE normal scrolling document inside the popup. */
@media (max-width: 760px) {
  #modal.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
    background: #fffafc;
  }
  #modal .panel.checkout-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fffafc;
  }
  #modal .checkout-panel > header {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 9px 14px;
    margin: 0;
    background: #fff;
    border-bottom: 1px solid #e9cbd5;
  }
  #modal .checkout-panel > header h2 {
    margin:0;
    font-size: 1.02rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  #modal .checkout-panel > header .x {
    flex:0 0 38px;
    width:38px;height:38px;min-width:38px;min-height:38px;
    border:1px solid #eed5df;border-radius:10px;
  }
  #modal .summary-body.checkout-layout {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width:100%;
    min-width: 0;
    min-height: 0;
    margin:0;
    padding: 12px 12px calc(24px + env(safe-area-inset-bottom,0px));
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: #fffafc;
  }
  #modal .summary-column,
  #modal .preview-column,
  #modal .order-column,
  #modal .checkout-column {
    flex: 0 0 auto;
    display: block;
    width: 100%;
    min-width:0;
    max-width:100%;
    height:auto;
    min-height:0;
    overflow:visible;
  }
  #modal .preview-card,
  #modal .order-card,
  #modal .checkout-card,
  #modal #orderForm {
    position:relative;
    width:100%;
    min-width:0;
    max-width:100%;
    height:auto;
    min-height:0;
    max-height:none;
    margin:0;
    border:1px solid #e9cbd5;
    border-radius:16px;
    box-shadow:0 5px 18px rgba(99,39,64,.05);
    background:#fff;
    overflow:visible;
  }
  #modal .preview-card { display:flex;flex-direction:column;padding:12px;gap:0; }
  /* Cancel the desktop size-container/flex ratios that create the oversized
     floating image shown in the user's screenshot. */
  #modal .summary-preview {
    container-type:normal;
    flex:0 0 auto;
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    height:auto;
    min-height:0;
    max-height:none;
    aspect-ratio:auto;
    padding:12px;
    margin:0;
    overflow:hidden;
    border:1px solid #f0dae2;
    border-radius:13px;
    background:linear-gradient(180deg,#fff,#fff7fa);
  }
  #modal .summary-preview .review-stage,
  #modal #reviewStage {
    position:relative;
    flex:0 0 auto;
    display:block;
    width:min(100%,210px);
    max-width:210px;
    height:auto;
    max-height:none;
    aspect-ratio:10/11;
    margin:0 auto;
    overflow:hidden;
    /* The cake layer elements retain their original layout/coordinates. */
  }
  #modal .summary-preview .review-export-image { display:none !important; }
  #modal .preview-details { margin:0;padding:12px 0 0; }
  #modal .preview-details h3 { margin:0;font-size:1rem; }
  #modal .preview-details p { font-size:.8rem; }
  #modal .preview-thumbs { max-width:100%;padding:8px 2px; }
  #modal .order-card { display:flex;flex-direction:column; }
  #modal .order-card .section-heading { padding:13px; }
  #modal .order-card .receipt-order-items {
    flex:0 0 auto;
    min-height:0;
    height:auto;
    max-height:none;
    margin:0;
    padding:10px;
    overflow:visible;
    scrollbar-gutter:auto;
  }
  #modal .order-card .receipt-order-items li.receipt-order-item {
    grid-template-columns:48px minmax(0,1fr);
    padding:9px;
    border:1px solid #efd4df;
    border-radius:12px;
  }
  #modal .order-card .total-row {
    position:static;
    margin:0;
    padding:13px;
    border-top:1px solid #efd4df;
    font-size:1.12rem;
  }
  #modal #orderForm {
    display:flex;
    flex-direction:column;
    gap:11px;
    padding:14px;
    scrollbar-gutter:auto;
    overscroll-behavior:auto;
  }
  #modal #orderForm .field { min-width:0;margin:0; }
  #modal #orderForm .field input,
  #modal #orderForm .field select,
  #modal #orderForm .field textarea { width:100%;max-width:100%;font-size:16px;box-sizing:border-box; }
  #modal #orderForm .row2.compact-grid,
  #modal #orderForm .gcash-grid,
  #modal #orderForm .gcash-amounts,
  #modal #orderForm .gcash-qr-box { display:grid;grid-template-columns:minmax(0,1fr); }
  #modal .delivery-picker,
  #modal .gcash-payment,
  #modal .checkout-action-box {
    width:100%;
    min-width:0;
    margin:0;
    padding:12px;
    border:1px solid #efd4df;
    border-radius:13px;
    background:#fffafa;
  }
  #modal .imake-calendar { max-width:100%;width:100%;min-width:0;padding:8px; }
  #modal .gcash-qr-image {max-width:180px;}
  #modal .checkout-action-box #placeBtn {min-height:48px;width:100%;}
  #modal #receiptBox { padding:14px; }
}

@media (max-width: 340px) {
  /* Keep all four header actions on one compact row on very narrow phones. */
  body.builder-page > header.site .nav { gap: 3px; }
  body.builder-page > header.site .nav a,
  body.builder-page > header.site .nav .greet-pill {
    padding: 5px 5px;
    font-size: .66rem;
    white-space: nowrap;
  }
}


/* =======================================================================
   MOBILE V3 — faithful to the laptop UI, without forcing desktop columns
   Only mobile layout, controls and presentation; no layer rendering changes.
   ======================================================================= */
.mobile-builder-dock { display:none; }
@media (max-width:700px) {
  body.builder-page {
    --mobile-rose-border:#edced9;
    --mobile-radius:18px;
    padding-bottom:calc(76px + env(safe-area-inset-bottom,0px));
  }
  body.builder-page > .wrap { width:calc(100% - 20px); max-width:none; padding:12px 0 48px; }
  body.builder-page .wrap > .lead {
    width:100%; max-width:none; margin:0 0 12px;
    border:1px solid var(--mobile-rose-border); border-radius:var(--mobile-radius);
    background:linear-gradient(135deg,#fff,#fff6fa);
    box-shadow:0 5px 18px rgba(99,39,64,.06);
  }
  body.builder-page .builder {display:flex;flex-direction:column;gap:12px;width:100%;min-width:0;}
  body.builder-page .builder-choices {width:100%;min-width:0;order:2;}
  body.builder-page .builder .stage-card {
    order:1;position:relative;top:auto;z-index:1;
    width:100%;min-width:0;max-width:none;
    grid-template-columns:minmax(0,40%) minmax(0,1fr);
    gap:9px 11px;padding:12px;
    border:1px solid var(--mobile-rose-border);
    border-radius:var(--mobile-radius);
    box-shadow:0 6px 21px rgba(99,39,64,.07);
    background:#fffdfd;
  }
  body.builder-page .builder .stage-card > .stage {
    border-radius:13px;border:1px solid #efd7e0;
    width:100%;max-width:160px;margin:0 auto;
    /* 10:11 and rendered cake layer sizes remain owned by style.css. */
  }
  body.builder-page .builder .stage-card > .price-tag {
    border-radius:13px;border:1px solid #f0d1dc;
    background:#fce9f0;box-shadow:none;
  }
  body.builder-page .builder .stage-card > .stage-actions .btn,
  body.builder-page .builder .stage-card > .mobile-preview-toggle {min-height:44px;border-radius:12px;}
  body.builder-page .builder-choices .step {
    width:100%;margin:0 0 12px;padding:15px 12px 16px;
    border:1px solid var(--mobile-rose-border);
    border-radius:var(--mobile-radius);
    box-shadow:0 5px 18px rgba(99,39,64,.055),inset 0 0 0 3px rgba(255,250,252,.7);
  }
  body.builder-page .builder-choices .step h3 {font-size:1.04rem;gap:8px;flex-wrap:wrap;}
  body.builder-page .builder-choices .step .badge {font-size:.61rem;padding:5px 9px;}
  body.builder-page .step .options,
  body.builder-page .step .options.options-scrollable {
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
    max-height:none;overflow:visible;padding:2px;gap:10px;
  }
  body.builder-page .step .options .opt {
    display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;
    width:100%;min-width:0;min-height:0;
    padding:9px 8px 11px;border:1.5px solid var(--mobile-rose-border);
    border-radius:15px;background:#fff;
  }
  body.builder-page .step .options .opt.selected {
    border-color:#bb4774;
    box-shadow:0 0 0 2px rgba(187,71,116,.14);
    background:#fff1f6;
  }
  body.builder-page .step .opt .thumb {
    width:100%;aspect-ratio:1/1;object-fit:contain;
    border:1px solid #fae9ee;border-radius:11px;
  }
  body.builder-page .step .opt .nm {font-size:.82rem;line-height:1.25;overflow-wrap:break-word;}
  body.builder-page .step .opt .pr {font-size:.8rem;line-height:1.3;margin-top:auto;padding-top:5px;}
  body.builder-page .step .step-review-actions {justify-content:stretch;}
  body.builder-page .step .step-review-actions .btn {width:100%;min-height:44px;}
  /* A compact price/review bar appears after the real cake preview scrolls out.
     This complements the existing desktop controls rather than replacing them. */
  .mobile-builder-dock[data-visible="true"] {
    position:fixed;left:8px;right:8px;
    bottom:calc(8px + env(safe-area-inset-bottom,0px));
    z-index:95;
    display:grid;grid-template-columns:minmax(72px,.75fr) minmax(72px,.9fr) minmax(112px,1.4fr);
    align-items:center;gap:7px;padding:9px;
    border:1px solid #e8bece;border-radius:17px;
    background:rgba(255,252,253,.98);
    box-shadow:0 7px 30px rgba(77,33,54,.19);
  }
  .mobile-dock-price {padding-left:4px;min-width:0;line-height:1.16;}
  .mobile-dock-price > span {display:block;color:#9b667a;font-size:.58rem;letter-spacing:.06em;font-weight:800;}
  #mobileDockPrice {display:inline;color:inherit;font-size:inherit;letter-spacing:0;font-weight:inherit;}
  .mobile-dock-price strong {font-size:clamp(.83rem,3.4vw,1.05rem);color:#95365d;overflow-wrap:anywhere;}
  .mobile-dock-view,.mobile-dock-review {
    min-width:0;min-height:44px;border-radius:11px;
    font-family:inherit;font-weight:800;font-size:.74rem;line-height:1.12;cursor:pointer;padding:6px;
  }
  .mobile-dock-view {color:#97375b;border:1px solid #e7c5d2;background:#fff;}
  .mobile-dock-review {color:#fff;border:1px solid #9c345b;background:#9c345b;}
  .mobile-dock-review:disabled {opacity:.45;cursor:not-allowed;}
  /* Give the dock breathing room at the bottom of the step list. */
  body.builder-page .builder-choices {padding-bottom:16px;}
  /* Checkout remains a single column on phones, without nested scrollbars. */
  #modal .summary-body.checkout-layout {width:100%;max-width:100%;}
  #modal .summary-column,#modal .preview-card,#modal .order-card,#modal #orderForm {box-sizing:border-box;}
}
@media (max-width:355px) {
  body.builder-page > .wrap {width:calc(100% - 14px);}
  body.builder-page .builder-choices .step {padding:13px 9px;}
  body.builder-page .step .options {gap:7px;}
  .mobile-builder-dock[data-visible="true"] {left:5px;right:5px;gap:5px;padding:7px;grid-template-columns:minmax(67px,.72fr) minmax(66px,.77fr) minmax(108px,1.42fr);}
  .mobile-dock-view,.mobile-dock-review {font-size:.69rem;}
}
@media (prefers-reduced-motion: reduce) {
  .mobile-builder-dock {transition:none;}
}

/* ========================================================================
   IMAKE MOBILE V4 — fixed top summary, scrolling components only
   Goal: on phones, keep the summary/preview panel still and clean,
   while only the component list scrolls. No changes to cake rendering.
   ======================================================================== */
@media (max-width: 700px) {
  html.builder-root,
  body.builder-page {
    height: 100%;
  }

  body.builder-page {
    --mobile-bottom-safe: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }

  body.builder-page > .wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  body.builder-page .builder {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Keep the summary panel steady and visible on mobile. */
  body.builder-page .builder .stage-card {
    position: sticky;
    top: 0;
    z-index: 6;
    flex: 0 0 auto;
    margin-bottom: 0;
  }

  body.builder-page .builder .stage-card > .stage {
    min-height: 138px;
    max-height: 138px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.builder-page .builder .stage-card > .placement-tools {
    grid-column: 1 / -1;
    grid-row: 4;
    width: 100%;
    margin: 0;
    padding: 9px 10px;
    border: 1px dashed #edd4dd;
    border-radius: 12px;
    background: #fffafc;
  }

  body.builder-page .builder .stage-card > .placement-tools[hidden] {
    display: none !important;
  }

  /* Only this area scrolls on mobile. */
  body.builder-page .builder-choices {
    flex: 1 1 auto;
    min-height: 0;
    max-height: var(--mobile-choices-height, 52dvh);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: #d496ae transparent;
  }

  body.builder-page .builder-choices::-webkit-scrollbar {
    width: 6px;
  }

  body.builder-page .builder-choices::-webkit-scrollbar-thumb {
    background: #d496ae;
    border-radius: 999px;
  }

  /* Make component cards cleaner with no cropped edges. */
  body.builder-page .builder-choices .step {
    overflow: hidden;
  }

  body.builder-page .step .options {
    align-items: stretch;
  }

  body.builder-page .step .opt,
  body.builder-page .step .opt.clear {
    min-height: 0;
    height: auto;
  }

  body.builder-page .step .opt .thumb {
    border-radius: 10px;
  }

  body.builder-page .step .options.options-scrollable {
    max-height: none;
    overflow: visible;
  }

  /* The quick dock is unnecessary when the summary stays visible. */
  .mobile-builder-dock {
    display: none !important;
  }
}

@media (max-width: 400px) {
  body.builder-page .builder .stage-card {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px 10px;
    padding: 10px;
  }

  body.builder-page .builder .stage-card > .stage {
    min-height: 126px;
    max-height: 126px;
  }

  body.builder-page .builder .stage-card > .price-tag {
    padding: 10px 6px;
  }

  body.builder-page .builder .stage-card > .mobile-preview-toggle,
  body.builder-page .builder .stage-card > .stage-actions .btn {
    min-height: 38px;
    font-size: .72rem;
  }
}

/* ========================================================================
   IMAKE MOBILE V5 — maximum space for cake components + compact footer
   Mobile only. Keep the cake image/layer rendering and desktop view unchanged.
   The page can still be scrolled deliberately to reach the short footer,
   while scrolling inside the component list keeps the top preview stationary.
   ======================================================================== */
@media (max-width: 700px) {
  html.builder-root { scroll-padding-top: 0; }
  body.builder-page { min-height: 100%; }

  /* One phone viewport for the builder. The footer starts BELOW it. */
  body.builder-page > .wrap {
    box-sizing: border-box;
    width: calc(100% - 16px);
    height: calc(100dvh - var(--fixed-builder-header-height, 76px));
    min-height: 0;
    max-height: none;
    overflow: hidden;
    margin: 0 auto;
    padding: 7px 0 8px;
    display: flex;
    flex-direction: column;
    gap: 7px;
  }
  @supports not (height: 100dvh) {
    body.builder-page > .wrap { height: calc(100vh - var(--fixed-builder-header-height, 76px)); }
  }

  /* The intro becomes a compact title instead of an oversized top card. */
  body.builder-page > .wrap > .lead {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 8px;
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid #eacdd7;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(115,48,73,.035);
    background: rgba(255,252,253,.96);
    text-align: left;
  }
  body.builder-page > .wrap > .lead .lead-kicker {
    margin: 0;
    padding: 3px 7px;
    font-size: .60rem;
    line-height: 1.05;
    white-space: nowrap;
  }
  body.builder-page > .wrap > .lead h1 {
    margin: 0;
    font-size: clamp(1rem, 4.2vw, 1.24rem);
    line-height: 1.18;
    letter-spacing: -.02em;
  }
  /* The detailed instructions are still in the PHP and desktop layout. */
  body.builder-page > .wrap > .lead p { display: none; }

  body.builder-page .builder {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    gap: 7px;
    align-items: stretch;
  }

  /* Small, stationary preview with a proportionally sized REAL cake stage. */
  body.builder-page .builder .stage-card {
    order: 1;
    position: relative;
    top: auto;
    z-index: 2;
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 8px;
    display: grid;
    grid-template-columns: minmax(88px, 33%) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 6px 8px;
    align-items: center;
    border: 1px solid #e9cbd5;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(99,39,64,.08);
    background: #fffdfd;
    overflow: hidden;
  }
  body.builder-page .builder .stage-card::before { display: none; }
  body.builder-page .builder .stage-card > .stage {
    grid-column: 1;
    grid-row: 1 / span 2;
    min-width: 0;
    width: min(100%, 112px);
    max-width: 112px;
    min-height: 0;
    max-height: none;
    height: auto;
    aspect-ratio: 10/11;
    margin: 0 auto;
    display: block;
    border: 1px solid #f0d8e1;
    border-radius: 11px;
    /* Do not touch .stage .layer, positions or scale. */
  }
  body.builder-page .builder .stage-card > .price-tag {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin: 0;
    padding: 7px 5px;
    border-radius: 10px;
    font-size: clamp(1.05rem, 4.7vw, 1.40rem);
    line-height: 1.12;
    text-align: center;
  }
  body.builder-page .builder .stage-card > .price-tag small {
    margin-top: 2px;
    font-size: .57rem;
    letter-spacing: .02em;
  }
  body.builder-page .builder .stage-card > .mobile-preview-toggle {
    display: block;
    grid-column: 2;
    grid-row: 2;
    min-height: 34px;
    width: 100%;
    margin: 0;
    padding: 5px 7px;
    border-radius: 9px;
    font-size: .71rem;
    line-height: 1.15;
  }
  body.builder-page .builder .stage-card > .stage-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1.35fr);
    gap: 7px;
    width: 100%;
    margin: 0;
  }
  body.builder-page .builder .stage-card > .stage-actions .btn {
    width: 100%;
    min-width: 0;
    min-height: 39px;
    padding: 7px 6px;
    border-radius: 10px;
    font-size: .76rem;
    line-height: 1.12;
    white-space: normal;
  }
  body.builder-page .builder .stage-card > .placement-tools {
    grid-column: 1 / -1;
    grid-row: 4;
    width: 100%;
    max-height: 92px;
    overflow-y: auto;
    margin: 0;
    padding: 6px 8px;
  }
  body.builder-page .builder .stage-card > .placement-tools[hidden] { display:none !important; }

  /* Take *every remaining pixel* for the component picker. */
  body.builder-page .builder-choices {
    order: 2;
    flex: 1 1 0;
    width: 100%;
    min-height: 0;
    height: auto;
    max-height: none;
    margin: 0;
    padding: 2px 2px 10px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #d59aae transparent;
    border-radius: 12px;
  }
  body.builder-page .builder-choices .step {
    margin-bottom: 8px;
    padding: 12px 9px 13px;
    border-radius: 13px;
    overflow: visible;
  }
  body.builder-page .builder-choices .step .hint { margin-bottom: 8px; }
  body.builder-page .builder-choices .options,
  body.builder-page .builder-choices .options.options-scrollable {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
    gap: 8px;
    padding: 2px;
  }
  body.builder-page .builder-choices .opt {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  /* The dock isn't needed: the original controls stay in view. */
  .mobile-builder-dock, .mobile-builder-dock[data-visible="true"] {display:none !important;}

  /* Enlarge preview becomes a focused full-screen inspection sheet. */
  body.builder-page .builder .stage-card.is-expanded {
    position: fixed;
    inset: calc(var(--fixed-builder-header-height, 76px) + 4px) 8px 8px;
    z-index: 99;
    width: auto;
    max-width: none;
    max-height: none;
    padding: 13px;
    overflow-x: hidden;
    overflow-y: auto;
    display: grid;
    grid-template-columns: minmax(0,1fr);
    grid-template-rows: auto auto auto auto auto;
    justify-items: stretch;
    align-content: start;
    gap: 10px;
    background: #fffdfd;
    box-shadow: 0 0 0 100vmax rgba(45,21,36,.44), 0 14px 36px rgba(60,28,45,.23);
  }
  body.builder-page .builder .stage-card.is-expanded > .mobile-preview-toggle {
    grid-column: 1; grid-row: 1; justify-self: end; width: auto; min-width: 120px;
  }
  body.builder-page .builder .stage-card.is-expanded > .stage {
    grid-column: 1; grid-row: 2;
    width: min(100%, 330px);
    max-width: 330px;
    max-height: none;
    aspect-ratio: 10/11;
    justify-self: center;
  }
  body.builder-page .builder .stage-card.is-expanded > .price-tag {grid-column: 1;grid-row: 3;width: 100%;}
  body.builder-page .builder .stage-card.is-expanded > .stage-actions {grid-column: 1;grid-row: 4;width: 100%;}
  body.builder-page .builder .stage-card.is-expanded > .placement-tools {
    grid-column: 1;grid-row: 5;width: 100%;max-height: none;
  }

  /* The footer remains reachable BELOW the builder, but is now compact. */
  body.builder-page .customer-footer { margin:0; }
  body.builder-page .customer-footer__scallop { height: 5px; }
  body.builder-page .customer-footer__main { padding: 11px 15px 9px !important; }
  body.builder-page .customer-footer__grid {
    display: grid;
    grid-template-columns: minmax(0,1fr);
    gap: 7px;
    width: 100%;
    margin: 0;
  }
  body.builder-page .customer-footer__grid > section,
  body.builder-page .customer-footer__grid > nav {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    min-width: 0;
  }
  body.builder-page .customer-footer__brand {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 11px;
  }
  body.builder-page .customer-footer__logo { flex:0 0 auto; }
  body.builder-page .customer-footer__logo img {
    width: 57px;
    height: auto;
    max-height: 48px;
  }
  body.builder-page .customer-footer__brand > p {
    max-width: none;
    margin: 0;
    font-size: .77rem;
    line-height: 1.28;
  }
  body.builder-page .customer-footer__column h2 {
    margin: 0 0 5px;
    font-size: .89rem;
    line-height: 1.15;
  }
  body.builder-page .customer-footer__column h2 span {display:none;}
  body.builder-page .customer-footer__grid > nav.customer-footer__column {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 12px;
    padding-top: 8px !important;
    border-top: 1px solid rgba(255,255,255,.27) !important;
  }
  body.builder-page .customer-footer__grid > nav.customer-footer__column h2 {
    flex-basis: 100%;
  }
  body.builder-page .customer-footer__column > a:not(.customer-footer__facebook-button) {
    margin: 0;
    font-size: .76rem;
    line-height: 1.2;
    white-space: normal;
  }
  body.builder-page .customer-footer__grid > .customer-footer__contact {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 11px;
    padding-top: 8px !important;
    border-top: 1px solid rgba(255,255,255,.27) !important;
  }
  body.builder-page .customer-footer__contact h2 {width: 100%;}
  body.builder-page .customer-footer__contact-row {
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: .75rem;
    line-height: 1.22;
  }
  body.builder-page .customer-footer__contact .customer-footer__contact-row + .customer-footer__contact-row {
    margin-top: 0;
  }
  body.builder-page .customer-footer__contact-icon {
    flex: 0 0 22px;
    width:22px;height:22px;
  }
  body.builder-page .customer-footer__contact-icon svg {width:13px;height:13px;}
  body.builder-page .customer-footer__contact-row a,
  body.builder-page .customer-footer__contact-row address {font-size:.73rem;line-height:1.22;}
  body.builder-page .customer-footer__grid > .customer-footer__community { display:none !important; }
  body.builder-page .customer-footer__bottom-inner {
    width: calc(100% - 30px);
    min-height: 35px;
    gap: 8px;
  }
  body.builder-page .customer-footer__bottom-inner > p {font-size: .69rem;line-height:1.15;}
  body.builder-page .customer-footer__facebook-icon {width:26px;height:26px;font-size:17px;}
}

@media (max-width: 355px) {
  body.builder-page .builder .stage-card {grid-template-columns:minmax(82px,33%) minmax(0,1fr);}
  body.builder-page .builder .stage-card > .stage {width:min(100%,96px)}
  body.builder-page .builder .stage-card > .stage-actions .btn {font-size:.69rem;min-height:38px}
  body.builder-page .customer-footer__grid > .customer-footer__contact {gap:6px}
}

/* ======================================================================
   IMAKE Mobile V6 — clean two-row header + taller scrollable components.
   Kept to phones only. Does not alter cake layer / preview rendering rules.
   ====================================================================== */
@media (max-width: 700px) {
  /* Brand occupies row 1, ALL account links stay on row 2, including Log out.
     A long personalized greeting clips gracefully rather than pushing a link
     onto a third row. */
  body.builder-page > header.site {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    align-content: center;
    gap: 3px;
    width: 100%;
    padding: 6px 10px 6px;
    min-height: 0;
  }
  body.builder-page > header.site > .brand {
    grid-row: 1;
    justify-self: start;
    font-size: 1.02rem;
    line-height: 1.1;
    min-width: 0;
  }
  body.builder-page > header.site .brand-cake { width: 22px; height: 22px; }
  body.builder-page > header.site > .nav {
    grid-row: 2;
    display: grid;
    grid-template-columns: max-content max-content minmax(0, 1fr) max-content;
    align-items: center;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    justify-content: stretch;
    column-gap: clamp(3px, 1.2vw, 7px);
    row-gap: 0;
  }
  body.builder-page > header.site .nav > a,
  body.builder-page > header.site .nav > .greet-pill {
    min-width: 0;
    margin: 0 !important;
    padding: 5px clamp(4px, 1.8vw, 8px);
    font-size: clamp(.64rem, 2.6vw, .74rem);
    line-height: 1.2;
    white-space: nowrap;
  }
  body.builder-page > header.site .nav > a:first-child { grid-column: 1; }
  body.builder-page > header.site .nav > a.active { grid-column: 2; }
  body.builder-page > header.site .nav > #navGreeting {
    grid-column: 3;
    justify-self: stretch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }
  body.builder-page > header.site .nav > #navAccount,
  body.builder-page > header.site .nav > #navLogout {
    grid-column: 4;
    justify-self: end;
    margin: 0 !important;
    text-decoration: none;
    cursor: pointer;
  }
  body.builder-page > header.site .nav > #navLogout:focus-visible {
    outline: 2px solid #ac3c67;
    outline-offset: 2px;
    border-radius: 8px;
  }

  /* Reclaim vertical room for the component list. The header is measured by
     build.php's existing ResizeObserver, so no fixed pixel-height guess. */
  body.builder-page { padding-bottom: 0; }
  body.builder-page > .wrap {
    width: calc(100% - 12px);
    height: calc(100dvh - var(--fixed-builder-header-height, 70px));
    min-height: 0;
    padding: 5px 0 5px;
    gap: 5px;
  }
  body.builder-page > .wrap > .lead {
    min-height: 0;
    padding: 5px 9px;
    gap: 4px 7px;
    border-radius: 11px;
  }
  body.builder-page > .wrap > .lead .lead-kicker {
    padding: 2px 6px;
    font-size: .58rem;
  }
  body.builder-page > .wrap > .lead h1 {
    font-size: clamp(.98rem, 4vw, 1.17rem);
    line-height: 1.15;
  }
  body.builder-page .builder { gap: 5px; }
  body.builder-page .builder .stage-card:not(.is-expanded) {
    gap: 4px 7px;
    padding: 6px 8px;
    grid-template-columns: minmax(84px, 30%) minmax(0, 1fr);
  }
  body.builder-page .builder .stage-card:not(.is-expanded) > .stage {
    width: min(100%, 98px);
    max-width: 98px;
    height: auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: 10/11;
  }
  body.builder-page .builder .stage-card:not(.is-expanded) > .price-tag {
    padding: 5px;
    font-size: clamp(1.02rem, 4.3vw, 1.31rem);
    line-height: 1.1;
  }
  body.builder-page .builder .stage-card:not(.is-expanded) > .mobile-preview-toggle {
    min-height: 32px;
    padding: 4px 6px;
    font-size: .70rem;
  }
  body.builder-page .builder .stage-card:not(.is-expanded) > .stage-actions { gap: 6px; }
  body.builder-page .builder .stage-card:not(.is-expanded) > .stage-actions .btn {
    min-height: 37px;
    padding: 6px 5px;
    font-size: .73rem;
  }
  body.builder-page .builder-choices {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  body.builder-page .builder-choices .step { margin-bottom: 7px; }
  body.builder-page .builder-choices .step:last-child { margin-bottom: 0; }
  /* Give selected cards a consistent border, never a cut-off half-card. */
  body.builder-page .builder-choices .options,
  body.builder-page .builder-choices .options.options-scrollable {
    overflow: visible;
    max-height: none;
  }
}
@media (max-width: 355px) {
  body.builder-page > header.site > .nav { column-gap: 2px; }
  body.builder-page > header.site .nav > a,
  body.builder-page > header.site .nav > .greet-pill {
    padding: 5px 3px;
    font-size: .62rem;
  }
  body.builder-page .builder .stage-card:not(.is-expanded) {
    grid-template-columns: minmax(74px, 29%) minmax(0, 1fr);
  }
  body.builder-page .builder .stage-card:not(.is-expanded) > .stage {
    width: min(100%, 86px);
  }
}

/* Mobile receipt sharing: avoid launching Facebook before the PNG is ready. */
.mobile-receipt-hint { display: none; }
@media (max-width: 767px) {
  .builder-page .mobile-receipt-hint {
    display: block;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.45;
  }
  .builder-page #shFb.receipt-preparing,
  .builder-page #shDl:disabled {
    opacity: .55;
    cursor: progress;
    pointer-events: none;
  }
}
