:root{--bg:#0d1117;--panel:#161b22;--line:#30363d;--fg:#e6edf3;--mut:#8b949e;--acc:#22c55e;--red:#ff3b3b;--blue:#58a6ff}
*{box-sizing:border-box}html,body{margin:0;height:100%}
body{background:var(--bg);color:var(--fg);font:15px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans",sans-serif;display:flex;flex-direction:column;min-height:100vh;min-height:100dvh;padding-bottom:calc(72px + env(safe-area-inset-bottom))}
.top{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--panel);border-bottom:1px solid var(--line)}
.logo{width:40px;height:40px;border-radius:50%;border:2px solid var(--red);flex:none}
.brand{flex:1;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.15;min-width:0}.brand b{color:#fff}.brand small{display:block;color:var(--mut);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sub{flex:none;background:var(--red);color:#fff;text-decoration:none;font-weight:700;font-size:13px;padding:7px 10px;border-radius:18px}
.sub span{display:none}
.bar{display:flex;gap:8px;padding:8px 12px;flex-wrap:wrap}
.sel{display:flex;flex-direction:column;gap:2px;font-size:11px;color:var(--mut);min-width:130px}.sel.grow{flex:1;min-width:170px}
select{background:var(--panel);color:var(--fg);border:1px solid var(--line);border-radius:10px;padding:9px 10px;font-size:15px;width:100%}
.work{flex:1;display:flex;flex-direction:column;gap:8px;padding:0 12px 8px;min-height:0}
.edpane{display:flex;flex-direction:column;min-height:0;min-width:0}
#editor{border:1px solid var(--line);border-radius:12px;overflow:hidden}
.CodeMirror{height:48vh;height:48dvh;min-height:260px;font-family:"JetBrains Mono","Fira Code",Menlo,Consolas,"Courier New",monospace;font-size:15px;line-height:1.5;background:#0d1117;color:#e6edf3}
.CodeMirror-gutters{background:#0d1117;border-right:1px solid #21262d}.CodeMirror-linenumber{color:#6e7681;padding:0 6px 0 4px}
.CodeMirror-cursor{border-left:2px solid #58a6ff}.CodeMirror-activeline-background{background:#161b22}
.CodeMirror-selected,.CodeMirror-focused .CodeMirror-selected{background:#264f78!important}
.CodeMirror-matchingbracket{color:#fff!important;background:#3b5070;outline:none}
.cm-s-tbz .cm-keyword{color:#ff7b72}.cm-s-tbz .cm-def{color:#d2a8ff}.cm-s-tbz .cm-variable{color:#e6edf3}.cm-s-tbz .cm-variable-2{color:#ffa657}.cm-s-tbz .cm-variable-3,.cm-s-tbz .cm-type{color:#79c0ff}
.cm-s-tbz .cm-builtin{color:#79c0ff}.cm-s-tbz .cm-string,.cm-s-tbz .cm-string-2{color:#a5d6ff}.cm-s-tbz .cm-number{color:#79c0ff}.cm-s-tbz .cm-comment{color:#8b949e;font-style:italic}
.cm-s-tbz .cm-atom{color:#79c0ff}.cm-s-tbz .cm-operator{color:#ff7b72}.cm-s-tbz .cm-property{color:#7ee787}.cm-s-tbz .cm-tag{color:#7ee787}.cm-s-tbz .cm-attribute{color:#79c0ff}.cm-s-tbz .cm-meta{color:#d2a8ff}.cm-s-tbz .cm-qualifier{color:#7ee787}.cm-s-tbz .cm-bracket{color:#8b949e}
details{margin-top:6px;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:6px 10px;font-size:13px;color:var(--mut)}
details textarea{width:100%;margin-top:6px;background:#0d1117;color:var(--fg);border:1px solid var(--line);border-radius:8px;font:14px monospace;padding:6px}
.outpane{display:flex;flex-direction:column;min-width:0;border:1px solid var(--line);border-radius:12px;overflow:hidden;background:#010409;min-height:180px}
.outhead{display:flex;justify-content:space-between;padding:6px 10px;background:var(--panel);font-size:13px;color:var(--mut)}
.status{color:var(--acc)}.status.err{color:#ff7b72}
#output{margin:0;padding:10px 12px;font:14px/1.5 "JetBrains Mono",Menlo,Consolas,monospace;white-space:pre-wrap;word-break:break-word;color:#e6edf3;flex:1;overflow:auto;min-height:150px;max-height:60vh}
#output .e{color:#ff7b72}#output .w{color:#e3b341}#output .i{color:var(--mut)}#output .r{color:#7ee787}
#output table{border-collapse:collapse;margin:4px 0 12px;font-size:13px}#output th,#output td{border:1px solid #30363d;padding:4px 10px;text-align:left}#output th{background:#161b22;color:#79c0ff}
#preview{width:100%;height:42vh;border:0;background:#fff}
.actions{position:fixed;left:0;right:0;bottom:0;display:flex;gap:6px;padding:8px 10px calc(8px + env(safe-area-inset-bottom));background:rgba(13,17,23,.96);border-top:1px solid var(--line);z-index:10}
.actions button{flex:1;min-height:50px;border-radius:12px;border:1px solid var(--line);background:var(--panel);color:var(--fg);font-size:14px;font-weight:600;padding:0 4px}
.actions .run{flex:2.4;background:var(--acc);color:#04210f;border:0;font-size:19px;font-weight:800}
.actions .run.busy{background:#e3b341}
.actions button:active{transform:scale(.97)}
#toast{position:fixed;left:50%;top:64px;transform:translateX(-50%);background:#238636;color:#fff;padding:9px 16px;border-radius:20px;font-size:14px;opacity:0;transition:opacity .2s;pointer-events:none;z-index:20;max-width:90vw;text-align:center}
#toast.show{opacity:1}
@media (min-width:900px){
  body{padding-bottom:0}
  .sub span{display:inline}
  .work{flex-direction:row;padding-bottom:12px}
  .edpane{flex:1.2}.outpane{flex:1}
  .CodeMirror{height:calc(100vh - 230px);font-size:16px}
  #output{max-height:none}#preview{height:100%;flex:1}
  .actions{position:static;padding:0 12px 12px;background:none;border:0;max-width:760px}
}

/* ---- recording mode (?rec=1): clean frame for screen-recorded videos ---- */
.tbz-hl{background:rgba(250,204,21,.16)!important;box-shadow:inset 4px 0 0 #facc15}
.run.press{transform:scale(.93);filter:brightness(1.25)}
body.rec{--recfs:18px;padding-bottom:0;height:100vh;overflow:hidden}
body.rec .bar,body.rec #stdinBox,body.rec #toast,body.rec .actions button:not(.run){display:none!important}
body.rec .top{padding:10px 14px}
body.rec .brand small{display:block}
body.rec .CodeMirror-cursors{visibility:visible!important}
body.rec .CodeMirror-cursor{border-left:3px solid #58a6ff}
body.rec .edpane,body.rec .outpane{min-width:0}
body.rec .work{flex:1;flex-direction:column;padding:10px 14px 8px;min-height:0}
body.rec .edpane{flex:1.35;min-height:0}
body.rec #editor{flex:1;min-height:0;display:flex}
body.rec .CodeMirror{flex:1;height:auto;min-height:0;font-size:var(--recfs);line-height:1.55}
body.rec .outpane{flex:1;min-height:0}
body.rec #output{font-size:calc(var(--recfs) * .92);max-height:none;min-height:0}
body.rec #output table{font-size:calc(var(--recfs) * .85)}
body.rec #preview{flex:1;height:auto}
body.rec .actions{position:static;padding:0 14px 12px;background:none;border:0;max-width:none}
body.rec .actions .run{min-height:52px;font-size:20px}
@media (min-aspect-ratio:1/1){
  body.rec .work{flex-direction:row}
  body.rec .edpane{flex:1.25}
  body.rec .outpane{flex:1}
  body.rec .sub span{display:inline}
  body.rec .actions{max-width:none;padding-left:calc(14px + 55%)}
}

.host{margin:8px;min-height:46px;border:0;border-radius:12px;background:linear-gradient(90deg,#2563eb,#7c3aed);color:#fff;font-size:17px;font-weight:800}
.modal{position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:30;display:flex;align-items:center;justify-content:center;padding:16px}
.modal[hidden]{display:none}
.modal .box{background:#161b22;border:1px solid #30363d;border-radius:16px;padding:18px;max-width:440px;width:100%;color:#e6edf3}
.modal h3{margin:0 0 6px;font-size:20px}.modal p{margin:0 0 10px;color:#8b949e;font-size:14px}
.modal input{width:100%;padding:10px;border-radius:10px;border:1px solid #30363d;background:#0d1117;color:#a5d6ff;font:13px monospace}
.mrow{display:flex;gap:8px;margin-top:10px}
.mrow>*{flex:1;min-height:46px;border-radius:12px;border:1px solid #30363d;background:#0d1117;color:#e6edf3;font-size:14px;font-weight:700;display:flex;align-items:center;justify-content:center;text-decoration:none;text-align:center}
.mrow .wa{background:#25d366;color:#052e16;border:0}
.modal small{display:block;margin-top:10px;color:#8b949e}
.modal .close{width:100%;margin-top:12px;min-height:44px;border-radius:12px;border:0;background:#22c55e;color:#04210f;font-weight:800;font-size:16px}
body.rec .host{display:none!important}

/* ---- multi-file project ---- */
.files{display:flex;align-items:center;gap:6px;margin-bottom:6px;min-width:0}
.files[hidden]{display:none}
.fbtn{flex:none;min-height:38px;min-width:40px;border-radius:10px;border:1px solid var(--line);background:var(--panel);color:var(--fg);font-size:15px;font-weight:700;padding:0 10px}
.fbtn.live{background:#1f6feb;border-color:#1f6feb;color:#fff}
.tabs{flex:1;display:flex;gap:4px;overflow-x:auto;scrollbar-width:none;min-width:0}
.tabs::-webkit-scrollbar{display:none}
.tab{flex:none;min-height:38px;padding:0 12px;border-radius:10px 10px 0 0;border:1px solid var(--line);border-bottom:2px solid transparent;background:#0d1117;color:var(--mut);font:600 13px/1 "JetBrains Mono",Menlo,monospace;white-space:nowrap}
.tab.on{color:#fff;background:#161b22;border-bottom-color:#f78166}
.drawer{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:8px;margin-bottom:6px}
.drawer[hidden]{display:none}
.dhead{display:flex;align-items:center;gap:8px;padding:2px 4px 8px;font-size:14px}.dhead span{flex:1;color:var(--mut);font-size:12px}
.dhead button{background:none;border:0;color:var(--fg);font-size:18px;min-width:36px;min-height:32px}
#fileList{list-style:none;margin:0;padding:0}
#fileList li{display:flex;gap:4px;align-items:center;border-radius:8px}
#fileList li.on{background:#1f2937}
#fileList li button{background:none;border:0;color:var(--fg);min-height:40px;font-size:15px;padding:0 8px}
#fileList .fname{flex:1;text-align:left;font-family:"JetBrains Mono",Menlo,monospace;font-size:14px}
.dnew{width:100%;margin-top:6px;min-height:42px;border-radius:10px;border:1px dashed #3d444d;background:none;color:#7ee787;font-weight:700;font-size:15px}
@media (max-width:899px){
  body.live .edpane .CodeMirror,body.live #editor,body.live #stdinBox{display:none}
  body.live #preview{height:68vh;height:68dvh}
}
@media (min-width:900px){ .fbtn.live{display:none} .drawer{position:static} }
body.rec .fbtn{display:none}
body.rec .tab{font-size:calc(var(--recfs) * .78);min-height:calc(var(--recfs) * 2.1)}

body.web #output{flex:0 0 auto;min-height:56px;max-height:120px}
body.web .outpane{min-height:0}
@media (min-width:900px){ body.web #preview{flex:1;height:auto;min-height:300px} }
body.rec.web #output{max-height:18%}

@media (max-width:899px){ body.live .edpane{flex:0 0 auto} body.rec.live #preview{height:auto;flex:1} body.rec.live .outpane{flex:1} }
@media (max-aspect-ratio:1/1){ body.rec.live .edpane{flex:0 0 auto} body.rec.live .edpane #editor{display:none} body.rec.live .outpane{flex:1} }

.edpane,.outpane{flex-shrink:0}
@media (min-width:900px){.edpane{flex:1.2 1 0}.outpane{flex:1 1 0}}
body.rec .edpane{flex:1.35 1 0}body.rec .outpane{flex:1 1 0}
@media (min-aspect-ratio:1/1){body.rec .edpane{flex:1.25 1 0}}
@media (max-width:899px){ body.live .edpane{flex:0 0 auto} }
@media (max-aspect-ratio:1/1){ body.rec.live .edpane{flex:0 0 auto} }

/* ==== LIGHT THEME (default since Oct 31 2026, Noor: "white kar do" so text is clear in videos). ?theme=dark = old dark theme ==== */
html.light{--bg:#ffffff;--panel:#f6f8fa;--line:#d0d7de;--fg:#1f2328;--mut:#59636e;--acc:#1f9d4c;--red:#e5262b;--blue:#0969da;color-scheme:light}
html.light body{background:var(--bg);color:var(--fg)}
html.light .brand b{color:#1f2328}
html.light select{background:#fff;color:var(--fg)}
html.light #editor{border:1.5px solid #c9d1d9;box-shadow:0 1px 3px rgba(31,35,40,.06)}
html.light .CodeMirror{background:#ffffff;color:#1f2328}
html.light .CodeMirror-gutters{background:#f6f8fa;border-right:1px solid #d0d7de}
html.light .CodeMirror-linenumber{color:#6e7781}
html.light .CodeMirror-cursor{border-left:2px solid #0969da}
html.light .CodeMirror-activeline-background{background:#f3f6fa}
html.light .CodeMirror-selected,html.light .CodeMirror-focused .CodeMirror-selected{background:#b6d7ff!important}
html.light .CodeMirror-matchingbracket{color:#1f2328!important;background:#c8e1ff;outline:none}
html.light .cm-s-tbz .cm-keyword{color:#cf222e}html.light .cm-s-tbz .cm-def{color:#8250df}html.light .cm-s-tbz .cm-variable{color:#1f2328}
html.light .cm-s-tbz .cm-variable-2{color:#953800}html.light .cm-s-tbz .cm-variable-3,html.light .cm-s-tbz .cm-type{color:#0550ae}
html.light .cm-s-tbz .cm-builtin{color:#8250df}html.light .cm-s-tbz .cm-string,html.light .cm-s-tbz .cm-string-2{color:#0a3069}
html.light .cm-s-tbz .cm-number{color:#0550ae}html.light .cm-s-tbz .cm-comment{color:#6e7781;font-style:italic}
html.light .cm-s-tbz .cm-atom{color:#0550ae}html.light .cm-s-tbz .cm-operator{color:#cf222e}html.light .cm-s-tbz .cm-property{color:#0550ae}
html.light .cm-s-tbz .cm-tag{color:#116329}html.light .cm-s-tbz .cm-attribute{color:#0550ae}html.light .cm-s-tbz .cm-meta{color:#8250df}
html.light .cm-s-tbz .cm-qualifier{color:#6639ba}html.light .cm-s-tbz .cm-bracket{color:#57606a}
html.light details textarea{background:#fff;color:var(--fg)}
html.light .outpane{background:#ffffff;border:1.5px solid #c9d1d9;box-shadow:0 1px 3px rgba(31,35,40,.06)}
html.light .outhead{background:#f6f8fa;color:#424a53;border-bottom:1px solid #d0d7de;font-weight:600}
html.light .status{color:#1a7f37}html.light .status.err{color:#cf222e}
html.light #output{color:#1f2328;background:#ffffff}
html.light #output .e{color:#cf222e}html.light #output .w{color:#9a6700}html.light #output .i{color:#59636e}html.light #output .r{color:#1a7f37}
html.light #output th,html.light #output td{border:1px solid #d0d7de}html.light #output th{background:#f6f8fa;color:#0550ae}
html.light #preview{border-top:1px solid #d0d7de}
html.light .actions{background:rgba(255,255,255,.97);border-top:1px solid var(--line)}
html.light .actions button{background:#f6f8fa;color:var(--fg);border:1px solid #d0d7de}
html.light .actions .run{background:#1f9d4c;color:#ffffff;border:0;box-shadow:0 2px 6px rgba(31,157,76,.30)}
html.light .actions .run.busy{background:#d4a72c;color:#1f2328}
html.light #toast{background:#1a7f37}
html.light .tbz-hl{background:rgba(250,204,21,.30)!important;box-shadow:inset 4px 0 0 #d4a72c}
html.light body.rec .CodeMirror-cursor{border-left:3px solid #0969da}
html.light .modal{background:rgba(31,35,40,.45)}
html.light .modal .box{background:#ffffff;border:1px solid #d0d7de;color:#1f2328;box-shadow:0 8px 30px rgba(31,35,40,.18)}
html.light .modal p,html.light .modal small{color:#59636e}
html.light .modal input{background:#f6f8fa;border:1px solid #d0d7de;color:#0550ae}
html.light .mrow>*{background:#f6f8fa;border:1px solid #d0d7de;color:#1f2328}
html.light .mrow .wa{background:#25d366;color:#052e16;border:0}
html.light .modal .close{background:#1f9d4c;color:#fff}
html.light .fbtn{background:#f6f8fa;color:var(--fg);border:1px solid #d0d7de}
html.light .fbtn.live{background:#0969da;border-color:#0969da;color:#fff}
html.light .tab{background:#f6f8fa;color:#59636e;border:1px solid #d0d7de;border-bottom:2px solid transparent}
html.light .tab.on{color:#1f2328;background:#ffffff;border-bottom-color:#fd8c73}
html.light .drawer{background:#f6f8fa;border:1px solid #d0d7de}
html.light #fileList li.on{background:#ddf4ff}
html.light .dnew{border:1px dashed #afb8c1;color:#1a7f37}
html.light details{background:#f6f8fa;border:1px solid #d0d7de;color:#59636e}
