/* Ganak — a calm numeric workspace. Dark by default, light on request. Colour marks running, errors and selection. */
:root {
  --bg: #0d1016; --bg2: #121620; --panel: #161b25; --panel2: #1c2230; --panel3: #222a3a; --line: #252d3c; --line2: #313b4e;
  --text: #e6e9ef; --text2: #a3acbd; --text3: #6b7488; --accent: #38bdf8; --accent2: #7dd3fc; --accent-ink: #04202e;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --run: #22c55e; --pause: #f59e0b; --sel: rgba(56,189,248,.28);
  --syn-kw: #c792ea; --syn-comment: #6f7d95; --syn-section: #7ee0c5; --syn-str: #e5c07b; --syn-num: #f78c6c; --syn-atom: #ff9cac; --syn-fn: #82aaff; --syn-op: #89ddff; --syn-bracket: #a3acbd;
  --cw-in: #9fb4d6; --cw-prompt: #38bdf8; --code-size: 13px;
  --radius: 8px; --shadow: 0 14px 40px rgba(0,0,0,.5);
  --font: "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Devanagari", monospace;
  color-scheme: dark;
}
:root[data-theme=light] {
  --bg: #eef1f6; --bg2: #f6f8fb; --panel: #ffffff; --panel2: #f2f5f9; --panel3: #e8edf4; --line: #dfe4ec; --line2: #cfd6e2;
  --text: #18202e; --text2: #4c5668; --text3: #8590a3; --accent: #0284c7; --accent2: #0369a1; --accent-ink: #ffffff;
  --ok: #059669; --warn: #b45309; --bad: #dc2626; --run: #16a34a; --pause: #d97706; --sel: rgba(2,132,199,.18);
  --syn-kw: #7c3aed; --syn-comment: #6b7a90; --syn-section: #0f766e; --syn-str: #a15c00; --syn-num: #c2410c; --syn-atom: #be185d; --syn-fn: #1d4ed8; --syn-op: #0e7490; --syn-bracket: #4c5668;
  --cw-in: #334e7a; --cw-prompt: #0284c7; --shadow: 0 14px 40px 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: 13px/1.4 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
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; }
.muted { color: var(--text2); } .dim { color: var(--text3); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.logo { width: 22px; height: 22px; }
::-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; }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--text3); background: var(--panel3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.run { background: var(--run); border-color: var(--run); color: #052e12; font-weight: 650; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn.danger { color: var(--bad); }
.btn.primary.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn:disabled, .ibtn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.ibtn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--text2); padding: 0; }
.ibtn:hover { background: var(--panel2); color: var(--text); }
.ibtn.on { color: var(--accent); background: var(--sel); }
.ibtn.sm { width: 22px; height: 22px; border-radius: 5px; } .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: 6px; padding: 4px 8px; min-width: 0; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
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: 7px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text2); padding: 3px 10px; border-radius: 5px; font-size: 12px; }
.seg button.on { background: var(--panel3); color: var(--text); box-shadow: 0 0 0 1px var(--line2); }

/* ---------- desktop frame ---------- */
#app { height: 100vh; display: grid; grid-template-rows: 42px 1fr 24px; }
.topbar { display: flex; align-items: center; gap: 4px; padding: 0 8px; background: var(--bg2); border-bottom: 1px solid var(--line); min-width: 0; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; letter-spacing: .2px; margin: 0 8px 0 2px; white-space: nowrap; }
.brand small { font-weight: 500; color: var(--text3); }
.topbar .sep { width: 1px; height: 20px; background: var(--line2); margin: 0 5px; flex: none; }
.topbar .sp { flex: 1; }
.dbg { display: flex; gap: 2px; align-items: center; padding: 2px 4px; border-radius: 8px; background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35); }
.dbg .lbl { font-size: 11.5px; color: var(--pause); font-weight: 650; margin: 0 4px; white-space: nowrap; }
.desk { display: grid; min-height: 0; grid-template-columns: var(--left-w, 240px) 4px minmax(0, 1fr) 4px var(--right-w, 400px); }
.desk.no-left { grid-template-columns: 0 0 minmax(0, 1fr) 4px var(--right-w, 400px); }
.desk.no-right { grid-template-columns: var(--left-w, 240px) 4px minmax(0, 1fr) 0 0; }
.desk.no-left.no-right { grid-template-columns: 0 0 minmax(0, 1fr) 0 0; }
.col { display: grid; min-height: 0; min-width: 0; }
.col.center { grid-template-rows: minmax(0, 1fr) 4px var(--cmd-h, 38%); }
.col.right { grid-template-rows: var(--rt-h, 44%) 4px minmax(0, 1fr); }
.col.left { grid-template-rows: minmax(0, 1fr); }
.split-v { cursor: col-resize; background: var(--bg); } .split-h { cursor: row-resize; background: var(--bg); }
.split-v:hover, .split-h:hover { background: var(--accent); }
.panel { background: var(--panel); min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.phead { display: flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px 0 10px; border-bottom: 1px solid var(--line); flex: none; background: var(--panel); }
.phead > b { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text2); font-weight: 650; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.phead .sp { flex: 1; }
.pbody { flex: 1; overflow: auto; min-height: 0; position: relative; }
.empty { padding: 26px 18px; text-align: center; color: var(--text3); line-height: 1.6; }
.ptabs { display: flex; gap: 0; align-items: stretch; height: 32px; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; overflow-y: hidden; background: var(--bg2); scrollbar-width: none; }
.ptabs::-webkit-scrollbar { display: none; }
.ptab { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px 0 11px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--text2); white-space: nowrap; font-size: 12.5px; position: relative; max-width: 220px; }
.ptab > span.nm { overflow: hidden; text-overflow: ellipsis; }
.ptab:hover { color: var(--text); background: var(--panel2); }
.ptab.on { color: var(--text); background: var(--panel); box-shadow: inset 0 2px 0 var(--accent); }
.ptab .x { width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center; color: var(--text3); }
.ptab .x:hover { background: var(--panel3); color: var(--text); }
.ptab .x svg.i { width: 12px; height: 12px; }
.ptab.dirty .x::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text2); }
.ptab.dirty .x svg { display: none; } .ptab.dirty .x:hover::before { display: none; } .ptab.dirty .x:hover svg { display: block; }
.ptab svg.i { width: 14px; height: 14px; }
.ptab.paused { box-shadow: inset 0 2px 0 var(--pause); }
.statusbar { display: flex; align-items: center; gap: 14px; padding: 0 10px; background: var(--bg2); border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text2); white-space: nowrap; overflow: hidden; }
.statusbar .sp { flex: 1; }
.statusbar button { border: 0; background: none; color: inherit; padding: 0 4px; font-size: 11.5px; }
.statusbar button:hover { color: var(--text); }
.st-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 0; }
.st-busy .st-dot { background: var(--run); animation: pulse 1s infinite; } .st-paused .st-dot { background: var(--pause); } .st-input .st-dot { background: var(--accent); animation: pulse 1.4s infinite; } .st-starting .st-dot { background: var(--text3); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- command window ---------- */
.cw { font: var(--code-size)/1.45 var(--mono); }
.cw .phead { font: 13px/1.4 var(--font); }
.figbody > .empty { position: absolute; inset: 0; display: grid; place-items: center; }
.cw .pbody { padding: 6px 0 0; cursor: text; }
.cw-out { padding: 0 12px; }
.cw-out pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
.cw-echo { color: var(--cw-in); }
.cw-echo .pr { color: var(--cw-prompt); user-select: none; }
.cw-warn { color: var(--warn); }
.cw-err { color: var(--bad); }
.cw-stderr { color: var(--bad); }
.cw-note { color: var(--text3); font-style: italic; }
.cw-err a, .cw-warn a { color: var(--accent2); text-decoration: underline; cursor: pointer; }
.cw-err .eid { color: var(--text3); font-size: .9em; }
.cw-trim { color: var(--text3); font-style: italic; padding: 2px 0 6px; }
.cw-in { display: flex; align-items: flex-start; gap: 6px; padding: 2px 12px 40px; }
.cw-in .pr { color: var(--cw-prompt); user-select: none; padding-top: 1px; min-width: 2ch; white-space: pre; }
.cw-in .pr.k { color: var(--pause); }
.cw-in .pr.ask { color: var(--text); }
.cw-in .cm-editor { flex: 1; min-width: 0; background: transparent; }
.cw-in .cm-editor.cm-focused { outline: none; }
.cw-in .cm-content { padding: 0; font: var(--code-size)/1.45 var(--mono); }
.cw-in .cm-line { padding: 0; }
.cw.busy .cw-in .pr { opacity: .35; }
.cw .busybar { height: 2px; background: linear-gradient(90deg, transparent, var(--run), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: busy 1.1s linear infinite; visibility: hidden; flex: none; }
.cw.busy .busybar { visibility: visible; }
@keyframes busy { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.cw-keywait { margin: 2px 12px; padding: 4px 8px; border-radius: 6px; background: var(--sel); color: var(--text); display: inline-block; font-family: var(--font); font-size: 12px; }

/* ---------- editor ---------- */
.editor-area { position: relative; }
.ed-host { flex: 1; min-height: 0; position: relative; }
.ed-host > .view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ed-host .cm-editor { height: 100%; font-size: var(--code-size); background: var(--panel); }
.cm-editor .cm-scroller { font-family: var(--mono); line-height: 1.5; }
.cm-editor .cm-gutters { background: var(--panel); border-right: 1px solid var(--line); color: var(--text3); }
.cm-editor .cm-activeLineGutter { background: var(--panel2); color: var(--text2); }
.cm-editor .cm-activeLine { background: rgba(127,140,170,.07); }
.cm-editor .cm-cursor { border-left-color: var(--accent); border-left-width: 2px; }
.cm-editor .cm-selectionBackground, .cm-editor.cm-focused .cm-selectionBackground { background: var(--sel) !important; }
.cm-editor .cm-matchingBracket { background: rgba(125,211,252,.18); outline: 1px solid rgba(125,211,252,.45); }
.cm-editor .cm-foldPlaceholder { background: var(--panel3); border: 1px solid var(--line2); color: var(--text2); border-radius: 4px; padding: 0 6px; }
.cm-editor .cm-foldGutter span { color: var(--text3); }
.cm-editor .cm-panels { background: var(--panel2); color: var(--text); border-color: var(--line2); }
.cm-editor .cm-panel.cm-search { padding: 6px 8px; font-family: var(--font); }
.cm-editor .cm-panel.cm-search input, .cm-editor .cm-panel.cm-search button { font-size: 12px; }
.cm-editor .cm-textfield { background: var(--bg2); border: 1px solid var(--line2); border-radius: 5px; color: var(--text); }
.cm-editor .cm-button { background: var(--panel3); border: 1px solid var(--line2); border-radius: 5px; color: var(--text); background-image: none; }
.cm-editor .cm-searchMatch { background: rgba(250,204,21,.25); } .cm-editor .cm-searchMatch-selected { background: rgba(250,204,21,.5); }
.cm-editor .cm-selectionMatch { background: rgba(125,211,252,.12); }
.cm-tooltip { background: var(--panel2) !important; border: 1px solid var(--line2) !important; border-radius: 8px; box-shadow: var(--shadow); color: var(--text); }
.cm-tooltip-autocomplete ul li[aria-selected] { background: var(--accent) !important; color: var(--accent-ink) !important; }
.cm-tooltip-autocomplete ul { font-family: var(--mono); font-size: 12.5px; }
.cm-completionDetail { color: var(--text3); font-style: normal !important; margin-left: 12px !important; }
.cm-tooltip-autocomplete ul li[aria-selected] .cm-completionDetail { color: inherit; opacity: .8; }
.cm-diagnostic-error { border-left-color: var(--bad) !important; }
.cm-lintRange-error { background-image: none !important; text-decoration: underline wavy var(--bad); text-underline-offset: 3px; }
.cm-bp-gutter { width: 16px; cursor: pointer; }
.cm-bp-gutter .cm-gutterElement { display: flex; align-items: center; justify-content: center; }
.cm-bp-gutter .cm-gutterElement:hover::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: rgba(248,113,113,.35); }
.bp-mark { width: 11px; height: 11px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 1.5px rgba(0,0,0,.25); }
.cm-bp-gutter .cm-gutterElement:has(.bp-mark):hover::after { display: none; }
.cm-pausedLine { background: rgba(245,158,11,.22) !important; box-shadow: inset 3px 0 0 var(--pause); }
.pause-arrow { color: var(--pause); font-size: 12px; line-height: 1; }
.cm-errorLine { background: rgba(248,113,113,.10); }
.cm-sectionLine { border-top: 1px solid var(--line2); }
.cm-curSection { background: rgba(126,224,197,.035); }
.ed-bar { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--text2); flex: none; background: var(--panel); }
.ed-bar .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11.5px; color: var(--text3); }
.ed-bar .sp { flex: 1; }

/* ---------- workspace ---------- */
.wtable { user-select: none; width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; }
.wtable th { position: sticky; top: 0; z-index: 1; background: var(--panel2); text-align: left; font-weight: 600; color: var(--text2); font-size: 11.5px; padding: 5px 8px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wtable th.sorted::after { content: ' ▾'; color: var(--accent); } .wtable th.sorted.up::after { content: ' ▴'; }
.wtable td { padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wtable td.v { font-family: var(--mono); font-size: 12px; color: var(--text2); }
.wtable td.n { font-weight: 600; } .wtable td.n svg.i { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; color: var(--text3); }
.wtable tr:hover td { background: var(--panel2); }
.wtable tr.sel td { background: var(--sel); }
.wtable tr.changed td.n { color: var(--accent2); }
.ws-filter { margin: 6px 8px; width: calc(100% - 16px); }

/* ---------- variable editor ---------- */
.vedit { display: flex; flex-direction: column; height: 100%; }
.vedit .vtools { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex: none; font-size: 12px; color: var(--text2); }
.vedit .vtools b { color: var(--text); font-family: var(--mono); font-size: 13px; }
.vgrid { flex: 1; overflow: auto; position: relative; font: 12.5px var(--mono); outline: none; }
.vgrid .vinner { position: relative; }
.vgrid .c { position: absolute; height: 24px; line-height: 24px; padding: 0 8px; text-align: right; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: var(--panel); }
.vgrid .c.h { background: var(--panel2); color: var(--text3); text-align: center; position: absolute; z-index: 2; font-family: var(--font); font-size: 11.5px; }
.vgrid .c.corner { z-index: 3; }
.vgrid .c.sel { background: var(--sel); outline: 1.5px solid var(--accent); outline-offset: -1.5px; z-index: 1; }
.vgrid .c.txt { text-align: left; }
.vgrid input.cedit { position: absolute; height: 24px; border-radius: 0; z-index: 4; text-align: right; font: 12.5px var(--mono); padding: 0 7px; border: 2px solid var(--accent); background: var(--bg2); }
.vtree { padding: 6px 0; font-size: 12.5px; overflow: auto; flex: 1; }
.vtree .tr { display: grid; grid-template-columns: minmax(140px, 32%) 90px 1fr; gap: 8px; align-items: center; padding: 3px 10px; cursor: default; border-bottom: 1px solid var(--line); }
.vtree .tr:hover { background: var(--panel2); }
.vtree .tr .k { display: flex; align-items: center; gap: 4px; font-family: var(--mono); overflow: hidden; white-space: nowrap; }
.vtree .tr .k button { width: 16px; height: 16px; border: 0; background: none; color: var(--text3); padding: 0; display: grid; place-items: center; }
.vtree .tr .k button svg.i { width: 12px; height: 12px; transition: transform .12s; }
.vtree .tr.open > .k button svg.i { transform: rotate(90deg); }
.vtree .tr .cl { color: var(--text3); font-size: 11.5px; }
.vtree .tr .val { font-family: var(--mono); color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtree .tr .val[contenteditable=true] { color: var(--text); outline: 1px solid var(--accent); background: var(--bg2); padding: 0 4px; border-radius: 3px; }

/* ---------- files ---------- */
.crumbs { display: flex; align-items: center; gap: 2px; padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 12px; overflow-x: auto; white-space: nowrap; flex: none; scrollbar-width: none; }
.crumbs button { border: 0; background: none; color: var(--text2); padding: 2px 4px; border-radius: 4px; }
.crumbs button:hover { color: var(--text); background: var(--panel2); }
.crumbs .s { color: var(--text3); }
.flist { padding: 4px 0; }
.frow { display: flex; align-items: center; gap: 7px; padding: 3px 10px; cursor: default; user-select: none; font-size: 12.5px; white-space: nowrap; border: 1px solid transparent; }
.frow:hover { background: var(--panel2); }
.frow.sel { background: var(--sel); }
.frow .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.frow .sz { color: var(--text3); font-size: 11px; }
.frow svg.i { width: 15px; height: 15px; color: var(--text3); }
.frow.dir svg.i { color: #f2c66d; } .frow.m svg.i { color: var(--accent); } .frow.gnb svg.i { color: #a78bfa; } .frow.mat svg.i { color: var(--ok); }
.frow.drop { border-color: var(--accent); }
.fdrop { margin: 10px; padding: 18px 10px; border: 1.5px dashed var(--line2); border-radius: 10px; text-align: center; color: var(--text3); font-size: 12px; }
.panel.dragover .fdrop, .panel.dragover .flist { border-color: var(--accent); background: rgba(56,189,248,.05); }
.mount-note { margin: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg2); font-size: 12px; color: var(--text2); display: grid; gap: 6px; }

/* ---------- figures ---------- */
.figdock { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.figbody { flex: 1; min-height: 0; position: relative; background: var(--panel); }
.figbody > .fig { position: absolute; inset: 0; }
.fig .figcanvas { position: absolute; inset: 0; }
.fig-missing { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text3); padding: 20px; font-size: 12.5px; line-height: 1.6; }
.figwin { position: fixed; z-index: 70; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; resize: both; min-width: 260px; min-height: 200px; }
.figwin > header { display: flex; align-items: center; gap: 4px; height: 32px; padding: 0 4px 0 10px; border-bottom: 1px solid var(--line); cursor: move; user-select: none; flex: none; font-size: 12.5px; font-weight: 600; }
.figwin > header .sp { flex: 1; }
.figwin .figbody { flex: 1; }
.cell-fig { position: relative; height: 320px; max-width: 640px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); margin: 6px 0; }
.cell-fig img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---------- live scripts ---------- */
.nb { height: 100%; overflow: auto; background: var(--bg2); }
.nb-inner { max-width: 920px; margin: 0 auto; padding: 18px 26px 120px; }
.nb-cell { position: relative; margin: 6px 0; border: 1px solid transparent; border-radius: 10px; padding: 4px 6px 4px 34px; }
.nb-cell:hover { border-color: var(--line); }
.nb-cell.cur { border-color: var(--line2); background: var(--panel); }
.nb-cell .gut { position: absolute; left: 4px; top: 6px; display: flex; flex-direction: column; gap: 2px; }
.nb-cell .gut .ibtn { width: 24px; height: 24px; }
.nb-cell .ctools { position: absolute; right: 6px; top: -12px; display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line2); border-radius: 7px; padding: 1px; z-index: 2; }
.nb-cell:hover .ctools, .nb-cell.cur .ctools { display: flex; }
.nb-code .cm-editor { border: 1px solid var(--line2); border-radius: 7px; background: var(--panel); font-size: var(--code-size); }
.nb-code .cm-editor.cm-focused { border-color: var(--accent); outline: none; }
.nb-code .cm-gutters { display: none; }
.nb-code .cm-content { padding: 6px 4px; }
.nb-cell .count { position: absolute; left: 6px; top: 34px; font: 10px var(--mono); color: var(--text3); width: 22px; text-align: center; }
.nb-cell.running .count { color: var(--run); }
.nb-out { margin: 4px 0 2px; font: var(--code-size)/1.45 var(--mono); }
.nb-out pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
.nb-out .err { color: var(--bad); } .nb-out .wrn { color: var(--warn); }
.nb-md { line-height: 1.6; font-size: 14.5px; padding: 2px 4px; min-height: 26px; cursor: text; }
.nb-md:empty::before { content: attr(data-ph); color: var(--text3); }
.nb-md h1 { font-size: 26px; margin: 8px 0 6px; } .nb-md h2 { font-size: 20px; margin: 8px 0 4px; } .nb-md h3 { font-size: 16.5px; margin: 6px 0 4px; }
.nb-md p { margin: 6px 0; } .nb-md code { font-family: var(--mono); font-size: .9em; background: var(--panel3); padding: 1px 5px; border-radius: 4px; }
.nb-md pre { background: var(--panel3); padding: 8px 10px; border-radius: 6px; overflow: auto; } .nb-md pre code { background: none; padding: 0; }
.nb-md blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--line2); color: var(--text2); }
.nb-md a { color: var(--accent2); }
.nb-md table { border-collapse: collapse; } .nb-md td, .nb-md th { border: 1px solid var(--line2); padding: 3px 8px; }
.nb-mdedit .cm-editor { border: 1px dashed var(--line2); border-radius: 7px; background: var(--panel); font-size: 13.5px; }
.nb-add { display: flex; gap: 6px; justify-content: center; opacity: 0; transition: opacity .15s; padding: 2px 0; }
.nb-add:hover, .nb-inner:hover > .nb-add:last-child { opacity: 1; }
.nb-title { font-size: 12px; color: var(--text3); margin-bottom: 8px; }
/* maths */
.math { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", Georgia, serif; font-size: 1.08em; white-space: nowrap; }
.math i { font-style: italic; } .math .up { font-style: normal; }
.math.display { display: block; text-align: center; margin: 10px 0; font-size: 1.2em; }
.math .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; }
.math .frac > span { padding: 0 3px; line-height: 1.15; } .math .frac > span:first-child { border-bottom: 1px solid currentColor; }
.math .sqrt { display: inline-flex; align-items: flex-start; } .math .sqrt > span { border-top: 1px solid currentColor; padding: 0 2px; margin-top: .12em; }
.math sup, .math sub { font-size: .72em; }
.math .big { font-size: 1.4em; vertical-align: -.15em; }

/* ---------- help ---------- */
.help { padding: 14px 18px 40px; line-height: 1.55; font-size: 13.5px; }
.help h1 { font-size: 22px; margin: 0 0 2px; font-family: var(--mono); }
.help .cat { color: var(--text3); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.help pre { font: 12.5px/1.5 var(--mono); background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin: 8px 0; white-space: pre-wrap; }
.help .hi { color: var(--text2); }
.help .actions { display: flex; gap: 6px; }
.help .na { color: var(--warn); font-size: 12.5px; }
.hbrowse { display: flex; flex-direction: column; height: 100%; }
.hbrowse .hsearch { margin: 8px; }
.hbrowse .hlist { flex: 1; overflow: auto; padding: 0 0 20px; }
.hbrowse .hcat { padding: 10px 12px 3px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); font-weight: 650; }
.hbrowse .hitem { display: flex; gap: 10px; width: 100%; padding: 4px 12px; border: 0; background: none; color: var(--text); text-align: left; font-size: 12.5px; }
.hbrowse .hitem:hover { background: var(--panel2); }
.hbrowse .hitem b { font-family: var(--mono); font-weight: 600; min-width: 92px; }
.hbrowse .hitem span { color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbrowse .hitem.na b { color: var(--text3); }

/* ---------- start page ---------- */
.home { height: 100%; overflow: auto; background: radial-gradient(900px 380px at 15% -10%, rgba(56,189,248,.10), transparent), radial-gradient(700px 300px at 95% 0%, rgba(167,139,250,.08), transparent), var(--panel); }
.home .wrap { max-width: 1060px; margin: 0 auto; padding: 26px 26px 60px; }
.home .hero { display: flex; align-items: center; gap: 14px; }
.home .hero .logo { width: 44px; height: 44px; }
.home .hero h1 { margin: 0; font-size: 26px; letter-spacing: .2px; }
.home .hero h1 small { font-weight: 500; color: var(--text3); font-size: 18px; margin-left: 6px; }
.home .tag { color: var(--text2); margin: 6px 0 0; max-width: 680px; line-height: 1.55; }
.home .hero .sp { flex: 1; }
.home h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); margin: 26px 0 10px; font-weight: 650; }
.newrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.newcard { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line2); background: var(--bg2); border-radius: 12px; text-align: left; color: var(--text); }
.newcard:hover { border-color: var(--accent); }
.newcard .ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--sel); color: var(--accent); flex: none; }
.newcard .ic svg.i { width: 20px; height: 20px; }
.newcard b { display: block; font-size: 13px; } .newcard small { color: var(--text3); font-size: 11.5px; }
.recent { display: grid; gap: 2px; }
.recent button { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); text-align: left; }
.recent button:hover { background: var(--panel2); }
.recent button small { color: var(--text3); font-family: var(--mono); font-size: 11.5px; margin-left: auto; }
.exgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.excard { border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; overflow: hidden; text-align: left; padding: 0; color: var(--text); display: flex; flex-direction: column; }
.excard:hover { border-color: var(--accent); transform: translateY(-1px); }
.excard .art { height: 92px; background: var(--panel2); display: grid; place-items: center; color: var(--accent); border-bottom: 1px solid var(--line); }
.excard .art svg { width: 100%; height: 100%; }
.excard .info { padding: 9px 11px 11px; } .excard b { font-size: 13px; display: block; } .excard small { color: var(--text3); font-size: 11.5px; line-height: 1.4; display: block; margin-top: 2px; }

/* ---------- popups ---------- */
.menu { position: fixed; z-index: 100; min-width: 210px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 9px; box-shadow: var(--shadow); padding: 5px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 9px; border: 0; background: none; color: var(--text); text-align: left; padding: 6px 9px; border-radius: 6px; font-size: 12.5px; }
.menu button .ml { flex: 1; }
.menu button:hover, .menu button:focus { background: var(--panel3); outline: none; }
.menu button kbd { margin-left: 16px; }
.menu hr { border: 0; border-top: 1px solid var(--line2); margin: 4px 2px; }
.menu .mhead { padding: 5px 9px 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 90; }
.modal { width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); }
.modal.wide { width: min(780px, calc(100vw - 32px)); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 15px; flex: 1; }
.modal .body { padding: 14px 16px; display: grid; gap: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 5px; } .field > span { font-size: 12px; color: var(--text2); }
.setrow { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: center; min-height: 32px; }
.setrow > label { color: var(--text2); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 26px; }
.keys .k { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.keys h4 { grid-column: 1 / -1; margin: 10px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); }
.toast { position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%); background: var(--panel3); border: 1px solid var(--line2); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow); z-index: 120; font-size: 13px; max-width: 80vw; display: flex; gap: 12px; align-items: center; }
.toast.bad { border-color: var(--bad); }
.tip { position: fixed; z-index: 130; background: var(--panel3); border: 1px solid var(--line2); padding: 4px 8px; border-radius: 6px; font-size: 12px; pointer-events: none; white-space: nowrap; box-shadow: var(--shadow); }

/* printing a live script (Export → PDF) */
@media print {
  html, body { overflow: visible; height: auto; background: #fff; color: #000; }
  body > :not(.print-root) { display: none !important; }
  .print-root { display: block !important; }
}
.print-root { display: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 900px) { .desk { grid-template-columns: 0 0 minmax(0, 1fr) 0 0; } .topbar .wide-only { display: none; } }
