/* Gauge Studio: a product configurator on white.
 * - The gauge is shown as the object it is: a black housing on a white table.
 * - The chrome is ink on paper. Colour on screen comes only from the gauge.
 * - Every choice is a picture of the result, drawn by the firmware.
 * - Barlow, the gauge's own family; condensed for headings.
 * - Circles are the gauge; everything else is square-edged and ruled. */

@font-face { font-family: Barlow; font-weight: 400; font-display: swap;
  src: url(fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap;
  src: url(fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap;
  src: url(fonts/barlow-semi-condensed-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap;
  src: url(fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); }

:root {
  color-scheme: light;
  --paper: #FFFFFF;
  --table: #F4F3F0;
  --ink: #111111;
  --ink-2: #2E2E2C;
  --muted: #55544F;
  --rule: #E3E2DD;
  --rule-2: #BDBBB3;
  --face: 480px;
  --font: Barlow, "Segoe UI", system-ui, sans-serif;
  --display: "Barlow Semi Condensed", Barlow, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; color: var(--rule-2); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.link {
  background: none;
  border: 0;
  padding: 6px 2px;
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-color: var(--rule-2);
  text-underline-offset: 4px;
}
.link:hover:not(:disabled) { color: var(--ink); text-decoration-color: var(--ink); }
.link:disabled { text-decoration: none; }
.solid {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 4px;
  padding: 9px 16px;
  font-weight: 500;
  white-space: nowrap;
}
.solid:hover { background: #2B2B2B; }
.plain {
  background: none;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  padding: 8px 14px;
}
.plain:hover { border-color: var(--ink); }

/* ---- Header ---- */
.bar {
  height: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; white-space: nowrap; }
.mark { font: 600 24px/1 var(--display); letter-spacing: -0.01em; }
.file { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.saved { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.modes { display: flex; gap: 28px; }
.modes button {
  background: none;
  border: 0;
  padding: 19px 0 17px;
  font: 600 20px/1 var(--display);
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.modes button:hover { color: var(--ink); }
.modes button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--ink); }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; white-space: nowrap; }
.device { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 15px; }
.device i { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--rule-2); }

/* ---- Layout: the gauge on a table, choices beside it ---- */
.studio {
  height: calc(100% - 60px);
  display: grid;
  position: relative;
  /* The settings panel: wide enough to read without scrolling sideways; the
   * owner can drag its edge (panel-grip) to make it wider or narrower. */
  --panel-w: clamp(460px, 38vw, 660px);
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
}
.panel-grip {
  position: absolute; top: 0; bottom: 0; right: calc(var(--panel-w) - 7px); width: 14px;
  cursor: col-resize; z-index: 6; touch-action: none; background: none; border: 0; padding: 0;
}
.panel-grip::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .15s; }
.panel-grip::after {
  content: ""; position: absolute; left: 3px; top: 50%; width: 8px; height: 44px; margin-top: -22px; border-radius: 4px;
  background: var(--paper); border: 1px solid var(--rule-2);
  background-image: radial-gradient(circle, var(--muted) 1px, transparent 1.4px); background-size: 6px 7px; background-position: center;
}
.panel-grip:hover::before, .panel-grip.dragging::before, .panel-grip:focus-visible::before { background: var(--ink-2); }
body.resizing-panel { cursor: col-resize; user-select: none; }
.stage {
  position: relative;
  background: var(--table);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 56px 28px 28px;
  overflow: auto;
  min-width: 0;
}
.stage-tools { position: absolute; top: 14px; left: 28px; right: 28px; display: flex; gap: 22px; align-items: center; font-size: 16px; color: var(--ink-2); }
.stage-tools .spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { accent-color: var(--ink); margin: 0; }

/* The housing: 52 mm of black ASA around a 44 mm picture, lit from the top left. */
.product { position: relative; flex: none; --ring: calc(var(--face) * 4 / 44); }
.housing {
  position: relative;
  width: calc(var(--face) + 2 * var(--ring));
  height: calc(var(--face) + 2 * var(--ring));
  padding: var(--ring);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 22%, #444442 0%, #1C1C1B 46%, #0D0D0D 100%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, .18),
    inset 0 -2px 3px rgba(0, 0, 0, .5),
    0 28px 40px -18px rgba(0, 0, 0, .42),
    0 3px 6px rgba(0, 0, 0, .18);
}
.housing::after {
  content: "";
  position: absolute;
  inset: calc(var(--ring) - 2px);
  border-radius: 50%;
  box-shadow: 0 0 0 2px #050505;
  pointer-events: none;
}
canvas#face {
  display: block;
  width: var(--face);
  height: var(--face);
  border-radius: 50%;
  background: #000;
  touch-action: none;
}
body[data-mode=test] canvas#face { cursor: pointer; }
body.photo-move canvas#face { cursor: grab; }
body.photo-move.dragging canvas#face { cursor: grabbing; }
.stage.drop-target .housing { outline: 2px dashed var(--ink); outline-offset: 10px; }
#slots { position: absolute; inset: var(--ring); width: var(--face); height: var(--face); pointer-events: none; }
body[data-mode=pages] #slots { pointer-events: auto; }
body:not([data-mode=pages]) #slots { display: none; }
.slot { fill: transparent; stroke: rgba(255, 255, 255, .45); stroke-width: 1.5; stroke-dasharray: 5 6; cursor: pointer; pointer-events: all; fill-rule: evenodd; }
.slot:hover { stroke: rgba(255, 255, 255, .9); }
.slot.selected { stroke: #FFFFFF; stroke-dasharray: none; stroke-width: 2.5; }
.light-face .slot { stroke: rgba(0, 0, 0, .4); }
.light-face .slot:hover { stroke: rgba(0, 0, 0, .8); }
.light-face .slot.selected { stroke: #000; }

.caption { color: var(--ink-2); text-align: center; min-height: 1.5em; font-size: 17px; }
.caption .warn { color: #C0262D; }

/* Page strip under the gauge */
.strip { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; justify-content: center; }
body[data-mode=test] .strip { display: none; }
.strip ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.strip li { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 16px; color: var(--muted); }
.strip li.current { color: var(--ink); }
.strip li.dragging { opacity: .35; }
.strip li.drop-before .disc { box-shadow: -8px 0 0 -5px var(--ink); }
/* Beside the panel the pages stay on one row (scrolling sideways when there
 * are many), so the strip never pushes the gauge up under the tools. */
@media (min-width: 981px) {
  .strip, .strip ol { flex-wrap: nowrap; gap: 10px; }
  .strip { flex: none; max-width: 100%; overflow-x: auto; scrollbar-width: thin; padding: 6px 6px 4px; justify-content: safe center; }
  .strip ol { justify-content: flex-start; }
}

.disc {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #000;
  border: 0;
  padding: 0;
  flex: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.disc canvas { width: 100%; height: 100%; border-radius: 50%; display: block; }
[aria-checked=true] .disc, [aria-pressed=true] .disc {
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink);
}
.stage .current .disc { box-shadow: 0 0 0 3px var(--table), 0 0 0 5px var(--ink); }
.add {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: none;
  border: 1.5px dashed var(--rule-2);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}
.add:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }

/* Test transport */
.transport { display: none; width: min(100%, 640px); }
body[data-mode=test] .transport { display: block; }
.transport-top { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.play {
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--ink); color: var(--paper);
  font-size: 14px; letter-spacing: -1px;
}
.time { color: var(--ink-2); font-size: 17px; }
.transport-top .spacer { flex: 1; }
.timeline { position: relative; padding-bottom: 42px; }
.timeline input { width: 100%; margin: 0; accent-color: var(--ink); }
.marks { position: absolute; left: 0; right: 0; top: 24px; height: 38px; }
.marks button {
  position: absolute;
  background: none;
  border: 0;
  border-left: 1px solid var(--rule-2);
  padding: 0 0 0 5px;
  height: 18px;
  line-height: 18px;
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
}
.marks button.low { top: 18px; }
.marks button:hover, .marks button.here { color: var(--ink); border-left-color: var(--ink); }
.hint { color: var(--muted); font-size: 16px; text-align: center; max-width: 640px; }

.segmented { display: inline-flex; border: 1px solid var(--rule-2); border-radius: 4px; overflow: hidden; }
.segmented button {
  background: none;
  border: 0;
  border-left: 1px solid var(--rule-2);
  padding: 7px 13px;
  color: var(--ink-2);
  white-space: nowrap;
  font-size: 15px;
}
.segmented button:first-child { border-left: 0; }
.segmented button:hover { background: var(--table); }
.segmented button[aria-checked=true] { background: var(--ink); color: var(--paper); }

.toast {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  padding: 9px 10px 9px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
  font-size: 16px;
}
.toast .link { color: var(--paper); text-decoration-color: #777; }

/* ---- Panel ---- */
.panel {
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-2) transparent;
  display: flex;
  flex-direction: column;
}
.panel > section { padding: 26px 30px; border-bottom: 1px solid var(--rule); }
.panel > section:last-child { border-bottom: 0; }
.panel h2 { font: 600 36px/1.05 var(--display); letter-spacing: -0.015em; }
.panel h3 { font: 600 22px/1.2 var(--display); margin-bottom: 16px; display: flex; justify-content: space-between; align-items: baseline; }
.panel h3 small { font: 400 15px var(--font); color: var(--muted); }
.lead { color: var(--ink-2); margin-top: 10px; font-size: 18px; }
.note { color: var(--muted); font-size: 15px; }
.back { margin-bottom: 8px; }
.foot { margin-top: auto; }
.foot .row { display: flex; gap: 18px; flex-wrap: wrap; }

/* Tiles: a round picture and a name */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 8px; }
.tiles.five { grid-template-columns: repeat(5, 1fr); }
.tile {
  background: none;
  border: 0;
  padding: 4px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--ink-2);
  min-width: 0;
}
.tile .disc { width: 68px; height: 68px; }
.tiles.featured-looks { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 10px; }
.featured-looks .tile .disc { width: min(96px, 100%); height: auto; aspect-ratio: 1; }
.other-looks { margin-top: 24px; }
.tiles.five .disc { width: 60px; height: 60px; }
.tile:hover { color: var(--ink); }
.tile[aria-checked=true], .tile[aria-pressed=true] { color: var(--ink); font-weight: 500; }
.tile span.name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout pictures (line drawings, ink) */
.layouts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.layouts button {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: var(--ink-2);
}
.layouts button:hover { border-color: var(--rule-2); }
.layouts button[aria-pressed=true] { border-color: var(--ink); color: var(--ink); }
.layouts svg { width: 36px; height: 36px; }

/* Colour rows */
.colours { list-style: none; margin: 0; padding: 0; }
.colours li { border-top: 1px solid var(--rule); }
.colours li:first-child { border-top: 0; }
.colour-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
}
.chip {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
}
.chip input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.colour-row code { font: 400 15px var(--font); color: var(--muted); text-transform: uppercase; }
.colour-row .role small { display: block; color: var(--muted); font-size: 15px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.swatches button {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
}
.swatches button[aria-pressed=true] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
.reserved { color: #B0202A; font-size: 15px; margin-top: 10px; }

.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field input[type=range] { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: var(--ink); }
.field output { color: var(--muted); font-size: 15px; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 1.5px dashed var(--rule-2);
  border-radius: 4px;
  background: none;
  padding: 20px;
  color: var(--ink-2);
}
.drop:hover { border-color: var(--ink); color: var(--ink); }
.drop small { color: var(--muted); font-size: 15px; }

/* Slot and channel lists */
.rows { list-style: none; margin: 0 -30px; padding: 0; }
.rows button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
  background: none;
  border: 0;
  padding: 12px 30px;
  text-align: left;
}
.rows button:hover { background: var(--table); }
.rows .aside { color: var(--muted); font-size: 15px; }
.rows button[aria-selected=true] { background: var(--table); box-shadow: inset 3px 0 0 var(--ink); }
.group { color: var(--muted); font-size: 15px; padding: 16px 0 4px; }
.search {
  width: 100%;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  padding: 9px 12px;
  margin-top: 14px;
  background: var(--paper);
}
.search:focus { border-color: var(--ink); outline: none; }

.scrub {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: ew-resize;
  user-select: none;
}
.scrub input { width: 6ch; border: 0; padding: 0; text-align: right; font-size: 20px; cursor: text; background: none; }
.scrub input:focus { outline: none; }
.scrub span { color: var(--muted); }

.states { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 0; padding: 0; }
.states li { list-style: none; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 15px; color: var(--ink-2); }
.states .disc { width: 62px; height: 62px; }
.states li.night canvas { filter: brightness(.31); }

/* Test data */
.data-row { padding: 12px 0; border-top: 1px solid var(--rule); }
.data-row:first-of-type { border-top: 0; }
.data-row header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.reading { font: 600 22px/1 var(--display); }
.reading.status-word { font: 500 15px var(--font); letter-spacing: .06em; color: var(--muted); }
.reading.invalid { color: #9A5B00; }
.data-row .segmented { width: 100%; }
.data-row .segmented button { flex: 1; padding: 5px 0; }
.data-row input[type=range] { width: 100%; margin: 10px 0 0; accent-color: var(--ink); }
details summary { cursor: pointer; color: var(--ink-2); padding: 4px 0; }
.switch-row { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.switch-row input { accent-color: var(--ink); width: 18px; height: 18px; }

/* ECU step */
.ecus { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ecu {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px 12px;
  align-items: baseline;
  text-align: left;
  background: none;
  border: 1px solid var(--rule-2);
  border-radius: 4px;
  padding: 14px 16px;
}
.ecu:hover { border-color: var(--ink); }
.ecu[aria-checked=true] { border: 2px solid var(--ink); padding: 13px 15px; }
.ecu .dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--rule-2); align-self: center; }
.ecu[aria-checked=true] .dot { border: 5px solid var(--ink); }
.ecu .name { font: 600 20px/1.2 var(--display); }
.ecu .sub { grid-column: 2; color: var(--muted); font-size: 15px; }
.badge { display: inline-block; font-size: 14px; border: 1px solid var(--rule-2); border-radius: 3px; padding: 1px 6px; margin-left: 8px; color: var(--ink-2); font-family: var(--font); font-weight: 400; }
.badge.warn { border-color: #9A5B00; color: #7A4700; }
.howto { margin: 0; padding-left: 24px; }
.howto li { margin-bottom: 8px; }
.sends { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.sends li::before { content: "✓  "; color: var(--ink); }
.sends li.missing { color: var(--muted); }
.sends li.missing::before { content: "–  "; }
table.can { width: 100%; border-collapse: collapse; font-size: 15px; }
table.can th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 6px 6px 0; }
table.can td { padding: 5px 6px 5px 0; border-top: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
/* An editor for one value or warning: two columns that shrink with the panel. */
.signal { padding: 14px 0 6px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 12px; }
.signal label, .pair label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; color: var(--muted); min-width: 0; }
.signal label small, .signal .arming small { color: var(--muted); font-size: 14px; }
.signal input:not([type=checkbox]), .signal select, .pair input:not([type=checkbox]), .pair select {
  width: 100%; min-width: 0; font-size: 16px; color: var(--ink); border: 1px solid var(--rule-2);
  border-radius: 4px; padding: 7px 9px; background: var(--paper);
}
.signal input:focus, .signal select:focus, .pair input:focus, .pair select:focus { border-color: var(--ink); outline: none; }
.signal .wide { grid-column: 1 / -1; min-width: 0; }
.signal .label { display: block; font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.pair.three { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr); }
.pair + .pair { margin-top: 12px; }
.field-error { color: #B0202A; font-size: 14px; }
.field-error:empty { display: none; }
.prefixed { display: flex; align-items: center; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper); }
.prefixed:focus-within { border-color: var(--ink); }
.prefixed span { padding-left: 9px; color: var(--muted); }
.signal .prefixed input { border: 0; padding-left: 2px; font-variant-numeric: tabular-nums; text-transform: uppercase; }
.id-row { align-items: end; }
.id-side { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; font-size: 15px; }
.id-side small { color: var(--muted); font-size: 14px; }
.check.inline { flex-direction: row !important; align-items: center; gap: 7px; color: var(--ink-2) !important; }
.check.inline input { accent-color: var(--ink); width: 16px; height: 16px; margin: 0; }
.position { display: flex; flex-direction: column; gap: 12px; }
.position-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 15px; color: var(--muted); }
.segmented.small button { padding: 4px 10px; font-size: 14px; }
.sub-more > summary { font-size: 15px; color: var(--ink-2); }
.sub-more[open] > summary { margin-bottom: 12px; }
.sub-more > label { margin-top: 12px; }
.notes p { color: #7A4700; font-size: 15px; }
.notes:empty { display: none; }
.editor-foot { display: flex; justify-content: flex-end; gap: 18px; }
.user-box { border-left: 3px solid var(--rule); padding-left: 12px; display: flex; flex-direction: column; gap: 12px; }
.user-box .note { margin: 0; }
.mono, .check-box input { font-family: ui-monospace, Consolas, monospace; font-size: 15px !important; }

/* The list of values: one line each, opened one at a time */
.signals, .warn-list { list-style: none; margin: 0 -30px; padding: 0; border-top: 1px solid var(--rule); }
.signals > li, .warn-list > li { border-bottom: 1px solid var(--rule); padding: 0 30px; }
.signals > li.open, .warn-list > li.open { background: #FBFAF8; }
.signal-head {
  width: 100%; display: grid; grid-template-columns: 12px auto minmax(0, 1fr); align-items: baseline; gap: 10px;
  background: none; border: 0; padding: 12px 0; text-align: left;
}
.signal-head .name { font-weight: 500; white-space: nowrap; }
.signal-head .aside { color: var(--muted); font-size: 14px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-head:hover .name { text-decoration: underline; text-underline-offset: 4px; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); align-self: center; }
.state-dot.note { background: #9A5B00; }
.state-dot.bad { background: #B0202A; }
.arming { display: flex; flex-direction: column; gap: 10px; }
/* Warnings: every reading, with its amber and red limits */
.warn-find { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
.warn-find input { flex: 1 1 160px; min-width: 0; font: inherit; font-size: 15px; padding: 6px 10px; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper); color: var(--ink); }
.warn-head {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 12px;
  background: none; border: 0; padding: 11px 0; text-align: left; color: inherit;
}
.warn-head .name { font-weight: 500; }
.warn-head .aside { grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); }
.warn-head .aside.off { color: var(--muted); }
.warn-head:hover .name { text-decoration: underline; text-underline-offset: 4px; }
.warn-value { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--muted); white-space: nowrap; }
.warn-value[data-level=amber] { color: #9A5B00; font-weight: 600; }
.warn-value[data-level=red] { color: #B0202A; font-weight: 600; }
.warn-editor { padding: 2px 0 18px; display: flex; flex-direction: column; gap: 14px; }
.warn-top { display: flex; align-items: baseline; gap: 10px; }
.warn-top .label { font-size: 14px; color: var(--muted); }
.warn-top .warn-value { font-size: 18px; color: var(--ink); }
.warn-bar { position: relative; height: 14px; margin: 6px 9px 4px; }
.warn-zones { position: absolute; inset: 3px 0; border-radius: 4px; background: var(--rule-2); overflow: hidden; }
.warn-zones span { position: absolute; top: 0; bottom: 0; }
.warn-zones .ok { background: #3F8F5A; }
.warn-zones .amber { background: #E89A2C; }
.warn-zones .red { background: #C8323C; }
.warn-marker { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; background: var(--ink); border-radius: 2px; }
.warn-handle {
  position: absolute; top: -4px; width: 18px; height: 22px; margin-left: -9px; border-radius: 4px; background: var(--paper);
  border: 2px solid var(--ink); cursor: ew-resize; touch-action: none; box-sizing: border-box;
}
.warn-handle.amber { border-color: #B5700F; }
.warn-handle.red { border-color: #B0202A; }
.warn-sides { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.warn-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.warn-editor h4 { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0; }
.warn-limit { display: grid; grid-template-columns: 16px 9px minmax(0, 1fr); align-items: center; gap: 4px 7px; font-size: 15px; }
.warn-limit input[type=checkbox] { accent-color: var(--ink); width: 16px; height: 16px; margin: 0; }
.warn-limit .dot { width: 9px; height: 9px; border-radius: 50%; }
.warn-limit.amber .dot { background: #E89A2C; }
.warn-limit.red .dot { background: #C8323C; }
.warn-limit input[type=text] { grid-column: 3; width: 100%; box-sizing: border-box; font: inherit; padding: 5px 8px; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper); color: var(--ink); }
.warn-limit.off input[type=text], .warn-limit.off .unit { display: none; }
.warn-limit.off .what { color: var(--muted); }
.warn-limit .unit { grid-column: 3; font-size: 13px; color: var(--muted); margin-top: -2px; }
.warn-limit .unit:empty { display: none; }
.warn-problem { color: #9A5B00; }
.warn-acts { display: flex; flex-direction: column; gap: 8px; }
.warn-act { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.warn-act .what { width: 48px; font-size: 15px; }
.warn-more summary { cursor: pointer; font-size: 15px; font-weight: 500; }
.warn-more[open] { display: flex; flex-direction: column; gap: 12px; }
.warn-more[open] summary { margin-bottom: 2px; }
.warn-more > label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; color: var(--muted); }
.warn-more small { color: var(--muted); font-size: 14px; }
.warn-more input:not([type=checkbox]) { font: inherit; padding: 6px 10px; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper); color: var(--ink); max-width: 160px; }
.warn-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
@media (max-width: 520px) { .warn-sides { grid-template-columns: minmax(0, 1fr); } }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.plain-select { border: 1px solid var(--rule-2); border-radius: 4px; padding: 7px 10px; background: var(--paper); max-width: 100%; }
.small-number { width: 90px; border: 1px solid var(--rule-2); border-radius: 4px; padding: 6px 8px; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.chip-button { background: none; border: 1px solid var(--rule-2); border-radius: 4px; padding: 3px 9px; font-size: 14px; }
.chip-button[aria-pressed=true] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.scale-fields .note { margin-top: 8px; }

/* Checking a value against a frame */
.check-box { border-top: 1px solid var(--rule); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.readout { font-size: 16px; color: var(--ink); }
.readout.warn, .warn-text { color: #7A4700; }
.readout.muted { color: var(--muted); }
.bitmap { display: flex; flex-direction: column; gap: 3px; }
.bitmap .byte { display: grid; grid-template-columns: 22px repeat(8, minmax(0, 26px)); gap: 3px; align-items: center; }
.byte-label { font-size: 13px; color: var(--muted); }
.bit {
  display: inline-grid; place-items: center; height: 20px; border: 1px solid var(--rule); border-radius: 2px;
  font: 500 12px/1 ui-monospace, Consolas, monospace; color: var(--muted);
}
.bit.mine { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.bit.other { background: var(--rule); }
.bit.clash { background: #B0202A; border-color: #B0202A; color: var(--paper); }
.bit.mux { background: repeating-linear-gradient(45deg, var(--rule) 0 3px, transparent 3px 6px); }
.legend { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.legend .bit { width: 14px; height: 12px; display: inline-block; vertical-align: middle; }
details.more > summary { font: 600 20px/1.2 var(--display); color: var(--ink); padding: 0; list-style: none; display: flex; justify-content: space-between; }
details.more > summary::after { content: "Show"; font: 400 16px var(--font); color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }
details.more[open] > summary::after { content: "Hide"; }
details.more[open] > summary { margin-bottom: 18px; }
details.more > summary::-webkit-details-marker { display: none; }
.data-row .top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.data-row .controls { margin-top: 10px; }

/* ---- Sheets ---- */
.sheet {
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 6px;
  padding: 28px 30px 22px;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}
.sheet::backdrop { background: rgba(20, 20, 18, .35); }
.sheet h2 { font: 600 28px/1.1 var(--display); margin-bottom: 16px; }
.sheet p { color: var(--ink-2); margin-bottom: 10px; }
.sheet-actions { display: flex; justify-content: flex-end; align-items: center; gap: 18px; margin-top: 22px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps > li { position: relative; padding: 0 0 16px 38px; counter-increment: step; font-weight: 500; }
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--rule-2);
  display: grid; place-items: center;
  font-size: 15px; color: var(--muted); font-weight: 400;
}
.steps > li.done::before { content: "✓"; background: var(--ink); border-color: var(--ink); color: var(--paper); }
.steps > li.off { color: var(--muted); }
.steps p { font-weight: 400; font-size: 16px; margin: 3px 0 0; color: var(--muted); }
.card-bar { height: 54px; border: 1.5px solid var(--ink); border-radius: 3px; margin: 14px 0; }
#calibrate input { width: 100%; accent-color: var(--ink); }

@media (max-width: 1280px) {
  .saved, .file { display: none; }
  /* Five steps: the steps follow the name rather than centring, so they never meet it. */
  .bar { grid-template-columns: auto auto minmax(0, 1fr); padding: 0 20px; }
  .bar .actions { justify-self: end; }
  .modes { gap: 20px; }
}
@media (max-width: 980px) {
  body { overflow: auto; }
  .bar { height: auto; grid-template-columns: 1fr auto; padding: 10px 16px; gap: 8px 16px; }
  .modes { grid-column: 1 / -1; grid-row: 2; gap: 22px; }
  .modes button { padding: 10px 0 8px; }
  .actions { gap: 10px; }
  .actions .link, .device { display: none; }
  .studio { display: block; height: auto; }
  .panel-grip { display: none; }
  .stage { padding: 52px 16px 24px; }
  .stage-tools { left: 16px; right: 16px; flex-wrap: wrap; gap: 14px; }
  .panel { border-left: 0; }
  .panel > section { padding: 20px 16px; }
  .rows { margin: 0 -16px; }
  .rows button { padding: 9px 16px; }
}

/* ---- Shift point handle on the gauge ---- */
.shift-handle { cursor: grab; pointer-events: all; }
.shift-handle circle { fill: #FFFFFF; stroke: #111111; stroke-width: 2.5; }
.shift-handle text { fill: #FFFFFF; font: 600 20px var(--display); paint-order: stroke; stroke: rgba(0, 0, 0, .7); stroke-width: 4px; pointer-events: none; }
.shift-handle:active { cursor: grabbing; }

/* ---- Send and import sheets ---- */
.sheet.wide-sheet { width: min(640px, calc(100vw - 32px)); }
.sheet-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; }
.sheet-actions .spacer { margin-right: auto; }
.steps > li.failed::before { content: "!"; border-color: #B0202A; color: #B0202A; }
.steps progress { width: 100%; height: 8px; margin-top: 10px; accent-color: var(--ink); }
.found { list-style: none; margin: 12px 0 0; padding: 0; }
.found li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 10px 0; border-top: 1px solid var(--rule); font-weight: 400; }
.found li small { display: block; color: var(--muted); font-size: 14px; }
.dbc-list { max-height: min(52vh, 520px); overflow: auto; margin-top: 12px; border-top: 1px solid var(--rule); }
.dbc-list .group { padding: 14px 0 4px; }
.dbc-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px); gap: 12px; align-items: center; padding: 6px 0; }
.dbc-row small { display: block; color: var(--muted); font-size: 14px; }
.dbc-row.off { color: var(--muted); }
.dbc-row select { width: 100%; border: 1px solid var(--rule-2); border-radius: 4px; padding: 6px 8px; background: var(--paper); }

/* ---- Phones and narrow windows: the gauge's own setup page opens on a phone ---- */
@media (max-width: 980px) {
  .actions .link { display: inline; padding: 6px 0; }
  .stage-tools { position: static; order: -1; width: 100%; }
  .stage { padding-top: 16px; gap: 16px; }
  .transport-top { flex-wrap: wrap; }
  .toast { white-space: normal; max-width: calc(100% - 32px); }
  .signals, .warn-list { margin: 0 -16px; }
  .signals > li, .warn-list > li { padding: 0 16px; }
  .warning-list .empty { padding: 12px 16px; }
}
@media (max-width: 600px) {
  .bar { display: flex; flex-wrap: wrap; align-items: center; }
  .brand { flex: 1; }
  .actions { order: 2; width: 100%; justify-content: space-between; gap: 6px; }
  .actions .solid { margin-left: auto; }
  .modes { order: 3; width: 100%; justify-content: space-between; gap: 8px; }
  .segmented button { padding: 7px 9px; }
  .marks button { font-size: 0; padding-left: 0; width: 12px; height: 14px; }
  .marks button.low { top: 0; }
  .timeline { padding-bottom: 20px; }
  .marks { height: 16px; }
  .signal { grid-template-columns: minmax(0, 1fr); }
  .pair.three { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .signal-head { grid-template-columns: 12px minmax(0, 1fr); }
  .signal-head .aside { grid-column: 2; text-align: left; }
  .dbc-row { grid-template-columns: minmax(0, 1fr); }
  .tile .disc { width: 56px; height: 56px; }
  .tiles.five .disc { width: 48px; height: 48px; }
  .states .disc { width: 48px; height: 48px; }
  .layouts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Keep the result in view while a phone owner scrolls the editing controls.
 * Only Choices scrolls: focusing an input must never push the gauge away. */
@media (max-width: 600px) {
  body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .bar { flex: none; padding: 8px 12px 0; gap: 4px 8px; }
  .mark { font-size: 21px; }
  .actions { font-size: 14px; }
  .actions .solid { padding: 6px 10px; }
  .modes button { font-size: 17px; padding: 8px 0; }
  .studio {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 55%) minmax(0, 1fr);
  }
  .stage { min-height: 0; overflow: hidden; padding: 32px 12px 8px; gap: 4px; }
  .stage-tools {
    position: absolute; top: 7px; left: 12px; right: 12px;
    width: auto; gap: 10px; flex-wrap: nowrap; font-size: 12px;
  }
  .stage-tools .check { gap: 4px; }
  #about-open { padding: 0; font-size: 0; }
  #about-open::after { content: 'Preview limits'; font-size: 12px; }
  .caption { width: 100%; min-height: 18px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .strip { width: 100%; min-height: 38px; gap: 6px; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; flex-shrink: 0; }
  .strip ol { gap: 6px; flex-wrap: nowrap; justify-content: flex-start; }
  .strip li > span { display: none; }
  .strip .disc { width: 30px; height: 30px; }
  .strip li > button { padding: 3px !important; }
  .strip .add { width: 32px; height: 32px; line-height: 30px; margin-top: 2px; flex: none; font-size: 22px; }
  .transport { flex-shrink: 0; width: 100%; max-width: none; }
  .transport-top { gap: 8px; flex-wrap: nowrap; }
  .transport .time { font-size: 13px; }
  .transport .play { width: 30px; height: 30px; }
  .transport .segmented button { padding: 4px 7px; font-size: 13px; }
  .transport .timeline { padding-bottom: 12px; }
  .stage > .hint { display: none; }
  .panel { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; border-top: 1px solid var(--rule-2); }
  .panel > section { flex: none; padding: 14px 16px; }
  .panel h2 { font-size: 27px; }
  .panel h3 { font-size: 20px; margin-bottom: 10px; }
  .panel .w-field input, .panel .w-field select { font-size: 16px; }
  body:has(.widget-overlay:not([hidden])) .panel > section:first-child:not(.w-bar) {
    position: sticky; top: 0; z-index: 2; display: flex; align-items: center;
    justify-content: space-between; gap: 10px; background: var(--paper);
  }
  body:has(.widget-overlay:not([hidden])) .panel > section:first-child h2 { font-size: 21px; }
  body:has(.widget-overlay:not([hidden])) .panel > section:first-child .lead { display: none; }
}

/* Simulated data: always said beside the gauge */
.sim-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--table); color: var(--ink-2); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
/* A status of its own, for things the owner should act on */
.status-box { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--rule-2); background: #FBF5EA; }
.status-box.caution { border-color: #E2B866; }
.status-box strong { font-size: 15px; color: #7A4A00; }
.status-box span { font-size: 14px; color: var(--ink-2); }
.status-box .plain { margin-top: 4px; }
.scenarios { flex-wrap: wrap; }
.scenarios button { padding: 6px 12px; }
.scope-note { margin: 10px 0 14px; }
/* Pages: the folded groups */
.page-fold details > summary { cursor: pointer; font: 600 19px/1.2 var(--display); display: flex; flex-direction: column; gap: 3px; }
.page-fold details > summary small { font: 400 14px/1.3 Barlow, sans-serif; color: var(--muted); }
.page-fold .fold-part { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--rule); }
.page-fold .fold-part > h3:first-child { margin-top: 0; }
.limit { margin: 0 0 10px; }
.limit.full { color: #7A4A00; }
/* The small live gauge on narrow screens */
.mini-face { position: fixed; right: 12px; bottom: 12px; z-index: 30; width: 104px; height: 104px; padding: 0; border: 0; border-radius: 50%;
  background: #000; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--rule-2); cursor: pointer; }
.mini-face canvas { width: 100%; height: 100%; border-radius: 50%; display: block; }

.warn-clears { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }

.small-link { font: 400 14px/1.2 Barlow, sans-serif; margin-left: auto; }
.panel h3:has(.small-link) { display: flex; align-items: baseline; gap: 10px; }

.themes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.themes button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--rule-2); border-radius: 8px; background: var(--paper); cursor: pointer; font: inherit; font-size: 13px; color: var(--ink); }
.themes button:hover { border-color: var(--ink); }
.themes button[aria-pressed=true] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.themes svg { width: 48px; height: 48px; }
.theme-own { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 15px; cursor: pointer; }
.theme-own input { width: 36px; height: 28px; padding: 0; border: 1px solid var(--rule-2); border-radius: 4px; background: none; }
.blank-start .row-actions { margin-top: 8px; }
@media (max-width: 520px) { .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* The phone's preview: smaller while editing a page, with a button to enlarge it */
#preview-size { display: none; }
@media (max-width: 600px) {
  body.editing #preview-size { display: inline; font-size: 12px; padding: 0; }
  body.editing:not(.big-preview) .studio { grid-template-rows: minmax(0, 34%) minmax(0, 1fr); }
  body.editing:not(.big-preview) .strip { display: none; }
}

.send-caution { color: #7A4A00; }
