@font-face{font-family:"Story Anton";src:url("fonts/Anton-Regular.ttf") format("truetype");font-weight:400;font-style:normal;font-display:swap}
:root{--bg:#111216;--panel:#1b1d23;--panel2:#252830;--text:#f5f5f7;--muted:#b3b6c2;--border:#343740;--accent:#a78bfa;--nav-h:80px}
html,body{height:100%;background:var(--bg);overscroll-behavior:none}
body{font-family:Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:var(--text)}
button{font-family:inherit;font-size:14px;cursor:pointer}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.app{width:100%;max-width:1200px;height:100dvh;margin:auto;padding:0 16px calc(84px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:8px;overflow:hidden}
.topbar{height:auto;min-height:64px;padding:max(8px,env(safe-area-inset-top)) 0 8px;display:flex;justify-content:space-between;align-items:center;flex-shrink:0}
.brand{display:flex;align-items:baseline;gap:6px;background:none;border:0;padding:8px 0;color:var(--text);font-size:18px;font-weight:750;min-height:44px;letter-spacing:-.5px}.brand span{font-size:12px;font-weight:500;color:var(--muted);letter-spacing:0}
.accent-button{min-height:44px;padding:0 16px;border:0;border-radius:12px;background:var(--accent);color:#191326;font-weight:750}
.preview-card,.preview-card.story-mode{position:static;flex:1;min-height:0;display:flex;flex-direction:column;border:0;background:none;border-radius:0;box-shadow:none;overflow:visible}
.story-preview{display:flex;flex:1;min-height:0;padding:0;background:none}.story-workbench{display:flex;width:100%;min-height:0;flex:1;padding:0;gap:0}.story-canvas-column{border:0;background:none;flex:1;min-height:0}.story-stage-wrap{min-height:0;height:100%;padding:8px 0;overflow:visible}
.story-stage{height:100%;width:auto;max-width:100%;max-height:100%;aspect-ratio:9/16;flex:none;border-radius:8px;background-color:#24262d;background-image:linear-gradient(45deg,#292b33 25%,transparent 25%),linear-gradient(-45deg,#292b33 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#292b33 75%),linear-gradient(-45deg,transparent 75%,#292b33 75%);background-size:16px 16px;background-position:0 0,0 8px,8px -8px,-8px 0;box-shadow:0 0 0 1px #383a43}
.story-empty{color:#b3b6c2;gap:12px;padding:16px}.story-empty strong{font-size:18px;color:var(--text);line-height:1.2}.story-empty>span:not(.empty-symbol){font-size:13px;line-height:1.5}.empty-symbol{font-size:38px;color:#bca8f9;font-weight:600;letter-spacing:-2px}.story-empty button{pointer-events:auto;min-height:44px;background:#e9e1ff;color:#281a44;border:0;border-radius:10px;padding:8px 12px;font-weight:700}
.story-safe{opacity:.4}.story-layer [data-edit-handle],.story-layer [data-visual-handle]{display:none!important}.story-layer.selected{outline-color:#c7b6ff}.story-rotate-handle,.story-resize-handle{color:#24202c;background:#ede7ff}
#selectionTools{min-height:48px;display:flex;justify-content:center;gap:8px;padding:4px 0;flex-shrink:0}#selectionTools button{min-height:44px;padding:0 16px;border:0;border-radius:10px;background:#252830;color:#f5f5f7;font-size:14px;font-weight:600}#selectionTools #moreSelected{padding:0;width:44px;display:grid;place-items:center}
.bottom-nav{position:fixed;inset:auto 0 0;transform:none;width:100%;max-width:none;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;border:0;border-top:1px solid #30333b;border-radius:0;background:#1b1d23;padding:8px 12px max(10px,env(safe-area-inset-bottom));height:auto;z-index:90;box-shadow:none}
.bottom-nav button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;min-height:56px;width:100%;padding:4px;border:0;border-radius:10px;background:transparent;color:#dedde6;font-size:14px;font-weight:500}.bottom-nav #storyAddBtn{color:#c2adff;background:#30283f}.bottom-nav svg{display:block}
#status{font-size:12px;line-height:1.4;background:none;color:#b3b6c2;flex-shrink:0;max-height:44px;overflow:auto}#status:not(:empty){padding:4px 0}
.story-dialog-open{position:static}.story-dialog-host{padding:0;place-items:end center}.story-dialog-backdrop{background:#05060b80}
.design-sheet,.story-quick-panel,.story-text-edit-panel{position:relative;z-index:1;width:100%;max-width:600px;max-height:78%;min-height:0;margin:0;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;border:1px solid #3a3c46;border-bottom:0;border-radius:22px 22px 0 0;background:#1b1d23;color:#f5f5f7;padding:20px 16px max(20px,env(safe-area-inset-bottom));box-shadow:0 -16px 60px #0003}
.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;margin-bottom:18px}.sheet-head h2{font-size:20px;margin:0 0 6px;letter-spacing:-.4px}.sheet-head p,.sheet-hint{font-size:13px;color:#b3b6c2;line-height:1.5;margin:0}.sheet-head button,.story-dialog-close{width:44px;height:44px;min-width:44px;border:0;border-radius:50%;background:#2b2e37;font-size:26px;color:var(--text)}.sheet-head>div{padding-top:6px}
.sheet-content{display:flex;flex-direction:column;gap:10px}.sheet-content>button,.story-selection-actions button{width:100%;min-height:48px;border:1px solid #3b3e49;border-radius:12px;background:#282b34;color:var(--text);padding:12px 16px;font-size:15px;text-align:left;font-weight:600}
#exportPanel #downloadBtn{background:var(--accent);color:#211634;border:0;margin:0}#exportPanel #exportStoryBtn{background:#282b34;color:var(--text)}#exportPanel .sheet-content{padding-bottom:8px}.danger-lite,.danger-btn,#projectPanel button:not([data-close-sheet]){color:#ff9caa!important}
.story-selection-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}#itemVisibility{margin-top:0}.appearance-tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;background:#111216;border-radius:12px;padding:4px;margin-bottom:16px}.appearance-tabs button{min-height:40px;border:0;border-radius:9px;background:none;color:#b3b6c2;font-weight:650}.appearance-tabs button[aria-selected=true]{background:#343040;color:#e0d4ff}
.story-quick-header strong,.story-text-edit-head strong{font-size:20px}.story-quick-color,.story-quick-field{font-size:14px}.story-quick-field select{background:#252830}.story-quick-range .label{font-size:14px;text-transform:none;color:#bfc1cc}.story-quick-range input[type=range]{height:44px;accent-color:#a78bfa}.value-pill{display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:600;background:#292c34;color:#eee;min-height:32px}.story-quick-toggle-group button{font-size:14px;font-weight:600;background:#292c34}.story-quick-toggle-group button.active{background:#d5c5ff;color:#25183b}#openAdvanced{width:100%;min-height:48px;border:1px solid #494250;border-radius:10px;background:#292633;color:#e0d4ff;font-size:14px}
body[data-dialog=visual] .app{padding-bottom:0;height:42dvh}body[data-dialog=visual] #selectionTools,body[data-dialog=visual] #status{display:none}body[data-dialog=visual] .story-dialog-backdrop{background:transparent}body[data-dialog=visual] #storyQuickPanel{height:58%;max-height:58%;}body[data-dialog=visual] .topbar{min-height:56px}
.story-text-edit-input{margin-top:12px;min-height:112px;background:#111216;border:1px solid #4b465a;font-size:17px;font-weight:500;line-height:1.5}.story-text-edit-actions button{height:48px;font-size:15px;font-weight:650}.story-text-edit-actions .primary{background:#b49afa;color:#251935}.story-text-edit-head>span{display:none}
#presetGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;overflow:visible;padding:0}#presetGrid .preset{width:100%;min-width:0;min-height:112px;flex:none;padding:12px;border-radius:14px;background:#252830;border:2px solid transparent;position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center}#presetGrid .preset canvas{display:block;width:100%;height:56px;object-fit:contain}#presetGrid .preset-name{display:block!important;font-size:14px;color:#dedde6;margin-top:6px;font-weight:600}#presetGrid .preset.active{border-color:#b69aff;background:#302a40}#presetGrid .preset.active:after{content:'✓';position:absolute;top:4px;right:8px;color:#cab5ff;font-size:16px}.preset-state,.preset-meta{display:none!important}
#storyEmotePanel{height:78%}.story-emote-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.story-emote-grid .emote-btn{padding:12px;border:0;background:#282b34;border-radius:14px;min-height:64px;aspect-ratio:1}.story-emote-grid img{width:36px;height:36px}.story-quick-subline{font-size:14px}
#layersPanel{height:70%;display:flex;flex-direction:column}#layersPanel>.sheet-content{min-height:0;flex:1}#layerList{display:flex;flex-direction:column;overflow:auto;min-height:0;max-height:none;gap:8px;scroll-snap-type:none;padding:0}.layer-row{flex:none;min-width:0;width:100%;min-height:72px;display:flex;border:1px solid transparent;background:#252830;border-radius:12px;padding:6px;gap:4px}.layer-row.selected{border-color:#ae91fb;background:#302b3e}.layer-main{flex:1;min-width:0;display:flex;gap:8px;align-items:center;touch-action:pan-y!important;padding:0;border:0;background:none;color:#fff}.layer-copy strong{font-size:14px;max-width:100%;font-weight:600}.layer-copy small{font-size:12px}.layer-thumb-wrap{width:36px;height:40px;flex:0 0 36px}.layer-row-actions{display:flex;gap:0;align-items:center}.layer-row-actions button{height:44px;min-width:44px;width:auto;padding:0 6px;font-size:12px;border:0;background:none;color:#c4c0cf}.layer-row-actions [data-layer-grip]{font-size:24px;touch-action:none;color:#b6a0e6}.layer-row-actions [data-layer-menu]{font-size:24px}.layer-row-ghost{z-index:500;pointer-events:none}.layer-empty{min-height:100px;font-size:15px}
#advancedPanel details{border:1px solid #373a44;background:#252830;border-radius:12px}#advancedPanel summary{font-size:15px;padding:16px}#advancedPanel .label{font-size:13px}#advancedPanel input,#advancedPanel select{font-size:16px}#advancedPanel .details-body{padding:12px}.toast{bottom:calc(88px + env(safe-area-inset-bottom));max-width:90vw;font-size:13px;padding:10px 16px;pointer-events:none}body[data-dialog] .toast{bottom:auto;top:max(68px,env(safe-area-inset-top))}
#storageNotice,#updateNotice{margin:0;flex-shrink:0;font-size:13px;max-height:100px;overflow:auto}.sheet-content .wide-secondary{font-size:15px}
@media(max-height:650px){.topbar{min-height:56px}.app{padding-bottom:76px;gap:0}.bottom-nav{padding-top:4px;padding-bottom:4px}.bottom-nav button{min-height:56px}#selectionTools{min-height:44px;padding:0}#selectionTools button{min-height:44px}.story-stage-wrap{padding:4px 0}.story-empty{gap:8px}.empty-symbol{display:none}.story-empty strong{font-size:15px}.story-empty>span:not(.empty-symbol){font-size:12px}#status{font-size:11px;max-height:32px}.design-sheet,.story-text-edit-panel,.story-quick-panel{padding:12px;max-height:88%}.sheet-head{margin-bottom:10px}body[data-dialog=visual] .app{height:32dvh}body[data-dialog=visual] #storyQuickPanel{height:68%;max-height:68%}}
@media(min-width:900px){.app{padding:12px 200px 16px 32px;max-width:1400px}.topbar{min-height:64px}.bottom-nav{left:auto;right:max(24px,calc((100vw - 1400px)/2 + 24px));top:110px;bottom:auto;width:152px;display:flex;flex-direction:column;border:1px solid #353740;border-radius:16px;padding:8px}.bottom-nav button{flex-direction:row;justify-content:flex-start;gap:12px;padding:12px;font-size:15px}#selectionTools{padding-top:12px}.story-stage{max-height:calc(100dvh - 190px)}.story-dialog-host{place-items:center end;padding:24px}.design-sheet,.story-quick-panel,.story-text-edit-panel{width:400px;max-width:400px;border:1px solid #3a3c46;border-radius:20px;max-height:90%;padding:24px}body[data-dialog=visual] .app{height:100dvh;padding-right:450px}body[data-dialog=visual] #storyQuickPanel{height:auto;max-height:90%}body[data-dialog=visual] .topbar{min-height:64px}body[data-dialog=visual] .story-stage{max-height:calc(100dvh - 120px)}#layersPanel{height:80%}.toast{bottom:24px}}
[hidden]{display:none!important}
#storyPreview:not([hidden]){display:flex!important}.story-workbench{height:100%}
#storyPreview{flex-direction:column}.story-workbench{height:auto}
#presetGrid .preset-meta{display:flex!important}.story-empty .empty-symbol{font-size:38px;font-weight:600;line-height:1}.preset-custom{display:none}

.dialog-feedback{font-size:14px;line-height:1.5;color:#ddd0ff;border-top:1px solid #494050;padding-top:12px;margin-bottom:0}
body[data-dialog=visual] .app{height:54dvh}body[data-dialog=visual] #storyQuickPanel{height:46%;max-height:46%}#exportPanel #exportStoryBtn{background:#282b34!important;color:#f5f5f7!important}#layersPanel{height:auto;max-height:70%}#layersPanel #layerList{max-height:calc(70dvh - 160px)}@media(max-height:650px){body[data-dialog=visual] .app{height:32dvh}body[data-dialog=visual] #storyQuickPanel{height:68%;max-height:68%}}@media(min-width:900px){body[data-dialog=visual] .app{height:100dvh}body[data-dialog=visual] #storyQuickPanel{height:auto;max-height:90%}}
/* v42: separate navigation from creation; permanent selection controls. */
.bottom-nav{grid-template-columns:repeat(5,minmax(0,1fr));gap:2px;padding-left:6px;padding-right:6px}
.bottom-nav button{font-size:14px}.bottom-nav #homeBtn{color:#d8c9ff;background:#30283f}.bottom-nav #storyAddBtn{background:transparent;color:#dedde6}
#selectionTools{position:fixed;left:0;right:0;bottom:var(--nav-size,76px);height:52px;min-height:52px;z-index:210;display:flex!important;align-items:center;justify-content:center;background:#111216;border-top:1px solid #2b2d35;padding:4px 12px}
#selectionTools button:disabled{opacity:.45;cursor:default}#selectionTools #editSelected{min-width:140px}#selectionTools #moreSelected{width:48px}
.app{padding-bottom:calc(var(--nav-size,76px) + 60px)}
.story-dialog-host{padding-bottom:calc(var(--nav-size,76px) + 52px)}
body[data-dialog=visual] .app{height:var(--available-preview,40dvh);padding-bottom:0}body[data-dialog=visual] #selectionTools{display:flex!important}
#itemPanel .story-selection-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px!important;width:100%}
#itemPanel .story-selection-actions button,#itemPanel .story-selection-actions button:nth-child(n){flex:none;min-width:0;max-width:none;width:100%;height:auto;min-height:52px;padding:12px;font-size:15px;line-height:1.35;white-space:normal;overflow-wrap:normal;text-align:left;box-sizing:border-box}
#itemPanel #appearanceSelected,#itemPanel #itemVisibility{width:100%;min-height:52px;font-size:15px;line-height:1.35;white-space:normal}
#itemPanel .sheet-content{gap:10px}
@media(max-height:650px){.app{padding-bottom:calc(var(--nav-size,64px) + 56px)}body[data-dialog=visual] .app{height:var(--available-preview,30dvh);padding-bottom:0}}
@media(min-width:900px){.bottom-nav{display:flex;padding:8px}.bottom-nav button{font-size:15px}#selectionTools{left:32px;right:200px;bottom:16px;width:auto;border:0;background:#111216}.app{padding-bottom:76px}.story-dialog-host{padding-bottom:76px}body[data-dialog=visual] .app{height:100dvh;padding-bottom:76px}}

/* Keep navigation above the panel backdrop. Text drafts still lock navigation with inert. */
.bottom-nav{z-index:210}

@media(min-width:900px){.story-dialog-host{padding-right:200px}}

/* Six clearly labelled destinations; each stays at least 48px wide at 320px. */
.bottom-nav{grid-template-columns:repeat(6,minmax(0,1fr));padding-left:3px;padding-right:3px;gap:0}
.bottom-nav button{font-size:12px;padding:3px 0;min-width:0}
#selectionTools{gap:8px}#selectionTools #editSelected{min-width:130px}#deleteSelected{color:#ff9baa;min-width:76px}
#textureGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
#textureGrid button{display:flex;flex-direction:column;gap:8px;min-height:100px;padding:10px;font-size:14px;text-align:left}
.texture-sample{width:100%;height:90px;overflow:hidden;border-radius:8px;background:linear-gradient(115deg,#555,#111 50%,#ddd 51%,#eee)}
.texture-sample img{width:100%;height:100%;object-fit:cover}
#textureControls{display:grid;gap:12px;padding:14px 0}#textureControls[hidden]{display:none}#textureControls input{width:100%;min-height:44px}#textureControls button{min-height:48px;font-size:14px}
@media(min-width:900px){.bottom-nav button{font-size:15px;padding:12px}}

#textureGrid button{background:#252830;border:1px solid #3a3d47;border-radius:12px;color:#f5f5f7;font-weight:500;cursor:pointer}#textureGrid button:focus-visible{outline:2px solid #b69aff;outline-offset:2px}
