/* A 1988 desktop, redrawn: one-bit black and white, every pixel doubled
   (--u). Original artwork; the type is the emulator's own 5x7 font. */

:root { --u: 2px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #fff; color: #000; }
body { font: 14px monospace; user-select: none; -webkit-user-select: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: default; }
a { color: inherit; }

/* Pixel type: canvases of the 5x7 glyphs, black on clear; inverse by filter. */
canvas.px { display: inline-block; vertical-align: middle; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }
.inv canvas.px, canvas.px.inv { filter: invert(1); }

/* Menu bar */
#menubar {
  position: fixed; top: 0; left: 0; right: 0; height: calc(12 * var(--u)); z-index: 100;
  display: flex; align-items: stretch; background: #fff; border-bottom: var(--u) solid #000;
  padding-left: calc(6 * var(--u));
}
.menu { position: relative; }
.menu > .title { display: flex; align-items: center; height: 100%; padding: 0 calc(5 * var(--u)); }
.menu.open > .title { background: #000; }
.menu.open > .title canvas.px { filter: invert(1); }
.menu > ul {
  display: none; position: absolute; top: 100%; left: 0; margin: 0; padding: var(--u) 0; list-style: none;
  min-width: calc(110 * var(--u)); background: #fff; border: var(--u) solid #000;
  box-shadow: var(--u) var(--u) 0 #000;
}
.menu.open > ul { display: block; }
.menu li { display: flex; justify-content: space-between; align-items: center; gap: calc(8 * var(--u)); height: calc(12 * var(--u)); padding: 0 calc(6 * var(--u)); white-space: nowrap; }
.menu li:not(.sep):not(.disabled):hover { background: #000; }
.menu li:not(.sep):not(.disabled):hover canvas.px { filter: invert(1); }
.menu li.sep { height: 0; padding: 0; margin: calc(3 * var(--u)) 0; border-top: var(--u) dotted #000; }
.menu li.disabled canvas.px { opacity: .35; }
.menu li .mark { width: calc(6 * var(--u)); }

/* Desktop: the 640-mode gray, a pixel on and a pixel off. */
#desktop {
  position: absolute; inset: calc(12 * var(--u)) 0 0 0;
  background: repeating-linear-gradient(90deg, #000 0 var(--u), #fff var(--u) calc(2 * var(--u)));
}
#desktop.drop { outline: calc(2 * var(--u)) dashed #000; outline-offset: calc(-4 * var(--u)); }
.icons {
  position: absolute; top: calc(8 * var(--u)); right: calc(6 * var(--u)); bottom: calc(6 * var(--u));
  display: flex; flex-direction: column; align-items: center; gap: calc(6 * var(--u)); width: calc(64 * var(--u));
}
.icon { display: flex; flex-direction: column; align-items: center; gap: var(--u); outline: none; }
.icon svg { width: calc(32 * var(--u)); height: calc(32 * var(--u)); }
.icon .label { background: #fff; padding: 0 var(--u); white-space: nowrap; }
.icon.selected svg, .icon.over svg { filter: invert(1); }
.icon.selected .label, .icon.over .label { background: #000; }
.icon.selected .label canvas.px, .icon.over .label canvas.px { filter: invert(1); }
.icon.trash { margin-top: auto; }
.icon.empty svg { opacity: .55; }

/* Windows */
.window {
  position: absolute; background: #fff; border: var(--u) solid #000;
  box-shadow: var(--u) var(--u) 0 #000; min-width: calc(160 * var(--u));
}
.titlebar {
  display: flex; align-items: center; gap: calc(4 * var(--u)); height: calc(12 * var(--u));
  padding: 0 calc(3 * var(--u)); border-bottom: var(--u) solid #000;
  background: repeating-linear-gradient(#fff 0 var(--u), #000 var(--u) calc(2 * var(--u))) content-box;
  background-clip: content-box; padding-block: calc(2 * var(--u));
}
.window:not(.front) .titlebar { background: #fff; }
.titlebar .name { margin: 0 auto; background: #fff; padding: 0 calc(4 * var(--u)); }
.titlebar .close, .titlebar .zoom, .titlebar .zoom-pad {
  width: calc(9 * var(--u)); height: calc(8 * var(--u)); background: #fff; border: var(--u) solid #000;
  box-shadow: 0 0 0 var(--u) #fff; flex: none;
}
.titlebar .zoom-pad { visibility: hidden; }
.titlebar .zoom { position: relative; }
.titlebar .zoom::after { content: ""; position: absolute; left: 0; top: 0; width: 55%; height: 55%; border-right: var(--u) solid #000; border-bottom: var(--u) solid #000; }
.window:not(.front) .titlebar .close, .window:not(.front) .titlebar .zoom { visibility: hidden; }
.infobar { display: flex; justify-content: space-between; gap: calc(10 * var(--u)); padding: var(--u) calc(5 * var(--u)); border-bottom: var(--u) solid #000; min-height: calc(11 * var(--u)); }
.body { padding: calc(6 * var(--u)) calc(8 * var(--u)); }
.body p { margin: 0 0 calc(3 * var(--u)); }
.links { list-style: none; margin: calc(4 * var(--u)) 0; padding: 0; }
.links li { margin-bottom: calc(4 * var(--u)); }
.links a, a.linkish { text-decoration: none; border-bottom: var(--u) dotted #000; }
.links a:hover, a.linkish:hover { background: #000; }
.links a:hover canvas.px, a.linkish:hover canvas.px { filter: invert(1); }
.links .sub { display: block; margin-left: calc(10 * var(--u)); opacity: .7; }

/* The machine */
.screen { position: relative; display: flex; justify-content: center; background: #000; line-height: 0; }
#canvas { display: block; image-rendering: pixelated; outline: none; }
#canvas.nocursor { cursor: none; }
.screen:fullscreen { display: flex; align-items: center; justify-content: center; width: 100vw; height: 100vh; }
.off {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(8 * var(--u)); background: #fff; line-height: normal;
}
.summary { display: grid; grid-template-columns: auto auto; gap: calc(2 * var(--u)) calc(8 * var(--u)); }
.note { opacity: .7; margin: 0; }
.strip { display: flex; flex-wrap: wrap; gap: calc(3 * var(--u)); padding: calc(4 * var(--u)); border-top: var(--u) solid #000; }
.hint { margin: 0; padding: 0 calc(4 * var(--u)) calc(4 * var(--u)); opacity: .7; }
#win-machine:not(.running) .strip .btn:not([data-act="joystick"]) { opacity: .35; pointer-events: none; }

/* Desktops: the machine's window is sized (frame.js) and the picture takes
   what its title, info bar, buttons and hint leave. Phones: see below. */
body:not(.mobile) #win-machine { display: flex; flex-direction: column; min-width: 0; }
body:not(.mobile) #win-machine > * { flex: none; }
body:not(.mobile) #win-machine > .screen { flex: 1 1 0; min-height: 0; align-items: center; overflow: hidden; }
body:not(.mobile) #win-machine > .hint { padding-right: calc(14 * var(--u)); }
.grip { display: none; position: absolute; z-index: 2; touch-action: none; }
body:not(.mobile) .grip { display: block; }
.grip[data-edge="n"], .grip[data-edge="s"] { left: calc(6 * var(--u)); right: calc(6 * var(--u)); height: calc(4 * var(--u)); cursor: ns-resize; }
.grip[data-edge="e"], .grip[data-edge="w"] { top: calc(6 * var(--u)); bottom: calc(6 * var(--u)); width: calc(4 * var(--u)); cursor: ew-resize; }
.grip[data-edge="n"] { top: calc(-3 * var(--u)); }
.grip[data-edge="s"] { bottom: calc(-3 * var(--u)); }
.grip[data-edge="e"] { right: calc(-3 * var(--u)); }
.grip[data-edge="w"] { left: calc(-3 * var(--u)); }
.grip[data-edge="nw"], .grip[data-edge="ne"], .grip[data-edge="sw"] { width: calc(7 * var(--u)); height: calc(7 * var(--u)); }
.grip[data-edge="nw"] { top: calc(-3 * var(--u)); left: calc(-3 * var(--u)); cursor: nwse-resize; }
.grip[data-edge="ne"] { top: calc(-3 * var(--u)); right: calc(-3 * var(--u)); cursor: nesw-resize; }
.grip[data-edge="sw"] { bottom: calc(-3 * var(--u)); left: calc(-3 * var(--u)); cursor: nesw-resize; }
/* The size box: two overlapping squares in the bottom-right corner. */
.grip[data-edge="se"] {
  right: 0; bottom: 0; width: calc(11 * var(--u)); height: calc(11 * var(--u)); cursor: nwse-resize;
  background: #fff; border-left: var(--u) solid #000; border-top: var(--u) solid #000;
}
.grip[data-edge="se"]::before, .grip[data-edge="se"]::after { content: ""; position: absolute; border: var(--u) solid #000; background: #fff; }
.grip[data-edge="se"]::before { left: calc(3 * var(--u)); top: calc(3 * var(--u)); width: calc(6 * var(--u)); height: calc(6 * var(--u)); }
.grip[data-edge="se"]::after { left: calc(1 * var(--u)); top: calc(1 * var(--u)); width: calc(4 * var(--u)); height: calc(4 * var(--u)); }
body.resizing, body.resizing * { user-select: none; }
body.mobile .desk-only { display: none !important; }

/* Buttons: round-cornered, the default one ringed. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: calc(40 * var(--u));
  height: calc(13 * var(--u)); padding: 0 calc(6 * var(--u)); background: #fff;
  border: var(--u) solid #000; border-radius: calc(6 * var(--u));
}
.btn:active, .btn.on { background: #000; }
.btn:active canvas.px, .btn.on canvas.px { filter: invert(1); }
.btn.default { box-shadow: 0 0 0 var(--u) #fff, 0 0 0 calc(3 * var(--u)) #000; border-radius: calc(7 * var(--u)); margin: calc(3 * var(--u)); }
.btn:disabled { opacity: .35; }

/* Dialogs: a modal with a heavy double frame. */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: calc(30 * var(--u)); }
.dialog {
  background: #fff; border: var(--u) solid #000; padding: calc(4 * var(--u));
  box-shadow: var(--u) var(--u) 0 #000; max-height: calc(100vh - 40 * var(--u)); overflow: auto;
}
.dialog > .inner { border: calc(3 * var(--u)) solid #000; outline: var(--u) solid #000; outline-offset: calc(2 * var(--u)); padding: calc(6 * var(--u)) calc(10 * var(--u)); margin: calc(3 * var(--u)); }
:is(.dialog, .wform) h2 { margin: 0 0 calc(4 * var(--u)); padding-bottom: calc(2 * var(--u)); border-bottom: var(--u) solid #000; font-size: inherit; }
:is(.dialog, .wform) .cols { display: flex; gap: calc(10 * var(--u)); align-items: flex-start; flex-wrap: wrap; }
:is(.dialog, .wform) .buttons { display: flex; justify-content: flex-end; align-items: center; gap: calc(8 * var(--u)); margin-top: calc(6 * var(--u)); }
:is(.dialog, .wform) .buttons .spacer { margin-right: auto; }
fieldset { border: var(--u) dotted #000; margin: 0 0 calc(5 * var(--u)); padding: calc(3 * var(--u)) calc(6 * var(--u)) calc(4 * var(--u)); }
legend { padding: 0 calc(2 * var(--u)); }
.row { display: flex; align-items: center; gap: calc(4 * var(--u)); min-height: calc(11 * var(--u)); }
input[type=text] { font: 14px monospace; border: var(--u) solid #000; padding: var(--u) calc(2 * var(--u)); width: 100%; margin-bottom: calc(3 * var(--u)); }

/* Checkboxes cross, radio buttons dot: the inputs are real, the look is drawn. */
.check, .radio { display: flex; align-items: center; gap: calc(4 * var(--u)); min-height: calc(11 * var(--u)); position: relative; }
.check input, .radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box, .radio .box { flex: none; width: calc(9 * var(--u)); height: calc(9 * var(--u)); border: var(--u) solid #000; background: #fff; }
.radio .box { border-radius: 50%; }
.check input:checked + .box {
  background:
    linear-gradient(45deg, transparent calc(50% - var(--u) * .75), #000 calc(50% - var(--u) * .75) calc(50% + var(--u) * .75), transparent calc(50% + var(--u) * .75)),
    linear-gradient(-45deg, transparent calc(50% - var(--u) * .75), #000 calc(50% - var(--u) * .75) calc(50% + var(--u) * .75), transparent calc(50% + var(--u) * .75)), #fff;
}
.radio input:checked + .box { box-shadow: inset 0 0 0 calc(1.5 * var(--u)) #fff, inset 0 0 0 calc(5 * var(--u)) #000; }
.check input:focus-visible + .box, .radio input:focus-visible + .box { outline: var(--u) dotted #000; outline-offset: var(--u); }
/* A control that does not apply right now (an accelerator's, with None chosen): greyed. */
.check:has(input:disabled), .radio:has(input:disabled), .popup:disabled { opacity: .35; }
/* The accelerator's DIP switches: the delays and options, then the slots beside them. */
.switches { display: flex; flex-wrap: wrap; column-gap: calc(10 * var(--u)); }
input[type=range] { width: calc(46 * var(--u)); accent-color: #000; }

.list { border: var(--u) solid #000; min-height: calc(36 * var(--u)); max-height: calc(60 * var(--u)); overflow: auto; margin-bottom: calc(3 * var(--u)); }
.list > div { padding: 0 calc(3 * var(--u)); min-height: calc(11 * var(--u)); display: flex; align-items: center; }
.list > div.sel { background: #000; }
.list > div.sel canvas.px { filter: invert(1); }

@media (max-width: 900px), (max-height: 600px) { :root { --u: 1.5px; } }

/* Pop-up menus: a shadowed box with a down-pointing mark; the list opens over it. */
.popup {
  display: inline-flex; align-items: center; gap: calc(4 * var(--u)); height: calc(12 * var(--u));
  padding: 0 calc(12 * var(--u)) 0 calc(4 * var(--u)); background: #fff; position: relative;
  border: var(--u) solid #000; box-shadow: var(--u) var(--u) 0 #000;
}
.popup::after {
  content: ""; position: absolute; right: calc(3 * var(--u)); top: calc(50% - 1.5 * var(--u));
  border: calc(3 * var(--u)) solid transparent; border-top-color: #000; border-bottom: 0;
}
.popup-list {
  position: fixed; z-index: 300; margin: 0; padding: var(--u) 0; list-style: none; background: #fff;
  border: var(--u) solid #000; box-shadow: var(--u) var(--u) 0 #000; max-height: 70vh; overflow: auto;
}
.popup-list li { display: flex; align-items: center; height: calc(12 * var(--u)); padding: 0 calc(10 * var(--u)) 0 calc(6 * var(--u)); white-space: nowrap; }
.popup-list li.sel { box-shadow: inset calc(2 * var(--u)) 0 0 #000; }
.popup-list li:hover { background: #000; }
.popup-list li:hover canvas.px { filter: invert(1); }

/* The board editor: one fault per row, where it is underneath. */
.faults { display: flex; flex-direction: column; gap: calc(4 * var(--u)); margin-bottom: calc(4 * var(--u)); max-height: 50vh; overflow: auto; }
.fault { border-bottom: var(--u) dotted #000; padding-bottom: calc(3 * var(--u)); }
.fault .row { flex-wrap: wrap; }
.fault .where { opacity: .7; margin: var(--u) 0 0; }
.btn.small { min-width: 0; padding: 0 calc(4 * var(--u)); }

/* Pythia: the agent's log, a line per entry, its kind in the gutter. */
.plog {
  width: calc(230 * var(--u)); height: calc(150 * var(--u)); overflow-y: auto; padding: calc(3 * var(--u)) calc(4 * var(--u));
  user-select: text; -webkit-user-select: text;
}
.plog .line { display: flex; gap: calc(3 * var(--u)); align-items: flex-start; min-height: calc(10 * var(--u)); flex-wrap: nowrap; }
.plog .line > .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.plog .k { flex: none; width: calc(6 * var(--u)); }
.plog .k-end > .t, .plog .k-problem > .t { font-weight: bold; }
.plog .k-problem { background: repeating-linear-gradient(90deg, transparent 0 var(--u), #ddd var(--u) calc(2 * var(--u))); }
.plog .k-state { opacity: .55; }
.psay { padding: calc(2 * var(--u)) calc(3 * var(--u)) 0; }
.psay input { margin-bottom: 0; }
.btn.kill { background: #000; }
.btn.kill canvas.px { filter: invert(1); }
.btn.kill:disabled { background: #fff; }
.btn.kill:disabled canvas.px { filter: none; }
.field { display: flex; flex-direction: column; margin-bottom: calc(2 * var(--u)); }
.field .label { margin-bottom: var(--u); }
.field input { margin-bottom: 0; }
input[type=password] { font: 14px monospace; border: var(--u) solid #000; padding: var(--u) calc(2 * var(--u)); width: 100%; }
input.num { font: 14px monospace; border: var(--u) solid #000; padding: var(--u) calc(2 * var(--u)); width: calc(40 * var(--u)); margin-left: auto; }
input.num:disabled { opacity: .35; }
.note.problem { opacity: 1; font-weight: bold; }
:is(.dialog, .wform) .pythia-cols > div { width: calc(170 * var(--u)); }

/* ---------- Phones: one column, the machine first --------------------- */

.menu-toggle, .keyrow, #softkb { display: none; }
/* The phone's keyboard types into this; it is on screen (iOS raises no
   keyboard for a field off it) but invisible, at 16px so iOS doesn't zoom. */
#softkb {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0;
  font-size: 16px; border: 0; padding: 0; resize: none; pointer-events: none;
}
body.mobile { --u: 2px; }
body.mobile #softkb { display: block; }
body.mobile #canvas { touch-action: none; }
body.mobile button, body.mobile .menu li { touch-action: manipulation; }
body.mobile .icons, body.mobile .hint, body.mobile #win-machine > .titlebar, body.mobile #btn-capture { display: none; }
body.mobile #desktop { background: #fff; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
body.mobile #win-machine {
  position: static; border: 0; box-shadow: none; min-width: 0; width: 100%;
}
body.mobile .screen { padding-top: env(safe-area-inset-top, 0); }
body.mobile .strip { justify-content: center; }
body.mobile .keyrow { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(3 * var(--u)); padding: calc(4 * var(--u)); border-top: var(--u) solid #000; }
body.mobile .keyrow .btn { min-width: calc(22 * var(--u)); height: calc(20 * var(--u)); padding: 0 calc(4 * var(--u)); }
body.mobile .keyrow .btn.wide { min-width: calc(60 * var(--u)); }
#win-machine:not(.running) .keyrow .btn { opacity: .35; pointer-events: none; }
body.mobile.typing .strip { display: none; }
/* Chords: armed for the next key (inverted), or locked/held down (inverted,
   ringed). Long-press shows it's being held before it locks. */
body.mobile .keyrow .btn { -webkit-touch-callout: none; }
.keyrow .btn.locked { background: #000; box-shadow: 0 0 0 var(--u) #fff, 0 0 0 calc(2.5 * var(--u)) #000; }
.keyrow .btn.locked canvas.px { filter: invert(1); }
.keyrow .btn.pressing { outline: var(--u) dashed #000; outline-offset: calc(2 * var(--u)); }

/* The menu bar becomes one Menu button; its menus open as one sheet. */
body.mobile .menu-toggle { display: flex; align-items: center; padding: 0 calc(5 * var(--u)); }
body.mobile #menubar.sheet .menu-toggle { background: #000; }
body.mobile #menubar.sheet .menu-toggle canvas.px { filter: invert(1); }
body.mobile #menubar .menu { display: none; }
body.mobile #menubar { padding-left: env(safe-area-inset-left, 0); }
body.mobile #menubar.sheet {
  height: auto; max-height: 100dvh; overflow-y: auto; flex-direction: column; align-items: stretch;
  box-shadow: 0 var(--u) 0 #000;
}
body.mobile #menubar.sheet > * { flex: none; }
body.mobile #menubar.sheet .menu-toggle { height: calc(16 * var(--u)); }
body.mobile #menubar.sheet .menu { display: block; border-top: var(--u) solid #000; }
body.mobile #menubar.sheet .menu > .title { height: calc(14 * var(--u)); background: #fff; }
body.mobile #menubar.sheet .menu > .title canvas.px { filter: none; }
body.mobile #menubar.sheet .menu > ul { display: block; position: static; border: 0; box-shadow: none; min-width: 0; }
body.mobile #menubar.sheet .menu li:not(.sep) { height: calc(18 * var(--u)); }

/* Other windows open as full-width sheets. */
body.mobile .window:not(#win-machine) {
  position: fixed; left: 0 !important; right: 0; top: calc(12 * var(--u)) !important; min-width: 0;
  max-height: calc(100dvh - 12 * var(--u)); overflow-y: auto; border-left: 0; border-right: 0;
}
body.mobile .modal { padding: calc(8 * var(--u)) calc(2 * var(--u)) 0; }
body.mobile .dialog { max-width: 100%; }

/* Phones: nothing wider than the screen. Pixel text wraps by word (ui.js),
   so let it: dialogs, windows and the menu sheet reflow to one column. */
body.mobile .window:not(#win-machine) .body, body.mobile .dialog { overflow-wrap: anywhere; }
body.mobile .plog { width: 100%; height: 55dvh; }
body.mobile input[type=text], body.mobile input[type=password], body.mobile input.num { font-size: 16px; }
body.mobile .infobar { flex-wrap: wrap; row-gap: 0; }
body.mobile .dialog .cols { flex-direction: column; flex-wrap: nowrap; gap: 0; }
body.mobile .dialog .cols > div { width: 100%; }
body.mobile .row { flex-wrap: wrap; }
body.mobile .check, body.mobile .radio { min-width: 0; }
body.mobile .check > .t, body.mobile .radio > .t { flex: 1; min-width: 0; }
body.mobile #menubar.sheet .menu li:not(.sep) { white-space: normal; height: auto; min-height: calc(18 * var(--u)); padding-block: calc(2 * var(--u)); }
body.mobile #menubar.sheet .menu li .key { display: none; }
body.mobile .links .sub { margin-left: calc(4 * var(--u)); }
body.mobile .popup-list { max-width: calc(100vw - 8px); }
body.mobile .popup-list li { white-space: normal; height: auto; min-height: calc(16 * var(--u)); }
body.mobile .popup { max-width: 100%; height: auto; min-height: calc(12 * var(--u)); }
body.mobile .titlebar .name { min-width: 0; overflow: hidden; }

/* Phones: a dialog is the whole screen's business. A dithered backdrop over
   the page, the dialog full-width below the menu bar, its buttons pinned to
   the bottom as it scrolls, and everything big enough for a finger. */
body.mobile .modal {
  align-items: flex-start; padding: calc(13 * var(--u) + env(safe-area-inset-top, 0px)) 0 0;
  background: repeating-linear-gradient(90deg, #000 0 var(--u), #fff var(--u) calc(2 * var(--u)));
}
body.mobile .dialog {
  width: 100%; max-height: calc(100dvh - 14 * var(--u) - env(safe-area-inset-top, 0px));
  padding: var(--u); border-left: 0; border-right: 0; overscroll-behavior: contain;
}
body.mobile .dialog > .inner { margin: var(--u); padding: calc(4 * var(--u)) calc(5 * var(--u)) 0; border-width: calc(2 * var(--u)); outline-offset: var(--u); }
body.mobile .dialog .buttons {
  position: sticky; bottom: calc(-1 * var(--u)); z-index: 1; background: #fff; flex-wrap: wrap;
  margin: calc(6 * var(--u)) calc(-5 * var(--u)) 0; padding: calc(4 * var(--u)) calc(5 * var(--u));
  border-top: var(--u) solid #000;
}
body.mobile .dialog .btn { height: calc(18 * var(--u)); }
body.mobile .check, body.mobile .radio { min-height: calc(16 * var(--u)); }
body.mobile .check .box, body.mobile .radio .box { width: calc(11 * var(--u)); height: calc(11 * var(--u)); }
body.mobile input[type=range] { flex: 1 1 100%; min-width: 0; width: 100%; height: calc(14 * var(--u)); }
body.mobile .list { max-height: 30vh; }
body.mobile .list > div { min-height: calc(16 * var(--u)); }
body.mobile input[type=text] { font-size: 16px; }

/* Phone-only items (the tutorial) aren't on the desktop's menus. */
body:not(.mobile) .phone-only { display: none !important; }

/* A form in a window (Pythia Settings): moves and resizes; scrolls when small. */
.wform { display: flex; flex-direction: column; }
.wform > .titlebar { flex: none; }
.wform > .wbody { flex: 1 1 auto; min-height: 0; overflow: auto; }
.wform .inner { padding: calc(6 * var(--u)) calc(10 * var(--u)); }

/* Getting Started: floats (.float) over the other windows, under the menus
   and dialogs, and never takes the machine's front; so it keeps the
   front window's title bar and close box itself. */
#win-coach { width: calc(170 * var(--u)); z-index: 90 !important; }
.window.float .titlebar { background: repeating-linear-gradient(#fff 0 var(--u), #000 var(--u) calc(2 * var(--u))) content-box; }
.window.float .titlebar .close { visibility: visible; }
#coach-ticks { margin-top: calc(4 * var(--u)); }
#win-coach [hidden] { display: none; }
#win-coach .buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: calc(8 * var(--u)); margin-top: calc(6 * var(--u)); }
#win-coach .buttons .spacer { margin-right: auto; }
#win-coach .btn { white-space: nowrap; }
.coach-point { outline: calc(2 * var(--u)) solid #000; outline-offset: var(--u); animation: coach-pulse 1s steps(2) infinite; }
@keyframes coach-pulse { 50% { outline-color: transparent; } }

/* The Disk Library: the URL, a status line, then a shelf of disks. */
#win-library { width: calc(240 * var(--u)); height: calc(250 * var(--u)); }
#library-status { margin: calc(3 * var(--u)) 0; }
#win-library .row .field { flex: 1 1 auto; margin: 0; }
#win-library .shelf { margin: calc(4 * var(--u)) 0; }
#win-library .disk { border-top: var(--u) dotted #000; padding: calc(4 * var(--u)) 0; }
#win-library .disk p { margin: 0 0 calc(2 * var(--u)); }
#win-library .disk .row { flex-wrap: wrap; }
body.mobile #win-library { width: auto; height: auto; }

/* Activity lights (crate::leds): a lit lamp bright in its colour, a dark
   one dim (the core's colours, as the desktop's); the floppy icons' lamp is
   there while a disk is in. */
.icon svg .disk-led { fill: none; stroke: none; }
.icon:not(.empty) svg .disk-led { fill: #000; stroke: #000; }
.icon.lit525 svg .disk-led { fill: #ff3020; }
.icon.lit35 svg .disk-led { fill: #40ff40; }
.icon.lit svg .hd-led { fill: #40ff40; }
.led { display: inline-block; width: calc(12 * var(--u)); height: calc(8 * var(--u)); border: var(--u) solid #000; background: #fff; vertical-align: middle; margin-right: calc(2 * var(--u)); }
.led.lit { background: #40ff40; }
.lamps { display: flex; gap: calc(4 * var(--u)); align-items: center; margin-left: auto; }
.lamps:empty { display: none; }
.lamps .lamp { display: flex; align-items: center; }
.infobar > .t { min-width: 0; overflow: hidden; }
.infobar > .lamps { flex: none; }

/* The manual: a HyperCard stack. Chrome in the pixel font; a card's text
   is real text, so it selects, finds and reads aloud. Black on white,
   card ruled off from the navigation bar below it, as HyperCard's was. */
#win-manual { display: flex; flex-direction: column; width: min(calc(330 * var(--u)), calc(100vw - 16px)); height: min(calc(250 * var(--u)), calc(100vh - 60px)); }
#win-manual > * { flex: none; }
#win-manual > .mcard {
  flex: 1 1 0; min-height: 0; overflow: auto; outline: none;
  padding: calc(6 * var(--u)) calc(10 * var(--u)); user-select: text; -webkit-user-select: text; cursor: auto;
  font: 15px/1.45 -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.mcard h2 { margin: 0 0 calc(5 * var(--u)); padding-bottom: calc(3 * var(--u)); border-bottom: var(--u) solid #000; font-size: inherit; }
.mcard h3 { font-size: inherit; margin: calc(5 * var(--u)) 0 calc(2 * var(--u)); }
.mcard p, .mcard ul, .mcard ol { margin: 0 0 calc(4 * var(--u)); }
.mcard ul, .mcard ol { padding-left: calc(10 * var(--u)); }
.mcard li { margin-bottom: var(--u); }
.mcard code, .mcard pre { font: 13px/1.35 ui-monospace, Menlo, Monaco, "Courier New", monospace; }
.mcard :not(pre) > code { padding: 0 2px; border: 1px dotted #000; }
.mcard pre { margin: 0 0 calc(3 * var(--u)); padding: calc(3 * var(--u)) calc(4 * var(--u)); border: var(--u) solid #000; white-space: pre-wrap; overflow-wrap: anywhere; }
/* A wrapped line continues 2 columns in: off the 4-space grid, so it reads as a continuation, not a nested line. */
.mcard pre .ln { display: block; padding-left: 2ch; text-indent: -2ch; }
.mcard pre.python { box-shadow: var(--u) var(--u) 0 #000; }
.mcard pre.text { background: #000; color: #fff; }
.mcard .codewrap { margin-bottom: calc(4 * var(--u)); }
/* A card's buttons are the page's buttons: the card's 15px/1.45 type
   mustn't reach them (at --u 1.5 its line box is taller than a button). */
.mcard .btn { font: 14px monospace; line-height: normal; }
.mcard .typeit { display: flex; align-items: center; gap: calc(4 * var(--u)); margin-top: calc(2 * var(--u)); }
.mcard .typeit .said { font-size: 13px; }
.mcard aside { margin: 0 0 calc(4 * var(--u)); padding: calc(3 * var(--u)) calc(5 * var(--u)); border: var(--u) solid #000; border-left-width: calc(4 * var(--u)); }
.mcard .tablewrap { overflow-x: auto; margin-bottom: calc(4 * var(--u)); }
.mcard table { border-collapse: collapse; font-size: 14px; }
.mcard th, .mcard td { border: 1px solid #000; padding: 2px 6px; text-align: left; vertical-align: top; }
.mcard th { background: #000; color: #fff; }
.mcard a { color: #000; text-decoration: none; border-bottom: var(--u) dotted #000; }
.mcard a:hover, .mcard a:focus-visible { background: #000; color: #fff; outline: none; }
.mcard a:hover code { color: #fff; border-color: #fff; }
.mcard .lede { margin-bottom: calc(6 * var(--u)); }
.mcard .stacks { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(120 * var(--u)), 1fr)); gap: calc(6 * var(--u)); }
.mcard .stackicon { display: grid; grid-template-columns: calc(24 * var(--u)) 1fr; grid-template-rows: auto auto; column-gap: calc(4 * var(--u)); text-align: left; align-items: start; padding: calc(2 * var(--u)); }
.mcard .stackicon svg { grid-row: span 2; width: calc(24 * var(--u)); height: calc(24 * var(--u)); }
.mcard .stackicon .blurb { font-size: 13px; line-height: 1.3; }
.mcard .stackicon:hover svg, .mcard .stackicon:focus-visible svg { filter: invert(1); }
.mcard .stackicon:focus-visible { outline: var(--u) dotted #000; }
.mcard .hits .where { font-size: 13px; }
.mcard .hits .snip { font-size: 13px; opacity: .75; }
.mbar { display: flex; align-items: center; gap: calc(3 * var(--u)); padding: calc(3 * var(--u)) calc(14 * var(--u)) calc(3 * var(--u)) calc(4 * var(--u)); border-top: calc(2 * var(--u)) solid #000; }
.mbar .btn { min-width: 0; }
.mbar .btn.arrow { width: calc(20 * var(--u)); }
.mbar .btn:disabled { opacity: .35; }
.mbar .where { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-align: center; }
.mbar input { width: calc(52 * var(--u)); height: calc(13 * var(--u)); font: 13px monospace; border: var(--u) solid #000; border-radius: 0; padding: 0 calc(3 * var(--u)); background: #fff; user-select: text; }
body.mobile #win-manual { width: auto; height: calc(100dvh - 40px); }
body.mobile .mbar { flex-wrap: wrap; padding-right: calc(4 * var(--u)); }
body.mobile .mbar input { font-size: 16px; flex: 1 1 calc(60 * var(--u)); }
@media print { #menubar, .icons, .mbar, .window:not(#win-manual) { display: none !important; } }
