:root{
  --bg-0:#12151b; --bg-1:#191d25; --bg-2:#1f2530; --bg-3:#262d3a;
  --line:#2c3342; --line-soft:#232936;
  --text-0:#e9ecf3; --text-1:#9aa4b8; --text-2:#5c6577;
  --copper:#c17a4a; --copper-bright:#e0985f;
  --teal:#35d0c0; --teal-dim:#1f8478;
  --amber:#eab24d; --red:#e2555a; --green:#59c97a;
  --radius:6px;
  --mono:'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --disp:'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
}

/* ---------- LIGHT THEME OVERRIDES ---------- */
[data-theme="light"]{
  --bg-0:#f4f5f8; --bg-1:#ffffff; --bg-2:#eef0f4; --bg-3:#e4e7ee;
  --line:#d7dbe3; --line-soft:#e4e7ee;
  --text-0:#1c212b; --text-1:#555f72; --text-2:#8791a3;
  --copper:#a85f2e; --copper-bright:#c17a4a;
  --teal:#0f9e8f; --teal-dim:#0c7e72;
  --amber:#b8811f; --red:#c73c41; --green:#2f9a55;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0; background:var(--bg-0); color:var(--text-0);
  font-family:var(--disp); overflow:auto; -webkit-font-smoothing:antialiased;
  transition:background .15s ease, color .15s ease;
}
::selection{background:var(--teal-dim); color:#fff;}
button{font-family:var(--disp);}
input, select{font-family:var(--mono);}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar{width:10px; height:10px;}
::-webkit-scrollbar-track{background:var(--bg-1);}
::-webkit-scrollbar-thumb{background:var(--bg-3); border-radius:5px; border:2px solid var(--bg-1);}
::-webkit-scrollbar-thumb:hover{background:var(--line);}

/* ============================== APP SHELL ============================== */
#app{
  display:grid;
  grid-template-rows:52px 1fr 190px;
  grid-template-columns:1fr;
  height:100vh; width:100vw;
}

/* ============================== TOPBAR ============================== */
#topbar{
  grid-row:1; display:flex; align-items:center; gap:14px;
  background:linear-gradient(180deg,var(--bg-2),var(--bg-1));
  border-bottom:1px solid var(--line); padding:0 16px;
  position:relative; z-index:30;
}
.brand{
  display:flex; align-items:center; gap:9px; margin-right:6px;
  font-weight:700; font-size:16px; letter-spacing:.2px; color:var(--text-0);
}
.brand .mark{
  width:22px; height:22px; border-radius:5px;
  background:conic-gradient(from 220deg, var(--teal), var(--copper), var(--teal));
  position:relative; box-shadow:0 0 0 1px rgba(255,255,255,.08) inset;
}
.brand .mark::after{
  content:""; position:absolute; inset:6px; background:var(--bg-0); border-radius:3px;
}
.brand small{font-weight:500; color:var(--text-2); font-size:10px; letter-spacing:1.5px; text-transform:uppercase;}

.topbar-div{width:1px; height:26px; background:var(--line); margin:0 4px;}

.tbtn{
  display:flex; align-items:center; gap:6px;
  background:var(--bg-2); border:1px solid var(--line); color:var(--text-1);
  padding:7px 12px; border-radius:var(--radius); cursor:pointer;
  font-size:12.5px; font-weight:600; letter-spacing:.2px;
  transition:background .12s, color .12s, border-color .12s, transform .06s;
  white-space:nowrap; user-select:none;
}
.tbtn:hover{background:var(--bg-3); color:var(--text-0); border-color:#3a4356;}
.tbtn:active{transform:translateY(1px);}
.tbtn svg{width:14px; height:14px; flex:none;}
.tbtn.primary{background:linear-gradient(180deg,#2c8f7f,#1f8478); border-color:#2c8f7f; color:#eafffb;}
.tbtn.primary:hover{background:linear-gradient(180deg,#33a692,#238b7e);}
.tbtn.danger-run{background:linear-gradient(180deg,#c65357,#a63e42); border-color:#c65357; color:#fff0ef;}
.tbtn.ghost{background:transparent; border-color:transparent;}
.tbtn.ghost:hover{background:var(--bg-2); border-color:var(--line);}
.tbtn.active{background:var(--teal-dim); border-color:var(--teal); color:#eafffb;}
.tbtn[disabled]{opacity:.4; cursor:not-allowed; pointer-events:none;}

/* theme toggle icon swap — only the icon matching the *current*
   theme is shown (moon while dark, sun while light) */
.theme-toggle{position:relative;}
.theme-icon{font-size:14px;}
.theme-icon-moon{display:inline-block;}
.theme-icon-sun{display:none;}
[data-theme="light"] .theme-icon-sun{display:inline-block; color:var(--amber);}
[data-theme="light"] .theme-icon-moon{display:none;}

/* realistic/schematic rocker toggle — signature element */
.view-toggle{
  display:flex; align-items:center; gap:8px; padding:4px; background:var(--bg-2);
  border:1px solid var(--line); border-radius:999px; position:relative;
}
.view-toggle .vt-label{font-size:10.5px; font-weight:700; letter-spacing:1px; text-transform:uppercase; color:var(--text-2); padding:0 8px;}
.view-toggle .vt-label.on{color:var(--copper-bright);}
.rocker{
  width:46px; height:24px; border-radius:999px; background:var(--bg-3);
  border:1px solid var(--line); position:relative; cursor:pointer;
  box-shadow:inset 0 2px 4px rgba(0,0,0,.4);
}
.rocker .knob{
  position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%;
  background:linear-gradient(180deg,#f0d9c3,var(--copper)); transition:left .18s cubic-bezier(.4,0,.2,1);
  box-shadow:0 1px 3px rgba(0,0,0,.5), 0 0 0 1px rgba(0,0,0,.2);
}
.rocker.on .knob{left:24px; background:linear-gradient(180deg,#bff5ea,var(--teal));}

.tb-spacer{flex:1;}
#zoomreadout{font-family:var(--mono); font-size:11.5px; color:var(--text-2); width:46px; text-align:center;}

.simstat{
  display:flex; align-items:center; gap:7px; font-family:var(--mono); font-size:11px;
  color:var(--text-2); padding:6px 10px; border:1px solid var(--line); border-radius:var(--radius); background:var(--bg-2);
}
.simstat .dot{width:7px; height:7px; border-radius:50%; background:var(--text-2); box-shadow:0 0 0 0 rgba(53,208,192,0);}
.simstat.live .dot{background:var(--teal); box-shadow:0 0 8px 1px var(--teal); animation:pulse 1.1s infinite;}
@keyframes pulse{0%,100%{opacity:1;}50%{opacity:.4;}}

/* ---------- SPEED BAR (slider) ---------- */
.speed-control{
  display:flex; align-items:center; gap:8px; background:var(--bg-2); border:1px solid var(--line);
  border-radius:var(--radius); padding:4px 10px; height:34px;
}
.speed-control label{font-size:10px; font-weight:700; letter-spacing:.7px; text-transform:uppercase; color:var(--text-2);}
.speed-control .sp-end{font-family:var(--mono); font-size:9.5px; color:var(--text-2); user-select:none;}
.speed-control output{
  font-family:var(--mono); font-size:11.5px; font-weight:600; color:var(--teal);
  min-width:44px; text-align:right;
}

.speed-control input[type=range]{
  -webkit-appearance:none; appearance:none;
  width:120px; height:18px; margin:0; background:transparent; cursor:pointer; outline:none;
  --fill:11.1%;
}
/* track — WebKit/Blink */
.speed-control input[type=range]::-webkit-slider-runnable-track{
  height:4px; border-radius:999px;
  background:linear-gradient(90deg, var(--teal) 0, var(--teal) var(--fill), var(--bg-3) var(--fill), var(--bg-3) 100%);
  box-shadow:inset 0 0 0 1px var(--line);
}
/* thumb — WebKit/Blink */
.speed-control input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none;
  width:14px; height:14px; margin-top:-5px; border-radius:50%;
  background:linear-gradient(180deg,#bff5ea,var(--teal));
  border:1px solid var(--teal-dim);
  box-shadow:0 1px 3px rgba(0,0,0,.5);
  transition:transform .1s;
}
.speed-control input[type=range]:hover::-webkit-slider-thumb{transform:scale(1.15);}
.speed-control input[type=range]:active::-webkit-slider-thumb{transform:scale(1.25);}
.speed-control input[type=range]:focus-visible::-webkit-slider-thumb{outline:2px solid var(--teal); outline-offset:2px;}
/* track + thumb — Firefox */
.speed-control input[type=range]::-moz-range-track{
  height:4px; border-radius:999px; background:var(--bg-3); box-shadow:inset 0 0 0 1px var(--line);
}
.speed-control input[type=range]::-moz-range-progress{
  height:4px; border-radius:999px; background:var(--teal);
}
.speed-control input[type=range]::-moz-range-thumb{
  width:12px; height:12px; border-radius:50%;
  background:linear-gradient(180deg,#bff5ea,var(--teal));
  border:1px solid var(--teal-dim); box-shadow:0 1px 3px rgba(0,0,0,.5);
}
.speed-control input[type=range]:focus-visible::-moz-range-thumb{outline:2px solid var(--teal); outline-offset:2px;}

/* ============================== MAIN GRID ============================== */
#main{
  grid-row:2; display:grid; grid-template-columns:216px 1fr 264px;
  min-height:0; border-bottom:1px solid var(--line);
}

/* ---------- PARTS PALETTE ---------- */
#palette{
  background:var(--bg-1); border-right:1px solid var(--line);
  overflow-y:auto; padding:10px 8px 40px;
}
.palette-search{
  display:flex; align-items:center; gap:6px; background:var(--bg-3); border:1px solid var(--line);
  border-radius:var(--radius); padding:6px 9px; margin:2px 2px 12px;
}
.palette-search input{
  background:transparent; border:none; outline:none; color:var(--text-0); font-size:12px; width:100%;
}
.palette-search svg{width:13px; height:13px; color:var(--text-2); flex:none;}

.pcat{margin-bottom:4px;}
.pcat-head{
  display:flex; align-items:center; justify-content:space-between; padding:7px 6px;
  font-size:10.5px; font-weight:700; letter-spacing:1.1px; text-transform:uppercase;
  color:var(--text-2); cursor:pointer; user-select:none;
}
.pcat-head:hover{color:var(--text-1);}
.pcat-head .chev{transition:transform .15s; font-size:9px;}
.pcat.collapsed .chev{transform:rotate(-90deg);}
.pcat.collapsed .pcat-body{display:none;}
.pcat-body{display:grid; grid-template-columns:1fr 1fr; gap:6px; padding:2px 2px 10px;}

.part{
  background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius);
  padding:8px 4px 6px; display:flex; flex-direction:column; align-items:center; gap:5px;
  cursor:grab; transition:border-color .12s, background .12s, transform .08s;
}
.part:hover{border-color:var(--copper); background:var(--bg-3);}
.part:active{cursor:grabbing; transform:scale(.96);}
.part canvas{pointer-events:none; display:block;}
.part span{font-size:9.5px; color:var(--text-1); text-align:center; letter-spacing:.2px; line-height:1.15;}

/* ---------- CANVAS STAGE ---------- */
#stage-wrap{position:relative; overflow:hidden; background:var(--bg-0);}
#stage-wrap.panning{cursor:grabbing;}
#gridcanvas, #wirecanvas, #compcanvas, #overlaycanvas{
  position:absolute; top:0; left:0;
}
#hint{
  position:absolute; left:14px; bottom:12px; background:color-mix(in srgb, var(--bg-1) 85%, transparent); backdrop-filter:blur(4px);
  border:1px solid var(--line); border-radius:var(--radius); padding:7px 11px; font-size:11px;
  color:var(--text-1); font-family:var(--mono); pointer-events:none; max-width:340px; line-height:1.5;
}
#coordread{
  position:absolute; right:14px; bottom:12px; background:color-mix(in srgb, var(--bg-1) 85%, transparent); backdrop-filter:blur(4px);
  border:1px solid var(--line); border-radius:var(--radius); padding:6px 10px; font-size:11px;
  color:var(--text-2); font-family:var(--mono); pointer-events:none;
}
.stage-toolbar{
  position:absolute; top:12px; left:14px; display:flex; flex-direction:column; gap:6px; z-index:10;
}
.stage-toolbar button{
  width:30px; height:30px; border-radius:var(--radius); background:color-mix(in srgb, var(--bg-2) 90%, transparent); border:1px solid var(--line);
  color:var(--text-1); cursor:pointer; display:flex; align-items:center; justify-content:center; backdrop-filter:blur(4px);
}
.stage-toolbar button:hover{color:var(--text-0); border-color:var(--copper);}
.stage-toolbar button.active{color:#eafffb; border-color:var(--teal); background:rgba(53,208,192,.15);}
.stage-toolbar button svg{width:15px; height:15px;}

/* ---------- RIGHT PANEL ---------- */
#rightpanel{background:var(--bg-1); border-left:1px solid var(--line); display:flex; flex-direction:column; min-height:0;}
.rp-tabs{display:flex; border-bottom:1px solid var(--line); flex:none;}
.rp-tab{
  flex:1; text-align:center; padding:10px 4px; font-size:11px; font-weight:700; letter-spacing:.6px;
  text-transform:uppercase; color:var(--text-2); cursor:pointer; border-bottom:2px solid transparent;
}
.rp-tab:hover{color:var(--text-1);}
.rp-tab.active{color:var(--teal); border-bottom-color:var(--teal);}
.rp-pane{flex:1; overflow-y:auto; display:none; padding:14px;}
.rp-pane.active{display:block;}

.prop-empty{color:var(--text-2); font-size:12px; text-align:center; margin-top:40px; line-height:1.6;}
.prop-title{
  display:flex; align-items:center; gap:8px; font-size:14px; font-weight:700; margin-bottom:3px;
}
.prop-title .swatch{width:9px; height:9px; border-radius:2px; background:var(--copper);}
.prop-sub{font-size:10.5px; color:var(--text-2); font-family:var(--mono); margin-bottom:16px;}
.field{margin-bottom:13px;}
.field label{
  display:block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.7px;
  color:var(--text-2); margin-bottom:5px;
}
.field .row{display:flex; gap:6px;}
.field input[type=text], .field input[type=number], .field select{
  width:100%; background:var(--bg-3); border:1px solid var(--line); border-radius:var(--radius);
  padding:7px 9px; color:var(--text-0); font-size:12.5px; outline:none;
}
.field input:focus, .field select:focus{border-color:var(--teal);}
.field .unit{
  background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius); padding:7px 10px;
  color:var(--text-2); font-size:11.5px; flex:none; min-width:44px; text-align:center;
}
.field input[type=range]{width:100%; accent-color:var(--copper);}
.field .rangeval{font-family:var(--mono); font-size:11px; color:var(--teal); float:right;}
.checkrow{display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text-1); margin-bottom:12px;}
.readouts{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:6px;}
.readout{
  background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius); padding:8px 10px;
}
.readout .rl{font-size:9.5px; text-transform:uppercase; letter-spacing:.6px; color:var(--text-2); margin-bottom:3px;}
.readout .rv{font-family:var(--mono); font-size:14px; color:var(--text-0); font-weight:500;}
.readout .rv.hot{color:var(--teal);}
.btnrow{display:flex; gap:8px; margin-top:6px;}
.btnrow .tbtn{flex:1; justify-content:center;}

#netlist-out{
  font-family:var(--mono); font-size:11px; color:var(--text-1); white-space:pre-wrap; line-height:1.7;
  background:var(--bg-3); border:1px solid var(--line); border-radius:var(--radius); padding:12px; min-height:160px;
}
.netlist-actions{display:flex; gap:8px; margin:10px 0;}

#console-out{
  font-family:var(--mono); font-size:11px; line-height:1.8; color:var(--text-1);
}
.log-line{border-bottom:1px dashed var(--line-soft); padding:4px 0;}
.log-line.err{color:var(--red);}
.log-line.warn{color:var(--amber);}
.log-line.ok{color:var(--green);}
.log-time{color:var(--text-2); margin-right:6px;}

/* ============================== BOTTOM PANEL ============================== */
#bottom{
  grid-row:3; display:grid; grid-template-columns:1fr 300px; background:var(--bg-1); min-height:0;
}
#scope-wrap{position:relative; border-right:1px solid var(--line);}
#scope-head{
  position:absolute; top:8px; left:12px; right:12px; display:flex; justify-content:space-between; z-index:2;
  font-size:10.5px; color:var(--text-2); font-family:var(--mono); pointer-events:none;
}
#scope-head .ch{display:flex; gap:12px;}
#scope-head .chip{display:flex; align-items:center; gap:5px;}
#scope-head .chip i{width:8px; height:2px; display:inline-block;}
#scopecanvas{display:block;}

#meters{padding:12px; overflow-y:auto;}
.meters-title{font-size:10.5px; font-weight:700; letter-spacing:.8px; text-transform:uppercase; color:var(--text-2); margin-bottom:10px;}
.meter-grid{display:grid; grid-template-columns:1fr 1fr; gap:8px;}
.meter{
  background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius); padding:9px 10px;
  display:flex; flex-direction:column; gap:2px;
}
.meter .ml{font-size:9px; text-transform:uppercase; letter-spacing:.5px; color:var(--text-2);}
.meter .mv{font-family:var(--mono); font-size:15px; font-weight:600;}
.meter.probe .mv{color:var(--teal);}
.meter-empty{grid-column:1/-1; color:var(--text-2); font-size:11px; text-align:center; padding:14px 0;}

/* ============================== drag ghost / misc ============================== */
#draglabel{
  position:fixed; pointer-events:none; z-index:999; font-family:var(--mono); font-size:11px;
  color:var(--teal); background:color-mix(in srgb, var(--bg-0) 90%, transparent); border:1px solid var(--teal-dim); border-radius:4px;
  padding:3px 7px; display:none;
}

.toast-wrap{position:fixed; top:60px; right:16px; display:flex; flex-direction:column; gap:8px; z-index:1000;}
.toast{
  background:var(--bg-2); border:1px solid var(--line); border-left:3px solid var(--teal); border-radius:var(--radius);
  padding:10px 14px; font-size:12px; color:var(--text-0); box-shadow:0 6px 20px rgba(0,0,0,.4);
  animation:toastin .18s ease-out;
}
.toast.err{border-left-color:var(--red);}
.toast.warn{border-left-color:var(--amber);}
@keyframes toastin{from{opacity:0; transform:translateX(12px);} to{opacity:1; transform:translateX(0);}}

/* context menu */
#ctxmenu{
  position:fixed; z-index:900; background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius);
  padding:5px; min-width:160px; box-shadow:0 10px 30px rgba(0,0,0,.5); display:none;
}
#ctxmenu .ci{
  padding:8px 11px; font-size:12px; color:var(--text-1); border-radius:4px; cursor:pointer; display:flex;
  align-items:center; justify-content:space-between;
}
#ctxmenu .ci:hover{background:var(--bg-3); color:var(--text-0);}
#ctxmenu .ci.danger:hover{background:#3a2224; color:var(--red);}
#ctxmenu .ci kbd{color:var(--text-2); font-size:10px; font-family:var(--mono);}
#ctxmenu hr{border:none; border-top:1px solid var(--line); margin:5px 2px;}

/* modal */
#modal-backdrop{
  position:fixed; inset:0; background:rgba(8,10,14,.6); backdrop-filter:blur(2px); z-index:800;
  display:none; align-items:center; justify-content:center;
}
#modal{
  background:var(--bg-1); border:1px solid var(--line); border-radius:10px; width:460px; max-width:92vw;
  max-height:82vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,.6);
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--line);
}
.modal-head h3{margin:0; font-size:15px;}
.modal-head button{background:none; border:none; color:var(--text-2); font-size:18px; cursor:pointer;}
.modal-body{padding:18px;}
.examples-grid{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
.example-card{
  background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius); padding:12px; cursor:pointer;
}
.example-card:hover{border-color:var(--copper);}
.example-card .et{font-weight:700; font-size:12.5px; margin-bottom:4px;}
.example-card .ed{font-size:10.5px; color:var(--text-2); line-height:1.4;}

.hidden{display:none !important;}
/* ============================== FOOTER ============================== */
#footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  padding: 0 16px;
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--mono);
  height: 28px;
  z-index: 25;
}

#footer div {
  display: flex;
  align-items: center;
  gap: 12px;
}

#footer .status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 5px rgba(89, 201, 122, 0.4);
}

#footer kbd {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
  color: var(--text-1);
}

#footer a {
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.12s;
}

#footer a:hover {
  color: var(--text-0);
}

/* ============================================================
   MOBILE / TABLET RESPONSIVE LAYER  (CSS only)
   ---------------------------------------------------------
   Appended after the core stylesheet. Selectors are prefixed with
   "html body" so they out-rank the <style> blocks that analysis.js,
   netlist-import.js and spice-highlight.js inject at runtime
   (including the !important grid-template-columns on #main).

   Breakpoints
     <=1100px  tablet / small laptop : narrower side columns, compact topbar
     <=820px   phone / portrait tablet: single column, page scrolls,
                                        palette becomes a horizontal strip
     <=480px   small phone            : tighter spacing, 1-col dialogs
============================================================ */

/* ---------- base fixes (all sizes) ---------- */
html body #app{width:100%; height:100vh; height:100dvh; grid-template-columns:minmax(0,1fr);}
html body #app > *{min-width:0;}
html body{overscroll-behavior-y:none;}

/* ============================== <= 1100px ============================== */
@media (max-width:1100px){
  /* topbar: one scrollable row instead of overflowing the viewport */
  html body #topbar{
    overflow-x:auto; overflow-y:hidden; gap:8px; padding:0 10px;
    scrollbar-width:thin; scrollbar-color:var(--line) transparent;
    -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; touch-action:pan-x;
    min-width:0; max-width:100%;
  }
  html body #topbar::-webkit-scrollbar{height:6px;}
  html body #topbar::-webkit-scrollbar-thumb{border:none; background:var(--line);}
  html body #topbar::-webkit-scrollbar-track{background:transparent;}
  html body #topbar > *{flex:none;}
  html body #topbar .tb-spacer{flex:1 0 0;}
  html body .brand small{display:none;}
  html body #topbar .tbtn .lbl{display:none;}
  html body #topbar #btn-run .lbl{display:inline;}

  /* speed bar: slimmer, drop the min/max end labels */
  html body .speed-control .sp-end{display:none;}
  html body .speed-control input[type=range]{width:96px;}

  /* narrower side columns */
  html body #main{grid-template-columns:176px minmax(0,1fr) var(--rp-w,300px) !important;}
  html body #bottom{grid-template-columns:minmax(0,1fr) 240px;}
  html body .rp-tab{font-size:10px; letter-spacing:.3px; padding:10px 2px;}
  html body #hint{max-width:240px;}
}

/* ============================== <= 820px ============================== */
@media (max-width:820px){

  /* ---- shell: natural-height column, the page itself scrolls ---- */
  html body #app{
    display:flex; flex-direction:column;
    height:auto; min-height:100vh; min-height:100dvh;
  }
  html body #topbar{
    position:sticky; top:0; flex:none; height:50px; z-index:40;
    padding-left:max(10px, env(safe-area-inset-left));
    padding-right:max(10px, env(safe-area-inset-right));
  }
  html body .topbar-div{margin:0 2px;}
  html body .speed-control label{display:none;}
  html body .speed-control{padding:4px 8px; gap:6px;}
  html body .speed-control input[type=range]{width:84px; height:28px;}
  html body .speed-control input[type=range]::-webkit-slider-thumb{width:20px; height:20px; margin-top:-8px;}
  html body .speed-control input[type=range]::-moz-range-thumb{width:18px; height:18px;}
  html body .speed-control output{min-width:46px;}
  html body #zoomreadout{width:40px;}
  html body .view-toggle .vt-label{display:none;}
  html body .view-toggle{padding:3px;}

  /* ---- main: palette strip -> canvas -> side panel, stacked ---- */
  html body #main{
    display:flex; flex-direction:column; flex:none;
    border-bottom:none;
  }

  /* palette becomes a horizontal scroller */
  html body #palette{
    flex:none; display:flex; align-items:stretch; gap:12px;
    overflow-x:auto; overflow-y:hidden; padding:8px 10px;
    border-right:none; border-bottom:1px solid var(--line);
    -webkit-overflow-scrolling:touch; scrollbar-width:thin;
  }
  html body #palette::-webkit-scrollbar{height:5px;}
  html body .palette-search{flex:none; width:150px; margin:0; align-self:center; position:sticky; left:0; z-index:2;}
  html body .palette-search input{font-size:16px;}
  html body #palette-root{display:flex; align-items:stretch; gap:14px; flex:none;}
  html body .pcat{display:flex; flex:none; align-items:stretch; gap:6px; margin:0;}
  html body .pcat-head{
    writing-mode:vertical-rl; transform:rotate(180deg);
    padding:2px 3px; justify-content:center; font-size:9.5px; letter-spacing:.9px;
    border-left:1px solid var(--line-soft);
  }
  html body .pcat-head .chev{display:none;}
  html body .pcat-body{display:flex; gap:6px; padding:0; align-items:stretch;}
  html body .part{flex:none; width:66px; cursor:pointer; padding:7px 3px 5px;}

  /* canvas stage: fixed generous height; touches here draw/pan, not scroll */
  html body #stage-wrap{
    flex:none; height:62vh; height:clamp(300px, 62dvh, 640px);
    touch-action:none; -webkit-user-select:none; user-select:none;
    -webkit-touch-callout:none;
  }
  html body #stage-wrap canvas{touch-action:none;}
  html body .stage-toolbar{top:10px; left:10px; gap:8px;}
  html body .stage-toolbar button{width:40px; height:40px;}
  html body .stage-toolbar button svg{width:18px; height:18px;}
  html body #coordread{display:none;}
  html body #hint{
    left:10px; right:10px; bottom:10px; max-width:none;
    font-size:10.5px; padding:6px 9px;
  }

  /* side panel: full width under the canvas */
  html body #rightpanel{
    flex:none; width:100%; height:min(62vh, 480px);
    border-left:none; border-top:1px solid var(--line);
  }
  html body #rp-resizer{display:none;}
  html body .rp-tabs{overflow-x:auto; scrollbar-width:none;}
  html body .rp-tabs::-webkit-scrollbar{display:none;}
  html body .rp-tab{flex:1 0 auto; padding:12px 12px; font-size:10.5px; white-space:nowrap;}
  html body .rp-pane{padding:12px;}

  /* inputs >=16px so iOS doesn't zoom the page on focus */
  html body .field input[type=text],
  html body .field input[type=number],
  html body .field select,
  html body #an-settings input[type=text],
  html body #an-settings select{font-size:16px; min-height:40px;}
  html body .field .unit{display:flex; align-items:center; justify-content:center;}
  html body .field input[type=range]{height:28px;}
  html body .checkrow input, html body .spice-opt input{width:20px; height:20px;}

  /* Draw CirSpice editor: textarea and highlight layer must share metrics */
  html body #pane-spice .hl-wrap{min-height:260px;}
  html body #pane-spice .hl-wrap #spice-in{font-size:16px !important; line-height:1.6 !important;}
  html body #pane-spice .hl-layer{font-size:16px !important; line-height:1.6 !important;}
  html body #netlist-out{font-size:12px;}
  html body #console-out{font-size:12px;}

  /* scope + meters stacked under the panel */
  html body #bottom{
    flex:none; display:flex; flex-direction:column;
    border-top:1px solid var(--line);
  }
  html body #scope-wrap{height:190px; border-right:none; border-bottom:1px solid var(--line);}
  html body #meters{max-height:240px;}
  html body .meter-grid{grid-template-columns:repeat(auto-fill,minmax(110px,1fr));}

  /* footer wraps and clears the home indicator */
  html body #footer{
    flex:none; height:auto; min-height:28px; flex-wrap:wrap; justify-content:center;
    gap:4px 16px; padding:6px 12px calc(6px + env(safe-area-inset-bottom));
  }
  html body #footer .footer-center{display:none;}

  /* floating UI */
  html body .toast-wrap{top:58px; left:12px; right:12px;}
  html body .toast{width:100%;}
  html body #ctxmenu .ci{padding:12px 14px; font-size:13px;}
  html body #modal{width:94vw; max-height:88vh; max-height:88dvh;}

  /* analysis dialog: full-screen sheet */
  html body #an-modal{
    width:100vw; height:100vh; height:100dvh; max-width:none; border-radius:0; border:none;
  }
  html body .an-head{flex-wrap:wrap; gap:8px 10px; padding:10px 12px; padding-top:max(10px, env(safe-area-inset-top));}
  html body .an-head h3{order:1; min-width:0; flex:1; font-size:14px;}
  html body #an-close{order:2; font-size:28px; width:40px; height:40px; line-height:1;}
  html body #an-tabs{
    order:3; flex:1 0 100%; overflow-x:auto; scrollbar-width:none; gap:6px;
  }
  html body #an-tabs::-webkit-scrollbar{display:none;}
  html body #an-tabs .tbtn{flex:none;}
  html body .an-body{grid-template-columns:1fr; grid-template-rows:auto minmax(0,1fr); overflow-y:auto;}
  html body #an-settings{max-height:36vh; border-right:none; border-bottom:1px solid var(--line);}
  html body #an-plotwrap{min-height:240px;}
  html body #an-table{padding:10px; -webkit-overflow-scrolling:touch;}
  html body #an-status{padding-bottom:max(7px, env(safe-area-inset-bottom));}
}

/* ============================== <= 480px ============================== */
@media (max-width:480px){
  html body .tbtn{padding:7px 9px;}
  html body .brand{font-size:15px; margin-right:2px;}
  html body .simstat{padding:5px 8px;}
  html body #hint{display:none;}
  html body .examples-grid{grid-template-columns:1fr;}
  html body .modal-head{padding:14px;}
  html body .modal-body{padding:14px;}
  html body .readouts{grid-template-columns:1fr 1fr; gap:6px;}
  html body .btnrow{flex-wrap:wrap;}
  html body #scope-wrap{height:170px;}
  html body #scope-head{left:8px; right:8px; flex-wrap:wrap; gap:2px 8px;}
}

/* ============================== touch devices ============================== */
@media (pointer:coarse){
  html body #topbar{scrollbar-width:none;}
  html body #topbar::-webkit-scrollbar{display:none; height:0;}
  html body .tbtn{min-height:40px;}
  html body .rp-tab{min-height:44px; display:flex; align-items:center; justify-content:center;}
  html body .pcat-head{min-width:24px;}
  html body .rocker{width:52px; height:28px;}
  html body .rocker .knob{width:22px; height:22px;}
  html body .rocker.on .knob{left:26px;}
  html body .an-chip{padding:7px 12px;}
  html body #ctxmenu .ci{min-height:44px;}
  /* speed slider: easier to grab with a finger */
  html body .speed-control input[type=range]{touch-action:pan-y;}
}

/* ============================== short landscape phones ============================== */
@media (max-width:900px) and (max-height:480px) and (orientation:landscape){
  html body #stage-wrap{height:calc(100vh - 50px); height:calc(100dvh - 50px);}
  html body #rightpanel{height:calc(100vh - 50px); height:calc(100dvh - 50px);}
  html body #an-settings{max-height:30vh;}
}

@media (prefers-reduced-motion:reduce){
  html body *{animation-duration:.01ms !important; transition-duration:.01ms !important;}
}

/* ============================================================
   MOBILE: SHOW EVERYTHING  (CSS only)
   ---------------------------------------------------------
   On phones / small tablets nothing is hidden any more:
   - simulation scope + live meters always visible
   - analysis (simulation) window shows settings, plot and table
     in one scrolling sheet
   - topbar labels, speed bar labels / end values, hint,
     coordinates and footer shortcuts are all displayed
   The topbar already scrolls sideways, so extra labels fit.
============================================================ */
@media (max-width:1100px){
  html body #topbar .tbtn .lbl{display:inline;}
  html body .view-toggle .vt-label{display:inline;}
  html body .speed-control label,
  html body .speed-control .sp-end{display:inline;}
  html body .brand small{display:inline;}
}

@media (max-width:820px){
  /* simulation window (scope) + meters: always shown, never collapsed */
  html body #bottom{display:flex; flex-direction:column; visibility:visible; opacity:1;}
  html body #scope-wrap{display:block; position:relative; width:100%; height:200px; min-height:200px; flex:none;}
  html body #scopecanvas{display:block; width:100%; height:100%;}
  html body #scope-head{display:flex;}
  html body #meters{display:block; max-height:none; overflow:visible;}

  /* canvas stage + info overlays */
  html body #stage-wrap{display:block;}
  html body #coordread{display:block;}
  html body #hint{display:block;}

  /* side panel: all tabs visible, panes fully scrollable */
  html body .rp-tabs{overflow-x:auto;}
  html body #rightpanel{height:min(70vh, 560px);}

  /* analysis / simulation dialog: everything stacked + scrollable */
  html body #an-modal{display:flex; flex-direction:column; overflow:hidden;}
  html body .an-body{display:block; flex:1 1 auto; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch;}
  html body #an-settings{display:block; max-height:none; overflow:visible; border-right:none; border-bottom:1px solid var(--line);}
  html body .an-main{display:block; min-height:0; overflow:visible;}
  html body #an-legend{display:flex; flex-wrap:wrap;}
  html body #an-plotwrap{display:block; position:relative; width:100%; height:300px; min-height:300px;}
  html body #an-canvas{display:block; width:100%; height:100%;}
  html body #an-table{display:block; max-height:none; overflow-x:auto;}
  html body #an-status{display:block;}

  /* footer: keep shortcuts line too */
  html body #footer .footer-center{display:flex;}
}

@media (max-width:480px){
  html body #hint{display:block; font-size:10px; padding:5px 8px;}
  html body #scope-wrap{height:180px; min-height:180px;}
}

/* ============================================================
   SPICE EXAMPLES DROP-DOWN  (flexible size, scrolls, grouped by topic)
   The button shrinks to the free space (long names get "…");
   the list is a scrollable popup with a max height.
============================================================ */
.btnrow{align-items:center;}
.ex-dd{flex:1 1 0; min-width:0;}
.ex-btn{
  width:100%; justify-content:space-between; min-width:0;
  background:var(--bg-3); border-color:var(--line); color:var(--text-0);
}
.ex-btn:hover, .ex-btn.open{border-color:var(--copper); background:var(--bg-2);}
.ex-btn.open{border-color:var(--teal);}
.ex-label{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left;}
.ex-caret{flex:none; font-size:10px; color:var(--text-2); transition:transform .15s;}
.ex-btn.open .ex-caret{transform:rotate(180deg);}
.btnrow #spice-clear{flex:none;}

.ex-menu{
  position:fixed; z-index:2000; overflow-y:auto; overscroll-behavior:contain; box-sizing:border-box;
  max-width:calc(100vw - 16px); -webkit-overflow-scrolling:touch;
  background:var(--bg-2); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:0 12px 32px rgba(0,0,0,.45); padding:4px 0;
}
.ex-menu[hidden]{display:none !important;}
.ex-topic{
  position:sticky; top:-4px; z-index:1; background:var(--bg-1);
  padding:7px 11px; font-size:10px; font-weight:700; letter-spacing:.9px; text-transform:uppercase;
  color:var(--copper-bright); border-bottom:1px solid var(--line-soft);
}
.ex-item{
  padding:7px 11px 7px 18px; font-size:12px; color:var(--text-1); cursor:pointer;
  font-family:var(--mono); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.ex-item:hover{background:var(--bg-3); color:var(--text-0);}
.ex-item.sel{color:var(--teal);}

@media (max-width:820px){
  html body .ex-btn{min-height:40px; font-size:14px;}
  html body .ex-item{padding:11px 12px 11px 18px; font-size:14px;}
}
@media (max-width:480px){
  html body #pane-spice .btnrow{flex-wrap:nowrap;}
}

/* ============================================================
   SPICE ACTION ROW:  [ 📂 Load example ▾ ] [ 🗑 Clear ] [ ⚡ Create Circuit ]
   One line, equal height; the middle button is the flexible one.
============================================================ */
#pane-spice .spice-actions{
  display:flex; align-items:stretch; gap:8px; margin:10px 0 0; flex-wrap:nowrap;
}
#pane-spice .spice-actions .tbtn{
  height:38px; padding:0 12px; font-size:12.5px; justify-content:center; flex:none;
}
#pane-spice .spice-actions .ex-dd{flex:1 1 0; min-width:0; display:flex;}
#pane-spice .spice-actions .ex-btn{flex:1; justify-content:space-between;}
#pane-spice .spice-create{box-shadow:0 2px 10px rgba(53,208,192,.22);}

/* danger button (Clear) */
.tbtn.danger{
  color:var(--red);
  background:color-mix(in srgb, var(--red) 10%, transparent);
  border-color:color-mix(in srgb, var(--red) 50%, var(--line));
}
.tbtn.danger:hover{
  background:linear-gradient(180deg,#c65357,#a63e42);
  border-color:#c65357; color:#fff0ef;
}

@media (max-width:820px){
  html body #pane-spice .spice-actions .tbtn{height:44px; font-size:13px;}
}
@media (max-width:380px){
  html body #pane-spice .spice-actions{gap:6px;}
  html body #pane-spice .spice-actions .tbtn{padding:0 9px;}
}

/* ============================================================
   SPICE ACTION ROW — FIXED BUTTON SIZES
   [ 📂 Load example ▾ ] [ 🗑 Clear ] [ ⚡ Create Circuit ]
   Clear and Create have fixed widths; Load example fills the rest.
   All three share the same fixed height. Tweak the 3 variables.
============================================================ */
#pane-spice .spice-actions{
  --btn-h:38px;        /* height of all 3 buttons   */
  --clear-w:84px;      /* Clear button width        */
  --create-w:128px;    /* Create Circuit width      */
  display:grid; grid-template-columns:minmax(0,1fr) var(--clear-w) var(--create-w);
  gap:8px; align-items:stretch;
}
#pane-spice .spice-actions .ex-dd,
#pane-spice .spice-actions .tbtn{height:var(--btn-h); min-height:var(--btn-h); width:100%; padding:0 8px; font-size:12px; line-height:1;}
#pane-spice .spice-actions .ex-btn{padding:0 10px;}
#pane-spice .spice-actions #spice-clear{width:var(--clear-w);}
#pane-spice .spice-actions #spice-create{width:var(--create-w);}

@media (max-width:820px){
  html body #pane-spice .spice-actions{--btn-h:44px; --clear-w:92px; --create-w:140px;}
  html body #pane-spice .spice-actions .tbtn{font-size:13px;}
}
@media (max-width:400px){
  html body #pane-spice .spice-actions{--clear-w:76px; --create-w:118px; gap:6px;}
  html body #pane-spice .spice-actions .tbtn{font-size:11.5px; padding:0 6px;}
}


/* ============================================================
   MOBILE STABILITY PATCH
   Fixes:
   1. Keep the live simulation/scope panel visible on phones.
   2. Prevent flex children from collapsing or being clipped.
   3. Make the Load example popup large enough and scrollable.
   4. Keep the example picker above the mobile panel and keyboard.
   ============================================================ */

/* Prevent mobile browsers from calculating a clipped app height. */
html,
body {
  min-height: 100%;
  height: auto;
}

@media (max-width: 820px) {
  html body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  html body #app {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    height: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible !important;
  }

  /* Keep the workspace in normal document flow. */
  html body #main {
    display: flex !important;
    flex-direction: column !important;
    flex: 0 0 auto !important;
    width: 100%;
    height: auto !important;
    min-height: 0;
    overflow: visible !important;
  }

  html body #palette,
  html body #stage-wrap,
  html body #rightpanel {
    flex-shrink: 0 !important;
    min-width: 0;
  }

  html body #stage-wrap {
    display: block !important;
    position: relative;
    width: 100%;
    height: clamp(320px, 58dvh, 620px) !important;
    min-height: 320px;
    overflow: hidden;
  }

  html body #rightpanel {
    display: flex !important;
    position: relative;
    width: 100% !important;
    height: auto !important;
    min-height: 420px;
    max-height: none !important;
    overflow: visible !important;
  }

  html body .rp-tabs {
    flex: 0 0 auto;
    position: sticky;
    top: 50px;
    z-index: 20;
    background: var(--bg-1);
  }

  html body .rp-pane {
    flex: 1 1 auto;
    min-height: 320px;
    max-height: 65dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Force the simulation panel to remain in the page.
     This also overrides an accidental inline display:none. */
  html body #bottom {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: column !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100%;
    height: auto !important;
    min-height: 260px;
    max-height: none !important;
    overflow: visible !important;
    background: var(--bg-1);
    z-index: 1;
  }

  html body #scope-wrap {
    display: block !important;
    position: relative;
    flex: 0 0 190px !important;
    width: 100%;
    height: 190px !important;
    min-height: 190px !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: hidden;
  }

  html body #scopecanvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    visibility: visible !important;
  }

  html body #scope-head {
    display: flex !important;
    visibility: visible !important;
  }

  html body #meters {
    display: block !important;
    flex: 0 0 auto;
    width: 100%;
    max-height: none !important;
    min-height: 90px;
    overflow: visible !important;
    visibility: visible !important;
  }

  html body #footer {
    display: flex;
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    min-height: 36px;
  }

  /* Make the spice editor and its action buttons fit narrow screens. */
  html body #pane-spice {
    min-width: 0;
    overflow-x: hidden;
  }

  html body #pane-spice #spice-in,
  html body #pane-spice .hl-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  html body #pane-spice .spice-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 76px 118px !important;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }

  html body #pane-spice .spice-actions .ex-dd {
    min-width: 0;
    width: 100%;
  }

  html body #pane-spice .spice-actions .tbtn {
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
  }

  /* Load-example popup: scrollable, touch-friendly, and above panels. */
  html body .ex-dd {
    position: relative;
    min-width: 0;
  }

  html body .ex-menu {
    position: fixed !important;
    z-index: 10000 !important;
    width: min(420px, calc(100vw - 20px));
    min-width: min(250px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
    max-height: min(58dvh, 440px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 5px 0;
    border-radius: 8px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .55);
  }

  html body .ex-menu[hidden] {
    display: none !important;
  }

  html body .ex-menu:not([hidden]) {
    display: block !important;
  }

  html body .ex-topic {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  html body .ex-item {
    min-height: 42px;
    display: flex;
    align-items: center;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    touch-action: manipulation;
  }
}

@media (max-width: 400px) {
  html body #stage-wrap {
    height: 54dvh !important;
    min-height: 300px;
  }

  html body #pane-spice .spice-actions {
    grid-template-columns: minmax(0, 1fr) 68px 108px !important;
    gap: 5px;
  }

  html body #pane-spice .spice-actions .tbtn {
    padding-left: 5px;
    padding-right: 5px;
    font-size: 11px;
  }

  html body #scope-wrap {
    flex-basis: 170px !important;
    height: 170px !important;
    min-height: 170px !important;
  }
}

/* Landscape phones: preserve a usable canvas and a visible scope. */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  html body #stage-wrap {
    height: 65dvh !important;
    min-height: 240px;
  }

  html body #scope-wrap {
    flex-basis: 160px !important;
    height: 160px !important;
    min-height: 160px !important;
  }
}


/* ============================================================
   RESPONSIVE FIX v2  (appended last, so it wins over everything above)

   1) SIMULATION STOPPING AFTER ~3-4 SECONDS ON PHONES
      Cause: backdrop-filter:blur() on the overlays that sit on top of
      the live canvas (#hint, #coordread, stage toolbar buttons, modal
      backdrops). The canvas is redrawn every animation frame, so the
      browser had to re-blur everything behind those overlays every
      frame. Phones run out of GPU/compositor budget after a few
      seconds, frame rate collapses and the animation looks frozen.
      Fix: no backdrop blur anywhere; slightly more opaque backgrounds
      give the same look.

   2) "LOAD EXAMPLE" LIST NOT VISIBLE ON PHONES / SMALL SCREENS
      Cause: the popup is position:fixed and placed by JS from the
      button's position. On a long stacked mobile page the button is
      often near / below the screen edge, so the popup landed off
      screen. Fix: on small screens the list is a bottom sheet pinned
      to the viewport (always visible, scrollable, safe-area aware),
      whatever the page scroll position or soft keyboard state.
============================================================ */

/* ---------- 1) no backdrop blur over live canvases ---------- */
html body #hint,
html body #coordread,
html body .stage-toolbar button,
html body #modal-backdrop,
html body #an-backdrop{
  -webkit-backdrop-filter:none !important;
  backdrop-filter:none !important;
}
html body #hint,
html body #coordread{background:color-mix(in srgb, var(--bg-1) 94%, transparent);}
html body .stage-toolbar button{background:color-mix(in srgb, var(--bg-2) 96%, transparent);}

/* ---------- 2) Load-example list: bottom sheet on small screens ---------- */
@media (max-width:820px){
  html body .ex-menu{
    position:fixed !important;
    left:8px !important; right:8px !important;
    top:auto !important;
    bottom:calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    width:auto !important; min-width:0 !important; max-width:none !important;
    max-height:min(62vh, 460px) !important;
    max-height:min(62dvh, 460px) !important;
    z-index:10000 !important;
    border-radius:14px !important;
    box-shadow:0 -6px 40px rgba(0,0,0,.55), 0 0 0 100vmax rgba(8,10,14,.45) !important;
    overflow-x:hidden; overflow-y:auto;
    overscroll-behavior:contain; -webkit-overflow-scrolling:touch; touch-action:pan-y;
  }
  html body .ex-menu .ex-topic{top:0 !important; padding:10px 14px; font-size:11px;}
}

/* landscape phones: keep the sheet inside the short viewport */
@media (max-width:900px) and (max-height:480px){
  html body .ex-menu{
    max-height:calc(100vh - 16px) !important;
    max-height:calc(100dvh - 16px) !important;
  }
}


/* ---------- DRAG THE WHOLE CIRCUIT (mouse + touch + pen) ---------- */
#stage-wrap{touch-action:none; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; outline:0;}
#stage-wrap canvas{touch-action:none; -webkit-user-drag:none;}
#stage-wrap.panning, #stage-wrap.panning canvas{cursor:grabbing !important;}
