/* --- BASE STYLES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@700;800;900&display=swap');

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #1f2937;
}

h1, h2, h3, h4, .modal__title, .field-label {
    font-family: 'Outfit', sans-serif;
}

/* Custom Scrollbar for Sidebar */
.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}
.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #fce7f3;
    border-radius: 10px;
}

/* --- EDITOR STYLES --- */
.editor-input {
    width: 100%;
    background: white;
    border: 1px solid #fee2e2;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 12px;
    color: #4b5563;
    outline: none;
    transition: border-color 0.2s;
}

.editor-input:focus {
    border-color: #f472b6;
}

.field-label {
    font-size: 10px;
    font-weight: 800;
    color: #9ca3af;
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
    letter-spacing: 0.05em;
}

/* --- PREVIEW WINDOW STYLES --- */
.bg-gingham {
    background-color: #fff5f7;
    background-image: radial-gradient(#ffcad4 1px, transparent 1px);
    background-size: 20px 20px;
}

.preview-window {
    width: 100%;
    max-width: 850px;
    aspect-ratio: 16 / 9;
    background: #fff6f9;
    border-radius: 32px;
    border: none;
    position: relative;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(236, 72, 153, 0.12);
    display: flex;
    flex-direction: column;
    background: linear-gradient(145deg, #fff8fb 0%, #fff2f7 45%, #fff7ef 100%);
}

.preview-decor {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.scene {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    padding: 40px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.scene.active {
    display: flex;
}

.preview-window::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 25%, rgba(251, 113, 133, 0.13), transparent 30%),
        radial-gradient(circle at 82% 70%, rgba(244, 114, 182, 0.1), transparent 34%),
        radial-gradient(circle at 55% 8%, rgba(253, 186, 116, 0.1), transparent 26%);
    z-index: 0;
}

.preview-window::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
    z-index: 0;
}

/* Scene transitions (cinematic, lightweight) */
.scene {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1), transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}
.scene.active {
    opacity: 1;
    transform: translateX(0);
}

.scene.exit {
    opacity: 0;
    transform: translateX(-20px);
}

/* Envelope open micro-animation */
.envelope-card {
    transition: transform 260ms ease, box-shadow 260ms ease;
}
.envelope-card:active {
    transform: scale(0.985);
}
.seal {
    transition: transform 260ms ease;
}
.envelope-card:hover .seal {
    transform: scale(1.05);
}

/* Toast (Save / Publish feedback) */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #fce7f3;
    color: #6b7280;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: 0 10px 30px rgba(244, 114, 182, 0.15);
    z-index: 9999;
}

/* Modal (Publish / QR) */
.modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
}
.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.35);
    backdrop-filter: blur(6px);
}
.modal__card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, calc(100% - 32px));
    background: rgba(255,255,255,0.96);
    border: 1px solid #fce7f3;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(236, 72, 153, 0.22);
    padding: 18px 18px 16px 18px;
}
.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.modal__title {
    margin: 0;
    font-size: 16px;
    font-weight: 950;
    color: #374151;
    letter-spacing: -0.01em;
}
.modal__close {
    border: 0;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    cursor: pointer;
    background: white;
    color: #f472b6;
    font-weight: 900;
    border: 1px solid #fce7f3;
}
.modal__sub {
    margin: 6px 0 14px 0;
    color: #6b7280;
    font-size: 12px;
    font-weight: 800;
}
.modal__row {
    margin-top: 14px;
    display: flex;
    gap: 10px;
}
.modal__input {
    flex: 1;
    border: 1px solid #fde2e8;
    background: white;
    border-radius: 14px;
    padding: 12px 12px;
    font-size: 12px;
    font-weight: 800;
    color: #4b5563;
}
.modal__btn {
    border: 1px solid #fde2e8;
    background: white;
    color: #ec4899;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 950;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.modal__btn--primary {
    background: linear-gradient(90deg, #ec4899, #fb7185);
    border-color: rgba(236, 72, 153, 0.25);
    color: white;
}
.modal__btn--ghost {
    background: rgba(236, 72, 153, 0.06);
}
.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}
.modal__hint {
    margin: 10px 0 0 0;
    font-size: 11px;
    color: #9ca3af;
    font-weight: 800;
    text-align: center;
}

/* Heart-style QR frame (keeps QR square inside for scanning) */
.qrHeart {
    position: relative;
    display: grid;
    place-items: center;
    padding: 18px;
    background: radial-gradient(circle at 30% 20%, rgba(236,72,153,.12), transparent 55%),
                radial-gradient(circle at 80% 80%, rgba(251,113,133,.12), transparent 55%),
                rgba(255,255,255,.8);
    border: 1px solid #fde2e8;
    border-radius: 24px;
}
.qrHeart__inner {
    width: 256px;
    height: 256px;
    background: white;
    border-radius: 22px;
    border: 10px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 40px rgba(236, 72, 153, 0.12);
    display: grid;
    place-items: center;
    position: relative;
}
.qrHeart__inner::before{
    content:"";
    position:absolute;
    inset:-18px;
    background: rgba(236,72,153,.08);
    clip-path: path("M 50 20 C 35 5, 10 10, 10 32 C 10 55, 30 70, 50 88 C 70 70, 90 55, 90 32 C 90 10, 65 5, 50 20 Z");
    transform: scale(1.35);
    border-radius: 24px;
    pointer-events:none;
}
.qrHeart__badge{
    position:absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display:grid;
    place-items:center;
    background: white;
    border: 1px solid #fde2e8;
    color: #ec4899;
    font-weight: 950;
    box-shadow: 0 10px 20px rgba(236,72,153,.10);
}


/* --- ELEMENT SPECIFIC STYLES --- */

/* Scene 1: Envelope */
.envelope-card {
    width: 280px;
    height: 180px;
    background: linear-gradient(135deg, #ffd5ea 0%, #fbcfe8 50%, #ffe4ef 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 16px 30px rgba(236, 72, 153, 0.18);
    animation: envelope-breathe 2.8s ease-in-out infinite;
}

.seal {
    width: 55px;
    height: 55px;
    background: #be185d;
    border-radius: 50%;
    border: 4px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    z-index: 10;
    box-shadow: 0 8px 16px rgba(190, 24, 93, 0.25);
}

#preview-hint1 {
    color: #db2777 !important;
    letter-spacing: 0.02em;
}

.scene-love-note {
    margin-top: 8px;
    font-size: 12px;
    color: #ec4899;
    font-style: italic;
    opacity: 0.86;
}

/* Scene 2: Letter */
.letter-paper {
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(244, 114, 182, 0.03) 0px,
            rgba(244, 114, 182, 0.03) 1px,
            transparent 1px,
            transparent 28px
        ),
        #fffdfa;
    padding: 40px;
    width: 90%;
    max-width: 550px;
    min-height: 200px;
    box-shadow: 0 14px 34px rgba(236, 72, 153, 0.11);
    border-radius: 2px;
    position: relative;
    font-family: 'Georgia', serif;
    line-height: 1.6;
    color: #4b5563;
    border: 1px solid #ffe4ef;
}

#preview-scene2Header {
    color: #db2777 !important;
    text-shadow: 0 4px 20px rgba(236, 72, 153, 0.2);
}

#preview-letter {
    font-size: 17px;
    line-height: 1.85;
    color: #374151;
}

#preview-finalText {
    font-family: "Brush Script MT", "Lucida Handwriting", cursive !important;
    font-weight: 400 !important;
    letter-spacing: 0.02em;
}

/* Scene 3: Polaroids */
.polaroid {
    background: white;
    padding: 12px 12px 35px 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 160px;
    position: absolute;
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1.1), opacity 0.3s ease, filter 0.3s ease;
    will-change: transform, opacity;
}

.polaroid:hover {
    transform: translate(-50%, -55%) rotate(0deg) scale(1.05) !important;
    z-index: 100 !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Keep absolute positioning predictable for "memories" layout */
#polaroid-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.polaroid:active {
    cursor: grabbing;
}

.polaroid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    pointer-events: none;
}

.polaroid-caption {
    font-size: 10px;
    text-align: center;
    margin-top: 10px;
    font-weight: 700;
    color: #9ca3af;
    font-family: 'Comic Sans MS', cursive;
}

/* Scene 4: Retro TV */
.retro-tv {
    background: #ffe4e9;
    padding: 24px;
    border-radius: 40px;
    border: 8px solid white;
    width: 340px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

/* Navigation & Utility */
.back-btn {
    position: absolute;
    bottom: 30px;
    left: 40px;
    background: white;
    color: #f472b6;
    padding: 10px 22px;
    border-radius: 99px;
    font-weight: 900;
    font-size: 12px;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(244, 114, 182, 0.2);
    z-index: 100;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.back-btn:hover {
    transform: translateY(-2px);
}

.continue-btn {
    position: absolute;
    bottom: 30px;
    left: 165px;
    background: white;
    color: #f472b6;
    padding: 10px 28px;
    border-radius: 99px;
    font-weight: 900;
    font-size: 12px;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(244, 114, 182, 0.2);
    z-index: 100;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.continue-btn:hover {
    transform: translateY(-2px);
}

.hidden {
    display: none !important;
}

/* Flower bloom transition (Scene 1 -> Scene 2) */
.flower-bloom-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 120;
}

.flower-bloom {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.15);
    opacity: 0;
    will-change: transform, opacity;
    animation: flower-bloom-out 1450ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes flower-bloom-out {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(0, 0) scale(0.15) rotate(0deg);
    }
    12% {
        opacity: 1;
    }
    74% {
        opacity: 0.95;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) scale(1.2) rotate(var(--rot));
    }
}

.flower-bloom--giant {
    font-size: 42px;
    animation: giant-flower-bloom 1550ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes giant-flower-bloom {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.05) rotate(0deg);
    }
    15% {
        opacity: 1;
    }
    70% {
        opacity: 0.95;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(9) rotate(40deg);
    }
}

/* Cute floating stickers across the full preview */
.preview-sticker {
    position: absolute;
    opacity: 0.82;
    filter: drop-shadow(0 4px 10px rgba(236, 72, 153, 0.16));
    animation: sticker-float 4.6s ease-in-out infinite;
}

.preview-sticker--tl {
    top: 14%;
    left: 13%;
    font-size: 38px;
}

.preview-sticker--tr {
    top: 18%;
    right: 13%;
    font-size: 36px;
    animation-delay: 0.6s;
}

.preview-sticker--bl {
    bottom: 16%;
    left: 10%;
    font-size: 34px;
    animation-delay: 1.1s;
}

.preview-sticker--br {
    bottom: 14%;
    right: 12%;
    font-size: 34px;
    animation-delay: 1.7s;
}

@keyframes sticker-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-6px) rotate(3deg); }
}

@keyframes envelope-breathe {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-3px) scale(1.012);
    }
}

/* =========================
   Template 2: Digital Diary
   ========================= */
.diary-theme .preview-window {
    max-width: 980px;
    aspect-ratio: 16 / 9;
}

.diary-scene {
    width: 100%;
    height: 100%;
    position: relative;
}

.bg-diary-gingham {
    background-color: #fff3f7;
    background-image:
        linear-gradient(90deg, rgba(236, 72, 153, 0.08) 50%, transparent 50%),
        linear-gradient(rgba(236, 72, 153, 0.08) 50%, transparent 50%);
    background-size: 48px 48px;
}

.bg-diary-dots {
    background-color: #fff6ef;
    background-image: radial-gradient(#f7d7c5 1.6px, transparent 1.6px);
    background-size: 14px 14px;
}

.bg-diary-stripes {
    background: repeating-linear-gradient(
        -35deg,
        #eef8e7 0 14px,
        #fff6ef 14px 28px
    );
}

.bg-diary-waves {
    background-color: #fff9f5;
    background-image:
        radial-gradient(circle at 0 100%, transparent 20px, rgba(240, 190, 190, 0.25) 21px, rgba(240, 190, 190, 0.25) 24px, transparent 25px),
        radial-gradient(circle at 100% 100%, transparent 20px, rgba(240, 190, 190, 0.25) 21px, rgba(240, 190, 190, 0.25) 24px, transparent 25px);
    background-size: 42px 24px;
    background-position: 0 0, 21px 0;
}

.diary-sticker {
    position: absolute;
    opacity: 0.86;
    font-size: 34px;
    filter: drop-shadow(0 4px 10px rgba(236, 72, 153, 0.14));
}

.diary-scene .particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.diary-scene .particle {
    position: absolute;
    color: #fbcfe8;
    opacity: 0.6;
    animation: float-particle var(--d) ease-in-out infinite;
    font-size: var(--s);
    left: var(--l);
    top: var(--t);
    filter: drop-shadow(0 3px 8px rgba(236, 72, 153, 0.2));
}

@keyframes float-particle {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    33% { transform: translate(30px, -50px) rotate(20deg); }
    66% { transform: translate(-20px, -100px) rotate(-20deg); }
}

.diary-lockbook {
    width: 285px;
    border-radius: 16px;
    background: linear-gradient(140deg, #d998a5 0%, #c98395 100%);
    box-shadow: 0 18px 36px rgba(160, 72, 94, 0.28);
    padding: 20px 16px 18px;
    position: relative;
    border: 1px solid rgba(255,255,255,0.42);
}

.diary-lockbook::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 28px;
    background: rgba(255, 245, 248, 0.75);
    border-radius: 16px 0 0 16px;
}

.diary-title {
    font-family: 'Outfit', sans-serif;
    font-size: 46px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 6px 20px rgba(60, 21, 33, 0.25);
}

.diary-subtitle {
    color: #fff4f7;
    font-size: 24px;
    margin-top: 8px;
    margin-bottom: 12px;
}

.diary-lock {
    font-size: 58px;
    margin-bottom: 10px;
}

.diary-pin-panel {
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    padding: 10px;
    box-shadow: inset 0 0 0 1px rgba(226, 154, 175, 0.35);
}

.diary-pin-digits {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.diary-digit {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid #eac0ce;
    background: #fff;
    color: #5b5154;
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.diary-digit.active {
    border-color: #ec4899;
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.18);
}

.diary-pin-hint {
    margin-top: 8px;
    color: #a16d7d;
    font-size: 13px;
}

.diary-envelope {
    width: 320px;
    height: 200px;
    border-radius: 10px;
    background: linear-gradient(145deg, #f7b6cf 0%, #f1a1bf 100%);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow: 0 16px 30px rgba(236, 72, 153, 0.2);
    overflow: visible;
    z-index: 6;
}

.diary-envelope::before,
.diary-envelope::after {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.diary-envelope::before {
    left: 0;
    right: 0;
    margin: auto;
    top: 0;
    border-width: 95px 160px 0 160px;
    border-color: #ffd9e8 transparent transparent transparent;
    transform-origin: top center;
    transition: transform 360ms ease;
    z-index: 5;
}

.diary-envelope::after {
    bottom: 0;
    left: 0;
    border-width: 0 160px 95px 160px;
    border-color: transparent transparent #f5b0c9 transparent;
    z-index: 4;
}

.diary-envelope-side {
    position: absolute;
    top: 0;
    width: 162px;
    height: 100%;
    z-index: 3;
    background: linear-gradient(155deg, #f8bfd4 0%, #f2a6c3 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.diary-envelope-side-left {
    left: 0;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.diary-envelope-side-right {
    right: 0;
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.diary-envelope .seal {
    position: absolute;
    left: 50%;
    top: 56%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    font-size: 20px;
    z-index: 6;
}

.diary-envelope.open::before {
    transform: rotateX(160deg);
}

.diary-envelope-paper-wrap {
    position: absolute;
    left: 50%;
    top: 10px;
    transform: translateX(-50%);
    width: 138px;
    height: 92px;
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.diary-envelope-paper {
    width: 100%;
    height: 100%;
    border-radius: 7px 7px 0 0;
    border: 1px solid rgba(205, 182, 167, 0.8);
    background:
      repeating-linear-gradient(
        to bottom,
        rgba(209, 140, 140, 0.26) 0px,
        rgba(209, 140, 140, 0.26) 1px,
        transparent 1px,
        transparent 18px
      ),
      #fffaf3;
    box-shadow: 0 8px 14px rgba(90, 58, 45, 0.14);
    font-family: "Brush Script MT", "Lucida Handwriting", cursive;
    color: #2b2b2b;
    text-align: center;
    padding-top: 6px;
    font-size: 14px;
    line-height: 1;
    transform: translateY(0);
    touch-action: none;
    cursor: grab;
}

.diary-envelope-paper.dragging {
    cursor: grabbing;
}

.diary-envelope.open .diary-envelope-side {
    opacity: 0.96;
}

.diary-envelope.open .diary-envelope-paper-wrap {
    opacity: 1;
    pointer-events: auto;
}

.letter-reveal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 20, 0.58);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
}

.letter-reveal-paper {
    width: 305px;
    height: 470px;
    border-radius: 8px;
    border: 1px solid rgba(205, 182, 167, 0.88);
    background:
      repeating-linear-gradient(
        to bottom,
        rgba(209, 140, 140, 0.3) 0px,
        rgba(209, 140, 140, 0.3) 1px,
        transparent 1px,
        transparent 32px
      ),
      #fffaf3;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.26);
    position: relative;
    padding: 24px 18px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(236, 72, 153, 0.45) rgba(255, 255, 255, 0.35);
}

.letter-reveal-paper::-webkit-scrollbar {
    width: 8px;
}

.letter-reveal-paper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
}

.letter-reveal-paper::-webkit-scrollbar-thumb {
    background: rgba(236, 72, 153, 0.45);
    border-radius: 999px;
}

.letter-tape {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 18px;
    border-radius: 2px;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(211, 211, 211, 0.7);
}

.letter-typed-text {
    font-family: "Brush Script MT", "Lucida Handwriting", cursive;
    color: #2b2b2b;
    font-size: 40px;
    line-height: 1.22;
    text-align: center;
    white-space: pre-wrap;
    padding-bottom: 16px;
}

.diary-tv {
    width: 260px;
    border-radius: 18px;
    border: 6px solid #ffd3e1;
    background: #ffe6f0;
    box-shadow: 0 16px 30px rgba(236, 72, 153, 0.18);
    padding: 12px;
    position: relative;
}

.diary-tv-screen {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #111;
    margin-bottom: 10px;
}

.diary-cassette {
    width: 250px;
    border-radius: 14px;
    background: #fff2f5;
    border: 3px solid #dba3b5;
    box-shadow: 0 14px 28px rgba(220, 120, 148, 0.2);
    padding: 16px;
}

/* =========================
   Template 3: Digital Paper Letter
   ========================= */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,500&family=Dancing+Script:wght@500;600;700&display=swap');

.paper-editor-body {
    background: #f8f6f2;
}

.paper-editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 16px 20px 20px;
    background: #faf9f7;
}

.paper-preview-chrome {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.paper-preview-chrome__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.paper-preview-chrome__badge {
    font-size: 10px;
    font-weight: 800;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 4px 10px;
    border-radius: 999px;
}

.paper-preview-chrome__actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.paper-preview-chrome__btn {
    font-size: 10px;
    font-weight: 700;
    color: #6b7280;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.paper-preview-chrome__btn:hover {
    background: #f9fafb;
}

.editor-tab {
    cursor: pointer;
    background: none;
    border: none;
    padding-bottom: 4px;
}

.editor-tab--active {
    color: #e11d48 !important;
    border-bottom: 2px solid #e11d48 !important;
}

.editor-tab-panel.hidden {
    display: none !important;
}

.paper-theme.preview-window {
    max-width: 100%;
    flex: 1;
    min-height: 0;
    aspect-ratio: auto;
    border-radius: 12px;
    border: 1px solid #e8e4dc;
    box-shadow: 0 12px 40px rgba(60, 50, 40, 0.08);
    background-color: #ebe4d6;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #f0ebe2 0%, #e8e0d4 100%);
}

.paper-theme.preview-window::before,
.paper-theme.preview-window::after {
    display: none;
}

.paper-draft-watermark {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    opacity: 0.14;
    background: repeating-linear-gradient(
        -32deg,
        transparent 0px,
        transparent 80px,
        rgba(120, 100, 80, 0.35) 80px,
        rgba(120, 100, 80, 0.35) 81px
    );
}

.paper-draft-watermark::after {
    content: "DRAFT · DRAFT · DRAFT · DRAFT · DRAFT · DRAFT";
    position: absolute;
    left: -20%;
    top: 40%;
    width: 140%;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 0.35em;
    color: #9a8b78;
    transform: rotate(-24deg);
    white-space: nowrap;
    text-align: center;
}

.paper-margin {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    border-left: 2px dashed rgba(140, 120, 100, 0.25);
    z-index: 3;
    pointer-events: none;
}

.paper-margin--left { left: 8%; }
.paper-margin--right { right: 8%; }

.paper-theme .scene {
    padding: 28px 12%;
    color: #2c3444;
}

/* Scene 1: Kraft envelope */
.paper-envelope-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.paper-envelope {
    width: 300px;
    height: 190px;
    background: linear-gradient(165deg, #d4b896 0%, #c4a67a 45%, #b8956a 100%);
    border-radius: 4px;
    position: relative;
    box-shadow: 0 18px 36px rgba(80, 60, 40, 0.22);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: envelope-breathe 2.8s ease-in-out infinite;
}

.paper-envelope::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 52%;
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%);
    clip-path: polygon(0 0, 50% 72%, 100% 0);
    pointer-events: none;
}

.paper-wax-seal {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #dc2626, #991b1b 55%, #7f1d1d);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.25), 0 8px 16px rgba(127, 29, 29, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.95);
    font-size: 22px;
    z-index: 2;
    margin-top: -8px;
}

.paper-envelope-label {
    margin-top: 12px;
    font-family: 'Dancing Script', cursive;
    font-size: 22px;
    font-weight: 600;
    color: #4a3728;
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.paper-open-prompt {
    font-size: 12px;
    color: #5c5348;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Scene 2: Letter on torn paper */
.paper-letter-scene {
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    padding: 8px 0;
}

.paper-letter-scene::-webkit-scrollbar { width: 5px; }
.paper-letter-scene::-webkit-scrollbar-thumb { background: #d4c4b0; border-radius: 4px; }

.paper-letter-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 4px;
}

.paper-letter-subtitle {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    font-style: italic;
    color: #3d4f66;
    margin-bottom: 20px;
}

.paper-letter-sheet {
    position: relative;
    background: #fffef9;
    padding: 28px 32px 32px 36px;
    max-width: 520px;
    margin: 0 auto;
    box-shadow: 0 12px 32px rgba(60, 50, 40, 0.12);
    border: 1px solid rgba(200, 180, 150, 0.4);
    clip-path: polygon(2% 0, 100% 0, 100% 100%, 0 100%, 0 8%);
}

.paper-letter-sheet::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 14px;
    background: linear-gradient(90deg, rgba(220,210,195,0.5), transparent);
    clip-path: polygon(0 0, 100% 4%, 100% 96%, 0 100%);
}

.paper-letter-greeting {
    font-family: 'Dancing Script', cursive;
    font-size: 1.5rem;
    color: #b91c1c;
    margin-bottom: 14px;
}

.paper-letter-body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.75;
    color: #374151;
    text-align: left;
    white-space: pre-wrap;
}

.paper-letter-sig {
    margin-top: 20px;
    font-family: 'Dancing Script', cursive;
    font-size: 1.35rem;
    color: #6b4423;
    text-align: right;
}

.paper-sticker {
    position: absolute;
    font-size: 28px;
    opacity: 0.9;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}

.paper-sticker--rose { top: 8%; left: 6%; font-size: 32px; }
.paper-sticker--flower { top: 10%; right: 8%; font-size: 30px; }
.paper-sticker--stars { bottom: 12%; left: 8%; font-size: 20px; letter-spacing: 4px; }

/* Scene 3: Polaroid collage */
.paper-photos-header {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 4px;
}

.paper-photos-sub {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.95rem;
    font-style: italic;
    color: #3d4f66;
    margin-bottom: 16px;
}

#polaroid-container.paper-polaroid-stage {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 280px;
}

.polaroid--paper {
    background: #fff;
    padding: 10px 10px 32px;
    box-shadow: 0 12px 28px rgba(40, 35, 30, 0.15);
    width: 150px;
}

.polaroid--paper::before,
.polaroid--paper::after {
    content: "";
    position: absolute;
    height: 18px;
    width: 44px;
    opacity: 0.55;
    z-index: 5;
}

.polaroid--paper::before {
    top: -6px;
    left: 20%;
    background: repeating-linear-gradient(90deg, #f9a8d4 0 4px, #fbcfe8 4px 8px);
    transform: rotate(-8deg);
}

.polaroid--paper::after {
    top: -4px;
    right: 15%;
    background: repeating-linear-gradient(90deg, #86efac 0 4px, #bbf7d0 4px 8px);
    transform: rotate(6deg);
}

.polaroid--paper .polaroid-caption {
    font-family: 'Dancing Script', cursive;
    font-size: 11px;
    color: #5c5348;
}

.paper-scene3-hint {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
    margin-top: auto;
    padding-bottom: 8px;
}

/* Scene 4: CRT video */
.paper-video-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 4px;
}

.paper-video-sub {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.95rem;
    font-style: italic;
    color: #3d4f66;
    margin-bottom: 16px;
}

.paper-crt {
    background: linear-gradient(180deg, #2d2a28 0%, #1a1816 100%);
    padding: 20px 24px 28px;
    border-radius: 16px;
    border: 6px solid #3d3835;
    width: min(380px, 90%);
    box-shadow: 0 16px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.08);
}

.paper-crt-screen {
    background: #0a0a0a;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/10;
    margin-bottom: 10px;
    border: 3px solid #111;
}

.paper-crt-brand {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 11px;
    letter-spacing: 0.2em;
    color: #d4cfc8;
    text-transform: uppercase;
}

.paper-crt-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
}

.paper-crt-controls button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f5f0e8;
    color: #5c5348;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.paper-crt-controls button.paper-crt-play {
    width: 44px;
    height: 44px;
    background: #fef3c7;
    color: #92400e;
}

/* Scene 5: Grid finale */
.paper-finale-scene {
    background-color: #f5f5f4;
    background-image:
        linear-gradient(rgba(180, 170, 160, 0.35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(180, 170, 160, 0.35) 1px, transparent 1px);
    background-size: 22px 22px;
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.paper-finale-scene::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: linear-gradient(180deg, #ebe4d6, #e0d6c8);
    opacity: 0.9;
}

.paper-finale-line {
    font-family: 'Dancing Script', cursive;
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: #991b1b;
    line-height: 1.1;
    text-shadow: 0 2px 0 rgba(255,255,255,0.5);
}

.paper-finale-sub {
    margin-top: 16px;
    font-family: 'Dancing Script', cursive;
    font-size: 1rem;
    color: #57534e;
    max-width: 320px;
}

.paper-finale-sticker {
    position: absolute;
    font-size: 26px;
    opacity: 0.85;
}

.paper-theme .back-btn,
.paper-theme .continue-btn {
    color: #6b4423;
    border: 1px solid #e8e0d4;
    box-shadow: 0 4px 12px rgba(80, 60, 40, 0.12);
}

/* Seal open transition */
.seal-open-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 120;
    background: radial-gradient(circle, rgba(255,250,240,0.9) 0%, transparent 70%);
    opacity: 0;
    animation: seal-flash 900ms ease forwards;
}

@keyframes seal-flash {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}