:root {
    --g-ink:     #0A0A0A;
    --g-muted:   #6B6B6B;
    --g-surface: #FFFFFF;
    --g-accent:  #7C3AED;
    --g-border:  rgba(10, 10, 10, 0.10);
    --g-border2: rgba(10, 10, 10, 0.18);
    --g-font:    "Avenir Next", "Avenir", "Helvetica Neue", system-ui, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f0f0f0;
    height: 100vh;
    overflow-y: auto;
}

/* -------------------------------------------------------------------------
   Connecting overlay
------------------------------------------------------------------------- */

#connecting-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: opacity 0.3s ease;
}

#connecting-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.connecting-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.connecting-text {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
}

/* -------------------------------------------------------------------------
   App shell
   Two columns: left = header + chat, right = gray surface with phone preview.
   Header now sits *only* above the chat panel; the preview column starts at
   y=0 so the phone has the full viewport height to breathe.
------------------------------------------------------------------------- */

.app {
    display: flex;
    height: 100vh;
}

.left-column {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* -------------------------------------------------------------------------
   Info panel — right column, gray surface holding a gallery-style phone
------------------------------------------------------------------------- */

.panel-resizer {
    width: 5px;
    flex-shrink: 0;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s;
    z-index: 10;
}

.panel-resizer:hover,
.panel-resizer.dragging {
    background: #0066cc44;
}

.info-panel {
    /* Default width = "exactly wide enough for a max-height phone plus
       horizontal padding plus a bit of breathing room so the colored glow
       around the phone is visible". With aspect 1:2 a phone of height
       (100vh - 70px) has width (100vh - 70px) / 2; add 74*2 = 148px for
       the panel padding and 50px so the drop-shadow isn't clipped against
       the panel edge. clamp() keeps it within the JS resizer's MIN/MAX. */
    width: clamp(800px, calc((100vh - 70px) / 2 + 448px), 1100px);
    flex-shrink: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--g-surface, #f5f5f7);   /* light gray, like /gallery */
    padding: 20px 60px;
    box-sizing: border-box;
    position: relative;                       /* anchor the approve overlay */
    overflow: hidden;
}

/* Widget sidebar — left of the phone in info-space and messages stages */

#widget-sidebar {
    position: absolute;
    left: 10px;
    top: 20px;
    bottom: 20px;
    width: 150px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 10;
    overflow-y: auto;
    scrollbar-width: none;
}
#widget-sidebar::-webkit-scrollbar { display: none; }

.widget-sidebar-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--g-text-muted, #999);
    margin: 0 0 6px 4px;
}

.widget-sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--g-text-muted, #aaa);
    margin: 10px 0 4px 4px;
}
.widget-sidebar-section-label:first-child { margin-top: 0; }

.widget-sidebar-item {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #222;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s, border-color 0.12s;
    width: 100%;
    backdrop-filter: blur(4px);
}
.widget-sidebar-item:hover {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.18);
}

/* Centre the phone in the gray surface */
.preview-phone-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
}

/* Phone size adapts to the available space while keeping the iPhone-ish
   1:2 aspect ratio. Two constraints:
     1. height ≤ 100vh - 70px  (header bars + breathing room above & below)
     2. width  ≤ 100% of the wrap (so it never overflows horizontally)
   We let aspect-ratio derive the missing dimension after picking the
   tighter of the two. */
.preview-phone-scaler {
    aspect-ratio: 1 / 2;
    width: min(calc((100vh - 70px) / 2), 100%);
    height: auto;
    flex-shrink: 0;
    transform-origin: center center;
    will-change: transform;
}

.preview-phone {
    width: 100%;
    height: 100%;
    border-radius: 46px;
    position: relative;
    /* No overflow:hidden here — the side buttons need to stick out a hair
       past the device edge to read as 3D. Inner screen content is still
       clipped by .preview-phone-inner's own overflow:hidden + border-radius. */
    /* Drop-shadow tinted with the event's background color (set via the
       `--phone-glow-color` CSS variable on .info-panel from main.js).
       Falls back to a warm neutral when no event colour is set yet. */
    box-shadow:
        0 32px 64px color-mix(in srgb, var(--phone-glow-color, rgba(40, 30, 20, 1)) 30%, transparent),
        0 0 0 1px rgba(0, 0, 0, 0.08),
        inset 0 0 0 4px rgba(0, 0, 0, 0.85);
    background: #000;
}

/* iPhone-style physical side buttons. Cosmetic only — no JS handlers.
   Shared between the chat builder's .preview-phone and the gallery's
   .gh-phone (both have the same bezel geometry). Heights are percentages
   of the phone's total height so they scale with the responsive sizing. */
.phone-side-btn {
    position: absolute;
    width: 4px;
    background: linear-gradient(to bottom,
        #555 0%,
        #2a2a2a 18%,
        #2a2a2a 82%,
        #555 100%);
    box-shadow:
        inset 0 1px 1px rgba(0, 0, 0, 0.5),
        0 0 1px rgba(0, 0, 0, 0.4);
    /* Sit visually behind the screen but above the device-rim shadow so
       the protruding edge reads as part of the bezel. */
    z-index: 0;
    pointer-events: none;
}

.phone-side-btn--left {
    left: -2px;
    border-radius: 2px 0 0 2px;
}
.phone-side-btn--right {
    right: -2px;
    border-radius: 0 2px 2px 0;
}

/* iPhone 15+/17 Pro-ish proportions (% of phone height): */
.phone-side-btn--action   { top: 13%;  height: 4.5%; }
.phone-side-btn--vol-up   { top: 21%;  height: 8%;   }
.phone-side-btn--vol-down { top: 30.5%; height: 8%;  }
.phone-side-btn--power    { top: 22%;  height: 14%;  }

.preview-phone-inner {
    position: absolute;
    inset: 4px;
    border-radius: 42px;
    overflow: hidden;
    background: #fafafa;
    display: flex;
    flex-direction: column;
}

/* Zoom layer inside .preview-phone-inner. The inner stays at its real size
   so its overflow:hidden + border-radius clip the zoomed-up content to the
   phone bezel. The wrapper is what visually scales: text, padding, icons,
   and hit areas all grow/shrink with --phone-zoom (set by ResizeObserver
   in main.js based on the phone's rendered width). Without this wrapper,
   applying zoom directly to .preview-phone-inner makes the rounded corner
   poke out past the bezel at zoom > 1. */
.preview-phone-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    zoom: var(--phone-zoom, 1);
}

/* Status bar — floats over content like real iOS */
.preview-phone-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--phone-chrome-color, #fff);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    /* Sits above editing controls (z 20) so widget tool buttons (camera,
       drag, delete) disappear behind the iOS status bar when the user
       scrolls a widget up to the top — same way a real device hides
       content behind its chrome. */
    z-index: 31;  /* above sticky messages-header (z 30) */
    font-family: -apple-system, system-ui, sans-serif;
}
/* All tabs render white chrome — event/messages have brand headers, and
   show/admin tabs paint the brand-tinted glow behind the iframe so white
   stays legible there too. */
.preview-phone-status-icons {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Screen viewport — clips the horizontal slider track. Per-pane scrolling
   lives on .phone-pane below, not here. */
.phone-screen {
    flex: 1;
    overflow: hidden;
    background: #fafafa;
    min-height: 0;
    position: relative;
}

/* Slider track — 4 fixed panes (event, messages, admin, show) laid
   side-by-side; JS translates the track on tab change. */
.phone-tab-slider {
    display: flex;
    /* width + per-pane width set in JS (_resizeSlider) — depends on the
       number of show tabs, which is dynamic. Track grows with N panes. */
    height: 100%;
    transform: translateX(0);  /* explicit baseline so first switch animates */
    transition: transform 280ms cubic-bezier(0.32, 0.72, 0.24, 1);
    will-change: transform;
}
.phone-pane {
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    /* Keep header backgrounds reaching the very top of the screen even
       though each pane is its own scroll container. */
    background: #fafafa;
    position: relative;
}

#phone-preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Sits above the slider as a stage-1/2 overlay. */
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #fff;
}

#phone-preview-placeholder[hidden] { display: none; }

#phone-preview-placeholder-text {
    font-size: 12px;
    color: #777;
    text-align: center;
    padding: 0 24px;
}

/* Home indicator bar at the bottom */

.phone-home-bar {
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.phone-home-indicator {
    width: 120px;
    height: 5px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 3px;
}

/* When the home indicator sits inside the new gallery-style preview phone
   (white background), make it a dark translucent pill instead of white. */
.preview-phone .phone-home-bar {
    position: absolute;
    bottom: 6px;
    left: 0;
    right: 0;
    /* Phone chrome (status bar + home bar) sits on TOP of editing controls
       (z 20) so widget controls disappear behind the iOS bars when the user
       scrolls past them — same as a real device would do. */
    z-index: 30;
    pointer-events: none;
    height: auto;
}
.preview-phone .phone-home-indicator {
    background: rgba(0, 0, 0, 0.35);
    width: 110px;
    height: 4px;
}

#blocks-container {
    /* Pull the widget list up over the header image + gradient.
       No background here — the image stays visible behind the widgets.
       Each widget card supplies its own background.
       Was -170px; -150px gives the first block ~20px more breathing room. */
    margin-top: -150px;
    position: relative;
    z-index: 1;
    padding: 1.5rem;
}

#message-blocks-container {
    padding: 20px;
}

#blocks-container .block,
#message-blocks-container .block {
    margin-top: 12px;
    margin-bottom: 12px;
}

.block-delete-wrapper {
    position: relative;
}

.block-delete-btn {
    position: absolute;
    top: -0.625rem;
    right: -0.625rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.94rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
    /* Editing-controls layer — above widget content (z 0) but below the
       iOS phone chrome (z 30) so controls slide behind the status bar /
       home indicator when the user scrolls them past those bars. */
    z-index: 20;
}

.block-delete-wrapper:hover .block-delete-btn {
    opacity: 1;
}

.block-delete-btn:hover {
    background: rgba(220, 38, 38, 0.85);
}

/* Vertical action column: drag handle + camera button, stacked top-left */
.block-action-col {
    position: absolute;
    top: -0.625rem;
    left: -0.625rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    /* Top layer — same as block-delete-btn, sits above phone chrome. */
    z-index: 20;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.block-delete-wrapper:hover .block-action-col {
    opacity: 1;
}

/* Shared style for items inside the column */
.block-action-col > * {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0.4rem;
    box-sizing: border-box;
    flex-shrink: 0;
}

.block-drag-handle {
    cursor: grab;
}

.block-drag-handle:active {
    cursor: grabbing;
}

.block-editable {
    cursor: text;
    border-radius: 3px;
    outline: none;
    transition: background 0.15s;
}
.block-editable:hover {
    background: rgba(0, 0, 0, 0.04);
}
.block-editable:focus {
    background: rgba(0, 120, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(0, 120, 255, 0.3);
}

/* Camera button inside the action column overrides its image-relative positioning */
.block-action-col .block-img-edit-btn {
    position: static;
    opacity: 1;
    backdrop-filter: none;
}

.block-delete-wrapper.is-dragging {
    opacity: 0.4;
}

.block-delete-wrapper.drag-over-top {
    box-shadow: 0 -3px 0 0 rgb(98, 27, 213);
    border-radius: 2px 2px 0 0;
}

.block-delete-wrapper.drag-over-bottom {
    box-shadow: 0 3px 0 0 rgb(98, 27, 213);
    border-radius: 0 0 2px 2px;
}

.timing-sticker {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.52);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.18rem 0.5rem 0.18rem 0.4rem;
    border-radius: 999px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
}

.timing-sticker-icon {
    width: 0.78rem;
    height: 0.78rem;
    flex: 0 0 auto;
}

.timing-sticker--editable {
    pointer-events: auto;
    cursor: pointer;
}

.timing-sticker--editable:hover {
    background: rgba(0, 0, 0, 0.75);
}

.timing-popup {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
    width: 260px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timing-popup-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #111;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.timing-popup-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    color: #111;
}

.timing-popup-examples {
    font-size: 0.72rem;
    color: #555;
    line-height: 1.6;
}

.timing-popup-example {
    color: #555;
    cursor: pointer;
    text-decoration: underline dotted;
}

.timing-popup-example:hover {
    color: #111;
}

.timing-popup-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.timing-popup-input {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    outline: none;
    box-sizing: border-box;
}

.timing-popup-input:focus {
    border-color: #666;
}

.timing-popup-btn {
    font-size: 0.8rem;
    font-weight: 600;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    white-space: nowrap;
}

.timing-popup-btn:hover {
    background: #333;
}

.timing-popup-btn:disabled {
    cursor: default;
    background: #111;
    opacity: 0.7;
    min-width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Generic button spinner — used by modal-utils.js withButtonSpinner() */
.btn-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: timing-spin 0.6s linear infinite;
    display: inline-block;
}

/* Keep old name as alias so timing-popup.js still works without changes */
.timing-popup-spinner { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: timing-spin 0.6s linear infinite; display: inline-block; }

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

/* Add Widget / Add Message button */

.add-widget-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.75rem 0 0;
    padding: 1.2rem 1rem;
    background: transparent;
    color: #666;
    font-size: 1.1rem;
    font-weight: 500;
    border: 3px dashed #bbb;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, color 0.15s;
}

.add-widget-btn svg {
    flex-shrink: 0;
    width: 3.3rem;
    height: 3.3rem;
}

.add-widget-btn:hover {
    border-color: #888;
    color: #444;
}

/* Event header */

.event-header {
    width: 100%;
    aspect-ratio: 10 / 13; /* matches BACKGROUND_IMAGE_ASPECT_RATIO 1:1.3 in config.py */
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    position: relative;
    flex-shrink: 0;
}

.event-header-gradient {
    position: absolute;
    /* Gradient covers the full lower half, including the 100px overlap zone,
       so the first widget card slides onto a dark fade — not bare image. */
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.90));
}

.event-header-info {
    position: absolute;
    bottom: 150px;
    left: 0;
    right: 0;
    padding: 1rem 1.25rem;
}

.event-header-title {
    color: #fff;
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.3rem;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
    cursor: text;
    border-radius: 4px;
    outline: none;
    transition: background 0.15s;
}
.event-header-title:hover {
    background: rgba(255,255,255,0.15);
}
.event-header-title[contenteditable="true"] {
    background: rgba(255,255,255,0.2);
    text-overflow: clip;
}

.event-header-users {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.0rem;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
}

/* Mobile: extend background image behind notch.
   NOTE: the old `.phone-island-bar` rule was removed when the layout switched
   to a gallery-style centred phone; the new chrome is inside .preview-phone-inner. */

@media (max-width: 600px) {
    .gh-header {
        padding-top: env(safe-area-inset-top);
        height: calc(70px + env(safe-area-inset-top));
    }

    .event-header {
        margin-left: -8px;
        margin-right: -8px;
        width: calc(100% + 16px);
    }

    .event-header-info {
        padding-top: 48px;
    }
}

/* Phone tab bar */

.phone-tab-bar {
    display: flex;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.phone-tab-bar[hidden] { display: none; }

/* Inside the gallery-style preview phone, the home-indicator pill sits
   absolutely at bottom: 6px. Without extra padding the tab-bar icons
   collide with it — give them 5px clear space below. */
.preview-phone .phone-tab-bar {
    padding-bottom: 10px;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.6rem 0;
    background: none;
    border: none;
    border-top: 2px solid transparent;
    color: #666;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn svg,
.tab-btn img {
    width: 20px;
    height: 20px;
}

.tab-btn img {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.tab-btn.is-active img {
    opacity: 1;
    filter: invert(16%) sepia(90%) saturate(3000%) hue-rotate(260deg) brightness(80%);
}

.tab-btn.is-active {
    color: rgb(98, 27, 213);
    border-top-color: rgb(98, 27, 213);
}

/* Show-tab delete button */

.tab-btn--show-tab {
    position: relative;
    min-width: 0;
}

.tab-btn--show-tab .tab-btn-label {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tab-btn-delete {
    position: absolute;
    top: -0.4rem;
    right: 0.25rem;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 0.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    cursor: pointer;
    z-index: 10;
}

.tab-btn--show-tab:hover .tab-btn-delete {
    opacity: 1;
}

.tab-btn-delete:hover {
    background: rgba(220, 38, 38, 0.9);
}

/* "+" add-tab button at the right of the show tabs */
.tab-btn--add-tab {
    flex: 0 0 auto;
    min-width: 36px;
    color: rgba(0, 0, 0, 0.4);
    /* Make the icon morph into a filled circle on hover so it's discoverable. */
    position: relative;
    transition: color 0.15s;
}
.tab-btn--add-tab svg {
    width: 18px;
    height: 18px;
    margin: 0;
    border-radius: 50%;
    padding: 4px;
    background: transparent;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}
.phone-tab-bar:hover .tab-btn--add-tab svg,
.tab-btn--add-tab:hover svg {
    background: #000;
    color: #fff;
    transform: scale(1.15);
}

/* Tab picker chip — shows tab icon + label */
.tab-picker-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.tab-picker-chip-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

/* Show-tab content panel */

.phone-pane--show {
    display: flex;
    flex-direction: column;
    background: #fff;
}

/* Safe-area top padding only for iframe-bearing panes — placeholder panes
   have their own header that handles the inset. */
.phone-pane--show:has(iframe) {
    padding-top: 36px;
}

/* Iframe-bearing tab content takes the event's brand colour as its
   safe-area background so the strip blends with the module's own header.
   Placeholder content (e.g. "Opens in the Close app" for app-only tabs)
   keeps the white default. */
.phone-pane--show:has(iframe) {
    background: var(--phone-glow-color, #000);
}

.phone-pane--show iframe {
    flex: 1;
    width: 100%;
    border: none;
    min-height: 0;
}

/* Show-tab placeholder panel */

.show-tab-placeholder-header {
    width: 100%;
    padding: 14px 16px;
    padding-top: calc(14px + 36px);  /* 36px safe-area, same as other preview headers */
    min-height: 64px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    background: var(--phone-glow-color, #510EA8);
}

.show-tab-placeholder-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
}

.show-tab-placeholder-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1.5rem;
}

.show-tab-placeholder-icon {
    width: 3rem;
    height: 3rem;
    opacity: 0.3;
}

.show-tab-placeholder-type {
    font-size: 0.8rem;
    color: #666;
}

.show-tab-placeholder-desktop-link {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #7c5cbf;
    text-decoration: underline;
}

/* Background image upload button — top-left corner of the event header */

.bg-upload-btn {
    position: absolute;
    /* Sit ~20px below the standard top inset so the status-bar clock stays
       clearly visible — the camera button shares the top-left corner with
       the iOS status bar text. */
    top: calc(0.75rem + 20px);
    left: 0.75rem;
    height: 2.25rem;
    width: 2.25rem;
    border-radius: 1.125rem;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.45rem;
    gap: 0;
    overflow: hidden;
    transition: width 0.25s ease, background 0.15s, gap 0.25s ease;
    /* Top layer — above the phone chrome so the camera button is always reachable
       even when the event header sits flush with the status bar. */
    z-index: 20;
}

.bg-upload-btn:hover {
    background: rgba(0, 0, 0, 0.65);
}

.event-header:hover .bg-upload-btn {
    background: rgba(0, 0, 0, 0.65);
    width: var(--bg-upload-expanded-width, 11rem);
    gap: 0.4rem;
}

.bg-upload-btn svg {
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
}

.bg-upload-label {
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    padding-left: 0.45rem;
    transition: max-width 0.25s ease, opacity 0.2s ease;
}

.event-header:hover .bg-upload-label {
    max-width: 10rem;
    opacity: 1;
}

/* Drag-over state: highlight border on the event header */

.event-header.drag-over {
    outline: 3px dashed rgba(255, 255, 255, 0.8);
    outline-offset: -4px;
}


/* Messages header */

.collect-info-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 36px 1rem 0.85rem;  /* 36px safe-area top */
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 30;
    margin-top: -1px;
    background: #510EA8;
}

.collect-info-header[hidden] { display: none; }


.messages-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 46px 1rem 0.85rem;  /* 36px safe-area + 10px content gap */
    flex-shrink: 0;
    position: sticky;
    top: 0;
    /* Same chrome layer as the iOS status / home bar (z 30) so widget
       editing controls (z 20) slide behind this sticky header instead of
       painting on top of the title text when scrolled. */
    z-index: 30;
    margin-top: -1px;       /* flush against the top of the phone screen */
}

.messages-header[hidden] { display: none; }

.messages-back-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.9;
}

.messages-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.25);
    background-image: url('/static/img/default_icon.png');
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.messages-header-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.messages-header-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: text;
    border-radius: 4px;
    outline: none;
    transition: background 0.15s;
}
.messages-header-title:hover {
    background: rgba(255,255,255,0.15);
}
.messages-header-title[contenteditable="true"] {
    text-overflow: clip;
    overflow: visible;
}

.messages-header-sub {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
}
.messages-header-sub:empty { display: none; }

.messages-color-btn {
    position: relative;
    margin-left: auto;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 1.125rem;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.45rem;
    align-self: center;
    overflow: hidden;
    gap: 0;
    transition: width 0.25s ease, background 0.15s, gap 0.25s ease;
}
.messages-color-btn:hover { background: rgba(0, 0, 0, 0.65); }

.messages-header:hover .messages-color-btn {
    background: rgba(0, 0, 0, 0.65);
    width: 10.5rem;
    gap: 0.4rem;
}

.messages-color-emoji {
    width: 1.35rem;
    text-align: center;
    flex-shrink: 0;
}

.messages-color-label {
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    transition: max-width 0.25s ease, opacity 0.2s ease;
}
.messages-header:hover .messages-color-label {
    max-width: 9rem;
    opacity: 1;
}

/* Block: Button survey */

.block-button-survey {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.survey-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.survey-body {
    padding: 1.1rem 1.1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.survey-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a1a1a;
}

.survey-description {
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 0.5rem;
}

.survey-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.survey-option {
    width: 100%;
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 0.875rem;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
}

.survey-option:hover {
    background: #f5f5f5;
}

.survey-option.selected {
    background: #f0ecfc;
    border-color: rgb(98, 27, 213);
    color: rgb(98, 27, 213);
}

.survey-send-button {
    width: 100%;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    color: #888;
    cursor: default;
    text-align: center;
    transition: color 0.15s;
}

.survey-send-button:not(:disabled) {
    color: #1a1a1a;
    cursor: pointer;
}

.survey-send-button:not(:disabled):hover {
    color: rgb(98, 27, 213);
}

/* Block: Text survey */

.block-text-survey {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.text-survey-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.text-survey-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.text-survey-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a1a;
}

.text-survey-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.6rem;
    font-size: 0.9rem;
    color: #1a1a1a;
    outline: none;
    transition: border-color 0.15s;
}

.text-survey-input:focus {
    border-color: rgb(98, 27, 213);
}

/* Block: Slider survey */

.block-slider-survey {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.slider-survey-fields {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-bottom: 0.5rem;
}

.slider-survey-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.slider-survey-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a1a;
}

.slider-survey-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #e0e0e0;
    outline: none;
    cursor: pointer;
}

.slider-survey-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgb(98, 27, 213);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-survey-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgb(98, 27, 213);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Block: Generic */

.block-generic {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 1rem;
    padding: 1rem 1.25rem;
}

.generic-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.6rem;
}

.generic-body p               { font-size: 0.9rem; color: #444; line-height: 1.6; margin-bottom: 0.5rem; }
.generic-body p:last-child    { margin-bottom: 0; }
.generic-body ul,
.generic-body ol              { padding-left: 1.25rem; margin-bottom: 0.5rem; font-size: 0.9rem; color: #444; }
.generic-body li              { margin-bottom: 0.2rem; line-height: 1.5; }
.generic-body strong          { font-weight: 600; color: #1a1a1a; }

/* Block: Link widget */

.block-link-widget {
    display: flex;
    align-items: stretch;
    border-radius: 1rem;
    border: 1px solid #e8e8e8;
    background: #fff;
    text-decoration: none;
    color: #1a1a1a;
    overflow: hidden;
    transition: background 0.15s;
}

.block-link-widget:hover {
    background: #f5f5f5;
}

.link-widget-image {
    width: 80px;
    min-height: 80px;
    flex-shrink: 0;
    object-fit: cover;
    display: block;
    /* stretch to card height — explicit height: 80px would prevent flex stretch */
    align-self: stretch;
}

/* When the image is wrapped in .block-img-wrap (editor mode), the wrapper
   stretches as the flex child; the img must fill it with height: 100%. */
.block-link-widget .block-img-wrap {
    flex-shrink: 0;
    width: 80px;
    align-self: stretch;
}

.block-link-widget .block-img-wrap .link-widget-image {
    width: 100%;
    height: 100%;
    min-height: 80px;
}

.link-widget-lines {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    gap: 0.2rem;
    padding: 0.75rem;
    overflow: hidden;
}

.link-widget-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.88rem;
}

/* Widget image edit button — injected by block renderers for link and button_survey */

.block-img-wrap {
    position: relative;
    display: block;
    line-height: 0; /* collapse whitespace gap under the img */
}

.block-img-edit-btn,
.block-img-refresh-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    flex-shrink: 0;
}

.block-img-edit-btn svg,
.block-img-refresh-btn svg {
    width: 100%;
    height: 100%;
}

/* Refresh button inside the action column resets its own positioning */
.block-action-col .block-img-refresh-btn {
    position: static;
    opacity: 1;
    backdrop-filter: none;
}


/* Block: Heading */

.block-heading-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #555;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Tiny white halo so the dark grey title stays readable when it sits
       directly on top of a dark event-header background image (no card behind). */
    text-shadow:
        0 0 1px rgba(255, 255, 255, 0.9),
        0 0 2px rgba(255, 255, 255, 0.6);
}

/* Block: Content card */

.block-content-card {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.content-card-image-wrap {
    position: relative;
}

.content-card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.content-card-push {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    color: #3b3ef5;
}

.content-card-push svg {
    width: 1.2rem;
    height: 1.2rem;
}

.content-card-body {
    padding: 1rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.content-card-body[hidden] { display: none; }

.content-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
}

.content-card-message {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.45;
}

.content-card-button {
    display: block;
    text-align: center;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a1a;
    text-decoration: none;
    transition: background 0.15s;
}

.content-card-button:hover {
    background: #f5f5f5;
}

.content-card-descriptions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.content-card-desc-heading {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-top: 0.4rem;
}

.content-card-desc {
    font-size: 0.85rem;
    color: #444;
    line-height: 1.5;
}

/* Carousel */

.block-carousel {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0.25rem 0 0.75rem;
    /* hide scrollbar but keep functionality */
    scrollbar-width: none;
}

.block-carousel::-webkit-scrollbar {
    display: none;
}

/* Carousel breaks out of container padding to be full-width.
   Negative margin pulls the carousel to the container edges; internal padding
   keeps the focused card aligned at the same offset as regular widgets.
   scroll-padding-left ensures subsequent cards also snap to that offset, so
   previous/next card peek shows inside the margin space on each side.
   Applies to both the editor preview and the gallery preview. */
/* Negative-margin bleed moves to the nav wrapper so prev/next buttons
   can be absolutely positioned at the true screen edges. */
#blocks-container .carousel-nav-wrapper,
.gh-blocks-container .carousel-nav-wrapper {
    margin-left: -1.5rem;
    margin-right: -1.5rem;
}
#blocks-container .block-carousel,
.gh-blocks-container .block-carousel {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    scroll-padding-left: 1.5rem;
}

#message-blocks-container .carousel-nav-wrapper,
.gh-message-blocks-container .carousel-nav-wrapper {
    margin-left: -20px;
    margin-right: -20px;
}
#message-blocks-container .block-carousel,
.gh-message-blocks-container .block-carousel {
    padding-left: 20px;
    padding-right: 20px;
    scroll-padding-left: 20px;
}

.carousel-nav-wrapper {
    position: relative;
}

.carousel-nav-btn {
    position: absolute;
    /* Start below the delete button (which sits at top:-0.625rem and is 2rem
       tall, ending around top:1.375rem) so a corner click hits delete, not
       the carousel nav. */
    top: 2rem;
    bottom: 0.75rem; /* match carousel padding-bottom */
    width: 50px;
    z-index: 10;
    cursor: pointer;
}
.carousel-nav-prev { left:  0; }
.carousel-nav-next { right: 0; }

.block-carousel-item {
    flex: 0 0 100%;
    scroll-snap-align: start;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.block-carousel-item .block-delete-wrapper,
.block-carousel-item .block-content-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Widget picker modal */

.widget-picker-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
}

.widget-picker-backdrop[hidden] {
    display: none;
}

.widget-picker {
    background: #fff;
    border-radius: 1.25rem;
    width: 100%;
    max-width: 460px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    padding: 1.5rem;
}

.widget-picker-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: #f0f0f0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
    z-index: 1;
    flex-shrink: 0;
}

.widget-picker-close svg {
    width: 1rem;
    height: 1rem;
}

.widget-picker-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 1rem;
    padding-right: 2.5rem;
    line-height: 1.35;
}

.widget-picker-section {
    margin-bottom: 1rem;
}

.widget-picker-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #666;
    margin: 0 0 0.5rem;
}

.widget-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.widget-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 2rem;
    border: 1.5px solid #e0e0e0;
    background: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, background 0.15s;
}

.widget-chip:hover {
    border-color: #aaa;
    background: #f5f5f5;
}



/* Content card modal */

.card-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
}

.card-modal-backdrop[hidden] {
    display: none;
}

.card-modal {
    background: #fff;
    border-radius: 1.25rem;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.card-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: #f0f0f0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e53e3e;
    z-index: 1;
}

.card-modal-close svg {
    width: 1rem;
    height: 1rem;
}

.card-modal-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    border-radius: 1.25rem 1.25rem 0 0;
}

.card-modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a1a1a;
}

.card-modal-desc-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-top: 0.5rem;
}

.card-modal-desc {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.55;
}

/* Block: Web widget */

.block-web-widget {
    width: 100%;
    border-radius: 0.75rem;
    overflow: hidden;
}

.web-widget-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

#blocks-container .web-widget-iframe,
#message-blocks-container .web-widget-iframe {
    overflow: hidden;
    pointer-events: none;
}

/* Block: Image (message flow — image on top, text below) */

.block-image-message {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.block-image-message-img {
    width: 100%;
    height: auto;
    border-radius: 0.75rem 0.75rem 0 0;
    display: block;
}

.block-image-message--no-text .block-image-message-img {
    border-radius: 0.75rem;
}

.block-image-message .message-text-block {
    border-radius: 0 0 0.75rem 0.75rem;
    margin-top: 0;
    margin-bottom: 0;
}

/* Block: Image (info space — linked card) */

.block-image-link {
    display: block;
    position: relative;
}

.block-image-img {
    width: 100%;
    height: auto;
    border-radius: 0.75rem;
    display: block;
}

.block-image-overlay {
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.3rem 0.6rem;
    border-radius: 0.35rem;
    backdrop-filter: blur(4px);
}

/* -------------------------------------------------------------------------
   Chat panel
------------------------------------------------------------------------- */

.chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;                  /* fill the remaining height in .left-column */
    min-height: 0;            /* allow inner scroll areas to shrink */
    min-width: 0;
    background: #fff;
    position: relative;
}

.chat-header {
    padding: 0.5rem 1.25rem;
    background: #1a1a1a;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.chat-header-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-header-version {
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.04em;
}

/* Stepper + version on a white background — applies to both the legacy
   in-header rendering and the new .builder-subbar where they now live. */
.gh-header .chat-header-version,
.builder-subbar .chat-header-version {
    color: rgba(0, 0, 0, 0.5);
}

.gh-header .stage-step,
.builder-subbar .stage-step {
    /* Match the grey used for inactive nav-link labels in the top bar
       (--g-muted = #6B6B6B), which is a touch darker than rgba(0,0,0,0.5). */
    color: var(--g-muted);
}

.gh-header .stage-step-icon,
.builder-subbar .stage-step-icon {
    border-color: rgba(0, 0, 0, 0.2);
}

.gh-header .stage-step-arrow,
.builder-subbar .stage-step-arrow {
    background: rgba(0, 0, 0, 0.12);
}

.gh-header .stage-step.is-active,
.builder-subbar .stage-step.is-active {
    color: #7C3AED;
}

.gh-header .stage-step.is-active .stage-step-icon,
.builder-subbar .stage-step.is-active .stage-step-icon {
    background: #7C3AED;
    border-color: #7C3AED;
}

.gh-header .stage-step.is-done,
.builder-subbar .stage-step.is-done {
    color: rgba(0, 0, 0, 0.6);
}

.gh-header .stage-step.is-done .stage-step-icon,
.builder-subbar .stage-step.is-done .stage-step-icon {
    background: transparent;
    border-color: rgba(0, 0, 0, 0.4);
    color: rgba(0, 0, 0, 0.6);
}

/* Stage stepper */
.stage-stepper {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stage-step {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.stage-step-icon {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.stage-step-arrow {
    width: 1rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

/* Active stage */
.stage-step.is-active {
    color: #fff;
}

.stage-step.is-active .stage-step-icon {
    background: #fff;
    border-color: #fff;
}

/* Completed stage */
.stage-step.is-done {
    color: rgba(255, 255, 255, 0.6);
}

.stage-step.is-done .stage-step-icon {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.6);
}

.stage-step.is-done .stage-step-icon::after {
    content: "✓";
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    position: relative;
}

.message {
    display: flex;
}

.message.user                        { justify-content: flex-end; }
.message.system, .message.assistant  { justify-content: flex-start; }

.bubble {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.45;
}

.message.user .bubble {
    background: rgb(98, 27, 213);
    color: #fff;
    border-bottom-right-radius: 0.2rem;
}

.message.system .bubble,
.message.assistant .bubble {
    background: #f0f0f0;
    color: #1a1a1a;
    border-bottom-left-radius: 0.2rem;
}

.message.system .bubble p,
.message.assistant .bubble p               { margin: 0 0 0.5rem; }
.message.system .bubble p:last-child,
.message.assistant .bubble p:last-child    { margin-bottom: 0; }
.message.system .bubble ul,
.message.system .bubble ol,
.message.assistant .bubble ul,
.message.assistant .bubble ol              { padding-left: 1.25rem; margin: 0 0 0.5rem; }
.message.system .bubble li,
.message.assistant .bubble li              { margin-bottom: 0.2rem; }
.message.system .bubble code,
.message.assistant .bubble code            { background: #e0e0e0; border-radius: 0.25rem; padding: 0.1rem 0.3rem; font-size: 0.85em; }
.message.system .bubble pre,
.message.assistant .bubble pre             { background: #e0e0e0; border-radius: 0.4rem; padding: 0.75rem; overflow-x: auto; margin: 0.5rem 0; }
.message.system .bubble pre code,
.message.assistant .bubble pre code        { background: none; padding: 0; }

/* Stage divider */

.stage-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
    color: #666;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.stage-divider::before,
.stage-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

/* Thinking bubble */

.thinking-text {
    display: block;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.4rem;
}

/* Typing indicator */

.typing-dots {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    height: 1rem;
}

.typing-dots span {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: #999;
    animation: bounce 1.2s infinite ease-in-out;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%            { transform: translateY(-6px); }
}

/* Chat input */

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.chat-input textarea {
    flex: 1;
    padding: 0.6rem 0.9rem;
    border: 1px solid #ddd;
    border-radius: 1.1rem;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    resize: none;
    overflow-y: hidden;
    line-height: 1.45;
    max-height: 10rem;
    overflow-y: auto;
    transition: border-color 0.15s;
}

.chat-input textarea:focus {
    border-color: #1a1a1a;
}

.chat-input button[type="submit"] {
    height: 2.5rem;
    padding: 0 1rem;
    gap: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.chat-input button[type="submit"]:hover {
    opacity: 0.8;
}

/* -------------------------------------------------------------------------
   Quick replies
------------------------------------------------------------------------- */

.reply-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
    padding: 0 1rem;
}

.reply-btn {
    padding: 0.6rem 1rem;
    background: transparent;
    color: rgb(98, 27, 213);
    border: 1.5px solid rgb(98, 27, 213);
    border-radius: 1.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.reply-btn:hover {
    background: rgb(98, 27, 213);
    color: #fff;
    transform: translateY(-2px);
}

.reply-btn:active {
    transform: translateY(0);
    opacity: 0.7;
}

.reply-btn--primary {
    background: rgb(98, 27, 213);
    color: #fff;
    border-color: rgb(98, 27, 213);
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.75rem 1.25rem;
}

.reply-btn--primary:hover {
    opacity: 0.88;
}

.reply-btn-emoji {
    font-size: 100%;
}

#approve-bar {
    /* Floating overlay at the TOP of the preview column. Slides in from
       the right edge to the centred resting position so it's visible but
       less in-the-way for someone who just wants to keep editing. */
    position: absolute;
    left: 50%;
    top: 24px;
    width: 70%;                               /* max 70% of the preview column */
    max-width: 360px;
    /* Start position: pushed off-screen to the right (clipped by the
       info-panel's overflow: hidden). 200% of own width past left:50% is
       safely beyond any reasonable panel width. */
    transform: translateX(200%);
    background: rgba(28, 28, 30, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px;
    /* Layered shadow: tight grounding close-shadow + wide soft halo. Both
       opacities are intentionally heavy because the popup sits over the
       dark phone bezel for much of its bleed area — anything subtler just
       blends in and reads as "no shadow at all". The brighter rim keeps
       the dark glass surface separated from anything behind it. */
    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.45),
        0 40px 96px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem 2.5rem 3.5rem;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition:
        opacity 0.25s ease,
        transform 0.45s cubic-bezier(0.32, 0.72, 0.24, 1);
}

#approve-bar.is-visible {
    opacity: 1;
    /* Resting position — centred horizontally on left:50%. */
    transform: translateX(-50%);
    pointer-events: auto;
}

#approve-bar.is-minimized {
    opacity: 1;
    pointer-events: auto;
    /* Anchor to top-right of the preview column; no centering transform */
    left: auto;
    right: 12px;
    top: 12px;
    width: auto;
    max-width: none;
    transform: none;
    /* Small pill with emoji on the left and the action button on the right */
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: 2rem;
    background: rgba(28, 28, 30, 0.96);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

#approve-bar.is-minimized #approve-hint,
#approve-bar.is-minimized #approve-hint-2,
#approve-bar.is-minimized #approve-dismiss { display: none; }

#approve-bar.is-minimized #approve-emoji {
    font-size: 1.2rem;
    margin: 0 2px 0 6px;
    line-height: 1;
}

#approve-bar.is-minimized #approve-btn {
    margin: 0;
    padding: 0.4rem 0.9rem;
    font-size: 0.78rem;
    border-radius: 2rem;
}

#approve-emoji {
    font-size: 2.76rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

#approve-hint {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    line-height: 1.4;
    margin-bottom: 0.15rem;
}

#approve-hint-2 {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    line-height: 1.4;
}

#approve-btn {
    margin-top: 1rem;
    padding: 0.75rem 1.25rem;
    background: rgb(98, 27, 213);
    color: #fff;
    border: none;
    border-radius: 1.5rem;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    white-space: nowrap;
}

#approve-btn:hover  { opacity: 0.88; transform: translateY(-1px); }
#approve-btn:active { opacity: 0.7;  transform: translateY(0); }

/* WYSIWYG_ONLY V2: persistent stage navigation (stages 4-6, no chat).
   Lives at the bottom of the left-side panel. */
#stage-nav {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    margin-top: 0.75rem;
    border-top: 1px solid #ececf0;
}
#stage-nav[hidden] { display: none; }
#stage-nav [hidden] { display: none !important; }
.stage-nav-spacer { flex: 1; }

.stage-nav-btn {
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.7rem 1.4rem;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s ease, background 0.2s ease, transform 0.1s ease;
}
.stage-nav-btn:active { transform: translateY(1px); opacity: 0.8; }

.stage-nav-btn--primary { background: #510EA8; color: #fff; }
.stage-nav-btn--primary:hover { background: #3F0B83; }

.stage-nav-btn--ghost { background: #f0f0f3; color: #1a1a1a; }
.stage-nav-btn--ghost:hover { background: #e4e4ea; }

#stage-nav-back { padding: 0.7rem 1rem; font-size: 1.1rem; line-height: 1; }

/* WYSIWYG_ONLY V3: edit-details toggle (header) + collapsible details editor. */
.edit-details-btn {
    position: absolute;
    top: calc(0.75rem + 20px);
    right: 0.75rem;
    height: 2.25rem;
    width: 2.25rem;
    border-radius: 1.125rem;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem;
    z-index: 20;
    transition: background 0.15s;
}
.edit-details-btn[hidden] { display: none; }
.edit-details-btn svg { width: 1.1rem; height: 1.1rem; }
.edit-details-btn:hover,
.edit-details-btn.is-active { background: rgba(0, 0, 0, 0.65); }

/* Event-details editor modal — top-level so it's never clipped by the phone
   preview's transforms. Light box because the editor text is dark. */
.details-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}
.details-modal-overlay[hidden] { display: none; }
.details-modal-box {
    position: relative;
    width: min(460px, 92vw);
    max-height: 82vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 18px;
    padding: 2rem 1.5rem 1.5rem;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}
.details-modal-title {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
}
.details-modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 2rem;
    height: 2rem;
    background: #f0f0f3;
    color: #1a1a1a;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.details-modal-close svg { width: 1rem; height: 1rem; }
.details-modal-close:hover { background: #e4e4ea; }
/* Inside the modal the editor is a normal block on a white card. */
#details-modal-mount #event-properties { display: block; }

/* WYSIWYG_ONLY V5: the chat is closed in stages 4-6. The left column keeps its
   width but swaps the chat for a side panel of best-practice tips + the stage
   actions; the phone preview stays on the right. */
body.stage-no-chat .chat-panel    { display: none; }
body.stage-no-chat #stage-panel   { display: flex; }

#stage-panel {
    display: none;            /* shown via body.stage-no-chat */
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: #fff;
    padding: 1.5rem 1.5rem 1.25rem;
    box-sizing: border-box;
}

.stage-panel-tips {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.stage-panel-tips-title {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
}
.stage-panel-tips-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.stage-panel-tips-list li {
    position: relative;
    padding-left: 1.6rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #3a3a3c;
}
.stage-panel-tips-list li::before {
    content: "💡";
    position: absolute;
    left: 0;
    top: 0;
}
.stage-panel-tips-list li.is-empty::before { content: ""; }

/* WYSIWYG_ONLY: full-screen spinner overlays (publishing + stage generation). */
#publish-loading,
#generate-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 390;
}
#publish-loading[hidden],
#generate-loading[hidden] { display: none; }
.publish-loading-box { text-align: center; }
.publish-spinner {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.25rem;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: publish-spin 0.8s linear infinite;
}
@keyframes publish-spin { to { transform: rotate(360deg); } }
.publish-loading-msg { font-size: 1.05rem; color: rgba(255, 255, 255, 0.9); }

/* WYSIWYG_ONLY V5: full-screen publish result overlay (covers the whole window,
   not just the phone). */
#publish-result {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 400;
    padding: 1.5rem;
}
#publish-result[hidden] { display: none; }
.publish-result-box {
    position: relative;
    width: min(420px, 92vw);
    background: rgba(28, 28, 30, 0.98);
    border-radius: 24px;
    padding: 2.75rem 2rem 2.25rem;
    text-align: center;
    color: #fff;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.publish-result-scan {
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin: 0 0 1.25rem;
}
.publish-result-scan[hidden] { display: none; }
#publish-result-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    width: 2rem;
    height: 2rem;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#publish-result-close svg { width: 1rem; height: 1rem; }
.publish-result-emoji   { font-size: 2.8rem; line-height: 1; margin-bottom: 0.75rem; }
.publish-result-message { font-size: 1rem; line-height: 1.4; margin-bottom: 1.25rem; }
.publish-result-qr {
    width: 240px;
    height: 240px;
    border-radius: 12px;
    background: #fff;
    padding: 10px;
    margin: 0 auto 1rem;
    display: block;
    box-sizing: border-box;
}
.publish-result-qr[hidden]   { display: none; }
.publish-result-link { color: #b794ff; word-break: break-all; font-size: 0.85rem; }
.publish-result-link[hidden] { display: none; }

/* WYSIWYG_ONLY: publish confirmation dialog (final-action warning). */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 1.5rem;
}
.confirm-overlay[hidden] { display: none; }
.confirm-box {
    width: min(400px, 92vw);
    background: #fff;
    border-radius: 18px;
    padding: 2rem 1.75rem;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}
.confirm-emoji   { font-size: 2.6rem; line-height: 1; margin-bottom: 0.5rem; }
.confirm-title   { margin: 0 0 0.6rem; font-size: 1.2rem; font-weight: 700; color: #1a1a1a; }
.confirm-message { margin: 0 0 1.5rem; font-size: 0.95rem; line-height: 1.5; color: #3a3a3c; }
.confirm-actions { display: flex; gap: 0.75rem; justify-content: center; }
.confirm-actions .stage-nav-btn { min-width: 120px; justify-content: center; }

#approve-dismiss {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    padding: 0;
    transition: background 0.15s;
}
#approve-dismiss:hover  { background: rgba(255, 255, 255, 0.25); }
#approve-dismiss svg { width: 14px; height: 14px; }

/* -------------------------------------------------------------------------
   Message blocks
------------------------------------------------------------------------- */

.message-text-block {
    background: #f5f5f5;
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.message-text-content {
    font-size: 0.9rem;
    color: #333;
    line-height: 1.5;
}

.message-text-content p {
    margin: 0 0 0.5rem;
}

.message-text-content p:last-child {
    margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   Event properties panel (stage 1)
------------------------------------------------------------------------- */

#event-properties[hidden] { display: none; }

#event-properties {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-bottom: 1px solid #eee;
}

.event-prop {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.event-prop b {
    font-weight: 600;
    color: #444;
}

.event-prop span {
    color: #111;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.event-prop-editable {
    cursor: text;
    border-radius: 4px;
    padding: 0.1rem 0.25rem;
    margin: -0.1rem -0.25rem;
    transition: background 0.15s;
}

.event-prop-editable:hover {
    background: #f0eeff;
}

.event-prop-locked {
    color: #888;
    cursor: not-allowed;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.event-prop--missing {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 0.5rem;
    padding: 0.35rem 0.5rem;
    flex-direction: row;
    align-items: stretch;
    gap: 0.4rem;
    position: relative;
}

.event-prop--missing .event-prop-missing-content {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    flex: 1;
    min-width: 0;
}

.event-prop--missing .event-prop-warning-emoji {
    margin-left: auto;
    font-size: 1.75em;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.event-prop-placeholder {
    color: #f59e0b;
    font-style: italic;
    font-size: 0.82rem;
}

.event-prop-input {
    width: 100%;
    font: inherit;
    font-size: 0.875rem;
    color: #111;
    border: 1px solid rgb(98, 27, 213);
    border-radius: 4px;
    padding: 0.15rem 0.35rem;
    outline: none;
    background: #fff;
}

.color-swatch {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.color-swatch-wide {
    display: inline-block;
    width: 4rem;
    height: 1.25rem;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
    cursor: pointer;
}

.event-prop-color-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.event-missing {
    font-size: 0.875rem;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
}

.event-missing b {
    font-weight: 600;
    color: #7a5800;
}

.event-missing ul {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
    color: #7a5800;
}

.event-missing li {
    margin: 0.1rem 0;
}

.event-missing-item:hover {
    text-decoration: underline;
}

/* -------------------------------------------------------------------------
   Background image crop modal
------------------------------------------------------------------------- */

.crop-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}

.crop-modal-backdrop[hidden] {
    display: none;
}

.crop-modal {
    background: #1a1a1a;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Constrain so the modal never overflows the viewport */
    max-width: min(92vw, 900px);
    max-height: 92vh;
    overflow: hidden;
}

.crop-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0;
    color: #fff;
}

.crop-modal-title {
    font-weight: 600;
    font-size: 1rem;
}

.crop-modal-cancel {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0;
}

.crop-modal-cancel:hover {
    color: #fff;
}

/* Wrapper that holds the image + the absolutely-positioned crop box */
.crop-canvas-wrap {
    position: relative;
    /* Shrink to fit the image; overflow hidden clips the box-shadow halo */
    display: inline-block;
    align-self: center;
    margin: 0 1.25rem;
    overflow: hidden;
    cursor: crosshair;
    line-height: 0; /* collapse whitespace gap under the img */
}

.crop-canvas-wrap img {
    display: block;
    /* Scale the image to fit without exceeding the modal */
    max-width: min(80vw, 860px);
    max-height: 65vh;
    user-select: none;
    pointer-events: none;
}

/* The crop box itself — box-shadow creates the dark overlay outside the selection */
.crop-box {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    box-sizing: border-box;
    /* Rule-of-thirds grid via repeating gradients at 1/3 intervals */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 33.333% 33.333%;
}

/* Corner resize handles */
.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    /* Offset handles so their centre sits exactly on the corner */
    margin: -7px;
}

.crop-handle-nw { top: 0;   left: 0;   cursor: nw-resize; }
.crop-handle-ne { top: 0;   right: 0;  cursor: ne-resize; }
.crop-handle-sw { bottom: 0; left: 0;  cursor: sw-resize; }
.crop-handle-se { bottom: 0; right: 0; cursor: se-resize; }

.crop-modal-footer {
    padding: 0 1.25rem 1.25rem;
    display: flex;
    justify-content: flex-end;
}

.crop-modal-confirm {
    background: rgb(98, 27, 213);
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    padding: 0.65rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.crop-modal-confirm:hover:not(:disabled) {
    background: rgb(78, 18, 180);
}

.crop-modal-confirm:disabled {
    opacity: 0.6;
    cursor: default;
}


/* ── Shared site header ── */
.gh-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    height: 70px;
    background: var(--g-surface);
    border-bottom: 1px solid var(--g-border);
    flex-shrink: 0;
}

/* Builder-only sub-bar — sits directly below the shared .gh-header and
   carries the stage stepper + version. Visually a slimmer strip with its
   own divider so it doesn't fight the main header for attention. */
.builder-subbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 40px;
    background: var(--g-surface);
    border-bottom: 1px solid var(--g-border);
    flex-shrink: 0;
}

.builder-subbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.gh-header-left {
    display: flex;
    align-items: center;
    gap: 44px;
}

.gh-logo {
    height: 32px;
    width: 32px;
    border-radius: 8px;
    display: block;
    object-fit: cover;
}

.gh-nav {
    display: flex;
    gap: 28px;
}

.gh-nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--g-muted);
    cursor: pointer;
    position: relative;
    padding-bottom: 4px;
    text-decoration: none;
}

.gh-nav-link--active {
    color: var(--g-ink);
    font-weight: 600;
}

.gh-nav-link--active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -22px;
    height: 2px;
    background: var(--g-accent);
    border-radius: 2px;
}

.gh-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Feedback button */
.feedback-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1.5px solid var(--g-accent, #7C3AED);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--g-accent, #7C3AED);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.feedback-btn:hover {
    background: var(--g-accent, #7C3AED);
    color: #fff;
}
.feedback-btn-icon {
    font-size: 15px;
    line-height: 1;
}

/* Floating feedback button — auto-injected by feedback.js on pages without
 * a .gh-header (create-in-app, modules). Sits below iOS safe-area-inset
 * so the notch / status bar doesn't overlap. */
.feedback-fab {
    position: fixed;
    right: 16px;
    top: calc(16px + env(safe-area-inset-top, 0px));
    z-index: 9998;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
}
.feedback-fab:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16), 0 1px 4px rgba(0, 0, 0, 0.10);
}

/* Feedback modal overlay */
.feedback-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.45);
    z-index: 9999;
    align-items: flex-start;
    justify-content: center;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
}
.feedback-overlay.is-open {
    display: flex;
}
.feedback-box {
    background: var(--g-surface, #fff);
    border-radius: 16px;
    padding: 28px 28px 24px;
    width: min(480px, calc(100vw - 40px));
    box-shadow: 0 8px 40px rgba(10,10,10,0.18);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.feedback-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--g-ink, #0A0A0A);
}
.feedback-intro {
    margin: 0;
    line-height: 1.5;
    color: var(--g-muted, #6B6B6B);
}
.feedback-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid var(--g-border2, rgba(10,10,10,0.18));
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--g-ink, #0A0A0A);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
    background: var(--g-bg, #F2F3F5);
}
.feedback-textarea:focus {
    border-color: var(--g-accent, #7C3AED);
}
.feedback-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.feedback-cancel {
    background: none;
    border: 1.5px solid var(--g-border2, rgba(10,10,10,0.18));
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--g-muted, #6B6B6B);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s;
}
.feedback-cancel:hover {
    border-color: var(--g-ink, #0A0A0A);
    color: var(--g-ink, #0A0A0A);
}
.feedback-send {
    background: var(--g-accent, #7C3AED);
    border: none;
    border-radius: 999px;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}
.feedback-send:hover { opacity: 0.88; }
.feedback-send:disabled { opacity: 0.6; cursor: default; }

/* Restart button — two variants */
.restart-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--g-muted);
    transition: color 0.15s;
}
.restart-btn:hover {
    color: var(--g-ink);
}
.restart-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Chat panel variant: floats top-right */
.restart-btn--chat {
    position: absolute;
    top: 12px;
    right: 14px;
    padding: 6px 10px;
    border-radius: 999px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.restart-btn--chat svg {
    width: 16px;
    height: 16px;
}
.restart-btn--chat:hover {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.15);
}

/* ── Agenda editor popup ───────────────────────────────────────────── */
.agenda-editor-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.25rem;
}
.agenda-editor-backdrop[hidden] { display: none; }

.agenda-editor-modal {
    background: #fff;
    border-radius: 1.25rem;
    width: 100%;
    max-width: 540px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

.agenda-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem 0.9rem;
    border-bottom: 1px solid #ebebeb;
    flex-shrink: 0;
}
.agenda-editor-head h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}
.agenda-editor-close {
    background: #f0f0f0;
    border: none;
    color: #444;
    border-radius: 50%;
    width: 1.9rem;
    height: 1.9rem;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.agenda-editor-close:hover { background: #e0e0e0; }

.agenda-editor-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding: 0.75rem 1.1rem 1rem;
    display: block;
}

.agenda-day-card,
.agenda-add-day-btn {
    margin-bottom: 0.75rem;
}

.agenda-day-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 0.875rem;
    overflow: hidden;
    transition: border-color 0.15s;
}
.agenda-day-card-top {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.9rem;
    background: #fafafa;
}
.agenda-day-num {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.1);
    color: #7C3AED;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.agenda-day-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #1a1a1a;
    font-size: 0.875rem;
    font-weight: 600;
    outline: none;
    font-family: inherit;
    min-width: 0;
}
.agenda-day-badge {
    background: #ebebeb;
    color: #888;
    border-radius: 20px;
    font-size: 0.68rem;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.agenda-day-remove {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem;
    border-radius: 4px;
    transition: color 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.agenda-day-remove:hover { color: #dc2626; }

.agenda-entries-table {
    border-top: 1px solid #ebebeb;
}
.agenda-table-header {
    display: grid;
    grid-template-columns: 68px 68px 1fr 26px;
    padding: 0.4rem 0.9rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #aaa;
    background: #fafafa;
}
.agenda-entry-row {
    display: grid;
    grid-template-columns: 68px 68px 1fr 26px;
    padding: 0.45rem 0.9rem;
    border-top: 1px solid #f0f0f0;
    align-items: center;
}
.agenda-entry-row:hover { background: #fafafa; }
.agenda-time-input {
    background: transparent;
    border: none;
    color: #555;
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    outline: none;
    width: 100%;
}
.agenda-time-input:focus { color: #7C3AED; }
.agenda-desc-input {
    background: transparent;
    border: none;
    color: #1a1a1a;
    font-size: 0.85rem;
    outline: none;
    width: 100%;
    font-family: inherit;
}
.agenda-entry-del {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 0.85rem;
    justify-self: center;
    transition: color 0.15s;
    line-height: 1;
    padding: 0;
}
.agenda-entry-del:hover { color: #dc2626; }
.agenda-add-slot-row {
    padding: 0.45rem 0.9rem;
    border-top: 1px solid #f0f0f0;
}
.agenda-add-slot-btn {
    background: none;
    border: none;
    color: #7C3AED;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.2rem 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: opacity 0.15s;
    font-family: inherit;
}
.agenda-add-slot-btn:hover { opacity: 0.7; }

.agenda-add-day-btn {
    background: #fff;
    border: 2px dashed #ddd;
    color: #aaa;
    border-radius: 0.875rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-family: inherit;
    flex-shrink: 0;
    width: 100%;
}
.agenda-add-day-btn:hover { border-color: #7C3AED; color: #7C3AED; background: rgba(124, 58, 237, 0.03); }

.agenda-editor-foot {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid #ebebeb;
    display: flex;
    gap: 0.65rem;
    justify-content: flex-end;
    flex-shrink: 0;
}
.agenda-editor-cancel {
    background: #f0f0f0;
    border: none;
    color: #444;
    border-radius: 0.65rem;
    padding: 0.6rem 1.1rem;
    font-size: 0.875rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
    font-family: inherit;
}
.agenda-editor-cancel:hover { background: #e5e5e5; }
.agenda-editor-save {
    background: #7C3AED;
    border: none;
    color: #fff;
    border-radius: 0.65rem;
    padding: 0.6rem 1.3rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}
.agenda-editor-save:hover { background: #6d28d9; }

/* ── Text message editor ── */
.text-msg-editor-field {
    margin-bottom: 1rem;
}
.text-msg-editor-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}
.text-msg-editor-textarea {
    width: 100%;
    border: 1.5px solid #e0e0e0;
    border-radius: 0.6rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: #1a1a1a;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.text-msg-editor-textarea:focus {
    outline: none;
    border-color: #7c3aed;
}

/* Template customize popup — full-width prominent CTA button */
.tmpl-customize-btn {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
}
.tmpl-customize-err {
    color: #c0392b;
    font-size: 0.85rem;
    margin-top: 4px;
    min-height: 0;
}
.tmpl-customize-err:empty { display: none; }

.tmpl-customize-required-hint {
    padding: 0 1.25rem 0.5rem;
    text-align: right;
    font-size: 0.75rem;
    color: #6b7280;
}

/* Pencil edit button in block action column */
.block-agenda-edit-btn {
    cursor: pointer;
}
.block-agenda-edit-btn:hover { background: rgba(124, 58, 237, 0.75) !important; }

/* Countdown block */
.block-countdown {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.block-countdown-inner {
    padding: 2rem 2px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.block-countdown-icon {
    font-size: 3rem;
    line-height: 1;
}

.block-countdown-timer {
    font-size: 2rem;
    font-weight: 700;
    color: #222;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    margin: 0;
}

.block-countdown-message {
    font-size: 0.95rem;
    color: #666;
    margin-top: 0;
    font-weight: 500;
}

/* -----------------------------------------------------------------------------
 * Replay mode — dev-only read-only playback of a recorded creation.
 * --------------------------------------------------------------------------- */

.replay-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #1f2937;
    color: #fff;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, monospace;
    padding: 4px 12px;
    text-align: center;
    letter-spacing: 0.05em;
}

body.replay-mode {
    padding-top: 24px;
}

body.replay-mode #chat-form,
body.replay-mode #restart-btn,
body.replay-mode #approve-bar {
    display: none !important;
}

body.replay-mode .phone-frame,
body.replay-mode #event-header,
body.replay-mode .stepper {
    pointer-events: none;
}
