/* colours: dark by default; Extras > Appearance sets data-appearance=light, Extras > Theme the accent */
:root {
  --bg: #15171a; --surface: #1e2125; --surface-2: #262a2f; --line: #343940; --line-2: #56606b;
  --text: #e6e8eb; --muted: #9aa3ad; --faint: #6c757f;
  --accent: #4f9cf5; --on-accent: #08131f; --ok: #3fcf8e; --warn: #f0b34a; --bad: #f0685c;
  --field: #14161a; --raised: #23272c; --raised-line: #4a525c; --inset: #1a1d21; --code-bg: #101214;
  --block: var(--surface); --block-line: #454c55; --dut-bg: #22211c; --dut-line: #5a5340;
  --dot-bg: #17191d; --dot-line: #8b95a1; --tag-bg: #2b3138;
  --shadow: rgba(0, 0, 0, .5); --shadow-soft: rgba(0, 0, 0, .35);
  --toast-bad-bg: #3a1f1c; --toast-bad-text: #ffd9d4; --danger-text: #ff9b91;
  --sheet-default: #17191d; --page-line: rgba(255, 255, 255, .28);
  --sel: color-mix(in srgb, var(--accent) 35%, transparent);
  --sel-soft: color-mix(in srgb, var(--accent) 20%, transparent);
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
:root[data-appearance=light] {
  --bg: #eceef2; --surface: #ffffff; --surface-2: #f1f3f6; --line: #d6dbe2; --line-2: #b7c0cb;
  --text: #1c2127; --muted: #5d6874; --faint: #9aa3ad;
  --field: #ffffff; --raised: #ffffff; --raised-line: #c3cad3; --inset: #f6f7f9; --code-bg: #f4f5f7;
  --block: #ffffff; --block-line: #b5bec9; --dut-bg: #fbf6e7; --dut-line: #d5c48f;
  --dot-bg: #ffffff; --dot-line: #7d8894; --tag-bg: #e7ebf0;
  --shadow: rgba(30, 40, 55, .22); --shadow-soft: rgba(30, 40, 55, .14);
  --toast-bad-bg: #fff0ee; --toast-bad-text: #8a1f14; --danger-text: #c43c2c;
  --sheet-default: #f7f8fa; --page-line: rgba(0, 0, 0, .3);
  color-scheme: light;
}
:root[data-theme=teal] { --accent: #26b5a5; }
:root[data-theme=green] { --accent: #3fbf7f; }
:root[data-theme=amber] { --accent: #e8a33d; }
:root[data-theme=violet] { --accent: #9d7cf0; }
:root[data-theme=rose] { --accent: #e5677d; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; }
button:hover { border-color: var(--line-2); }
button:disabled { cursor: default; opacity: .5; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.danger:hover { border-color: var(--bad); color: var(--bad); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select, input[type=text], input[type=search], input[type=number], input[type=url], textarea {
  background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; color: var(--text); }
code { font-family: var(--mono); font-size: 12.5px; }

/* the header: the project, its menus, a toolbar */
.top { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.title-row { display: flex; align-items: center; gap: 12px; padding: 7px 14px 2px; flex-wrap: wrap; }
.top .grow, .toolbar .grow { flex: 1; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: .5px; flex: none; }
.doc { display: flex; flex-direction: column; min-width: 0; }
.doc-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.doc-name { border: 0; background: transparent; padding: 1px 5px; margin-left: -5px; font-size: 15.5px; font-weight: 600; border-radius: 5px;
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-name:hover { background: var(--surface-2); }
.save-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.menubar { display: flex; margin-left: -6px; }
.mb-item { border: 0; background: transparent; padding: 2px 8px; font-size: 13px; border-radius: 5px; }
.mb-item:hover, .mb-item.open { background: var(--surface-2); }
.share-btn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 5px; padding: 5px 14px 6px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 5px; }
.toolbar[hidden] { display: none; }
.tb { min-width: 30px; height: 28px; padding: 0 7px; font-size: 14px; line-height: 1; }
.tb.on { border-color: var(--accent); color: var(--accent); }
.tb-zoom { min-width: 58px; font-size: 12.5px; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.ro-badge { font-size: 11.5px; font-weight: 700; letter-spacing: .4px; padding: 2px 8px; border-radius: 4px; background: var(--sel-soft); color: var(--accent); }
.ro-badge[hidden] { display: none; }
.hint { color: var(--muted); background: var(--field); padding: 3px 8px; border-radius: 5px; border: 1px solid var(--line); }
.conn { font-size: 12px; color: var(--warn); white-space: nowrap; }
.conn::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.conn.ok { color: var(--ok); }
.empty { text-align: center; color: var(--muted); margin-top: 80px; }
/* the Schematic and Python tabs at the start of the toolbar */
.view-tabs { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--field); border: 1px solid var(--line); }
.view-tabs button { border: 0; background: transparent; border-radius: 6px; padding: 3px 13px; color: var(--muted); font-weight: 600; font-size: 13px; }
.view-tabs button:hover { color: var(--text); }
.view-tabs button[aria-selected=true] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.view-tabs button.away::after { content: " ⧉"; color: var(--accent); }   /* Python is open in its own window */
/* while the Python tab shows, the schematic's tools rest (the schematic itself goes on underneath) */
body.py-mode .toolbar > :not(.view-tabs, .hint, .grow, [data-cmd="view.fullscreen"]) { display: none; }

/* three panes: catalog | bench | DUT library (and the Format panel) */
html, body { height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }
.work { flex: 1; min-height: 0; display: flex; position: relative; }
.side { flex: none; width: 290px; overflow-y: auto; background: var(--surface); padding: 12px 12px 20px; border-right: 1px solid var(--line); }
#right { border-right: 0; border-left: 1px solid var(--line); width: 310px; }
#format { border-right: 0; border-left: 1px solid var(--line); width: 280px; padding: 4px 12px 20px; }
.side[hidden] { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.side h2 { font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.side .seg button, .side-head > button { font-size: 12.5px; padding: 3px 9px; }
.search { width: 100%; margin-bottom: 8px; }
.side-note { color: var(--muted); font-size: 12.5px; margin: 14px 2px 0; }
.side-note b { color: var(--text); font-weight: 600; }
.group { border-top: 1px solid var(--line); }
.group summary { cursor: pointer; padding: 8px 4px; font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; list-style-position: inside; }
.group summary .count { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 12px; }
.item { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: 6px; cursor: grab; border: 1px solid transparent; }
.item:hover { background: var(--surface-2); border-color: var(--line); }
.item:active { cursor: grabbing; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.item-main b { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.item-main small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--tag-bg); color: var(--muted); white-space: nowrap; }
.tag.full { background: rgba(63, 207, 142, .16); color: var(--ok); }
.mini { padding: 0; width: 26px; height: 26px; flex: none; font-size: 15px; line-height: 1; }
.mini:disabled { opacity: .35; cursor: default; }
.ghost[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
#dut-form { background: var(--inset); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
#dut-form[hidden] { display: none; }
#dut-form h3 { margin: 0; font-size: 13px; }
#dut-form .row { margin: 4px 0 0; }

/* schematic: a canvas scaled by the zoom inside a sizer that gives the scroll area */
.center { flex: 1; min-width: 0; position: relative; }
/* z-index 0: the schematic is its own layer, so its handles never cover the floating windows */
#bench { position: absolute; inset: 0; overflow: auto; z-index: 0; background: var(--sheet-bg, var(--sheet-default)); }
.center.with-ruler #bench { top: 20px; left: 20px; }
.center.with-tabs #bench { bottom: 31px; }
#bench.drop-ok { outline: 2px dashed var(--accent); outline-offset: -6px; }
#sizer { position: relative; width: 3200px; height: 2000px; overflow: hidden; }
/* the sheet: its colour and grid are set from the right-click menu (applySheet in app.js) */
#canvas { position: absolute; left: 0; top: 0; width: 3200px; height: 2000px; transform-origin: 0 0; background: var(--sheet-bg, var(--sheet-default)); }
#bench:not([data-grid=lines]):not([data-grid=none]) #canvas {
  background-image: radial-gradient(circle, var(--sheet-dot, #2c3138) 1.2px, transparent 1.4px); background-size: 20px 20px; }
#bench[data-grid=lines] #canvas {
  background-image: linear-gradient(var(--sheet-line, #212429) 1px, transparent 1px),
                    linear-gradient(90deg, var(--sheet-line, #212429) 1px, transparent 1px);
  background-size: 20px 20px; }
.center:has(#bench.sheet-light) > .empty { color: #4d555e; }
#wires { position: absolute; inset: 0; width: 100%; height: 100%; }
#guides { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
#guides line { stroke: #ff4fa3; stroke-width: 1; stroke-dasharray: 4 3; }
#page-outline { position: absolute; left: 0; top: 0; border: 1.5px dashed var(--page-line); pointer-events: none; }
#page-outline[hidden] { display: none; }
#page-outline span { position: absolute; right: 6px; bottom: 4px; font-size: 11px; color: var(--page-line); }
#nodes { position: absolute; inset: 0; pointer-events: none; }   /* empty space: the wires below get the pointer */
.center > .empty { position: absolute; left: 0; right: 0; top: 38%; margin: 0; padding: 0 30px; pointer-events: none; }
.keys-hint { color: var(--muted); font-size: 12.5px; }
.wire { fill: none; stroke: #4f9cf5; stroke-width: 2.5; pointer-events: none; stroke-linejoin: round; stroke-linecap: round; }
.wire.selected { stroke-width: 3; }
.wire-halo { fill: none; stroke-width: 10; opacity: .3; pointer-events: none; stroke-linejoin: round; }
.wire.temp { stroke-dasharray: 6 5; opacity: .8; }
.wire.xpage { stroke-dasharray: 5 4; opacity: .75; }
.xpage-label { font-size: 11px; fill: var(--muted); pointer-events: none; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 16; cursor: pointer; pointer-events: stroke; }
body.read-only .wire-hit { cursor: default; }
/* handles of the selected wire: ends, bends, middles of runs */
.wh { position: absolute; pointer-events: auto; transform: translate(-50%, -50%); touch-action: none; z-index: 3; box-sizing: border-box; }
.wh:hover { transform: translate(-50%, -50%) scale(1.3); }
.wh-end { width: 15px; height: 15px; border-radius: 50%; background: var(--warn); border: 2px solid #17191d; cursor: grab; }
.wh-bend { width: 12px; height: 12px; border-radius: 2px; background: #f2f4f6; border: 2px solid #17191d; cursor: move; }
.wh-mid { width: 12px; height: 12px; border-radius: 50%; background: #17191d; border: 2px solid #f2f4f6; cursor: grab; opacity: .9; }
.marquee { position: absolute; border: 1px dashed var(--accent); background: var(--sel-soft); pointer-events: none; z-index: 4; }
/* what is selected, and what can be done with it */
.selbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 12px; max-width: calc(100% - 20px); flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 9px; box-shadow: 0 8px 24px var(--shadow); font-size: 13px; }
.center.with-ruler .selbar { top: 30px; }
.selbar[hidden] { display: none; }
.selbar .sb-label { color: var(--muted); white-space: nowrap; }
.selbar .swatches { display: flex; gap: 5px; }
.selbar .swatch { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid #17191d; }
.selbar .swatch:hover, .selbar .swatch:focus-visible { outline: 2px solid #f2f4f6; outline-offset: 1px; }
.selbar button { padding: 3px 10px; font-size: 12.5px; }
.selbar .sb-x { border: 0; background: transparent; font-size: 17px; line-height: 1; padding: 0 6px; color: var(--muted); }

/* rulers along the top and left of the schematic */
.ruler { position: absolute; z-index: 2; background: var(--surface); }
.ruler[hidden] { display: none; }
#ruler-x { left: 20px; right: 0; top: 0; height: 20px; border-bottom: 1px solid var(--line); }
#ruler-y { left: 0; top: 20px; bottom: 0; width: 20px; border-right: 1px solid var(--line); }
.center.with-ruler::before { content: ""; position: absolute; left: 0; top: 0; width: 20px; height: 20px; background: var(--surface); z-index: 2;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.center.with-tabs #ruler-y { bottom: 31px; }

/* page tabs along the bottom */
.pagetabs { position: absolute; left: 0; right: 0; bottom: 0; height: 31px; display: none; align-items: stretch; gap: 2px; padding: 0 8px;
  background: var(--surface); border-top: 1px solid var(--line); z-index: 7; overflow-x: auto; }
.center.with-tabs .pagetabs { display: flex; }
.pagetabs button { border: 0; border-radius: 0; background: transparent; padding: 0 12px; font-size: 12.5px; white-space: nowrap; color: var(--muted); border-top: 2px solid transparent; }
.pagetabs button.active { color: var(--text); border-top-color: var(--accent); background: var(--surface-2); }
.pagetabs .pt-add { font-size: 16px; padding: 0 10px; }
.center.with-tabs #toast { bottom: 44px; }

.node { position: absolute; pointer-events: auto; background: var(--block); border: 1.5px solid var(--block-line); border-radius: 9px; cursor: grab; user-select: none; touch-action: none; box-shadow: 0 4px 14px var(--shadow-soft); }
.node:active { cursor: grabbing; }
body.read-only .node, .node.locked { cursor: default; }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--sel), 0 4px 14px var(--shadow-soft); }
.node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.node.hinted { outline: 2px dashed var(--accent); outline-offset: 3px; }   /* a menu item points at it */
.node.found { outline: 2px solid var(--warn); outline-offset: 3px; }      /* Find */
.node.dim { opacity: .28; }                                                /* Tags: not showing this tag */
.node.inst { width: 220px; z-index: 1; }
.node.dut { width: 180px; border-color: var(--dut-line); background: var(--dut-bg); z-index: 1; }
.node.dut.selected { border-color: var(--accent); }
/* a T node: one signal split 2 to 8 ways */
.node.tee { width: 160px; border-color: #3fb6a8; background: var(--dut-bg); z-index: 1; }
.node.tee.selected { border-color: var(--accent); }
.node.tee .tee-glyph { flex: none; width: 18px; height: 18px; border-radius: 4px; background: #3fb6a8; color: #0d2421;
  font-weight: 800; font-size: 12px; line-height: 18px; text-align: center; }
.node.tee .n-value { font-size: 11.5px; }
.node.tee .n-value.warn, .tee-level.warn { color: var(--warn); }
.tee-ed .tee-level { margin: 8px 0 10px; font-size: 13px; }
.tee-ed .tee-level .note { margin: 3px 0 0; }
.tee-ports { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tee-ports th, .tee-ports td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.tee-ports thead th { color: var(--muted); font-weight: 600; }
.tee-ports input.num { width: 64px; }
.tee-ports .tee-wired { max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.tee-ports .tee-delay { color: var(--muted); }
.tee-ports .tee-custom input.num { width: 52px; }
/* Edit Style: a block's own colour; Lock; Collapse */
.node.styled { border-color: var(--blk); }
.node.styled .n-head { background: color-mix(in srgb, var(--blk) 26%, transparent); border-radius: 7px 7px 0 0; }
.node.styled.selected { border-color: var(--accent); }
.node.locked .n-head b::after, .node.note.locked::after { content: "\1F512"; font-size: 10px; margin-left: 5px; opacity: .75; }
.node.collapsed .n-screen, .node.collapsed .n-meta, .node.collapsed .n-open, .node.collapsed .n-value { display: none; }
.node.collapsed .n-ports { padding-top: 0; }
.n-link { border: 0; background: transparent; padding: 0 4px; height: 22px; color: var(--accent); font-size: 13px; line-height: 1; flex: none; }
/* notes written on the sheet: under the blocks; "plain" is text only, in the sheet's ink */
.node.note { min-width: 60px; max-width: 280px; padding: 7px 11px; border-radius: 3px; border-color: #d8c25a; background: #f5e48f; color: #2f2a12;
  font-size: 13px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }
.node.note.c-blue { background: #bfdcff; border-color: #8db8ec; color: #102a46; }
.node.note.c-green { background: #c3efd6; border-color: #86cfa6; color: #11331f; }
.node.note.c-pink { background: #ffcfe0; border-color: #eb9dbb; color: #47142a; }
.node.note.c-plain { background: transparent; border-color: transparent; box-shadow: none; color: var(--sheet-ink, #e6e8eb); font-size: 14px; }
.node.note.c-plain:hover { border-color: rgba(127, 127, 127, .35); }
.node.note.sz-s { font-size: 11.5px; }
.node.note.sz-l { font-size: 17px; }
.node.note.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--sel), 0 3px 10px rgba(0, 0, 0, .3); }
.node.note.editing { cursor: text; z-index: 2; }
.note-edit { display: block; width: 240px; min-height: 2.9em; margin: 0; padding: 0; border: 0; outline: none; resize: none;
  background: transparent; color: inherit; font: inherit; line-height: inherit; overflow: hidden; }
.note-edit::placeholder { color: inherit; opacity: .55; }
.n-rename { flex: 1; min-width: 0; padding: 1px 6px; font-size: 13.5px; font-weight: 600; }
.n-head { display: flex; align-items: center; gap: 6px; padding: 6px 6px 4px 11px; }
.n-head b { flex: 1; font-size: 13.5px; overflow-wrap: anywhere; line-height: 1.2; }
.n-x { border: 0; background: transparent; padding: 0; width: 24px; height: 24px; font-size: 18px; line-height: 1; color: var(--muted); border-radius: 5px; flex: none; }
.n-x:hover { color: var(--bad); background: rgba(240, 104, 92, .12); }
body.read-only .n-x, .node.locked .n-x { display: none; }
.n-screen { margin: 0 9px; padding: 5px 8px; min-height: 28px; border-radius: 4px; background: #060a09; color: #58f0dc; font: 13px/1.35 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 10px 2px 11px; }
.n-meta code { color: var(--muted); font-size: 11.5px; }
.n-value { padding: 0 11px 2px; color: var(--muted); font: 12.5px var(--mono); }
.n-ports { padding: 4px 0 6px; }
/* terminals: rows down the left and right sides, cells along the top and bottom (a turned block) */
.port-row { position: relative; display: flex; align-items: center; height: 24px; padding: 0 12px; font-size: 12px; color: var(--muted); }
.port-row.right { justify-content: flex-end; }
.dot { position: absolute; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--dot-bg); border: 2.5px solid var(--dot-line); cursor: crosshair; touch-action: none; }
.port-row.left .dot { left: -9px; }
.port-row.right .dot { right: -9px; }
.port-note { margin: 0 8px; color: var(--faint); font: 11.5px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.port-row .port-label { flex: none; }
.node.dut.multi { width: 250px; }
/* the port editor: a card per port (a DUT block's window, a custom DUT in the right pane) */
.port-ed { display: flex; flex-direction: column; gap: 8px; }
.port-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
.port-card-head { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.port-card-head .port-name { flex: 1; min-width: 0; font-family: var(--mono); }
.port-card .port-std { width: 100%; margin-bottom: 8px; }
.port-card .fields { margin-bottom: 0; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.port-hint { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.port-hint:empty { display: none; }
.port-add { align-self: flex-start; }
.n-strip { display: flex; gap: 4px; padding: 0 8px; }
.n-strip.top { padding-top: 11px; }
.n-strip.bottom { padding-bottom: 11px; }
.port-cell { position: relative; flex: 1 1 0; min-width: 0; text-align: center; font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.port-cell .port-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n-strip .dot { left: 50%; margin-left: -8px; }
.n-strip.top .dot { top: -20px; }
.n-strip.bottom .dot { top: auto; bottom: -20px; }
.dot:hover, .dot.target { border-color: var(--accent); background: var(--accent); }
.dot.wired { border-color: #4f9cf5; background: color-mix(in srgb, #4f9cf5 45%, var(--dot-bg)); }
body.read-only .dot { cursor: default; }
.n-open { display: block; width: calc(100% - 18px); margin: 0 9px 9px; padding: 3px 0; font-size: 12.5px; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; padding: 5px 12px; border-radius: 7px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13px; box-shadow: 0 6px 18px var(--shadow); }
body.dragging { cursor: grabbing; user-select: none; }
.item { user-select: none; touch-action: none; }

/* floating windows */
#windows { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.win { position: absolute; pointer-events: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 14px 40px var(--shadow); min-width: 380px; max-width: calc(100% - 10px); max-height: calc(100% - 10px); display: flex; flex-direction: column; resize: horizontal; overflow: hidden; }
.win:focus { outline: none; border-color: var(--accent); }
.win.dut-win { width: 430px; resize: none; }
.win-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; cursor: move; border-bottom: 1px solid var(--line); flex-wrap: wrap; user-select: none; touch-action: none; }
.win-sub { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.win-body { overflow-y: auto; }
.inst-win .panel-fit { margin: 10px 12px 12px; }
#toast { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; background: var(--toast-bad-bg); border: 1px solid var(--bad); color: var(--toast-bad-text); padding: 8px 16px; border-radius: 8px; max-width: 80%; }
#toast.info { background: var(--surface-2); border-color: var(--line-2); color: var(--text); }
#toast[hidden] { display: none; }

/* right-click menus, the menu bar's menus and the picker (menu.js) */
.ctx { position: fixed; z-index: 200; min-width: 210px; max-width: min(360px, calc(100vw - 8px)); max-height: calc(100vh - 8px); overflow-y: auto;
  padding: 5px; background: var(--raised); border: 1px solid var(--raised-line); border-radius: 9px; box-shadow: 0 12px 32px var(--shadow);
  font-size: 13px; color: var(--text); }
.ctx:focus { outline: none; }
.ctx-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 10px; border: 0; border-radius: 6px;
  background: transparent; text-align: left; font-size: 13px; line-height: 1.35; opacity: 1; }
.ctx-item:focus, .ctx-item[aria-expanded=true] { background: var(--sel-soft); outline: none; }
.ctx-item:disabled { color: var(--faint); cursor: default; opacity: 1; }
.ctx-item.danger:not(:disabled) { color: var(--danger-text); }
.ctx-item.danger:focus { background: rgba(240, 104, 92, .16); }
.ctx-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-key { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ctx-tick { width: 12px; flex: none; color: var(--accent); }
.ctx-sep { height: 1px; margin: 5px 6px; background: var(--line); }
.ctx-head { padding: 3px 10px 5px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-swatches { display: flex; flex-wrap: wrap; gap: 7px; padding: 5px 10px 7px; }
.ctx-swatch { width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 2px solid #15171a; background: var(--sw); }
.ctx-swatch.active { box-shadow: 0 0 0 2px var(--text); }
.ctx-swatch:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctx-pick { width: 320px; display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.ctx-pick .ctx-head { padding: 0 2px; }
.ctx-search { width: calc(100% - 4px); margin: 2px 2px 4px; }
.ctx-results:empty { display: none; }
.ctx-list { max-height: min(300px, 60vh); overflow-y: auto; }
.ctx-opt { display: flex; flex-direction: column; padding: 5px 9px; border-radius: 6px; cursor: pointer; line-height: 1.3; }
.ctx-opt[aria-selected=true] { background: var(--sel-soft); }
.ctx-opt b { font-weight: 600; }
.ctx-opt small { color: var(--muted); font-size: 12px; }
.ctx-none { padding: 6px 9px; color: var(--muted); }
.ctx-color { position: fixed; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
@media (pointer: coarse) { .ctx-item { padding: 9px 12px; } .ctx-opt { padding: 8px 10px; } }

/* dialogs (dialog.js) */
.dlg-back { position: fixed; inset: 0; z-index: 300; background: rgba(8, 10, 12, .55); display: grid; place-items: center; padding: 16px; }
.dlg { width: min(470px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 20px 60px var(--shadow); }
.dlg.wide { width: min(780px, 100%); }
/* Help > Quick Start Video */
.dlg.video { width: min(980px, 100%); }
.qs { display: flex; flex-direction: column; gap: 10px; }
.qs-video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; border: 0; border-radius: 8px; }
.qs-caption { min-height: 2.95em; padding: 6px 14px; border-radius: 6px; background: var(--surface-2); text-align: center;
              font-size: 14.5px; line-height: 1.45; display: grid; place-items: center; }
.qs-chapters { display: flex; flex-wrap: wrap; gap: 6px; }
.qs-chap { font-size: 12.5px; padding: 3px 11px; border-radius: 14px; }
.qs-chap.on { border-color: var(--accent); color: var(--accent); }
.qs-t { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 5px; }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 6px 18px; }
.dlg-head h2 { flex: 1; margin: 0; font-size: 16px; }
.dlg-x { border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 0 6px; color: var(--muted); }
.dlg-body { padding: 6px 18px 10px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px 14px; flex-wrap: wrap; }
.dlg-error { color: var(--bad); margin: 0 18px 4px; font-size: 13px; }
.dlg-error[hidden] { display: none; }
.dlg-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.dlg-field > span { color: var(--muted); font-size: 12.5px; }
.dlg-field input, .dlg-field select, .dlg-field textarea { width: 100%; }
.dlg-field small { color: var(--muted); font-size: 12px; }
.dlg-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.dlg-text { margin: 0; line-height: 1.5; }
.dlg-text a, .dlg a { color: var(--accent); }
.dlg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.dlg-muted { color: var(--muted); font-size: 12.5px; margin: 0; }
.dlg-sub { margin: 6px 0 -4px; font-size: 13.5px; font-weight: 650; }
.dlg-sub:first-child { margin-top: 0; }
.dlg-path { display: block; margin-top: 3px; word-break: break-all; font-size: 12px; }
.dlg textarea.code { font: 12.5px/1.45 var(--mono); min-height: 340px; resize: vertical; white-space: pre; }
.proj-list { border: 1px solid var(--line); border-radius: 8px; max-height: 340px; overflow-y: auto; }
.proj { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.proj:last-child { border-bottom: 0; }
.proj:hover, .proj:focus-visible { background: var(--surface-2); outline: none; }
.proj.current { background: var(--sel-soft); }
.proj b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj small { color: var(--muted); font-size: 12px; }
.proj .proj-acts { grid-row: span 2; display: flex; gap: 4px; align-items: center; }
.proj .proj-acts button { padding: 2px 8px; font-size: 12px; }
.keys-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.keys-table td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.keys-table td:last-child { text-align: right; white-space: nowrap; }
kbd { font: 12px var(--mono); padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }
.about-logo { width: 56px; height: 56px; border-radius: 12px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }
.share-links { display: flex; gap: 8px; flex-wrap: wrap; }
.share-links a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--text); font-size: 13px; }
.share-links a:hover { border-color: var(--accent); }

/* tool panels: Outline, Text outline, Layers, Tags, Find (dialog.js panel) */
.tp { position: absolute; z-index: 8; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 12px 32px var(--shadow);
  display: flex; flex-direction: column; max-height: calc(100% - 20px); }
.tp:focus { outline: none; }
.tp-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; cursor: move; border-bottom: 1px solid var(--line); user-select: none; touch-action: none; }
.tp-head b { flex: 1; font-size: 13px; }
.tp-x { border: 0; background: transparent; font-size: 17px; line-height: 1; padding: 0 6px; color: var(--muted); }
.tp-body { padding: 8px 10px 10px; overflow: auto; font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.outline-map { width: 100%; height: 170px; display: block; border-radius: 6px; border: 1px solid var(--line); background: var(--sheet-bg, var(--sheet-default)); cursor: crosshair; touch-action: none; }
.list-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; cursor: pointer; min-height: 28px; }
.list-row:hover { background: var(--surface-2); }
.list-row.active { background: var(--sel-soft); }
.list-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.list-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 6px 0 2px; }
.icon-btn { border: 0; background: transparent; padding: 2px 5px; min-width: 24px; color: var(--muted); font-size: 13px; }
.icon-btn:hover { color: var(--text); }
.icon-btn.on { color: var(--accent); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-row button { padding: 3px 9px; font-size: 12.5px; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 4px 1px 9px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; }
.chip button { border: 0; background: transparent; padding: 0 3px; color: var(--muted); }
.chip.on { border-color: var(--accent); color: var(--accent); }
.chips-row { display: flex; gap: 5px; flex-wrap: wrap; }

/* the Format panel (docked on the right) */
.fp-sec { border-bottom: 1px solid var(--line); padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.fp-sec:last-child { border-bottom: 0; }
.fp-sec h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.fp-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.fp-row > span { color: var(--muted); min-width: 64px; }
.fp-row input[type=number] { width: 78px; }
.fp-row input[type=text], .fp-row input[type=url], .fp-row select { flex: 1; min-width: 0; }
.fp-row button { padding: 3px 9px; font-size: 12.5px; }
#format :is(input, select, textarea):disabled { opacity: .55; cursor: default; }
#format .dlg-check:has(input:disabled) { opacity: .55; }
.swatch-row { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 22px; height: 22px; border-radius: 50%; padding: 0; border: 2px solid var(--line-2); background: var(--sw); }
.sw.active { box-shadow: 0 0 0 2px var(--text); }
.fp-empty { color: var(--muted); font-size: 12.5px; }

.card.selected { border-color: var(--line-2); }
.card.drop-ok { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.conns { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 12px 8px; }
.conn-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 6px 3px 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.conn-chip b { font-weight: 600; color: var(--muted); text-transform: capitalize; }
.conn-chip.active { border-color: var(--accent); }
.conn-chip.open { color: var(--muted); padding-right: 10px; border-style: dashed; }
.conn-chip .x { border: 0; background: transparent; padding: 0 4px; font-size: 16px; line-height: 1; color: var(--muted); }
.conn-chip .x:hover { color: var(--bad); }
.badge.stub { background: rgba(240, 179, 74, .15); color: var(--warn); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.card:focus { outline: none; border-color: var(--line-2); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
.card-head .name { font-weight: 600; }
.card-head .res { color: var(--muted); }
.card-head .info { color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.card-head .grow { flex: 1; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .6px; padding: 2px 7px; border-radius: 4px; background: var(--tag-bg); color: var(--muted); }
.badge.twin { background: rgba(63, 207, 142, .16); color: var(--ok); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { padding: 4px 10px; font-size: 13px; }
.tabs button.active { border-color: var(--accent); color: var(--accent); }

.panel-wrap { padding: 4px 12px 14px; }
.panel-fit { position: relative; overflow: hidden; }
.panel-scale { transform-origin: 0 0; position: absolute; left: 0; top: 0; }

.inspector { border-top: 1px solid var(--line); padding: 14px 16px 16px; background: var(--inset); }
.inspector h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; }
.inspector p.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; max-width: 78ch; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.field input, .field select { color: var(--text); font-family: var(--mono); }
.check { display: flex; gap: 7px; align-items: center; color: var(--text); font-size: 13.5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 4px 12px; }
.seg button.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font-size: 12.5px; padding: 3px 9px; border-radius: 14px; }
.status { font-size: 13px; color: var(--muted); }
.status.err { color: var(--bad); }
.status.ok { color: var(--ok); }

.log { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; height: 190px; overflow-y: auto; padding: 6px 9px; white-space: pre-wrap; word-break: break-all; }
.log .w { color: #8fc0ff; } .log .r { color: #9be3b8; } .log .x { color: var(--warn); }
:root[data-appearance=light] .log .w { color: #1f5fb8; }
:root[data-appearance=light] .log .r { color: #1d7a45; }
.log time { color: #5d6670; margin-right: 8px; }
.console-in { flex: 1; min-width: 180px; font-family: var(--mono); }
pre.snippet { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; margin: 0; overflow-x: auto; user-select: all; }

/* online platform: the library links and the signed-in account in the header */
.acct-link { color: var(--text); text-decoration: none; font-size: 13px; }
.acct-link:hover { color: var(--accent); }
.site-links { display: flex; gap: 14px; padding-right: 12px; border-right: 1px solid var(--line); }
.platform .keys-hint { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.acct-link.who { color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* online catalog: instruments that are in the library but not in the lab yet */
a.item.soon { color: var(--muted); text-decoration: none; cursor: pointer; }
a.item.soon b { font-weight: 500; }
.tag.soon { background: rgba(240, 179, 74, .14); color: var(--warn); }
.side-note a { color: var(--accent); }
/* the Python tab (python.js) over the whole work area, the schematic laid out underneath; its editor stays dark */
.py-view { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; background: var(--bg); }
.py-view[hidden] { display: none; }
body.py-mode .work > :not(.py-view) { visibility: hidden; }
body.py-mode #toast { visibility: visible; bottom: 64px; }   /* messages still show, over the terminal */
.py-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.py-host[hidden], .py-away[hidden] { display: none; }
/* while Python is open in a window of its own */
.py-away { flex: 1; display: grid; place-items: center; padding: 24px; }
.py-away-card { max-width: 440px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 28px 18px; box-shadow: 0 14px 40px var(--shadow-soft); }
.py-away-card h2 { margin: 6px 0 8px; font-size: 17px; }
.py-away-card p { color: var(--muted); margin: 0 0 18px; }
.py-away-card .row { justify-content: center; }
.py-away-icon { font-size: 30px; color: var(--accent); line-height: 1; }
/* /python: Python in a window of its own (python-page.js) */
.py-page-head { display: flex; align-items: center; gap: 12px; padding: 7px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.py-page-head .logo { text-decoration: none; width: 30px; height: 30px; font-size: 12px; }
.py-page-head .grow { flex: 1; }
.py-page-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.py-page-title b { font-size: 15.5px; }
.py-page-project { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.py-closed { margin: auto; text-align: center; padding: 24px; }
.py-closed p { color: var(--muted); }
.py-closed a { color: var(--accent); }
.py { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* the toolbar's "⧉ Own window": a link, so that Ctrl+click and the middle button open a tab */
.py-detach { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 14px; white-space: nowrap; }
.py-detach:hover { border-color: var(--line-2); }
.py-detach:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.py-bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.py-bar .grow { flex: 1 0 0; }
.py-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }
.py-name { flex: 0 1 200px; min-width: 90px; }
.py-saved { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
/* files on the left, the editor on the right */
.py-main { flex: 3 1 0; min-height: 120px; display: flex; }
/* the bar between the editor and the terminal: drag it to share the height (python.js splitter) */
.py-split { flex: none; height: 6px; cursor: row-resize; background: var(--line); border-block: 2px solid var(--bg); touch-action: none; }
.py-split:hover, .py-split.on, .py-split:focus-visible { background: var(--accent); outline: none; }
.py-term { flex: 2 1 0; min-height: 110px; display: flex; flex-direction: column; }
.py-side { flex: none; width: 190px; overflow: auto; padding: 6px 0 10px; border-right: 1px solid var(--line); background: var(--surface); }
.py-side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 4px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; }
.py-add { padding: 0 7px; font-size: 14px; line-height: 1.3; }
.py-file { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 4px 10px 4px 14px; border: 0;
  border-radius: 0; background: transparent; text-align: left; font-size: 12.5px; color: var(--text); cursor: pointer; }
.py-file > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.py-file small { color: var(--muted); font-size: 11px; }
.py-file:hover { background: var(--surface-2); }
.py-file.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.py-none { margin: 2px 14px; font-size: 12px; color: var(--muted); }
.py-center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.py-banner { padding: 6px 12px; font-size: 12.5px; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--line); }
.py-banner a { color: var(--accent); }
.py-edit-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.py-edit { flex: 1; min-height: 0; display: flex; overflow: hidden; background: #111316; }
.py-edit-wrap.ro .py-ta { caret-color: transparent; }
.py-find { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.py-find[hidden] { display: none; }
.py-find input[type=search], .py-find input[type=text] { width: 150px; font-family: var(--mono); font-size: 12.5px; padding: 3px 6px; }
.py-find button { padding: 2px 8px; font-size: 12px; }
.py-find .grow { flex: 1; }
.py-case { display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); }
.py-find-n { font-size: 12px; color: var(--muted); min-width: 52px; }
.py-gutter { flex: none; min-width: 2.6em; padding: 10px 8px 10px 6px; text-align: right; color: #56606b; background: #0e1012;
  font: 13px/1.5 var(--mono); white-space: pre; overflow: hidden; user-select: none; }
.py-code { position: relative; flex: 1; min-width: 0; }
.py-hl, .py-ta { position: absolute; inset: 0; margin: 0; padding: 10px 12px; border: 0; border-radius: 0;
  font: 13px/1.5 var(--mono); letter-spacing: 0; white-space: pre; tab-size: 4; overflow: auto; }
.py-hl { color: #d7dce2; pointer-events: none; overflow: hidden; background: transparent; }
.py-hl code { font: inherit; }
.py-ta { color: transparent; background: transparent; caret-color: #f2f4f6; resize: none; outline: none; }
.py-ta::selection { background: rgba(79, 156, 245, .38); color: transparent; }
.t-kw { color: #c792ea; } .t-str { color: #b5e08a; } .t-com { color: #6f7b88; font-style: italic; }
.t-num { color: #f7a26c; } .t-fn { color: #82aaff; } .t-bi { color: #7fd6ec; } .t-dec { color: #ffcb6b; }
.py-out-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--line); }
.py-status { color: var(--muted); font-size: 12.5px; }
.py-clear { font-size: 12px; padding: 2px 9px; }
.py-out { flex: 1; min-height: 40px; overflow: auto; padding: 8px 12px; background: #0d0f11; color: #d7dce2;
  font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.py-out .err { color: #ff9b91; }
.py-out .err a { color: inherit; text-decoration: underline dotted; }
.py-out .info { color: #6f7b88; }
.py-out .echo { color: #8fb6ff; }
/* the terminal's prompt: Python in the namespace of the scripts and bench.py */
.py-in-row { display: flex; align-items: center; gap: 8px; padding: 4px 12px 6px; background: #0d0f11; border-top: 1px solid #1d2126; }
.py-prompt { color: #8fb6ff; font: 12.5px var(--mono); flex: none; min-width: 2.2em; }
.py-in { flex: 1; min-width: 0; background: transparent; border: 0; color: #e6e8eb; font: 12.5px var(--mono); padding: 4px 0; outline: none; }
.py-in:disabled { opacity: .5; }
.py-plugins, .py-have-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.py-have { margin-top: 8px; max-height: 180px; overflow: auto; }
.py-out img.py-fig { display: block; max-width: 100%; background: #fff; border-radius: 4px; margin: 6px 0; }

/* online: linking to the user's own instrument through their bridge */
.inspector ol.steps { margin: 4px 0 12px; padding-left: 20px; font-size: 13px; color: var(--muted); }
.inspector ol.steps li { margin: 3px 0; }
.inspector a { color: var(--accent); }

/* File > Print: only the drawing */
#print-root { display: none; }
@media print {
  html, body { height: auto; display: block; overflow: visible; background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root svg { display: block; width: 100%; height: auto; max-height: 100vh; }
}
