:root{--bg:#10111f;--panel:#181a2c;--panel2:#222436;--line:rgba(255,255,255,.12);--text:#f8fafc;--muted:#a9b0c3;--primary:#7c5cff;--primary2:#00d68f;--danger:#ff5c7a;--shadow:0 24px 70px rgba(0,0,0,.35)}*{box-sizing:border-box}body{margin:0;background:radial-gradient(circle at 25% 0,#2b2358 0,#10111f 45%,#080912 100%);color:var(--text);font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;overflow:hidden}button,input,select{font:inherit}button{cursor:pointer}.app-shell{height:100vh;display:grid;grid-template-columns:300px minmax(0,1fr) 360px}.leftbar,.rightbar{background:rgba(18,20,35,.92);border-color:var(--line);backdrop-filter:blur(18px);padding:18px;overflow:auto}.leftbar{border-right:1px solid var(--line)}.rightbar{border-left:1px solid var(--line)}.brand{display:flex;align-items:center;gap:12px;margin-bottom:22px}.brand-mark{width:46px;height:46px;border-radius:16px;background:linear-gradient(135deg,var(--primary),#9f7aea);display:grid;place-items:center;font-weight:900}.brand small{display:block;color:var(--muted);font-weight:600}.upload-box{display:grid;place-items:center;text-align:center;gap:9px;min-height:170px;border:2px dashed rgba(124,92,255,.45);border-radius:24px;background:rgba(124,92,255,.08);padding:20px;transition:.2s}.upload-box:hover,.upload-box.drag{background:rgba(124,92,255,.16);transform:translateY(-1px)}.upload-icon{width:54px;height:54px;border-radius:18px;background:linear-gradient(135deg,var(--primary),#00d68f);display:grid;place-items:center;font-size:30px;font-weight:300}.upload-box small,.muted{color:var(--muted);font-size:.92rem}.panel{background:rgba(255,255,255,.06);border:1px solid var(--line);border-radius:22px;padding:16px;margin-bottom:14px}.panel.mini{margin-top:14px}.panel-title{font-weight:900;margin-bottom:12px;letter-spacing:.01em}.file-list.empty{color:var(--muted);font-size:.92rem}.file-item{display:flex;gap:10px;align-items:center;padding:10px;border-radius:14px;background:rgba(255,255,255,.06);margin-bottom:8px}.file-icon{width:38px;height:38px;border-radius:12px;background:var(--panel2);display:grid;place-items:center}.file-info{min-width:0;flex:1}.file-info b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-info small{color:var(--muted)}.small-upload,.ghost-btn,.primary-btn{border:0;border-radius:16px;padding:12px 16px;font-weight:900;color:white;display:inline-flex;align-items:center;justify-content:center;gap:8px}.small-upload{background:rgba(255,255,255,.08);border:1px solid var(--line);width:100%;margin-bottom:10px}.ghost-btn{background:rgba(255,255,255,.08);border:1px solid var(--line)}.primary-btn{background:linear-gradient(135deg,var(--primary),#9f7aea);box-shadow:0 16px 35px rgba(124,92,255,.32)}.stage-wrap{display:flex;flex-direction:column;min-width:0}.topbar{height:96px;display:flex;align-items:center;justify-content:space-between;gap:18px;padding:20px 26px;border-bottom:1px solid var(--line);background:rgba(8,9,18,.38);backdrop-filter:blur(12px)}.topbar h1{margin:0;font-size:1.5rem}.topbar p{margin:4px 0 0;color:var(--muted)}.top-actions{display:flex;gap:10px}.stage{position:relative;flex:1;margin:22px;border-radius:28px;background:repeating-conic-gradient(from 45deg,#222436 0 25%,#1c1e30 0 50%) 50%/32px 32px;border:1px solid var(--line);box-shadow:inset 0 0 0 1px rgba(255,255,255,.02),var(--shadow);display:grid;place-items:center;overflow:hidden}.empty-stage{text-align:center;color:var(--muted);padding:24px}.empty-icon{width:78px;height:78px;margin:0 auto 12px;border-radius:26px;background:rgba(255,255,255,.08);display:grid;place-items:center;font-size:32px;color:#fff}.empty-stage h2{color:#fff;margin:0 0 6px}#imageCanvas{max-width:100%;max-height:100%;display:none;border-radius:14px;box-shadow:0 20px 60px rgba(0,0,0,.28)}.video-preview{position:relative;width:min(92%,920px);max-height:90%;display:grid;place-items:center}.video-preview video{width:100%;max-height:72vh;border-radius:18px;background:#000}.hidden{display:none!important}.video-wm{position:absolute;right:30px;bottom:30px;color:white;font-weight:900;font-size:42px;text-shadow:0 3px 12px rgba(0,0,0,.85);opacity:.8;user-select:none;touch-action:none}.tabs{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:14px}.tab{border:1px solid var(--line);background:rgba(255,255,255,.06);color:var(--muted);border-radius:14px;padding:10px 8px;font-weight:900}.tab.active{background:rgba(124,92,255,.18);color:#fff;border-color:rgba(124,92,255,.5)}.tabpane{display:none}.tabpane.active{display:block}label{display:grid;gap:8px;margin-bottom:13px;font-weight:800;color:#dce1f3}input,select{width:100%;border:1px solid var(--line);background:#10111f;color:#fff;border-radius:14px;padding:12px;outline:none}input:focus,select:focus{border-color:var(--primary)}input[type=color]{height:48px;padding:5px}input[type=range]{accent-color:var(--primary);padding:0}.segmented{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.segmented label{display:flex;gap:6px;align-items:center;justify-content:center;background:#10111f;border:1px solid var(--line);padding:12px;border-radius:14px;margin:0}.segmented input,.check input{width:auto}.style-buttons{display:grid;grid-template-columns:repeat(2,1fr);gap:8px;margin:12px 0}.style-buttons button{border:1px solid var(--line);background:#10111f;color:var(--muted);border-radius:14px;padding:11px;font-weight:900}.style-buttons button.active{background:rgba(0,214,143,.14);border-color:rgba(0,214,143,.45);color:#eafff7}.two{display:grid;grid-template-columns:1fr 52px;align-items:center;gap:8px}.two output{background:#10111f;border:1px solid var(--line);border-radius:14px;padding:12px;text-align:center}.two-fields{display:grid;grid-template-columns:1fr 1fr;gap:10px}.check{display:flex;align-items:center;gap:10px;margin:9px 0;color:var(--muted)}.grid9{display:grid;grid-template-columns:repeat(3,1fr);gap:9px;margin-bottom:16px}.grid9 button{height:60px;border-radius:16px;border:1px solid var(--line);background:#10111f;position:relative}.grid9 button:after{content:"";width:13px;height:13px;border-radius:50%;background:var(--muted);position:absolute}.grid9 button[data-pos*="top"]:after{top:12px}.grid9 button[data-pos*="bottom"]:after{bottom:12px}.grid9 button[data-pos*="center"]:after{top:50%;transform:translateY(-50%)}.grid9 button[data-pos*="left"]:after{left:12px}.grid9 button[data-pos$="right"]:after{right:12px}.grid9 button[data-pos$="center"]:after,.grid9 button[data-pos="center"]:after{left:50%;transform:translate(-50%,-50%)}.grid9 button[data-pos="top-center"]:after{left:50%;transform:translateX(-50%)}.grid9 button[data-pos="bottom-center"]:after{left:50%;transform:translateX(-50%)}.grid9 button.active{border-color:var(--primary);background:rgba(124,92,255,.18)}.grid9 button.active:after{background:#fff}.result-panel{position:absolute;left:322px;right:382px;bottom:18px;background:rgba(18,20,35,.96);border:1px solid var(--line);border-radius:18px;padding:14px;z-index:10;box-shadow:var(--shadow)}.download-card{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 0;border-bottom:1px solid var(--line)}.download-card:last-child{border-bottom:0}.download-card a{color:#fff;text-decoration:none}.mobilebar{display:none}.toast{position:fixed;top:18px;left:50%;transform:translateX(-50%);background:#181a2c;border:1px solid var(--line);border-radius:16px;padding:12px 16px;box-shadow:var(--shadow);z-index:50}.toast.error{background:#341621;color:#ffdbe3}.spinner{width:16px;height:16px;border:2px solid rgba(255,255,255,.3);border-top-color:white;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media(max-width:1100px){body{overflow:auto}.app-shell{height:auto;min-height:100vh;display:block;padding-bottom:76px}.leftbar,.rightbar{position:static;border:0}.stage-wrap{min-height:70vh}.topbar{height:auto;align-items:flex-start;flex-direction:column}.stage{height:62vh;margin:14px}.rightbar{padding-bottom:90px}.result-panel{position:fixed;left:12px;right:12px;bottom:82px}.mobilebar{position:fixed;left:0;right:0;bottom:0;z-index:30;display:grid;grid-template-columns:repeat(5,1fr);background:rgba(18,20,35,.96);border-top:1px solid var(--line);padding:8px 8px calc(8px + env(safe-area-inset-bottom));backdrop-filter:blur(18px)}.mobilebar button{border:0;background:transparent;color:var(--muted);font-weight:900;padding:10px 4px}.mobilebar #mExport{background:linear-gradient(135deg,var(--primary),#9f7aea);color:white;border-radius:14px}}@media(max-width:640px){.topbar h1{font-size:1.25rem}.top-actions{width:100%;display:grid;grid-template-columns:1fr 1fr}.stage{height:55vh;border-radius:22px}.two-fields{grid-template-columns:1fr}.video-wm{font-size:28px}.app-shell{padding-bottom:86px}.leftbar,.rightbar{padding:14px}.panel{border-radius:18px}.segmented{grid-template-columns:1fr}.tabs{overflow:auto}.tab{min-width:86px}.result-panel{max-height:40vh;overflow:auto}}

/* KOAF + mobile-first editor update */
.brand-img{width:54px;height:54px;border-radius:16px;object-fit:contain;background:#fff;padding:5px}.default-logo-preview{display:flex;align-items:center;gap:10px;margin-bottom:10px;color:var(--muted);font-size:.9rem}.default-logo-preview img{width:54px;height:54px;border-radius:14px;background:#fff;object-fit:contain;padding:5px}.rightbar:before{display:none;content:""}
@media(max-width:760px){
  html,body{height:100%;overflow:hidden;background:#10111f}.app-shell{height:100dvh;min-height:0;display:flex;flex-direction:column;padding-bottom:0;overflow:hidden}.leftbar{order:1;flex:0 0 96px;display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:8px 10px;background:rgba(18,20,35,.98);border-bottom:1px solid var(--line);overflow:hidden}.leftbar .brand{display:none}.leftbar .panel.mini{display:none}.leftbar .ghost-btn{display:none}.upload-box{min-height:78px;height:78px;border-radius:18px;padding:8px;gap:2px}.upload-box .upload-icon{width:34px;height:34px;border-radius:12px;font-size:22px}.upload-box b{font-size:.82rem;line-height:1.1}.upload-box small{font-size:.66rem;line-height:1.1}.leftbar .panel:nth-of-type(2){display:block;margin:0;padding:8px;border-radius:18px;min-height:78px}.leftbar .panel:nth-of-type(2) .panel-title{font-size:.8rem;margin-bottom:4px}.leftbar .small-upload{height:34px;margin-bottom:4px;padding:6px;font-size:.76rem;border-radius:12px}.leftbar .default-logo-preview{display:none}.leftbar #logoName{font-size:.68rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .stage-wrap{order:2;flex:1 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden;padding-bottom:0}.topbar{flex:0 0 auto;height:86px;padding:10px 14px;display:grid;grid-template-columns:1fr auto;gap:8px;align-items:center}.topbar h1{font-size:1.12rem;line-height:1.1}.topbar p{font-size:.84rem;line-height:1.15}.top-actions{display:flex;width:auto}.top-actions .ghost-btn{display:none}.top-actions .primary-btn{min-width:96px;padding:12px 16px;border-radius:16px}
  .stage{flex:1 1 auto;min-height:0;height:auto;margin:8px 10px calc(42dvh + 74px);border-radius:20px;place-items:center}.empty-stage{padding:10px}.empty-icon{width:54px;height:54px;border-radius:18px;font-size:24px}.empty-stage h2{font-size:1rem}.empty-stage p{font-size:.82rem}#imageCanvas{max-width:100%;max-height:100%;border-radius:12px}.video-preview{width:100%;height:100%;max-height:100%}.video-preview video{max-height:100%;height:100%;object-fit:contain;border-radius:12px}.video-wm{font-size:24px}
  .rightbar{position:fixed;z-index:35;left:0;right:0;bottom:64px;height:42dvh;max-height:42dvh;overflow:auto;padding:22px 14px 14px;background:rgba(24,26,44,.98);border:1px solid var(--line);border-left:0;border-right:0;border-bottom:0;border-radius:22px 22px 0 0;box-shadow:0 -18px 45px rgba(0,0,0,.35);-webkit-overflow-scrolling:touch}.rightbar:before{display:block;position:fixed;left:50%;bottom:calc(42dvh + 52px);transform:translateX(-50%);width:46px;height:5px;border-radius:999px;background:rgba(255,255,255,.25);z-index:36}.rightbar .tabs{display:none}.tabpane.active{display:block}.panel{padding:12px;border-radius:18px;margin-bottom:10px}.panel-title{font-size:.98rem;margin-bottom:10px}label{font-size:.9rem;margin-bottom:10px;gap:6px}input,select{padding:11px;border-radius:13px}.segmented{grid-template-columns:repeat(3,1fr)}.segmented label{font-size:.82rem;padding:9px 6px}.style-buttons{grid-template-columns:repeat(4,1fr);gap:7px}.style-buttons button{font-size:.78rem;padding:10px 4px}.two{grid-template-columns:1fr 48px}.two output{padding:10px 4px}.two-fields{grid-template-columns:1fr 1fr}.grid9 button{height:44px;border-radius:12px}.check{font-size:.88rem;margin:7px 0}.mobilebar{height:64px;display:grid;grid-template-columns:repeat(5,1fr);align-items:center}.mobilebar button{font-size:.8rem}.mobilebar button.active{color:#fff}.mobilebar #mExport{padding:10px 4px}.result-panel{position:fixed;z-index:50;left:10px;right:10px;bottom:calc(64px + 42dvh + 10px);max-height:128px;overflow:auto;padding:12px;border-radius:18px;background:rgba(18,20,35,.98)}.download-card{gap:8px}.download-card span{font-size:.9rem;line-height:1.2;word-break:break-word}.download-card .primary-btn{padding:10px 14px;border-radius:14px;flex:0 0 auto}
}
@media(max-width:390px){.stage{margin-bottom:calc(46dvh + 72px)}.rightbar{height:46dvh;max-height:46dvh;bottom:62px}.rightbar:before{bottom:calc(46dvh + 50px)}.result-panel{bottom:calc(62px + 46dvh + 8px)}.style-buttons{grid-template-columns:repeat(2,1fr)}}

/* ===== FINAL MOBILE-FIRST FIX v9: keep preview visible while editing ===== */
@media(max-width:760px){
  html,body{height:100%;overflow:hidden;background:#0d0f1d}
  body{font-size:15px}
  .app-shell{height:100dvh;min-height:0;display:block;padding:0;overflow:hidden;background:radial-gradient(circle at 20% 0,#251d54 0,#10111f 45%,#080912 100%)}

  /* Hide the old left column as a layout block. Keep only upload/logo as floating tools. */
  .leftbar{position:fixed;z-index:60;left:10px;right:auto;top:76px;width:auto;height:auto;display:block;padding:0;background:transparent;border:0;overflow:visible;backdrop-filter:none}
  .leftbar .brand,.leftbar .panel.mini,.leftbar .ghost-btn{display:none!important}
  .leftbar .upload-box{width:58px;height:58px;min-height:58px;border-radius:18px;padding:0;display:grid;place-items:center;border:1px solid rgba(124,92,255,.7);background:linear-gradient(135deg,rgba(124,92,255,.95),rgba(0,214,143,.9));box-shadow:0 12px 35px rgba(0,0,0,.34)}
  .leftbar .upload-box b,.leftbar .upload-box small{display:none!important}
  .leftbar .upload-icon{width:auto;height:auto;background:transparent;font-size:34px;line-height:1;color:#fff}
  .leftbar .panel:nth-of-type(2){display:block!important;position:fixed;top:76px;right:10px;width:58px;height:58px;min-height:58px;margin:0;padding:0;border-radius:18px;background:rgba(24,26,44,.92);border:1px solid var(--line);box-shadow:0 12px 35px rgba(0,0,0,.28);overflow:hidden}
  .leftbar .panel:nth-of-type(2) .panel-title,.leftbar .panel:nth-of-type(2) #logoName{display:none!important}
  .leftbar .small-upload{width:58px;height:58px;margin:0;padding:0;border:0;background:transparent;font-size:0;display:grid;place-items:center}
  .leftbar .small-upload:before{content:'Logo';font-size:11px;font-weight:900;color:#fff}
  .leftbar .default-logo-preview{display:none!important}

  /* Main preview area */
  .stage-wrap{height:100dvh;min-height:0;display:flex;flex-direction:column;overflow:hidden;padding:0 0 0;background:transparent}
  .topbar{height:68px;min-height:68px;padding:9px 14px 9px 82px;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px;background:rgba(8,9,18,.92);border-bottom:1px solid var(--line);backdrop-filter:blur(16px)}
  .topbar h1{font-size:1rem;margin:0;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar p{font-size:.74rem;margin:3px 0 0;line-height:1.1;color:var(--muted);max-width:190px}
  .top-actions{display:flex;width:auto;gap:8px}.top-actions .ghost-btn{display:none}.top-actions .primary-btn{min-width:86px;padding:10px 13px;border-radius:14px;font-size:.88rem}

  .stage{height:auto;flex:1 1 auto;min-height:0;margin:10px 10px calc(46dvh + 12px);border-radius:22px;border:1px solid rgba(255,255,255,.13);box-shadow:inset 0 0 0 1px rgba(255,255,255,.04),0 20px 60px rgba(0,0,0,.32);display:grid;place-items:center;overflow:hidden;background:repeating-conic-gradient(from 45deg,#222436 0 25%,#191b2e 0 50%) 50%/28px 28px}
  .empty-stage{padding:14px}.empty-icon{width:48px;height:48px;border-radius:16px;font-size:22px}.empty-stage h2{font-size:1.02rem}.empty-stage p{font-size:.82rem;margin:4px 0 0}
  #imageCanvas{max-width:100%;max-height:100%;width:auto!important;height:auto!important;object-fit:contain;border-radius:14px}
  .video-preview{width:100%;height:100%;max-height:100%;display:grid;place-items:center}.video-preview video{width:100%;height:100%;max-height:100%;object-fit:contain;border-radius:14px}.video-wm{font-size:22px}

  /* Bottom editing sheet */
  .rightbar{position:fixed;z-index:45;left:0;right:0;bottom:0;height:46dvh;max-height:46dvh;overflow-y:auto;overflow-x:hidden;padding:0 12px 14px;background:rgba(24,26,44,.985);border:1px solid var(--line);border-left:0;border-right:0;border-bottom:0;border-radius:24px 24px 0 0;box-shadow:0 -20px 55px rgba(0,0,0,.42);backdrop-filter:blur(20px);-webkit-overflow-scrolling:touch}
  .rightbar:before{content:'';display:block;position:sticky;top:7px;margin:7px auto 6px;width:46px;height:5px;border-radius:999px;background:rgba(255,255,255,.26);z-index:3}
  .rightbar .tabs{position:sticky;top:18px;z-index:2;display:grid!important;grid-template-columns:repeat(4,1fr);gap:6px;margin:0 -2px 10px;padding:6px 0 8px;background:rgba(24,26,44,.985);backdrop-filter:blur(20px)}
  .tab{min-width:0;border-radius:13px;padding:9px 4px;font-size:.78rem;background:#10111f;color:#c7ccda}
  .tab.active{background:linear-gradient(135deg,var(--primary),#9f7aea);color:#fff;border-color:transparent}
  .tabpane{padding-bottom:18px}.tabpane.active{display:block}
  .panel{padding:12px;border-radius:18px;margin-bottom:10px;background:rgba(255,255,255,.055)}
  .panel-title{font-size:.95rem;margin-bottom:9px}.segmented{display:grid;grid-template-columns:repeat(3,1fr);gap:7px}.segmented label{font-size:.8rem;padding:9px 5px;border-radius:13px}
  label{font-size:.85rem;margin-bottom:9px;gap:5px}input,select{font-size:.92rem;padding:10px 11px;border-radius:13px;min-height:42px}
  input[type=color]{height:43px;min-height:43px}.style-buttons{grid-template-columns:repeat(4,1fr);gap:6px}.style-buttons button{font-size:.72rem;padding:9px 2px;border-radius:12px}.two{grid-template-columns:1fr 44px;gap:7px}.two output{padding:9px 2px;border-radius:12px;font-size:.84rem}.two-fields{grid-template-columns:1fr 1fr;gap:8px}.check{font-size:.82rem;margin:6px 0}.grid9{gap:7px;margin-bottom:11px}.grid9 button{height:42px;border-radius:12px}

  /* Result appears as a small download bar without hiding the controls */
  .result-panel{position:fixed;z-index:70;left:10px;right:10px;bottom:calc(46dvh + 8px);max-height:92px;overflow:auto;padding:10px 12px;border-radius:17px;background:rgba(18,20,35,.98);border:1px solid rgba(255,255,255,.14);box-shadow:0 16px 38px rgba(0,0,0,.38)}
  .result-panel b{font-size:.86rem}.download-card{padding:5px 0;gap:8px}.download-card span{font-size:.78rem;line-height:1.15;word-break:break-word}.download-card .primary-btn{padding:8px 11px;border-radius:12px;font-size:.82rem;flex:0 0 auto}

  /* Remove old extra mobile footer nav. Tabs are now inside bottom sheet. */
  .mobilebar{display:none!important}
}

@media(max-width:390px){
  .topbar{height:64px;min-height:64px;padding-left:76px}.leftbar,.leftbar .panel:nth-of-type(2){top:72px}.leftbar .upload-box,.leftbar .panel:nth-of-type(2),.leftbar .small-upload{width:52px;height:52px;min-height:52px}.stage{margin-bottom:calc(48dvh + 10px)}.rightbar{height:48dvh;max-height:48dvh}.result-panel{bottom:calc(48dvh + 8px)}.style-buttons{grid-template-columns:repeat(2,1fr)}.topbar p{max-width:160px}
}
