:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --text: #1c1c1c;
  --muted: #5c5c5c;
  --accent: #0b57d0;
  --border: #c9c9c4;
  --screen-bg: #000;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2a2b2d;
    --panel: #323335;
    --text: #d4d5d7;
    --muted: #9b9ca1;
    --accent: #4aa6f0;
    --border: #1a1a1b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, sans-serif;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 18px; }
h2 { margin: 0 0 8px; font-size: 15px; }
h3 { margin: 0; font-size: 13px; color: var(--muted); }

.controls, .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

button:focus-visible, .button:focus-within, select:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.screen-wrap { min-width: 0; position: relative; }
#selection {
  position: absolute;
  pointer-events: none;
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  border: 1px solid var(--accent);
}
#selection[hidden] { display: none; }

.zoom { display: inline-flex; align-items: stretch; }
.zoom-label { min-width: 6.5ch; font-variant-numeric: tabular-nums; }

.screen-wrap { overflow: auto; }

/* The size is set by js/zoom.js; this is the size before it runs. */
canvas {
  display: block;
  margin: 0 auto;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--screen-bg);
  image-rendering: pixelated;
  border: 1px solid var(--border);
  border-radius: 4px;
}

canvas[hidden] { display: none; }
canvas.captured { outline: 2px solid var(--accent); }
canvas:fullscreen { margin: auto; object-fit: fill; border: 0; border-radius: 0; }  /* the size is set by js/zoom.js, in the shape of the monitor */

.hint, .status, .info { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.status { min-height: 1.4em; }
.paste-layout { display: block; }
.paste-layout select { margin-left: 4px; font-size: 12px; padding: 2px 24px 2px 6px; }
.status.error { color: #c5221f; }

.side { display: grid; gap: 16px; min-width: 0; }

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.disk .row + .row { margin-top: 6px; }
.disk.drop-target { outline: 2px dashed var(--accent); outline-offset: 4px; }
.report { margin-top: 6px; font-size: 13px; }
.report summary { cursor: pointer; color: var(--muted); }
.report pre { margin: 6px 0 0; max-height: 14em; overflow: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.disk + .disk { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.info { font-family: var(--mono); font-size: 12px; margin-bottom: 6px; overflow-wrap: anywhere; }

/* The Disks title folds the panel to one line of drive lights and letters (app.js setupDisksFold). */
.fold, .fold:hover:not(:disabled), .fold:active:not(:disabled) {
  background: none; border: 0; box-shadow: none; padding: 0; color: var(--text); text-shadow: none; text-transform: none;
  letter-spacing: 0; font-size: inherit; font-weight: inherit;
}
.fold::after { content: " \25BE"; color: var(--muted); }
.fold[aria-expanded="false"]::after { content: " \25B8"; }
.fold:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.disks.folded { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.disks.folded h2 { margin: 0 6px 0 0; }
.disks.folded > :not(h2, .disk), .disks.folded .disk > :not(.drive), .disks.folded .actions, .disks.folded .drive-kind { display: none; }
.disks.folded .disk + .disk { margin: 0; padding: 0; border: 0; }

/* The disks area: one compact row per drive (its light, name and buttons; Add and the notes fold away), the image below. */
.drive { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.drive h3 { color: var(--text); display: inline-flex; align-items: center; gap: 7px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.disk .info { margin: 4px 0 0; color: var(--muted); }
.info .image-name { color: var(--accent); font-weight: 700; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " \25BE"; }
.menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-body {
  position: absolute; z-index: 5; left: 0; top: calc(100% + 4px); min-width: 200px; display: grid; gap: 6px; padding: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.2);
}
.disk .button, .disk .actions button, .disk .menu-body button, .disk .menu > summary { padding: 3px 8px; }
.disk .menu-body select { font-size: 12px; padding: 3px 8px; }
.disk [data-dest] { flex: 1 1 7em; min-width: 0; font-size: 12.5px; }
.menu-body .button, .menu-body button, .menu-body select, .menu-body input[type="text"] { width: 100%; box-sizing: border-box; text-align: left; }
.menu-body [hidden] { display: none; }
.menu-body.opens-left { left: auto; right: 0; }            /* app.js placeMenu: no room to the right of the button */
/* the notes of a drive: shown while the pointer is on the "?" or it has the keyboard focus */
.tip-wrap { position: relative; }
.disk .actions .tip-button { padding: 3px 8px; font-weight: 700; }
.tip {
  display: none; position: absolute; z-index: 6; right: 0; top: calc(100% + 4px); width: min(300px, 80vw); padding: 4px 10px 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.2);
}
.tip-wrap:hover .tip, .tip-button:focus-visible + .tip { display: block; }
.tip .hint { margin: 6px 0 0; }
.tip [hidden] { display: none; }
.disk label.hint:not([hidden]) { display: block; margin-top: 6px; }
.make-new { margin: 12px 0 0; }
.slot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.slot[hidden] { display: none; }
.slot label { color: var(--muted); font-size: 13px; }
.slot + .disk { margin-top: 10px; }
.hint a { color: var(--accent); }

#debugger { font-family: var(--mono); font-size: 12px; }
#debugger pre { margin: 6px 0; white-space: pre; overflow-x: auto; }
#debugger input[type="text"] {
  font: inherit; width: 9ch; padding: 2px 4px;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
}

@media (max-width: 820px) {
  main { grid-template-columns: minmax(0, 1fr); padding: 16px; }
}

/* A window wide enough for two columns: the page is the height of the window and does not scroll; the screen fits its column
 * (js/zoom.js) and the right column scrolls by itself only when its panels are taller than the window. */
@media (min-width: 821px) {
  body { height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
  main { min-height: 0; align-items: stretch; }
  .screen-wrap { min-height: 0; }
  .side { min-height: 0; overflow: auto; align-content: start; }
}

.pc .devices, .pc .tools { margin-bottom: 4px; }
.pc .tools { display: flex; width: fit-content; margin-top: 4px; }
