/* V8.23 mobile editor: keep the live bouquet visible above the controls.
   Does not touch desktop, Photo Preview, checkout, authentication or backend. */
@media (max-width:760px) {
  body.pm-simple-mode .builder, body.pm-advanced-mode .builder{overflow:visible!important;align-items:stretch!important;}
  body.pm-simple-mode .builder>.preview, body.pm-advanced-mode .builder>.preview {
    position:sticky!important; top:0; z-index:52; align-self:stretch;
    background:#fbfaf7; padding:6px 10px!important;
    border-bottom:1px solid #d8e5dc;
    box-shadow:0 8px 18px rgba(35,73,52,.12);
    overflow:visible;
  }
  /* A compact view of the SAME live, draggable SVG—not a separate stale image. */
  body.pm-simple-mode .preview .canvas-wrap,body.pm-advanced-mode .preview .canvas-wrap {
    height:clamp(185px,29dvh,270px)!important;min-height:0!important;
    max-height:30dvh!important; overflow:hidden;
  }
  body.pm-simple-mode .preview #bouquetCanvas,body.pm-advanced-mode .preview #bouquetCanvas{
    max-height:100%!important; max-width:100%!important;
  }
  body.pm-advanced-mode .preview-toolbar{display:flex;flex-wrap:nowrap;align-items:center;gap:8px;min-height:37px;max-height:43px;overflow-x:auto;scrollbar-width:none;margin:0;}
  body.pm-advanced-mode .preview-toolbar::-webkit-scrollbar{display:none;}
  body.pm-advanced-mode .preview-toolbar .live-label{display:none;}
  body.pm-advanced-mode .preview-toolbar .toolbar-actions{display:flex;flex-wrap:nowrap;white-space:nowrap;gap:5px;width:max-content;}
  body.pm-advanced-mode .preview-toolbar .icon-btn{flex-shrink:0;min-height:32px;}
  /* Keep original controls in the editor; hide only redundant explanatory chrome */
  body.pm-advanced-mode .preview .view-help,body.pm-advanced-mode .preview .preview-scenes{display:none!important;}
  body.pm-advanced-mode .preview-footer{display:flex;gap:6px;align-items:center;justify-content:space-between;padding:5px 2px;margin:0;min-height:40px;flex-wrap:nowrap;}
  body.pm-advanced-mode .preview-footer .design-name{font:600 12px/1.3 Georgia,serif;margin:0;}
  body.pm-advanced-mode .preview-footer .recipe-line{font-size:10px;margin:0;}
  body.pm-advanced-mode .preview-footer .recipe-button,body.pm-advanced-mode .preview-footer .pm-share-btn{min-height:35px;padding:4px 7px;font-size:10px;flex:0 0 auto;width:auto;}
  body.pm-simple-mode .preview .preview-footer{display:none!important;}
  body.pm-simple-mode .controls,body.pm-advanced-mode .controls{overflow:visible!important;scroll-margin-top:clamp(205px,34dvh,350px);}
  body.pm-simple-mode #pmSimpleRecipe,body.pm-advanced-mode #flowerSearch{scroll-margin-top:clamp(215px,35dvh,365px);}
  /* The selected-flower editor is a scrollable bottom sheet rather than a
     long card a screen away from the selected stem. Full original tools remain. */
  body.pm-simple-mode .controls #stemEditor:not([hidden]),
  body.pm-advanced-mode .controls #stemEditor:not([hidden]){
    display:block!important;position:fixed!important;inset:auto 8px calc(73px + env(safe-area-inset-bottom)) 8px!important;
    transform:none!important;order:initial!important;z-index:108!important;
    width:auto!important;max-height:min(43dvh,calc(100dvh - 34dvh - 90px))!important;
    overflow-y:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
    margin:0!important;padding:11px 12px!important;
    border:1px solid #cbdccf;border-radius:16px 16px 11px 11px;
    box-shadow:0 -10px 30px rgba(19,57,39,.22);background:#fffdf9;
  }
  body.pm-simple-mode .controls #stemEditor .stem-editor-head,body.pm-advanced-mode .controls #stemEditor .stem-editor-head{
    position:sticky;top:-11px;z-index:1;padding:6px 0 8px;background:#fffdf9;
  }
  body.pm-simple-mode .controls #stemEditor .stem-tools,body.pm-advanced-mode .controls #stemEditor .stem-tools{
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;
  }
  body.pm-simple-mode .controls #stemEditor .stem-tools button,body.pm-advanced-mode .controls #stemEditor .stem-tools button{
    min-height:37px!important;font-size:12px!important;
  }
  body.pm-simple-mode .controls #stemEditor .stem-tools [data-stem-action="remove"],
  body.pm-advanced-mode .controls #stemEditor .stem-tools [data-stem-action="remove"]{grid-column:1/-1;}
  /* A foreground sheet should never trap the free/paid options in the footer. */
  body.pm-stem-editing .pm-easy-mobile-bar{z-index:112;}
  body.pm-ai-preview-open .controls #stemEditor{display:none!important;}
  /* Touch actual flowers to move them; dragging the empty background won't
     rotate the entire design. Scroll the page from outside the live SVG. */
  #bouquetCanvas .bouquet-item,#bouquetCanvas .bouquet-item * {touch-action:none!important;}
}
@media(max-width:760px){
  /* Reduce the original editor's long preview chrome; the matching controls
     remain available through the bottom purchase action and editor tabs. */
  body.pm-advanced-mode .preview #loadedIdeaSummary,
  body.pm-advanced-mode .preview .inspiration-rotate,
  body.pm-advanced-mode .preview .pm-ai-launch {display:none!important;}
  body.pm-advanced-mode .preview .view-switch {margin:2px 0 4px;gap:5px;}
  body.pm-advanced-mode .preview .view-switch button {min-height:32px;padding:6px 12px;font-size:11px;}
}
@media (max-width:760px){
  /* The old html+body overflow:auto makes body a non-scrolling sticky
     ancestor in Chrome's mobile webview. Let the document own scrolling so
     the bouquet preview genuinely stays pinned while editing lower down. */
  html {overflow-y:visible!important;}
  body.pm-simple-mode,body.pm-advanced-mode {overflow-y:visible!important;}
}
@media(max-width:760px){
  /* Advanced mode must inherit the SAME fixed purchase rail; previously its
     display:flex declaration omitted position:fixed. */
  body.pm-advanced-mode .pm-easy-mobile-bar{
    display:flex!important;position:fixed!important;bottom:0;left:0;right:0;
    z-index:112;gap:8px;padding:10px 12px calc(10px + env(safe-area-inset-bottom));
    background:#fffffff2;border-top:1px solid #dfe9db;box-shadow:0 -8px 25px #244b3520;
  }
  body.pm-advanced-mode .pm-easy-mobile-bar[hidden]{display:none!important;}
  body.pm-advanced-mode #pmMobilePhoto{min-height:49px;font-size:14px;}
}
@media(max-width:760px){
  /* The free florist brief must open ABOVE both sticky canvas and editor sheet.
     The legacy backdrop uses z-index:20, too low for the new mobile workspace. */
  #modalBackdrop.open{z-index:2500!important;}
  body:has(#modalBackdrop.open) .controls #stemEditor,
  body:has(#modalBackdrop.open) .pm-easy-mobile-bar{display:none!important;}
}

/* V8.23.1 mobile workspace refinement — give the bouquet, not the controls,
   the majority of the screen. Does not affect desktop or the purchase flow. */
@media (max-width:760px) {
  body.pm-simple-mode .preview .canvas-wrap,
  body.pm-advanced-mode .preview .canvas-wrap {
    height:clamp(285px,42dvh,390px)!important;
    max-height:44dvh!important;
  }
  /* A stem is selected: maximize the viewable arrangement. The same toolbar
     becomes available as soon as the user dismisses the selected flower. */
  /* V8.24.3: NEVER change the preview's height when a stem is tapped.
     Previously the toolbar and footer vanished, causing the sticky canvas
     to jump upward when the editor opened. Leave the existing chrome in flow.
     Browsing mode still hides it, regardless of selection. */
  body.pm-compact-stem-ready .controls #stemEditor:not([hidden]) {
    max-height:min(32dvh,245px)!important;
    padding:9px 11px!important;
    border-radius:16px;
  }
  body.pm-compact-stem-ready .controls #stemEditor .stem-editor-head {
    padding:4px 0 5px!important;
    top:-9px!important;
  }
  body.pm-compact-stem-ready .controls #stemEditor .stem-editor-head strong {font-size:14px!important;}
  body.pm-compact-stem-ready .controls #stemEditor .stem-editor-main {
    margin:5px 0 8px!important;gap:8px!important;font-size:11px!important;
  }
  body.pm-compact-stem-ready .controls #stemEditor .stem-editor-main select {height:35px!important;font-size:13px!important;margin-top:3px!important;}
  body.pm-compact-stem-ready .controls #stemEditor .stem-editor-main input {margin:6px 0 0!important;}
  body.pm-compact-stem-ready .controls #stemEditor .stem-layer-status {display:none!important;}
  body.pm-compact-stem-ready .controls #stemEditor .stem-tools {gap:6px!important;}
  body.pm-compact-stem-ready .controls #stemEditor .stem-tools button {min-height:34px!important;font-size:12px!important;padding:5px!important;}
  body.pm-compact-stem-ready:not(.pm-stem-expanded) .controls #stemEditor .stem-tools button:not([data-stem-action="rotate-left"]):not([data-stem-action="rotate-right"]) {display:none!important;}
  body.pm-compact-stem-ready .controls #stemEditor .pm-more-stem-tools {
    display:block;width:100%;min-height:33px;margin:8px 0 0;padding:5px 10px;
    border:1px solid #d1ded3;border-radius:9px;background:#f3f7f1;
    color:#2b5b45;font:750 12px/1.3 system-ui,sans-serif;cursor:pointer;
  }
  body.pm-compact-stem-ready .controls #stemEditor .pm-more-stem-tools:focus-visible {outline:3px solid #b0c8b2;outline-offset:2px;}
  body.pm-compact-stem-ready.pm-stem-expanded .controls #stemEditor:not([hidden]) {max-height:47dvh!important;}
  body.pm-compact-stem-ready.pm-stem-expanded .controls #stemEditor .stem-layer-status {display:flex!important;}
  body.pm-compact-stem-ready.pm-stem-expanded .controls #stemEditor .stem-tools button {display:block!important;}
  body.pm-compact-stem-ready.pm-stem-expanded .controls #stemEditor .stem-tools [data-stem-action="remove"] {grid-column:1/-1;}
}
/* The compact/expanded control is phone-only. Desktop retains its original
   complete, single-panel stem editor without any extra button. */
@media (min-width:761px) {
  #stemEditor .pm-more-stem-tools {display:none!important;}
}


/* V8.23.2 adaptive browsing preview — mobile only. Keep the SAME SVG canvas
   live while the visitor browses. No image copies and no editor state changes. */
@media (max-width:760px) {
  body.pm-simple-mode .preview,
  body.pm-advanced-mode .preview { transition:box-shadow .16s ease; }
  /* Once the reader scrolls into the flower list, the sticky bouquet reduces
     in height instead of consuming most of the screen. */
  body.pm-bouquet-browsing .builder>.preview {
    display:flex!important; flex-direction:row!important;align-items:center!important;
    gap:10px!important;min-height:0!important;padding:7px 10px!important;
    border-bottom:1px solid #c6d6c9;box-shadow:0 4px 14px #173d2725;
  }
  body.pm-bouquet-browsing .preview .preview-toolbar,
  body.pm-bouquet-browsing .preview .view-switch,
  body.pm-bouquet-browsing .preview .preview-footer,
  body.pm-bouquet-browsing .preview .pm-ai-launch,
  body.pm-bouquet-browsing .preview .view-help,
  body.pm-bouquet-browsing .preview #loadedIdeaSummary {display:none!important;}
  body.pm-bouquet-browsing .preview .canvas-wrap {
    flex:0 0 auto!important;width:116px!important;height:116px!important;
    max-width:116px!important;max-height:116px!important;
    min-height:0!important;margin:0!important;overflow:hidden!important;
    border:1px solid #e1e8df;border-radius:12px;background:#faf8f1;
  }
  body.pm-bouquet-browsing .preview #bouquetCanvas,
  body.pm-bouquet-browsing .preview #inspirationImage {
    max-width:100%!important;max-height:100%!important;
  }
  body.pm-bouquet-browsing .preview .pm-mobile-live-caption {
    display:flex!important;flex:1 1 auto;flex-direction:column;gap:5px;min-width:0;
    align-items:flex-start;justify-content:center;
    font-family:system-ui,-apple-system,sans-serif;color:#244b38;
  }
  body.pm-bouquet-browsing .preview .pm-mobile-live-caption strong {
    font-size:13px;line-height:1.25;font-weight:800;
  }
  body.pm-bouquet-browsing .preview .pm-mobile-live-caption small {
    font-size:11px;line-height:1.3;color:#5f7469;
  }
  body.pm-bouquet-browsing .preview .pm-mobile-expand {
    display:inline-flex!important;min-height:34px;align-items:center;gap:4px;
    border:1px solid #c4d6c8;border-radius:8px;background:#fff;
    color:#244b38;font-weight:750;font-size:12px;padding:6px 10px;cursor:pointer;
  }
  body.pm-bouquet-browsing .controls #stemEditor:not([hidden]) {
    max-height:min(39dvh,295px)!important;
  }
  /* Compact the library without removing color choices, season hints, or
     increment/decrement functionality. Two lines instead of tall info cards. */
  body.pm-advanced-mode #flowersPanel .flower-grid {gap:5px!important;}
  body.pm-advanced-mode #flowersPanel .flower-card {
    grid-template-columns:44px minmax(0,1fr) auto!important;
    gap:7px!important;min-height:74px!important;padding:6px 7px!important;
    border-radius:11px!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-icon {
    width:43px!important;height:46px!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .name {
    font-size:13px!important;line-height:1.18!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .role {
    display:none!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .pm-flower-season {
    font-size:10px!important;line-height:1.18!important;margin-top:2px!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .pm-season-badge {
    display:inline-block!important;font-size:10px!important;
    padding:3px 5px!important;margin:3px 0 0!important;
    line-height:1.15!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .variant-picker {
    margin-top:1px!important;gap:3px!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .variant-picker select {
    min-height:23px!important;max-width:105px!important;font-size:11px!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .type-total {
    min-height:0!important;font-size:10px!important;line-height:1.1!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .qty-stepper {
    grid-template-columns:31px 18px 31px!important;gap:2px!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .qty-btn {
    min-width:31px!important;min-height:40px!important;height:40px!important;
    width:31px!important;font-size:20px!important;
  }
  body.pm-advanced-mode #flowersPanel .flower-card .qty-count {
    font-size:13px!important;min-width:18px!important;
  }
  /* Compact the purchase bar above Pinterest's in-app Save control. */
  body.pm-simple-mode .pm-easy-mobile-bar,
  body.pm-advanced-mode .pm-easy-mobile-bar {
    padding:6px 10px calc(6px + env(safe-area-inset-bottom))!important;
    gap:7px!important;
  }
  body.pm-simple-mode .pm-easy-mobile-bar button,
  body.pm-advanced-mode .pm-easy-mobile-bar button {
    min-height:40px!important;height:42px!important;
    padding:6px 9px!important;font-size:12px!important;
    border-radius:10px!important;
  }
  /* A compact two-button toolbar; additional original actions remain in a
     disclosure instead of running off the right edge of the phone. */
  body.pm-advanced-mode .preview-toolbar {overflow:visible!important;max-height:none!important;position:relative;}
  body.pm-advanced-mode .preview-toolbar .toolbar-actions {width:100%;overflow:visible;align-items:center;flex-wrap:wrap;}
  body.pm-advanced-mode .preview-toolbar .toolbar-actions>.icon-btn:nth-child(n+3) {
    display:none!important;
  }
  body.pm-advanced-mode.pm-mobile-tools-open .preview-toolbar .toolbar-actions>.icon-btn:nth-child(n+3) {
    display:inline-flex!important;
  }
  body.pm-advanced-mode .preview-toolbar .pm-mobile-tools-toggle {
    display:inline-flex;align-items:center;justify-content:center;
    background:#f3f7f1;border:1px solid #cbdccd;border-radius:9px;
    padding:6px 10px;min-height:34px;color:#244b38;
    font:750 12px/1.2 system-ui,sans-serif;cursor:pointer;
  }
  body.pm-advanced-mode.pm-mobile-tools-open .preview-toolbar .toolbar-actions {
    background:#fdfdf9;border:1px solid #d9e3d8;padding:7px;border-radius:10px;
  }
}
@media(min-width:761px){
  .pm-mobile-live-caption,.pm-mobile-expand,.pm-mobile-tools-toggle{display:none!important;}
}
@media(max-width:760px){
  /* Hidden until the bouquet actually enters compact browsing mode. */
  .pm-mobile-live-caption,.pm-mobile-expand{display:none;}
}

/* V8.24 Touch-first mobile editing. Keep document scrolling outside canvas. */
.pm-mobile-nudge,.pm-quick-add,.pm-simple-tidy {display:none;}
@media(max-width:760px){
  #bouquetCanvas,.preview #bouquetCanvas,#bouquetCanvas *,#presentationCanvas {
    touch-action:none!important;
    -webkit-user-select:none!important;user-select:none!important;
    -webkit-touch-callout:none;
  }
  .preview .canvas-wrap {overscroll-behavior:contain;}
  #bouquetCanvas .drag-ring {
    stroke:#983E83!important;stroke-width:5.2!important;stroke-dasharray:6 3!important;
    filter:drop-shadow(0 0 5px rgba(255,255,255,.98)) drop-shadow(0 0 3px #983E83)!important;
    pointer-events:none!important;
  }
  #bouquetCanvas .bouquet-item[aria-pressed="true"] .item-hit {stroke:#983E83;stroke-width:2;}
  .pm-mobile-nudge {display:flex;align-items:center;justify-content:space-between;gap:5px;margin:8px 0 5px;}
  .pm-mobile-nudge span {font-size:12px;color:#405f50;font-weight:750;white-space:nowrap;margin-right:auto;}
  .pm-mobile-nudge button {min-width:37px;min-height:38px;border:1px solid #c9d9cd;background:#f1f6f0;
    border-radius:9px;color:#23523d;font-size:20px;font-weight:800;padding:0 7px;touch-action:manipulation;}
  .pm-mobile-nudge button:active {background:#d5e7da;}
  .pm-quick-add:not([hidden]) {display:block;background:#f5f9f5;border:1px solid #d3e0d5;
    border-radius:13px;padding:9px;margin:8px 0 12px;}
  .pm-quick-heading {display:flex;justify-content:space-between;flex-wrap:wrap;gap:4px;font-size:12px;margin-bottom:7px;}
  .pm-quick-heading small {color:#66766d;}
  .pm-quick-item {display:inline-flex;align-items:center;gap:7px;justify-content:space-between;
    margin:3px;padding:7px 9px;background:#fff;border:1px solid #cbdccc;border-radius:9px;
    color:#23533e;font-size:12px;min-height:37px;touch-action:manipulation;}
  .pm-quick-item strong {font-size:14px;}
  .pm-simple-tidy {display:flex;justify-content:center;align-items:center;gap:7px;
    border:1px solid #c2d5c7;border-radius:10px;background:#f1f6f1;color:#23513c;
    font-weight:750;font-size:13px;min-height:40px;width:100%;margin:11px 0;}
  .pm-simple-tidy small {font-size:10px;font-weight:500;color:#526e5e;}
  body.pm-advanced-mode .preview-toolbar .toolbar-actions>.icon-btn.pm-tidy-button {display:inline-flex!important;
    align-items:center;padding:0 8px;min-height:34px;font-size:11px;color:#335b42;background:#eaf4e9;}
  body.pm-advanced-mode .preview-toolbar .toolbar-actions {justify-content:flex-start;}
  body.pm-advanced-mode .preview-toolbar .toolbar-actions>.icon-btn:nth-child(n+4) {display:none!important;}
  body.pm-advanced-mode.pm-mobile-tools-open .preview-toolbar .toolbar-actions>.icon-btn:nth-child(n+4) {display:inline-flex!important;}
  body.pm-advanced-mode .preview-toolbar .toolbar-actions>.icon-btn.pm-tidy-button {display:inline-flex!important;}
}

@media(max-width:760px){
  .pm-mobile-history-actions {display:none;}
  body.pm-bouquet-browsing .pm-mobile-history-actions {
    display:flex;gap:4px;margin-top:2px;align-items:center;flex-wrap:wrap;
  }
  .pm-mobile-history-actions button {
    background:#eff5ef;border:1px solid #c6d7ca;color:#25523b;
    border-radius:8px;min-height:30px;min-width:51px;font-size:11px;font-weight:750;
    padding:3px 6px;touch-action:manipulation;
  }
  .pm-mobile-history-actions button:disabled{opacity:.37;}
  body.pm-bouquet-browsing .pm-mobile-live-caption small {font-size:10px;line-height:1.15;}
  body.pm-bouquet-browsing .preview .pm-mobile-expand {font-size:11px;padding:6px 7px;}
}

/* V8.24.2: gentle indicator at the soft expansion threshold. */
@media(max-width:760px){
  /* No change to height, padding, button text, or layout at the threshold.
     Only background color changes softly; nothing to trigger layout jumping. */
  body.pm-bouquet-browsing .preview .pm-mobile-expand {
    transition:background-color .28s ease,border-color .28s ease,color .28s ease;
  }
  body.pm-bouquet-ceiling .preview .pm-mobile-expand {
    background:#eaf3eb;color:#24543d;border-color:#a9c8b0;
  }
  /* Avoid browser scroll-anchoring fighting the compact-height change. */
  body.pm-simple-mode .builder>.preview,
  body.pm-advanced-mode .builder>.preview {overflow-anchor:none;}
}
@media(prefers-reduced-motion:reduce){
  body.pm-bouquet-browsing .preview .pm-mobile-expand {transition:none!important;}
}

/* V8.24.3 — no-jump mobile selection and an always-findable delete action. */
@media (max-width:760px){
  body.pm-simple-mode .controls #stemEditor .stem-editor-head,
  body.pm-advanced-mode .controls #stemEditor .stem-editor-head {
    display:flex;align-items:center;gap:8px;flex-wrap:nowrap;
  }
  #stemEditor .stem-editor-head strong{flex:1 1 auto;min-width:0;overflow-wrap:anywhere;}
  #stemEditor .stem-editor-head .pm-mobile-delete-stem {
    display:inline-flex;flex:0 0 auto;align-items:center;justify-content:center;
    min-height:35px;padding:6px 10px;border:1px solid #bc8790;
    border-radius:9px;background:#fff1f2;color:#8f3748;
    font:750 12px/1.15 system-ui,sans-serif;touch-action:manipulation;
  }
  #stemEditor .stem-editor-head .pm-mobile-delete-stem:focus-visible {
    outline:2px solid #983e83;outline-offset:2px;
  }
  /* Selection is visual, not a scroll or page-layout event. */
  body.pm-stem-editing .builder>.preview {scroll-margin-top:0;}
}
@media(min-width:761px){#stemEditor .pm-mobile-delete-stem{display:none!important;}}
