/* LOGIC: logic.qkyubit.dev. Colours, fonts, buttons, frames, cursor and CRT come from the main site
   (/css/style.css), the framed tab groups from the tycoon game. */
@font-face { font-family: "Press Start 2P"; src: url(../fonts/PressStart2P-Regular.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "VT323"; src: url(../fonts/VT323-Regular.woff2) format("woff2"); font-display: swap; }

:root {
  --bg: #000;
  --panel: #0a0a10;
  --line: #22222e;
  --text: #e8e6e3;
  --dim: #8a8a9c;
  --or: #ff7a18;
  --or-hi: #ffb347;
  --or-lo: #a84300;
  --bl: #2ea8ff;
  --bl-hi: #8fd8ff;
  --bl-lo: #0b5c99;
  --ok: #3bff8a;
  --bad: #ff3b5c;
  --v0: #1d70b8;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --mono: "VT323", ui-monospace, monospace;
  --cur: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='22' viewBox='-1 -1 16 22' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h2v2h2v2h2v2h2v2h2v2h2v2h2v2h-6v2h2v2h2v2h-4v-2h-2v-2h-2v2h-2v2h-2z' fill='%23ff7a18' stroke='%23000'/%3E%3C/svg%3E") 0 0, auto;
  --cur-link: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='22' viewBox='-1 -1 16 22' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h2v2h2v2h2v2h2v2h2v2h2v2h2v2h-6v2h2v2h2v2h-4v-2h-2v-2h-2v2h-2v2h-2z' fill='%232ea8ff' stroke='%23000'/%3E%3C/svg%3E") 0 0, pointer;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 21px/1.3 var(--mono); cursor: var(--cur);
  display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden;
  scrollbar-color: var(--line) var(--panel); -webkit-text-size-adjust: 100%;
}
a, button, select, label, summary { cursor: var(--cur-link); }
input[type="text"], input[type="search"], textarea { cursor: text; }
button:disabled { cursor: not-allowed; }
a { color: var(--bl); }
a:hover { color: var(--or); }
::selection { background: var(--or); color: #000; }
:focus-visible { outline: 3px dashed var(--bl); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--pixel); font-weight: normal; }
[hidden] { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: 18px; }
.good { color: var(--ok); }
.bad { color: var(--bad); }
code { font: inherit; color: var(--or-hi); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 10px 0; }
.row.end { justify-content: flex-end; }

/* ---------- CRT overlay (as on the main site, a touch lighter over a work surface) ---------- */
.crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 1000;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.16) 2px 4px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 65%, rgba(0,0,0,.45) 100%);
  animation: flicker 6s steps(1) infinite;
}
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: .85; } 48% { opacity: 1; } 73% { opacity: .92; } 74% { opacity: 1; } }
body.nocrt .crt { display: none; }

/* ---------- buttons (the main site's pixel buttons) ---------- */
.btn {
  --f: var(--or); --hi: var(--or-hi); --lo: var(--or-lo);
  display: inline-block; font: 12px/1 var(--pixel); color: #000; text-decoration: none; white-space: nowrap;
  background: var(--f); border: 0; padding: 14px 18px; margin: 4px;
  box-shadow: inset -4px -4px 0 0 var(--lo), inset 4px 4px 0 0 var(--hi), 0 -4px 0 0 #000, 0 4px 0 0 #000, -4px 0 0 0 #000, 4px 0 0 0 #000;
  transition: transform .08s steps(2); touch-action: manipulation;
}
.btn:hover:not(:disabled) { color: #000; transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 4px 4px 0 0 var(--lo), inset -4px -4px 0 0 var(--hi), 0 -4px 0 0 #000, 0 4px 0 0 #000, -4px 0 0 0 #000, 4px 0 0 0 #000; }
.btn.alt { --f: var(--bl); --hi: var(--bl-hi); --lo: var(--bl-lo); }
.btn.danger { --f: var(--bad); --hi: #ff8fa3; --lo: #8c0f2a; }
.btn.sm { font-size: 9px; padding: 9px 10px; }
.btn.xs { font-size: 7px; padding: 6px 7px; margin: 2px 4px; box-shadow: inset -2px -2px 0 0 var(--lo), inset 2px 2px 0 0 var(--hi), 0 0 0 2px #000; }
.btn:disabled { --f: #2a2a36; --hi: #3a3a48; --lo: #16161e; color: #5a5a6e; }
.btn[aria-pressed="true"] { --f: var(--ok); --hi: #9dffc4; --lo: #13883f; }
.savebtn.on { --f: var(--ok); --hi: #9dffc4; --lo: #13883f; }

/* ---------- HUD ---------- */
.hud {
  display: flex; align-items: center; gap: 4px 14px; padding: 4px 10px; background: #000; overflow-x: auto; scrollbar-width: none;
  border-bottom: 4px solid; border-image: repeating-linear-gradient(90deg, var(--or) 0 8px, transparent 8px 16px, var(--bl) 16px 24px, transparent 24px 32px) 4;
  position: relative; z-index: 20;
}
.hud::-webkit-scrollbar { display: none; }
.home { font: 9px var(--pixel); text-decoration: none; white-space: nowrap; }
.hbar { display: flex; align-items: center; gap: 0; flex: none; }
.hbar.end { margin-left: auto; }
.glitch {
  position: relative; margin: 0; font-size: 20px; line-height: 1; color: var(--text); white-space: nowrap; flex: none;
  text-shadow: 2px 2px 0 var(--or), 4px 4px 0 var(--bl); padding: 0 6px 4px 0; animation: boot 1s steps(8) both;
}
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; text-shadow: none; clip-path: inset(0 0 100% 0); }
.glitch::before { color: var(--or); animation: g1 3.1s steps(1) infinite 1s; }
.glitch::after { color: var(--bl); animation: g2 2.3s steps(1) infinite 1.4s; }
@keyframes boot { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes g1 { 0%, 86%, 100% { clip-path: inset(0 0 100% 0); transform: none; } 87% { clip-path: inset(10% 0 70% 0); transform: translate(-4px, 0); } 89% { clip-path: inset(55% 0 25% 0); transform: translate(4px, 0); } 91% { clip-path: inset(30% 0 50% 0); transform: translate(-2px, 0); } }
@keyframes g2 { 0%, 80%, 100% { clip-path: inset(0 0 100% 0); transform: none; } 81% { clip-path: inset(65% 0 15% 0); transform: translate(4px, 0); } 83% { clip-path: inset(5% 0 80% 0); transform: translate(-4px, 0); } }
.badge { font: 7px var(--pixel); padding: 6px 7px; margin-left: 8px; border: 2px solid; white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--or-hi); }
.badge.bad { color: var(--bad); animation: blink 1s steps(2) infinite; }
.badge::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: currentColor; vertical-align: 0; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 216px minmax(0, 1fr) var(--side-w, 360px); min-height: 0; }
body.side-hidden .app { grid-template-columns: 216px minmax(0, 1fr); }
body.side-hidden .side { display: none; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }
.parts { overflow-y: auto; padding: 10px 8px 16px; border-right: 4px solid var(--line); background: #05050a; display: flex; flex-direction: column; gap: 12px; }
.stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.side { position: relative; display: flex; flex-direction: column; min-height: 0; border-left: 4px solid var(--line); background: #05050a; }
.side-grip { position: absolute; z-index: 5; left: -8px; top: 0; bottom: 0; width: 12px; cursor: col-resize; touch-action: none; }
.side-grip:hover, .side-grip:focus-visible { background: linear-gradient(90deg, transparent 4px, var(--bl) 4px 8px, transparent 8px); outline: none; }
.side-show { position: absolute; top: 8px; right: 8px; display: none; }
body.side-hidden .side-show { display: inline-block; }

input[type="text"], input[type="search"], textarea {
  width: 100%; background: #000; color: var(--text); font: 21px var(--mono); border: 4px solid var(--line); padding: 6px 8px; resize: vertical; border-radius: 0;
}
input[type="text"]:focus, input[type="search"]:focus, textarea:focus { border-color: var(--or); outline: none; }
input[type="search"] { font: 9px var(--pixel); padding: 10px 8px; }
input[type="search"]::placeholder { color: var(--dim); }
input[type="checkbox"] { accent-color: var(--or); width: 18px; height: 18px; vertical-align: -3px; margin: 0 8px 0 0; }

/* parts palette: framed groups with their name on the top edge */
.pgroup { --gc: var(--or); position: relative; padding: 14px 4px 4px; border: 2px solid var(--gc); box-shadow: inset 0 0 0 2px #000, 3px 3px 0 #000; }
.pgroup-label { position: absolute; top: -7px; left: 6px; padding: 0 4px; font: 7px var(--pixel); color: var(--gc); background: #05050a; }
.pitems { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.part {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px 6px; min-width: 0;
  background: var(--panel); border: 2px solid #1e1e2a; color: var(--text); font: 7px/1.3 var(--pixel); text-align: center;
  box-shadow: inset -2px -2px 0 #000, inset 2px 2px 0 #1a1a26; touch-action: manipulation;
}
.part canvas { image-rendering: auto; pointer-events: none; }
.part span { overflow-wrap: anywhere; }
.part:hover, .part:focus-visible { border-color: var(--gc); color: var(--gc); }
.pgroup p { margin: 2px 4px 4px; }

/* circuit tabs */
.tabs { display: flex; gap: 4px; padding: 6px 8px 0; overflow-x: auto; background: #05050a; border-bottom: 4px solid var(--line); scrollbar-width: thin; }
.tab {
  display: flex; align-items: center; gap: 6px; flex: none; padding: 8px 10px; font: 8px var(--pixel); color: var(--dim); background: var(--panel);
  border: 2px solid var(--line); border-bottom: 0; white-space: nowrap;
}
.tab i { width: 8px; height: 8px; display: inline-block; }
.tab small { font-size: 6px; color: var(--dim); }
.tab.on { color: #000; background: repeating-linear-gradient(0deg, var(--or) 0 2px, var(--or-hi) 2px 4px); border-color: var(--or); }
.tab.on small { color: #000; }
.tab:hover:not(.on) { color: var(--text); border-color: var(--bl-lo); }
.tab.add { color: var(--bl); border-style: dashed; }

/* canvas */
.cwrap { position: relative; min-height: 0; overflow: hidden; }
#cv { position: absolute; inset: 0; display: block; touch-action: none; outline: none; }
#cv:focus-visible { outline: 3px dashed var(--bl); outline-offset: -3px; }
.zoom { position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; background: #000; border: 2px solid var(--line); box-shadow: 4px 4px 0 #000; }
.zoom button { font: 10px var(--pixel); color: var(--text); background: var(--panel); border: 0; min-width: 34px; height: 32px; padding: 0 8px; }
.zoom button:hover { background: var(--bl-lo); }
.zoom span { font-size: 18px; min-width: 52px; text-align: center; color: var(--dim); }
.modebar { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; max-width: calc(100% - 20px);
  padding: 4px 4px 4px 12px; background: #000; border: 2px solid var(--or); box-shadow: 4px 4px 0 var(--bl-lo); font-size: 18px; color: var(--or-hi); }
.modebar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* status bar */
.status { display: flex; align-items: center; gap: 6px 16px; padding: 3px 10px; font-size: 18px; background: #05050a; border-top: 4px solid var(--line); white-space: nowrap; overflow: hidden; }
#hint { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tog { font: 7px var(--pixel); color: var(--dim); background: none; border: 2px solid var(--line); padding: 5px 6px; }
.tog:hover { color: var(--text); border-color: var(--bl-lo); }

/* side panels */
#sidetabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 4px; padding: 8px 8px 0; border-bottom: 4px solid var(--line); align-items: end; }
#sidetabs [role=tab] { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; font: 8px var(--pixel); padding: 9px 2px 6px; color: var(--dim);
  background: var(--panel); border: 2px solid var(--line); border-bottom: 0; }
#sidetabs [role=tab] small { font: 15px/1 var(--mono); color: #5a5a6e; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sidetabs [role=tab] small.on { color: var(--or-hi); }
#sidetabs [role=tab][aria-selected="true"] { color: #000; background: repeating-linear-gradient(0deg, var(--bl) 0 2px, var(--bl-hi) 2px 4px); border-color: var(--bl); }
#sidetabs [role=tab][aria-selected="true"] small { color: #04263f; }
#sidetabs [role=tab]:hover:not([aria-selected="true"]) { color: var(--text); border-color: var(--bl-lo); }
.side-hide { align-self: stretch; margin-bottom: 4px; font: 14px var(--pixel); color: var(--dim); background: none; border: 2px solid var(--line); padding: 0 6px; }
.side-hide:hover { color: var(--text); border-color: var(--bl-lo); }
.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 20px; }
.panel h3 { font-size: 11px; color: var(--or); margin: 14px 0 8px; line-height: 1.5; }
.panel h4 { font-size: 8px; color: var(--bl); margin: 18px 0 8px; line-height: 1.6; }
.panel h4 small { font: 17px var(--mono); color: var(--dim); }
.panel p { margin: 6px 0; }
.lbl { display: block; font: 8px var(--pixel); color: var(--or); margin: 12px 0 6px; }
.field { display: block; }
.check { display: flex; align-items: center; margin: 12px 0; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper output { min-width: 44px; text-align: center; font-size: 26px; color: var(--or-hi); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 28px; height: 28px; border: 2px solid #000; box-shadow: 0 0 0 2px var(--line); padding: 0; }
.swatches button[aria-checked="true"] { box-shadow: 0 0 0 3px var(--text); transform: translateY(-2px); }
dl.kv, dl.pins, dl.exprs, dl.keys { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 14px; margin: 0; }
dl dt { color: var(--dim); }
dl dd { margin: 0; overflow-wrap: anywhere; }
dl.pins { grid-template-columns: minmax(0, 1fr) auto; font-size: 19px; }
dl.pins dt small { color: #5a5a6e; }
dl.exprs dd { display: flex; align-items: center; flex-wrap: wrap; }
.tips { margin: 0; padding-left: 20px; color: #c9c7d1; font-size: 19px; }
.note { border: 4px dashed var(--or-lo); background: #ff7a180a; padding: 8px 12px; margin: 10px 0 !important; }
.note.bad { border-color: #8c0f2a; }
.v0, .v.v0 { color: var(--v0); }
.v1, .v.v1 { color: var(--or); }
.v2, .v.v2 { color: #6a6a80; }
.v3, .v.v3 { color: var(--bad); }
b.v { font-weight: normal; font-family: var(--pixel); font-size: 9px; }
.copyable { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 2px 0 6px; }
.copyable code { color: var(--dim); font-size: 18px; }
.copyable .form { font: 6px var(--pixel); color: var(--bl); min-width: 44px; }
dl.exprs .words { flex-basis: 100%; color: var(--dim); font-size: 17px; }
.sop { font-size: 24px; line-height: 1.5; }
.sop .term { padding: 0 3px; border: 2px solid transparent; }
.sop .term:hover, .sop .term:focus { border-color: var(--bl); outline: none; color: var(--text); }

/* tables */
.ttwrap { max-height: 420px; overflow: auto; border: 4px solid var(--line); background: #000; }
.ttwrap.short { max-height: 300px; }
table.tt { border-collapse: collapse; width: 100%; font-size: 20px; text-align: center; }
table.tt th { position: sticky; top: 0; background: var(--panel); font: 8px var(--pixel); color: var(--dim); padding: 8px 6px; font-weight: normal; }
table.tt td { padding: 0 6px; }
table.tt tr:nth-child(even) td { background: #08080e; }
table.tt .first { border-left: 4px solid var(--line); }
table.tt th.out { color: var(--or); }
table.kmap { border-collapse: collapse; font-size: 22px; text-align: center; margin: 4px 0; }
table.kmap th { font-size: 18px; color: var(--dim); font-weight: normal; padding: 2px 8px; }
table.kmap th.corner { font-size: 16px; color: var(--bl); }
table.kmap td { width: 48px; height: 40px; border: 2px solid var(--line); background: #000; }
table.kmap td.v1 { background: #ff7a1818; }
table.kmap td.hl { background: var(--bl-lo); color: #fff; border-color: var(--bl-hi); }
details.syntax { margin-top: 18px; border-top: 4px dashed var(--line); padding-top: 8px; }
details.syntax summary { font: 8px var(--pixel); color: var(--bl); }
details.syntax code { margin-right: 6px; }
#scope { display: block; width: 100%; height: 80px; border: 4px solid var(--line); background: #000; image-rendering: pixelated; }

/* themed dropdown (from the main site) */
.dd { position: relative; display: inline-block; vertical-align: middle; }
.dd-btn { min-width: 100px; background: #000; color: var(--text); font: 21px var(--mono); text-align: left; border: 4px solid var(--line); padding: 3px 36px 3px 10px; position: relative; }
.dd-btn::after { content: ''; position: absolute; right: 10px; top: calc(50% - 3px); border: 6px solid transparent; border-top: 6px solid var(--or); border-bottom: 0; }
.dd-btn:hover, .dd-btn:focus-visible, .dd-btn[aria-expanded="true"] { border-color: var(--or); outline: none; }
.dd-btn[aria-expanded="true"]::after { border-top: 0; border-bottom: 6px solid var(--or); }
.dd-list { position: absolute; z-index: 20; left: 0; min-width: 100%; top: calc(100% - 4px); margin: 0; padding: 0; list-style: none;
  background: var(--panel); border: 4px solid var(--or); box-shadow: 4px 4px 0 #000; max-height: 240px; overflow-y: auto; font: 21px var(--mono); }
.dd-list li { padding: 3px 12px 3px 28px; position: relative; cursor: var(--cur-link); white-space: nowrap; }
.dd-list li[aria-selected="true"]::before { content: '>'; position: absolute; left: 10px; color: var(--or); }
.dd-list li.active { background: var(--or); color: #000; }
.dd-list li.active::before { color: #000; }

/* context menu (the main site's menus) */
.menu { position: fixed; z-index: 500; min-width: 220px; padding: 6px; background: var(--panel);
  box-shadow: 0 -4px 0 0 var(--line), 0 4px 0 0 var(--line), -4px 0 0 0 var(--line), 4px 0 0 0 var(--line), 8px 8px 0 4px #0009; }
.menu button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--text); font: 9px var(--pixel); text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--or); color: #000; outline: none; }
.menu kbd { font: 16px var(--mono); color: var(--dim); }
.menu button:hover kbd, .menu button:focus-visible kbd { color: #000; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 0; padding: 18px 20px; width: min(520px, 94vw); max-height: 88vh; overflow: auto;
  box-shadow: 0 -4px 0 0 var(--or), 0 4px 0 0 var(--or), -4px 0 0 0 var(--or), 4px 0 0 0 var(--or), 10px 10px 0 4px var(--bl-lo); }
dialog.wide { width: min(760px, 94vw); }
dialog::backdrop { background: #000c; }
dialog h2 { font-size: 13px; color: var(--or); margin: 0 0 14px; line-height: 1.5; }
dialog h4 { font-size: 8px; color: var(--bl); margin: 18px 0 8px; }
dialog p { margin: 8px 0; }
dl.keys { gap: 6px 18px; font-size: 19px; }
dl.keys dt { color: var(--or-hi); }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.legend i { display: inline-block; width: 26px; height: 5px; margin-right: 10px; vertical-align: middle; }
.exlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.ex { display: grid; gap: 6px; text-align: left; padding: 12px; background: #000; color: var(--text); border: 4px solid var(--line); font: 19px/1.2 var(--mono); }
.ex b { font: 9px var(--pixel); color: var(--or); font-weight: normal; }
.ex:hover, .ex:focus-visible { border-color: var(--or); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--bl-lo); }

#toast {
  position: fixed; left: 50%; bottom: 60px; transform: translate(-50%, 400%); z-index: 900; visibility: hidden; max-width: 92vw; text-align: center;
  font: 10px/1.5 var(--pixel); background: var(--or); color: #000; padding: 12px 16px;
  box-shadow: 0 -4px 0 0 #000, 0 4px 0 0 #000, -4px 0 0 0 #000, 4px 0 0 0 #000, 8px 8px 0 0 var(--bl);
  transition: transform .25s steps(4), visibility .25s;
}
#toast.on { transform: translate(-50%, 0); visibility: visible; }
.nojs { padding: 20px; }

/* ---------- narrower screens: the tools become a drawer, then the parts too ---------- */
.mobilebar { display: none; }
#scrim { display: none; }
@media (max-width: 1100px) {
  .app, body.side-hidden .app { grid-template-columns: 200px minmax(0, 1fr); }
  body.side-hidden .side { display: flex; } /* a drawer here: hiding and resizing are for wide screens */
  .side-grip, .side-hide, body.side-hidden .side-show { display: none !important; }
  .side { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); transform: translateX(105%); transition: transform .2s steps(4); box-shadow: -8px 0 0 #000; }
  body.show-side .side { transform: none; }
  .mobilebar { display: flex; position: fixed; z-index: 30; right: 10px; bottom: 54px; gap: 0; }
  #mParts { display: none; }
  body.show-side #scrim, body.show-parts #scrim { display: block; position: fixed; inset: 0; z-index: 35; background: #000a; }
}
@media (max-width: 760px) {
  body { font-size: 20px; }
  .app, body.side-hidden .app { grid-template-columns: minmax(0, 1fr); }
  .parts { position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-105%); transition: transform .2s steps(4); box-shadow: 8px 0 0 #000; }
  body.show-parts .parts { transform: none; }
  .mobilebar { left: 8px; right: auto; bottom: 50px; }
  #mParts { display: inline-block; }
  .zoom { bottom: 58px; }
  .status { font-size: 16px; }
  #counts, #coords, .tog { display: none; }
  .glitch { font-size: 15px; }
  .hud { padding: 2px 6px; gap: 2px 8px; }
  .btn.sm { font-size: 8px; padding: 8px 8px; }
  .modebar { top: 6px; font-size: 16px; }
  body.busy .mobilebar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.lite *, .lite *::before, .lite *::after { animation: none !important; transition: none !important; }

/* ---------- tools bar: shared pieces ---------- */
.intro { color: #c9c7d1; font-size: 19px; margin: 12px 0 6px !important; padding-left: 10px; border-left: 4px solid var(--bl-lo); }
.empty { margin: 12px 0; padding: 10px 12px; border: 4px dashed var(--line); }
.empty b { font: 8px var(--pixel); color: var(--or); font-weight: normal; }
.empty p { margin: 6px 0 0; color: #c9c7d1; }
details.sec { margin: 14px 0 0; border-top: 4px solid var(--line); padding-top: 4px; }
details.sec > summary { font: 8px/1.6 var(--pixel); color: var(--bl); padding: 6px 0; list-style: none; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: '+'; display: inline-block; width: 16px; color: var(--or); }
details.sec[open] > summary::before { content: '-'; }
details.sec > summary:hover { color: var(--bl-hi); }
.seg { display: inline-flex; border: 2px solid var(--line); }
.seg button { font: 7px var(--pixel); padding: 7px 8px; color: var(--dim); background: #000; border: 0; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button[aria-checked="true"] { color: #000; background: var(--or); }
.seg button:hover:not([aria-checked="true"]) { color: var(--text); }
.linkbtn { font: inherit; color: var(--bl); background: none; border: 0; padding: 0 0 0 6px; text-decoration: underline; }
.linkbtn:hover { color: var(--or); }
/* EDIT */
.phead { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.phead canvas { flex: none; background: #000; border: 2px solid var(--line); }
.phead h3 { margin: 0 0 4px !important; }
.phead p { margin: 0 !important; }
.now { font-size: 22px; }
.stepper small { margin-left: 8px; font-size: 16px; }
.actions { border-top: 4px dashed var(--line); padding-top: 10px; margin-top: 14px; }
/* TABLE */
table.tt.click tbody tr { cursor: var(--cur-link); }
table.tt.click tbody tr:hover td { background: #16162a; }
table.tt tbody tr.now td { background: #ff7a1826 !important; box-shadow: inset 0 2px 0 var(--or), inset 0 -2px 0 var(--or); }
table.tt tbody tr.now td:first-child::before { content: '>'; color: var(--or); margin-right: 4px; }
dl.exprs { margin-top: 10px; }
dl.exprs code { margin-right: 6px; }
/* BOOLEAN */
#expr { font-size: 24px; }
.opkeys, .examples { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.key { font: 18px var(--mono); min-width: 30px; padding: 2px 8px; color: var(--text); background: var(--panel); border: 2px solid var(--line); box-shadow: inset -2px -2px 0 #000; }
.key:hover, .key:focus-visible { border-color: var(--or); color: var(--or-hi); }
.key.wide { font-size: 17px; }
.exprstatus { min-height: 28px; margin: 4px 0 8px; font-size: 19px; }
.exprstatus.ok { color: var(--ok); }
.exprstatus.ok b, .exprstatus.err b { font: 7px var(--pixel); font-weight: normal; }
.exprstatus.err { color: #ffb3c0; border: 2px solid #8c0f2a; background: #ff3b5c12; padding: 6px 8px; }
.exprstatus .where { display: block; margin: 4px 0; color: var(--text); font-size: 21px; white-space: pre-wrap; word-break: break-all; }
.exprstatus mark { background: var(--bad); color: #000; padding: 0 1px; animation: blink 1s steps(2) infinite; }
#labOut.stale { opacity: .4; }
.helpbox { margin: 8px 0 4px; border: 2px solid var(--bl-lo); box-shadow: inset 0 0 0 2px #000; background: #03060c; padding: 0 10px; }
.helpbox > summary { font: 8px/1.6 var(--pixel); color: var(--bl); padding: 8px 0; list-style: none; }
.helpbox > summary::-webkit-details-marker { display: none; }
.helpbox > summary::before { content: '? '; color: var(--or); }
.helpbox[open] > summary { border-bottom: 2px dashed var(--line); margin-bottom: 6px; }
table.syntax { width: 100%; border-collapse: collapse; font-size: 18px; }
table.syntax th { font: 7px var(--pixel); color: var(--or); text-align: left; padding: 6px 6px 6px 0; font-weight: normal; white-space: nowrap; vertical-align: top; }
table.syntax thead th { color: var(--dim); }
table.syntax td { padding: 3px 4px; vertical-align: top; }
table.syntax tbody tr + tr { border-top: 1px solid #15151f; }
table.syntax code { display: inline-block; white-space: nowrap; margin: 0 6px 2px 0; padding: 0 4px; background: #000; border: 1px solid var(--line); color: var(--or-hi); }
ul.rules { margin: 10px 0; padding-left: 18px; font-size: 18px; color: #c9c7d1; }
ul.rules li { margin: 4px 0; }
ul.rules b { color: var(--text); font-weight: normal; }
.result { margin: 10px 0; padding: 4px 12px 8px; border: 4px solid var(--or); box-shadow: 6px 6px 0 var(--bl-lo); background: #0a0604; }
.rhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rhead h4 { color: var(--or) !important; margin: 10px 0 4px !important; }
.result .big { font-size: 30px; line-height: 1.3; overflow-wrap: anywhere; }
.result .fname { color: var(--dim); }
.result .big .term { padding: 0 3px; border: 2px solid transparent; }
.result .big .term:hover, .result .big .term:focus { border-color: var(--bl); outline: none; color: var(--text); }
.result .build { margin-top: 4px; }
code.mid { font-size: 22px; overflow-wrap: anywhere; }
#cmpSec input { margin-top: 6px; }
table.syntax td:last-child { white-space: nowrap; }
.lblrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.lblrow .linkbtn { font: 7px var(--pixel); text-decoration: none; padding: 0; }
