/* The page's look (contract §4.1): the site's palette (§4.1.1) and the board's tokens (§4.1.2) as custom properties,
   the one place a colour is written. The canvas reads them back from here; nothing in the code spells a colour. */
:root {
  --color_space_bg: #05070E;
  --color_panel_bg: rgba(13, 20, 32, 0.86);
  --color_menu_bg: rgb(13, 20, 32); /* the menus' own: the panel colour at alpha 1, so nothing of the board shows through the items (M0-D112) */
  --color_hud_text: #DCE6F2;
  --color_hud_dim: #7A889C;
  --color_accent: #FFC857;
  --color_warning: #FF6B6B;

  --font: system-ui, sans-serif;
  --font_size_secondary: 14px;
  --font_size_body: 16px;
  --font_size_heading: 18px;
  --radius: 8px;
  --spacing: 8px;

  --board_bg: #0A0F1A;
  --grid_dot: #1B2433;
  --grid_major: #243044;
  --part_stroke: var(--color_hud_text);
  --wire: #8A96A8;
  --selection: var(--color_accent);
  --burnt: #5A5048;
  --logic_0: #4A5A70;
  --logic_1: #6EE7A0;
  --logic_u: #FFC857;
  --battery_step: #5AC8FA;
  --clickable: #B79CFF; /* the moving piece of a part a click operates, and the legend's « Click to operate » bar (§4.1.2, M0-T219) */
  --shaft: #C0C6CC; /* the steel of an axle and the discs on it, a shaft net's wire never a wire's grey (§4.1.2, M0-T225) */
  --scope_bg: #070B12;
  --graticule: #1F2A3A;
  --trace_1: #FFC857;
  --trace_2: #5AC8FA;
  --trace_3: #FF7AD9;
  --trace_4: #6EE7A0;
  --dot: #FFE08A;
  --scroll_thumb: var(--color_hud_dim); /* the one thin bar every scrolling box wears (M0-D167) */
  --scroll_track: transparent;
  color-scheme: dark; /* the browser's own controls and bars take the dark theme where a rule below does not reach them */
}

/* ---- The shell (contract §4.2): a grid of a 48 px top bar, the parts palette (232 px), the board over its 36 px status bar,
   the right panel (320 px) and the instruments (240 px, collapsible). A side panel collapses to a 32 px strip; the page
   opens with both collapsed under 1280 px wide (shell.ts sets data-palette / data-side). Colours only through the tokens above. */
:root {
  --bar_h: 48px;
  --status_h: 36px;
  --palette_w: 232px;
  --side_w: 320px;
  --strip_w: 32px;
  --instruments_h: 240px;
  --tabs_h: 36px;
  --hairline: 1px solid var(--grid_major);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--color_space_bg);
  color: var(--color_hud_text);
  font: var(--font_size_body) var(--font);
}

body {
  display: grid;
  grid-template-columns: var(--palette_w) minmax(0, 1fr) var(--side_w);
  grid-template-rows: var(--bar_h) minmax(0, 1fr) var(--status_h) var(--instruments_h);
  grid-template-areas:
    "topbar topbar topbar"
    "palette board side"
    "palette status side"
    "instruments instruments instruments";
}

body[data-palette="collapsed"] { grid-template-columns: var(--strip_w) minmax(0, 1fr) var(--side_w); }
body[data-side="collapsed"] { grid-template-columns: var(--palette_w) minmax(0, 1fr) var(--strip_w); }
body[data-palette="collapsed"][data-side="collapsed"] { grid-template-columns: var(--strip_w) minmax(0, 1fr) var(--strip_w); }
body[data-instruments="collapsed"] { grid-template-rows: var(--bar_h) minmax(0, 1fr) var(--status_h) var(--tabs_h); }

button, input {
  font: inherit;
  color: inherit;
}

button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 var(--spacing);
  min-height: calc(4 * var(--spacing));
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) { background: color-mix(in srgb, var(--color_hud_text) 10%, transparent); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--color_accent); outline-offset: 1px; }
button:disabled { color: var(--color_hud_dim); cursor: default; }
button[aria-pressed="true"], button[aria-selected="true"] {
  color: var(--color_accent);
  border-color: var(--color_accent);
}

h1, h2 { margin: 0; font-size: var(--font_size_heading); font-weight: 600; white-space: nowrap; }

/* top bar */
#topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--spacing);
  padding: 0 var(--spacing);
  background: var(--color_panel_bg);
  border-bottom: var(--hairline);
  min-width: 0;
  overflow: hidden;
}
#menus { display: flex; gap: 0; flex: 1 1 auto; min-width: 0; }
#menus button { font-size: var(--font_size_secondary); }
#menus button[aria-expanded="true"] { background: color-mix(in srgb, var(--color_hud_text) 10%, transparent); }
#lang { display: flex; gap: var(--spacing); flex: none; }
#lang button { font-size: var(--font_size_secondary); }
#sound { display: flex; align-items: center; gap: var(--spacing); flex: none; }
#sound_volume { width: 88px; accent-color: var(--color_accent); }

/* side panels */
#palette, #side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--color_panel_bg);
  overflow: hidden;
}
#palette { grid-area: palette; border-right: var(--hairline); }
#side { grid-area: side; border-left: var(--hairline); }

.panel_head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing);
  padding: 0 var(--spacing);
  height: var(--tabs_h);
  flex: none;
  border-bottom: var(--hairline);
  min-width: 0;
}
.edge_toggle { flex: none; padding: 0; min-width: calc(3 * var(--spacing)); color: var(--color_hud_dim); }

#palette_body, #side_body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--spacing); }
/* The palette's body does not scroll: its list does (M0-T217), so Deselect and the search box above it stay in sight. */
#palette_body { display: flex; flex-direction: column; gap: var(--spacing); overflow: hidden; }
#palette_deselect {
  flex: none;
  width: 100%;
  min-height: calc(4 * var(--spacing));
  font-size: var(--font_size_secondary);
  border: 1px solid var(--grid_major);
  border-radius: var(--radius);
}
#palette_deselect:not(:disabled) { border-color: var(--selection); color: var(--color_hud_text); }
#palette_search {
  box-sizing: border-box;
  width: 100%;
  padding: 0 var(--spacing);
  min-height: calc(4 * var(--spacing));
  font-size: var(--font_size_secondary);
  background: var(--board_bg);
  border: 1px solid var(--grid_major);
  border-radius: var(--radius);
}
#palette_search { flex: none; }
#palette_groups { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* The parts palette (M0-T138, contract §4.6.2): a group is a fold, a row a symbol over the board's own drawing and its name. */
.palette_none { margin: 0; padding: calc(var(--spacing) / 2) 0; font-size: var(--font_size_secondary); color: var(--color_hud_dim); overflow-wrap: anywhere; }
.palette_group { margin-bottom: var(--spacing); }
.palette_group[hidden], .palette_list li[hidden] { display: none; }
.palette_group_title {
  cursor: pointer;
  padding: calc(var(--spacing) / 2) 0;
  font-size: var(--font_size_secondary);
  color: var(--color_hud_dim);
}
.palette_list { list-style: none; margin: 0; padding: 0; }
.palette_item {
  display: flex;
  align-items: center;
  gap: var(--spacing);
  width: 100%;
  padding: 2px calc(var(--spacing) / 2);
  text-align: left;
  font-size: var(--font_size_secondary);
  white-space: normal;
  cursor: pointer;
  border: 1px solid transparent;
}
/* The picked row (M0-T217): the selection's colour, as the board draws a selected part. */
.palette_item[aria-pressed="true"] { border-color: var(--selection); color: var(--selection); }
/* A kind picked: each click on the board places one. */
#board[data-pick] { cursor: crosshair; }
/* The pointer over the body of a part a click operates (M0-T220): set by the input only while nothing is picked, the label tool is off and no pin is under it. */
#board[data-hand] { cursor: pointer; }
.palette_symbol { flex: none; }
.palette_name { min-width: 0; overflow-wrap: anywhere; }

body[data-palette="collapsed"] #palette .panel_head { justify-content: center; padding: 0; }
body[data-palette="collapsed"] #palette_title,
body[data-palette="collapsed"] #palette_body { display: none; }
body[data-side="collapsed"] #side .panel_head { justify-content: center; padding: 0; }
body[data-side="collapsed"] #side_tabs,
body[data-side="collapsed"] #side_body { display: none; }

[role="tablist"] { display: flex; gap: var(--spacing); min-width: 0; }
[role="tab"] { font-size: var(--font_size_secondary); }
[role="tabpanel"][hidden] { display: none; }

/* the board and its status bar */
#board_area { grid-area: board; position: relative; min-width: 0; min-height: 0; overflow: hidden; }

#board {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--board_bg);
}

/* The legend's fold (M0-D171, §4.1.3): open, a small « − » the page places at the legend's top left (main.ts `placeLegendFold`);
   folded, a chip at the legend's corner, bottom left (12 px, the legend's margin), with the voltage scale's colours and its word. */
#legend_fold {
  position: absolute;
  z-index: 2;
  min-height: 0;
  padding: 0;
  font-size: var(--font_size_secondary);
  line-height: 1;
  color: var(--color_hud_dim);
}
#legend_fold[hidden] { display: none; }
#legend_fold[data-legend="open"] {
  width: 18px;
  height: 18px;
  border-radius: calc(var(--radius) / 2);
  font-size: var(--font_size_heading);
  font-weight: 600;
}
#legend_fold[data-legend="open"]:hover { color: var(--color_hud_text); }
#legend_fold[data-legend="folded"] {
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 var(--spacing);
  border: 1px solid var(--color_hud_dim);
  background: var(--color_panel_bg);
  color: var(--color_hud_text);
}
#legend_fold[data-legend="folded"]::before {
  content: "";
  flex: none;
  width: 18px;
  height: 6px;
  border-radius: 1px;
  /* the voltage scale's three anchors (§4.1.3), then the click colour */
  background: linear-gradient(90deg, #FF7AD9, var(--wire), #6EE7A0 75%, var(--clickable) 75%);
}

/* The board's top (M0-D159): the block bar, the failed start's banner and the banners' stack share one column, so none is painted over another. */
#board_top {
  position: absolute;
  top: var(--spacing);
  left: var(--spacing);
  right: var(--spacing);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing);
  pointer-events: none;
}

#board_top > #banner,
#board_top > #block_bar {
  pointer-events: auto;
}

#banner {
  max-width: 100%;
  padding: var(--spacing) calc(2 * var(--spacing));
  border-radius: var(--radius);
  background: var(--color_panel_bg);
  color: var(--color_warning);
  font-size: var(--font_size_body);
}

#banner[hidden] {
  display: none;
}

/* The hover probe's tooltip (§4.4, M0-D123): near the pointer, over the board, never in its way. */
#hover_tip {
  position: absolute;
  z-index: 3;
  max-width: calc(100% - 2 * var(--spacing));
  padding: calc(var(--spacing) / 2) var(--spacing);
  border-radius: var(--radius);
  background: var(--color_panel_bg);
  color: var(--color_hud_text);
  font-size: var(--font_size_secondary);
  white-space: nowrap;
  pointer-events: none;
}

#hover_tip[hidden] {
  display: none;
}

/* The banners across the board's top (M0-T133): one row each, the warning colour for a refusal or a stall, the dim one for a hint. */
#banners {
  display: flex;
  flex-direction: column;
  gap: var(--spacing);
  align-items: center;
  max-width: 100%;
  pointer-events: none;
}

#banners[hidden] {
  display: none;
}

.banner_row {
  padding: var(--spacing) calc(2 * var(--spacing));
  border-radius: var(--radius);
  background: var(--color_panel_bg);
  color: var(--color_warning);
  font-size: var(--font_size_body);
  text-align: center;
}

/* A row with a ✕ (the sound hint, M0-D111): the text, then the button; the stack ignores the pointer, the button does not. */
.banner_row:has(.banner_close) {
  display: flex;
  align-items: center;
  gap: var(--spacing);
}

.banner_close {
  pointer-events: auto;
  flex: none;
  padding: 0 var(--spacing);
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.banner_close:hover,
.banner_close:focus-visible {
  color: var(--color_warning);
}

.banner_row[data-banner="supply"],
.banner_row[data-banner="island"],
.banner_row[data-banner="decoder"],
.banner_row[data-banner="sound"] {
  color: var(--color_hud_text);
}

#statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: var(--spacing);
  padding: 0 var(--spacing);
  min-width: 0;
  overflow: hidden;
  font-size: var(--font_size_secondary);
  background: var(--color_panel_bg);
  border-top: var(--hairline);
}
#statusbar > * { flex: none; }
#status_time { font-variant-numeric: tabular-nums; flex: none; white-space: nowrap; }
/* Reset, Run / Pause and Step are signs (§0.5a TJ6, M0-D170), one width in both languages: each drawn in its button's colour through a mask,
   so hover, the focus ring and Step's dim while running stay the buttons' own; its word is its title and its aria-label (status.ts) */
#statusbar .sign { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; }
#statusbar .sign::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--sign) center / contain no-repeat; mask: var(--sign) center / contain no-repeat; }
#run_reset { --sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8A4.5 4.5 0 1 0 5.75 4.1' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='M4.65 2.2L3.5 5.4L6.85 6Z'/%3E%3C/svg%3E"); }
#run_toggle[data-sign="play"] { --sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5 3L12.5 8L5 13Z'/%3E%3C/svg%3E"); }
#run_toggle[data-sign="pause"] { --sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 3.5h2.5v9h-2.5zM9 3.5h2.5v9H9z'/%3E%3C/svg%3E"); }
#run_step { --sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 3L10 8L3.5 13Z'/%3E%3Cpath d='M10.5 3.5h2v9h-2z'/%3E%3C/svg%3E"); }
/* the knob never shrinks under its own content (M0-D170: in French at 1024 its ▶ and « ×1 » lay over the notice): its floor is ◀, the track's 32 px, ▶ and the speed */
#speed { display: flex; align-items: center; gap: 0; flex: 0 20 auto; }
#speed .knob_step { color: var(--color_hud_dim); }
#speed_track { position: relative; display: flex; align-items: center; flex: 0 20 auto; min-width: 32px; }
/* « ×1 » marked on the track: a tick where real time sits (--real, set by status.ts), half a thumb in from each end */
#speed_track::after {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: calc(8px + (100% - 16px) * var(--real, 0.5));
  width: 1px;
  background: var(--color_hud_dim);
  pointer-events: none;
}
/* the slider gives its width back first (M0-D113): a narrow bar keeps the slow-run notice whole, the knob's ◀ ▶ and « ×1 » never shrink.
   Its width is a percentage capped at 72px (M0-D170): a range input's percentage counts as zero in the knob's floor, the cap is its wish */
#speed_slider { flex: 1 1 auto; width: 100%; max-width: 72px; min-width: 0; margin: 0; accent-color: var(--color_accent); }
#speed_value { min-width: 4ch; color: var(--color_accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* the notice keeps 104px (M0-D113: « tourne à ×0,31 / (demandé ×1) » on two lines in the French bar at 1280 px, one line where the bar is wider) and takes the rest; two lines at most, the figure first */
#status_running { flex: 1 0 104px; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; line-height: 16px; color: var(--color_hud_dim); }
#status_running[data-slow="true"] { color: var(--color_warning); }
#status_warnings[data-count="0"] { color: var(--color_hud_dim); }
#status_warnings:not([data-count="0"]) { color: var(--color_warning); }
#status_warnings[aria-disabled="true"] { cursor: default; }

/* the warnings list (contract §4.2): a click on the count opens it over the bar's right end, in a layer of its own */
.warn_panel {
  position: fixed;
  z-index: 30;
  box-sizing: border-box;
  width: min(420px, calc(100vw - 2 * var(--spacing)));
  max-height: 50vh;
  overflow: auto;
  padding: var(--spacing);
  background: var(--color_panel_bg);
  border: var(--hairline);
  border-radius: var(--radius);
  font-size: var(--font_size_secondary);
}
.warn_panel[hidden] { display: none; }
.warn_panel ul { margin: 0; padding: 0; list-style: none; }
.warn_panel li { display: flex; gap: calc(2 * var(--spacing)); padding: var(--spacing) calc(2 * var(--spacing)); }
.warn_panel li + li { border-top: 1px solid var(--grid_major); }
.warn_panel strong { flex: none; min-width: 3ch; color: var(--color_warning); }

/* instruments */
#instruments {
  grid-area: instruments;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--color_panel_bg);
  border-top: var(--hairline);
  overflow: hidden;
}
#instruments_body { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--scope_bg); }
body[data-instruments="collapsed"] #instruments_body { display: none; }

/* every box that scrolls wears one thin bar in the theme's colours, never the browser's light default (M0-D167) */
.menu_panel, .warn_panel, #palette_groups, #side_body, #instruments_body, .dialog_body, .scope_settings, .scope_traces {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll_thumb) var(--scroll_track);
}

/* the menus (contract §4.2, §4.6.1): drop-downs in a layer of their own, fixed under the top bar; an item with no action yet is dim.
   A panel never passes the window's bottom: menus.ts sets its max-height from the room under its button, and it scrolls inside (M0-D167). */
.menu_panel {
  position: fixed;
  z-index: 30;
  box-sizing: border-box;
  min-width: 232px;
  max-width: calc(100vw - 2 * var(--spacing));
  padding: var(--spacing);
  background: var(--color_menu_bg);
  border: var(--hairline);
  border-radius: var(--radius);
  outline: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu_panel[hidden] { display: none; }
.menu_item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(3 * var(--spacing));
  box-sizing: border-box;
  width: 100%;
  padding: var(--spacing) calc(2 * var(--spacing));
  border-radius: var(--radius);
  font-size: var(--font_size_secondary);
  text-align: left;
}
.menu_item:focus { background: color-mix(in srgb, var(--color_hud_text) 10%, transparent); }
.menu_item[aria-disabled="true"] { color: var(--color_hud_dim); cursor: default; }
.menu_item[aria-disabled="true"]:hover { background: transparent; }
.menu_item[aria-disabled="true"]:focus { background: color-mix(in srgb, var(--color_hud_text) 6%, transparent); }
.menu_item[aria-checked="true"] .menu_label::before { content: "✓ "; color: var(--color_accent); }
.menu_keys { color: var(--color_hud_dim); font-variant-numeric: tabular-nums; }
.menu_rule { height: 1px; margin: var(--spacing) 0; background: var(--grid_major); }

/* the dialog frame (contract §4.2 Dialogs): a modal over a dimmed page, above the menus */
.dialog_backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(2 * var(--spacing));
  background: color-mix(in srgb, var(--color_space_bg) 70%, transparent);
}
.dialog {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: calc(2 * var(--spacing));
  width: min(480px, 100%);
  max-height: 100%;
  padding: calc(2 * var(--spacing));
  background: var(--color_panel_bg);
  border: var(--hairline);
  border-radius: var(--radius);
  outline: none;
}
/* a link in a dialog reads in the accent on the panel (M0-D166), with the buttons' focus ring */
.dialog a { color: var(--color_accent); }
.dialog a:focus-visible { outline: 2px solid var(--color_accent); outline-offset: 1px; }
.dialog_body { min-height: 0; overflow: auto; font-size: var(--font_size_secondary); }
.dialog_buttons { display: flex; justify-content: flex-end; gap: var(--spacing); flex: none; }
.dialog_button { border-color: var(--grid_major); }

/* the Keyboard shortcuts dialog (M0-T141, contract §4.5, §4.6.10): keys left, what they do right, the Mac note under */
.kb_table { width: 100%; border-collapse: collapse; }
.kb_table td { padding: calc(var(--spacing) / 2) var(--spacing); vertical-align: top; border-bottom: var(--hairline); }
.kb_keys { white-space: nowrap; color: var(--color_hud_dim); }
.kb_keys kbd { font-family: inherit; color: var(--color_hud_text); }
.kb_note { margin: var(--spacing) 0 0; color: var(--color_hud_dim); }

/* The Part tab (M0-T139, contract §4.2, §4.6.3): the part's name, a label over each control, the Ideal box, the refusal, Replace and the scope buttons. */
#pane_part { display: flex; flex-direction: column; gap: var(--spacing); }
#pane_part[hidden] { display: none; }
.part_title { margin: 0; font-size: var(--font_size_heading); overflow-wrap: anywhere; }
.part_none { margin: 0; color: var(--color_hud_dim); }
.part_row { display: flex; flex-direction: column; gap: calc(var(--spacing) / 2); }
.part_row_check { flex-direction: row; align-items: center; gap: var(--spacing); }
.part_label { color: var(--color_hud_dim); font-size: var(--font_size_secondary); }
.part_control {
  box-sizing: border-box;
  width: 100%;
  min-height: calc(4 * var(--spacing));
  padding: 0 var(--spacing);
  color: var(--color_hud_text);
  background: var(--board_bg);
  border: 1px solid var(--grid_major);
  border-radius: var(--radius);
  font: inherit;
}
.part_check { accent-color: var(--color_accent); }
.part_error { margin: 0; color: var(--color_warning); font-size: var(--font_size_secondary); overflow-wrap: anywhere; }
.part_error[hidden], .part_button[hidden] { display: none; }
.part_button { align-self: flex-start; }
.part_file_input[hidden] { display: none; }
.part_row[hidden] { display: none; } /* the audio input's file, Loop and device rows, shown by its source (M0-T198) */
.part_file_name { color: var(--color_hud_dim); font-size: var(--font_size_secondary); overflow-wrap: anywhere; }
.part_scope { display: flex; flex-direction: column; align-items: flex-start; gap: calc(var(--spacing) / 2); }

/* The scope panel (M0-T144, contract §4.4, §4.1.2): the graticule on the left, the controls on the right, in the instruments' body */
.scope_pane { display: flex; height: 100%; min-height: 0; }
.scope_pane[hidden] { display: none; }
.scope_stage { flex: 1 1 auto; min-width: 0; min-height: 0; position: relative; }
.scope_canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scope_controls {
  flex: none;
  box-sizing: border-box;
  width: min(460px, 45%);
  padding: var(--spacing);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: calc(2 * var(--spacing));
  border-left: var(--hairline);
  font-size: var(--font_size_secondary);
  overflow: hidden;
}
.scope_settings { display: flex; flex-direction: column; gap: var(--spacing); min-width: 0; overflow: auto; }
.scope_row { display: flex; align-items: center; gap: var(--spacing); }
/* a label wraps inside its column and is never cut (M0-D169): it shrinks before the control beside it, its longest word its least width */
.scope_label { color: var(--color_hud_dim); flex: 0 4 auto; min-width: min-content; }
.scope_value { flex: 1 1 auto; text-align: center; font-variant-numeric: tabular-nums; }
.scope_step { min-width: calc(4 * var(--spacing)); }
/* the trigger's level and « 50 % » share a row (M0-D172): the level's label and field take the room, the button keeps its one line */
.scope_row > .scope_row { flex: 1 1 auto; min-width: 0; }
.scope_fifty { flex: none; white-space: nowrap; }
.scope_control {
  box-sizing: border-box;
  min-width: 0;
  flex: 1 1 auto;
  min-height: calc(3.5 * var(--spacing));
  padding: 0 var(--spacing);
  color: var(--color_hud_text);
  background: var(--board_bg);
  border: 1px solid var(--grid_major);
  border-radius: var(--radius);
  font: inherit;
}
/* the output pickers are one height: the one that ends the column keeps its own, never stretched to the column's */
.scope_traces > .scope_control { flex: none; }
.scope_trigger { display: flex; flex-direction: column; gap: calc(var(--spacing) / 2); }
.scope_traces { display: flex; flex-direction: column; gap: var(--spacing); min-width: 0; overflow: auto; }
.scope_trace { display: flex; flex-direction: column; gap: calc(var(--spacing) / 2); padding-left: var(--spacing); border-left: 3px solid var(--grid_major); }
.scope_name { flex: 1 1 auto; overflow-wrap: anywhere; }
.scope_notice { margin: 0; color: var(--color_warning); }
.scope_notice:empty { display: none; }

/* The sweep graph's panel (M0-T145, contract §1.5, §4.4): the same two columns as the scope; the plot's canvas, the input and its range, the outputs and their picker */
.sweep_check { flex: none; margin: 0; }
.sweep_number { flex: 1 1 0; width: 0; }
.sweep_run { flex: none; min-height: calc(3.5 * var(--spacing)); padding: 0 calc(3 * var(--spacing)); }
.sweep_note { margin: 0; color: var(--color_hud_dim); }
.sweep_output { padding-left: var(--spacing); }

/* The Explain tab (M0-T148b, contract §1.8.1, §4.6.6, §4.6.7): the part's sentences (a warning in the warning colour), « Where does the current go? », the loop's drops and the power ledger. */
#pane_explain { display: flex; flex-direction: column; gap: var(--spacing); }
#pane_explain[hidden] { display: none; }
.explain_title { margin: 0; font-size: var(--font_size_heading); }
.explain_none { margin: 0; color: var(--color_hud_dim); }
.explain_part { display: flex; flex-direction: column; gap: var(--spacing); }
.explain_name { margin: 0; font-size: var(--font_size_secondary); color: var(--color_hud_dim); overflow-wrap: anywhere; }
.explain_sentences, .explain_reasons, .explain_where { display: flex; flex-direction: column; gap: calc(var(--spacing) / 2); }
.explain_sentence, .explain_reason, .explain_paths, .explain_switching, .explain_total { margin: 0; overflow-wrap: anywhere; }
.explain_sentence[data-warning="1"], .explain_reason { color: var(--color_warning); }
.explain_reason, .explain_switching, .explain_total { font-size: var(--font_size_secondary); }
.explain_where_button { align-self: flex-start; }
.explain_loop_title, .explain_ledger_title { margin: var(--spacing) 0 0; font-size: var(--font_size_secondary); color: var(--color_hud_dim); }
.explain_loop, .explain_ledger { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: calc(var(--spacing) / 4); font-size: var(--font_size_secondary); }
.explain_loop_row, .explain_ledger_row { overflow-wrap: anywhere; }
.explain_ledger_row[data-gives="1"] { color: var(--logic_1); }
.explain_part[hidden], .explain_none[hidden], .explain_where[hidden], .explain_paths[hidden], .explain_switching[hidden], .explain_loop_title[hidden], .explain_ledger_title[hidden], .explain_total[hidden] { display: none; }
/* The Example tab (M0-T153): the title, the blurb, the speed it opens at, E6's note, the Explain lines and the receipts */
.example_panel { display: flex; flex-direction: column; gap: var(--spacing); }
.example_title { margin: 0; font-size: var(--font_size_heading); }
.example_blurb, .example_explain, .example_burn_off { margin: 0; overflow-wrap: anywhere; }
.example_opened_at { margin: 0; font-size: var(--font_size_secondary); color: var(--color_hud_dim); }
.example_burn_off { color: var(--color_warning); }
.example_burn_off[hidden] { display: none; }
.receipts_title { margin: var(--spacing) 0 0; font-size: var(--font_size_secondary); color: var(--color_hud_dim); }
.receipts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: calc(var(--spacing) / 2); font-size: var(--font_size_secondary); }
.receipt { overflow-wrap: anywhere; }
.receipt[data-mark="pass"] .receipt_mark { color: var(--logic_1); }
.receipt[data-mark="fail"] { color: var(--color_warning); }
.receipt[data-mark="none"], .receipt[data-mark="shown"] { color: var(--color_hud_dim); }
/* The ready blocks' bar (§1.8.3, M0-T155b): « Open the block » for a block selected on the board, the breadcrumb `Board › 5 V supply` while one is open. */
#block_bar { align-self: flex-start; display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing); max-width: 100%; padding: calc(var(--spacing) / 2) var(--spacing); border-radius: var(--radius); background: var(--color_panel_bg); color: var(--color_hud_text); font-size: var(--font_size_secondary); }
#block_bar[hidden], #block_bar [hidden] { display: none; }
#block_crumb { display: flex; align-items: center; gap: calc(var(--spacing) / 2); }
#block_bar button { font: inherit; color: inherit; background: none; border: 1px solid var(--color_hud_dim); border-radius: var(--radius); padding: 0 var(--spacing); cursor: pointer; }
#block_blurb, #block_note { color: var(--color_hud_dim); overflow-wrap: anywhere; }
