/* ===== FLOATING PREVIEW POPOUT (NON-EDIT) ===== */
.popout-overlay {
    position: absolute;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.popout-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.popout-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.popout-card {
    position: relative;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.18);
    padding: 18px 18px 22px 18px;
    width: min(calc(100vw - 64px), 340px);
    height: auto;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    z-index: 501;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    -webkit-user-select: none;
}

.popout-overlay:not(.hidden) .popout-card {
    transform: scale(1);
}

.popout-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    color: #666;
    transition: background 0.2s, transform 0.2s;
    z-index: 502;
}

.popout-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

.popout-slider-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    margin-top: 18px;
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: #f9fafb;
    display: grid;
    align-items: center;
    justify-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.popout-slide {
    grid-area: 1 / 1;
    position: relative;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

.popout-slide.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.popout-slide.prev {
    transform: translateX(-100%);
}

.popout-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.popout-note-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    font-size: 1.15rem;
    font-family: var(--font-hand), monospace;
    line-height: 1.4;
    box-sizing: border-box;
    overflow-y: auto;
}

.popout-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    height: 12px;
}

.popout-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e5e7eb;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.25s ease, transform 0.25s ease;
}

.popout-dot:hover {
    transform: scale(1.2);
}

.popout-dot.active {
    background-color: #7c3aed;
    transform: scale(1.25);
}

/* Newly added item jump animation */
@keyframes itemJumpIn {
    0% {
        opacity: 0;
        transform: translate(0px, 300px) scale(0.2) rotate(calc((var(--final-rot-deg, 0) - 15) * 1deg));
    }
    65% {
        transform: translate(0px, -30px) scale(calc(var(--final-scale, 1) * 1.25)) rotate(calc((var(--final-rot-deg, 0) + 10) * 1deg));
    }
    85% {
        transform: translate(0px, 10px) scale(calc(var(--final-scale, 1) * 0.95)) rotate(calc((var(--final-rot-deg, 0) - 3) * 1deg));
    }
    100% {
        opacity: 1;
        transform: translate(0px, 0px) scale(var(--final-scale, 1)) rotate(calc(var(--final-rot-deg, 0) * 1deg));
    }
}

.item-jump-animation {
    animation: itemJumpIn 0.75s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}

/* Unified controls container below the board canvas wrap */
.board-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 8px;
    flex-shrink: 0;
    width: var(--wall-frame-width);
    max-width: calc(100% - 32px);
    margin: 0 auto;
    box-sizing: border-box;
    z-index: 99999;
}

/* Grouped Floating Actions container centered */
.board-actions-group {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

#screen-board.edit-active .board-actions-group {
    width: 100%;
    justify-content: space-between;
}

body.visitor-wall-mode .board-controls-bar,
body.visitor-wall-mode #layer-palette,
body.visitor-wall-mode #btn-open-items,
body.visitor-wall-mode #btn-open-pictures,
body.visitor-wall-mode #btn-open-text,
body.visitor-wall-mode #btn-open-folder,
.visitor-submit-mode .sheet-tab[data-tab="decor"],
.visitor-submit-mode .sheet-tab[data-tab="folder"],
.visitor-submit-mode #pane-decor,
.visitor-submit-mode #pane-folder {
    display: none !important;
}

body.visitor-wall-mode #board-profile-circle {
    cursor: default;
}

body.visitor-wall-mode .top-nav {
    display: none !important;
}

body.visitor-wall-mode .visitor-wall-header {
    display: grid !important;
}

body.visitor-wall-mode .board-visitor-frame,
body:not(.visitor-wall-mode) #screen-board:not(.edit-active) .board-visitor-frame {
    display: flex !important;
    flex-direction: column !important;
    width: min(var(--wall-frame-width), calc(100% - 36px)) !important;
    max-height: calc(100dvh - 96px) !important;
    margin: 6px auto 24px !important;
    background: #ffffff !important;
    border: 2px solid #cfc7d8 !important;
    border-radius: 18px !important;
    box-shadow: 0 0 24px rgba(84, 70, 100, 0.12), 0 10px 30px rgba(84, 70, 100, 0.14) !important;
    overflow: hidden !important;
}

body.visitor-wall-mode .board-canvas-wrap,
body:not(.visitor-wall-mode) #screen-board:not(.edit-active) .board-canvas-wrap {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

body.visitor-wall-mode #board-canvas,
body:not(.visitor-wall-mode) #screen-board:not(.edit-active) #board-canvas {
    width: 100% !important;
    aspect-ratio: 408 / 666 !important;
    height: auto !important;
    margin: 0 !important;
}

body:not(.visitor-wall-mode) #screen-board:not(.edit-active) .board-controls-bar {
    position: static !important;
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 14px 22px 18px !important;
    background: #f8f5fb !important;
    border-top: 1.5px solid #cfc7d8 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    z-index: 10 !important;
}

body:not(.visitor-wall-mode) #screen-board:not(.edit-active) .board-actions-group,
body:not(.visitor-wall-mode) #screen-board:not(.edit-active) #btn-share-wall {
    flex: 0 0 calc(50% - 8px) !important;
    width: calc(50% - 8px) !important;
    min-width: calc(50% - 8px) !important;
    max-width: calc(50% - 8px) !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

body:not(.visitor-wall-mode) #screen-board:not(.edit-active) #btn-share-wall {
    height: 52px !important;
    border-radius: 18px !important;
    background: #1f182b !important;
    border: 1px solid #36294a !important;
    color: #ffffff !important;
    font-family: var(--font-ui) !important;
    font-size: 1.08rem !important;
    font-weight: 600 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-shadow: 0 4px 14px rgba(31, 24, 43, 0.22) !important;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease !important;
}

body:not(.visitor-wall-mode) #screen-board:not(.edit-active) #btn-edit-board {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 52px !important;
    border-radius: 18px !important;
    background: #1f182b !important;
    border: 1px solid #36294a !important;
    color: #ffffff !important;
    font-family: var(--font-ui) !important;
    font-size: 1.08rem !important;
    font-weight: 600 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    box-shadow: 0 4px 14px rgba(31, 24, 43, 0.22) !important;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease !important;
}

body:not(.visitor-wall-mode) #screen-board:not(.edit-active) #btn-share-wall:hover,
body:not(.visitor-wall-mode) #screen-board:not(.edit-active) #btn-edit-board:hover {
    background: #312645 !important;
    box-shadow: 0 6px 18px rgba(31, 24, 43, 0.3) !important;
    transform: translateY(-2px) !important;
}

body.visitor-wall-mode .board-dock {
    position: static !important;
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 14px 22px 18px !important;
    background: #f8f5fb !important;
    border-top: 1.5px solid #cfc7d8 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    z-index: 10 !important;
}

body.visitor-wall-mode .board-cta-label {
    display: block !important;
    font-family: var(--font-serif);
    font-size: 1.4rem !important;
    font-weight: 500;
    color: #111111;
    margin: 0 0 12px 0;
    text-align: center;
    width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

body.visitor-wall-mode .action-row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: var(--wall-frame-width);
    gap: 16px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

body.visitor-wall-mode #btn-open-question,
body.visitor-wall-mode #btn-open-music {
    flex: 0 0 calc(50% - 8px) !important;
    width: calc(50% - 8px) !important;
    min-width: calc(50% - 8px) !important;
    max-width: calc(50% - 8px) !important;
    height: 52px !important;
    border-radius: 18px !important;
    background: #1f182b !important;
    border: 1px solid #36294a !important;
    color: #ffffff !important;
    font-family: var(--font-ui);
    font-size: 1.08rem !important;
    font-weight: 600 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    box-shadow: 0 4px 14px rgba(31, 24, 43, 0.22) !important;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease !important;
}

body.visitor-wall-mode #btn-open-question:hover,
body.visitor-wall-mode #btn-open-music:hover {
    background: #312645 !important;
    box-shadow: 0 6px 18px rgba(31, 24, 43, 0.3) !important;
    transform: translateY(-2px) !important;
}

body.visitor-wall-mode #btn-open-question:active,
body.visitor-wall-mode #btn-open-music:active {
    transform: scale(0.97) !important;
}

body.visitor-wall-mode #btn-open-question .action-btn-label,
body.visitor-wall-mode #btn-open-music .action-btn-label {
    display: inline !important;
}

.visitor-submit-mode .sheet-tabs {
    grid-template-columns: repeat(2, 1fr);
}

.owner-direct-tool-mode .sheet-panel > .sheet-tabs,
.owner-direct-tool-mode #decor-subtabs {
    display: none !important;
}

.visitor-auth-panel {
    padding: 14px 22px 26px;
    text-align: center;
}

.visitor-auth-panel h2 {
    margin: 8px 0 8px;
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 400;
    line-height: 1;
}

.visitor-auth-panel p {
    max-width: 300px;
    margin: 0 auto 18px;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.86rem;
    line-height: 1.35;
}

.visitor-google-signin {
    margin-top: 0;
}

.visitor-auth-cancel {
    width: 100%;
    margin-top: 10px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

/* Profile picture expand overlay specific styles */
.profile-expand-content {
    position: relative;
    z-index: 501;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.3);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.popout-overlay:not(.hidden) .profile-expand-content {
    transform: scale(1);
    opacity: 1;
}

.profile-expand-circle-ring {
    width: 260px;
    height: 260px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 5px solid transparent;
    background: white;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.profile-expand-circle-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Item expand overlay specific styles */
.item-expand-content-wrap {
    position: relative;
    z-index: 501;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transform: scale(0.3);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.popout-overlay:not(.hidden) .item-expand-content-wrap {
    transform: scale(1);
    opacity: 1;
}

.expanded-item-card {
    width: min(88vw, 420px);
    max-height: min(78vh, 640px);
    box-sizing: border-box;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

.expanded-picture-card {
    width: min(calc(100vw - 64px), 340px);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.expanded-picture-card img {
    width: 100%;
    max-height: calc(min(78vh, 640px) - 68px);
    object-fit: contain;
    border-radius: 8px;
    display: block;
    background: #f8fafc;
}

.expanded-picture-caption {
    width: 100%;
    text-align: center;
    font-family: var(--font-hand), monospace;
    font-size: clamp(1rem, 3.5vw, 1.35rem);
    line-height: 1.1;
    color: #111827;
    overflow-wrap: anywhere;
}

.expanded-qa-card {
    width: min(calc(100vw - 64px), 340px);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(12px, 3vh, 20px);
    background: #fdfbf7;
}

.expanded-qa-question,
.expanded-qa-answer {
    box-sizing: border-box;
    width: 100%;
    max-height: calc((min(78vh, 640px) - 72px) / 2);
    overflow: hidden;
    border-radius: 10px;
    padding: clamp(12px, 3vw, 18px);
    font-family: var(--font-serif), serif;
    line-height: 1.22;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.expanded-qa-question {
    align-self: flex-start;
    font-size: clamp(1.05rem, 4.5vw, 1.55rem);
    font-weight: 700;
    color: #374151;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.expanded-qa-answer {
    align-self: flex-end;
    font-size: clamp(1.1rem, 4.8vw, 1.7rem);
    color: #111827;
    border: 1.5px dashed #cbd5e1;
}

.expanded-qa-question.pink { background: var(--sticky-pink); }
.expanded-qa-question.yellow { background: var(--sticky-yellow); }
.expanded-qa-question.blue { background: var(--sticky-blue); }
.expanded-qa-question.green { background: var(--sticky-green); }
.expanded-qa-question.lavender { background: #dfccfb; }
.expanded-qa-answer.default { background: #ffffff; }
.expanded-qa-answer.pink { background: var(--sticky-pink); border-color: #ffb8d2; }
.expanded-qa-answer.yellow { background: var(--sticky-yellow); border-color: #fff280; }
.expanded-qa-answer.blue { background: var(--sticky-blue); border-color: #a3e0ff; }
.expanded-qa-answer.green { background: var(--sticky-green); border-color: #adffaa; }
.expanded-qa-answer.lavender { background: #dfccfb; border-color: #ccb0ff; }

.expanded-music-card {
    width: min(88vw, 360px);
    max-height: min(78vh, 620px);
    padding: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.expanded-music-card .item-cd-wrap,
.expanded-music-card .item-music-note {
    transform: none !important;
    width: 100%;
    max-width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
}

.expanded-music-card .item-vinyl-player {
    width: min(35vw, 120px);
    height: min(35vw, 120px);
    margin: 0;
    flex-shrink: 0;
    display: block;
}


.expanded-music-card .item-cd-song-title,
.expanded-music-card .item-cd-sender-note,
.expanded-music-card .item-cd-reply-bubble,
.expanded-music-card .music-note-title {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere;
}

.expanded-music-card .item-cd-song-title {
    font-size: clamp(0.95rem, 4vw, 1.25rem) !important;
    text-align: left !important;
}

.expanded-music-card .item-cd-wrap a,
.expanded-music-card .item-music-note a {
    width: fit-content !important;
    max-width: 100% !important;
    box-sizing: border-box;
    display: inline-flex !important;
    justify-content: flex-start;
    white-space: normal !important;
    text-align: left;
    line-height: 1.15;
}

.expanded-music-card .item-cd-wrap a span,
.popout-cd-content .item-cd-wrap a span {
    white-space: normal;
    overflow-wrap: anywhere;
}

.item-expand-content-wrap .board-item {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    pointer-events: auto !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
}

.item-expand-content-wrap .board-item.item-cd-wrap {
    box-shadow: none !important;
    background: transparent !important;
}

.item-expand-content-wrap .board-item.item-cd-wrap .item-vinyl-player {
    filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.35));
}

/* ─── Expand Overlay Share Bar ─── */
.expanded-share-bar {
    display: flex;
    justify-content: center;
    animation: shareBarFadeIn 0.3s ease 0.15s both;
}

@keyframes shareBarFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.btn-expand-share {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #374151;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-expand-share:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.btn-expand-share:active {
    transform: scale(0.95);
}

.btn-expand-share svg {
    flex-shrink: 0;
}
