/* Workspace styling. */

:root {
  --bg: #12151a;
  --panel: #181c23;
  --panel2: #1f242d;
  --sunken: #0d1014;
  --line: #2a313b;
  --line2: #39434f;
  --text: #ccd4dd;
  --dim: #7e8995;
  --faint: #5a6472;
  --acc: #52b6c2;
  --acc-dk: #17343a;
  --stmt: #c98a3c;
  --val: #4fa3b0;
  --addr: #8f80c4;
  --ctrl: #5f9a6b;
  --ui: #c07f97;
  --red: #d4706a;
  --green: #6fae83;
  --amber: #d59a4a;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.workspace-panel { width: 100%; margin: 0; overflow: auto; }
.workspace-panel h2 { margin-top: 0; }
.workspace-fields, .workspace-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; margin: 8px 0; }
.workspace-fields label, .workspace-card > label { display: flex; flex-direction: column; gap: 6px; }
.workspace-fields input { min-width: 150px; }
/* A tick is not a text field: the 150px minimum above pushes its own label
   half a row away and makes a group of them span the whole form. */
.workspace-fields input[type=checkbox] { min-width: 0; width: auto; margin: 0;
                                         accent-color: var(--acc); }
.workspace-file { display: flex; flex-direction: column; gap: 6px; }
.workspace-file[hidden], .menu-section[hidden] { display: none; }
.menu-section { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.workspace-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.workspace-columns > div { min-width: 0; }
.workspace-card { background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px; margin: 0; }
.workspace-card > label { margin-bottom: 12px; }
.workspace-card textarea { width: 100%; font-family: var(--mono); }
.workspace-panel pre { background: var(--sunken); padding: 14px; overflow: auto; min-height: 32px; white-space: pre; font-family: var(--mono); }
.live-panel > h3 { margin-top: 0; }
.live-watch-list { margin-top: 4px; }
#live-watch-add { margin: 2px 0 6px; }
#live-watch-add label { gap: 2px; }
.data-grid { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
.data-grid th, .data-grid td { padding: 3px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-grid th { position: sticky; top: 0; background: var(--panel); font-weight: 600; }
.data-grid tr:hover { background: var(--acc-dk); }
.data-grid .changed { color: var(--acc); }
.memory-grid { font-family: var(--mono); }
.memory-grid .selected { background: var(--acc-dk); }
.memory-address { font: inherit; border: 0; background: transparent; padding: 0; }
#live-memory { overflow: auto; }
.debug-workspace { display: flex; flex-direction: column; }
.debug-panes { display: grid; grid-template-columns: minmax(400px, 1fr) 270px; flex: 1; min-height: 180px; }
.debug-panes > * { overflow: auto; min-width: 0; }
.debug-panes aside { border-left: 1px solid var(--line); }
#debug-disassembly tr.selected { background: var(--acc-dk); }
#debug-registers .changed { color: var(--acc); }
#debug-state { max-width: 70ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-grid input { width: 120px; padding: 2px 4px; }
#ams-status, #live-status { white-space: pre-wrap; }
.ams-visual-intro { color: var(--dim); font-size: 12px; margin: 2px 0 12px; }
.ams-op-list { margin: 0; padding: 0; }
.ams-op { position: relative; background: var(--bg); border-bottom: 1px solid var(--line); padding: 6px 8px; margin: 0; }
.ams-op-write { border-left: 3px solid var(--stmt); }
.ams-op-condition, .ams-op-button, .ams-op-flow { border-left: 3px solid var(--ctrl); }
.ams-op-loop { border-left: 3px solid var(--addr); }
.ams-op-cave { border-left: 3px solid var(--ui); }
.ams-op-head { display: flex; gap: 10px; align-items: end; }
.ams-op-head > span { font: 11px var(--mono); color: var(--faint); padding-bottom: 6px; }
.ams-op-head label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 11px; }
.ams-op-head select { min-width: 180px; }
.ams-op-remove { margin-left: auto; color: var(--dim); }
.ams-op-fields { margin: 10px 0 0; gap: 9px; }
.ams-op-fields label { font-size: 11px; color: var(--dim); }
.ams-op-fields input, .ams-op-fields select { min-width: 105px; }
.ams-op-hint { margin: 0; align-self: end; }
.ams-cave-source { flex: 1 0 100%; display: flex; flex-direction: column; gap: 5px; color: var(--dim); font-size: 11px; }
.ams-cave-source textarea { min-height: 132px; width: 100%; font: 12px/1.5 var(--mono); }
.ams-workspace { width: 100%; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.ams-titlebar { display: flex; align-items: start; gap: 8px; margin-bottom: 6px; }
.ams-titlebar h2 { margin: 0; }
.ams-titlebar p { color: var(--dim); margin: 3px 0 0; }
.ams-titlebar .workspace-actions { justify-content: end; margin: 0; }
.ams-meta { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; padding: 8px 12px; margin: 0 0 12px; }
.ams-workbench-grid { display: grid; grid-template-columns: 200px minmax(260px, 1fr); flex: 1; min-height: 0; border: 1px solid var(--line); background: var(--panel); }
.ams-workbench-grid > * { min-width: 0; padding: 8px; overflow: auto; }
.ams-cheats-pane, .ams-script-pane { border-right: 1px solid var(--line); }
.ams-pane-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 9px; margin-bottom: 10px; }
.ams-pane-title h3 { margin: 0; }
.ams-pane-title span { color: var(--faint); font: 10px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
#ams-cheat-list { display: flex; flex-direction: column; gap: 3px; }
.ams-cheat-item { text-align: left; padding: 9px; border: 1px solid transparent; background: transparent; overflow: hidden; text-overflow: ellipsis; }
.ams-cheat-item:hover { background: var(--panel2); }
.ams-cheat-item.on { background: var(--acc-dk); border-color: #28616a; color: #d9f4f7; }
.ams-cheat-item small { display: block; color: var(--faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.ams-add-menu { display: grid; gap: 6px; margin: 14px 0 8px; }
.ams-add-menu button { text-align: left; }
.ams-add-menu .ams-add-cave { border-color: #7a5570; background: #2a1d2a; }
.ams-cheats-pane > #ams-open-caves { width: 100%; color: var(--dim); }
.ams-script-pane { overflow: auto; }
.ams-script-pane .workspace-card { margin: 0; border: 0; border-radius: 0; padding: 0; background: transparent; }
.ams-script-pane .workspace-card > label { max-width: 470px; }
.ams-output-pane[hidden] { display: none; }
.ams-output-pane #ams-status { color: var(--dim); font-size: 12px; margin: 4px 0; }
.ams-output-pane #ams-output { margin: 0; font-size: 12px; }
@media (max-width: 700px) { .ams-titlebar { display: block; } .ams-titlebar .workspace-actions { justify-content: start; margin-top: 12px; } .ams-workbench-grid { grid-template-columns: 1fr; } .ams-cheats-pane, .ams-script-pane { border-right: 0; border-bottom: 1px solid var(--line); } }

/* The rest of the application is an editor with a persistent status strip.
   AMS programs can be arbitrarily long, so treating this tab as the same
   fixed-height canvas put its lower steps underneath that strip. Give AMS a
   normal document flow: the footer comes after the workbench instead. */
@media (max-width: 900px) { .workspace-columns { grid-template-columns: 1fr; } }

* { box-sizing: border-box; }
/* The `hidden` attribute is only a UA rule of `display: none`, so any element
   this stylesheet gives a display to beats it. #drop sets `display: grid`,
   which meant the drop veil covered the whole page permanently -- an import
   would succeed behind it and look like nothing had happened. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.5 var(--sans);
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.mono, code, pre { font-family: var(--mono); }
code { color: var(--text); background: var(--panel2); padding: 0 4px; border-radius: 3px; font-size: .92em; }
.grow { flex: 1; }
.hint { color: var(--faint); font-size: 12px; line-height: 1.5; }
h2 { font-size: 17px; margin: 0 0 6px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 4px; font-weight: 600; }

/* ---------------------------------------------------------- chrome */
#menubar { display: flex; height: 27px; flex: 0 0 auto; align-items: stretch;
  padding: 0 6px; background: #20242b; border-bottom: 1px solid #11151a; }
#menubar details { position: relative; }
#menubar summary { list-style: none; cursor: pointer; padding: 3px 11px 4px;
  color: var(--text); font-size: 12px; }
#menubar summary::-webkit-details-marker { display: none; }
#menubar details[open] summary, #menubar summary:hover { background: var(--acc-dk); }
.menu-popup { position: absolute; z-index: 50; top: 100%; left: 0; min-width: 170px;
  padding: 4px; background: var(--panel2); border: 1px solid var(--line2);
  box-shadow: 0 7px 18px #0009; }
.menu-popup button, .menu-popup a { display: block; width: 100%; text-align: left; border: 0;
  border-radius: 2px; padding: 6px 9px; color: var(--text); background: transparent;
  font: 12px/1.4 var(--sans); text-decoration: none; }
.menu-popup a:visited { color: var(--text); }
.menu-popup button:hover, .menu-popup a:hover { background: var(--acc-dk); }
.menu-popup a:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
#bar {
  display: flex; align-items: center; gap: 9px; padding: 0 12px;
  height: 38px; flex: 0 0 auto; overflow-x: auto;
  background: #181c22; border-bottom: 1px solid var(--line);
}
/* Nothing in the bar shrinks. Flex items shrink by default, which clipped the
   "Advanced" tab to "Advancec" on a 1400px window; the bar scrolls instead. */
#bar > * { flex: 0 0 auto; }
#bar .app { font-weight: 600; font-size: 14px; letter-spacing: .01em; white-space: nowrap; }
.chip {
  font-family: var(--mono); font-size: 11px; color: var(--dim);
  border: 1px solid var(--line2); border-radius: 3px; padding: 2px 7px;
  white-space: nowrap; max-width: 30ch; overflow: hidden; text-overflow: ellipsis;
}
.chip b { color: var(--text); font-weight: 500; }
.chip.good { color: var(--green); border-color: #2c4a38; }
.chip.warn { color: var(--amber); border-color: #4a3c22; }
input.hdr {
  width: auto; background: transparent; border: 1px solid transparent;
  padding: 2px 6px; font-size: 12px; color: var(--text);
}
input.hdr::placeholder { color: var(--faint); }
input.hdr:hover { border-color: var(--line2); }
input.hdr:focus { background: var(--sunken); border-color: var(--acc); }

button, .filebtn {
  font: inherit; font-size: 12px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line2);
  border-radius: 3px; padding: 4px 11px; cursor: pointer; white-space: nowrap;
}
button:hover, .filebtn:hover { border-color: var(--acc); }
button:focus-visible, .filebtn:focus-within { outline: 2px solid var(--acc); outline-offset: 1px; }
button.primary { background: var(--acc); border-color: var(--acc); color: #08282c; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
/* The step that deletes something or writes to a running game does not look
   like the step that saves a file. */
button.danger { background: var(--red); border-color: var(--red); color: #1a0c0c; font-weight: 600; }
button.danger:hover { filter: brightness(1.1); }
button:disabled { opacity: .45; cursor: default; border-color: var(--line2); }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { color: var(--text); border-color: var(--line2); }
.filebtn { position: relative; overflow: hidden; display: inline-block; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 3px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line2); border-radius: 0; background: transparent; color: var(--dim); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--acc); color: #08282c; font-weight: 600; }
.seg button { flex: 0 0 auto; }
.seg.small button { padding: 2px 9px; font-size: 11px; }

#tabs {
  display: flex; gap: 0; padding: 0 8px; flex: 0 0 auto;
  background: var(--panel); border-bottom: 1px solid var(--line);
  min-height: 31px;
}
#tabs button {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--dim); padding: 7px 14px;
}
#tabs button.on { color: var(--text); border-bottom-color: var(--acc); background: var(--bg); }

main { flex: 1; min-height: 0; display: flex; }
.tab { display: none; flex: 1; min-width: 0; min-height: 0; }
.tab.on { display: flex; }
.pad { padding: 8px; overflow: auto; flex: 1; min-width: 0; }
.scroll { overflow: auto; flex: 1; min-height: 0; }

#status {
  display: flex; gap: 16px; align-items: center; padding: 0 12px;
  height: 26px; flex: 0 0 auto; font-family: var(--mono); font-size: 11px;
  color: var(--dim); background: var(--panel2); border-top: 1px solid var(--line);
}
#problems { color: var(--red); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#problems .blame { cursor: pointer; text-decoration: underline dotted; }
#problems .blame:hover { text-decoration: underline; }

/* ---------------------------------------------------------- panes */
.split { display: flex; flex: 1; min-width: 0; min-height: 0; }
.pane {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--panel); border-right: 1px solid var(--line);
  width: 300px; flex: 0 0 300px;
}
.pane:last-child { border-right: 0; }
.pane.narrow { width: 208px; flex: 0 0 208px; }
.pane.wide { flex: 1; width: auto; }
.pane.grow { flex: 1; width: auto; }
.pane-h {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint);
  padding: 8px 10px 6px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}

.runtime-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.runtime-body { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(280px, 400px); gap: 8px; }
.runtime-list { overflow: auto; }
.runtime-list .sel { background: var(--acc-dk); }
.runtime-list button { border: 0; background: transparent; text-align: left; }
.runtime-editor { border-left: 1px solid var(--line); background: var(--panel); padding: 8px; }
.runtime-empty { color: var(--dim); padding: 16px 0; }
.runtime-edit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.runtime-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.runtime-fields label { display: grid; gap: 4px; color: var(--dim); font-size: 11px; }
.runtime-fields .wide { grid-column: 1 / -1; }
.runtime-fields input, .runtime-fields select, .runtime-fields textarea { width: 100%; box-sizing: border-box; }
.runtime-warning { border-left: 2px solid var(--amber); padding-left: 9px; margin: 14px 0; }
input, select, textarea {
  font: inherit; font-size: 12px; color: var(--text); background: var(--sunken);
  border: 1px solid var(--line2); border-radius: 3px; padding: 4px 8px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--acc); }
#toolbox-filter, #rows-filter, #blocks-filter {
  margin: 6px; width: calc(100% - 12px); flex: 0 0 auto;
}

/* ---------------------------------------------------------- rows list */
.row {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  cursor: pointer; border-left: 2px solid transparent;
}
.row:hover { background: #1c2129; }
.row:focus-visible { outline: 0; background: #1c2129; border-left-color: var(--dim); }
.row.over { box-shadow: inset 0 2px 0 var(--acc); }
/* The row the compiler is complaining about. `#problems` names it too; this
   is so you can find it in a list of two hundred without reading the name. */
.row.bad { box-shadow: inset 2px 0 0 var(--red); }
.row.bad .nm { color: var(--red); }
.row.sel { background: var(--acc-dk); border-left-color: var(--acc); }
.row.off { opacity: .42; }
.row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .tag {
  font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  border: 1px solid var(--line2); padding: 0 4px; border-radius: 2px;
}
/* Sticky, because a group header that scrolls away takes with it the only
   thing saying which group you are looking at. */
.row.group {
  color: var(--dim); font-family: var(--mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase; padding-top: 10px; cursor: default;
  position: sticky; top: 0; z-index: 2; background: var(--panel);
  box-shadow: 0 1px 0 var(--line);
}
.sw { width: 22px; height: 12px; border-radius: 6px; background: var(--line2); position: relative; flex: 0 0 auto; }
.sw.on { background: var(--green); }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bg); }
.sw.on::after { left: 12px; }
.star { color: var(--amber); }

/* ---------------------------------------------------------- improvements */
.hint-box {
  border: 1px dashed var(--line2); border-radius: 5px; padding: 18px 20px;
  max-width: 74ch; margin-bottom: 16px;
}
.hint-box p { color: var(--dim); margin: 0 0 10px; }
.hint-box .row { display: flex; gap: 8px; flex-wrap: wrap; padding: 0; cursor: default; }
.imp {
  border: 1px solid var(--line); border-radius: 5px; background: var(--panel);
  padding: 12px 14px; margin-bottom: 9px; display: flex; gap: 12px;
  align-items: flex-start; max-width: 96ch;
}
.imp input[type=checkbox] { width: auto; margin-top: 3px; accent-color: var(--acc); }
.imp .body { flex: 1; min-width: 0; }
.imp p { margin: 3px 0 0; color: var(--dim); font-size: 12px; }
.imp .ba { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 7px; font-family: var(--mono); font-size: 11px; }
.was { color: var(--faint); text-decoration: line-through; }
.now { color: var(--green); }
.pill { font-size: 10px; padding: 1px 6px; border-radius: 9px; border: 1px solid currentColor; }
.pill.proved { color: var(--green); }
.pill.likely { color: var(--amber); }
.sticky-apply {
  position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 40%);
  padding: 14px 0 4px; display: flex; gap: 10px; align-items: center;
}

/* ---------------------------------------------------------- blocks */
.canvas {
  background: var(--sunken); padding: 14px;
  background-image: radial-gradient(circle at 1px 1px, #1b2027 1px, transparent 0);
  background-size: 14px 14px;
}
.stack { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.node {
  border-radius: 4px; border: 1px solid rgba(0,0,0,.35); padding: 4px 8px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 11.5px; color: #0d1014; cursor: grab;
}
.node.stmt { background: var(--stmt); }
.node.ctrl { background: var(--ctrl); }
.node.readout { background: var(--ui); }
.node.value { background: var(--val); }
.node.address { background: var(--addr); }
.node.bad { box-shadow: 0 0 0 2px var(--red); }
.node.moving { opacity: .4; }
/* "in front of this one". A statement takes a drop as well as the zone at the
   end of the list, or a move could only ever append. */
.node.before { box-shadow: 0 -3px 0 var(--acc); }
.socket.held { cursor: grab; }
/* The word the row writes, not the patch. Marked because it is the one the
   slider moves -- and because it is deliberately outside the guarded run. */
.words tr.tunable td { background: var(--acc-dk); }
.words tr.tunable .word { color: var(--acc); font-weight: 600; }
.cave h3 .tag {
  font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  border: 1px solid var(--line2); padding: 0 4px; border-radius: 2px;
  margin-left: 6px; vertical-align: middle;
}
.canvas-bad {
  color: var(--red); border: 1px solid var(--red); border-radius: 3px;
  padding: 6px 9px; margin: 0 0 10px; font-size: 11.5px; max-width: 60ch;
}
.batch {
  display: flex; align-items: center; gap: 5px; flex: 0 0 auto;
  padding: 5px 6px; margin: 0 6px 6px; border-radius: 3px;
  background: var(--acc-dk); border: 1px solid var(--acc);
}
.batch > span:first-child {
  font-family: var(--mono); font-size: 10px; color: var(--text); padding: 0 3px;
}
.batch button { padding: 2px 7px; font-size: 10.5px; }
.row.mark { background: var(--acc-dk); }
.row.mark .nm { color: var(--text); }
.socket.held.moving { opacity: .4; }
.node .keep {
  font-family: var(--sans); font-size: 9.5px; letter-spacing: .04em;
  opacity: .45; cursor: pointer; text-transform: uppercase; padding: 0 2px;
}
.node .keep:hover { opacity: 1; }
.node .kw { font-weight: 600; }
.node .x { opacity: .5; cursor: pointer; font-weight: 600; padding: 0 2px; }
.node .x:hover { opacity: 1; }
.socket {
  background: rgba(10,12,15,.42); color: #e6ecf2; border-radius: 3px;
  padding: 1px 6px; display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid rgba(255,255,255,.08); min-height: 19px;
}
.socket.empty { color: #9fb0bd; border-style: dashed; background: rgba(10,12,15,.2); }
/* A constant the image says is executable, shown as the instruction it is.
   Five rows of `16991169...` say nothing; `str w1, [x8, #0x30]; ret` is the
   cheat. */
.socket.asm { background: rgba(10,12,15,.55); box-shadow: inset 0 0 0 1px rgba(95,154,107,.6); }
.socket.asm b { color: var(--ctrl); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.socket.asm .mn { color: #cfe3d3; }
.socket.over { border-color: var(--acc); background: rgba(82,182,194,.22); }
.socket input { width: 9ch; padding: 0 4px; font-family: var(--mono); font-size: 11px; background: rgba(0,0,0,.35); border-color: transparent; }
.socket input.wide { width: 18ch; }
.socket select { width: auto; padding: 0 2px; font-size: 11px; background: rgba(0,0,0,.35); border-color: transparent; }
.nest { border-left: 2px solid var(--ctrl); margin-left: 10px; padding: 6px 0 2px 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
/* Every level drawn the same made four-deep nesting a wall of identical
   rails. Fading each one in turn is enough to count them at a glance. */
.nest .nest { border-left-color: var(--val); }
.nest .nest .nest { border-left-color: var(--addr); }
.nest .nest .nest .nest { border-left-color: var(--line2); }
/* Compact statements keep expression trees behind an editor. Only actual
   control-flow scopes form nested containers on the canvas. */
#canvas .stack { align-items: stretch; min-width: 0; gap: 9px; }
.statement-block { border: 1px solid var(--line2); border-radius: 6px; background: #131c24; min-width: 0; }
.statement-block > .compact-node { background: #182630; color: var(--text); border: 0; border-radius: 5px; padding: 10px 12px; gap: 9px; }
.statement-block.stmt { border-color: #705734; }
.statement-block.stmt > .compact-node { background: #2b251b; }
.compact-node .kw { font-size: 10px; letter-spacing: .08em; color: #79cece; }
.compact-node.stmt .kw { color: #e4b66f; }
.statement-block.assignment { border-color: #51466a; }
.statement-block.assignment .kw { color: #b6a1ef; }
.compact-node .keep { margin-left: auto; color: var(--faint); }
.compact-node .x, .block-fold { border: 0; background: transparent; color: var(--faint); padding: 0 3px; }
.block-fold { cursor: pointer; font-size: 14px; width: 18px; }
.expression-field { max-width: 100%; padding: 0; background: #10191f; border-color: #344753; }
.expression-chip { text-align: left; white-space: normal; overflow-wrap: anywhere; padding: 6px 9px; color: #d8e6ef; background: transparent; border: 0; font: 12px/1.5 var(--mono); cursor: pointer; }
.expression-chip:hover { background: #203340; }
.statement-block > .nest { margin: 0 12px 12px 19px; padding: 9px 0 0 13px; align-items: stretch; border-left-color: #3b646b; }
.statement-block > .nest[hidden], .branch-action[hidden] { display: none; }
.branch-label { color: var(--faint); font: 10px var(--mono); }
.branch-action { margin: 0 12px 12px 34px; }
.add-branch { background: transparent; border: 1px dashed var(--line2); color: var(--faint); font-size: 11px; }
.expression-editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.expression-editor-bar h2 { font-size: 16px; }
#block-expression-editor { width: min(880px, calc(100vw - 40px)); max-height: 85vh; overflow: auto; }
.expression-preview { display: block; padding: 12px; margin: 12px 0; background: var(--sunken); border: 1px solid var(--line2); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.expression-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font: 12px var(--mono); }
.expression-controls .socket { flex-wrap: wrap; max-width: 100%; }
.expression-kind { display: inline-flex; gap: 6px; align-items: center; font-size: 10px; color: var(--dim); }
.expression-kind select { width: auto; max-width: 190px; font-size: 12px; color: var(--text); }
.expression-build-actions { display: flex; gap: 8px; margin: 12px 0 18px; }
.dropzone {
  border: 1px dashed var(--line2); border-radius: 4px; padding: 4px 10px;
  color: var(--faint); font-family: var(--mono); font-size: 11px; min-width: 130px;
}
.dropzone.over { border-color: var(--acc); background: rgba(82,182,194,.12); color: var(--acc); }
.blk {
  display: flex; align-items: center; gap: 6px; padding: 3px 9px; margin: 0 6px 4px;
  border-radius: 3px; font-family: var(--mono); font-size: 11px; color: #0d1014;
  font-weight: 500; border: 1px solid rgba(0,0,0,.25); cursor: grab;
}
.blk small { font-weight: 400; opacity: .72; font-family: var(--sans); }
.blk.write { background: var(--stmt); }
.blk.control { background: var(--ctrl); }
.blk.address { background: var(--addr); }
.blk.value { background: var(--val); }
.blk.readout { background: var(--ui); }
.blk.other { background: var(--line2); color: var(--text); }
.blk.kept { background: var(--panel); color: var(--text); border: 1px dashed var(--line2); }
.blk.kept .x { opacity: .45; margin-left: 6px; }
.blk.kept .x:hover { opacity: 1; color: var(--red); }
.tbx-cat { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin: 10px 10px 5px; }

/* ---------------------------------------------------------- inspector */
/* Capped, because a form stretched over 1400px is unreadable -- the eye
   has to travel the whole width to get from a label to its box. */
.insp { padding: 10px; overflow: auto; }
.pane.wide .insp, .pane.grow .insp { max-width: 760px; }
.field { margin-bottom: 9px; }
.cave-site-row { display: grid; grid-template-columns: 1fr 1.2fr auto;
  gap: 8px; margin: 8px 0; align-items: center; }
.cave-site-row input { min-width: 0; }
.token-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  margin: -3px 0 10px; color: var(--dim); font-size: 11px; }
.token-bar button { font-family: var(--mono); font-size: 10px; padding: 3px 6px; }
.cave-hook { border: 1px solid var(--line); padding: 10px; margin: 10px 0;
  background: rgba(255,255,255,.025); }
.cave-hook h4 { margin: 0 0 8px; }
.hook-facts { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); }
.hook-facts code { color: var(--text); }
.field label { display: block; font: 12px/1.4 var(--sans); letter-spacing: normal; text-transform: none; color: var(--dim); margin-bottom: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plain { background: var(--acc-dk); border-left: 2px solid var(--acc); padding: 8px 11px; font-size: 12px; line-height: 1.55; color: #cfe6ea; border-radius: 0 3px 3px 0; margin-bottom: 10px; }
.warn-box { background: #2a1d1c; border-left: 2px solid var(--red); padding: 8px 11px; font-size: 12px; color: #e7c3c0; border-radius: 0 3px 3px 0; margin-bottom: 10px; }

/* ---------------------------------------------------------- overlay preview */
.overlay-wrap { display: flex; gap: 24px; align-items: flex-start; }
.ovl {
  width: 448px; background: #000; border: 1px solid var(--line2);
  border-radius: 6px; padding: 12px 0 8px; flex: 0 0 auto;
  max-height: 720px; overflow: auto; position: relative;
}
.ovl-cat { padding: 12px 22px 4px; font-size: 11.5px; color: #5bd6e4; }
.ovl-row { display: flex; align-items: center; gap: 9px; padding: 8px 22px; font-size: 14px; color: #f0f0f0; }
.ovl-row.tall { padding: 15px 22px; }
.ovl-row .v { margin-left: auto; color: #9aa4ae; font-family: var(--mono); font-size: 13px; }
.ovl-note { padding: 0 22px 8px; margin-top: -5px; font-size: 11.5px; color: #8b8b8b; }
.ovl-bar { height: 5px; border-radius: 3px; background: #2f2f2f; flex: 1; max-width: 170px; position: relative; }
.ovl-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: #5bd6e4; }
.walkthrough .wt-steps li { margin-bottom: 10px; }
.walkthrough .wt-steps p { margin: 0 0 6px; }
.wt-code { margin: 6px 0 4px; padding: 10px 12px; background: var(--sunken); border: 1px solid var(--line);
  border-left: 3px solid var(--line2); border-radius: 4px; overflow: auto; font: 12.5px/1.55 var(--mono);
  color: var(--text); white-space: pre; }
.wt-part { margin-top: 10px; font: 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.wt-code .k { color: #7fc08d; } .wt-code .s { color: #e0a356; } .wt-code .a { color: #ad9fe0; }
.wt-code .n { color: #6cc3cf; } .wt-code .u { color: #dc98b1; } .wt-code .c { color: var(--faint); font-style: italic; }
#body-view { margin-left: 8px; }
.code-bar { display: flex; gap: 6px; align-items: center; padding: 8px 14px 0; }
.code-msg { font-size: 12px; color: var(--dim); }
.code-msg.bad { color: var(--red); }
.code-msg.warn { color: var(--amber); }
.code-help { margin-left: auto; font-size: 12px; color: #5bd6e4; }
.code-view { display: block; width: calc(100% - 28px); min-height: 420px; margin: 8px 14px;
  padding: 12px 14px; box-sizing: border-box; font-family: var(--mono); font-size: 13px;
  line-height: 1.55; color: #d8dee4; background: #0d0f12; border: 1px solid var(--line2);
  border-radius: 3px; white-space: pre; overflow: auto; tab-size: 4; resize: vertical; }
.crumbs { padding: 6px 14px; font-size: 12px; color: #9aa4ae; }
.crumbs a { cursor: pointer; color: #5bd6e4; }
.crumbs a:last-child { color: inherit; cursor: default; }
.ovl .crumbs { padding: 0 22px 6px; }
.ovl.compact .crumbs { display: none; }
.ovl-folder { cursor: pointer; }
.ovl-folder .v, .design-folder .v { color: #5bd6e4; }
.design-folder { cursor: pointer; }
.design-folder.over { border: 2px dashed var(--acc); }
.design-control.hidden-row { opacity: .5; }
#ovl-views { margin-left: 10px; display: inline-flex; gap: 2px; }
#ovl-views button { font-size: 11px; padding: 1px 8px; }
#ovl-views button.on { color: var(--fg, #fff); border-color: #5bd6e4; }
/* The compact window: nxcloader's MenuPanel, 400 wide, 40px rows, 23px text. */
.ovl.compact { width: 400px; padding: 0; background: rgba(0,0,0,.73); border-radius: 6px; }
.cmp-head { padding: 14px 16px 14px 68px; font-size: 12px; line-height: 19px; color: #999; }
.cmp-head { position: relative; }
.cmp-head img { position: absolute; left: 24px; top: 16px; width: 32px; height: 32px; border-radius: 4px; }
.btn-b, .btn-a { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%;
  background: #eee; color: #111; font: 600 10px var(--sans); font-style: normal; margin-right: 4px; vertical-align: 1px; }
.full-head { display: flex; align-items: center; gap: 12px; padding: 4px 22px 10px; }
.full-head img { width: 36px; height: 36px; border-radius: 4px; }
.full-title { font-size: 20px; color: #f0f0f0; line-height: 1.2; }
.full-sub { font-size: 12px; color: #9aa4ae; }
.full-rows { min-height: 300px; }
.full-foot { display: flex; gap: 26px; padding: 12px 22px 4px; margin-top: 8px; border-top: 1px solid #333;
  font-size: 15px; color: #f0f0f0; }
.full-foot .cmp-back { color: #f0f0f0; }
.full-foot .cmp-back[data-top] { cursor: default; }
.ovl:not(.compact) .crumbs { padding: 0 22px 6px; }
.cmp-rows { min-height: 480px; }
.cmp-row { display: flex; align-items: baseline; height: 40px; padding: 0 16px 0 14px; font-size: 18px; color: #fff; cursor: default; }
.cmp-row.sel { color: #ffe822; }
.cmp-mark { width: 26px; flex: 0 0 26px; }
.cmp-hotkeys { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; margin-right: 7px; }
.cmp-hotkeys .glyph { font-size: 11px; padding: 1px 4px; color: #e8e8e8; border-color: #777; background: rgba(0,0,0,.32); }
.cmp-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-value { flex: 0 0 auto; min-width: 76px; margin-left: 12px; position: relative; }
.cmp-value.dim { color: #999; }
.cmp-bar { position: absolute; left: 0; right: 4px; top: 22px; height: 3px; background: #555; }
.cmp-bar i { position: absolute; inset: 0 auto 0 0; background: currentColor; }
.cmp-foot { display: flex; justify-content: space-between; padding: 8px 16px 12px; font-size: 14px; color: #fff; }
.cmp-back { cursor: pointer; color: #9aa4ae; }
.glyph { font-family: var(--mono); font-size: 11px; color: #d0d0d0; border: 1px solid #444; border-radius: 3px; padding: 0 5px; }
.fold { border-top: 1px dashed #333; margin: 0 18px; position: relative; }
.fold span { position: absolute; right: 0; top: -8px; background: #000; color: #666; font-size: 10px; font-family: var(--mono); padding: 0 4px; }

/* ---------------------------------------------------------- examples */
.ex h2 { margin-bottom: 10px; }
.ex .q { font-size: 15px; color: var(--text); margin: 0 0 10px; }
.ex .why { max-width: 76ch; color: var(--dim); font-size: 13px; line-height: 1.65; }
.ex .caution { margin-top: 10px; }
.ex form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); margin: 16px 0; max-width: 76ch; }
.ex form label { display: flex; flex-direction: column; gap: 3px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.words { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; max-width: 76ch; }
.words th { text-align: left; font-size: 9.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--faint); font-weight: 500; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); }
.words td { padding: 5px 12px 5px 0; border-bottom: 1px solid var(--line); }
.words .word { color: var(--amber); }
.words .no { color: var(--faint); font-style: italic; }
.src { font-size: 11.5px; color: var(--faint); margin-top: 14px; max-width: 76ch; }

/* ---------------------------------------------------------- annotated listing */
.listing { font-family: var(--mono); font-size: 11.5px; line-height: 1.7; background: var(--sunken); padding: 12px 14px; border-radius: 4px; overflow-x: auto; }
.listing .l { white-space: pre; }
.listing .hd { color: var(--ctrl); }
.listing .dw { color: var(--dim); }
.listing .cm { color: var(--acc); }

/* ---------------------------------------------------------- caves */
.cave form { display: grid; gap: 10px; grid-template-columns: 1fr 200px; max-width: 860px; margin-bottom: 14px; }
.cave label { display: flex; flex-direction: column; gap: 3px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.cave textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; min-height: 150px; resize: vertical; }
.cave .tpl { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cave .tpl button { font-size: 11.5px; }
.site { font-family: var(--mono); font-size: 12px; background: var(--sunken); border-radius: 4px; padding: 10px 12px; max-width: 860px; }
.site .l { white-space: pre; color: var(--dim); }
.site .l.here { color: var(--amber); font-weight: 600; }
.site .l.here::after { content: "   <- the branch replaces this"; color: var(--faint); font-weight: 400; }
.bar-used { display: flex; height: 16px; border-radius: 3px; overflow: hidden; background: var(--sunken); border: 1px solid var(--line2); margin: 8px 0; }
.bar-used i { display: block; height: 100%; }
.bar-used i.mine { background: var(--acc); }
.bar-used i.free { background: transparent; }
.alloc-row { display: flex; gap: 10px; font-family: var(--mono); font-size: 11.5px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.alloc-row b { color: var(--acc); font-weight: 500; }

/* ---------------------------------------------------------- run */
.run-controls { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.run-controls label { font-size: 11px; color: var(--faint); font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.run-controls input, .run-controls select { margin-top: 3px; }
.run-controls > label { display: flex; flex-direction: column; }
pre {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6; margin: 0;
  background: var(--sunken); padding: 12px 14px; border-radius: 4px;
  overflow: auto; color: var(--text); white-space: pre;
}
table.t { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11.5px; margin-top: 12px; }
table.t th { text-align: left; font-size: 9.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--faint); font-weight: 500; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 4px 10px; border-bottom: 1px solid var(--line); }
td.wrote { color: var(--amber); }

/* ---------------------------------------------------------- start sheet */
#start {
  width: min(600px, 92vw); max-height: 85vh; padding: 0; overflow: auto;
}
#start .sheet {
  background: var(--panel); padding: 12px; width: 100%;
}
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 14px; }
#start .choices { gap: 3px; margin-top: 6px; }
#start .choice { padding: 6px 8px; border-radius: 2px; }
/* minmax(0, ...) rather than a bare 1fr: a grid track's automatic minimum is
   its item's min-content width, so without it a wide card pushes the track
   wider than the sheet instead of wrapping inside it. */
.choices { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; margin-top: 16px; }
.choice {
  display: flex; gap: 13px; align-items: flex-start; text-align: left;
  width: 100%; max-width: 100%; min-width: 0;
  padding: 13px 15px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); font: inherit; cursor: pointer; position: relative;
  /* These cards are buttons and labels, and the shared rule for those sets
     `white-space: nowrap` -- right for a toolbar button, wrong for a
     paragraph. Every description ran off the side of the sheet. */
  white-space: normal;
}
.choice:hover { border-color: var(--acc); background: #232935; }
.choice .n {
  flex: 0 0 22px; height: 22px; border-radius: 50%; background: var(--sunken);
  border: 1px solid var(--line2); color: var(--dim);
  font-family: var(--mono); font-size: 11px; display: grid; place-items: center;
}
.choice:hover .n { border-color: var(--acc); color: var(--acc); }
.choice .c { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.choice .c b { font-size: 14px; font-weight: 600; }
.choice .c span { font-size: 12.5px; color: var(--dim); line-height: 1.55; overflow-wrap: anywhere; }
.choice .tick:empty { display: none; }
.choice .tick { color: var(--green); font-size: 12px; font-family: var(--mono); }
.choice.filebtn { overflow: visible; }
.choice.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ---------------------------------------------------------- overlays */
#drop {
  position: fixed; inset: 0; background: rgba(8,10,13,.86); z-index: 50;
  display: grid; place-items: center; font-size: 19px; color: var(--acc);
}
#drop div { border: 2px dashed var(--acc); border-radius: 10px; padding: 46px 62px; }
#toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line2); border-left: 3px solid var(--acc);
  border-radius: 4px; padding: 10px 16px; z-index: 60; max-width: 74ch;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#toast.bad { border-left-color: var(--red); }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line2);
  border-radius: 5px; padding: 18px 20px; min-width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px); overflow: auto; }
dialog > h2, dialog > h3, dialog > form > h2, dialog > form > h3 {
  font: 600 16px/1.35 var(--sans); margin: 0 0 10px; }
dialog p { line-height: 1.5; }
dialog input:not([type=checkbox]):not([type=radio]):not([type=file]), dialog select { min-width: 0; }
dialog .field > input:not([type=checkbox]):not([type=radio]):not([type=file]), dialog .field > select,
dialog .field > textarea { width: 100%; }
#ask, #sure { width: min(480px, calc(100vw - 32px)); }
#ask-value { width: 100%; }
#pick-image { width: min(720px, 92vw); }
#pick-image-search { width: 100%; margin: 6px 0 8px; }
.pick-list { max-height: 55vh; overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
.pick-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.pick-row:hover, .pick-row:focus { background: var(--panel2); }
.pick-row .pick-name { color: var(--text); }
.pick-row .pick-file { grid-column: 1; font: 11.5px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row .pick-meta { grid-column: 2; grid-row: 1 / span 2; align-self: center; font: 11.5px var(--mono); color: var(--dim); }
.pick-row.this-game .pick-meta { color: var(--green); }
dialog::backdrop { background: rgba(8,10,13,.7); }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 14px 0 0; }
dialog input { margin-top: 0; }

/* The Switch connection dialog. The toolbar row style does not survive five
   controls in a modal: everything wrapped into one line and the checkboxes
   stacked over their own labels. */
#connection-dialog { min-width: 54ch; }
#connection-dialog h2 { margin: 0 0 4px; }
.connect-form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 0; }
.connect-form label { display: flex; flex-direction: column; gap: 5px;
                      font-size: 12px; color: var(--dim); }
.connect-form input { margin-top: 0; width: 100%; }
.connect-row { display: flex; gap: 10px; align-items: flex-start; }
.connect-address { flex: 1 1 auto; min-width: 0; }
.connect-port { flex: 0 0 11ch; }
.connect-options { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.connect-form label.inline { flex: 0 0 auto; color: var(--text); white-space: nowrap; }
/* No default box margin, so the tick lines up with the fields above it. */
.connect-options input[type=checkbox] { width: auto; margin: 0; accent-color: var(--acc); }
.connect-actions { display: flex; gap: 8px; padding-top: 2px; }
#connection-dialog #live-status { margin: 12px 0 0; font-size: 12px;
                                  color: var(--dim); line-height: 1.5; }

@media (max-width: 900px) {
  .split { flex-direction: column; }
  .pane, .pane.narrow { width: auto; flex: 0 0 auto; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .overlay-wrap { flex-direction: column; }
  .ovl { width: 100%; max-width: 448px; }
}

/* The Add-a-row sheet: recipes down the left, the chosen one's fields right. */
#recipes { max-width: min(92vw, 78ch); }
.recipes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
           gap: 18px; align-items: start; }
.recipes .choices { gap: 8px; }
.recipes .choice.on { outline: 2px solid var(--accent, #4a9eff); }
#recipe-detail h3 { margin: 0 0 4px; }
#recipe-detail .f { display: block; margin: 10px 0; }
#recipe-detail .f span { display: block; font-size: 12px; opacity: .8;
                         margin-bottom: 3px; }
#recipe-detail .f input, #recipe-detail .f select { width: 100%; }
#recipe-detail .f small { display: block; margin-top: 3px; font-size: 11px; }
#recipe-detail .f textarea { width: 100%; font: 12px/1.5 var(--mono, monospace);
                             resize: vertical; }
.rgroup { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.rgroup h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .06em;
             text-transform: uppercase; opacity: .6; font-weight: 600; }
#recipe-why { color: var(--red); margin: 8px 0 0; font-size: 12px; }
@media (max-width: 720px) { .recipes { grid-template-columns: 1fr; } }

/* `ask()` puts newline-separated lists in here -- a numbered list of game
   images, say -- and without this they collapse into one run-on line. */
#ask-detail { white-space: pre-wrap; max-width: 70ch; }
dialog { max-width: min(92vw, 80ch); }

/* The after-build panel: where the file goes. Persistent, unlike a toast. */
.done { position: fixed; left: 50%; transform: translateX(-50%); bottom: 46px;
        max-width: min(92vw, 78ch); padding: 12px 16px; border-radius: 8px;
        background: #143018; border: 1px solid #2f6b38; color: #d8f0dc;
        box-shadow: 0 6px 24px rgba(0,0,0,.4); z-index: 40; line-height: 1.5; }
.done code { background: rgba(0,0,0,.35); padding: 1px 5px; border-radius: 4px;
             word-break: break-all; }
.done .x { margin-left: 10px; }


/* The row's body, shown as the pieces it is made of. The inspector used to
   show a row's name and its mode and, for what it actually did, a button to
   the block canvas. */
.parts { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 0;
         margin: 0 0 12px; }
.parts-h { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.parts-h label { font-size: 11px; letter-spacing: .06em;
                 text-transform: uppercase; opacity: .7; }
.parts-h button { font-size: 11px; padding: 2px 8px; }
.part + .part { margin-top: 8px; border-top: 1px solid var(--line);
                padding-top: 8px; }
.part-h { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.part-h .what { flex: 1; font-size: 12px; }
.part-h button { font-size: 11px; padding: 1px 7px; opacity: .7; }
.part-h button:hover { opacity: 1; color: var(--red); }
.part .fields { display: grid; gap: 4px 10px;
                grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.part .fields .wide { grid-column: 1 / -1; }
.part .field { margin: 0; }
.part textarea { width: 100%; font: 12px/1.5 var(--mono, monospace);
                 resize: vertical; }

#paste, #cavesheet { max-width: min(92vw, 80ch); }
#paste textarea, #cavesheet textarea { width: 100%; font: 12px/1.5
    var(--mono, monospace); resize: vertical; }
#cavesheet .field input, #cavesheet .field select { width: 100%; }
#cs-blurb { display: block; margin-top: 4px; }
#paste-why { color: var(--red); }
/* The search scope: a row of ticks that reads as one control, not four. */
.scan-regions { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap;
                border: 1px solid var(--line); border-radius: 4px;
                margin: 0; padding: 2px 8px 4px; }
.scan-regions legend { font-size: 12px; color: var(--dim); padding: 0 4px; }
.scan-regions label.inline { flex: 0 0 auto; }
#scan-scope { margin: 6px 0 0; }
#scan-progress { display: block; width: 100%; height: 6px; margin: 6px 0 0;
                 border: 0; background: var(--sunken); }
#scan-progress::-webkit-progress-bar { background: var(--sunken); }
#scan-progress::-webkit-progress-value { background: var(--acc); }
#scan-progress::-moz-progress-bar { background: var(--acc); }

/* Inside .workspace-fields the label above is already flex-direction: column,
   and setting display alone leaves the box stacked over its text. */
label.inline { display: inline-flex; flex-direction: row; gap: 6px;
               align-items: center; font-size: 12px; }

.palette { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.palette .chip { font-size: 11px; padding: 3px 9px; cursor: grab; }
.palette .chip:active { cursor: grabbing; }
.parts-drop.over { outline: 2px dashed var(--accent, #4a9eff);
                   outline-offset: 2px; }
.part { cursor: default; }
.part .grip { flex: 0 0 auto; cursor: grab; opacity: .35;
              letter-spacing: -2px; }
.part:hover .grip { opacity: .7; }
#cs-example { display: block; margin-top: 3px; font-style: italic;
              opacity: .75; }
#rows-palette { padding: 0 8px 6px; }
#rows-scroll.over { outline: 2px dashed var(--accent, #4a9eff);
                    outline-offset: -2px; }

/* The toolbox pane on Design. A tool is a name and what it does, because
   nine one-word buttons say nothing to somebody meeting them. */
.tools { display: grid; gap: 4px; }
.tool-section { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.tool-section summary { cursor: pointer; color: var(--dim); font-family: var(--mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em; padding: 4px 0 7px; }
.tool { display: block; text-align: left; padding: 6px 8px; cursor: grab; }
.tool:active { cursor: grabbing; }
.tool b { display: block; font-size: 12px; }
.tool span { display: block; font-size: 11px; opacity: .65; line-height: 1.35;
             margin-top: 1px; white-space: normal; }
.ex-group { padding: 9px 8px 4px; color: var(--faint); font: 10px var(--mono);
            text-transform: uppercase; letter-spacing: .08em; }
.advanced-parts { margin: 8px 0; }
.advanced-parts > summary { cursor: pointer; color: var(--dim); font-size: 11px; }
.advanced-parts > p { margin: 6px 0; }
.pattern h3 { margin: 20px 0 5px; font-size: 13px; }
.example-search { flex: 0 0 auto; padding: 12px 16px; display: grid; gap: 6px; }
#ex-scroll { min-height: 0; }
#ex-scroll .nm { white-space: normal; overflow-wrap: anywhere; }
.example-asm pre { white-space: pre; }
.pattern .eyebrow { color: var(--dim); font: 11px var(--mono); text-transform: uppercase; }
.pattern-when { color: var(--text); font-size: 14px; max-width: 78ch; }
.pattern pre { max-width: 90ch; overflow: auto; padding: 12px; border: 1px solid var(--line);
               background: var(--sunken); color: var(--text); font: 12px/1.6 var(--mono);
               white-space: pre-wrap; }
.pattern ol { max-width: 78ch; padding-left: 22px; }
.pattern li { padding: 3px 0 3px 4px; line-height: 1.55; }
.pattern p { max-width: 78ch; line-height: 1.6; }
.pattern .note-box { margin-top: 20px; padding: 10px; border: 1px solid var(--line);
                     background: var(--panel); }
.pattern .note-box p { margin: 5px 0 0; }

/* Keep Simple mode safe even if a proxy serves an older app.js briefly. */
html[data-mode="simple"] #toolbox-pane [data-new="patch"],
html[data-mode="simple"] #toolbox-pane [data-new="@cave"],
html[data-mode="simple"] #toolbox-pane [data-new="@paste"],
html[data-mode="simple"] #toolbox-pane [data-new="topped_up"],
html[data-mode="simple"] #toolbox-pane [data-new="freeze"] { display: none; }

/* The advanced half of Properties, folded away until it is wanted. */
details.adv { margin: 10px 0; border-top: 1px solid var(--line);
              padding-top: 8px; }
details.adv > summary { cursor: pointer; font-size: 11px;
                        letter-spacing: .06em; text-transform: uppercase;
                        opacity: .7; }
details.adv[open] > summary { margin-bottom: 8px; }
#impl { max-width: min(92vw, 100ch); }
#impl .listing { max-height: 46vh; overflow: auto; white-space: pre;
                 font: 12px/1.5 var(--mono, monospace); }
label.filebtn.inline { display: inline-flex; }
label.filebtn.inline input { display: none; }
/* The footer is one line. A build problem can be a paragraph, and three of
   them used to wrap behind the page and take the status line with them. */
#status { flex-wrap: nowrap; }
#problems { flex: 1 1 auto; min-width: 0; white-space: nowrap;
            overflow: hidden; text-overflow: ellipsis; }
#problems > * { white-space: nowrap; }

#imported { max-width: min(92vw, 78ch); }
.summary { margin: 0 0 10px; padding-left: 18px; line-height: 1.6; }
.summary li { margin: 4px 0; }
#imported details summary { cursor: pointer; font-size: 12px; opacity: .8; }
#imported .listing { max-height: 30vh; overflow: auto; margin-top: 6px; }

/* A surviving address from a value search. */
.found { border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px;
         margin-bottom: 6px; }
.found.unusable { opacity: .55; }
.found-h { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.found-b { display: flex; gap: 6px; margin-top: 5px; }
.found-b button { font-size: 11px; padding: 2px 8px; }
#savefound { max-width: min(92vw, 60ch); }
#savefound .field input, #savefound .field select { width: 100%; }
#sf-why { color: var(--red); }
#find-left h2 { font-size: 15px; margin: 14px 0 6px; }
#find-left .field input, #find-left .field select { width: 100%; }
.sheet-sep { margin: 18px 0 6px; font-size: 11px; letter-spacing: .06em;
             text-transform: uppercase; opacity: .55; }
.choices.small { margin-top: 0; gap: 6px; }
.choices.small .choice { padding: 7px 10px; }
.choices.small .choice b { font-size: 12px; }
#status > span:not(#problems) { flex: 0 0 auto; white-space: nowrap; }
#build-version { color: var(--muted, var(--dim)); }
#status-switch.status-good { color: var(--green); }
/* Held still is a state worth seeing from across the room. */
#status-pause.status-warn { color: var(--amber); border-color: var(--amber); }

/* Persistent desktop panes and shared tab strips. */
#desktop { display: flex; flex: 1; min-height: 0; overflow: hidden; }
#project-explorer[hidden], #designer-navigation[hidden], #rows-inspector[hidden], .pane-divider[hidden] { display: none; }
[data-pane][aria-checked="true"]::after { content: '✓'; float: right; margin-left: 12px; }
#desktop-center { display: flex; flex-direction: column; flex: 1; min-width: 0; }
#tabs { overflow-x: auto; flex-shrink: 0; }
.document-tab { display: flex; flex: none; border-right: 1px solid var(--line); }
.document-tab[hidden] { display: none; }
#tabs .document-close { padding: 2px 6px; border: 0; font-size: 15px; }
#tabs .document-close:hover { background: var(--acc-dk); }
#project-explorer { width: 176px; flex: none; overflow: auto; background: var(--panel); }
#project-explorer summary { padding: 4px 8px; font-weight: 600; cursor: pointer; }
#project-explorer button { display: block; width: 100%; text-align: left; padding: 3px 12px 3px 22px; border: 0; border-radius: 0; background: transparent; }
#project-explorer button.on { background: var(--acc-dk); color: var(--text); }
html[data-mode="simple"] .desktop-advanced { display: none; }
.pane-divider { flex: 0 0 5px; background: var(--line); cursor: col-resize; }
.pane-divider:hover, .pane-divider:focus-visible { background: var(--acc); }
.pane-divider.horizontal { cursor: row-resize; }
#designer-navigation { display: flex; flex-direction: column; width: 220px; flex: none; min-height: 0; }
#designer-navigation > .pane { width: 100%; flex: 1; min-height: 0; }
#designer-navigation #toolbox-pane { flex: 0 1 290px; border-top: 1px solid var(--line); }
#toolbox-pane .tool { display: block; min-height: 28px; width: 100%; padding: 3px 8px; border: 0; border-radius: 0; text-align: left; background: transparent; }
#toolbox-pane .tool:hover { background: var(--acc-dk); }
#toolbox-pane .tools { gap: 0; }
#form-pane { flex: 1; width: auto; min-width: 240px; }
#rows-inspector { width: 300px; flex: none; overflow: auto; min-width: 230px; }
#form-scroll { padding: 12px; }
#rows-inspector .field { margin: 6px 0; }
#rows-inspector .field > label { letter-spacing: 0; text-transform: none; font: 12px var(--sans); }
.dock-tabs { display: flex; align-items: center; border-bottom: 1px solid var(--line); height: 28px; flex: none; }
.dock-tabs button { border-radius: 0; border: 0; background: transparent; padding: 4px 10px; }
.dock-tabs button.on { background: var(--acc-dk); border-bottom: 2px solid var(--acc); }
#tool-dock { height: 200px; min-height: 28px; max-height: 45vh; flex: none; overflow: auto; border-top: 1px solid var(--line2); background: var(--panel); }
#tool-dock.collapsed { height: 28px !important; }
#tool-dock.collapsed #dock-content { display: none; }
#dock-content { padding: 6px 10px; }
#dock-content pre { margin: 0; padding: 0; border: 0; background: transparent; font: 12px/1.5 var(--mono); }
#dock-content h3 { display: none; }
.ams-titlebar h2, .workspace-panel h2 { font-size: 13px; }
.ams-cheat-item { padding: 4px 6px; }
#status { gap: 10px; overflow: hidden; }
#status-switch { padding: 0 5px; border: 0; background: transparent; font: inherit; }
#status-operation { max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#connection-dialog { max-width: 720px; }
.context-menu { position: fixed; z-index: 100; padding: 3px; min-width: 150px; border: 1px solid var(--line2); background: var(--panel); }
.context-menu button { display: block; border: 0; border-radius: 0; text-align: left; width: 100%; background: transparent; }
.context-menu button:hover, .context-menu button:focus { background: var(--acc-dk); }
#toast .tech { margin: 6px 0 0; max-width: 70ch; max-height: 30vh;
               overflow: auto; white-space: pre-wrap;
               font: 11px/1.45 var(--mono, monospace); opacity: .85; }
#toast .blame { cursor: pointer; text-decoration: underline dotted; }
/* A file button inside a field: the field's label styling would uppercase
   the button's own text. */
.field label.filebtn span { text-transform: none; letter-spacing: normal;
                            font-size: 12px; opacity: 1; }

/* Properties, laid out from the schema: a half-width property pairs with the
   next one, a full-width one takes the row. */
.props { display: grid; gap: 8px 10px;
         grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.props .field { margin: 0; }
.props .field.wide { grid-column: 1 / -1; }
.props .field input, .props .field select, .props .field textarea { width: 100%; }
.props .field textarea { font: 12px/1.5 var(--mono, monospace);
                         resize: vertical; }
.props small.hint { display: block; margin-top: 2px; font-size: 11px; }
.option-writes { margin: 8px 0; }
.option-writes summary { cursor: pointer; font-size: 12px; }
.option-writes > .hint { margin: 4px 0; font-family: var(--mono, monospace); }
.option-write-list { display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
                     gap: 2px 10px; align-items: baseline; font-size: 12px; }
.option-write-list > span:nth-child(3n+1) { overflow-wrap: anywhere; }
.option-write-list code { font-size: 11px; }

/* An input with a button on the end of it. */
.withbtn { display: flex; gap: 4px; }
.withbtn input { flex: 1 1 auto; min-width: 0; }
.withbtn button { flex: 0 0 auto; padding: 2px 9px; }

#bindings { max-width: min(92vw, 72ch); }
#bindings-body { max-height: 60vh; overflow: auto; }
.bgroup + .bgroup { margin-top: 14px; }
.bgroup h4 { margin: 0 0 4px; font-size: 11px; letter-spacing: .06em;
             text-transform: uppercase; opacity: .6; }
.bgroup .choice { margin-top: 4px; padding: 5px 9px; }
.bgroup .choice b { font-size: 12px; }

/* Ultrahand lays controls out in order. */
#form-scroll { padding: 18px 24px 28px; background: #101318; }
.form-surface {
  position: relative; margin: 0 auto; overflow: hidden;
  background: #20252d;
  padding: 16px; border: 1px solid #57616e;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.form-empty { position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--faint); font: 12px var(--mono); pointer-events: none; }
.design-control {
  position: relative; cursor: grab; user-select: none;
  overflow: visible; background: #292f39; border: 1px solid #596474;
  box-shadow: 0 2px 6px rgba(0,0,0,.24);
}
.design-control:hover { border-color: var(--acc); }
.design-control.on { border: 2px solid var(--acc); z-index: 5; }
.design-control.moving { opacity: .78; z-index: 20; }
.design-control .ovl-row { padding: 10px 14px; }
.design-control .resize-handle {
  position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px;
  background: var(--acc); border: 2px solid var(--bg); cursor: nwse-resize;
  display: none;
}
.design-control.on .resize-handle { display: block; }
.form-surface.over { outline: 2px dashed var(--acc); outline-offset: 4px; }

/* The form editor: a selection rectangle with handles, a drop line, a band.
   The handles do not resize -- a row's height is the control type's, fixed by
   libultrahand -- they mark what is selected, which is what they are for on a
   surface with one degree of freedom. */
.ovl-hit .grabs { position: absolute; inset: -2px; pointer-events: none; }
.ovl-hit .grabs::before, .ovl-hit .grabs::after {
  content: ""; position: absolute; width: 6px; height: 6px;
  background: var(--accent, #4a9eff); }
.ovl-hit .grabs::before { left: -3px; top: -3px; }
.ovl-hit .grabs::after { right: -3px; bottom: -3px; }
.ovl-hit.dragging { opacity: .4; }
#form-ovl { position: relative; }
.drop-line { position: absolute; left: 0; right: 0; height: 2px;
             background: var(--accent, #4a9eff); pointer-events: none;
             box-shadow: 0 0 6px var(--accent, #4a9eff); }
.band { position: absolute; left: 0; right: 0; pointer-events: none;
        background: rgba(74, 158, 255, .13);
        border: 1px solid var(--accent, #4a9eff); }

.formbar { display: flex; gap: 4px; align-items: center; padding: 4px 8px;
           border-bottom: 1px solid var(--line); }
.formbar button { font-size: 11px; padding: 2px 8px; }
.formbar button:disabled { opacity: .35; }
.formbar .sep { width: 1px; height: 14px; background: var(--line2);
                margin: 0 3px; }
.formbar .hint { font-size: 11px; }
.tool.on { outline: 1px solid var(--accent, #4a9eff); outline-offset: -1px; }
.tool.dragging { opacity: .5; }
.unbound { padding: 4px 2px; }
.unbound p { margin: 0 0 6px; font-size: 12px; }
.unbound .row { display: flex; flex-wrap: wrap; gap: 4px; }
.unbound button { font-size: 11px; padding: 3px 9px; }
#inline-recipe-form .f { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 6px; margin: 5px 0; }
#inline-recipe-form .f > span { color: var(--dim); }
#inline-recipe-form .f:has(textarea) { display: block; }
#inline-recipe-form input, #inline-recipe-form textarea { font-family: var(--mono); }
#rows-inspector .field:has(> input), #rows-inspector .field:has(> select) { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 6px; }
#rows-inspector .field > .hint { grid-column: 1 / -1; }
/* Half-width properties pair up two to a row, so a 100px label beside each
   input left the input about 30px wide. Label above, input full width. */
#rows-inspector .props .field:not(.wide) { display: block; }
#rows-inspector .props .field:not(.wide) > label { margin-bottom: 3px; }
#rows-inspector .field > input, #rows-inspector .field > select { width: 100%; min-width: 0; }
#debug-history, #ptr-results { max-height: 260px; overflow: auto; }
#debug-stop-detail { max-height: 180px; overflow: auto; }
.else-chain { margin-top: 6px; }
.else-chain > .statement-block { margin-left: 0; border-width: 1px 0 0; border-radius: 0; }
.else-chain > .statement-block > .compact-node { border-radius: 0; }
.inspector-section { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.inspector-section h3 { font-size: 12px; color: #c0d2db; margin: 4px 0 10px; }
.inspector-section .hint, .form-empty .hint { color: #9faeb9; }
.choices-editor { margin: 8px 0; }
.choices-editor table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.choices-editor th { font-size: 11px; text-align: left; color: #b9cad3; }
.choices-editor th:last-child { width: 78px; }
.choices-editor td:last-child { white-space: nowrap; }
.choices-editor td:last-child button { padding: 2px 5px; min-width: 22px; }
.choices-editor td { padding: 3px 2px; }
.choices-editor input { min-width: 0; width: 100%; }
.include-control.sw { width: 15px; height: 15px; border-radius: 3px; background: transparent; border: 1px solid #6c8994; color: #addec0; text-align: center; line-height: 13px; font-size: 12px; }
.include-control.sw::before, .include-control.sw::after { display: none; }
#getting-started { max-width: 600px; }
#getting-started li { margin-bottom: 8px; line-height: 1.45; }
.form-empty { pointer-events: auto; position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 18px; }
.include-control { width: 15px; height: 15px; flex: 0 0 15px; accent-color: #79b6a4; cursor: pointer; }

/* Shared presentation for authoring dialogs, menus and forms. */
a { color: var(--acc); text-underline-offset: 2px; }
a:visited { color: var(--acc); }
.menu-popup { width: max-content; min-width: 208px;
  max-width: min(320px, calc(100vw - 16px)); max-height: calc(100dvh - 42px); overflow: auto; }
.menu-popup button, .menu-popup a { white-space: normal; }
.menu-popup a, .menu-popup a:visited { color: var(--text); }
.field, .props, .two, .part .fields, .workspace-fields > label { min-width: 0; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hint { line-height: 1.5; overflow-wrap: anywhere; }
.field > .hint, .field > small { display: block; margin-top: 4px; }
dialog .row { flex-wrap: wrap; }
dialog .row > button { max-width: 100%; white-space: normal; }
dialog textarea { max-width: 100%; }
dialog pre { max-width: 100%; overflow: auto; }
dialog menu { flex-wrap: wrap; align-items: center; }
dialog > form[method=dialog]:last-child { margin-top: 14px; }
dialog > form[method=dialog]:last-child > menu { margin-top: 0; }
#workspace-help { width: min(640px, calc(100vw - 32px)); }
#workspace-help th, #workspace-help td { white-space: normal; }

#bar { height: auto; min-height: 38px; padding: 5px 10px; gap: 6px; flex-wrap: wrap; overflow: visible; }
#bar .grow { flex: 1 1 auto; }
#bar input.hdr { flex: 1 1 160px; min-width: 120px; max-width: 300px; }
#bar .chip { max-width: 24ch; }
.formbar { flex-wrap: wrap; }
#canvas-pane > .pane-h { flex-wrap: wrap; gap: 6px; }
#canvas-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.workspace-columns { gap: 16px; }
dialog .row { padding: 0; margin: 10px 0; border: 0; cursor: default; }
dialog .row:hover { background: transparent; }
dialog label.inline { width: auto; min-width: 0; margin: 0; white-space: normal; align-items: center; }
dialog input[type=checkbox], dialog input[type=radio] { width: auto; min-width: 0; flex: none; margin: 0; }
:is(#cavesheet, #recipes, #bindings, #savefound, #imported, #impl, #paste)[open] {
  display: flex; flex-direction: column; overflow: hidden;
  width: min(760px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
:is(#cavesheet, #recipes, #bindings, #savefound, #imported, #impl, #paste) > :is(h2, form[method=dialog]) { flex: none; }
:is(#cavesheet-body, #bindings-body, #savefound-body, #imported-body, #impl-body, #paste-body) {
  min-height: 0; overflow: auto; flex: 1 1 auto; padding-right: 4px; }
#recipes > .recipes { min-height: 0; overflow: auto; flex: 1 1 auto; }
#recipe-list .choice { padding: 7px 9px; }
#recipe-list .choice .c b { font-size: 12px; }
#recipe-list .choice .c span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11.5px; }
#recipe-list h4 { margin: 10px 0 5px; }
dialog > form[method=dialog]:last-child { border-top: 1px solid var(--line); padding-top: 12px; }
#ask > form, #sure > form { border-top: 0; padding: 0; margin: 0; }
#getting-started > form { display: flex; justify-content: flex-end; }
.control-choices { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.control-choices button { text-align: left; white-space: normal; padding: 10px; }
.control-choices strong, .control-choices span { display: block; }
.control-choices span { color: var(--dim); font-size: 12px; margin-top: 3px; }
#inline-recipe-form .f > button { grid-column: 2; justify-self: start; max-width: 100%; white-space: normal; }
.hook-help { margin: 8px 0; color: var(--dim); font-size: 12px; }
.hook-help > summary { cursor: pointer; color: var(--text); }
#cs-blurb, #cs-example { margin: 4px 0; }
@media (max-width: 1200px) {
  #project-explorer { width: 140px; max-width: 160px; }
  #designer-navigation { width: 170px; max-width: 200px; }
  #rows-inspector { width: 280px; max-width: 300px; }
  #tab-blocks .pane.narrow { width: 150px; flex-basis: 150px; }
  #blocks-inspector { width: 240px; flex: 0 0 240px; }
  #form-scroll { padding: 8px; }
  #canvas-pane { min-width: 240px; }
  .runtime-head { flex-wrap: wrap; }
}

.connect-checks { list-style: none; margin: 6px 0; padding: 0; font-size: 12px; }
.connect-checks li { padding: 2px 0 2px 8px; border-left: 3px solid var(--line2); }
.connect-checks .check-ok { border-left-color: var(--green); }
.connect-checks .check-fail { border-left-color: var(--red); }
#done .build-problems { margin: 6px 0; padding-left: 18px; max-height: 30vh; overflow: auto; }
#problems-list { position: fixed; left: 8px; bottom: 30px; z-index: 40; margin: 0; padding: 8px 12px 8px 28px;
  max-width: min(92vw, 90ch); max-height: 40vh; overflow: auto; background: var(--panel2);
  border: 1px solid var(--line2); border-left: 3px solid var(--red); border-radius: 4px; }
#problems-list[hidden] { display: none; }
#problems-list li { margin: 3px 0; }

/* ---------------------------------------------------- shared control scale
   One height for every input, select and button, so a row of mixed controls
   sits on one line; one gap scale; one radius. Per-tab rules above still win
   where they set their own width. */
:root { --ctl-h: 26px; --gap-1: 4px; --gap-2: 8px; --gap-3: 12px; --measure: 70ch; }
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]),
select { height: var(--ctl-h); box-sizing: border-box; padding-top: 0; padding-bottom: 0; line-height: 1; }
button, .filebtn { min-height: var(--ctl-h); box-sizing: border-box; display: inline-flex;
  align-items: center; justify-content: center; line-height: 1; }
.filebtn span { display: inline-flex; align-items: center; height: 100%; }
button.primary:focus-visible, button.danger:focus-visible { outline-color: var(--text); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 1px solid var(--acc); outline-offset: 0; }
input.invalid { border-color: var(--red); }
fieldset { border: 1px solid var(--line2); border-radius: 3px; margin: 0; padding: 2px 10px 4px; }
fieldset legend { font-size: 11px; color: var(--dim); padding: 0 4px; }

/* ---------------------------------------------------------- Game setup */
.setup { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px 16px;
  max-width: 760px; align-items: start; }
.setup > label { color: var(--dim); font-size: 12px; line-height: var(--ctl-h); margin: 0; }
.setup > div { min-width: 0; }
.setup input.id16 { width: 22ch; }
.setup > div > input:not(.id16) { max-width: 420px; }
.setup .hint { margin: 4px 0 0; max-width: var(--measure); }
.setup-status { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center;
  min-height: var(--ctl-h); font-size: 12px; color: var(--dim); }
.setup-status.ok { color: var(--text); }
.setup-buttons { display: flex; gap: var(--gap-2); flex-wrap: wrap; margin-top: var(--gap-2); }
.setup-path { display: flex; align-items: center; min-height: var(--ctl-h); font-size: 12px;
  color: var(--dim); overflow-wrap: anywhere; }
.setup-note { max-width: var(--measure); margin: 20px 0 0; padding-top: 10px;
  border-top: 1px solid var(--line); }

/* ----------------------------------------------------------- window chrome
   Menu bar, toolbar, document tabs, dock tabs and status bar share one bar
   height and one set of hover, active, disabled and focus states. */
:root { --bar-h: 30px; }
#tabs { height: var(--bar-h); min-height: var(--bar-h); padding: 0; align-items: stretch; }
#tabs button { height: var(--bar-h); min-height: 0; padding: 0 12px; line-height: 1;
  border-bottom: 2px solid transparent; }
#tabs button:hover { color: var(--text); background: var(--panel2); }
#tabs button.on { background: var(--bg); }
#tabs .document-tab { align-items: stretch; }
#tabs .document-tab > button:first-child { padding-right: 4px; }
#tabs .document-close { width: 22px; padding: 0; font-size: 14px; border-bottom: 2px solid transparent; color: var(--faint); }
#tabs .document-close:hover { color: var(--text); background: var(--acc-dk); }
.dock-tabs { height: var(--bar-h); background: var(--panel); }
.dock-tabs button { height: 100%; min-height: 0; padding: 0 12px; line-height: 1; color: var(--dim);
  border-bottom: 2px solid transparent; }
.dock-tabs button:hover { color: var(--text); background: var(--panel2); }
.dock-tabs button.on { color: var(--text); background: var(--bg); border-bottom-color: var(--acc); }
#tool-dock.collapsed { height: var(--bar-h) !important; }
#bar { gap: var(--gap-2); }
#bar button { padding: 0 12px; }
#bar #btn-undo, #bar #btn-redo { width: var(--ctl-h); padding: 0; }
#status { height: 24px; }
#project-explorer button { min-height: 24px; justify-content: flex-start; line-height: 1.2; }
#project-explorer button:hover { background: var(--panel2); }
#project-explorer button:focus-visible, #tabs button:focus-visible, .dock-tabs button:focus-visible {
  outline: 1px solid var(--acc); outline-offset: -2px; }
button:disabled, input:disabled, select:disabled { opacity: .45; cursor: default; }

/* A <p class="row"> holding buttons is a button row, not a list row: it took
   the list row's padding, hover and pointer, which indented the buttons. */
p.row { padding: 6px; cursor: default; border-left: 0; margin: 0; }
p.row:hover { background: none; }
.workspace-panel pre:empty { display: none; }
#live-memory:empty::before { content: "No bytes read yet. Connect to a Switch, attach to the game and read an address.";
  display: block; padding: 8px 0; color: var(--faint); font-size: 12px; }
#live-status { margin: 4px 0 8px; color: var(--dim); font-size: 12px; max-width: var(--measure); }
.workspace-fields { gap: var(--gap-2) var(--gap-3); }
.workspace-fields label { color: var(--dim); font-size: 12px; gap: var(--gap-1); }
.workspace-fields button { align-self: end; }

.hint-box { border: 0; border-radius: 0; padding: 12px 8px; }
.hint-box h2 { margin: 0 0 8px; font-size: 14px; }
.imp, .workspace-card, .cave-hook { border-radius: 3px; }
input[type=file]:not(.filebtn input) { width: auto; height: auto; padding: 0; border: 0;
  background: none; color: var(--dim); font-size: 12px; }
input[type=file]::file-selector-button { font: inherit; font-size: 12px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line2); border-radius: 3px;
  height: var(--ctl-h); padding: 0 11px; margin-right: var(--gap-2); cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--acc); }

.workspace-actions { align-items: center; gap: var(--gap-2); }
.workspace-actions label { flex-direction: row; align-items: center; gap: 6px; color: var(--dim); font-size: 12px; white-space: nowrap; }
.workspace-actions input[type=checkbox] { margin: 0; accent-color: var(--acc); }
.workspace-actions > span { color: var(--dim); font-size: 12px; }
/* Section headers inside a padded panel start at the panel's left edge. */
.pad .pane-h { padding-left: 0; padding-right: 0; }
.workspace-actions select { width: auto; min-width: 90px; }
.workspace-actions label.inline { gap: 6px; }

/* The label and the close button are two buttons in one .document-tab. The
   active underline, background and hover belong to the tab, so they read as
   one control. */
#tabs .document-tab { border-bottom: 2px solid transparent; }
#tabs .document-tab:has(> button.on) { background: var(--bg); border-bottom-color: var(--acc); }
#tabs .document-tab:hover { background: var(--panel2); }
#tabs .document-tab:has(> button.on):hover { background: var(--bg); }
#tabs .document-tab > button { border-bottom: 0; background: transparent; }
#tabs .document-tab > button.on { background: transparent; }
#tabs .document-tab > button:hover { background: transparent; }
#tabs .document-tab > button.document-close { width: 20px; margin-right: 4px; border-radius: 3px;
  align-self: center; height: 20px; min-height: 0; }
#tabs .document-tab > button.document-close:hover { background: var(--line2); color: var(--text); }

/* ---------------------------------------------------- second cleanup pass
   Properties grid, narrow windows, tab styling shared with the rest, dialogs. */
#rows-inspector { width: 320px; }
#rows-inspector .props { grid-template-columns: minmax(0, 1fr); gap: 6px; }
#rows-inspector .props .field,
#rows-inspector .props .field.wide,
#rows-inspector .props .field:not(.wide) {
  display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center;
  column-gap: 8px; grid-column: 1 / -1; margin: 0; }
#rows-inspector .props .field > label,
#rows-inspector .props .field:not(.wide) > label { margin: 0; }
#rows-inspector .props .field > .hint,
#rows-inspector .props .field > small.hint { grid-column: 2; margin-top: 2px; }
#rows-inspector .props .field > input,
#rows-inspector .props .field > select,
#rows-inspector .props .field > textarea { width: 100%; min-width: 0; }
#rows-inspector .props .field:has(> textarea) { align-items: start; }
#rows-inspector .props .field:has(> textarea) > label { padding-top: 5px; }
#rows-inspector .insp { padding-bottom: 48px; }
.control-choices button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.control-choices strong, .control-choices span { display: block; width: 100%; text-align: left; }

/* Narrow windows keep the preview and Properties; the explorer gives way first. */
@media (max-width: 1200px) { #rows-inspector { width: 290px; } }
@media (max-width: 1000px) {
  #project-explorer { width: 112px; max-width: 112px; }
  #project-explorer button { padding-left: 14px; }
  #designer-navigation { width: 150px; max-width: 150px; }
  #rows-inspector { width: 250px; max-width: 250px; min-width: 200px; }
  #rows-inspector .props .field,
  #rows-inspector .props .field.wide,
  #rows-inspector .props .field:not(.wide) { grid-template-columns: 1fr; row-gap: 3px; }
  #rows-inspector .props .field > .hint,
  #rows-inspector .props .field > small.hint { grid-column: 1; }
  #form-pane, #canvas-pane { min-width: 160px; }
}
@media (max-width: 760px) { #project-explorer { display: none; } }

/* Wide windows: forms and prose stay at a readable measure, lists use the rest. */
@media (min-width: 1500px) {
  #tab-examples .pad, #tab-improve .pad, #tab-game .pad { max-width: none; }
  #tab-examples .pad > *:not(table):not(.ex-list) { max-width: 110ch; }
  .setup, .setup-note { max-width: 760px; }
}

/* Pagination only shows when there is something to page. */
#scan-prev-page:disabled, #scan-next-page:disabled { display: none; }
#scan-page:empty { display: none; }

/* Same look for the controls that were styled one by one. */
.ams-add-menu .ams-add-cave { border-color: var(--line2); background: var(--panel); }
.ams-add-menu .ams-add-cave:hover { border-color: var(--acc); }
.workspace-file { position: relative; flex-direction: row; align-items: center; min-height: var(--ctl-h);
  box-sizing: border-box; padding: 0 11px; background: var(--panel); border: 1px solid var(--line2);
  border-radius: 3px; font-size: 12px; color: var(--text); cursor: pointer; white-space: nowrap; }
.workspace-file:hover { border-color: var(--acc); }
.workspace-file input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
  cursor: pointer; padding: 0; }
.workspace-file:focus-within { outline: 2px solid var(--acc); outline-offset: 1px; }
.ams-titlebar .workspace-file { display: inline-flex; }
.debug-panes #debug-disassembly:empty::before, #debug-registers:empty::before, #debug-stack:empty::before {
  content: "Attach GDB to see this."; display: block; padding: 8px 0; color: var(--faint); font-size: 12px; }
.debug-panes > aside { border-left: 1px solid var(--line); padding-left: 8px; }
#tab-pointers h2, #tab-pointers h3, #tab-pointers .pane-h { font: 10px var(--mono); text-transform: uppercase;
  letter-spacing: .08em; color: var(--faint); font-weight: 400; margin: 14px 0 6px; padding: 0; }
#tab-pointers .workspace-fields { align-items: end; }

/* Game setup sits under the tab strip with the same inset as the others. */
#tab-game .pad { padding-top: 12px; }

/* Dialogs */
#start .choice, #start .choice .c, #start .choice .c span { text-align: left; align-items: flex-start; }
#start .choices { gap: 6px; }
#connection-dialog { width: 520px; max-width: calc(100vw - 32px); }
#terms { width: min(640px, calc(100vw - 32px)); }
#terms h3 { margin: 14px 0 6px; font: 600 12px var(--sans); color: var(--text); }
#terms dt { margin-top: 8px; }
#terms dd { margin: 2px 0 0 14px; }
#terms ul { margin: 0; padding-left: 18px; }
#terms li { margin: 4px 0; }
#version-update { max-width: 420px; }

.id-error { color: var(--red); }

/* The generic narrow rule stacks every .split. The Designer and Behavior editor
   keep their columns; the panes shrink instead (see the 1000px block above). */
@media (max-width: 900px) {
  #tab-rows > .split, #tab-blocks > .split { flex-direction: row; }
  #tab-rows .pane, #tab-blocks .pane { max-height: none; }
  #tab-rows .split > .pane, #tab-blocks .split > .pane { border-bottom: 0; }
}

/* Behavior editor Properties uses the same grid as the Designer's. */
#blocks-inspector .props { grid-template-columns: minmax(0, 1fr); gap: 6px; }
#blocks-inspector .props .field,
#blocks-inspector .props .field.wide,
#blocks-inspector .props .field:not(.wide) {
  display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center;
  column-gap: 8px; grid-column: 1 / -1; margin: 0; }
#blocks-inspector .props .field > label { margin: 0; }
#blocks-inspector .props .field > .hint,
#blocks-inspector .props .field > small.hint { grid-column: 2; margin-top: 2px; }
#blocks-inspector .props .field > input,
#blocks-inspector .props .field > select,
#blocks-inspector .props .field > textarea { width: 100%; min-width: 0; }
#blocks-inspector .insp { padding-bottom: 48px; }
@media (max-width: 1000px) {
  #blocks-inspector .props .field,
  #blocks-inspector .props .field.wide,
  #blocks-inspector .props .field:not(.wide) { grid-template-columns: 1fr; row-gap: 3px; }
  #blocks-inspector .props .field > .hint,
  #blocks-inspector .props .field > small.hint { grid-column: 1; }
}
#canvas-pane { overflow-x: auto; }
#terms h2 { margin-top: 0; }
#terms h3 { margin: 10px 0 4px; }
#terms dt { margin-top: 6px; }
#terms li { margin: 2px 0; }

.done.failed { background: #2e1719; border-color: #7a2f35; color: #f1d4d6; }

/* -- accounts and admin ------------------------------------------------ */
#menubar details.acct { margin-left: auto; }
#menubar details.acct .menu-popup { left: auto; right: 0; }
#acct-banner { padding: 3px 12px; background: var(--panel2); border-bottom: 1px solid var(--line2);
  font-size: 12px; color: var(--text); }
dialog.acct-dlg { width: min(92vw, 440px); }
dialog#admin { width: min(96vw, 1100px); height: min(86vh, 760px); display: none; flex-direction: column; max-width: none; }
dialog#admin[open] { display: flex; }
dialog#acct-projects { width: min(96vw, 760px); max-width: none; }
.acct-field { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 2px 10px; align-items: center; margin: 0 0 8px; }
.acct-field > .hint { grid-column: 2; font-size: 11px; color: var(--faint); max-width: 60ch; }
.acct-field input:not([type=checkbox]) { width: 100%; }
.acct-field label.inline { display: inline-flex; gap: 4px; align-items: center; }
.acct-err { color: var(--red); min-height: 1.4em; margin: 4px 0 0; }
.acct-table { overflow: auto; flex: 1 1 auto; min-height: 80px; border: 1px solid var(--line); }
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; }
table.grid th, table.grid td { padding: 3px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th { position: sticky; top: 0; background: var(--panel2); color: var(--faint); font-weight: 600; z-index: 1; }
table.grid th.sort { cursor: pointer; }
table.grid th[data-dir=asc]::after { content: " \25B4"; }
table.grid th[data-dir=desc]::after { content: " \25BE"; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.off td { color: var(--faint); }
table.grid tr.current td:first-child { border-left: 2px solid var(--acc); }
table.grid td.acts { text-align: right; }
table.grid td.acts button { padding: 1px 6px; min-height: 0; height: 20px; font-size: 11px; margin-left: 3px; }
table.kv { border-collapse: collapse; font-size: 12px; margin: 4px 0 8px; }
table.kv th { text-align: left; color: var(--faint); font-weight: 400; padding: 2px 18px 2px 0; }
.admin-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line2); margin-bottom: 8px; }
.admin-tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 4px 14px;
  border-radius: 0; color: var(--faint); }
.admin-tabs button:hover { color: var(--text); background: var(--panel2); }
.admin-tabs button.on { color: var(--text); border-bottom-color: var(--acc); }
.admin-pane { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.admin-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-bar input[type=search] { width: 260px; }
.admin-bar input[type=number] { width: 70px; }
.admin-bar a.button { display: inline-block; padding: 3px 10px; border: 1px solid var(--line2); border-radius: 4px;
  background: var(--panel2); color: var(--text); text-decoration: none; }
.admin-form { max-width: 620px; }
.admin-view pre { max-height: 40vh; overflow: auto; border: 1px solid var(--line); padding: 6px 8px; font: 11px/1.4 var(--mono); margin: 4px 0; }
.admin-pane h4, .acct-versions h4 { margin: 10px 0 4px; font-size: 12px; color: var(--faint); font-weight: 600; text-transform: none; }
.admin-pane svg rect { fill: var(--acc); }
.admin-pane table.kv, .admin-pane svg { align-self: flex-start; }

.cave-group{border:1px solid var(--line,#444);border-left:3px solid #c9893a;border-radius:3px;margin:6px 0;background:rgba(201,137,58,.08)}
.cave-head{display:flex;gap:10px;align-items:baseline;padding:6px 10px;font-size:12px}
.cave-head b{white-space:nowrap;color:#e0a85a;letter-spacing:.04em;text-transform:uppercase;font-size:11px}
.cave-listing{margin:0;padding:6px 10px 8px;font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;overflow-x:auto;white-space:pre}
.cave-listing .at{opacity:.5}
.cave-group details{border-top:1px solid var(--line,#444);padding:4px 10px}
.cave-group summary{cursor:pointer;font-size:11px;opacity:.7}
