/* Laboratory furniture is independent of the machine and its software. */
.laboratory-page {
  --paper: #111827; --ink: #e0e6ef; --muted: #a3b0c5; --line: #30415d; --accent: #83c9f4;
  margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); color: var(--ink); font: 13px/1.5 system-ui, sans-serif;
}
.laboratory-page * { box-sizing: border-box; }
.laboratory-page a { color: var(--accent); }
.laboratory-page button, .laboratory-page input, .laboratory-page select, .laboratory-page textarea {
  font: inherit; color: var(--ink); background: #101c30; border: 1px solid #435674; border-radius: 4px; padding: 5px 8px; min-width: 0; max-width: 100%;
}
.laboratory-page button { cursor: pointer; white-space: normal; }
.laboratory-page button:hover:not(:disabled) { background: #283f60; }
.laboratory-page :disabled { opacity: .45; cursor: default; }
.laboratory-page :focus-visible { outline: 2px solid #83c9f4; outline-offset: 3px; }
.laboratory-page [hidden] { display: none !important; }
.laboratory-page label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.laboratory-page pre { color: var(--ink); background: none; border: 0; border-radius: 0; padding: 0; margin: 0; font: 12px/1.6 var(--mono); white-space: pre; }
.laboratory-header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; padding: 6px 14px; border-bottom: 1px solid var(--line); background: #0c1322; }
.laboratory-brand { font-weight: 700; text-decoration: none; }
.lab-navigation { display: flex; gap: 3px; }
.lab-navigation button { font-size: 16px; line-height: 1; min-width: 28px; }
.laboratory-header h1 { flex: 1; font: 600 14px/1.4 system-ui, sans-serif; margin: 0; letter-spacing: 0; }
.laboratory-header h1 span { color: var(--muted); font-weight: 400; }
.lab-panel-body { padding: 10px; min-height: 0; min-width: 0; }
.lab-panel-body > h2 { margin: 0 0 12px; font: 600 14px/1.4 system-ui, sans-serif; }
.lab-panel-body > h2:not(:first-child) { margin-top: 24px; }
.lab-scroll { overflow: auto; scrollbar-color: #435674 #18253b; }
.lab-hint, .laboratory-credit { color: var(--muted); font: 11px/1.5 system-ui, sans-serif; margin: 8px 0; }
.laboratory-credit { padding: 0 4px; margin: 0; }
.laboratory-page .basic-controls { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; }
.laboratory-page .basic-controls button { padding: 5px 8px; font-size: 11px; }
.laboratory-page .basic-readout { font: 11px/1.5 var(--mono); color: var(--muted); margin: 6px 0; overflow-wrap: anywhere; }
.laboratory-page .basic-message { min-height: 0; margin: 8px 0 0; font: 12px/1.5 system-ui, sans-serif; color: #ffd18a; }
.lab-machine-controls .basic-message:empty { display: none; }
.laboratory-page .basic-controls button:first-child { background: #304e73; color: #eff6ff; }
.laboratory-page :is(.apple2-memory-byte, .lab-memory-byte).is-changed { background: #594420; color: #ffe0a2; }
.lab-tool-registers :is(.apple2-registers, .lab-registers) { display: grid; grid-template-columns: repeat(auto-fit, minmax(8ch, 1fr)); gap: 3px 16px; font: 21px/1.25 var(--mono); }
.lab-tool-registers :is(.apple2-registers, .lab-registers) :is(.apple2-cpu-value, .lab-cpu-value) { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; min-width: 0; }
.lab-tool-registers :is(.apple2-registers, .lab-registers) :is(.apple2-cpu-label, .lab-cpu-label) { color: #a3b0c5; }
.lab-tool-registers :is(.apple2-registers, .lab-registers) :is(.apple2-cpu-number, .lab-cpu-number) { color: #65ef8b; padding: 0 2px; border-radius: 3px; }
.lab-tool-registers :is(.apple2-registers, .lab-registers) .is-changed { background: transparent; text-decoration: none; }
.lab-tool-registers :is(.apple2-registers, .lab-registers) .is-changed :is(.apple2-cpu-number, .lab-cpu-number) { background: #594420; color: #ffe0a2; }
.lab-tool-registers :is(.apple2-flags, .lab-flags) { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; max-width: 193px; margin-top: 12px; }
.lab-tool-registers :is(.apple2-cpu-flag, .lab-cpu-flag), .lab-tool-registers :is(.apple2-cpu-flag, .lab-cpu-flag).is-changed { display: grid; place-items: center; height: 30px; padding-bottom: 3px; border: 1px solid #435674; border-radius: 3px; background: #101c30; color: #d5deec; font: 700 16px/1 var(--mono); text-decoration: none; }
.lab-tool-registers :is(.apple2-cpu-flag, .lab-cpu-flag).is-set { background: #962740; border-color: #e94560; color: #fff; }
.lab-tool-registers :is(.apple2-cpu-flag, .lab-cpu-flag).is-changed { border-color: #ffd18a; box-shadow: inset 0 -3px #ffd18a; }
.lab-tool-registers :is(.apple2-cpu-flag, .lab-cpu-flag) :is(.apple2-cpu-number, .lab-cpu-number) { display: none; }
.lab-address { display: flex; align-items: end; gap: 8px; margin-bottom: 8px; }
.lab-address input { width: 85px; font-family: var(--mono); }
.laboratory-page .lab-live-toggle { width: 11px; height: 11px; margin: 0 4px; padding: 0; border: 1px solid #58677c; border-radius: 2px; background: #273245; }
.laboratory-page .lab-live-toggle[aria-pressed=true] { background: #7ac9a1; border-color: #7ac9a1; box-shadow: 0 0 3px #7ac9a166; }
.lab-inspector-controls { display: flex; align-items: center; gap: 4px; }
.lab-inspector-choices { display: inline-flex; border: 1px solid #435674; border-radius: 3px; }
.laboratory-page .lab-inspector-choices button { min-width: 22px; padding: 2px 4px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font: 10px/1.4 var(--mono); }
.laboratory-page .lab-inspector-choices button + button { border-left: 1px solid #435674; }
.laboratory-page .lab-inspector-choices button[aria-pressed=true] { background: #304e73; color: #eff6ff; }
.laboratory-page .lab-inspector-choices button:focus-visible { outline-offset: -2px; }
.lab-memory-address { display: flex; margin: 0; }
.laboratory-page .lab-memory-address input { width: 54px; padding: 2px 4px; font: 12px/1.4 var(--mono); }
.lab-tool-memory .lab-panel-body { height: 100%; display: flex; flex-direction: column; gap: 8px; }
.lab-memory-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-color: #435674 #18253b; }
.lab-memory-space { position: relative; min-width: 100%; }
.lab-memory-space pre { position: absolute; left: 0; min-width: 100%; width: max-content; }
:is(.apple2-memory-byte, .lab-memory-byte).is-selected { box-shadow: inset 0 -1px #83c9f4; }
.lab-memory-character { display: inline-block; width: 1ch; text-align: center; color: #7ac9a1; }
.lab-memory-character.is-inverse { background: #a3b0c5; color: #132139; }
.lab-memory-character.is-flashing { color: #ffd18a; }
.lab-memory-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; color: #ffd18a; font: 11px/1.5 var(--mono); }
.laboratory-page .lab-memory-editor input { width: 6ch; font: inherit; }
.laboratory-page .lab-memory-editor button { padding: 2px 5px; font-size: 11px; }
[data-memory-editing=true] [data-memory-byte] { cursor: cell; }
.lab-memory-edit-bytes { display: none; }
[data-memory-editing=true] .lab-memory-edit-bytes { display: inline; }
.is-next-fetch { text-decoration: underline dotted #99aef4; text-underline-offset: 3px; }
.is-next-read { text-decoration: underline solid #68d9e8 2px; text-underline-offset: 3px; }
.is-next-write { outline: 1px solid #e3a1df; outline-offset: 1px; }
.lab-memory-key { font: 10px/1.6 var(--mono); color: var(--muted); }
.lab-memory-key span { margin: 0 3px; }
.laboratory-page [data-stack-view] { color: #7ac9a1; font-size: 13px; }
.laboratory-page [data-instruction-preview] { white-space: pre-wrap; font-size: 12px; }
.lab-instruction-assembly { color: #ffd18a; font-size: 16px; }
.lab-instruction-purpose { color: var(--muted); font: 11px/1.5 system-ui, sans-serif; }
.laboratory-page .lab-instruction-calculations { white-space: pre-wrap; overflow-wrap: anywhere; }
.laboratory-page .lab-memory-link { border: 0; padding: 0; background: transparent; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: .2em; }
.lab-tool-registers button:is(.apple2-cpu-number, .lab-cpu-number) { border: 0; background: transparent; font: inherit; }
.lab-tool-registers button:is(.apple2-cpu-number, .lab-cpu-number):disabled { opacity: 1; }
.lab-tool-registers .lab-register-edit { width: 5.5ch; padding: 0 2px; font: inherit; }
.lab-workspace-value { display: grid; grid-template-columns: 6ch 6ch 1fr; column-gap: 8px; padding: 4px 0; border-bottom: 1px solid #263750; font: 11px/1.6 var(--mono); }
.lab-workspace-value > button { justify-self: start; }
.lab-workspace-description { grid-column: 2 / -1; color: var(--muted); font: 10px/1.5 system-ui, sans-serif; }
.lab-workspace-number { color: #7ac9a1; justify-self: start; }
.lab-workspace-number.is-changed, .lab-watch-value.is-changed { background: #594420; color: #ffe0a2; }
.lab-workspace-number .lab-memory-link, .lab-watch-value.is-changed .lab-memory-link { color: inherit; }
.lab-watch-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-bottom: 12px; }
.lab-watch-form label:nth-child(2) { flex: 1; }
.lab-watch-row { display: grid; grid-template-columns: 6ch minmax(0, 1fr) auto 24px; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid #263750; font: 12px/1.5 var(--mono); }
.lab-watch-row > span:nth-child(2) { overflow-wrap: anywhere; color: var(--muted); }
.lab-watch-row > button { padding: 0 4px; }
.lab-watch-stops { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); }
.lab-watch-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lab-watch-history-heading h2 { margin: 0; font: 600 14px/1.4 system-ui, sans-serif; }
.laboratory-page .lab-watch-byte { border: 0; border-radius: 0; padding: 0; background: transparent; color: inherit; font: inherit; }
.lab-call-frame { padding: 7px 0; border-bottom: 1px solid #263750; font: 12px/1.6 var(--mono); }
.lab-call-frame .lab-hint { margin: 3px 0 0; }
.lab-hardware-map { width: 100%; border-collapse: collapse; font: 11px/1.5 var(--mono); }
.lab-hardware-map th { text-align: left; color: var(--muted); font-weight: 400; }
.lab-hardware-map td, .lab-hardware-map th { padding: 4px 5px; border-bottom: 1px solid #263750; }
.lab-hardware-map td:first-child { white-space: nowrap; }
.lab-hardware-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 10px; }
.lab-hardware-card { border: 1px solid var(--line); border-radius: 4px; padding: 10px; }
.lab-hardware-card h3 { margin: 0 0 9px; font: 600 12px/1.4 system-ui, sans-serif; color: var(--accent); }
.lab-hardware-card dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; margin: 0; font: 11px/1.5 var(--mono); }
.lab-hardware-card dt { color: var(--muted); }
.lab-hardware-card dd { margin: 0; color: #7ac9a1; justify-self: start; }
.lab-hardware-card a { font-size: 11px; }
.lab-hardware-map .is-changed, .lab-hardware-card .is-changed { color: #ffe0a2; background: #594420; }
.lab-device-controls { display: flex; align-items: end; gap: 10px; }
.lab-device-event { padding: 8px 0; border-bottom: 1px solid #263750; }
.lab-device-transfer { font: 12px/1.6 var(--mono); color: #7ac9a1; }
.lab-device-event .lab-hint { margin: 4px 0 0; }
.lab-breakpoint-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; }
.laboratory-page .lab-breakpoint-row label { display: flex; align-items: center; gap: 8px; font: 12px/1.5 var(--mono); }
.lab-breakpoint-row button { padding: 0 5px; }
.laboratory-page .lab-code .lab-breakpoint-marker { padding: 0 3px; border: 0; background: transparent; color: #8294ae; font-size: 15px; text-decoration: none; }
.laboratory-page .lab-code .lab-breakpoint-marker[aria-pressed=true] { color: #ff879c; }
.laboratory-page summary { cursor: pointer; color: #b4cce8; font-size: 12px; padding: 6px 0; }
.laboratory-page .rom-controls { display: grid; grid-template-columns: 1fr; gap: 8px; }
.laboratory-page .rom-controls button { justify-self: start; }
.laboratory-page .rom-current { font-size: 12px; margin: 12px 0 8px; }
.lab-routines { font-size: 12px; }
.lab-routines dt { color: #c3daf6; font-family: var(--mono); margin-top: 14px; }
.lab-routines dd { margin: 4px 0; color: var(--muted); }
.lab-code-navigation { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.lab-code-navigation label { display: flex; align-items: center; gap: 5px; margin-right: auto; }
.lab-code { width: 100%; border-collapse: collapse; font: 11px/1.7 var(--mono); }
.lab-code caption { text-align: left; }
.lab-code th { padding: 0 8px 0 2px; white-space: nowrap; text-align: left; font-size: 10px; color: var(--muted); font-weight: 400; }
.lab-code th:first-child { padding-right: 6px; }
.lab-code td { padding: 3px 8px 3px 2px; vertical-align: top; white-space: nowrap; }
.lab-code th:nth-child(7), .lab-code td:nth-child(7), .lab-code th:last-child, .lab-code td:last-child { padding-left: 12px; }
.lab-code th:nth-child(3), .lab-code td:nth-child(3) { padding-right: 12px; }
.lab-code td:first-child { color: var(--accent); }
.lab-code button { border: 0; padding: 0; background: transparent; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: .2em; }
.lab-code button:disabled { opacity: 1; color: var(--muted); text-decoration: none; }
.lab-code .is-current { background: #263c56; }
.lab-code .is-executed { color: var(--muted); }
.lab-code .flow-unconditional td { border-bottom: 1px solid #7087a5; }
.lab-code .flow-conditional td { border-bottom: 1px dotted #7087a5; }
.lab-code .lab-code-label { white-space: nowrap; text-align: left; color: #ffd18a; }
.lab-rom-reference h2 { margin: 12px 0; font: 600 14px/1.4 system-ui, sans-serif; }
.lab-reference-current { margin: 10px 0 14px; padding: 10px; background: #131f33; border: 1px solid var(--line); border-radius: 4px; }
.lab-reference-current h3 { margin: 0; color: #ffd18a; font: 600 12px/1.5 var(--mono); }
.lab-reference-current p { margin: 8px 0; font-size: 12px; }
.lab-reference-list { max-height: 260px; overflow: auto; scrollbar-width: thin; }
.lab-reference-list button { display: block; width: 100%; padding: 5px 7px; border: 0; border-radius: 0; text-align: left; background: transparent; font: 12px/1.5 var(--mono); }
.lab-reference-list button[aria-pressed=true] { background: #304e73; color: #eff6ff; }
.lab-log-controls, .lab-log-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.lab-log-controls label, .lab-log-filters label { display: flex; align-items: center; gap: 4px; }
.lab-log-controls button { margin-left: auto; }
.lab-log-filters { margin: 12px 0 0; padding: 8px; border: 1px solid var(--line); border-radius: 4px; }
.lab-log-filters legend { color: var(--muted); font-size: 11px; }
.lab-log-help { margin-bottom: 12px; }
.laboratory-page [data-log-output] { font-size: 11px; }
.lab-history-controls label { display: flex; align-items: center; gap: 5px; }
.lab-tool-trace .lab-panel-body { display: grid; height: 100%; grid-template-rows: auto auto minmax(70px, 1fr) auto minmax(70px, 1fr); }
.lab-history-list, .laboratory-page [data-history-detail] { overflow: auto; min-height: 0; }
.lab-history-list button { display: block; width: 100%; border: 0; border-radius: 0; padding: 2px 4px; text-align: left; white-space: pre; background: transparent; font: 11px/1.6 var(--mono); }
.lab-history-list button[aria-pressed="true"] { background: #304e73; color: #eff6ff; }
.laboratory-page [data-history-detail] { border-top: 1px solid var(--line); padding-top: 8px; }
/* Apple II presentation uses the same screen renderer as the classroom. */
.apple2-laboratory .apple2-display-surround { margin: 8px 0 4px; padding: 10px; background: #080f15; border: 1px solid #314152; border-radius: 5px; }
.apple2-laboratory .apple2-screen { padding: 2%; font-size: 2.5cqw; border-radius: 0; }
.apple2-laboratory .apple2-display-options label { display: flex; }

.laboratory { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lab-tool { position: relative; height: 100%; width: 100%; overflow: auto; background: #18253b; scrollbar-color: #435674 #18253b; }
.lab-tool-trace pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; }
.lab-tool-screen .lab-panel-body { height: 100%; display: grid; grid-template-rows: minmax(120px, 1fr) auto auto; gap: 6px; }
.lab-display-area { container-type: size; display: grid; place-items: center; min-width: 0; min-height: 0; }
.lab-display-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.lab-display-footer .apple2-display-options { margin-left: auto; }
/* Fit the 4:3 screen plus its surround's 10px padding and 1px border into the available area. */
.lab-tool-screen .apple2-display-surround { width: min(100cqw, calc((100cqh - 22px) * 4 / 3 + 22px)); margin: 0; }
.lab-tool-screen .basic-readout { margin: 0; }

/* Inspection overlays the existing text cells without changing the display raster. */
.apple2-screen.is-inspecting .apple2-row > span { cursor: crosshair; }
.apple2-screen .apple2-row > span.is-inspected { outline: 2px solid #ffcf66; outline-offset: -1px; z-index: 1; }
.lab-screen-inspector { display: grid; gap: 5px; padding-top: 6px; border-top: 1px solid var(--line); font: 12px/1.5 var(--mono); }
.lab-screen-inspector[hidden] { display: none; }
.lab-screen-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lab-screen-inspector [data-screen-notice]:empty { display: none; }
.lab-display-footer [data-screen-inspect][aria-pressed="true"] { color: #ffcf66; border-color: #ffcf66; }

.lab-code td.lab-rom-note { white-space: normal; min-width: 23ch; max-width: 32ch; font: 11px/1.5 system-ui, sans-serif; color: #b4cce8; }
.lab-routine-details { margin: 12px 0; font-size: 12px; }
.lab-routine-details dt { color: var(--accent); font-weight: 600; margin-top: 10px; }
.lab-routine-details dd { margin: 4px 0 0; }
.lab-reference-links { display: flex; flex-wrap: wrap; gap: 5px; }
.lab-reference-links button { font: 11px/1.5 var(--mono); padding: 3px 6px; }
[data-rom-walkthrough] h2 { font: 600 14px/1.5 var(--mono); color: #ffd18a; margin: 16px 0 10px; }
[data-rom-walkthrough] h3 { color: var(--accent); font-size: 12px; margin: 16px 0 6px; }
[data-rom-walkthrough] p { font-size: 12px; line-height: 1.6; }
.lab-walkthrough-setup { padding: 10px; background: #131f33; border-left: 2px solid var(--line); }
.lab-walkthrough-navigation { display: flex; gap: 6px; margin-top: 8px; }

.lab-state-form { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; margin-bottom: .8rem; }
.lab-state-form label { flex: 1; }
.lab-state-form input { width: 100%; }
.lab-state-differences { font: .85rem/1.6 var(--mono); overflow-wrap: anywhere; }
.lab-state-differences > div { border-bottom: 1px solid var(--line); padding: .15rem 0; }
.lab-state-differences pre { white-space: pre-wrap; }
