/* =========================================================
   ABFL STUDIO — CLEAN CONSOLIDATED STYLESHEET
   Sections:
   1. Variables / Reset
   2. Studio Shell / Header
   3. Layout
   4. Block Library
   5. Story Canvas
   6. Editor Blocks
   7. Inspector
   8. Floating Add Menu
   9. Floating Toolbar
   10. Gallery Block
   11. Preview Modal
   12. Notices / Autosave
   13. Responsive
========================================================= */

/* =========================================================
   1. VARIABLES / RESET
========================================================= */

:root{
    --studio-bg:#1f113f;
    --studio-bg-deep:#160b31;
    --studio-panel:#3a1f64;
    --studio-panel-soft:#4a2878;
    --studio-card:#4c2a7b;
    --studio-card-hover:#5c3491;
    --studio-canvas:#cba4ff;
    --studio-paper:#fbfaff;
    --studio-text:#171224;
    --studio-muted:#8f82a6;
    --studio-white:#ffffff;
    --studio-accent:#ff4fa0;
    --studio-accent-2:#ff6faf;
    --studio-accent-soft:rgba(255,79,160,.16);
    --studio-border:rgba(255,255,255,.14);
    --studio-shadow:0 24px 80px rgba(58,31,100,.35);
}

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

html,
body{
    height:100%;
}

body{
    font-family:Inter,sans-serif;
    background:var(--studio-bg);
    color:white;
    overflow:hidden;
}

button,
input{
    font-family:inherit;
}

button{
    border:none;
    cursor:pointer;
}

/* =========================================================
   2. STUDIO SHELL / HEADER
========================================================= */

.studio{
    height:100vh;
    display:flex;
    flex-direction:column;
    background:var(--studio-bg);
}

.studio-header{
    height:76px;
    flex:0 0 auto;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:24px;
    padding:0 36px;
    background:linear-gradient(90deg,#32185b,#5e2a7e,#32185b);
    border-bottom:1px solid rgba(255,255,255,.08);
    box-shadow:0 8px 30px rgba(0,0,0,.18);
    z-index:20;
}

.studio-brand{
    min-width:0;
    display:flex;
    align-items:center;
    gap:18px;
}

.studio-logo{
    height:38px;
    flex:0 0 auto;
}

.studio-title{
    min-width:0;
}

.studio-title h1{
    margin:0;
    color:white;
    font-size:22px;
    line-height:1.1;
    white-space:nowrap;
}

.studio-title span{
    display:block;
    margin-top:4px;
    color:#d9c8f5;
    font-size:13px;
    line-height:1.1;
    white-space:nowrap;
}

.studio-actions{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap:32px;
    min-width:0;
}

.toolbar-item{
    appearance:none;
    display:inline-flex;
    align-items:center;
    gap:8px;
    background:transparent;
    color:white;
    font-size:.95rem;
    font-weight:700;
    line-height:1;
    text-decoration:none;
    opacity:.95;
    transition:.2s ease;
}

.toolbar-item:hover{
    color:var(--studio-accent);
}

.toolbar-item svg{
    width:17px;
    height:17px;
    stroke-width:2.5;
}

.save-status{
    min-width:120px;
}

.save-status span{
    white-space:nowrap;
}

.preview-toggle{
    padding:0;
}

.publish-btn{
    min-height:48px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    padding:0 28px;
    border-radius:14px;
    background:linear-gradient(135deg,var(--studio-accent),var(--studio-accent-2));
    color:white;
    font-weight:800;
    box-shadow:0 10px 26px rgba(255,79,160,.28);
    transition:.2s ease;
}

.publish-btn:hover{
    transform:translateY(-2px);
    box-shadow:0 12px 25px rgba(255,77,157,.35);
}

.publish-btn svg{
    width:18px;
    height:18px;
}

/* =========================================================
   3. LAYOUT
========================================================= */

.studio-layout{
    flex:1;
    height:calc(100vh - 76px);
    display:grid;
    grid-template-columns:320px minmax(0,1fr) 360px;
    background:#241246;
    overflow:hidden;
    visibility:visible;
    opacity:1;
}

.block-sidebar,
.inspector{
    min-height:0;
    overflow:auto;
}

.canvas{
    min-width:0;
    min-height:0;
    overflow:auto;
    background:linear-gradient(180deg,#cfa9ff 0%,#b78af0 100%);
}

/* =========================================================
   4. BLOCK LIBRARY
========================================================= */

.block-sidebar{
    padding:32px 28px 40px;
    background:linear-gradient(180deg,#4a2678 0%,#8d4bb9 100%);
    border-right:1px solid rgba(255,255,255,.08);
}

.block-sidebar h2{
    margin-bottom:16px;
    color:white;
    font-size:27px;
    line-height:1.1;
}

.block-search{
    margin-bottom:28px;
}

.block-search input{
    width:100%;
    height:50px;
    padding:0 18px;
    border:1px solid rgba(255,255,255,.15);
    border-radius:14px;
    background:rgba(54,28,91,.84);
    color:white;
    font-size:15px;
    outline:none;
    transition:.2s ease;
}

.block-search input::placeholder{
    color:#d3b5f7;
}

.block-search input:focus{
    border-color:var(--studio-accent);
    box-shadow:0 0 0 4px rgba(255,79,160,.18);
}

.block-category{
    margin-bottom:28px;
}

.block-category h4{
    margin:0 0 10px;
    color:white;
    font-size:15px;
    font-weight:800;
    letter-spacing:.06em;
}

.block-card{
    position:relative;
    min-height:68px;
    display:flex;
    align-items:center;
    gap:14px;
    margin-bottom:10px;
    padding:14px;
    border:1px solid rgba(255,255,255,.08);
    border-radius:13px;
    background:rgba(62,32,105,.92);
    box-shadow:0 10px 26px rgba(0,0,0,.08);
    cursor:pointer;
    transition:.2s ease;
}

.block-card:hover{
    transform:translateX(4px);
    border-color:var(--studio-accent);
    background:#56308d;
}

.block-icon{
    width:36px;
    height:36px;
    flex:0 0 auto;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:10px;
    background:rgba(255,255,255,.12);
    font-size:19px;
}

.block-card strong{
    display:block;
    color:white;
    font-size:15px;
    line-height:1.2;
}

.block-card small{
    display:block;
    margin-top:3px;
    color:#d3c0eb;
    font-size:13px;
    line-height:1.3;
}

.block-card[data-block]{
    padding-right:72px;
}

.block-card[data-block="paragraph"],
.block-card[data-block="heading"],
.block-card[data-block="quote"],
.block-card[data-block="gallery"],
.block-card[data-block="image"],
.block-card[data-block="embed"],
.block-card[data-block="custom_embed"],
.block-card[data-block="character"],
.block-card[data-block="divider"],
.block-card[data-block="note"]{
    border-color:rgba(255,255,255,.12);
}

.block-card[data-block="paragraph"]::after,
.block-card[data-block="heading"]::after,
.block-card[data-block="quote"]::after,
.block-card[data-block="gallery"]::after,
.block-card[data-block="image"]::after,
.block-card[data-block="embed"]::after,
.block-card[data-block="custom_embed"]::after,
.block-card[data-block="character"]::after,
.block-card[data-block="divider"]::after,
.block-card[data-block="note"]::after{
    content:"READY";
    position:absolute;
    right:12px;
    top:50%;
    transform:translateY(-50%);
    padding:4px 8px;
    border-radius:999px;
    background:rgba(255,255,255,.15);
    color:white;
    font-size:10px;
    font-weight:800;
    letter-spacing:.04em;
}

.block-card[data-block="timeline"]::after,
.block-card[data-block="poll"]::after,
.block-card[data-block="playlist"]::after{
    content:"SOON";
    position:absolute;
    right:12px;
    top:50%;
    transform:translateY(-50%);
    padding:4px 8px;
    border-radius:999px;
    background:#caa7ff;
    color:#351c59;
    font-size:11px;
    font-weight:800;
    letter-spacing:.04em;
}

/* =========================================================
   5. STORY CANVAS
========================================================= */

.story-canvas{
    min-height:100%;
    padding:28px 28px 70px;
    display:flex;
    justify-content:center;
    background:radial-gradient(circle at top,#d8bbff 0%,#c49bf7 48%,#a874e3 100%);
    overflow:visible;
}

.story-stack{
    position:relative;
    width:min(920px,100%);
    min-height:1120px;
    margin:0 auto;
    padding:62px 74px 80px;
    border:1px solid rgba(255,255,255,.7);
    border-radius:18px;
    background:var(--studio-paper);
    color:var(--studio-text);
    box-shadow:var(--studio-shadow), inset 0 0 0 1px rgba(255,255,255,.8);
}

.story-title{
    margin:0;
    text-align:center;
    font-family:Georgia,"Times New Roman",serif;
    font-size:52px;
    line-height:1.05;
    color:var(--studio-text);
    outline:none;
    white-space:pre-wrap;
}

.story-subtitle{
    max-width:680px;
    margin:18px auto 54px;
    text-align:center;
    font-family:Georgia,"Times New Roman",serif;
    font-size:21px;
    line-height:1.55;
    color:var(--studio-muted);
    outline:none;
    white-space:pre-wrap;
}

#storyContent{
    width:100%;
    display:block;
}

#blockContainer{
    width:100%;
    max-width:760px;
    margin:0 auto;
}

.empty-page{
    max-width:430px;
    margin:130px auto 0;
    text-align:center;
    color:#999;
}

.empty-icon{
    color:#bf8cff;
    font-size:52px;
    line-height:1;
}

.empty-page h2{
    margin:18px 0 10px;
    color:#3d3748;
    font-size:32px;
}

.empty-page p{
    color:#8a8197;
    font-size:18px;
    line-height:1.6;
}

.add-block{
    position:sticky;
    bottom:34px;
    margin-left:auto;
    transform:translateX(44px);
    width:66px;
    height:66px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:50%;
    background:linear-gradient(135deg,var(--studio-accent),var(--studio-accent-2));
    color:white;
    font-size:36px;
    line-height:1;
    box-shadow:0 18px 38px rgba(0,0,0,.28);
    z-index:5;
    transition:.2s ease;
}

.add-block:hover{
    transform:translateX(44px) scale(1.06);
}

/* =========================================================
   6. EDITOR BLOCKS
========================================================= */

.editor-block{
    position:relative;
    width:100%;
    outline:none;
    white-space:pre-wrap;
    transition:border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .22s ease, opacity .22s ease;
}

.paragraph-block{
    min-height:auto;
    margin:22px 0;
    padding:24px 28px;
    border:2px solid transparent;
    border-radius:16px;
    background:transparent;
    color:var(--studio-text);
    font-family:Georgia,"Times New Roman",serif;
    font-size:21px;
    line-height:1.75;
}

.paragraph-block:hover{
    border-color:#efdfff;
}

.paragraph-block:focus{
    border-color:var(--studio-accent);
    background:white;
}

.heading-block{
    margin:48px 0 20px;
    color:var(--studio-text);
    font-family:Georgia,"Times New Roman",serif;
    font-size:42px;
    line-height:1.15;
    font-weight:700;
}

.quote-block{
    margin:28px 0;
    padding:24px 30px;
    border-left:5px solid #8b5cf6;
    border-radius:0 14px 14px 0;
    background:#f3edff;
    color:#2b2440;
    font-family:Georgia,"Times New Roman",serif;
    font-size:23px;
    line-height:1.65;
    font-style:italic;
}

.selected-block{
    border-color:var(--studio-accent) !important;
    box-shadow:0 0 0 4px rgba(255,79,160,.12), 0 12px 32px rgba(58,31,100,.12);
}

.selected-block::before{
    content:"⋮⋮";
    position:absolute;
    left:-40px;
    top:20px;
    color:#9b8ab9;
    font-family:Inter,sans-serif;
    font-size:22px;
    letter-spacing:-7px;
    cursor:grab;
    opacity:.8;
}

.selected-block:active::before{
    cursor:grabbing;
}

.selected-block::after{
    content:"•••";
    position:absolute;
    right:18px;
    top:12px;
    color:#2b2440;
    font-family:Inter,sans-serif;
    font-size:19px;
    letter-spacing:2px;
}

.block-just-moved{
    animation:blockLand .28s ease;
}

@keyframes blockLand{
    0%{
        transform:translateY(-8px);
        opacity:.65;
    }

    100%{
        transform:translateY(0);
        opacity:1;
    }
}

.text-bold{
    font-weight:800;
}

.text-italic{
    font-style:italic;
}

.text-underline{
    text-decoration:underline;
}

/* =========================================================
   7. INSPECTOR
========================================================= */

.inspector{
    padding:32px 28px;
    background:linear-gradient(180deg,#3c1f67 0%,#8d4bb9 100%);
    border-left:1px solid rgba(255,255,255,.08);
}

.studio-inspector h2{
    margin-bottom:18px;
    color:white;
    font-size:27px;
    line-height:1.1;
}

.inspector-empty{
    margin-top:120px;
    text-align:center;
    color:#e5d7f7;
}

.inspector-empty h3{
    margin:16px 0 6px;
    font-size:22px;
}

.inspector-empty p{
    max-width:250px;
    margin:0 auto;
    color:#dac5f2;
    line-height:1.45;
}

.inspector-icon,
.inspector-icon svg{
    width:54px;
    height:54px;
    margin:0 auto 14px;
}

.inspector-panel{
    display:flex;
    flex-direction:column;
    gap:24px;
    padding-top:4px;
}

.inspector-tabs{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    margin-bottom:8px;
    border-bottom:1px solid rgba(255,255,255,.13);
}

.inspector-tab{
    padding:0 0 14px;
    border-bottom:3px solid transparent;
    background:transparent;
    color:#d8c8ef;
    font-weight:700;
}

.inspector-tab.active{
    color:white;
    border-bottom-color:var(--studio-accent);
}

.selected-summary{
    display:flex;
    align-items:center;
    gap:16px;
    margin-top:4px;
    padding-bottom:22px;
    border-bottom:1px solid rgba(255,255,255,.12);
}

.selected-icon{
    width:58px;
    height:58px;
    flex:0 0 auto;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:16px;
    background:rgba(255,255,255,.14);
}

.selected-icon svg{
    width:28px;
    height:28px;
}

.selected-summary h3{
    margin:0 0 4px;
    color:white;
    font-size:21px;
}

.selected-summary p{
    margin:0;
    color:#d8c8ef;
    line-height:1.35;
}

.inspector-section{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.inspector-section label{
    color:white;
    font-size:15px;
    font-weight:800;
}

.text-style-row,
.align-buttons{
    display:flex;
    overflow:hidden;
    border:1px solid rgba(255,255,255,.16);
    border-radius:12px;
}

.text-style-row button,
.align-buttons button{
    width:46px;
    height:44px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-right:1px solid rgba(255,255,255,.12);
    background:rgba(69,36,115,.72);
    color:white;
    font-weight:800;
    transition:.2s ease;
}

.text-style-row button:last-child,
.align-buttons button:last-child{
    border-right:none;
}

.text-style-row button:hover,
.align-buttons button:hover{
    background:#6a3aa1;
}

.align-buttons svg{
    width:20px;
    height:20px;
}

.active-tool{
    background:var(--studio-accent) !important;
    color:white !important;
    box-shadow:0 8px 18px rgba(255,79,160,.3);
}

.range-row{
    display:grid;
    grid-template-columns:auto 1fr auto;
    align-items:center;
    gap:10px;
    color:#d8c8ef;
    font-size:12px;
}

.range-row input{
    accent-color:var(--studio-accent);
}

.move-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
}

.move-btn,
.duplicate-btn,
.delete-btn{
    min-height:46px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    border-radius:13px;
    font-weight:800;
    transition:.2s ease;
}

.move-btn{
    border:1px solid rgba(255,255,255,.16);
    background:rgba(69,36,115,.72);
    color:white;
}

.move-btn:hover{
    border-color:var(--studio-accent);
    background:#6a3aa1;
}

.duplicate-btn{
    min-height:48px;
    border:2px solid var(--studio-accent);
    background:transparent;
    color:white;
}

.delete-btn{
    min-height:48px;
    border:2px solid var(--studio-accent);
    background:rgba(120,19,70,.18);
    color:#ff8fbd;
}

.move-btn svg,
.duplicate-btn svg,
.delete-btn svg{
    width:18px;
    height:18px;
}

/* =========================================================
   8. FLOATING ADD MENU
========================================================= */

.block-menu{
    position:fixed;
    right:430px;
    bottom:120px;
    width:320px;
    padding:18px;
    border:1px solid rgba(255,255,255,.14);
    border-radius:22px;
    background:#3a1f64;
    box-shadow:0 24px 70px rgba(0,0,0,.35);
    opacity:0;
    pointer-events:none;
    transform:translateY(18px) scale(.96);
    transition:.22s ease;
    z-index:50;
}

.block-menu.open{
    opacity:1;
    pointer-events:auto;
    transform:translateY(0) scale(1);
}

.block-menu-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:14px;
}

.block-menu-header h3{
    margin:0;
    color:white;
    font-size:1.2rem;
}

.block-menu-header button{
    width:34px;
    height:34px;
    border-radius:50%;
    background:rgba(255,255,255,.08);
    color:white;
    font-size:22px;
    line-height:1;
}

.block-menu-options{
    display:flex;
    flex-direction:column;
    gap:10px;
}

.block-menu-options button{
    width:100%;
    display:flex;
    align-items:center;
    gap:14px;
    padding:14px;
    border:1px solid rgba(255,255,255,.08);
    border-radius:14px;
    background:var(--studio-card);
    color:white;
    text-align:left;
    transition:.2s ease;
}

.block-menu-options button:hover{
    transform:translateX(4px);
    border-color:var(--studio-accent);
    background:var(--studio-card-hover);
}

.block-menu-options span{
    width:38px;
    height:38px;
    flex:0 0 auto;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:12px;
    background:rgba(255,255,255,.12);
    font-size:20px;
}

.block-menu-options strong{
    display:block;
    color:white;
    font-size:.95rem;
}

.block-menu-options small{
    display:block;
    margin-top:3px;
    color:#d3c0eb;
    font-size:.82rem;
}

/* =========================================================
   9. FLOATING TOOLBAR
========================================================= */

.floating-toolbar{
    position:fixed;
    display:flex;
    align-items:center;
    gap:2px;
    padding:8px;
    border:1px solid rgba(30,20,50,.08);
    border-radius:14px;
    background:white;
    color:var(--studio-text);
    box-shadow:0 14px 36px rgba(35,20,60,.18);
    backdrop-filter:blur(12px);
    opacity:0;
    pointer-events:none;
    transform:translateX(-50%) translateY(8px);
    transition:.18s ease;
    z-index:200;
}

.floating-toolbar.show{
    opacity:1;
    pointer-events:auto;
    transform:translateX(-50%) translateY(0);
}

.floating-toolbar button{
    width:38px;
    height:34px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:9px;
    background:transparent;
    color:var(--studio-text);
    font-size:15px;
    font-weight:800;
    transition:.18s ease;
}

.floating-toolbar button:hover{
    transform:translateY(-1px);
    background:#f2eaff;
    color:var(--studio-accent);
}

.floating-toolbar svg{
    width:17px;
    height:17px;
}

/* =========================================================
   10. GALLERY BLOCK
========================================================= */

.gallery-block{
    width:100%;
    min-height:auto;
    margin:30px 0;
    padding:18px;
    border:2px solid transparent;
    border-radius:20px;
    background:#f7f1ff;
    outline:none;
}

.gallery-block:hover{
    border-color:#ead7ff;
}

.gallery-block.selected-block{
    border-color:var(--studio-accent) !important;
}

.gallery-block.has-images{
    padding:16px;
    background:#f8f3ff;
}

.gallery-upload-area{
    display:flex;
    align-items:center;
    gap:14px;
    flex-wrap:wrap;
}

.gallery-block.has-images .gallery-upload-area{
    justify-content:space-between;
    margin-bottom:14px;
}

.gallery-input{
    display:none;
}

.gallery-upload-btn{
    min-height:46px;
    display:flex;
    align-items:center;
    gap:10px;
    padding:0 18px;
    border-radius:14px;
    background:var(--studio-card);
    color:white;
    font-weight:800;
    transition:.2s ease;
}

.gallery-upload-btn:hover{
    background:var(--studio-card-hover);
}

.gallery-upload-btn svg{
    width:20px;
    height:20px;
}

.gallery-upload-area small{
    color:var(--studio-muted);
    font-size:14px;
}

.gallery-block.has-images .gallery-upload-area small{
    display:none;
}

.gallery-block.has-images .gallery-upload-btn{
    min-height:34px;
    padding:0 12px;
    border-radius:10px;
    font-size:12px;
}

.gallery-block.has-images .gallery-upload-btn span{
    font-size:0;
}

.gallery-block.has-images .gallery-upload-btn span::after{
    content:"Replace images";
    font-size:12px;
}

.gallery-grid{
    display:grid;
    gap:12px;
    margin-top:14px;
}

.gallery-block.has-images .gallery-grid{
    margin-top:10px;
}

.gallery-block[data-image-count="1"] .gallery-grid{
    grid-template-columns:1fr;
}

.gallery-block[data-image-count="2"] .gallery-grid,
.gallery-block[data-image-count="4"] .gallery-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
}

.gallery-block[data-image-count="3"] .gallery-grid{
    grid-template-columns:repeat(3,minmax(0,1fr));
}

.gallery-grid img{
    width:100%;
    height:auto;
    max-height:340px;
    object-fit:contain;
    object-position:center;
    display:block;
    border-radius:14px;
    background:white;
    box-shadow:0 12px 28px rgba(44,24,76,.16);
}

.gallery-block[data-image-count="4"] .gallery-grid img{
    max-height:260px;
}

/* =========================================================
   11. PREVIEW MODAL
========================================================= */

.preview-overlay{
    position:fixed;
    inset:0;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:40px;
    background:rgba(20,10,40,.72);
    backdrop-filter:blur(14px);
    opacity:0;
    pointer-events:none;
    transition:.25s ease;
    z-index:500;
}

.preview-overlay.open{
    opacity:1;
    pointer-events:auto;
}

.preview-modal{
    width:min(900px,100%);
    max-height:90vh;
    overflow:auto;
    border-radius:24px;
    background:#f9f6ff;
    color:var(--studio-text);
    box-shadow:0 30px 90px rgba(0,0,0,.42);
}

.preview-header{
    position:sticky;
    top:0;
    z-index:2;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:22px 28px;
    background:linear-gradient(90deg,#32185b,#5e2a7e);
    color:white;
}

.preview-label{
    display:block;
    margin-bottom:4px;
    color:#d8c8ef;
    font-size:.8rem;
    font-weight:800;
    letter-spacing:.08em;
    text-transform:uppercase;
}

.preview-header h2{
    margin:0;
    font-size:1.35rem;
}

.preview-close{
    width:42px;
    height:42px;
    border-radius:50%;
    background:rgba(255,255,255,.12);
    color:white;
    font-size:28px;
    line-height:1;
}

.preview-close:hover{
    background:var(--studio-accent);
}

.preview-page{
    width:min(760px,100%);
    margin:0 auto;
    padding:64px 54px 80px;
}

#previewStoryTitle{
    margin:0;
    text-align:center;
    font-family:Georgia,"Times New Roman",serif;
    font-size:52px;
    line-height:1.05;
    color:var(--studio-text);
}

#previewStorySubtitle{
    max-width:620px;
    margin:18px auto 56px;
    text-align:center;
    font-family:Georgia,"Times New Roman",serif;
    font-size:21px;
    line-height:1.55;
    color:var(--studio-muted);
    white-space:pre-wrap;
}

.preview-block{
    margin:28px 0;
    font-family:Georgia,"Times New Roman",serif;
    color:var(--studio-text);
    white-space:pre-wrap;
}

.preview-paragraph{
    font-size:22px;
    line-height:1.8;
}

.preview-heading{
    margin-top:52px;
    font-size:42px;
    line-height:1.15;
    font-weight:700;
}

.preview-quote{
    padding:24px 30px;
    border-left:5px solid #8b5cf6;
    border-radius:0 14px 14px 0;
    background:#f1eaff;
    font-size:23px;
    line-height:1.65;
    font-style:italic;
}

.preview-gallery{
    display:grid;
    gap:18px;
    margin:34px 0 44px;
}

.preview-gallery.image-count-1{
    grid-template-columns:1fr;
}

.preview-gallery.image-count-2,
.preview-gallery.image-count-4{
    grid-template-columns:repeat(2,minmax(0,1fr));
}

.preview-gallery.image-count-3{
    grid-template-columns:repeat(3,minmax(0,1fr));
}

.preview-gallery img{
    width:100%;
    height:auto;
    max-height:520px;
    object-fit:contain;
    object-position:center;
    display:block;
    border-radius:16px;
    background:white;
    box-shadow:0 18px 42px rgba(44,24,76,.18);
}

.preview-gallery.image-count-4 img{
    max-height:360px;
}

.preview-empty{
    max-width:420px;
    margin:80px auto 0;
    text-align:center;
    color:var(--studio-muted);
    font-size:20px;
    line-height:1.5;
}

/* =========================================================
   12. NOTICES / AUTOSAVE
========================================================= */

.studio-notice{
    position:fixed;
    left:50%;
    bottom:32px;
    transform:translateX(-50%) translateY(20px);
    padding:14px 20px;
    border-radius:999px;
    background:#251342;
    color:white;
    font-weight:800;
    box-shadow:0 18px 40px rgba(0,0,0,.28);
    opacity:0;
    pointer-events:none;
    transition:.25s ease;
    z-index:600;
}

.studio-notice.show{
    opacity:1;
    transform:translateX(-50%) translateY(0);
}

/* =========================================================
   13. RESPONSIVE
========================================================= */

@media (max-width:1200px){
    .studio-layout{
        grid-template-columns:280px minmax(0,1fr) 320px;
    }

    .story-stack{
        padding:52px 52px 72px;
    }

    .block-menu{
        right:360px;
    }
}

@media (max-width:980px){
    body{
        overflow:auto;
    }

    .studio{
        min-height:100vh;
        height:auto;
    }

    .studio-header{
        height:auto;
        min-height:76px;
        flex-wrap:wrap;
        padding:16px 20px;
    }

    .studio-actions{
        gap:16px;
        flex-wrap:wrap;
    }

    .studio-layout{
        height:auto;
        min-height:calc(100vh - 76px);
        grid-template-columns:1fr;
        overflow:visible;
    }

    .block-sidebar,
    .inspector{
        max-height:none;
    }

    .story-canvas{
        padding:22px;
    }

    .story-stack{
        padding:44px 28px 72px;
    }

    .story-title,
    #previewStoryTitle{
        font-size:42px;
    }

    .block-menu{
        right:24px;
        bottom:110px;
    }
}

@media (max-width:620px){
    .publish-btn{
        width:100%;
    }

    .story-stack{
        padding:36px 20px 64px;
    }

    .story-title,
    #previewStoryTitle{
        font-size:34px;
    }

    .story-subtitle,
    #previewStorySubtitle{
        font-size:18px;
    }

    .paragraph-block,
    .preview-paragraph{
        font-size:19px;
    }

    .heading-block,
    .preview-heading{
        font-size:32px;
    }

    .quote-block,
    .preview-quote{
        font-size:20px;
    }

    .selected-block::before,
    .selected-block::after{
        display:none;
    }

    .block-menu{
        left:20px;
        right:20px;
        width:auto;
    }

    .preview-overlay{
        padding:20px;
    }

    .preview-page{
        padding:46px 26px 64px;
    }

    .gallery-block[data-image-count="2"] .gallery-grid,
    .gallery-block[data-image-count="3"] .gallery-grid,
    .gallery-block[data-image-count="4"] .gallery-grid,
    .preview-gallery.image-count-2,
    .preview-gallery.image-count-3,
    .preview-gallery.image-count-4{
        grid-template-columns:1fr;
    }
}

/* =========================================================
   SHARE PREVIEW MODE
========================================================= */

.preview-actions{
    display:flex;
    align-items:center;
    gap:12px;
}

.share-mode-toggle{
    min-height:42px;
    display:flex;
    align-items:center;
    gap:8px;

    padding:0 16px;

    border-radius:999px;

    background:rgba(255,255,255,.12);
    color:white;

    font-weight:800;
}

.share-mode-toggle:hover{
    background:#ff4fa0;
}

.share-mode-toggle svg{
    width:17px;
    height:17px;
}

.share-card-brand,
.share-card-footer{
    display:none;
}

/* Share mode shell */

.preview-overlay.share-mode{
    background:
        radial-gradient(circle at top,#6c3aa0 0%,#21113f 52%,#12091f 100%);
}

.preview-overlay.share-mode .preview-modal{
    width:min(640px,100%);
    background:transparent;
    box-shadow:none;
    border-radius:0;
}

.preview-overlay.share-mode .preview-header{
    width:min(560px,100%);
    margin:0 auto 16px;

    border-radius:20px;

    background:rgba(37,19,66,.82);
    backdrop-filter:blur(16px);

    box-shadow:0 18px 45px rgba(0,0,0,.22);
}

.preview-overlay.share-mode .preview-page{
    width:min(560px,100%);
    min-height:700px;

    margin:0 auto;
    padding:42px 42px 38px;

    border-radius:32px;

    background:
        linear-gradient(180deg,#ffffff 0%,#fbf7ff 58%,#f0e3ff 100%);

    box-shadow:
        0 28px 90px rgba(0,0,0,.38),
        inset 0 0 0 1px rgba(255,255,255,.85);

    overflow:hidden;
}

.preview-overlay.share-mode .share-card-brand{
    display:flex;
    align-items:center;
    justify-content:space-between;

    margin-bottom:34px;
    padding-bottom:16px;

    border-bottom:1px solid rgba(80,50,120,.12);
}

.preview-overlay.share-mode .share-card-brand strong{
    color:#5e2a7e;
    font-size:24px;
    letter-spacing:.04em;
}

.preview-overlay.share-mode .share-card-brand span{
    padding:7px 12px;

    border-radius:999px;

    background:#f0e3ff;
    color:#7a4ca5;

    font-size:12px;
    font-weight:900;
    text-transform:uppercase;
    letter-spacing:.08em;
}

.preview-overlay.share-mode #previewStoryTitle{
    font-size:42px;
    line-height:1.05;
    text-align:left;
}

.preview-overlay.share-mode #previewStorySubtitle{
    margin:16px 0 30px;

    max-width:none;

    text-align:left;

    font-size:17px;
    line-height:1.5;
}

.preview-overlay.share-mode .preview-block{
    margin:22px 0;
}

.preview-overlay.share-mode .preview-paragraph{
    font-size:18px;
    line-height:1.65;
}

.preview-overlay.share-mode .preview-heading{
    margin-top:30px;
    font-size:30px;
}

.preview-overlay.share-mode .preview-quote{
    padding:18px 22px;

    font-size:18px;
    line-height:1.55;

    border-left-width:4px;
}

.preview-overlay.share-mode .preview-gallery{
    gap:12px;
    margin:26px 0 30px;
}

.preview-overlay.share-mode .preview-gallery img{
    max-height:260px;
    border-radius:18px;
}

.preview-overlay.share-mode .preview-gallery.image-count-4 img{
    max-height:190px;
}

.preview-overlay.share-mode .share-card-footer{
    display:flex;
    justify-content:center;

    margin-top:34px;
    padding-top:18px;

    border-top:1px solid rgba(80,50,120,.12);
}

.preview-overlay.share-mode .share-card-footer span{
    color:#8f82a6;
    font-size:13px;
    font-weight:800;
}

/* =========================================================
   STORY AUTHOR / HANDLE
========================================================= */

.story-author{
    display:block;

    max-width:680px;
    margin:12px auto 24px;

    text-align:center;

    color:#9c7bc4;

    font-size:15px;
    font-weight:800;
    line-height:1.2;
    letter-spacing:.02em;

    outline:none;
    white-space:nowrap;
}

.story-author:focus{
    color:#5e2a7e;
}

.story-author + .story-subtitle{
    margin-top:0;
}

/* Hidden in normal reader preview */
#previewStoryAuthor{
    display:none;

    margin:10px auto 24px;

    text-align:center;

    color:#7a4ca5;

    font-size:15px;
    font-weight:900;
    line-height:1.2;
    letter-spacing:.02em;
}

/* Visible in Share Preview Mode */
.preview-overlay.share-mode #previewStoryAuthor{
    display:block;

    margin:10px 0 18px;

    text-align:left;

    color:#7a4ca5;
}

/* In Share Mode: Title - Author - Subtitle */
.preview-overlay.share-mode #previewStoryTitle{
    margin-bottom:0;
}

.preview-overlay.share-mode #previewStorySubtitle{
    margin:0 0 30px;
}

/* =========================================================
   IMAGE LIGHTBOX
========================================================= */

.image-lightbox{
    position:fixed;
    inset:0;

    display:flex;
    align-items:center;
    justify-content:center;

    padding:36px;

    background:rgba(18,9,31,.86);
    backdrop-filter:blur(16px);

    opacity:0;
    pointer-events:none;

    transition:.22s ease;

    z-index:700;
}

.image-lightbox.open{
    opacity:1;
    pointer-events:auto;
}

.image-lightbox img{
    max-width:min(1000px,96vw);
    max-height:88vh;

    object-fit:contain;

    border-radius:20px;

    background:white;

    box-shadow:0 30px 90px rgba(0,0,0,.5);
}

.image-lightbox-close{
    position:fixed;
    top:24px;
    right:28px;

    width:46px;
    height:46px;

    display:flex;
    align-items:center;
    justify-content:center;

    border-radius:50%;

    background:rgba(255,255,255,.14);
    color:white;

    font-size:32px;
    line-height:1;

    transition:.2s ease;

    z-index:701;
}

.image-lightbox-close:hover{
    background:var(--studio-accent);
    transform:scale(1.05);
}

.preview-gallery img{
    cursor:zoom-in;
}

@media (max-width:620px){
    .image-lightbox{
        padding:18px;
    }

    .image-lightbox-close{
        top:16px;
        right:16px;
    }

    .image-lightbox img{
        max-width:96vw;
        max-height:82vh;
        border-radius:16px;
    }
}

/* =========================================================
   SHARE PREVIEW FORMAT CONTROLS
========================================================= */

.share-format-controls{
    display:none;
    align-items:center;
    gap:6px;

    padding:5px;

    border:1px solid rgba(255,255,255,.14);
    border-radius:999px;

    background:rgba(255,255,255,.1);
}

.preview-overlay.share-mode .share-format-controls{
    display:flex;
}

.share-format-btn{
    min-height:32px;
    padding:0 12px;

    border-radius:999px;

    background:transparent;
    color:#e9ddff;

    font-size:12px;
    font-weight:900;
    line-height:1;

    transition:.2s ease;
}

.share-format-btn:hover{
    background:rgba(255,255,255,.14);
    color:white;
}

.share-format-btn.active{
    background:white;
    color:#5e2a7e;
}

/* =========================================================
   SHARE PREVIEW SIZE MODES
========================================================= */

/* Default card */
.preview-overlay.share-mode.share-format-card .preview-page{
    width:min(560px,100%);
    min-height:700px;
}

/* Instagram / Threads / X portrait post */
.preview-overlay.share-mode.share-format-post .preview-page{
    width:min(560px,100%);
    aspect-ratio:4 / 5;
    min-height:auto;
    max-height:none;
}

/* Story / Reel / TikTok vertical promo */
.preview-overlay.share-mode.share-format-story .preview-page{
    width:min(430px,100%);
    aspect-ratio:9 / 16;
    min-height:auto;
    max-height:none;
    padding:32px 30px 28px;
}

/* Keep story format tighter */
.preview-overlay.share-mode.share-format-story .share-card-brand{
    margin-bottom:22px;
    padding-bottom:12px;
}

.preview-overlay.share-mode.share-format-story #previewStoryTitle{
    font-size:34px;
}

.preview-overlay.share-mode.share-format-story #previewStoryAuthor{
    font-size:13px;
    margin:8px 0 14px;
}

.preview-overlay.share-mode.share-format-story #previewStorySubtitle{
    font-size:14px;
    line-height:1.45;
    margin:0 0 22px;
}

.preview-overlay.share-mode.share-format-story .preview-paragraph{
    font-size:15px;
    line-height:1.55;
}

.preview-overlay.share-mode.share-format-story .preview-heading{
    font-size:22px;
}

.preview-overlay.share-mode.share-format-story .preview-gallery{
    gap:10px;
    margin:20px 0 22px;
}

.preview-overlay.share-mode.share-format-story .preview-gallery img{
    max-height:180px;
}

.preview-overlay.share-mode.share-format-story .preview-gallery.image-count-4 img{
    max-height:130px;
}

/* =========================================================
   SCREENSHOT MODE
========================================================= */

.preview-overlay.screenshot-mode .preview-header{
    display:none;
}

.preview-overlay.screenshot-mode .preview-modal{
    max-height:none;
    overflow:visible;
}

.preview-overlay.screenshot-mode .preview-page{
    position:relative;
}

/* Subtle watermark inside the screenshot card */
.preview-overlay.screenshot-mode .preview-page::after{
    content:"ABFL Studio";

    position:absolute;
    right:24px;
    bottom:18px;

    color:rgba(94,42,126,.28);

    font-size:12px;
    font-weight:900;
    letter-spacing:.08em;
    text-transform:uppercase;

    pointer-events:none;
}

/* =========================================================
   SCREENSHOT MODE BUTTON
========================================================= */

.screenshot-mode-toggle{
    min-height:42px;
    display:none;
    align-items:center;
    gap:8px;

    padding:0 16px;

    border-radius:999px;

    background:rgba(255,255,255,.12);
    color:white;

    font-weight:800;
}

.preview-overlay.share-mode .screenshot-mode-toggle{
    display:flex;
}

.screenshot-mode-toggle:hover{
    background:#ff4fa0;
}

.screenshot-mode-toggle.active{
    background:white;
    color:#5e2a7e;
}

.screenshot-mode-toggle svg{
    width:17px;
    height:17px;
}

/* =========================================================
   SCREENSHOT MODE — INTENTIONAL CROP / FADE
========================================================= */

.preview-overlay.screenshot-mode .preview-page{
    position:relative;
    overflow:hidden;
}

/* Fade out long content so the crop looks intentional */
.preview-overlay.screenshot-mode .preview-page::before{
    content:"";

    position:absolute;
    left:0;
    right:0;
    bottom:0;

    height:120px;

    background:linear-gradient(
        180deg,
        rgba(251,247,255,0),
        rgba(240,227,255,.96) 72%,
        rgba(240,227,255,1)
    );

    pointer-events:none;
    z-index:4;
}

/* Keep ABFL Studio watermark above the fade */
.preview-overlay.screenshot-mode .preview-page::after{
    z-index:5;
}

/* Make sure footer does not fight the watermark in screenshot mode */
.preview-overlay.screenshot-mode .share-card-footer{
    display:none;
}

/* Slightly tighten screenshot content */
.preview-overlay.screenshot-mode .preview-block{
    margin:18px 0;
}

.preview-overlay.screenshot-mode .preview-gallery{
    margin:20px 0 26px;
}

/* Keep the first visible gallery from becoming too tall */
.preview-overlay.screenshot-mode .preview-gallery img{
    max-height:210px;
}

.preview-overlay.screenshot-mode.share-format-story .preview-gallery img{
    max-height:150px;
}

/* =========================================================
   STORY SETTINGS MODAL
========================================================= */

.settings-toggle{
    padding:0;
}

.settings-overlay{
    position:fixed;
    inset:0;

    display:flex;
    align-items:center;
    justify-content:center;

    padding:40px;

    background:rgba(20,10,40,.72);
    backdrop-filter:blur(14px);

    opacity:0;
    pointer-events:none;

    transition:.25s ease;

    z-index:650;
}

.settings-overlay.open{
    opacity:1;
    pointer-events:auto;
}

.settings-modal{
    width:min(820px,100%);
    max-height:88vh;

    overflow:auto;

    border-radius:24px;

    background:#f9f6ff;
    color:var(--studio-text);

    box-shadow:0 30px 90px rgba(0,0,0,.42);
}

.settings-header{
    position:sticky;
    top:0;
    z-index:2;

    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:24px 28px;

    background:linear-gradient(90deg,#32185b,#5e2a7e);
    color:white;
}

.settings-label{
    display:block;

    margin-bottom:4px;

    color:#d8c8ef;

    font-size:.8rem;
    font-weight:800;
    letter-spacing:.08em;
    text-transform:uppercase;
}

.settings-header h2{
    margin:0;

    font-size:1.45rem;
}

.settings-close{
    width:42px;
    height:42px;

    display:flex;
    align-items:center;
    justify-content:center;

    border-radius:50%;

    background:rgba(255,255,255,.12);
    color:white;

    font-size:28px;
    line-height:1;

    transition:.2s ease;
}

.settings-close:hover{
    background:var(--studio-accent);
}

.settings-body{
    padding:32px;
}

.settings-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:18px;
}

.settings-field{
    display:flex;
    flex-direction:column;
    gap:8px;
}

.settings-field.full-width{
    margin-top:18px;
}

.settings-field span{
    color:#5e2a7e;

    font-size:13px;
    font-weight:900;
    letter-spacing:.04em;
    text-transform:uppercase;
}

.settings-field input,
.settings-field select,
.settings-field textarea{
    width:100%;

    border:2px solid #eadcff;
    border-radius:14px;

    background:white;
    color:var(--studio-text);

    font-size:15px;
    font-weight:600;

    outline:none;
    transition:.2s ease;
}

.settings-field input,
.settings-field select{
    height:48px;
    padding:0 14px;
}

.settings-field textarea{
    min-height:92px;
    padding:14px;

    resize:vertical;
    line-height:1.5;
}

.settings-field input:focus,
.settings-field select:focus,
.settings-field textarea:focus{
    border-color:var(--studio-accent);
    box-shadow:0 0 0 4px rgba(255,79,160,.14);
}

.settings-hint{
    margin-top:22px;

    color:#8f82a6;

    font-size:14px;
    line-height:1.55;
}

@media (max-width:620px){
    .settings-overlay{
        padding:20px;
    }

    .settings-grid{
        grid-template-columns:1fr;
    }

    .settings-body{
        padding:24px;
    }
}

/* =========================================================
   PREVIEW METADATA CHIPS
========================================================= */

.preview-meta-chips{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    gap:8px;

    max-width:620px;
    margin:-34px auto 48px;
}

.preview-meta-chips:empty{
    display:none;
}

.preview-meta-chip{
    display:inline-flex;
    align-items:center;

    min-height:30px;
    padding:0 12px;

    border-radius:999px;

    background:#f0e3ff;
    color:#6b3c93;

    font-size:12px;
    font-weight:900;
    line-height:1;
    letter-spacing:.02em;
}

.preview-meta-chip.is-rating{
    background:#ffe4f1;
    color:#9f2f68;
}

.preview-meta-chip.is-warning{
    background:#fff1d8;
    color:#8a5a12;
}

.preview-meta-chip.is-tag{
    background:#ede7ff;
    color:#6a4aaa;
}

/* Share mode alignment */

.preview-overlay.share-mode .preview-meta-chips{
    justify-content:flex-start;
    max-width:none;
    margin:-14px 0 30px;
}

.preview-overlay.share-mode .preview-meta-chip{
    min-height:28px;
    padding:0 10px;
    font-size:11px;
}

/* Story format needs tighter chips */

.preview-overlay.share-mode.share-format-story .preview-meta-chips{
    gap:6px;
    margin:-10px 0 22px;
}

.preview-overlay.share-mode.share-format-story .preview-meta-chip{
    min-height:24px;
    padding:0 8px;
    font-size:10px;
}

/* =========================================================
   PUBLISH REVIEW MODAL
========================================================= */

.publish-review-overlay{
    position:fixed;
    inset:0;

    display:flex;
    align-items:center;
    justify-content:center;

    padding:40px;

    background:rgba(20,10,40,.72);
    backdrop-filter:blur(14px);

    opacity:0;
    pointer-events:none;

    transition:.25s ease;

    z-index:680;
}

.publish-review-overlay.open{
    opacity:1;
    pointer-events:auto;
}

.publish-review-modal{
    width:min(760px,100%);
    max-height:88vh;

    display:flex;
    flex-direction:column;

    overflow:hidden;

    border-radius:24px;

    background:#f9f6ff;
    color:var(--studio-text);

    box-shadow:0 30px 90px rgba(0,0,0,.42);
}

.publish-review-header{
    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:24px 28px;

    background:linear-gradient(90deg,#32185b,#5e2a7e);
    color:white;
}

.publish-review-label{
    display:block;

    margin-bottom:4px;

    color:#d8c8ef;

    font-size:.8rem;
    font-weight:800;
    letter-spacing:.08em;
    text-transform:uppercase;
}

.publish-review-header h2{
    margin:0;

    font-size:1.45rem;
}

.publish-review-close{
    width:42px;
    height:42px;

    display:flex;
    align-items:center;
    justify-content:center;

    border-radius:50%;

    background:rgba(255,255,255,.12);
    color:white;

    font-size:28px;
    line-height:1;

    transition:.2s ease;
}

.publish-review-close:hover{
    background:var(--studio-accent);
}

.publish-review-body{
    padding:30px;
    overflow:auto;
}

.publish-review-intro{
    margin:0 0 22px;

    color:#8f82a6;

    font-size:15px;
    line-height:1.55;
}

.publish-review-summary{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
}

.publish-review-item{
    padding:16px;

    border:1px solid #eadcff;
    border-radius:16px;

    background:white;
}

.publish-review-item.full{
    grid-column:1 / -1;
}

.publish-review-item span{
    display:block;

    margin-bottom:6px;

    color:#6b3c93;

    font-size:11px;
    font-weight:900;
    letter-spacing:.08em;
    text-transform:uppercase;
}

.publish-review-item strong{
    display:block;

    color:#171224;

    font-size:16px;
    line-height:1.35;
}

.publish-review-chip-list{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.publish-review-chip{
    display:inline-flex;
    align-items:center;

    min-height:28px;
    padding:0 10px;

    border-radius:999px;

    background:#f0e3ff;
    color:#6b3c93;

    font-size:12px;
    font-weight:900;
}

.publish-review-warnings{
    margin-top:20px;
}

.publish-review-warning{
    padding:14px 16px;

    border-radius:14px;

    background:#fff1d8;
    color:#7a4c08;

    font-size:14px;
    font-weight:800;
    line-height:1.45;
}

.publish-review-warning + .publish-review-warning{
    margin-top:10px;
}

.publish-review-footer{
    display:flex;
    justify-content:flex-end;
    gap:12px;

    padding:20px 28px;

    border-top:1px solid #eadcff;

    background:#fff;
}

.publish-review-back,
.publish-review-confirm{
    min-height:44px;

    padding:0 18px;

    border-radius:13px;

    font-weight:900;

    transition:.2s ease;
}

.publish-review-back{
    background:#f0e3ff;
    color:#5e2a7e;
}

.publish-review-back:hover{
    background:#e5d3ff;
}

.publish-review-confirm{
    background:linear-gradient(135deg,var(--studio-accent),var(--studio-accent-2));
    color:white;

    box-shadow:0 10px 26px rgba(255,79,160,.28);
}

.publish-review-confirm:hover{
    transform:translateY(-1px);
}

@media (max-width:620px){
    .publish-review-overlay{
        padding:20px;
    }

    .publish-review-summary{
        grid-template-columns:1fr;
    }

    .publish-review-footer{
        flex-direction:column;
    }
}

/* =========================================================
   NEW STORY CONFIRMATION MODAL
========================================================= */

.new-story-overlay{
    position:fixed;
    inset:0;

    display:flex;
    align-items:center;
    justify-content:center;

    padding:40px;

    background:rgba(20,10,40,.72);
    backdrop-filter:blur(14px);

    opacity:0;
    pointer-events:none;

    transition:.25s ease;

    z-index:690;
}

.new-story-overlay.open{
    opacity:1;
    pointer-events:auto;
}

.new-story-modal{
    width:min(520px,100%);

    overflow:hidden;

    border-radius:24px;

    background:#f9f6ff;
    color:var(--studio-text);

    box-shadow:0 30px 90px rgba(0,0,0,.42);
}

.new-story-header{
    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:24px 28px;

    background:linear-gradient(90deg,#32185b,#5e2a7e);
    color:white;
}

.new-story-label{
    display:block;

    margin-bottom:4px;

    color:#d8c8ef;

    font-size:.8rem;
    font-weight:800;
    letter-spacing:.08em;
    text-transform:uppercase;
}

.new-story-header h2{
    margin:0;
    font-size:1.45rem;
}

.new-story-close{
    width:42px;
    height:42px;

    display:flex;
    align-items:center;
    justify-content:center;

    border-radius:50%;

    background:rgba(255,255,255,.12);
    color:white;

    font-size:28px;
    line-height:1;

    transition:.2s ease;
}

.new-story-close:hover{
    background:var(--studio-accent);
}

.new-story-body{
    padding:30px;
}

.new-story-body p{
    margin:0;

    color:#5f526f;

    font-size:16px;
    line-height:1.6;
}

.new-story-warning{
    margin-top:16px !important;

    color:#9f2f68 !important;

    font-weight:800;
}

.new-story-footer{
    display:flex;
    justify-content:flex-end;
    gap:12px;

    padding:20px 28px;

    border-top:1px solid #eadcff;

    background:white;
}

.new-story-cancel,
.new-story-confirm{
    min-height:44px;

    padding:0 18px;

    border-radius:13px;

    font-weight:900;

    transition:.2s ease;
}

.new-story-cancel{
    background:#f0e3ff;
    color:#5e2a7e;
}

.new-story-cancel:hover{
    background:#e5d3ff;
}

.new-story-confirm{
    background:#ff4fa0;
    color:white;

    box-shadow:0 10px 26px rgba(255,79,160,.28);
}

.new-story-confirm:hover{
    transform:translateY(-1px);
}

@media (max-width:620px){
    .new-story-overlay{
        padding:20px;
    }

    .new-story-footer{
        flex-direction:column;
    }
}

.media-embed-editor,
.custom-embed-editor {
    padding: 18px;
    border: 1px solid rgba(110, 70, 160, 0.2);
    border-radius: 16px;
    background: rgba(90, 45, 135, 0.05);
}

.media-embed-input-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.media-embed-url {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 10px;
}

.media-embed-preview,
.custom-embed-preview {
    margin-top: 16px;
}

.studio-media-frame,
.preview-media-frame {
    width: 100%;
    border: 0;
    border-radius: 16px;
}

.studio-media-frame.is-youtube,
.preview-media-frame.is-youtube {
    aspect-ratio: 16 / 9;
    min-height: 270px;
}

.studio-media-frame.is-spotify,
.preview-media-frame.is-spotify {
    height: 352px;
}

.custom-embed-editor textarea {
    width: 100%;
    min-height: 120px;
    margin: 6px 0 14px;
    padding: 12px;

    resize: vertical;

    font-family: monospace;
    font-size: 13px;

    border-radius: 10px;
}

.custom-embed-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.studio-custom-embed-frame,
.preview-custom-embed iframe {
    width: 100%;
    border: 0;
    border-radius: 16px;
    background: transparent;
}

.author-note-block {
    position: relative;

    padding: 42px 20px 20px;

    border: 1px solid rgba(119, 70, 170, 0.18);
    border-left: 4px solid #ff4fa3;

    border-radius: 16px;

    background:
        linear-gradient(
            135deg,
            rgba(255, 79, 163, 0.06),
            rgba(116, 65, 165, 0.08)
        );
}

.author-note-block::before {
    content: "AUTHOR'S NOTE";

    position: absolute;

    top: 15px;
    left: 20px;

    font-size: 10px;
    font-weight: 800;

    letter-spacing: 0.08em;

    color: #7a3fa1;
}


.divider-block {
    padding: 18px;

    border-radius: 14px;

    background:
        rgba(110, 70, 160, 0.04);
}

.divider-style-controls {
    display: flex;
    align-items: center;
    gap: 8px;

    margin-bottom: 18px;
}

.divider-style-controls span {
    margin-right: auto;

    font-size: 11px;
    font-weight: 700;
}

.divider-style-controls button {
    padding: 7px 10px;

    border-radius: 999px;

    cursor: pointer;
}

.divider-style-controls button.active-tool {
    background: #ff4fa3;
    color: white;
}


.divider-visual,
.preview-divider {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 30px;

    text-align: center;

    color: #7a3fa1;
}

.divider-visual.is-line::before,
.preview-divider.is-line::before {
    content: "";

    width: 70%;
    height: 1px;

    background:
        rgba(100, 64, 135, 0.35);
}

.divider-visual.is-dots,
.preview-divider.is-dots {
    font-size: 18px;
    letter-spacing: 6px;
}

.divider-visual.is-stars,
.preview-divider.is-stars {
    font-size: 18px;
    letter-spacing: 4px;
}


.preview-author-note {
    margin: 28px 0;
    padding: 18px 20px;

    border-left: 4px solid #ff4fa3;
    border-radius: 14px;

    background:
        rgba(122, 63, 161, 0.07);
}

.preview-author-note-label {
    display: block;

    margin-bottom: 8px;

    font-size: 10px;
    font-weight: 800;

    letter-spacing: 0.08em;

    color: #7a3fa1;
}

.preview-author-note p {
    margin: 0;
}

/* =========================================================
   CHARACTER BLOCK — STUDIO
   ========================================================= */

.character-block {
    padding: 18px;
}

.character-block-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 16px;
}

.character-block-heading > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.character-block-heading strong {
    font-size: 14px;
}

.character-block-heading span {
    font-size: 11px;
    opacity: 0.7;
}

.character-block-count {
    padding: 6px 10px;

    border-radius: 999px;

    background: rgba(122, 63, 161, 0.08);

    font-size: 11px;
    font-weight: 800;
}


/* IMPORTANT — fixed 2×2 grid */

.character-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 16px;
}

.character-editor-card {
    min-width: 0;

    padding: 14px;

    border:
        1px solid
        rgba(112, 68, 150, 0.18);

    border-radius: 16px;

    background:
        rgba(255, 255, 255, 0.7);
}

.character-card-number {
    margin-bottom: 10px;

    font-size: 9px;
    font-weight: 800;

    letter-spacing: 0.09em;

    color: #76449a;
}

.character-image-preview {
    position: relative;

    width: 100%;

    aspect-ratio: 4 / 3;

    overflow: hidden;

    border-radius: 12px;

    background:
        rgba(103, 65, 134, 0.07);
}

.character-image-preview img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: cover;
}

.character-image-empty {
    width: 100%;
    height: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 7px;

    color: #8d77a3;

    font-size: 11px;
}

.character-image-empty svg {
    width: 26px;
    height: 26px;
}

.character-image-input {
    display: none;
}

.character-image-actions {
    display: flex;
    gap: 8px;

    margin-top: 8px;
}

.character-image-actions button {
    padding: 7px 10px;

    border-radius: 999px;

    font-size: 10px;

    cursor: pointer;
}

.character-field {
    display: block;

    margin-top: 10px;
}

.character-field > span {
    display: block;

    margin-bottom: 4px;

    font-size: 9px;
    font-weight: 800;

    letter-spacing: 0.06em;

    text-transform: uppercase;

    color: #79658d;
}

.character-field input,
.character-field textarea {
    width: 100%;

    box-sizing: border-box;

    padding: 9px 10px;

    border:
        1px solid
        rgba(102, 69, 133, 0.16);

    border-radius: 9px;

    font: inherit;

    background: white;
}

.character-field textarea {
    min-height: 70px;

    resize: vertical;
}


/* Studio preview */

.preview-character-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 18px;

    margin: 30px 0;
}

.preview-character-card {
    overflow: hidden;

    border-radius: 18px;

    border:
        1px solid
        rgba(104, 65, 139, 0.14);

    background: white;
}

.preview-character-image {
    width: 100%;

    aspect-ratio: 4 / 3;

    object-fit: cover;

    display: block;
}

.preview-character-body {
    padding: 16px;
}

.preview-character-body h3 {
    margin: 0 0 4px;

    font-size: 20px;
}

.preview-character-role,
.preview-character-pronouns {
    display: block;

    margin-top: 3px;

    font-size: 11px;

    color: #76558d;
}

.preview-character-description {
    margin: 12px 0 0;

    font-size: 13px;
    line-height: 1.55;
}

.preview-character-traits {
    display: flex;
    flex-wrap: wrap;

    gap: 5px;

    margin-top: 12px;
}

.preview-character-traits span {
    padding: 4px 7px;

    border-radius: 999px;

    background: #f1e5fa;

    font-size: 9px;
    font-weight: 700;
}

.preview-character-body blockquote {
    margin: 14px 0 0;

    font-style: italic;
}

/* =========================================================
   MULTI-CHAPTER STUDIO
   ========================================================= */

.studio-chapter-strip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 18px;
    align-items: end;
    margin: 20px 0 8px;
    padding: 16px 18px;
    border: 1px solid rgba(113, 73, 151, 0.14);
    border-radius: 16px;
    background: rgba(122, 63, 161, 0.055);
}

.studio-chapter-strip-copy {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 110px;
}

.studio-chapter-strip-copy span {
    color: #5e2a7e;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.studio-chapter-strip-copy strong {
    width: max-content;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f0e3ff;
    color: #6b3c93;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.studio-chapter-title-field span {
    display: block;
    margin-bottom: 6px;
    color: #79658d;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.studio-chapter-title-field input {
    width: 100%;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid rgba(102, 69, 133, .16);
    border-radius: 11px;
    background: white;
    color: #171224;
    font: inherit;
    font-weight: 700;
    outline: none;
}

.studio-chapter-title-field input:focus {
    border-color: #ff4fa0;
    box-shadow: 0 0 0 4px rgba(255,79,160,.1);
}

.chapters-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: rgba(20, 10, 40, .76);
    backdrop-filter: blur(14px);
    opacity: 0;
    pointer-events: none;
    transition: .2s ease;
}

.chapters-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.chapters-modal {
    width: min(700px, 100%);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 26px;
    background: #f9f6ff;
    color: #171224;
    box-shadow: 0 30px 90px rgba(0,0,0,.4);
}

.chapters-header,
.chapters-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
}

.chapters-header {
    background: linear-gradient(90deg,#32185b,#5e2a7e);
    color: white;
}

.chapters-header span {
    display: block;
    margin-bottom: 4px;
    color: #d8c8ef;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.chapters-header h2 {
    margin: 0;
    font-size: 24px;
}

.chapters-close {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    color: white;
    font-size: 26px;
    cursor: pointer;
}

.chapters-body {
    padding: 22px 24px;
    overflow: auto;
}

.chapters-intro {
    margin: 0 0 16px;
    color: #6f617f;
    font-size: 14px;
    line-height: 1.5;
}

.chapters-list {
    display: grid;
    gap: 10px;
}

.chapter-manager-row {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 13px 14px;
    border: 1px solid #eadcff;
    border-radius: 16px;
    background: white;
    color: #171224;
    text-align: left;
    cursor: pointer;
}

.chapter-manager-row:hover,
.chapter-manager-row.current {
    border-color: #ff4fa0;
    background: #fff4fa;
}

.chapter-manager-number {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #f0e3ff;
    color: #6b3c93;
    font-weight: 900;
}

.chapter-manager-copy {
    min-width: 0;
}

.chapter-manager-copy strong,
.chapter-manager-copy span {
    display: block;
}

.chapter-manager-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.chapter-manager-copy span {
    margin-top: 3px;
    color: #8f82a6;
    font-size: 11px;
}

.chapter-manager-status {
    padding: 5px 8px;
    border-radius: 999px;
    background: #f0e3ff;
    color: #6b3c93;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
}

.chapter-manager-status.is-published {
    background: #e8f8ef;
    color: #277548;
}

.chapters-empty {
    padding: 18px;
    border: 1px dashed #d9c3ed;
    border-radius: 16px;
    color: #7a4ca5;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
}

.chapters-footer {
    justify-content: flex-end;
    border-top: 1px solid #eadcff;
    background: white;
}

.chapters-new {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: #ff4fa0;
    color: white;
    font-weight: 900;
    cursor: pointer;
}

.chapters-new:disabled {
    opacity: .5;
    cursor: not-allowed;
}

@media (max-width: 700px) {
    .studio-chapter-strip {
        grid-template-columns: 1fr;
    }

    .chapters-overlay {
        padding: 16px;
    }
}

.preview-chapter-heading {
    margin: 10px 0 24px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(94,42,126,.055);
}

.preview-chapter-heading span {
    display: block;
    margin-bottom: 5px;
    color: #7a4ca5;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.preview-chapter-heading h2 {
    margin: 0;
    color: #171224;
    font-family: Georgia,"Times New Roman",serif;
    font-size: 22px;
}
