/* Sankalak — a calm, warm code runner. Dark by default, light on request. Orange marks Run; red errors; violet AI. */
:root {
  --bg: #0b0d14; --bg2: #11131c; --panel: #151823; --panel2: #1b1f2c; --panel3: #232838; --line: #242a3a; --line2: #30374b;
  --text: #e8eaf1; --text2: #a5adbf; --text3: #6c748a; --accent: #f97316; --accent2: #fb923c; --accent-ink: #1c0b02; --ai: #a78bfa;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --sel: rgba(249,115,22,.22); --sel-solid: #4a2b16; --match: rgba(167,139,250,.22);
  --ed-bg: #0f1119; --ed-line: rgba(255,255,255,.035); --term-bg: #0c0e15;
  --syn-kw: #c792ea; --syn-comment: #6b7891; --syn-str: #e5c07b; --syn-num: #f78c6c; --syn-atom: #ff9cac; --syn-fn: #82aaff; --syn-type: #7fdbca; --syn-op: #89ddff; --syn-bracket: #a5adbf; --syn-prop: #c3e88d; --syn-meta: #f9a8d4;
  --radius: 10px; --shadow: 0 18px 50px rgba(0,0,0,.55);
  --font: "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Mono", monospace;
  --top: 48px; --vvh: 100dvh;
  color-scheme: dark;
}
:root[data-theme=light] {
  --bg: #eef0f5; --bg2: #f7f8fb; --panel: #ffffff; --panel2: #f3f4f8; --panel3: #e8eaf1; --line: #e1e4ec; --line2: #cfd4df;
  --text: #171a24; --text2: #4b5366; --text3: #868ea2; --accent: #ea580c; --accent2: #c2410c; --accent-ink: #ffffff; --ai: #7c3aed;
  --ok: #059669; --warn: #b45309; --bad: #dc2626; --sel: rgba(234,88,12,.16); --sel-solid: #fbd5bd; --match: rgba(124,58,237,.14);
  --ed-bg: #ffffff; --ed-line: rgba(15,23,42,.035); --term-bg: #fbfbfd;
  --syn-kw: #7c3aed; --syn-comment: #7a8599; --syn-str: #a15c00; --syn-num: #c2410c; --syn-atom: #be185d; --syn-fn: #1d4ed8; --syn-type: #0f766e; --syn-op: #0e7490; --syn-bracket: #4b5366; --syn-prop: #15803d; --syn-meta: #9d174d;
  --shadow: 0 18px 50px rgba(20,30,50,.18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
::selection { background: var(--sel); }
.hidden, [hidden] { display: none !important; }
.dim { color: var(--text3); } .muted { color: var(--text2); } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sp { flex: 1; }
svg.i { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.logo { width: 26px; height: 26px; flex: none; }
.lmw { display: inline-flex; flex: none; } .lmw svg { display: block; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; } ::-webkit-scrollbar-corner { background: transparent; }
.boot { height: 100%; display: grid; place-content: center; gap: 12px; text-align: center; color: var(--text3); }
.boot-logo { width: 56px; height: 56px; margin: auto; border-radius: 14px; background: linear-gradient(135deg, #fbbf24, #f97316 50%, #ec4899); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.94); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); white-space: nowrap; font-weight: 550; }
.btn:hover { border-color: var(--text3); background: var(--panel3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn:disabled, .ibtn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn kbd { margin-left: 2px; }
.btn.run { background: linear-gradient(180deg, #fb923c, #f97316); border-color: #f97316; color: #1c0b02; font-weight: 750; padding: 0 14px 0 11px; box-shadow: 0 0 0 1px rgba(249,115,22,.25), 0 6px 18px -6px rgba(249,115,22,.6); }
.btn.run:hover { filter: brightness(1.07); }
.btn.run kbd { background: rgba(0,0,0,.14); border-color: rgba(0,0,0,.18); color: #3b1703; }
.btn.stop { background: rgba(248,113,113,.14); border-color: rgba(248,113,113,.5); color: var(--bad); font-weight: 700; }
.ibtn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text2); padding: 0; flex: none; }
.ibtn:hover { background: var(--panel2); color: var(--text); }
.ibtn.on { color: var(--accent); background: var(--sel); }
.ibtn.sm { width: 24px; height: 24px; border-radius: 6px; } .ibtn.sm svg.i { width: 14px; height: 14px; }
input[type=text], input[type=number], input[type=search], select, textarea { background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 9px; min-width: 0; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--sel); }
kbd { font-family: var(--mono); font-size: 11px; background: var(--panel2); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text2); white-space: nowrap; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding: 2px; gap: 2px; flex: none; }
.seg button { border: 0; background: transparent; color: var(--text2); padding: 4px 10px; border-radius: 7px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button.on { background: var(--panel3); color: var(--text); box-shadow: 0 0 0 1px var(--line2); }
.seg button svg.i { width: 15px; height: 15px; }

/* ---------- the frame ---------- */
#app { height: var(--vvh); display: grid; grid-template-rows: var(--top) 1fr 26px; padding-top: env(safe-area-inset-top); }
.top { display: flex; align-items: center; gap: 6px; padding: 0 10px; background: var(--bg2); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 9px; margin-right: 6px; text-decoration: none; color: inherit; flex: none; }
.brand b { font-size: 15.5px; font-weight: 780; letter-spacing: .2px; }
.brand small { color: var(--text3); font-size: 12px; }
.langbtn { display: inline-flex; align-items: center; gap: 9px; height: 36px; padding: 0 10px 0 4px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); min-width: 0; max-width: 300px; }
.langbtn:hover { border-color: var(--text3); background: var(--panel2); }
.langbtn { overflow: hidden; }
.langbtn .ln { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; overflow: hidden; }
.langbtn .ln b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.langbtn .ln b { font-size: 13.5px; }
.langbtn .ln small { font-size: 11px; color: var(--text3); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where-seg .dev-dot, .pdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.pdot.dev, .dev-dot { background: var(--ok); } .pdot.srv { background: #60a5fa; } .pdot.loc { background: var(--ai); }
.work { display: grid; grid-template-columns: minmax(0, 1fr) 6px minmax(300px, var(--side, 42%)); min-height: 0; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.side { display: grid; grid-template-rows: auto 6px minmax(0, 1fr); min-height: 0; background: var(--bg); }
.side.noinput { grid-template-rows: auto 0 minmax(0, 1fr); }
.splitter { background: var(--bg); position: relative; z-index: 2; }
.splitter.v { cursor: col-resize; } .splitter.h { cursor: row-resize; }
.splitter:hover, .splitter.drag { background: var(--sel); }
body.dragging { user-select: none; }

/* file tabs */
.ftabs { display: flex; align-items: stretch; gap: 1px; height: 38px; padding: 0 6px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; flex: none; }
.ftabs::-webkit-scrollbar { display: none; }
.ftab { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px 0 12px; border: 0; background: transparent; color: var(--text2); font-family: var(--mono); font-size: 12.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.ftab:hover { color: var(--text); }
.ftab.on { color: var(--text); border-bottom-color: var(--accent); background: var(--panel); }
.ftab .main-mark { color: var(--accent); font-size: 10px; }
.ftab .x { opacity: 0; } .ftab:hover .x, .ftab.on .x { opacity: .7; }
.ftab .dot-err { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.ftabs .addf { align-self: center; }
.edwrap { flex: 1; min-height: 0; position: relative; }
.edwrap .cm-editor { position: absolute; inset: 0; }
.edwrap .cm-editor.cm-focused { outline: none; }
.symbar { display: none; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--bg2); border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.symbar::-webkit-scrollbar { display: none; }
.symbar button { min-width: 38px; height: 36px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); font-family: var(--mono); font-size: 15px; font-weight: 600; flex: none; touch-action: manipulation; }
.symbar button:active { background: var(--sel); }

/* input box */
.inbox { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.phead { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); background: var(--bg2); flex: none; font-weight: 650; font-size: 12.5px; color: var(--text2); }
.phead svg.i { width: 15px; height: 15px; }
.phead .hint { font-weight: 450; color: var(--text3); font-size: 11.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.inbox textarea { flex: 1; min-height: 0; height: var(--inh, 96px); resize: none; border: 0; border-radius: 0; background: var(--ed-bg); font-family: var(--mono); font-size: 13px; padding: 8px 12px; }
.inbox textarea:focus { box-shadow: none; }
.inbox.collapsed textarea { display: none; }

/* output */
.outbox { display: flex; flex-direction: column; min-height: 0; background: var(--term-bg); }
.ohead { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 6px; background: var(--bg2); border-bottom: 1px solid var(--line); flex: none; min-width: 0; }
.otabs { display: flex; gap: 2px; min-width: 0; overflow: hidden; }
.otab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 0; background: transparent; color: var(--text2); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.otab:hover { background: var(--panel2); color: var(--text); }
.otab.on { background: var(--panel3); color: var(--text); }
.otab svg.i { width: 15px; height: 15px; }
.badge { font-style: normal; font-weight: 700; font-size: 10.5px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; border-radius: 9px; background: var(--panel3); color: var(--text2); text-align: center; }
.badge.bad { background: var(--bad); color: #fff; }
.oactions { margin-left: auto; display: flex; gap: 4px; flex: none; }
.oactions .btn.ai { color: var(--ai); border-color: color-mix(in srgb, var(--ai) 45%, transparent); background: color-mix(in srgb, var(--ai) 10%, transparent); }
.oprogress { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--text2); flex: none; }
.obar { flex: 1; height: 6px; border-radius: 3px; background: var(--panel3); overflow: hidden; }
.obar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #fbbf24, #f97316, #ec4899); border-radius: 3px; transition: width .15s; }
.otext { white-space: nowrap; font-variant-numeric: tabular-nums; }
.obody { flex: 1; min-height: 0; position: relative; }
.term { position: absolute; inset: 0; padding: 8px 4px 4px 12px; }
.term .xterm { height: 100%; }
.term .xterm-viewport { background: var(--term-bg) !important; }
.comp, .results { position: absolute; inset: 0; overflow: auto; padding: 10px 12px; background: var(--term-bg); }
.empty { color: var(--text3); margin: 18px 4px; text-align: center; font-size: 12.5px; }
.ctext { margin: 0 0 6px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--text2); }
.ctext.err { color: var(--text); }
.dlist { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.diag { display: grid; grid-template-columns: 18px auto 1fr; gap: 8px; align-items: start; text-align: left; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12.5px; }
.diag:hover { border-color: var(--line2); background: var(--panel2); }
.diag svg.i { width: 16px; height: 16px; margin-top: 1px; }
.diag.error svg.i { color: var(--bad); } .diag.warning svg.i { color: var(--warn); } .diag.note svg.i { color: var(--syn-fn); }
.dloc { color: var(--text3); white-space: nowrap; font-size: 12px; margin-top: 1px; }
.dmsg { white-space: pre-wrap; word-break: break-word; }
.rimg { margin: 0 0 14px; background: #fff; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; }
.rimg img { display: block; max-width: 100%; height: auto; margin: auto; }
.rimg figcaption { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; background: var(--panel); color: var(--text2); font-size: 12px; }
.rtable { margin-bottom: 16px; }
.rcap { font-size: 12px; font-weight: 650; color: var(--text2); margin: 0 0 6px 2px; }
.rscroll { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 10px; }
.rtable table { border-collapse: collapse; font: 12.5px/1.4 var(--mono); width: 100%; }
.rtable th { position: sticky; top: 0; background: var(--panel2); text-align: left; font-weight: 700; color: var(--text); }
.rtable th, .rtable td { padding: 6px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable tr:nth-child(even) td { background: color-mix(in srgb, var(--panel2) 55%, transparent); }
.rtable td.num { text-align: right; color: var(--syn-num); } .rtable td.null { color: var(--text3); font-style: italic; }
.ohint { padding: 7px 12px; font-size: 12px; color: var(--accent2); background: var(--sel); border-top: 1px solid var(--line); flex: none; }
.ostatus { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 12px; border-top: 1px solid var(--line); background: var(--bg2); font-size: 12.5px; font-weight: 600; flex: none; }
.ostatus:empty { display: none; }
.ostatus .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); flex: none; }
.ostatus.ok .dot { background: var(--ok); } .ostatus.bad .dot { background: var(--bad); } .ostatus.warn .dot { background: var(--warn); }
.ostatus.busy .dot { background: var(--accent); animation: pulse .9s infinite; }
.ostatus .dim { font-weight: 450; }

/* status bar */
.statusbar { display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--bg2); border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text3); white-space: nowrap; overflow: hidden; }
.statusbar .net::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }
.statusbar .net.off::before { background: var(--warn); }
.statusbar .engine { overflow: hidden; text-overflow: ellipsis; }

/* bottom bar (phones) */
.bottombar { display: none; }

/* ---------- popups ---------- */
.menu { position: fixed; z-index: 60; min-width: 220px; padding: 6px; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; text-align: left; color: var(--text); }
.menu button:hover, .menu button:focus { background: var(--panel2); outline: none; }
.menu .ml { flex: 1; } .menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.menu .mhead { padding: 6px 10px 2px; font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.modal-back, .picker-back { position: fixed; inset: 0; z-index: 50; background: rgba(5,7,12,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); max-height: calc(var(--vvh) - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); }
.modal.wide { width: min(760px, 100%); }
.modal header { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px 18px; }
.modal header h3 { margin: 0; font-size: 16px; flex: 1; }
.modal .body { padding: 4px 18px 16px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; font-size: 12.5px; color: var(--text2); }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 44px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: var(--panel3); border: 1px solid var(--line2); box-shadow: var(--shadow); font-weight: 550; animation: fade .15s; }
.toast.bad { border-color: var(--bad); }
.tip { position: fixed; z-index: 80; pointer-events: none; padding: 5px 9px; border-radius: 7px; background: var(--panel3); border: 1px solid var(--line2); box-shadow: var(--shadow); font-size: 12px; max-width: 280px; }

/* picker & palette */
.picker { width: min(640px, 100%); height: min(640px, calc(var(--vvh) - 32px)); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.picker header { display: flex; align-items: baseline; gap: 10px; padding: 16px 12px 6px 18px; }
.picker header h3 { margin: 0; font-size: 16px; }
.picker header .pclose { margin-left: auto; align-self: center; }
.psearchrow { display: flex; align-items: center; gap: 8px; margin: 6px 14px 8px; padding: 0 10px; border: 1px solid var(--line2); border-radius: 10px; background: var(--bg2); }
.psearchrow:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--sel); }
.psearchrow svg.i { color: var(--text3); }
.psearch { flex: 1; border: 0 !important; background: transparent !important; box-shadow: none !important; height: 40px; font-size: 14.5px; padding: 0 !important; }
.plist { flex: 1; overflow: auto; padding: 0 8px 8px; }
.pgroup { padding: 12px 10px 4px; font-size: 11px; font-weight: 750; color: var(--text3); text-transform: uppercase; letter-spacing: .6px; }
.prow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 7px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; color: var(--text); }
.prow.sel { background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line2); }
.prow.cur .pname b::after { content: " ✓"; color: var(--accent); }
.prow.off { opacity: .55; }
.pname { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.pname b { font-size: 14px; font-weight: 650; }
.pname small { color: var(--text3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pwhere { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text2); white-space: nowrap; }
.pwhere small { color: var(--text3); }
.pfoot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text3); flex-wrap: wrap; }
.pfoot span { display: inline-flex; align-items: center; gap: 7px; }
.palette { height: auto; max-height: min(520px, calc(var(--vvh) - 32px)); align-self: start; margin-top: 10vh; }
.prow.pal { padding: 8px 10px; } .prow.pal svg.i { color: var(--text3); }

/* examples gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.excard { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text); min-width: 0; }
.excard:hover { border-color: var(--accent); }
.excard b { font-size: 13.5px; }
.excard pre { margin: 0; font: 11px/1.4 var(--mono); color: var(--text2); max-height: 92px; overflow: hidden; white-space: pre; mask-image: linear-gradient(#000 60%, transparent); }
.excard .tag { align-self: flex-start; font-size: 10.5px; color: var(--accent2); background: var(--sel); padding: 1px 7px; border-radius: 6px; }

/* settings, share, AI */
.setgrid { display: grid; grid-template-columns: 150px 1fr; gap: 12px 16px; align-items: center; }
.setgrid > label { color: var(--text2); font-size: 12.5px; }
.engrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.engrow .en { flex: 1; min-width: 0; }
.sharebox { display: flex; gap: 6px; margin: 4px 0 14px; }
.sharebox input { flex: 1; font-family: var(--mono); font-size: 12px; }
.ai-answer { min-height: 120px; }
.ai-wait { display: flex; align-items: center; gap: 10px; color: var(--text2); padding: 20px 0; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line2); border-top-color: var(--ai); animation: spin .8s linear infinite; display: inline-block; }
.ai-problem, .ai-err { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 12%, transparent); }
.ai-code { background: var(--ed-bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow: auto; max-height: 300px; font: 12.5px/1.5 var(--mono); }
.ai-row { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.md { line-height: 1.6; } .md code { font-family: var(--mono); font-size: .92em; background: var(--panel2); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--ed-bg); padding: 10px; border-radius: 8px; overflow: auto; }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: 13px; }

/* ---------- tablets ---------- */
@media (max-width: 1100px) { .brand small, .top .wtxt { display: none; } .langbtn .ln small { max-width: 130px; } }
@media (max-width: 900px) { .brand b { display: none; } .top .optional { display: none; } }

/* ---------- phones: one panel at a time ---------- */
body.phone #app { grid-template-rows: var(--top) 1fr auto; }
body.phone .top { gap: 4px; padding: 0 6px; }
body.phone .brand { margin-right: 0; }
body.phone .langbtn { flex: 1; max-width: none; }
body.phone .langbtn .ln small, body.phone .top .pal { display: none; }
body.phone .langbtn { padding-right: 6px; gap: 7px; }
body.phone .top > .sp { display: none; }
body.phone .where-seg button { padding: 4px 8px; }
body.phone .where-seg .wtxt { display: none; }
body.phone .btn.run { padding: 0 12px; } body.phone .btn.run kbd, body.phone .btn .btxt { display: none; }
body.phone .work { display: block; position: relative; }
body.phone .work > * { position: absolute; inset: 0; }
body.phone .splitter { display: none; }
body.phone .side { display: contents; }
body.phone .pane.code, body.phone .inbox, body.phone .outbox { display: none; }
body.phone .work[data-pane=code] .pane.code, body.phone .work[data-pane=input] .inbox, body.phone .work[data-pane=output] .outbox { display: flex; position: absolute; inset: 0; }
body.phone .inbox.collapsed textarea { display: block; }
body.phone .inbox .collapse { display: none; }
body.phone .symbar { display: flex; }
body.phone .statusbar { display: none; }
body.phone .bottombar { display: flex; background: var(--bg2); border-top: 1px solid var(--line); padding: 0 4px env(safe-area-inset-bottom); }
.bottombar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 54px; border: 0; background: transparent; color: var(--text3); font-size: 11.5px; font-weight: 600; position: relative; }
.bottombar button.on { color: var(--accent); }
.bottombar button .badge { position: absolute; top: 5px; left: calc(50% + 8px); }
body.phone.kbd .bottombar { display: none; }
body.phone .modal-back, body.phone .picker-back { padding: 0; place-items: stretch; }
body.phone .picker, body.phone .palette { width: 100%; height: var(--vvh); max-height: none; border-radius: 0; margin: 0; border: 0; }
body.phone .modal { width: 100%; max-height: var(--vvh); height: auto; align-self: end; border-radius: 16px 16px 0 0; }
body.phone .setgrid { grid-template-columns: 1fr; gap: 6px; }
body.phone .pfoot { gap: 8px 14px; }
body.phone .gallery { grid-template-columns: 1fr; }

/* ---------- embed (inside AeroGyan courses) ---------- */
body.embed #app { grid-template-rows: 42px minmax(0, 1fr) auto; }
body.embed .work { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.2fr) minmax(140px, 1fr); }
body.embed .work > .splitter.v { display: none; }
body.embed .side { grid-template-rows: auto 0 minmax(0, 1fr); }
body.embed .ftabs { display: none; }
body.embed .statusbar { display: none; }
body.embed .bottombar { display: none !important; }
.embedfoot { display: none; }
body.embed .embedfoot { display: flex; align-items: center; gap: 8px; padding: 4px 10px; font-size: 11.5px; color: var(--text3); background: var(--bg2); border-top: 1px solid var(--line); }
body.embed .embedfoot a { color: var(--accent2); text-decoration: none; }

/* account: email code + Sign in with AeroGyan (AeroGyan ID) */
.acct .btxt { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-modal { width: min(420px, calc(100vw - 32px)); }
.acct-sign { display: grid; gap: 12px; }
.acct-sign input { width: 100%; }
.acct-code { letter-spacing: 6px; font-size: 20px; text-align: center; }
.acct-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.acct-err { color: #ef4444; margin: 0; }
.btn.acct-aerogyan { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 40px; border-color: #6c8cff; font-weight: 600; }
.acct-or { display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: .75; }
.acct-or::before, .acct-or::after { content: ""; flex: 1; border-top: 1px solid currentColor; opacity: .35; }
@media (max-width: 520px) { .acct .btxt { display: none; } }
/* ---------- AeroGyan Labs (/lab, js/app/lab.js) ---------- */
body.lab .work { grid-template-columns: minmax(260px, var(--prob, 30%)) 6px minmax(0, 1fr) 6px minmax(280px, var(--side, 34%)); }
.pane.problem { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); border-right: 1px solid var(--line); }
.lab-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.lab-head h1 { font-size: 17px; margin: 2px 0 8px; line-height: 1.3; overflow-wrap: anywhere; }
.lab-course { color: var(--text3); font-size: 12px; }
.lab-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.lab-meta .chip, .lab-score .chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg3, rgba(127,127,127,.12)); color: var(--text2); border: 1px solid var(--line); }
.chip .ic { width: 14px; height: 14px; }
.chip.bad { color: var(--bad); border-color: currentColor; } .chip.ok { color: var(--ok); border-color: currentColor; }
.lab-body { overflow: auto; padding: 12px 14px 24px; min-height: 0; flex: 1; font-size: 14px; line-height: 1.55; }
.lab-body h2 { font-size: 14px; margin: 18px 0 8px; }
.lab-statement pre, .lab-io pre, .lab-msg { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow: auto; font: 12.5px/1.45 var(--mono, ui-monospace, monospace); white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; max-height: 240px; }
.lab-statement .math { font-style: italic; } .lab-statement .math.display { display: block; text-align: center; margin: 8px 0; }
.lab-statement table { border-collapse: collapse; } .lab-statement td, .lab-statement th { border: 1px solid var(--line); padding: 3px 8px; }
.lab-sample { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin: 6px 0; }
.lab-sample summary { cursor: pointer; font-weight: 600; }
.lab-io { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .lab-io b { font-size: 12px; color: var(--text2); }
.lab-tests { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.lab-test { border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 6px 10px; }
.lab-test.pass { border-left-color: var(--ok); } .lab-test.fail { border-left-color: var(--bad); } .lab-test.part { border-left-color: var(--warn); }
.lab-trow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lab-mark { font-weight: 800; width: 1.2em; text-align: center; }
.lab-test.pass .lab-mark { color: var(--ok); } .lab-test.fail .lab-mark { color: var(--bad); } .lab-test.part .lab-mark { color: var(--warn); }
.lab-score { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin: 12px 0 4px; }
.lab-score b { font-size: 26px; }
.lab-note { color: var(--text2); font-size: 13px; } .lab-note.bad { color: var(--bad); }
.lab-hint { margin-top: 16px; display: grid; gap: 8px; } .lab-hint textarea { width: 100%; }
.lab-hint-out { font-size: 13.5px; }
.lab-error { padding: 32px 20px; max-width: 520px; margin: 0 auto; text-align: center; }
.btn.lab-submit[disabled], .btn.lab-samples[disabled] { opacity: .5; cursor: not-allowed; }
.dim { color: var(--text3); }
body.phone.lab .pane.problem { display: none; border: 0; }
body.phone.lab .work[data-pane=problem] .pane.problem { display: flex; position: absolute; inset: 0; }
body.phone.lab .lab-io { grid-template-columns: 1fr; }
body.phone.lab .top .lab-samples { padding: 0 10px; }
@media (max-width: 1100px) { body.lab:not(.phone) .work { grid-template-columns: minmax(240px, 34%) 6px minmax(0, 1fr) 6px minmax(240px, 30%); } }
