/* ============================================
   MapToPrint V3 - Generate Page Styles
   ============================================ */

.generate-page {
    --generate-workspace-bg: var(--bc-workspace);
    height: 100vh;
    overflow: hidden;
    background: var(--generate-workspace-bg);
}

/* Prevent controls FOUC while JS rebuilds the shell (all viewports). */
body.controls-shell-init .controls-panel {
    visibility: hidden;
    pointer-events: none;
}

/* Full-page loading overlay - visible only while controls-shell-init is active */
.generate-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bc-bg);
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.generate-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(216, 160, 126, 0.15);
    border-top-color: var(--bc-clay);
    border-radius: 50%;
    animation: generateSpin 0.7s linear infinite;
}

@keyframes generateSpin {
    to { transform: rotate(360deg); }
}

.feature-flag-pill {
    display: none;
    position: fixed;
    top: calc(64px + var(--space-2));
    right: var(--space-3);
    z-index: var(--z-toast);
    padding: var(--space-1) var(--space-3);
    border-radius: 999px;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--bc-clay);
    color: var(--bc-bg);
    box-shadow: var(--shadow-sm);
}

body.feature-mobile-v2 .feature-flag-pill {
    display: inline-flex;
    align-items: center;
}

/* Mobile nav buy button */
body.feature-mobile-v2 .mobile-generate-nav-hidden {
    display: none !important;
}

body.feature-mobile-v2 .mobile-nav-buy-btn {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid var(--bc-clay);
    border-radius: 999px;
    background: var(--bc-clay);
    color: var(--bc-decision-cta-text);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-fast);
}

body.feature-mobile-v2 .mobile-nav-buy-btn:active {
    opacity: 0.9;
    transform: scale(0.97);
}

body.feature-mobile-v2 .mobile-nav-buy-main {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}

body.feature-mobile-v2 .mobile-nav-buy-label {
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

body.feature-mobile-v2 .mobile-nav-buy-price {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    align-self: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.95;
    text-align: left;
    width: auto;
    min-width: 0;
    flex-shrink: 1;
}

body.feature-mobile-v2 .mobile-nav-buy-price .discount-price-list {
    display: none;
}

body.feature-mobile-v2 .mobile-nav-buy-price .discount-price-sale {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    white-space: nowrap;
    text-align: left;
    transform: translateY(0.5px);
}


.mobile-sheet-handle,
.controls-actions-mobile {
    display: none;
}

/* ============================================
   Header
   ============================================ */

/* Header now uses .nav-full from styles.css (matches all pages) */

.nav-print-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    line-height: 1;
    border-radius: 999px;
}

.nav-print-cta svg {
    flex-shrink: 0;
}

.nav-download-fallback {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    line-height: 1;
    border-radius: 999px;
}

/* Desktop-only: compact dropdown-style menu. At max-width 768px, global slide drawer from styles.css applies. */
@media (min-width: 769px) {
    .generate-page .nav.nav-full .nav-menu {
        display: none;
        position: absolute;
        top: calc(100% + 0.5rem);
        right: 1rem;
        z-index: 1100;
        min-width: 180px;
        padding: 0.5rem;
        border-radius: 12px;
        border: 1px solid var(--bc-border);
        background: rgba(11, 17, 33, 0.96);
        flex-direction: column;
        gap: 0.25rem;
    }

    .generate-page .nav.nav-full .nav-inner {
        position: relative;
    }

    .generate-page .nav.nav-full .nav-menu.is-open {
        display: flex;
    }
}

.nav-site-toggle {
    /* Uses global nav styles from css/styles.css */
}

/* Feature-gated release model:
 * - production (default): fallback download-first header
 * - test with FEATURES_GATED=true: print/auth/save/download-auth surfaces
 */
body:not(.features-gated) .nav-print-cta,
body:not(.features-gated) #saveDesignBtn,
body:not(.features-gated) #downloadHighResBtn,
body:not(.features-gated) #downloadMenuSaveOption,
body:not(.features-gated) #downloadMenuHighResOption,
body:not(.features-gated) #authModal {
    display: none !important;
}

body:not(.features-gated) .nav-download-fallback {
    display: inline-flex;
}

body:not(.features-gated) .controls-group[data-panel="download"] {
    display: none;
}

/* Options panel hidden on desktop pill - sizing handled on product/checkout pages */
@media (min-width: 901px) {
    .controls-group[data-panel="options"] {
        display: none;
    }
}

/* ── Options panel (size / paper / frame) ────── */

/* Hidden DOM hub for checkout grids (#checkoutOptionsHub); not a sidebar tab */
.checkout-options-hub {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.options-panel-section {
    padding: 0.75rem 0.9rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.options-panel-heading {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bc-text-warm);
}

.options-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.options-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    background: var(--bc-surface);
    color: var(--bc-text-warm);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.options-chip:hover {
    border-color: var(--bc-clay);
    color: var(--bc-text-clay-deep);
    background: var(--bc-clay-soft);
}

.options-chip--active {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-text-clay-deep);
}

.options-chip-label {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
}

.options-chip-sub {
    font-size: 0.65rem;
    opacity: 0.65;
    line-height: 1;
}

.frame-paper-chip-grid .options-chip-price {
    margin-top: 0.15rem;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    max-width: 100%;
    opacity: 0.88;
}

.frame-paper-chip-grid .options-chip-price .options-chip-price-list {
    display: block;
    opacity: 0.65;
    font-size: 0.58rem;
}

.frame-paper-chip-grid .options-chip-price .options-chip-price-sale {
    display: block;
}

/* Paper info icon + tooltip */
.frame-paper-chip-grid .options-chip {
    position: relative;
}
.paper-info-wrap {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
}
.paper-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--bc-workspace, #f5f0eb);
    color: var(--bc-text-muted, #9a8e82);
    cursor: help;
    transition: color 0.15s ease, background 0.15s ease;
}
.paper-info-btn:hover {
    color: var(--bc-clay, #b08968);
    background: var(--bc-clay-soft, #f3ebe2);
}
.paper-info-btn svg {
    pointer-events: none;
}
.paper-info-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: max-content;
    max-width: 180px;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: var(--bc-surface, #fff);
    color: var(--bc-text-muted, #6b5e52);
    font-size: 0.65rem;
    font-weight: 400;
    line-height: 1.4;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    z-index: 20;
    text-align: left;
    white-space: normal;
    pointer-events: none;
}
.paper-info-tooltip.visible {
    display: block;
}

.options-price-display {
    margin: 0.2rem 0 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--bc-clay);
    min-height: 1.2em;
}

.discount-price-list {
    margin-right: 0.35rem;
    opacity: 0.72;
}

.discount-price-sale {
    color: inherit;
}

/* ── Frame option chips with visual preview ──────────────── */

.options-chip--frame {
    padding: 0.4rem 0.6rem;
    min-width: 70px;
}

.options-chip--unavailable {
    opacity: 0.38;
    cursor: not-allowed;
}

/* Small poster-shaped frame preview icon inside chip */
.options-chip-frame-icon {
    display: block;
    width: 28px;
    height: 36px;
    border-radius: 2px;
    position: relative;
    margin-bottom: 0.15rem;
}

.frame-chip-unframed {
    background: linear-gradient(160deg, #f3ede3 0%, #ebe3d8 100%);
    border: 1px dashed var(--bc-border);
}

.frame-chip-black {
    background: linear-gradient(160deg, #f3ede3 0%, #ebe3d8 100%);
    border: 5px solid var(--bc-ink);
    box-shadow: 0 0 0 1px var(--bc-border), inset 0 0 0 1px rgba(0,0,0,0.06);
}

.frame-chip-white {
    background: linear-gradient(160deg, #f3ede3 0%, #ebe3d8 100%);
    border: 5px solid #e8e6e0;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.25), inset 0 0 0 1px rgba(0,0,0,0.08);
}

/* Wood frame chips - grain borders in physical-preview-wood.css */
.frame-chip-natural {
    border: 5px solid transparent;
}

.frame-chip-dark-wood {
    border: 5px solid transparent;
}

.frame-chip-hanger-black,
.frame-chip-hanger-white,
.frame-chip-hanger-natural,
.frame-chip-hanger-dark {
    background: linear-gradient(160deg, #f3ede3 0%, #ebe3d8 100%);
    border: none;
    box-shadow: none;
}

.frame-chip-hanger-black::before,
.frame-chip-hanger-black::after,
.frame-chip-hanger-white::before,
.frame-chip-hanger-white::after,
.frame-chip-hanger-natural::before,
.frame-chip-hanger-natural::after,
.frame-chip-hanger-dark::before,
.frame-chip-hanger-dark::after {
    content: '';
    position: absolute;
    left: calc(-1 * var(--hanger-rail-overhang-x) * 0.35);
    right: calc(-1 * var(--hanger-rail-overhang-x) * 0.35);
    height: 10px;
    border-radius: 1px;
}

/* Edit-menu mode icons: thinner rails, less overhang than poster preview */
.physical-frame-mode-icon.frame-chip-hanger-black::before,
.physical-frame-mode-icon.frame-chip-hanger-black::after,
.physical-frame-mode-icon.frame-chip-hanger-white::before,
.physical-frame-mode-icon.frame-chip-hanger-white::after,
.physical-frame-mode-icon.frame-chip-hanger-natural::before,
.physical-frame-mode-icon.frame-chip-hanger-natural::after,
.physical-frame-mode-icon.frame-chip-hanger-dark::before,
.physical-frame-mode-icon.frame-chip-hanger-dark::after {
    left: 12%;
    right: 12%;
    height: 4px;
    border-radius: 1px;
}

.physical-frame-mode-icon.frame-chip-hanger-black::before,
.physical-frame-mode-icon.frame-chip-hanger-white::before,
.physical-frame-mode-icon.frame-chip-hanger-natural::before,
.physical-frame-mode-icon.frame-chip-hanger-dark::before {
    top: 3px;
}

.physical-frame-mode-icon.frame-chip-hanger-black::after,
.physical-frame-mode-icon.frame-chip-hanger-white::after,
.physical-frame-mode-icon.frame-chip-hanger-natural::after,
.physical-frame-mode-icon.frame-chip-hanger-dark::after {
    bottom: 3px;
}

.frame-chip-hanger-black::before,
.frame-chip-hanger-white::before,
.frame-chip-hanger-natural::before,
.frame-chip-hanger-dark::before { top: 1px; }

.frame-chip-hanger-black::after,
.frame-chip-hanger-white::after,
.frame-chip-hanger-natural::after,
.frame-chip-hanger-dark::after { bottom: 1px; }

.frame-chip-hanger-black::before,
.frame-chip-hanger-black::after { background: #1a1410; box-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.frame-chip-hanger-white::before,
.frame-chip-hanger-white::after { background: #e8e6e0; box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.1); }
/* Hanger chip rail colors - physical-preview-wood.css */

.options-chip-group-label {
    flex: 0 0 100%;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bc-text-warm);
    margin: 0.35rem 0 0.1rem;
    width: 100%;
}

.physical-frame-chip-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.physical-frame-mode-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
}

.physical-frame-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    min-height: 44px;
    padding: 0.625rem 0.25rem;
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    background: var(--bc-surface);
    color: var(--bc-text-warm);
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.physical-frame-mode:hover:not(:disabled) {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-text-clay-deep);
}

.physical-frame-mode--active {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-text-clay-deep);
}

.physical-frame-mode--unavailable {
    opacity: 0.38;
    cursor: not-allowed;
}

.physical-frame-mode-icon {
    flex-shrink: 0;
    margin-bottom: 0;
}

.physical-frame-mode-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    width: 100%;
    min-width: 0;
}

.physical-frame-mode-label {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.15;
}

.physical-frame-mode .physical-frame-chip-price {
    display: block;
    width: 100%;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    opacity: 0.88;
}

.physical-frame-mode .physical-frame-chip-price .options-chip-price-list {
    display: block;
    opacity: 0.65;
    font-size: 0.58rem;
    font-weight: 400;
}

.physical-frame-mode .physical-frame-chip-price .options-chip-price-sale {
    display: block;
}

.physical-frame-swatch-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    width: 100%;
    max-width: 100%;
    margin-top: 0.1rem;
}

.physical-frame-mode .physical-frame-swatch {
    width: 12px;
    height: 8px;
    padding: 0;
    border-width: 1px;
    border-radius: 3px;
    flex-shrink: 1;
    min-width: 0;
    max-width: 14px;
}

.physical-frame-swatch {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 14px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.physical-frame-swatch:hover:not(:disabled) {
    transform: translateY(-1px);
}

.physical-frame-swatch--active {
    border-color: var(--bc-clay);
    box-shadow: 0 0 0 2px var(--bc-clay-soft);
}

.physical-frame-swatch--unavailable {
    opacity: 0.35;
    cursor: not-allowed;
}

.physical-frame-color-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.25rem;
    width: 100%;
    padding-top: 0.15rem;
}

.physical-frame-color {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 0;
    min-width: 0;
    padding: 0.28rem 0.12rem;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: var(--bc-surface);
    color: var(--bc-text-warm);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
}

.physical-frame-color:hover:not(:disabled) {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
}

.physical-frame-color--active {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-text-clay-deep);
}

.physical-frame-color--unavailable {
    opacity: 0.38;
    cursor: not-allowed;
}

.physical-frame-color .physical-frame-swatch {
    width: 16px;
    height: 10px;
    pointer-events: none;
}

.physical-frame-color-label {
    font-size: 0.58rem;
    font-weight: 600;
    line-height: 1.05;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.frame-unavail-note {
    font-size: 0.6rem;
    color: var(--bc-text-warm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Size standard toggle (CM/Inch) ─────────────────────── */
.size-standard-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.size-standard-label {
    font-size: 0.72rem;
    color: var(--bc-text-warm);
    white-space: nowrap;
    flex-shrink: 0;
}

.size-std-btn {
    -webkit-appearance: none;
    appearance: none;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    background: var(--bc-surface, #fff);
    color: var(--bc-ink);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.size-std-btn:hover {
    border-color: var(--bc-clay);
    color: var(--bc-ink);
}

.size-std-btn.active {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-text-clay-deep);
}

/* ── Admin mode badge (clickable save trigger) ─ */

.admin-mode-badge {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    background: var(--bc-clay-soft);
    border: 1px solid var(--bc-clay);
    color: var(--bc-text-clay-deep);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.42rem 1.1rem;
    border-radius: var(--bc-radius-pill);
    cursor: pointer;
    transition: background 150ms ease, box-shadow 150ms ease;
    user-select: none;
}

.admin-mode-badge:hover {
    background: var(--bc-clay-soft);
    box-shadow: 0 0 0 3px var(--bc-clay-soft);
}

/* ── Admin: Add to cart button override ─────── */
.controls-cart-btn--admin {
    background: var(--bc-clay-soft) !important;
    border: 1px solid var(--bc-clay);
    color: var(--bc-text-clay-deep) !important;
}
.controls-cart-btn--admin:hover {
    background: #eed6c5 !important;
}

/* ── Admin: Export JPEG button ──────────────── */
.admin-export-jpeg-btn {
    position: fixed;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    background: rgba(99,179,237,0.15);
    border: 1px solid rgba(99,179,237,0.45);
    color: #93c5fd;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.32rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 150ms ease, box-shadow 150ms ease;
    white-space: nowrap;
}
.admin-export-jpeg-btn:hover:not(:disabled) {
    background: rgba(99,179,237,0.25);
    box-shadow: 0 0 0 3px rgba(99,179,237,0.18);
}
.admin-export-jpeg-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* ── Save as Product overlay ────────────────── */

.save-product-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(90, 79, 71, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.save-product-overlay[hidden] {
    display: none;
}

.save-product-modal {
    background: var(--bc-surface);
    border: 1px solid var(--bc-border-strong);
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
}

.save-product-title {
    margin: 0;
    font-size: 1.2rem;
    color: var(--bc-ink);
}

.save-product-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--bc-text-muted);
}

.save-product-label {
    font-size: 0.82rem;
    color: var(--bc-text-warm);
}

.save-product-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--bc-border-strong);
    border-radius: 9px;
    background: var(--bc-workspace);
    color: var(--bc-ink);
    font-size: 1rem;
}

.save-product-input:focus {
    outline: none;
    border-color: var(--bc-clay);
    box-shadow: 0 0 0 3px var(--bc-clay-soft);
}

.save-product-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.save-product-btn {
    padding: 0.55rem 1.2rem;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}

.save-product-btn--cancel {
    background: var(--bc-workspace);
    color: var(--bc-ink);
    border-color: var(--bc-border-strong);
}

.save-product-btn--confirm {
    background: var(--bc-clay);
    color: var(--bc-decision-cta-text);
}

.save-product-btn--confirm:hover {
    background: #e0a869;
}

.save-product-btn--confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.save-product-status {
    margin: 0;
    font-size: 0.82rem;
    color: var(--bc-text-muted);
    min-height: 1.2em;
}

/* ── Controls pill: Add to cart button ─────────── */

.controls-cart-btn {
    /* Hidden on mobile - the bottom nav handles it */
    display: none;
}

@media (min-width: 901px) {
    .controls-cart-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        width: var(--controls-pill-btn-width, 100px);
        min-width: var(--controls-pill-btn-width, 100px);
        align-self: center;
        -webkit-appearance: none;
        appearance: none;
        border: 1px solid var(--bc-clay);
        border-radius: 14px;
        background: var(--bc-clay);
        color: var(--bc-decision-cta-text);
        cursor: pointer;
        padding: 0.65rem 0.1rem;
        transition: background 150ms ease, transform 100ms ease, border-color 150ms ease;
    }

    .controls-cart-btn:hover {
        background: var(--bc-clay);
        border-color: var(--bc-clay);
        opacity: 0.9;
        transform: scale(1.03);
    }

    .controls-cart-btn:active {
        transform: scale(0.97);
    }

    .controls-cart-btn:disabled {
        opacity: 0.45;
        cursor: not-allowed;
        transform: none;
    }

    .controls-cart-main {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.45rem;
        width: 100%;
        min-width: 0;
    }

    .controls-cart-icon {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .controls-cart-label {
        font-size: 0.95rem;
        font-weight: 700;
        line-height: 1.1;
        letter-spacing: 0.01em;
        white-space: nowrap;
        text-align: center;
    }

    .controls-cart-price {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 0.75rem;
        font-weight: 600;
        line-height: 1;
        letter-spacing: 0.01em;
        opacity: 0.75;
        text-align: center;
        width: 100%;
        max-width: 100%;
    }

    .controls-cart-price .discount-price-list,
    .controls-cart-price .discount-price-sale {
        display: block;
        width: 100%;
        text-align: center;
        white-space: normal;
    }

    .controls-cart-price .discount-price-list {
        margin-right: 0;
        color: var(--bc-decision-cta-text);
        opacity: 0.85;
    }

    .controls-cart-price .discount-price-sale {
        color: var(--bc-decision-cta-text);
    }

    .discount-price-list,
    .discount-price-sale {
        white-space: nowrap;
    }
}

/* ============================================
   Main Layout
   ============================================ */

.generate-main {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - var(--header-offset));
    /* Keep generate content below fixed header (nav + promo; --header-offset from styles.css + nav.js) */
}

/* Left rail: controls panel first, preview to the right (unified with mobile V2 order) */
.controls-panel {
    order: 1;
}

.preview-section {
    order: 2;
}

/* ============================================
   Controls Panel
   ============================================ */

.controls-panel {
    position: relative;
    background: var(--bc-workspace);
    border-right: 1px solid var(--bc-border);
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Wraps rebuild groups + Buy; desktop adds max-height + scroll in min-width:901px block. */
.controls-panel-rail {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
    flex: 1 1 auto;
}

.controls-section {
    padding-bottom: 0;
    border-bottom: none;
}

.controls-group {
    display: flex;
    flex-direction: column;
}

.controls-group-toggle {
    display: none;
}

.controls-group-body {
    display: flex;
    flex-direction: column;
}

.controls-group-subitems {
    display: flex;
    flex-direction: column;
}

.controls-flyout-collapse {
    display: none;
}

/* Same offset after Buildings as after Railway (before Other) */
.map-layers-panel .layer-toggles:last-of-type {
    margin-bottom: 1.5rem;
}

.controls-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 400;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    color: var(--bc-ink);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.controls-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    background: var(--bc-clay);
    color: var(--bc-bg);
    border-radius: 50%;
    flex-shrink: 0;
}

.controls-step {
    display: none;
}

.controls-hint {
    font-size: 0.75rem;
    color: var(--bc-text-warm);
    margin-top: 0.5rem;
}

/* Search */
.use-current-location-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bc-text-muted);
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.use-current-location-btn:hover {
    color: var(--bc-clay);
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
}

.use-current-location-btn:active {
    transform: scale(0.98);
}

.use-current-location-btn svg {
    display: block;
    flex-shrink: 0;
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    color: var(--bc-ink);
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    outline: none;
    transition: var(--transition-fast);
}

.search-input::placeholder {
    color: var(--bc-text-warm);
}

.search-input:focus {
    border-color: var(--bc-clay);
    box-shadow: 0 0 0 3px var(--bc-clay-soft);
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bc-text-warm);
    pointer-events: none;
}

.search-confirm-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bc-clay);
    color: var(--bc-decision-text);
    border: none;
    border-radius: 7px;
    width: 34px;
    height: 34px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), opacity var(--transition-fast);
    z-index: 1;
}

.search-confirm-btn:hover {
    opacity: 0.85;
}

.search-confirm-btn:active {
    opacity: 0.7;
}

.search-wrapper.has-text .search-confirm-btn {
    display: flex;
}

.search-wrapper.has-text .search-input {
    padding-right: 3.25rem;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    overflow: hidden;
    z-index: 50;
    display: none;
    max-height: 240px;
    overflow-y: auto;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item.is-selected {
    background: rgba(90, 79, 71, 0.08);
    outline: 1px solid rgba(90, 79, 71, 0.18);
}

.autocomplete-item-message {
    cursor: default;
}

.autocomplete-item-message:hover {
    background: transparent;
}

.autocomplete-item {
    padding: 0.875rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bc-border);
    transition: var(--transition-fast);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--bc-surface);
}

.autocomplete-item-city {
    font-weight: 500;
}

.autocomplete-item-country {
    font-size: 0.8125rem;
    color: var(--bc-text-muted);
}

/* Location Panel */
.location-panel {
    padding-top: 1rem;
}

.text-style-panel,
.rotation-panel {
    padding-top: 1rem;
}

/* Radius Panel */
.radius-panel {
    padding-top: 1rem;
}

/* Theme Panel */
.theme-panel {
    padding-top: 1rem;
}

/* Size Panel */
.size-panel {
    padding-top: 1rem;
}

/* Paper type (Frame group) */
.paper-panel {
    padding-top: 1rem;
    overflow: visible;
}

/* Occasion Panel */
.occasion-panel {
    padding-top: 1rem;
}

/* Poster Style Panel */
.poster-style-panel {
    padding-top: 1rem;
}

/* Map Icons Panel */
.map-icons-panel {
    padding-top: 1rem;
}

/* Map Layers Panel */
.map-layers-panel {
    padding-top: 1rem;
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.theme-swatch {
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.theme-swatch:hover {
    transform: scale(1.1);
    z-index: 1;
}

.theme-swatch.selected {
    border-color: var(--bc-clay);
    box-shadow: 0 0 0 2px var(--bc-clay-soft);
}

.theme-popular-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.45rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bc-decision-text);
    background: rgba(0,0,0,0.45);
    border-radius: 4px;
    padding: 0.15rem 0.35rem;
    pointer-events: none;
    line-height: 1.4;
}

.theme-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.25rem 0.25rem 0.2rem;
    font-size: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: center;
    text-transform: uppercase;
    color: var(--bc-decision-text);
    background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 100%);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    line-height: 1.4;
}

/* Theme description tooltip on hover */
.theme-hint {
    min-height: 1.2rem;
    transition: opacity 0.15s ease;
}

/* Customize toggle (accordion) */
.controls-divider {
    padding: 0.5rem 0;
    border-top: 1px solid var(--bc-border);
    border-bottom: 1px solid var(--bc-border);
    margin: 0;
}

/* Hide redundant headers in Place and Text groups */
.controls-section[data-panel="place"][data-always-open="true"] > .controls-divider,
.controls-section[data-panel="labels"] > .controls-divider {
    display: none;
}

.controls-section[data-panel="labels"] .text-panel {
    display: block !important;
}

.customize-toggle,
#themeToggle,
#sizeToggle,
#textToggle,
#locationToggle,
#radiusToggle,
#occasionToggle,
#posterStyleToggle,
#mapIconsToggle,
#mapLayersToggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bc-text-muted);
    transition: var(--transition-fast);
}

.customize-toggle:hover,
#themeToggle:hover,
#sizeToggle:hover,
#textToggle:hover,
#locationToggle:hover,
#radiusToggle:hover,
#occasionToggle:hover,
#posterStyleToggle:hover,
#mapIconsToggle:hover,
#mapLayersToggle:hover {
    color: var(--bc-ink);
}

.customize-toggle .chevron,
#themeToggle .chevron,
#sizeToggle .chevron,
#textToggle .chevron,
#locationToggle .chevron,
#radiusToggle .chevron,
#occasionToggle .chevron,
#posterStyleToggle .chevron,
#mapIconsToggle .chevron,
#mapLayersToggle .chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.customize-toggle.open .chevron,
#themeToggle.open .chevron,
#sizeToggle.open .chevron,
#textToggle.open .chevron,
#locationToggle.open .chevron,
#radiusToggle.open .chevron,
#occasionToggle.open .chevron,
#posterStyleToggle.open .chevron,
#mapIconsToggle.open .chevron,
#mapLayersToggle.open .chevron {
    transform: rotate(180deg);
}

/* Desktop: unified nav style (same hierarchy as mobile V2) */
@media (min-width: 901px) {
    .generate-main {
        position: relative;
        grid-template-columns: 1fr;
    }

    .preview-section {
        order: 1;
        padding-left: 0;
    }

    .controls-panel {
        position: absolute;
        top: 1.5rem;
        left: 1rem;
        bottom: auto;
        width: max-content;
        z-index: 20;
        padding: 0.55rem 0.4rem;
        border: 1px solid var(--bc-border);
        border-radius: 22px;
        background: var(--bc-surface);
        box-shadow: var(--shadow-lg);
        gap: 0.5rem;
        overflow: visible;
        align-items: center;
    }

    /* Scroll the pill stack on short laptop viewports; flyouts use .controls-group { position: relative }. */
    .controls-panel-rail {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        min-height: 0;
        max-height: calc(100dvh - var(--header-offset) - 2.5rem);
        overflow-y: auto;
        /* Only the pill column scrolls; no horizontal scroll trap for flyouts. */
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* Styled scrollbar only when content overflows (see .controls-panel-rail--scrollable + JS). */
        scrollbar-width: none;
        width: 100%;
    }

    .controls-panel-rail.controls-panel-rail--scrollable {
        scrollbar-width: thin;
        scrollbar-color: var(--bc-clay) rgba(216, 160, 126, 0.1);
    }

    .controls-panel-rail.controls-panel-rail--scrollable::-webkit-scrollbar {
        width: 8px;
    }

    .controls-panel-rail.controls-panel-rail--scrollable::-webkit-scrollbar-track {
        background: rgba(216, 160, 126, 0.08);
        border-radius: 999px;
    }

    .controls-panel-rail.controls-panel-rail--scrollable::-webkit-scrollbar-thumb {
        background: var(--bc-clay);
        border-radius: 999px;
    }

    .controls-panel .controls-group[data-panel="place"]    { order: 1; }
    .controls-panel .controls-group[data-panel="route"]    { order: 1; }
    .controls-panel .controls-group[data-panel="style"]    { order: 2; }
    .controls-panel .controls-group[data-panel="labels"]   { order: 3; }
    .controls-panel .controls-group[data-panel="frame"]    { order: 4; }
    .controls-panel .controls-group[data-panel="extra"]    { order: 5; }
    .controls-panel .controls-cart-btn {
        order: 6;
    }

    .controls-group {
        position: relative;
        z-index: 0;
        width: var(--controls-pill-btn-width, 100px);
        min-width: var(--controls-pill-btn-width, 100px);
        border: 1px solid var(--bc-border-soft);
        border-radius: 18px;
        background: transparent;
        box-shadow: none;
        /* visible so the desktop flyout is not clipped; toggle keeps its own radius */
        overflow: visible;
        /* vertical rhythm: .controls-panel-rail gap only (avoids gap + margin doubling) */
        margin-bottom: 0;
        transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    }

    .controls-group.is-open {
        z-index: 1;
        border-color: var(--bc-clay);
        box-shadow: none;
    }

    .controls-group-toggle {
        display: flex;
        -webkit-appearance: none;
        appearance: none;
        align-items: center;
        justify-content: center;
        width: var(--controls-pill-btn-width, 100px);
        min-width: var(--controls-pill-btn-width, 100px);
        background: transparent;
        border: 1px solid transparent;
        border-radius: 14px;
        cursor: pointer;
        padding: 0.65rem 0.1rem;
        font-family: var(--font-sans);
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--bc-text-warm);
        text-align: center;
        transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    }

    .controls-group-toggle:hover {
        color: var(--bc-ink);
        background: rgba(216, 160, 126, 0.08);
        border-color: var(--bc-border-soft);
    }

    .controls-group-main {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.3rem;
        width: 100%;
        min-width: 0;
    }

    .controls-group-icon {
        flex-shrink: 0;
        opacity: 0.95;
    }

    .controls-group-label {
        line-height: 1.1;
        font-size: 0.95rem;
    }

    .controls-group.is-open .controls-group-toggle {
        color: var(--bc-decision-text);
        background: var(--bc-decision);
        border-color: transparent;
    }

    /* Fixed to viewport: avoids clipping by .controls-panel-rail scroll; position set via JS (see syncDesktopFlyoutHeight). */
    .controls-group-body {
        display: none;
        position: fixed;
        top: var(--controls-flyout-top, 0);
        left: var(--controls-flyout-left, 0);
        right: auto;
        width: var(--controls-flyout-width, min(320px, calc(100vw - 2rem)));
        max-width: min(320px, calc(100vw - 2rem));
        gap: 0.45rem;
        padding: 1rem;
        border: 1px solid var(--bc-border);
        border-radius: 22px;
        background: var(--bc-surface);
        box-shadow: var(--shadow-lg);
        z-index: 30;
        /* visible so .controls-flyout-collapse (absolute, translated past the edge) is not clipped */
        overflow: visible;
        box-sizing: border-box;
        flex-direction: column;
        height: var(--controls-rail-height, 420px);
        max-height: var(--controls-rail-height, 420px);
    }

    .controls-group.is-open .controls-group-body {
        display: flex;
    }

    .controls-group-subitems {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 0.2rem;
        border-radius: 12px;
        scrollbar-width: thin;
        scrollbar-color: var(--bc-clay) rgba(216, 160, 126, 0.1);
    }

    .controls-group[data-has-tabs="true"] .controls-group-subitems {
        border-radius: 0 0 12px 12px;
    }

    .controls-group-subitems::-webkit-scrollbar {
        width: 10px;
    }

    .controls-group-subitems::-webkit-scrollbar-track {
        background: rgba(216, 160, 126, 0.08);
        border-radius: 999px;
    }

    .controls-group-subitems::-webkit-scrollbar-thumb {
        background: var(--bc-clay);
        border-radius: 999px;
        border: 2px solid var(--bc-surface);
    }

    .controls-group-subitems::-webkit-scrollbar-thumb:hover {
        opacity: 0.9;
    }

    .controls-panel .controls-section {
        margin: 0;
        border: 1px solid transparent;
        border-radius: 12px;
        padding: 0.1rem 0.2rem;
    }

    .controls-group[data-has-tabs="true"] .desktop-group-tabs {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.5rem;
        margin: 0 0 0.8rem;
        padding: 0 0.15rem;
        overflow-x: auto;
        border-radius: 12px 12px 0 0;
    }

    .controls-group[data-has-tabs="true"] .desktop-group-tab {
        -webkit-appearance: none;
        appearance: none;
        border: 1px solid var(--bc-border-soft);
        background: var(--bc-bg);
        color: var(--bc-text-warm);
        border-radius: 999px;
        padding: 0.5rem 0.8rem;
        font-size: 0.82rem;
        font-weight: 600;
        cursor: pointer;
        transition: var(--transition-fast);
        white-space: nowrap;
    }

    .controls-group[data-has-tabs="true"] .desktop-group-tab:hover {
        color: var(--bc-ink);
        border-color: var(--bc-clay);
        background: rgba(216, 160, 126, 0.08);
    }

    .controls-group[data-has-tabs="true"] .desktop-group-tab.active {
        color: var(--bc-decision-cta-text);
        background: var(--bc-clay);
        border-color: var(--bc-clay);
        box-shadow: none;
    }

    .controls-group[data-has-tabs="true"] .controls-section {
        display: none;
        border: 0;
        padding: 0;
    }

    .controls-group[data-has-tabs="true"] .controls-section.is-active-tab {
        display: block;
    }

    /* True tabs mode: hide section heading rows entirely */
    .controls-group[data-has-tabs="true"] .controls-divider,
    .controls-group[data-has-tabs="true"] .controls-section .customize-toggle {
        display: none !important;
    }

    .controls-panel .controls-divider {
        border: 0;
        padding: 0;
        margin: 0 0 0.6rem;
    }

    .controls-panel .customize-toggle {
        -webkit-appearance: none;
        appearance: none;
        display: flex;
        align-items: center;
        gap: 0.55rem;
        width: 100%;
        min-height: 54px;
        padding: 0.8rem 1rem;
        border: 1px solid var(--bc-border-soft);
        border-radius: 22px;
        background: var(--bc-bg);
        color: var(--bc-ink);
        font-size: 1.05rem;
        font-weight: 500;
        text-align: left;
        transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    }

    /* Make all sub-items match the Perspective row component */
    .controls-group-body .customize-toggle,
    .controls-group-body #themeToggle,
    .controls-group-body #mapIconsToggle,
    .controls-group-body #mapLayersToggle,
    .controls-group-body #customThemeToggle,
    .controls-group-body #textStyleToggle,
    .controls-group-body #rotationToggle,
    .controls-group-body #perspectiveToggle,
    .controls-group-body #locationToggle,
    .controls-group-body #posterStyleToggle,
    .controls-group-body #sizeToggle,
    .controls-group-body #textToggle,
    .controls-group-body #textSizesToggle {
        min-height: 56px;
        padding: 0.9rem 1rem;
        border-radius: 28px;
        border: 1px solid var(--bc-border-soft);
        background: var(--bc-bg);
        font-size: 1rem;
        font-weight: 500;
        color: var(--bc-ink);
    }

    .controls-group-body .customize-toggle.open {
        border-color: var(--bc-clay);
        box-shadow: 0 0 0 2px var(--bc-clay-soft);
    }

    .controls-panel .customize-toggle .chevron {
        opacity: 0.85;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .controls-panel .customize-toggle:hover {
        border-color: var(--bc-clay);
    }

    .controls-panel .customize-toggle.open {
        color: var(--bc-ink);
        background: var(--bc-surface);
        border-color: var(--bc-clay);
        box-shadow: none;
        margin: 0;
    }

    .controls-panel .customize-toggle.open .chevron {
        opacity: 1;
        transform: rotate(180deg);
    }

    .controls-panel .customize-toggle:focus-visible {
        outline: none;
        box-shadow: 0 0 0 2px var(--bc-clay-soft);
    }

    /* Right edge of fixed flyout - tab sits past the submenu toward the map (not beside the rail). */
    .controls-flyout-collapse {
        position: absolute;
        right: 0;
        left: auto;
        top: 50%;
        transform: translate(calc(100% + 2px), -50%);
        width: 34px;
        height: 44px;
        border-radius: 10px 0 0 10px;
        border: 1px solid var(--bc-border-strong);
        background: var(--bc-bg);
        color: var(--bc-ink);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(26, 26, 26, 0.12);
        z-index: 4;
    }

    .controls-flyout-collapse:hover {
        border-color: var(--bc-clay);
        color: var(--bc-clay);
        background: var(--bc-surface);
    }

    .controls-flyout-collapse svg {
        flex-shrink: 0;
        stroke: currentColor;
        opacity: 0.9;
    }
}

/* Short-height laptops: tighten the rail so it fits more viewports before scrolling. */
@media (min-width: 901px) and (max-height: 820px) {
    .controls-panel-rail {
        gap: 0.35rem;
    }

    .controls-group-toggle {
        padding: 0.5rem 0.08rem;
        font-size: 0.85rem;
    }

    .controls-group-label {
        font-size: 0.85rem;
    }

    .controls-group-icon {
        width: 18px;
        height: 18px;
    }

    .controls-panel {
        padding: 0.55rem 0.4rem;
    }
}

.customize-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Custom Theme Panel */
.custom-theme-panel {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bc-border);
}

.color-pickers {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.custom-theme-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.45rem 0;
    background: none;
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    color: var(--bc-text-warm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.custom-theme-reset-btn:hover {
    color: var(--bc-text-muted);
    border-color: var(--bc-text-warm);
}
.custom-theme-reset-btn svg {
    flex-shrink: 0;
}

.color-picker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.color-picker-row span {
    font-size: 0.8125rem;
    color: var(--bc-text-muted);
}

.color-picker-row input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border: 2px solid var(--bc-border);
    border-radius: 6px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-picker-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-row input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.theme-swatch-custom {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bc-surface) !important;
    border: 2px dashed var(--bc-border) !important;
    color: var(--bc-text-warm);
}

.theme-swatch-custom:hover {
    border-color: var(--bc-clay) !important;
    color: var(--bc-clay);
}

.theme-swatch-custom.selected {
    border-color: var(--bc-clay) !important;
    border-style: solid !important;
    color: var(--bc-clay);
}

.theme-swatch-custom svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.theme-swatch-custom:hover svg,
.theme-swatch-custom.selected svg {
    opacity: 1;
}

/* Occasion Presets */
.occasion-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.occasion-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.625rem;
    background: var(--bc-surface);
    border: 1px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--bc-text-muted);
    transition: var(--transition-fast);
    white-space: nowrap;
}

.occasion-btn:hover {
    background: var(--bc-surface);
    border-color: var(--bc-border);
}

.occasion-btn.selected {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-clay);
}

.occasion-icon {
    font-size: 0.875rem;
}

/* Text Fields */
.text-fields {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.text-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.text-field-group.disabled .text-field-input {
    opacity: 0.35;
    pointer-events: none;
}

.text-field-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-field-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bc-text-warm);
}

.text-visibility-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    background: var(--bc-surface);
    color: var(--bc-text-warm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    padding: 0;
}

.text-visibility-icon-hidden {
    display: none;
}

.text-visibility-toggle.hidden .text-visibility-icon-open {
    display: none;
}

.text-visibility-toggle.hidden .text-visibility-icon-hidden {
    display: block;
}

.text-visibility-toggle:hover {
    background: var(--bc-surface);
    color: var(--bc-ink);
    border-color: var(--bc-text-warm);
}
.text-visibility-toggle.hidden {
    background: rgba(214, 189, 96, 0.1);
    border-color: rgba(214, 189, 96, 0.45);
    color: var(--bc-clay);
}

.text-field-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--bc-ink);
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    outline: none;
    transition: var(--transition-fast);
}

.text-field-input-row .text-field-input {
    flex: 1 1 auto;
}

.text-field-input:focus {
    border-color: var(--bc-clay);
    box-shadow: 0 0 0 2px var(--bc-clay-soft);
}

.text-field-input::placeholder {
    color: var(--bc-text-warm);
}

/* Divider toggle row */
.divider-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bc-border);
}

/* Font Selector */
.font-selector {
    display: flex;
    gap: 0.375rem;
}

.font-option {
    flex: 1;
    padding: 0.5rem 0.25rem;
    background: var(--bc-surface);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--bc-text-muted);
    text-align: center;
    transition: var(--transition-fast);
}

.font-option:hover {
    border-color: var(--bc-border);
}

.font-option.selected {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-clay);
}

/* Pin Selector */
.pin-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.pin-option {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bc-surface);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.125rem;
    transition: var(--transition-fast);
    color: var(--bc-text-warm);
}

.pin-option:hover {
    border-color: var(--bc-border);
    transform: scale(1.1);
}

.pin-option.selected {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
}

/* Poster Style Selector */
.poster-style-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.poster-style-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem;
    background: var(--bc-surface);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 0.75rem;
    color: var(--bc-text-muted);
}

.poster-style-option:hover {
    border-color: var(--bc-border);
    transform: translateY(-2px);
}

.poster-style-option.selected {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-ink);
}

.style-preview {
    width: 100%;
    aspect-ratio: 0.75;
    background: var(--bc-surface);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--bc-border);
}

.style-preview-map {
    width: 100%;
    height: 70%;
    background: #E0D8C8;
    background-size: cover;
    background-position: center;
}

/* Framed style thumbnail - map fills the entire preview */
.style-preview-framed {
    border: 3px solid #333;
    padding: 2px;
}

.style-preview-map-framed {
    width: 100%;
    height: 100%;
    background-color: #E0D8C8;
    background-size: cover;
    background-position: center;
}

/* Mat style thumbnail */
.style-preview-mat {
    padding: 8% 8% 22%;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border) !important;
}

.style-preview-map-inset {
    width: 100%;
    height: 100%;
    background-color: #E0D8C8;
    background-size: cover;
    background-position: center;
    border-radius: 1px;
}

/* Mat text area removed - white mat padding alone conveys the style */

/* Circle style thumbnail */
.style-preview-circle {
    background: var(--bc-surface);
    border: 1px solid var(--bc-border) !important;
}

.style-preview-map-circle {
    position: absolute;
    top: 4%;
    left: 50%;
    transform: translateX(-50%);
    width: 82%;
    aspect-ratio: 1;
    height: auto;
    background-color: #E0D8C8;
    background-size: cover;
    background-position: center;
    border-radius: 50%;
}

/* Circle text area removed - white space below circle conveys the style */

/* Boxed style thumbnail */
.style-preview-boxed {
    padding: 4%;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border) !important;
}

.style-preview-map-boxed {
    width: 100%;
    height: 100%;
    background-color: #E0D8C8;
    background-size: cover;
    background-position: center;
    border-radius: 1px;
    position: relative;
}

.style-preview-text-boxed {
    position: absolute;
    bottom: 16%;
    left: 50%;
    transform: translateX(-50%);
    width: 46%;
    height: 18%;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 1px;
}

/* Pantone style thumbnail */
.style-preview-pantone {
    padding: 4% 4% 28%;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border) !important;
}

.style-preview-map-pantone {
    width: 100%;
    height: 100%;
    background-color: #E0D8C8;
    background-size: cover;
    background-position: center;
    border-radius: 1px;
}

/* Pantone text area removed - white bottom band alone conveys the style */

/* ── Dimension badge (overlay on poster, mobile only) ── */
.dim-badge {
    display: none; /* shown via mobile media query below */
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 15;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.dim-badge:active {
    background: rgba(0, 0, 0, 0.75);
}
.dim-badge-icon {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.55);
}

/* Physical frame modes (desktop sidebar) - 3-column grid matches size row */
@media (min-width: 521px) {
    .controls-panel .physical-frame-mode {
        min-height: 48px;
    }

    .controls-panel .physical-frame-mode-label {
        font-size: 0.78rem;
    }

    .controls-panel .physical-frame-mode .physical-frame-chip-price {
        font-size: 0.62rem;
    }

    .controls-panel .physical-frame-mode .physical-frame-chip-price .options-chip-price-list {
        display: block;
        opacity: 0.65;
        font-size: 0.58rem;
        font-weight: 400;
    }

    .controls-panel .physical-frame-mode .physical-frame-chip-price .options-chip-price-sale {
        display: block;
    }
}

/* .style-preview-text removed - grey text placeholders no longer used */

/* Icon Selector (Multiple Draggable Icons) */
.icon-selector {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.icon-option {
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: var(--bc-surface);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--bc-text-muted);
    font-size: 0.75rem;
    transition: var(--transition-fast);
}

.icon-option:hover {
    border-color: var(--bc-border);
    transform: translateY(-1px);
}

.icon-option.is-active-asset {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-ink);
}

.icon-option:focus-visible {
    outline: 2px solid var(--bc-clay);
    outline-offset: 2px;
}

.icon-option svg {
    width: 22px;
    height: 22px;
}

.icon-option-label {
    font-size: 0.7rem;
    line-height: 1.1;
}

.icon-editor-card {
    margin-top: 1rem;
    padding: 0.875rem;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 12px;
}

.icon-editor-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.icon-editor-detail[hidden] {
    display: none !important;
}

.icon-editor-done-btn {
    width: 100%;
    margin-top: 0.35rem;
}

.icon-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.icon-selection-status {
    font-size: 0.75rem;
    color: var(--bc-text-warm);
}

.icon-selection-note {
    margin-bottom: 0.9rem;
}

.icon-color-row {
    margin-bottom: 0.75rem;
}

.icon-color-presets {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.icon-color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 999px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-color-swatch:hover {
    transform: translateY(-1px);
}

.icon-color-swatch.selected {
    border-color: var(--bc-clay);
    box-shadow: 0 0 0 3px var(--bc-clay-soft);
}

.icon-variant-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.95rem;
}

.icon-variant-selector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.icon-variant-btn {
    min-height: 40px;
    padding: 0.625rem 0.75rem;
    background: var(--bc-bg);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--bc-text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-variant-btn:hover {
    border-color: var(--bc-border);
}

.icon-variant-btn.selected {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-ink);
}

.icon-variant-btn:disabled,
.icon-color-swatch:disabled,
.icon-remove-btn:disabled,
.icon-clear-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.icon-size-control {
    margin-top: 0;
    margin-bottom: 0.95rem;
}

.icon-remove-btn {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.28);
    border-radius: 8px;
    color: #fca5a5;
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-remove-btn:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.4);
}

.icon-clear-btn {
    margin-top: 0.85rem;
    padding: 0.5rem 1rem;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--bc-text-muted);
    transition: var(--transition-fast);
    width: 100%;
}

.icon-clear-btn:hover {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
    color: var(--bc-ink);
}

/* Pin Overlay on Map */
/* Map Icons Container (Multiple Draggable Icons) */
.map-icons-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.map-icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    pointer-events: all;
    user-select: none;
    touch-action: none;
    transition: transform 0.1s ease;
    z-index: 5;
}

.map-icon:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

.map-icon.selected {
    z-index: 8;
}

.map-icon-visual {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    border-radius: 999px;
    transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

.map-icon-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.map-icon.selected .map-icon-visual {
    background: var(--bc-clay-soft);
    box-shadow: 0 0 0 2px rgba(214, 189, 96, 0.75);
}

.map-icon.dragging {
    opacity: 0.8;
    z-index: 10;
}

.map-icon-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    background: #ff4444;
    border: 2px solid var(--bc-surface);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    color: var(--bc-decision-text);
    line-height: 1;
    z-index: 6;
}

.map-icon:hover .map-icon-remove {
    display: flex;
}

.map-icon-remove:hover {
    background: #cc0000;
}

.map-icon-confirm {
    position: absolute;
    bottom: -8px;
    left: -8px;
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    background: #22a854;
    border: 2px solid var(--bc-surface);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: var(--bc-decision-text);
    z-index: 6;
}

.map-icon:hover .map-icon-confirm {
    display: flex;
}

.map-icon-confirm:hover {
    background: #1d8f47;
}

.map-icon--locked {
    cursor: pointer;
}

.map-icon--locked .map-icon-visual {
    opacity: 0.92;
}

@media (hover: none), (pointer: coarse) {
    .map-icon-remove {
        display: flex;
    }

    .map-icon-confirm {
        display: flex;
    }
}

.pin-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}

.map-pin {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
    animation: pin-bounce 0.5s ease;
}

@keyframes pin-bounce {
    0% { transform: translateY(-20px) scale(0.5); opacity: 0; }
    60% { transform: translateY(4px) scale(1.1); }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Coverage Options */
.coverage-options {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.coverage-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.875rem;
    background: var(--bc-surface);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: var(--font-sans);
}

.coverage-option:hover {
    background: var(--bc-surface);
}

.coverage-option.selected {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
}

.coverage-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--bc-text-muted);
}

.coverage-option.selected .coverage-name {
    color: var(--bc-clay);
}

.coverage-desc {
    font-size: 0.6875rem;
    color: var(--bc-text-warm);
}

.coverage-option.selected .coverage-desc {
    color: var(--bc-clay);
    opacity: 0.7;
}

/* Radius Fine-tune Toggle */
.radius-fine-tune-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.375rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--bc-text-muted);
    transition: var(--transition-fast);
    width: 100%;
}

.radius-fine-tune-toggle:hover {
    background: var(--bc-surface);
    border-color: var(--bc-border-strong);
    color: var(--bc-ink);
}

.radius-fine-tune-toggle .chevron {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    margin-left: auto;
}

.radius-fine-tune-toggle.open .chevron {
    transform: rotate(180deg);
}

/* Custom theme container (same pattern as radius slider) */
.custom-theme-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bc-border);
}

/* Radius Slider */
.radius-slider-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bc-border);
}

.radius-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-inline: calc(var(--rs-thumb, 18px) / 2);
}

.radius-slider-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--bc-text-muted);
    font-family: var(--font-sans);
}

.radius-slider-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bc-clay);
    font-family: var(--font-sans);
}

.size-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-size-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--bc-border);
    border-radius: 4px;
    background: transparent;
    color: var(--bc-text-warm);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.text-size-reset-btn:hover {
    color: var(--bc-clay);
    border-color: var(--bc-clay);
}

/* Shared: text / frame / extra sliders in edit panels */
.text-size-slider-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

/* Thumb size + track height for range alignment (header/labels inset + thumb centering) */
.text-size-slider-container,
.tilt-slider-container,
.radius-slider-container {
    --rs-thumb: 18px;
    --rs-track-h: 6px;
}

.radius-slider {
    width: 100%;
    min-height: 24px;
    height: 24px;
    box-sizing: border-box;
    border-radius: 3px;
    background: transparent;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0.75rem 0;
    padding: 0;
    cursor: pointer;
}

.radius-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--bc-border-strong), var(--bc-text-muted));
    opacity: 0.85;
}

.radius-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--bc-border-strong), var(--bc-text-muted));
    opacity: 0.85;
}

.radius-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--rs-thumb, 18px);
    height: var(--rs-thumb, 18px);
    border-radius: 50%;
    background: var(--bc-clay);
    cursor: pointer;
    border: 2px solid var(--bc-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: var(--transition-fast);
    transform: translateY(calc((var(--rs-track-h, 6px) - var(--rs-thumb, 18px)) / 2));
}

.radius-slider::-webkit-slider-thumb:hover {
    transform: translateY(calc((var(--rs-track-h, 6px) - var(--rs-thumb, 18px)) / 2)) scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.radius-slider::-moz-range-thumb {
    width: var(--rs-thumb, 18px);
    height: var(--rs-thumb, 18px);
    border-radius: 50%;
    background: var(--bc-clay);
    cursor: pointer;
    border: 2px solid var(--bc-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: var(--transition-fast);
    transform: translateY(calc((var(--rs-track-h, 6px) - var(--rs-thumb, 18px)) / 2));
}

.radius-slider::-moz-range-thumb:hover {
    transform: translateY(calc((var(--rs-track-h, 6px) - var(--rs-thumb, 18px)) / 2)) scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* --- Icon Floating Toolbar (all viewports) --- */
.icon-toolbar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(6px);
    z-index: 200;
    display: flex;
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    background: linear-gradient(180deg, rgba(16, 20, 34, 0.96) 0%, rgba(10, 14, 26, 0.97) 100%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.icon-toolbar[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.icon-toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 64px;
    min-height: 52px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: rgba(255, 253, 248, 0.92);
    border-radius: 12px;
    font-size: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s ease, color 0.12s ease;
}

.icon-toolbar-btn:hover {
    background: rgba(255, 248, 241, 0.14);
}

.icon-toolbar-btn:active {
    background: rgba(255, 248, 241, 0.18);
}

.icon-toolbar-btn.active {
    background: rgba(255, 248, 241, 0.2);
}

.icon-toolbar-btn:focus-visible {
    outline: 2px solid rgba(255, 248, 241, 0.6);
    outline-offset: 2px;
}

.icon-toolbar-btn--danger {
    color: #ff6b6b;
}

.icon-toolbar-btn--confirm {
    color: #86efac;
}

.icon-toolbar-label {
    font-family: var(--font-sans);
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: rgba(255, 253, 248, 0.78);
}

.icon-toolbar-swatch {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    background: var(--bc-surface);
}

.icon-toolbar-size-val {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
}

/* --- Icon toolbar panels (color / size) --- */
.icon-toolbar-panel {
    position: fixed;
    left: 50%;
    bottom: 88px;
    transform: translateX(-50%) translateY(8px);
    z-index: 200;
    background: linear-gradient(180deg, rgba(16, 20, 34, 0.97) 0%, rgba(10, 14, 26, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    max-width: min(340px, calc(100vw - 2rem));
    min-width: 260px;
}

.icon-toolbar-panel[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 901px) {
    .icon-toolbar,
    .icon-toolbar-panel {
        display: none !important;
    }
}

.icon-toolbar-panel-presets {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-toolbar-preset-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.14);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.icon-toolbar-preset-swatch.selected {
    border-color: var(--bc-decision-text, #fff);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28);
    transform: scale(1.12);
}

.icon-toolbar-panel-custom {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    color: rgba(255, 253, 248, 0.85);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.icon-toolbar-panel-custom:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.34);
}

.icon-toolbar-panel-color-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

.icon-toolbar-panel-variants {
    display: flex;
    gap: 6px;
    margin-left: 2px;
}

.icon-toolbar-variant-btn {
    padding: 6px 11px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 8px;
    color: rgba(255, 253, 248, 0.84);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.icon-toolbar-variant-btn.selected {
    background: rgba(255, 255, 255, 0.18);
    color: var(--bc-decision-text, #fff);
    border-color: rgba(255, 255, 255, 0.5);
}

.icon-toolbar-size-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    justify-content: center;
    flex-wrap: nowrap;
    max-width: 320px;
    margin: 0 auto;
    --its-thumb: 22px;
    --its-track-h: 4px;
    padding-inline: calc(var(--its-thumb) / 2);
}

.icon-toolbar-size-min,
.icon-toolbar-size-max {
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
    color: rgba(255, 253, 248, 0.7);
    white-space: nowrap;
    width: 2.8rem;
    text-align: center;
}

.icon-toolbar-size-slider {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 24px;
    height: 24px;
    box-sizing: border-box;
    border-radius: 3px;
    background: transparent;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
    cursor: pointer;
    align-self: center;
}

.icon-toolbar-size-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--bc-border-strong), var(--bc-text-muted));
    opacity: 0.9;
}

.icon-toolbar-size-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--bc-border-strong), var(--bc-text-muted));
    opacity: 0.9;
}

.icon-toolbar-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--its-thumb, 22px);
    height: var(--its-thumb, 22px);
    background: #f8efe4;
    border: 2px solid rgba(21, 24, 35, 0.9);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
    transform: translateY(calc((var(--its-track-h, 4px) - var(--its-thumb, 22px)) / 2));
}

.icon-toolbar-size-slider::-moz-range-thumb {
    width: var(--its-thumb, 22px);
    height: var(--its-thumb, 22px);
    background: #f8efe4;
    border-radius: 50%;
    border: 2px solid rgba(21, 24, 35, 0.9);
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
    transform: translateY(calc((var(--its-track-h, 4px) - var(--its-thumb, 22px)) / 2));
}

.radius-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--bc-text-warm);
    font-family: var(--font-sans);
    margin-top: 0.25rem;
    padding-inline: calc(var(--rs-thumb, 18px) / 2);
}

/* Layer Toggles */
.controls-subtitle {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bc-text-warm);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.layer-toggles {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.layer-toggle input {
    display: none;
}

.toggle-track {
    width: 36px;
    height: 20px;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    position: relative;
    transition: var(--transition-fast);
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--bc-text-warm);
    border-radius: 50%;
    transition: var(--transition-fast);
}

.layer-toggle input:checked + .toggle-track {
    background: var(--bc-clay);
    border-color: var(--bc-clay);
}

.layer-toggle input:checked + .toggle-track::after {
    left: 18px;
    background: var(--bc-bg);
}

.toggle-label {
    font-size: 0.875rem;
    color: var(--bc-text-muted);
}

.map-layers-actions {
    margin-top: 0.875rem;
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
    border-top: 1px solid var(--bc-border);
    display: flex;
    justify-content: flex-start;
}

.map-layers-show-all-btn {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--bc-border);
    border-radius: 999px;
    background: transparent;
    color: var(--bc-text-warm);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.map-layers-show-all-btn:hover {
    border-color: var(--bc-border-strong);
    background: var(--bc-surface);
    color: var(--bc-ink);
}

/* Perspective (Flat / 3D / Isometric) */
.perspective-panel {
    padding-top: 1rem;
}

.perspective-options {
    display: flex;
    gap: 0.25rem;
    background: var(--bc-surface);
    border-radius: 8px;
    padding: 3px;
}

.perspective-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 0.35rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    font-family: var(--font-sans);
    color: var(--bc-text-warm);
    transition: var(--transition-fast);
    min-height: 44px;
}

.perspective-option:hover {
    color: var(--bc-text-muted);
}

.perspective-option.selected {
    background: var(--bc-surface);
    color: var(--bc-ink);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.perspective-option:focus-visible {
    outline: 2px solid var(--bc-clay);
    outline-offset: 2px;
}

.perspective-icon {
    flex-shrink: 0;
}

.perspective-custom-controls {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.tilt-slider-container {
    margin-bottom: 0;
}

/* Rotation wheel (iPod-style circular) */
.rotation-control-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.rotation-wheel {
    position: relative;
    width: 120px;
    height: 120px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.04), rgba(0,0,0,0.2));
    border: 1px solid var(--bc-border);
}

.rotation-wheel:active {
    cursor: grabbing;
}

.rotation-wheel-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.rotation-wheel-track {
    fill: none;
    stroke: var(--bc-text-warm);
    stroke-opacity: 0.45;
    stroke-width: 5;
}

.rotation-wheel:hover .rotation-wheel-track {
    stroke: var(--bc-border-strong);
}

.rotation-wheel-center {
    fill: var(--bc-text-warm);
}

.rotation-wheel-needle {
    transition: x2 0.05s ease-out, y2 0.05s ease-out;
}

.rotation-cardinal {
    position: absolute;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--bc-text-warm);
    pointer-events: none;
}

.rotation-cardinal-n { top: 6px; left: 50%; transform: translateX(-50%); }
.rotation-cardinal-e { right: 8px; top: 50%; transform: translateY(-50%); }
.rotation-cardinal-s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.rotation-cardinal-w { left: 8px; top: 50%; transform: translateY(-50%); }

.rotation-wheel-label {
    position: absolute;
    left: 50%;
    bottom: -1.4rem;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bc-text-muted);
    min-width: 4.5em;
    text-align: center;
}

.rotation-reset-btn {
    margin-top: 1.9rem;
    min-height: 34px;
    padding: 0.4rem 0.9rem;
    border: 1px solid rgba(214, 189, 96, 0.4);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--bc-text-muted);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.rotation-reset-btn:hover {
    border-color: rgba(214, 189, 96, 0.62);
    background: rgba(214, 189, 96, 0.12);
    color: var(--bc-ink);
    transform: translateY(-1px);
}

.rotation-reset-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(214, 189, 96, 0.28);
}

/* Size Options */
.size-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

/* Orientation Toggle */
/* Portrait-only UI removed from editor - keep DOM for scripts, hide visually */
#orientationToggle,
.orientation-toggle {
    display: none !important;
}

.orientation-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bc-text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.orientation-btn:hover {
    color: var(--bc-ink);
    background: var(--bc-workspace);
}

.orientation-btn.selected {
    color: var(--bc-clay);
    background: var(--bc-clay-soft);
    border-color: var(--bc-clay);
}

.orientation-btn svg {
    width: 14px;
    height: 14px;
    display: block;
}



.size-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.625rem 0.25rem;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.size-option:hover {
    border-color: var(--bc-border-strong);
}

.size-option.selected {
    border-color: var(--bc-clay);
    background: var(--bc-clay-soft);
}

.size-option span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--bc-text-muted);
}

.size-option.selected span {
    color: var(--bc-clay);
}

.size-dims {
    font-size: 0.625rem !important;
    font-weight: 400 !important;
    color: var(--bc-text-warm) !important;
}

.size-price-label {
    display: block;
    width: 100%;
    margin-top: 0.1rem;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
}
.size-price-label .options-chip-price-list {
    display: block;
    opacity: 0.65;
    font-size: 0.58rem;
    font-weight: 400;
}
.size-price-label .options-chip-price-sale {
    display: block;
}

.size-preview {
    background: var(--bc-text-warm);
    border-radius: 2px;
}

.size-a5 { width: 14px; height: 20px; }
.size-a4 { width: 16px; height: 23px; }
.size-a3 { width: 18px; height: 26px; }
.size-a2 { width: 18px; height: 25px; }
.size-3040 { width: 17px; height: 23px; }
.size-4050 { width: 17px; height: 21px; }
.size-5070 { width: 18px; height: 25px; }
.size-square { width: 20px; height: 20px; }

.size-custom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}
.size-custom svg {
    width: 14px;
    height: 14px;
    stroke: var(--bc-text-warm);
}
.size-option.selected .size-custom svg {
    stroke: var(--bc-clay);
}

/* Custom Size Panel */
.custom-size-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bc-workspace);
    border: 1px solid var(--bc-border);
    border-radius: 10px;
}

.custom-size-unit-toggle {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.625rem;
    background: var(--bc-bg);
    border-radius: 6px;
    padding: 2px;
}

.unit-btn {
    flex: 1;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--bc-text-warm);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.unit-btn.selected {
    background: var(--bc-clay);
    color: var(--bc-bg);
}

.unit-btn:hover:not(.selected) {
    color: var(--bc-ink);
}

.custom-size-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-size-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.custom-size-field label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--bc-text-warm);
    flex-shrink: 0;
}

.custom-size-field input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
    color: var(--bc-ink);
    background: var(--bc-bg);
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
    -moz-appearance: textfield;
}

.custom-size-field input::-webkit-outer-spin-button,
.custom-size-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-size-field input:focus {
    border-color: var(--bc-clay);
}

.custom-size-x {
    font-size: 0.875rem;
    color: var(--bc-text-warm);
    flex-shrink: 0;
}

/* Actions */
.controls-actions {
    margin-top: auto;
    border-top: 1px solid var(--bc-border);
    padding-top: 1.5rem;
}

#desktopPurchaseBtn {
    min-height: 48px;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
}

/* Download Button Purchase Styling */
.download-btn-purchase {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.125rem 1.75rem;
    gap: 1rem;
}

.download-btn-text {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
}

.download-btn-price {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--bc-clay);
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
}

.download-btn-price.is-hint {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0;
}

/* Experiment: exp_cta_price - hide price pill + center label */
.download-btn-purchase.is-no-price {
    justify-content: center;
}
.download-btn-purchase.is-no-price .download-btn-price {
    display: none;
}

.download-btn-purchase:hover .download-btn-price {
    background: #f0d060;
}

.download-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--bc-text-warm);
    margin-top: 0.75rem;
}

/* ============================================
   Preview Section
   ============================================ */

.preview-section {
    display: flex; /* Visible on desktop by default */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Extra right/bottom padding keeps dim indicators from being cut off.
       Right: covers right: -60px indicator.  Bottom: covers bottom: -56px indicator. */
    padding: 2.5rem 4rem 4.5rem;
    background: var(--generate-workspace-bg);
    position: relative;
    overflow: visible;
    min-height: 0;
}

/* Hide preview section on mobile by default (shown only in preview mode) */
@media (max-width: 900px) {
    .preview-section {
        display: none;
    }
    
    .generate-main.preview-mode .preview-section {
        display: flex;
    }
}

/* View Toggle */
/* Preview Wrapper */
.preview-wrapper {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    position: relative;
}


/* .poster-dims-wrap owns the max-width so the dim indicators are
   always flush with the poster edge, not the full preview-wrapper width. */
#posterDimsWrap {
    max-width: min(700px, calc((100vh - var(--header-offset) - 7rem) * 0.75));
}


.poster-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 0.75;
    background: var(--bc-surface);
    border-radius: 4px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: visible;
    padding: 0;
    transition: all 0.3s ease;
}

.poster-frame-inner {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 4px;
    clip-path: inset(0 round 4px);
}

#mapContainer {
    will-change: transform;
}

/* Static poster image until MapLibre reaches idle (mobile LCP) */
.map-lcp-placeholder {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background-color: var(--map-bg, #F8F5EE);
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.map-lcp-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.map-lcp-placeholder--hidden {
    opacity: 0;
    visibility: hidden;
}

/* Poster Style: Framed - Mapiful-style: inset map, poster-color outer margin, double-line frame */
.poster-frame.framed {
    padding: 3.5%;
    background: var(--poster-bg-color, #f5f5f5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Outer thin line at the edge of the map area */
.poster-frame.framed .poster-frame-inner {
    flex: 1 1 0%;
    min-height: 0;
    height: auto;
    border: 1px solid rgba(0, 0, 0, 0.6);
    box-shadow: none;
}

/* Inner bolder line, ~1.2% inside the outer border; box-shadow fills the gap with poster bg */
.poster-frame.framed .poster-frame-inner::before {
    content: '';
    position: absolute;
    inset: 1.2%;
    border: clamp(1px, 0.45%, 3px) solid rgba(0, 0, 0, 0.75);
    box-shadow: 0 0 0 clamp(3px, 1.4%, 8px) var(--poster-bg-color, var(--bc-surface));
    pointer-events: none;
    z-index: 3;
}

/* Suppress top fade - bottom-only gradient (Mapiful style) */
.poster-frame.framed .poster-fade-top {
    height: 0 !important;
}

/* Poster Style: Mat (passepartout) */
.poster-frame.mat {
    background: var(--poster-bg-color, var(--bc-surface));
    padding: var(--route-pad-top, 5%) var(--route-pad-side, 5%) var(--route-pad-bottom, 18%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.poster-frame.mat .poster-frame-inner {
    flex: 1 1 0%;
    min-height: 0;
    height: auto;
    border-radius: 2px;
}

/* Suppress fades for mat - sharp map edges look cleaner */
.poster-frame.mat .poster-fade-top,
.poster-frame.mat .poster-fade-bottom {
    height: 0 !important;
}

/* Poster Style: Circle */
.poster-frame.circle {
    background: var(--poster-bg-color, var(--bc-surface));
}

/* Clip the map to a circle positioned in the upper portion of the frame.
   --circle-size is set in pixels by syncCircleSize() in JS. */
.poster-frame.circle .poster-frame-inner {
    position: absolute;
    top: var(--circle-top, 2%);
    left: 50%;
    transform: translateX(-50%);
    width: var(--circle-size, 88%);
    height: var(--circle-size, 88%);
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.08);
}

/* Suppress fades for circle */
.poster-frame.circle .poster-fade-top,
.poster-frame.circle .poster-fade-bottom {
    height: 0 !important;
}

/* Poster Style: Boxed - full map with thin white edge and white text rectangle */
.poster-frame.boxed {
    background: var(--poster-bg-color, var(--bc-surface));
    padding: 2%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.poster-frame.boxed .poster-frame-inner {
    flex: 1 1 0%;
    min-height: 0;
    height: auto;
    border-radius: 1px;
}

.poster-frame.boxed .poster-fade-top,
.poster-frame.boxed .poster-fade-bottom {
    height: 0 !important;
}

/* Poster Style: Pantone - map inset with white edge, left-aligned text below.
   CSS padding-% is always relative to width, so 4% gives equal visual
   spacing on sides and top.  Bottom needs room for gap + text + gap;
   24% of width is enough for all poster sizes down to 280px. */
.poster-frame.pantone {
    background: var(--poster-bg-color, var(--bc-surface));
    padding: 4% 4% 24%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.poster-frame.pantone .poster-frame-inner {
    flex: 1 1 0%;
    min-height: 0;
    height: auto;
    border-radius: 1px;
    border-bottom: 2.5px solid rgba(0, 0, 0, 0.8);
}

.poster-frame.pantone.divider-hidden .poster-frame-inner {
    border-bottom: none;
}

.poster-frame.pantone .poster-fade-top,
.poster-frame.pantone .poster-fade-bottom {
    height: 0 !important;
}

/* ── Poster Background Color Picker ──────────────────────────────── */
.bg-color-panel {
    padding: 0 0.75rem 0.75rem;
}

.bg-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.bg-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.15s, transform 0.15s;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.bg-swatch:hover {
    transform: scale(1.12);
}

.bg-swatch.selected {
    border-color: var(--accent, #333);
    box-shadow: 0 0 0 1px var(--accent, #333), 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.bg-swatch-custom {
    background: conic-gradient(
        hsl(0,100%,60%), hsl(30,100%,60%), hsl(60,100%,60%),
        hsl(120,100%,40%), hsl(180,100%,40%), hsl(240,100%,60%),
        hsl(300,100%,60%), hsl(360,100%,60%)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bc-decision-text);
    font-size: 14px;
    font-weight: 700;
}

/* Physical product frame preview - box-shadow only, no z-index / overflow tricks.
 *
 * Visual layer anatomy (front → back):
 *   Inset rabbet - frame lip casts directional shadow ONTO the print (inset)
 *   Inner face - lighter/distinct color ring at the frame opening; this is
 *                    the angled inner profile of the rail, visible head-on.
 *                    A top-left-offset duplicate creates directional lighting.
 *   Frame front - main wood color (the broad face of the rail)
 *   Outer edge - hairline trim at perimeter
 *   Drop shadow - floating depth
 *
 * Sharp 90° corners match real wood frames; border-radius on the base element
 * is overridden to 0 and transitions back when the frame is removed.
 */

/* Sharp corners - applied to both the poster element (so spread layers are square)
   and the inner content clip. */
.poster-frame.physical-framed {
    border-radius: 0;
    overflow: visible;
    transition: box-shadow 0.25s ease, border-radius 0.25s ease;
}

.poster-frame.physical-framed .poster-frame-inner {
    border-radius: 0;
    transition: border-radius 0.25s ease;
}

/* Preserve circle clipping when physical frame is also active */
.poster-frame.circle.physical-framed .poster-frame-inner {
    border-radius: 50%;
}

/* Inset rabbet overlay - absolutely positioned on top of the poster art so the
   frame-lip shadow is visible over the content (same z-index technique as checkout). */
.poster-frame.physical-framed::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* White wood - outward spreads only on the element; inset on ::after overlay */
.poster-frame.physical-framed.physical-frame-white {
    box-shadow:
        /* Drop shadow */
        0 28px 70px rgba(0, 0, 0, 0.24),
        0 8px 22px  rgba(0, 0, 0, 0.11),
        /* Outer edge - thin dark perimeter so the white frame reads on any bg */
        0 0 0 23px  rgba(0, 0, 0, 0.18),
        /* Frame front face - warm off-white mat */
        0 0 0 22px  var(--bc-surface),
        /* Inner face directional highlight */
        -3px -5px 0 7px rgba(255, 255, 255, 1),
        /* Inner face base - clean white, slightly shaded */
        0 0 0 5px   rgba(240, 240, 240, 0.98);
}

.poster-frame.physical-framed.physical-frame-white::after {
    box-shadow:
        inset 0   3px 8px  rgba(0, 0, 0, 0.16),
        inset 3px  0  6px  rgba(0, 0, 0, 0.10),
        inset -1px 0  4px  rgba(0, 0, 0, 0.06),
        inset 0  -1px 4px  rgba(0, 0, 0, 0.06);
}

/* Black wood */
.poster-frame.physical-framed.physical-frame-black {
    box-shadow:
        /* Drop shadow */
        0 28px 70px rgba(0, 0, 0, 0.58),
        0 8px 22px  rgba(0, 0, 0, 0.30),
        /* Outer edge */
        0 0 0 23px  rgba(255, 255, 255, 0.07),
        /* Frame front face */
        0 0 0 22px  #1a1410,
        /* Inner face directional highlight */
        -3px -5px 0 7px rgba(100, 82, 66, 0.92),
        /* Inner face base */
        0 0 0 5px   #5c4c40;
}

.poster-frame.physical-framed.physical-frame-black::after {
    box-shadow:
        inset 0   3px 10px rgba(0, 0, 0, 0.50),
        inset 3px  0  8px  rgba(0, 0, 0, 0.32),
        inset -2px 0  6px  rgba(0, 0, 0, 0.20),
        inset 0  -2px 6px  rgba(0, 0, 0, 0.20);
}

.poster-frame.physical-framed.physical-frame-natural {
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.28),
        0 8px 22px  rgba(0, 0, 0, 0.14),
        0 0 0 23px  rgba(0, 0, 0, 0.16),
        0 0 0 22px  #c4a06a,
        0 0 0 21px  #b89560,
        -3px -5px 0 7px rgba(220, 190, 140, 0.95),
        0 0 0 5px   #a67c52;
}

.poster-frame.physical-framed.physical-frame-natural::after {
    box-shadow:
        inset 0   3px 8px  rgba(0, 0, 0, 0.18),
        inset 3px  0  6px  rgba(0, 0, 0, 0.12),
        inset -1px 0  4px  rgba(0, 0, 0, 0.08),
        inset 0  -1px 4px  rgba(0, 0, 0, 0.08);
}

.poster-frame.physical-framed.physical-frame-dark-wood {
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.36),
        0 8px 22px  rgba(0, 0, 0, 0.18),
        0 0 0 23px  rgba(255, 255, 255, 0.06),
        0 0 0 22px  #5c4030,
        0 0 0 21px  #4a3428,
        -3px -5px 0 7px rgba(120, 90, 66, 0.92),
        0 0 0 5px   #3d2a1a;
}

.poster-frame.physical-framed.physical-frame-dark-wood::after {
    box-shadow:
        inset 0   3px 9px  rgba(0, 0, 0, 0.36),
        inset 3px  0  7px  rgba(0, 0, 0, 0.24),
        inset -2px 0  5px  rgba(0, 0, 0, 0.16),
        inset 0  -2px 5px  rgba(0, 0, 0, 0.16);
}

/* Poster hanger preview - top/bottom rails clamp outside the print */
.poster-frame.physical-hanger {
    position: relative;
    overflow: visible;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.14);
    transition: box-shadow 0.25s ease;
}

.poster-frame.physical-hanger .poster-frame-inner {
    position: relative;
    z-index: 1;
}

.poster-frame.physical-hanger::before,
.poster-frame.physical-hanger::after {
    content: '';
    position: absolute;
    left: calc(-1 * var(--hanger-rail-overhang-x));
    right: calc(-1 * var(--hanger-rail-overhang-x));
    width: auto;
    height: var(--hanger-rail-height);
    z-index: 5;
    pointer-events: none;
    border-radius: 2px;
    box-shadow:
        0 2px 5px rgba(0, 0, 0, 0.22),
        0 1px 0 rgba(255, 255, 255, 0.1) inset,
        0 -1px 2px rgba(0, 0, 0, 0.12) inset;
}

.poster-frame.physical-hanger::before {
    top: 0;
    transform: translateY(calc(-1 * var(--hanger-rail-outside-y)));
}

.poster-frame.physical-hanger::after {
    bottom: 0;
    transform: translateY(var(--hanger-rail-outside-y));
}

/* Hanger rail colors - physical-preview-wood.css */

.poster-frame.circle.physical-hanger {
    padding-top: 3%;
    padding-bottom: 3%;
}

.poster-frame.circle.physical-hanger::before,
.poster-frame.circle.physical-hanger::after {
    left: calc(-1 * var(--hanger-rail-overhang-x) * 0.6);
    right: calc(-1 * var(--hanger-rail-overhang-x) * 0.6);
}


.map-container {
    position: absolute;
    inset: 0;
    background-color: var(--map-bg, #F8F5EE);
}

/* Gradient fades - height driven by --fade-top / --fade-bottom (set by JS from style profile) */
.poster-fade {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 2;
    transition: height 0.4s ease;
}

.poster-fade-top {
    top: 0;
    height: calc(var(--fade-top, 0.25) * 100%);
    /* Map/poster fade; fallback is near-black for dark map themes (not app chrome) */
    background: linear-gradient(to bottom, var(--poster-bg, #000000) 0%, transparent 100%);
}

.poster-fade-bottom {
    bottom: 0;
    height: calc(var(--fade-bottom, 0.25) * 100%);
    background: linear-gradient(to top, var(--poster-bg, #000000) 0%, var(--poster-bg, #000000) 30%, transparent 100%);
}

.poster-text-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* z-index above .poster-frame-inner (z-index stacking context) so text
       always renders on top regardless of poster style */
    z-index: 6;
}

/* Preview Control Buttons */
.preview-controls {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.75rem;
}

.preview-ctrl-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--bc-text-muted);
    transition: var(--transition-fast);
}

.preview-ctrl-btn:hover {
    background: var(--bc-surface);
    color: var(--bc-ink);
    border-color: var(--bc-border-strong);
}

.preview-ctrl-btn:active {
    transform: scale(0.95);
}

.preview-hint {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--bc-text-warm);
}

/* ============================================
   Payment / Download Gate Modal
   ============================================ */

.payment-gate {
    text-align: center;
    padding: 0.5rem;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: none;
    border: none;
    color: var(--bc-text-warm);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.modal-close-btn:hover {
    color: var(--bc-ink);
    background: var(--bc-surface);
}

.payment-gate-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--bc-clay-soft);
    border-radius: 50%;
    color: var(--bc-clay);
    margin-bottom: 1rem;
}

.payment-gate h3 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 400;
    margin-bottom: 1.25rem;
}

.payment-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
}

.payment-action-hint {
    font-size: 0.72rem;
    color: var(--bc-text-warm);
    margin: 0 0 0.5rem;
    line-height: 1.35;
}

.payment-hint {
    font-size: 0.6875rem;
    color: var(--bc-text-warm);
    margin-bottom: 1rem;
}

.email-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.email-form input[type="email"] {
    width: 100%;
    padding: 0.7rem 0.8rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--bc-ink);
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 10px;
    outline: none;
    transition: var(--transition-fast);
    text-align: center;
}

.email-form input[type="email"]:focus {
    border-color: var(--bc-clay);
    box-shadow: 0 0 0 3px var(--bc-clay-soft);
}

.email-form input[type="email"].error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ============================================
   Export Modal
   ============================================ */

.export-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.export-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bc-border);
    border-top-color: var(--bc-clay);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.export-progress h3 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 400;
}

.export-progress p {
    font-size: 0.875rem;
    color: var(--bc-text-muted);
}

/* ============================================
   Purchase Success Modal
   ============================================ */

.purchase-success-content {
    max-width: 480px;
    padding: 2.5rem;
}

.purchase-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.purchase-phase h3 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 400;
    margin: 0;
}

.purchase-phase p {
    font-size: 0.9375rem;
    color: var(--bc-text-muted);
    margin: 0;
}

.purchase-checkmark {
    animation: purchaseCheckPop 0.5s ease-out;
}

@keyframes purchaseCheckPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.purchase-thankyou {
    color: var(--bc-text-warm);
    font-size: 0.875rem;
}

.purchase-preview {
    width: 100%;
    max-width: 280px;
    margin: 0.75rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--bc-border);
}

.purchase-preview-img {
    width: 100%;
    height: auto;
    display: block;
}

#purchaseDownloadBtn {
    margin-top: 0.5rem;
    gap: 0.5rem;
}

.purchase-file-info {
    font-size: 0.75rem;
    color: var(--bc-text-warm);
    margin-top: 0.25rem;
}

.purchase-create-another {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: var(--bc-text-warm);
    text-decoration: none;
    transition: color 0.2s;
}

.purchase-create-another:hover {
    color: var(--bc-clay);
}

/* ============================================
   Responsive
   ============================================ */

/* Controls Panel Toggle (Mobile) */
.controls-panel-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    width: 44px;
    height: 44px;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: var(--transition-fast);
}

.controls-panel-toggle:hover {
    background: var(--bc-surface);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.controls-panel-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--bc-ink);
}

/* Mobile Tab Switcher */
.mobile-tab-switcher {
    display: none;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bc-bg);
    border-bottom: 1px solid var(--bc-border);
    padding: 0;
    margin: 0;
}

.mobile-tab-switcher .tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--bc-text-muted);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.mobile-tab-switcher .tab-btn svg {
    width: 18px;
    height: 18px;
}

.mobile-tab-switcher .tab-btn.active {
    color: var(--bc-clay);
    border-bottom-color: var(--bc-clay);
    background: var(--bc-surface);
}

.mobile-tab-switcher .tab-btn:hover:not(.active) {
    color: var(--bc-ink);
    background: var(--bc-workspace);
}

/* Preview Mode (Mobile) */
.generate-main.preview-mode .controls-panel {
    display: none !important;
}

.generate-main.preview-mode .preview-section {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    padding: 1rem 1rem 5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1000;
    background: var(--generate-workspace-bg);
}

.generate-main.preview-mode .poster-frame,
.generate-main.preview-mode #posterDimsWrap {
    max-width: min(calc(100vw - 2rem), 420px);
    width: 100%;
    flex-shrink: 0;
    margin-bottom: 1rem;
}

/* On preview-mode mobile: hide ruler lines, show badge */
.generate-main.preview-mode .dim-indicator-h,
.generate-main.preview-mode .dim-indicator-w {
    display: none;
}
.generate-main.preview-mode .dim-badge {
    display: flex;
}

.generate-main.preview-mode .preview-actions-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem;
    background: var(--bc-bg);
    border-top: 1px solid var(--bc-border);
    z-index: 1001;
    flex-shrink: 0;
}

.generate-main.preview-mode .preview-action-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-radius: var(--radius-md);
    color: var(--bc-ink);
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.generate-main.preview-mode .preview-action-btn:hover {
    background: var(--bc-workspace);
    border-color: var(--bc-border-strong);
}

.generate-main.preview-mode .preview-action-btn-primary {
    background: var(--bc-clay);
    border-color: var(--bc-clay);
    color: var(--bc-bg);
    flex: 1;
    max-width: 200px;
}

.generate-main.preview-mode .preview-action-btn-primary:hover {
    background: var(--bc-clay);
    opacity: 0.9;
    transform: translateY(-1px);
}

.generate-main.preview-mode .preview-action-btn svg {
    width: 18px;
    height: 18px;
}

.generate-main.edit-mode .preview-actions-container {
    display: none !important;
}

/* Edit Mode (Mobile) */
/* Edit mode on mobile hides preview */
@media (max-width: 900px) {
    .generate-main.edit-mode .preview-section {
        display: none;
    }
}

.generate-main.edit-mode .controls-panel {
    display: block !important;
    order: 1;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 1rem;
    border: none;
    border-top: 1px solid var(--bc-border);
}

.generate-main.edit-mode .controls-panel-toggle {
    display: none;
}

/* Mobile Download Menu Styles */
.download-menu-content {
    max-width: 460px;
    padding: 2rem 1.5rem 1.4rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(10, 12, 20, 0.97) 0%, rgba(7, 10, 18, 0.98) 100%);
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    text-align: left;
}

#downloadMenuModal .modal-close-btn {
    top: 0.7rem;
    right: 0.7rem;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--bc-text-warm);
}

#downloadMenuModal .modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--bc-ink);
    border-color: rgba(255, 255, 255, 0.24);
}

.download-menu-content h3 {
    margin: 0 0 1.1rem 0;
    font-size: 1.85rem;
    font-weight: 500;
    font-family: var(--font-serif);
    letter-spacing: -0.01em;
    color: var(--bc-ink);
    text-align: center;
}

.download-menu-options {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.download-option {
    border-radius: 999px;
    min-height: 64px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.download-option:hover {
    transform: translateY(-1px);
}

.download-option-preview {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: linear-gradient(180deg, rgba(13, 16, 28, 0.98) 0%, rgba(10, 13, 24, 0.98) 100%);
    color: var(--bc-ink);
    font-size: 1.05rem;
    font-weight: 550;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.download-option-purchase {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    font-size: 1.05rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid rgba(214, 189, 96, 0.56);
    box-shadow: 0 10px 26px rgba(214, 189, 96, 0.2);
}

.download-option-purchase .download-btn-text {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.download-option-purchase .download-btn-text span:last-child {
    white-space: nowrap;
}

.download-option-purchase .download-btn-price {
    color: var(--bc-bg);
    font-size: clamp(1.4rem, 7vw, 2rem);
    font-weight: 700;
    line-height: 1;
    margin-left: auto;
    letter-spacing: -0.01em;
    background: rgba(0, 0, 0, 0.14);
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    padding: 0.18rem 0.75rem 0.22rem;
}

#downloadMenuModal .download-hint {
    margin-top: 0.05rem;
    margin-bottom: 0.22rem;
    font-size: 0.78rem;
    letter-spacing: 0.01em;
    color: rgba(231, 233, 238, 0.5);
}

/* Utility classes for mobile/desktop visibility */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 900px) {
    body.generate-page {
        --generate-mobile-top-inset: 8px;
    }

    body.generate-page .nav {
        padding: 0.5rem 1rem;
    }

    body.generate-page .nav-inner {
        min-height: var(--nav-height);
    }

    .generate-header-meta {
        display: none;
    }

    .generate-header-actions {
        gap: 0.35rem;
    }

    .generate-header-link-btn,
    .generate-header-auth-btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.8rem;
    }

    .controls-group-toggle {
        display: none !important;
    }

    .controls-group-body {
        display: flex !important;
    }

    .controls-group-body[hidden] {
        display: flex !important;
    }

    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
    .mobile-tab-switcher {
        display: flex !important;
    }
    
    .generate-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .controls-panel-toggle {
        display: flex;
    }
    
    .controls-panel {
        order: 2;
        border-right: none;
        border-top: 1px solid var(--bc-border);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
        padding-top: 0;
        padding-bottom: 0;
    }
    
    .controls-panel.open {
        max-height: 70vh;
        padding-top: 1rem;
        padding-bottom: 1rem;
        overflow-y: auto;
    }
    
    .preview-section {
        order: 1;
        padding: 1rem;
    }

    .nav-print-cta {
        padding: 0.45rem 0.85rem;
        font-size: 0.8rem;
    }

    .nav-download-fallback {
        padding: 0.45rem 0.85rem;
        font-size: 0.8rem;
    }

    .nav-print-cta svg {
        width: 14px;
        height: 14px;
    }

    .nav-download-fallback svg {
        width: 14px;
        height: 14px;
    }

    .download-menu-content {
        width: min(92vw, 460px);
        padding: 1.45rem 1rem 1rem;
        border-radius: 20px;
    }

    .download-menu-content h3 {
        font-size: 1.45rem;
        margin-bottom: 0.9rem;
    }

    .download-option {
        min-height: 56px;
    }

    .download-option-preview {
        font-size: 0.98rem;
    }

    .download-option-purchase {
        font-size: 0.98rem;
        padding: 0.8rem 0.85rem;
    }

    .download-option-purchase .download-btn-price {
        font-size: clamp(1.35rem, 9vw, 1.85rem);
    }

    .poster-frame {
        max-width: 300px;
    }
    
    .theme-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    /* Larger touch targets on mobile */
    .theme-swatch {
        min-width: 44px;
        min-height: 44px;
    }
    
    .coverage-option {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    .text-size-slider-container,
    .tilt-slider-container,
    .radius-slider-container {
        --rs-thumb: 24px;
    }

    .radius-slider {
        min-height: 32px;
        height: 32px;
    }
    
    .preview-ctrl-btn {
        width: 44px;
        height: 44px;
    }
    
    .layer-toggle {
        min-height: 44px;
    }
    
    .pin-option {
        min-width: 44px;
        min-height: 44px;
    }
    
    .mobile-share-btn-icon {
        width: 48px;
        height: 48px;
        min-width: 48px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bc-surface);
        border: 1px solid var(--bc-border);
        border-radius: var(--radius-md);
        color: var(--bc-ink);
        cursor: pointer;
        transition: var(--transition-fast);
        flex-shrink: 0;
    }

    .mobile-share-btn-icon:hover {
        background: var(--bc-workspace);
        border-color: var(--bc-border-strong);
    }

    .mobile-share-btn-icon svg {
        width: 20px;
        height: 20px;
    }
    
    /* Legacy - keep for backwards compatibility but hide */
    .mobile-share-btn {
        display: none !important;
    }
    
    .preview-hint {
        font-size: 0.75rem;
    }
}

/* Mobile V2: map-first shell (compact controls added in separate block) */
.mobile-v2-only {
    display: none;
}

@media (max-width: 900px) {
    /* No document scroll on mobile V2: footer is off-screen and fixed chrome owns the viewport */
    html:has(body.generate-page.feature-mobile-v2) {
        overflow: hidden;
        height: 100%;
    }

    body.generate-page.feature-mobile-v2 {
        overflow: hidden;
        height: 100%;
        max-height: 100dvh;
    }

    body.generate-page.feature-mobile-v2 .footer {
        display: none !important;
    }

    body.feature-mobile-v2 .generate-main {
        display: block;
        position: relative;
        height: calc(100vh - (var(--header-offset) + var(--generate-mobile-top-inset)));
    }

    body.feature-mobile-v2 .preview-section {
        position: fixed;
        top: calc(var(--header-offset) + var(--generate-mobile-top-inset));
        left: 0;
        right: 0;
        bottom: 0;
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 20px 24px 96px;
        z-index: var(--z-base);
        overflow: hidden;
        background: var(--generate-workspace-bg);
    }

    body.feature-mobile-v2 .preview-wrapper {
        width: 100%;
        height: 100%;
        min-height: 0;
        align-items: center;
        justify-content: center;
        gap: 0;
    }

    /* Width- and height-budget: cap poster so it fits under header + bottom nav/padding */
    body.feature-mobile-v2 #posterDimsWrap {
        width: min(
            calc(100vw - 48px),
            380px,
            calc((100dvh - var(--header-offset) - var(--generate-mobile-top-inset) - 120px) * 0.75)
        );
        max-width: 100%;
        margin: 0 auto;
        min-height: 0;
    }

    body.feature-mobile-v2 .poster-frame {
        width: 100%;
        margin: 0 auto;
        max-height: calc(100dvh - var(--header-offset) - var(--generate-mobile-top-inset) - 120px);
        aspect-ratio: 0.75;
        height: auto;
    }

    body.feature-mobile-v2 .poster-frame-inner {
        max-height: 100%;
    }

    /* Hide ruler indicators on mobile; show compact badge instead */
    body.feature-mobile-v2 .dim-indicator-h,
    body.feature-mobile-v2 .dim-indicator-w {
        display: none;
    }
    body.feature-mobile-v2 .dim-badge {
        display: flex;
    }

    body.feature-mobile-v2 .controls-panel-toggle,
    body.feature-mobile-v2 .controls-panel-toggle {
        display: none !important;
    }

    body.feature-mobile-v2 .controls-panel {
        display: none !important;
    }

    body.feature-mobile-v2 .mobile-sheet-handle,
    body.feature-mobile-v2 .controls-actions-mobile {
        display: none !important;
    }

    body.feature-mobile-v2 .mobile-v2-only {
        display: flex;
    }

    body.feature-mobile-v2 .preview-actions-container {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        left: auto;
        bottom: auto;
        z-index: 8;
        display: flex !important;
        background: transparent;
        border: 0;
        padding: 0;
        width: auto;
        gap: 0;
    }

    body.feature-mobile-v2 .preview-action-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        border-radius: 999px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        background: rgba(10, 14, 26, 0.92);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    }

    body.feature-mobile-v2 #previewDownloadBtn {
        display: none !important;
    }

    body.feature-mobile-v2 #mobileShareBtn {
        display: none !important;
    }

    body.feature-mobile-v2 .mobile-generate-shell {
        position: fixed;
        top: calc(var(--header-offset) + env(safe-area-inset-top, 0px));
        left: 0;
        right: 0;
        z-index: calc(var(--z-nav) + 1);
        display: none;
        pointer-events: none;
    }

    body.feature-mobile-v2 .mobile-generate-shell[aria-hidden="false"] {
        display: block;
    }

    body.feature-mobile-v2 .mobile-generate-shell-bar {
        display: flex;
        justify-content: flex-end;
        padding: 10px 16px 0;
    }

    body.feature-mobile-v2 .mobile-generate-shell-buy {
        pointer-events: auto;
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 36px;
        padding: 6px 12px;
        border: 1px solid var(--bc-clay);
        border-radius: 999px;
        background: var(--bc-clay);
        color: var(--bc-decision-cta-text);
        font-family: var(--font-sans);
        font-size: 0.8125rem;
        font-weight: 700;
        line-height: 1;
    }

    body.feature-mobile-v2 .mobile-generate-shell-buy-main {
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 6px;
        flex-shrink: 0;
    }

    body.feature-mobile-v2 .mobile-generate-shell-buy-label {
        font-size: 0.8125rem;
        font-weight: 700;
        line-height: 1;
        white-space: nowrap;
    }

    body.feature-mobile-v2 .mobile-generate-shell-buy-price {
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        align-self: center;
        justify-content: center;
        gap: 4px;
        font-size: 0.75rem;
        font-weight: 600;
        opacity: 0.95;
        text-align: left;
        width: auto;
        min-width: 0;
        line-height: 1;
    }

    body.feature-mobile-v2 .mobile-generate-shell-buy-price .discount-price-list {
        display: none;
    }

    body.feature-mobile-v2 .mobile-generate-shell-buy-price .discount-price-sale {
        display: inline-flex;
        align-items: center;
        line-height: 1;
        text-align: left;
        white-space: nowrap;
        transform: translateY(0.5px);
    }

    body.feature-mobile-v2 .mobile-v2-nav {
        position: fixed;
        left: var(--space-3);
        right: var(--space-3);
        bottom: max(var(--space-3), env(safe-area-inset-bottom, 0px));
        z-index: var(--z-nav);
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        gap: 4px;
        padding: 4px;
        background: var(--bc-surface);
        border: 1px solid var(--bc-border-strong);
        border-radius: 28px;
        box-shadow: 0 8px 24px rgba(26, 26, 26, 0.12);
    }

    body.feature-mobile-v2 .mobile-v2-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        flex: 1;
        min-width: 0;
        min-height: 44px;
        padding: 6px 4px;
        font-family: var(--font-sans);
        font-size: 0.5625rem;
        font-weight: 600;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        color: #8b857d;
        background: transparent;
        border: 1px solid transparent;
        border-radius: 22px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
    }

    body.feature-mobile-v2 .mobile-v2-nav-icon {
        flex-shrink: 0;
        display: block;
    }

    body.feature-mobile-v2 .mobile-v2-nav-label {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    body.feature-mobile-v2 .mobile-v2-nav-icon {
        width: 20px;
        height: 20px;
    }

    body.feature-mobile-v2[data-mobile-v2-active-panel="place"] .mobile-v2-nav-item[data-panel="place"],
    body.feature-mobile-v2[data-mobile-v2-active-panel="style"] .mobile-v2-nav-item[data-panel="style"],
    body.feature-mobile-v2[data-mobile-v2-active-panel="labels"] .mobile-v2-nav-item[data-panel="labels"],
    body.feature-mobile-v2[data-mobile-v2-active-panel="frame"] .mobile-v2-nav-item[data-panel="frame"],
    body.feature-mobile-v2[data-mobile-v2-active-panel="extra"] .mobile-v2-nav-item[data-panel="extra"] {
        color: var(--bc-decision-text);
        border-color: var(--bc-decision);
        background: var(--bc-decision);
        box-shadow: none;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-tabs {
        display: none;
        flex-shrink: 0;
        padding: var(--space-2) var(--space-3);
        border-bottom: 1px solid var(--bc-border);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-tabs[aria-hidden="false"] {
        display: flex;
        gap: 0;
        justify-content: flex-start;
        background: var(--bc-surface);
        margin: 0 var(--space-3) var(--space-2);
        padding: var(--space-1);
        border-radius: var(--radius-lg);
        border: 1px solid var(--bc-border);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-padding-inline: var(--space-3);
        scrollbar-width: none;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-tabs[aria-hidden="false"]::-webkit-scrollbar {
        display: none;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-tab {
        flex: 0 0 auto;
        min-width: max-content;
        padding: var(--space-2) var(--space-3);
        font-family: var(--font-sans);
        font-size: 0.8125rem;
        font-weight: 500;
        color: var(--bc-text-muted);
        background: transparent;
        border: none;
        border-radius: var(--radius-md);
        cursor: pointer;
        transition: color var(--transition-fast), background var(--transition-fast);
        -webkit-tap-highlight-color: transparent;
        text-align: center;
        white-space: nowrap;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-tab.active {
        color: var(--bc-decision-text);
        background: var(--bc-decision);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    }

    /* --- Icon floating toolbar --- */
    body.feature-mobile-v2 .icon-toolbar {
        position: fixed;
        left: 50%;
        transform: translateX(-50%) translateY(8px);
        bottom: calc(72px + max(var(--space-3), env(safe-area-inset-bottom, 0px)));
        z-index: calc(var(--z-nav) - 1);
        min-width: min(92vw, 332px);
    }

    body.feature-mobile-v2 .icon-toolbar[aria-hidden="false"] {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0);
    }

    body.feature-mobile-v2 .icon-toolbar-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-width: 64px;
        min-height: 52px;
        padding: 6px 12px;
        background: transparent;
        border: none;
        border-radius: 12px;
        color: var(--bc-decision-text);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.12s ease;
    }

    body.feature-mobile-v2 .icon-toolbar-btn:active {
        background: rgba(255, 248, 241, 0.12);
    }

    body.feature-mobile-v2 .icon-toolbar-btn.active {
        background: rgba(255, 248, 241, 0.15);
    }

    body.feature-mobile-v2 .icon-toolbar-btn--danger {
        color: #ff6b6b;
    }

    body.feature-mobile-v2 .icon-toolbar-btn--confirm {
        color: #86efac;
    }

    body.feature-mobile-v2 .icon-toolbar-label {
        font-family: var(--font-sans);
        font-size: 0.5625rem;
        font-weight: 600;
        letter-spacing: 0.5px;
        text-transform: uppercase;
    }

    body.feature-mobile-v2 .icon-toolbar-swatch {
        display: block;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.4);
        background: var(--bc-surface);
    }

    body.feature-mobile-v2 .icon-toolbar-size-val {
        font-family: var(--font-sans);
        font-size: 0.875rem;
        font-weight: 700;
        line-height: 1;
    }

    /* --- Icon toolbar panels (color / size) --- */
    body.feature-mobile-v2 .icon-toolbar-panel {
        position: fixed;
        left: 50%;
        transform: translateX(-50%) translateY(8px);
        bottom: calc(132px + max(var(--space-3), env(safe-area-inset-bottom, 0px)));
        z-index: calc(var(--z-nav) - 1);
        max-width: calc(100vw - 2rem);
        min-width: min(92vw, 300px);
    }

    body.feature-mobile-v2 .icon-toolbar-panel[aria-hidden="false"] {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0);
    }

    body.feature-mobile-v2 .icon-toolbar-panel-presets {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    body.feature-mobile-v2 .icon-toolbar-preset-swatch {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        border: 2px solid transparent;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: border-color 0.12s ease, transform 0.12s ease;
    }

    body.feature-mobile-v2 .icon-toolbar-preset-swatch.selected {
        border-color: var(--bc-decision-text);
        transform: scale(1.15);
    }

    body.feature-mobile-v2 .icon-toolbar-panel-custom {
        display: inline-block;
        padding: 5px 10px;
        background: rgba(255, 255, 255, 0.12);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        color: var(--bc-decision-text);
        font-family: var(--font-sans);
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }

    /* Off-screen input; <label for> provides native color picker (avoids iOS + programmatic .click()) */
    body.feature-mobile-v2 .icon-toolbar-panel-color-input {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
        opacity: 0;
    }

    body.feature-mobile-v2 .icon-toolbar-panel-variants {
        display: flex;
        gap: 4px;
        margin-left: 4px;
    }

    body.feature-mobile-v2 .icon-toolbar-variant-btn {
        padding: 5px 10px;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.25);
        border-radius: 8px;
        color: rgba(255, 253, 248, 0.7);
        font-family: var(--font-sans);
        font-size: 0.6875rem;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    }

    body.feature-mobile-v2 .icon-toolbar-variant-btn.selected {
        background: rgba(255, 255, 255, 0.18);
        color: var(--bc-decision-text);
        border-color: rgba(255, 255, 255, 0.5);
    }

    /* Size slider panel: avoid min-width overflow on narrow viewports */
    body.feature-mobile-v2 .icon-toolbar-size-row {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        margin: 0 auto;
        box-sizing: border-box;
        justify-content: center;
        flex-wrap: nowrap;
        --its-thumb: 22px;
        --its-track-h: 4px;
        padding-inline: calc(var(--its-thumb) / 2);
    }

    body.feature-mobile-v2 .icon-toolbar-size-min,
    body.feature-mobile-v2 .icon-toolbar-size-max {
        font-family: var(--font-sans);
        font-size: 0.6875rem;
        font-weight: 600;
        color: rgba(255, 253, 248, 0.7);
        white-space: nowrap;
        width: 2.8rem;
        text-align: center;
    }

    body.feature-mobile-v2 .icon-toolbar-size-slider {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 28px;
        height: 28px;
        box-sizing: border-box;
        -webkit-appearance: none;
        appearance: none;
        background: transparent;
        border-radius: 2px;
        outline: none;
        margin: 0;
        padding: 0;
    }

    body.feature-mobile-v2 .icon-toolbar-size-slider::-webkit-slider-runnable-track {
        height: 4px;
        border-radius: 2px;
        background: rgba(255, 255, 255, 0.2);
    }

    body.feature-mobile-v2 .icon-toolbar-size-slider::-moz-range-track {
        height: 4px;
        border-radius: 2px;
        background: rgba(255, 255, 255, 0.2);
    }

    body.feature-mobile-v2 .icon-toolbar-size-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: var(--its-thumb, 22px);
        height: var(--its-thumb, 22px);
        background: var(--bc-decision-text);
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
        transform: translateY(calc((var(--its-track-h, 4px) - var(--its-thumb, 22px)) / 2));
    }

    body.feature-mobile-v2 .icon-toolbar-size-slider::-moz-range-thumb {
        width: var(--its-thumb, 22px);
        height: var(--its-thumb, 22px);
        background: var(--bc-decision-text);
        border-radius: 50%;
        border: none;
        cursor: pointer;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
        transform: translateY(calc((var(--its-track-h, 4px) - var(--its-thumb, 22px)) / 2));
    }

    /* --- Icon context menu (long-press) --- */
    body.feature-mobile-v2 .icon-context-menu {
        position: fixed;
        z-index: calc(var(--z-nav) - 1);
        display: flex;
        flex-direction: column;
        min-width: 180px;
        padding: 6px;
        background: var(--bc-decision);
        border-radius: 14px;
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
        opacity: 0;
        pointer-events: none;
        transform: scale(0.92);
        transform-origin: top left;
        transition: opacity 0.12s ease, transform 0.12s ease;
    }

    body.feature-mobile-v2 .icon-context-menu[aria-hidden="false"] {
        opacity: 1;
        pointer-events: auto;
        transform: scale(1);
    }

    body.feature-mobile-v2 .icon-context-menu-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        background: transparent;
        border: none;
        border-radius: 10px;
        color: var(--bc-decision-text);
        font-family: var(--font-sans);
        font-size: 0.8125rem;
        font-weight: 500;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.1s ease;
    }

    body.feature-mobile-v2 .icon-context-menu-item:active {
        background: rgba(255, 255, 255, 0.1);
    }

    body.feature-mobile-v2 .icon-context-menu-item--danger {
        color: #ff6b6b;
    }

    body.feature-mobile-v2 .mobile-v2-sheet {
        position: fixed;
        inset: 0;
        z-index: calc(var(--z-nav) + 2);
        display: flex;
        align-items: flex-end;
        justify-content: center;
        pointer-events: none;
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-open="true"] {
        pointer-events: auto;
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-open="true"] .mobile-v2-sheet-backdrop {
        opacity: 1;
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-open="true"] .mobile-v2-sheet-content {
        transform: translateY(0);
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-panel-id="place"] .mobile-v2-sheet-content {
        height: calc(100vh - var(--header-offset) - 62px);
        max-height: calc(100vh - var(--header-offset) - 62px);
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-panel-id="place"] .mobile-v2-sheet-body {
        overflow-y: auto;
        padding-top: var(--space-2);
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-panel-id="place"] .autocomplete-dropdown {
        z-index: 240;
        max-height: min(52vh, 420px);
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-panel-id="extra"][data-active-tab-id="icons"] .mobile-v2-sheet-content {
        max-height: 50dvh;
    }

    body.feature-mobile-v2 .mobile-v2-sheet[data-panel-id="extra"][data-active-tab-id="icons"] .icon-editor-card {
        display: none;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        transition: opacity var(--transition-base);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-content {
        position: relative;
        width: 100%;
        max-height: calc(100vh - var(--header-offset) - 62px);
        overflow: hidden;
        background: var(--bc-workspace);
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        box-shadow: var(--shadow-lg);
        transform: translateY(100%);
        transition: transform var(--transition-base);
        display: flex;
        flex-direction: column;
        margin: 0;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-3);
        border-bottom: 1px solid var(--bc-border);
        flex-shrink: 0;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-title {
        font-family: var(--font-sans);
        font-size: 1rem;
        font-weight: 600;
        color: var(--bc-ink);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-close {
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--bc-text-muted);
        background: var(--bc-surface);
        border: 1px solid var(--bc-border);
        cursor: pointer;
        border-radius: var(--radius-md);
        transition: var(--transition-fast);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-close:hover {
        color: var(--bc-ink);
        border-color: var(--bc-border-strong);
        background: var(--bc-surface);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-close-icon-desktop {
        display: none;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-close-icon-mobile {
        display: block;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-close-ear {
        width: 34px;
        height: 34px;
        border-radius: 999px;
        position: static;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body {
        overflow-y: auto;
        padding: var(--space-3);
        flex: 1;
        min-height: 0;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .controls-hint,
    body.feature-mobile-v2 .mobile-v2-sheet-body .radius-slider-labels {
        margin-top: var(--space-1);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .controls-section {
        margin-bottom: 0;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .poster-style-selector,
    body.feature-mobile-v2 .mobile-v2-sheet-body .theme-grid {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: var(--space-2);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: var(--space-1);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .poster-style-selector::-webkit-scrollbar,
    body.feature-mobile-v2 .mobile-v2-sheet-body .theme-grid::-webkit-scrollbar {
        display: none;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .theme-swatch {
        flex: 0 0 auto;
        width: 96px;
        min-width: 96px;
        height: 96px;
        min-height: 96px;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .coverage-option,
    body.feature-mobile-v2 .mobile-v2-sheet-body .layer-toggle {
        min-height: 44px;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .poster-style-option {
        flex: 0 0 auto;
        width: 108px;
        min-width: 108px;
        min-height: 44px;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .text-field-input,
    body.feature-mobile-v2 .mobile-v2-sheet-body .search-input {
        min-height: 44px;
    }

    /* Frame sheet uses light workspace - default toggle used white-on-transparent for inactive. */
    body.feature-mobile-v2 .mobile-v2-sheet-body .size-standard-toggle {
        width: 100%;
        justify-content: flex-start;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .size-standard-label {
        color: var(--bc-text-muted);
        flex: 1 1 100%;
        min-width: 100%;
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .size-std-btn {
        color: var(--bc-ink);
        background: var(--bc-surface, rgba(255, 255, 255, 0.65));
        border-color: var(--bc-border);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .size-std-btn:hover {
        color: var(--bc-ink);
        border-color: var(--bc-clay);
    }

    body.feature-mobile-v2 .mobile-v2-sheet-body .size-std-btn.active {
        color: var(--bc-text-clay-deep);
        background: var(--bc-clay-soft);
        border-color: var(--bc-clay);
    }

    body.feature-mobile-v2 .mobile-v2-download-actions {
        width: 100%;
    }

    body.feature-mobile-v2 .mobile-v2-download-actions .btn {
        width: 100%;
    }

    body.feature-mobile-v2 .mobile-v2-download-actions .download-hint {
        text-align: center;
    }

    /* Keep post-checkout modal usable on small screens */
    #purchaseSuccessModal {
        align-items: flex-start;
        padding: 1rem;
    }

    #purchaseSuccessModal .modal-content.purchase-success-content {
        margin-top: 0.25rem;
        max-width: 460px;
        max-height: calc(100dvh - 2rem);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1.5rem 1.25rem;
    }

    #purchaseSuccessModal .purchase-preview {
        max-width: min(72vw, 280px);
    }
}

@media (max-width: 374px) {
    body.feature-mobile-v2 .mobile-v2-nav-icon {
        width: 18px;
        height: 18px;
    }
    body.feature-mobile-v2 .mobile-v2-nav-item {
        font-size: 0.5rem;
        padding: 5px 2px;
    }
}

@media (max-width: 480px) {
    .theme-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.375rem;
    }
    
    .controls-panel {
        padding: 0.75rem;
    }
    
    .controls-panel.open {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    .poster-frame {
        max-width: 280px;
    }
    
    .controls-section {
        margin-bottom: 1.25rem;
    }
    
    .controls-title {
        font-size: 1rem;
    }
}

/* ============================================
   Controls Button Row (Save + Download side-by-side)
   ============================================ */

.controls-btn-row {
    display: flex;
    gap: 0.5rem;
}

.controls-btn-row .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex: 1;
}

.controls-btn-row .btn svg {
    flex-shrink: 0;
}

/* ─── Advanced drawer toggle ─────────────────────────────────────────── */
.advanced-drawer-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.4rem 0;
    background: none;
    border: none;
    border-top: 1px solid var(--bc-border);
    color: var(--bc-text-warm);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: left;
    transition: color 0.15s ease;
}

.advanced-drawer-toggle:hover {
    color: var(--text);
}

.advanced-drawer-toggle .chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.advanced-drawer-toggle.open .chevron {
    transform: rotate(180deg);
}

.advanced-drawer {
    padding-top: 0.5rem;
}

/* ─── Location suggestions ───────────────────────────────────────────── */

/* ─── Product summary (SSR + crawlable specs below editor) ───────────── */
.generate-product-summary {
    position: relative;
    z-index: var(--z-base, 1);
    padding: 2.5rem 1.5rem 2rem;
    background: var(--bg-secondary, #f7f5f2);
    border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.generate-product-summary-inner {
    max-width: 42rem;
    margin: 0 auto;
}

.generate-product-summary-title {
    font-family: var(--font-serif, 'Instrument Serif', Georgia, serif);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 400;
    line-height: 1.15;
    margin: 0 0 0.5rem;
    color: var(--text);
}

.generate-product-summary-lead {
    margin: 0 0 0.75rem;
    color: var(--text-muted, #5c5c5c);
    font-size: 1rem;
    line-height: 1.5;
}

.generate-product-summary-price {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
    color: var(--text);
}

.generate-product-summary-price s {
    color: var(--text-muted, #5c5c5c);
    margin-right: 0.35rem;
}

.generate-summary-price--muted {
    color: var(--text-muted, #5c5c5c);
    font-size: 0.95rem;
}

.generate-product-summary-specs {
    margin: 0 0 1.25rem;
    display: grid;
    gap: 0.65rem;
}

.generate-product-summary-specs div {
    display: grid;
    grid-template-columns: minmax(5rem, 7rem) 1fr;
    gap: 0.5rem 1rem;
    align-items: start;
}

.generate-product-summary-specs dt {
    margin: 0;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
}

.generate-product-summary-specs dd {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text-muted, #5c5c5c);
}

.generate-product-summary-specs a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.generate-product-summary-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    font-size: 0.875rem;
}

.generate-product-summary-links a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.generate-product-summary-links a:hover {
    color: var(--accent, #c45c26);
}

/* Mobile editor shell: keep summary crawlable but off-screen */
@media (max-width: 768px) {
    body.generate-page.feature-mobile-v2 .generate-product-summary {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}
