/* BEAST EDITOR v0.4 - VN-inspired editing workflow; original styling and assets. */
:root{color-scheme:dark;--bg:#08090b;--panel:#121318;--card:#1e2127;--edge:#303039;--muted:#999daa;--cyan:#49c8e2;--yellow:#ffd542;--red:#ff5b70;--mint:#4ed1ae;--txt:#f7f7fa;--purple:#a77bda}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}html,body{margin:0;width:100%;height:100%;overflow:hidden;overscroll-behavior:none;background:var(--bg);color:var(--txt);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Arial,sans-serif;font-size:14px}button,input,select,textarea{font:inherit}button{border:0;background:transparent;color:inherit;cursor:pointer;touch-action:manipulation}button:active{opacity:.74}button:disabled{opacity:.3;cursor:default}svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}#app{height:100vh;height:100dvh;width:100%;display:flex;flex-direction:column;overflow:hidden;min-height:0;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)}
/* Header */
.app-header{height:50px;flex:0 0 50px;border-bottom:1px solid #24262d;display:flex;align-items:center;justify-content:space-between;padding:0 11px;background:#111216;gap:8px}.brand{display:flex;align-items:center;min-width:0;gap:8px}.go-back{margin-right:0}.brand-letter{font-size:25px;line-height:29px;font-weight:950;letter-spacing:-2.4px;white-space:nowrap;color:#eee}.brand-letter span{color:var(--yellow)}.brand-name{display:flex;flex-direction:column;gap:3px}.brand-name b{font-size:11px;letter-spacing:.9px;white-space:nowrap}.brand-name small{font-size:9px;letter-spacing:.8px;color:var(--muted);white-space:nowrap}.brand-name em{font-size:9px;color:var(--yellow);font-style:normal;letter-spacing:.5px;margin-left:4px}.header-actions{display:flex;align-items:center;gap:0;flex-shrink:0}.top-icon{height:34px;width:33px;display:grid;place-items:center;color:#d7d8df;padding:0}.top-icon svg{width:20px;height:20px}.top-icon.save svg{width:17px;height:17px}.export-btn{display:flex;align-items:center;gap:3px;height:32px;padding:0 10px;background:#e3f5ff;color:#0d141e;border-radius:7px;font-size:11px;font-weight:800;margin-left:4px}.export-btn svg{width:14px;height:14px;stroke-width:2.5}
/* Preview stays contained and never pushes whole app into a vertical scroll */
.preview-area{flex:1 1 auto;min-height:145px;display:flex;flex-direction:column;align-items:center;overflow:hidden;background:#07080b}.preview-title{height:33px;min-height:33px;display:flex;align-items:center;justify-content:space-between;width:100%;padding:0 13px;position:relative;color:#b6b8c1}.preview-title button{font-size:11px;color:#e2e5ec}.preview-title button:first-child{background:#1c1e23;border-radius:5px;padding:4px 9px;font-weight:650}.ratio-icon{font-size:14px;color:#b1c4c9}.chevron{padding-left:4px;color:#7b7c89}.preview-title-center{font-size:9px;letter-spacing:.9px;color:#727883;display:flex;align-items:center;gap:6px}.ready-dot{width:5px;height:5px;border-radius:100%;background:var(--mint);display:inline-block}.preview-title button svg{width:16px;height:16px}.preview-canvas-wrap{position:relative;flex:1;min-height:0;display:flex;align-items:center;justify-content:center;width:100%;overflow:hidden}#preview{display:block;height:100%;width:auto;max-height:100%;max-width:100%;aspect-ratio:9/16;object-fit:contain;background:#14171d;touch-action:none;box-shadow:0 0 0 1px #27282f,0 0 13px #0008}.canvas-guide{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);padding:5px 8px;border-radius:4px;white-space:nowrap;pointer-events:none;background:#0a0b0cb5;color:#dedee6;font-size:9px;letter-spacing:.4px;transition:opacity .2s;opacity:.65}.canvas-guide.inactive{opacity:0}.transport{display:grid;grid-template-columns:minmax(90px,1fr) auto minmax(28px,1fr);align-items:center;width:100%;min-height:45px;flex:0 0 45px;padding:0 14px;gap:4px;border-bottom:1px solid #191a20}.timecode{font-size:10px;font-variant-numeric:tabular-nums;white-space:nowrap;color:#d7d9e0;font-weight:650;letter-spacing:.2px}.transport-main{display:flex;align-items:center;gap:9px}.transport-main button{display:grid;place-items:center;color:#c8c9d3;width:27px;height:34px}.transport-main svg{width:19px;height:19px}.transport-main .play-btn{font-size:21px;color:#fff;width:39px;height:37px}.transport-add{justify-self:end;color:#dbdee6;background:#202127;border:1px solid #33353e;width:27px;height:27px;border-radius:7px;display:grid;place-items:center}.transport-add svg{width:16px;height:16px}
/* Timeline: top-to-bottom Audio, Text, Sticker, Video, Ruler like VN */
.timeline-area{flex:0 0 227px;height:227px;display:flex;flex-direction:column;background:#111217;border-top:1px solid #272931;border-bottom:1px solid #262932;min-height:0}.timeline-top{height:40px;min-height:40px;display:flex;align-items:center;justify-content:space-between;padding:3px 10px 3px 13px;gap:3px}.timeline-label{min-width:0}.timeline-label b{font-size:12px;font-weight:740;white-space:nowrap}.timeline-label small{font-size:10px;color:#9698a4;display:block;max-width:140px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px}.timeline-tools{display:flex;align-items:center;gap:3px}.timeline-tools>button{height:27px;min-width:26px;border-radius:5px;background:#24262d;border:1px solid #3b3d46;font-size:17px}.timeline-tools .scale-label{font-size:9px;color:#c5c7d0;font-variant-numeric:tabular-nums;min-width:48px;font-weight:600}.timeline-tools .tool-divider{height:18px;width:1px;background:#42434c;margin:0 2px}.timeline-tools .split-btn{background:#f6d443;color:#191818;padding:0 7px;border-color:#f6d443;display:flex;align-items:center;gap:3px;min-width:50px;font-size:10px;font-weight:850}.split-btn svg{width:15px;height:15px;stroke-width:2.3}
.timeline-shell{position:relative;flex:1;min-height:0;width:100%;overflow:hidden}.timeline-viewport{height:100%;width:100%;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:none;touch-action:pan-x;scroll-behavior:auto}.timeline-viewport::-webkit-scrollbar,.tool-content::-webkit-scrollbar,.tool-nav::-webkit-scrollbar{display:none}.timeline-content{height:100%;min-width:100%;position:relative;padding-top:0}.tl-track{height:31px;position:relative;border-bottom:1px solid #30313b;background:repeating-linear-gradient(90deg,#17191e,#17191e 38px,#181a21 39px)}.audio-track{height:31px}.text-track{height:29px}.sticker-track{height:29px}.video-track{height:62px;background:#1a1b21}.ruler{height:21px;position:relative;background:#131419;touch-action:pan-x}.tick{position:absolute;top:3px;height:9px;border-left:1px solid #71737f;color:#9497a1;font-size:9px;padding-left:3px;white-space:nowrap}.tick.sub{height:5px;top:5px;border-color:#494b53}.tl-clip{position:absolute;top:3px;height:calc(100% - 6px);border:1px solid #ffffff28;border-radius:3px;overflow:hidden;display:flex;align-items:center;justify-content:center;white-space:nowrap;user-select:none;-webkit-user-select:none;touch-action:none;box-shadow:0 1px 2px #0007}.tl-clip:active{filter:none}.tl-clip .clip-inner{display:flex;align-items:center;justify-content:center;gap:4px;padding:0 13px;font-size:10px;font-weight:700;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;pointer-events:none;z-index:2;text-shadow:0 1px 2px #000c}.tl-clip.video-c{background:#333a40;color:white}.tl-clip.video-c .clip-inner{position:absolute;bottom:4px;font-size:9px;left:12px;right:12px;background:#0008;border-radius:3px;min-height:15px;z-index:2}.thumb-repeat{position:absolute;inset:0;background-image:var(--clip-thumb,linear-gradient(90deg,#34383c,#434f5a));background-size:78px 100%;background-repeat:repeat-x;background-position:left center;filter:saturate(.9);opacity:.96;pointer-events:none}.tl-clip.text-c{background:#6d4aa0;color:#fff}.tl-clip.sticker-c{background:#9d535e;color:#fff}.tl-clip.audio-c{background:#2a637b;color:#fff}.audio-wave{position:absolute;inset:0;opacity:.55;pointer-events:none;background:repeating-linear-gradient(90deg,transparent 0px,transparent 6px,#c6f4edb3 7px,#c6f4edb3 9px,transparent 10px,transparent 13px);mask-image:linear-gradient(0deg,transparent 6%,black 24% 80%,transparent 95%)}.tl-clip.is-selected{outline:2px solid var(--yellow);outline-offset:-1px;box-shadow:0 0 0 1px #f8d749,z-index:30}.tl-clip.is-selected .clip-inner{color:#fff}.trim-handle{position:absolute;top:0;bottom:0;width:16px;background:var(--yellow);z-index:21;display:flex;align-items:center;justify-content:center;cursor:ew-resize;touch-action:none}.trim-handle::after{content:"";height:13px;border-left:2px solid #4a3b03;box-shadow:3px 0 0 #4a3b03}.trim-handle.left{left:0}.trim-handle.right{right:0}.tl-clip:not(.is-selected) .trim-handle{display:none}
.track-gutter{position:absolute;top:0;left:0;z-index:17;width:43px;background:#121318ee;box-shadow:2px 0 9px #0008;display:flex;flex-direction:column;border-right:1px solid #34353c}.track-gutter button{height:31px;border-bottom:1px solid #33353c;color:#c4c7d1;font-size:20px;font-weight:650;line-height:20px;position:relative}.track-gutter button:nth-child(2),.track-gutter button:nth-child(3){height:29px;font-size:17px}.track-gutter button:nth-child(4){height:62px;font-size:20px}.track-gutter button span{font-size:12px;color:var(--yellow);position:absolute;top:2px;right:5px}.fixed-playhead{pointer-events:none;position:absolute;z-index:25;top:0;bottom:0;left:50%;border-left:2px solid #fff;filter:drop-shadow(0 0 2px #000);transform:translateX(-1px)}.fixed-playhead span{pointer-events:auto;position:absolute;top:-2px;left:-8px;border-top:13px solid #fafafa;border-left:8px solid transparent;border-right:8px solid transparent;touch-action:none;cursor:ew-resize}.selection-info{height:23px;min-height:23px;display:flex;align-items:center;gap:7px;padding:0 11px;background:#16171b;color:#b1b4bc;font-size:10px;white-space:nowrap;overflow:hidden}.selection-info .selection-dot{width:6px;height:6px;border-radius:50%;background:#7f8289;flex:0 0 auto}.selection-info.has-selection .selection-dot{background:var(--yellow)}.selection-info span:nth-child(2){overflow:hidden;text-overflow:ellipsis}.selection-info span:last-child{margin-left:auto;color:var(--yellow);font-variant-numeric:tabular-nums}
/* Context first, horizontal tools second, category tabs at bottom — no page scroll */
.bottom-studio{flex:0 0 151px;height:151px;min-height:0;display:flex;flex-direction:column;background:#15161b}.tool-context{height:25px;min-height:25px;border-bottom:1px solid #272932;display:flex;align-items:center;justify-content:space-between;gap:7px;padding:0 13px;font-size:11px;font-weight:700}.tool-context small{font-size:9px;color:#838793;font-weight:450;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:66%}.tool-content{flex:1;min-height:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;touch-action:pan-x}.tool-strip{height:100%;display:flex;align-items:center;gap:6px;padding:5px 11px;min-width:max-content}.tool-btn{height:60px;min-width:55px;max-width:87px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;border-radius:7px;color:#e1e3e8;padding:4px 5px;text-align:center;font-size:9px;background:transparent;border:1px solid transparent}.tool-btn .b-icon{height:24px;line-height:23px;font-size:22px;color:#eff0f4}.tool-btn .b-icon svg{width:22px;height:22px}.tool-btn.strong{color:var(--yellow)}.tool-btn.strong .b-icon{color:var(--yellow)}.tool-btn.red .b-icon{color:#fb6d80}.tool-btn.gold .b-icon{color:var(--yellow)}.tool-btn.green .b-icon{color:var(--mint)}.tool-btn:disabled{opacity:.26}.preview-caption{font-size:10px;color:#9197a5;max-width:200px;line-height:1.45;padding:0 5px}.tool-nav{min-height:48px;height:48px;flex:0 0 48px;display:flex;align-items:stretch;gap:0;overflow-x:auto;overflow-y:hidden;touch-action:pan-x;scrollbar-width:none;border-top:1px solid #2a2b34;background:#101115}.tool-tab{flex:0 0 66px;min-width:66px;height:47px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:#8b8f9d;font-size:10px;border-top:2px solid transparent}.tool-tab .tab-icon{height:21px;line-height:21px;font-size:20px;font-weight:500}.tool-tab.active{color:var(--yellow);border-top-color:var(--yellow)}
/* modal sheets */
.import-progress{position:absolute;z-index:40;inset:13%;border-radius:13px;background:#1b1c21f2;border:1px solid #69636a;display:flex;flex-direction:column;gap:11px;align-items:center;justify-content:center;text-align:center;padding:18px}.import-progress strong{font-size:13px;max-width:100%;overflow-wrap:anywhere}.import-progress small{font-size:10px;color:#bdc2cd}.progress-line{width:100%;height:5px;background:#30323a;border-radius:4px;overflow:hidden}.progress-line span{display:block;width:42%;height:100%;background:var(--yellow);animation:indeterminate 1.2s ease-in-out infinite}@keyframes indeterminate{0%{transform:translateX(-120%)}100%{transform:translateX(250%)}}.spin{border:3px solid #555761;border-top-color:var(--yellow);width:29px;height:29px;border-radius:100%;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.sheet-backdrop{position:fixed;inset:0;background:#000b;z-index:70}.sheet{position:fixed;left:0;right:0;bottom:0;z-index:71;background:#1b1d22;border:1px solid #44454e;border-radius:16px 16px 0 0;max-height:79dvh;min-height:230px;padding-bottom:calc(9px + env(safe-area-inset-bottom));display:flex;flex-direction:column;box-shadow:0 -10px 44px #000c}.sheet-grip{width:40px;height:5px;background:#676871;border-radius:8px;margin:9px auto 4px}.sheet-heading{display:flex;align-items:center;justify-content:space-between;padding:5px 15px 11px;border-bottom:1px solid #3a3b43}.sheet-heading strong{font-size:16px}.sheet-close{font-size:19px;height:30px;width:30px}.sheet-body{overflow-y:auto;overscroll-behavior:contain;padding:13px 16px 30px;display:grid;gap:13px}.sheet-body label{display:grid;gap:7px;font-size:12px;color:#d6d7df}.sheet-body input:not([type=color]):not([type=range]),.sheet-body select,.sheet-body textarea{background:#101115;color:white;border:1px solid #565862;border-radius:7px;padding:10px 9px;min-height:40px;width:100%}.sheet-body input[type=color]{width:100%;height:40px;background:#26272d;border:1px solid #555;border-radius:5px}.sheet-body input[type=range]{accent-color:var(--yellow);width:100%}.setting-grid{display:grid;grid-template-columns:1fr 1fr;gap:11px}.sheet-actions{display:flex;gap:7px;flex-wrap:wrap}.sheet-actions button,.sheet-body .action{background:#333640;padding:10px 12px;border-radius:8px;font-size:12px;font-weight:700}.sheet-actions button.primary,.sheet-body .action.primary{background:var(--yellow);color:#151515}.sheet-actions button.warn{background:#75343e}.sheet-note{color:#aeb2bf;font-size:11px;line-height:1.5}.button-row{display:flex;gap:8px;align-items:center}.check-row{display:flex;gap:8px;align-items:center}.toast{position:fixed;z-index:110;left:50%;bottom:calc(20px + env(safe-area-inset-bottom));transform:translateX(-50%);max-width:calc(100vw - 30px);min-width:170px;background:#292e35;color:white;border:1px solid #77715b;border-radius:9px;padding:12px 16px;font-size:12px;text-align:center;opacity:0;pointer-events:none;transition:opacity .18s}.toast.show{opacity:1}.export-overlay{position:fixed;inset:0;z-index:90;background:#07090bed;display:grid;place-items:center;padding:25px}.export-card{width:min(360px,100%);border:1px solid #454751;background:#24262d;padding:27px 22px;border-radius:16px;display:flex;flex-direction:column;align-items:center;gap:12px;text-align:center}.export-card p{font-size:13px;color:#b8bdc9}.export-meter{height:7px;width:100%;background:#3c3d46;border-radius:8px;overflow:hidden}.export-meter>div{height:100%;width:0;background:var(--yellow);transition:width .13s}.flat.danger{background:#66323b;padding:10px 20px;border-radius:7px}.mini-pill{display:inline-block;background:#2f3238;border-radius:5px;padding:4px 8px;color:var(--yellow);font-size:10px}.export-overlay[hidden],.sheet[hidden],.sheet-backdrop[hidden],.import-progress[hidden],.drop-target[hidden]{display:none!important}input[type=file]{display:none!important}
/* responsive behavior: keep all controls on-screen on small iPhones */
@media(max-height:760px){.timeline-area{height:206px;flex-basis:206px}.bottom-studio{height:132px;flex-basis:132px}.preview-title{height:27px;min-height:27px}.transport{height:38px;min-height:38px;flex-basis:38px}.tool-context{height:21px;min-height:21px}.tool-nav{height:43px;flex-basis:43px;min-height:43px}.tool-tab{height:42px}.tool-btn{height:55px}.timeline-top{height:32px;min-height:32px}.tl-track.audio-track{height:28px}.tl-track.text-track,.tl-track.sticker-track{height:25px}.tl-track.video-track{height:56px}.ruler{height:20px}.track-gutter button{height:28px}.track-gutter button:nth-child(2),.track-gutter button:nth-child(3){height:25px}.track-gutter button:nth-child(4){height:56px}.selection-info{min-height:20px;height:20px}.timeline-label small{display:none}}
@media(max-height:630px){.app-header{height:43px;flex-basis:43px}.timeline-area{height:169px;flex-basis:169px}.bottom-studio{height:113px;flex-basis:113px}.preview-title-center{display:none}.preview-title{height:20px;min-height:20px}.transport{height:32px;min-height:32px;flex-basis:32px}.transport-main .play-btn{height:27px}.tool-context{height:18px;min-height:18px}.tool-nav{height:39px;flex-basis:39px;min-height:39px}.tool-tab{height:38px}.tool-strip{padding:1px 10px}.tool-btn{height:48px}.timeline-top{height:29px;min-height:29px}.selection-info{height:18px;min-height:18px}}
@media(min-width:780px){#app{max-width:1200px;margin:auto}.preview-area{min-height:260px}.timeline-area{height:259px;flex-basis:259px}.tl-track.video-track{height:83px}.track-gutter button:nth-child(4){height:83px}.bottom-studio{height:165px;flex-basis:165px}.tool-nav{justify-content:center}.tool-content{display:flex;justify-content:center}}
/* Expand preview without navigating away from the editing screen */
#app.preview-expanded .timeline-area,#app.preview-expanded .bottom-studio{display:none}#app.preview-expanded .preview-area{flex:1}#app.preview-expanded .canvas-guide{display:none}

.empty-import{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:9px;padding:20px 15px;background:#14181fd9;border:1px dashed #52606b;border-radius:9px;min-width:150px;color:white}.empty-import-icon{height:40px;width:40px;display:grid;place-items:center;background:#ffd542;color:#181a1e;font-size:30px;line-height:1;border-radius:9px}.empty-import strong{font-size:13px}.empty-import small{font-size:10px;color:#9fa7b5}.empty-import.invisible{display:none}.tl-clip.is-selected{box-shadow:0 0 0 1px #f8d749;z-index:30}

/* Swipe normally on clips to scrub; precision trim via yellow edges, reorder using grip. */
.tl-clip{touch-action:pan-x}.tl-clip .trim-handle{touch-action:none}.move-handle{display:none;position:absolute;top:1px;left:50%;transform:translateX(-50%);z-index:23;border-radius:0 0 5px 5px;background:var(--yellow);color:#25200d;font-weight:900;line-height:15px;width:29px;height:17px;text-align:center;font-size:17px;cursor:grab;touch-action:none}.tl-clip.is-selected .move-handle{display:block}.canvas-guide{display:none}

/* Real, lightly compressed thumbnail frames, sampled on local import */
.thumb-cells{position:absolute;inset:0;pointer-events:none;overflow:hidden}.thumb-cell{position:absolute;top:0;height:100%;background-repeat:no-repeat;background-position:center;background-size:cover;border-right:1px solid #15171a88}.tl-clip .trim-handle{width:20px}.move-handle{width:35px;height:20px;font-size:17px;line-height:19px}
