/* EM Spectrum Dispatcher: a dispatch-desk switchboard. Drawings from art.js (colors from the --ed-* properties). */
html {
  --ed-wood1: #7b4b2c; --ed-wood2: #4f2e1a; --ed-wood-line: #2e1a0e;
  --ed-brass1: #fff1b8; --ed-brass2: #c99a3c; --ed-brass3: #7a5a1c; --ed-hole: #1c140e;
  --ed-panel1: #fbf6ea; --ed-panel2: #efe4cf; --ed-panel-line: #8a6a3c; --ed-ink: #1f2328;
  --ed-card1: #fffdf6; --ed-card2: #f3ead4; --ed-head: #13202b; --ed-head-ink: #eaf4fb;
  --ed-accent: #1f4e79; --ed-ok: #13704a; --ed-bad: #b3261e; --ed-focus: #f6c343;
  --ed-cloud: #6fa8e6; --ed-orbit: #6a7f95; --ed-atom-bg1: #eef4fa; --ed-atom-bg2: #d9e5f0;
  --ed-b-radio: #8a6f5a; --ed-b-microwave: #a7713f; --ed-b-infrared: #b3473c; --ed-b-ultraviolet: #6a4fb3; --ed-b-x-ray: #3f5fa0; --ed-b-gamma: #2e3f6e;
}
html[data-theme="dark"] {
  --ed-wood1: #4a2f1e; --ed-wood2: #2c1a10; --ed-wood-line: #120a05;
  --ed-brass1: #f3dd94; --ed-brass2: #a87d2c; --ed-brass3: #5c4212; --ed-hole: #0b0805;
  --ed-panel1: #262a30; --ed-panel2: #1f2227; --ed-panel-line: #b58f55; --ed-ink: #eef1f4;
  --ed-card1: #31343a; --ed-card2: #2a2c31; --ed-head: #0b1219; --ed-head-ink: #eaf4fb;
  --ed-accent: #8fc2f0; --ed-ok: #4fd08c; --ed-bad: #ff8a80; --ed-focus: #f6c343;
  --ed-cloud: #8fc2f0; --ed-orbit: #9fb3c8; --ed-atom-bg1: #1c2734; --ed-atom-bg2: #141c26;
  --ed-b-radio: #b39783; --ed-b-microwave: #d39a62; --ed-b-infrared: #e07a6c; --ed-b-ultraviolet: #a68cf0; --ed-b-x-ray: #86a6e6; --ed-b-gamma: #9fb0e0;
}

/* ── layout ── */
.ed { position: absolute; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; padding: 8px 10px;
  color: var(--ed-ink); font-size: 16px; overflow: auto; }
.ed input, .ed button { font: inherit; font-size: 16px; }
.ed-sr, .ed-legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── the switchboard ── */
.ed-board { position: relative; display: grid; grid-template-columns: 268px repeat(7, minmax(0, 1fr)); column-gap: 4px;
  padding: 8px 10px 10px; border-radius: 14px; border: 3px solid var(--ed-wood-line);
  background: repeating-linear-gradient(90deg, rgba(0,0,0,0) 0 36px, rgba(0,0,0,.05) 36px 38px), linear-gradient(var(--ed-wood1), var(--ed-wood2));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.15), 0 3px 8px rgba(0,0,0,.25); }
.ed-head { display: contents; }
.ed-head-tk { display: grid; align-content: center; padding: 4px 8px; color: #fbeedb; line-height: 1.2; }
.ed-head-tk b { font-size: 18px; letter-spacing: .04em; text-transform: uppercase; }
.ed-head-tk span { font-size: 16px; opacity: .9; }
.ed-band { display: grid; justify-items: center; align-content: start; gap: 1px; padding: 4px 2px 3px; border-radius: 8px 8px 0 0;
  background: var(--ed-head); color: var(--ed-head-ink); text-align: center; line-height: 1.12; border-bottom: 6px solid var(--band, #888); min-width: 0; }
.ed-band--radio { --band: var(--ed-b-radio); } .ed-band--microwave { --band: var(--ed-b-microwave); } .ed-band--infrared { --band: var(--ed-b-infrared); }
.ed-band--visible { --band: #3fae49; border-image: linear-gradient(90deg, #d7263d, #f08a24, #f6d02f, #3fae49, #2a6fd6, #6b3fb5) 1; border-image-width: 0 0 6px 0; }
.ed-band--ultraviolet { --band: var(--ed-b-ultraviolet); } .ed-band--x-ray { --band: var(--ed-b-x-ray); } .ed-band--gamma { --band: var(--ed-b-gamma); }
.ed-band-top { display: flex; align-items: center; gap: 3px; }
.ed-band-i { flex: none; width: 18px; height: 18px; color: var(--ed-head-ink); }
.ed-band-i svg { width: 18px; height: 18px; display: block; }
.ed-band--visible .ed-band-i { color: #ffd65a; } .ed-band--infrared .ed-band-i { color: #ff9b7a; } .ed-band--ultraviolet .ed-band-i { color: #c7b4ff; }
.ed-band-n { font-size: 16px; }
.ed-band-r { display: grid; font-size: 16px; color: #c8dcea; white-space: nowrap; }
.ed-axis { grid-column: 2 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 3px 0 4px;
  padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.28); color: #fbeedb; font-size: 16px; font-weight: 700; white-space: nowrap; }
.ed-axis-m { font-weight: 400; font-style: italic; opacity: .9; }

.ed-row { display: contents; }
.ed-ticket { position: relative; display: grid; grid-template-columns: 28px 44px minmax(0, 1fr); align-items: center; gap: 6px; margin: 3px 14px 3px 0;
  min-height: 56px; padding: 4px 8px 4px 6px; border-radius: 8px; color: var(--ed-ink);
  background: linear-gradient(var(--ed-card1), var(--ed-card2)); border-left: 7px solid var(--cord);
  box-shadow: 0 2px 4px rgba(0,0,0,.35); }
html[data-theme="dark"] .ed-ticket { border-left-color: var(--cord-d); }
.ed-ticket::after { content: ''; position: absolute; right: -2px; top: 6px; bottom: 6px; border-right: 3px dotted rgba(0,0,0,.25); }
.ed-tk-n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--cord); color: #fff; font-weight: 800; }
html[data-theme="dark"] .ed-tk-n { background: var(--cord-d); color: #111; }
.ed-tk-i svg { width: 42px; height: 42px; display: block; }
.ed-tk-t { display: grid; line-height: 1.15; min-width: 0; }
.ed-tk-t b { font-size: 16px; }
.ed-tk-f { font-size: 16px; font-variant-numeric: tabular-nums; }
.ed-tk-f i { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; }
.ed-tk-focus { position: absolute; top: -11px; left: -4px; padding: 0 7px; border-radius: 9px; background: var(--ed-focus); color: #3a2a00;
  font-size: 16px; font-weight: 800; line-height: 1.25; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.ed-row.is-focus .ed-ticket { outline: 3px solid var(--ed-focus); outline-offset: 0; }
.ed-tk-port { position: absolute; right: -13px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, var(--ed-brass1), var(--ed-brass2) 65%, var(--ed-brass3)); box-shadow: 0 1px 2px rgba(0,0,0,.5); z-index: 3; }

/* jacks (radio inputs) */
.ed-jack { position: relative; display: grid; place-items: center; align-content: center; margin: 3px 0; border-radius: 10px; cursor: pointer; min-height: 56px; }
.ed-jack input { position: absolute; z-index: 4; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ed-sock { position: relative; z-index: 1; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, var(--ed-brass1), var(--ed-brass2) 62%, var(--ed-brass3)); box-shadow: 0 2px 3px rgba(0,0,0,.45); }
.ed-sock::before { content: ''; width: 13px; height: 13px; border-radius: 50%; background: var(--ed-hole); box-shadow: inset 0 2px 2px #000; }
.ed-plug { position: absolute; z-index: 3; inset: -3px; display: none; place-items: center; border-radius: 50%; background: var(--cord); color: #fff;
  font-weight: 800; border: 2px solid #111; box-shadow: 0 2px 4px rgba(0,0,0,.5); }
html[data-theme="dark"] .ed-plug { background: var(--cord-d); color: #111; }
.ed-jack.is-on .ed-plug { display: grid; }
.ed-jack-t { display: none; font-size: 16px; font-weight: 700; color: #fbeedb; }
.ed-jack-m { position: absolute; z-index: 5; top: 1px; right: 3px; font-weight: 900; font-size: 18px; line-height: 1; }
.ed-jack:hover:not(.is-locked *) { background: rgba(255,255,255,.12); }
.ed-jack:has(input:focus-visible) { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: -2px; background: rgba(255,255,255,.14); }
.ed-row.is-set .ed-jack:not(.is-on) .ed-sock { opacity: .78; }
.is-locked .ed-jack, .is-locked .ed-jack input { cursor: default; }
.ed-jack.is-ok { background: rgba(79,208,140,.28); box-shadow: inset 0 0 0 3px var(--ed-ok); }
.ed-jack.is-ok .ed-jack-m { color: #c9ffd9; }
.ed-jack.is-bad { background: rgba(255,120,110,.22); box-shadow: inset 0 0 0 3px var(--ed-bad); }
.ed-jack.is-bad .ed-jack-m { color: #ffd2cc; }
.ed-jack.is-should { box-shadow: inset 0 0 0 3px #c9ffd9; outline: 3px dashed #c9ffd9; outline-offset: -8px; }
.ed-jack.is-should .ed-jack-m { color: #c9ffd9; }

.ed-cables { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.ed-cord { fill: none; stroke-width: 6; stroke-linecap: round; }
.ed-cord-sh { fill: none; stroke: rgba(0,0,0,.35); stroke-width: 6; stroke-linecap: round; }
.ed-pulse { fill: #fff7c2; stroke: #ffb000; stroke-width: 3; filter: drop-shadow(0 0 6px #ffd23f); }

/* ── lower panels ── */
.ed-lower { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 10px; min-height: 0; }
.ed-bench, .ed-calc { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; padding: 8px 12px;
  background: linear-gradient(var(--ed-panel1), var(--ed-panel2)); border: 3px solid var(--ed-panel-line); border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.ed-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0; font-size: 17px; line-height: 1.2; }
.ed-h-k { font-size: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ed-accent); }
.ed-note { margin: 0; font-size: 16px; line-height: 1.3; }
.ed-formula b { font-family: Georgia, 'Times New Roman', serif; }

.ed-bench-b { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 10px; align-items: start; }
.ed-atom-box svg { display: block; width: 176px; height: auto; }
.ed-atom-bg { fill: var(--ed-atom-bg1); stroke: var(--ed-panel-line); stroke-width: 2; }
.ed-orbit { stroke: var(--ed-orbit); }
.ed-atom-p, .ed-atom-e { font: 800 19px var(--tlg-font, sans-serif); fill: #fff; }
.ed-atom-cap { font: italic 24px var(--tlg-font, sans-serif); fill: var(--ed-ink); opacity: .8; }
.ed-photon-w { stroke: #e0a800; } .ed-photon-h { fill: #e0a800; }
.is-radio .ed-photon-w, .is-microwave .ed-photon-w { stroke: var(--ed-b-microwave); } .is-radio .ed-photon-h, .is-microwave .ed-photon-h { fill: var(--ed-b-microwave); }
.is-infrared .ed-photon-w { stroke: var(--ed-b-infrared); } .is-infrared .ed-photon-h { fill: var(--ed-b-infrared); }
.is-visible .ed-photon-w { stroke: #2f9a3f; } .is-visible .ed-photon-h { fill: #2f9a3f; }
.is-ultraviolet .ed-photon-w { stroke: #7d5ad6; } .is-ultraviolet .ed-photon-h { fill: #7d5ad6; }
.is-x-ray .ed-photon-w, .is-gamma .ed-photon-w { stroke: #3a6fd6; } .is-x-ray .ed-photon-h, .is-gamma .ed-photon-h { fill: #3a6fd6; }
.ed-bench-side { display: grid; gap: 6px; min-width: 0; }
.ed-chip { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 0; padding: 3px 9px; border-radius: 8px;
  background: var(--ed-card1); border: 2px solid var(--ed-panel-line); font-size: 16px; }
.ed-chip--given { border-color: var(--ed-accent); }
.ed-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.ed-choice { position: relative; display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 3px 8px; border-radius: 10px;
  border: 2px solid #b5a184; background: var(--ed-card1); cursor: pointer; }
html[data-theme="dark"] .ed-choice { border-color: #7d6d58; }
.ed-choice input { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ed-choice-i { flex: none; width: 20px; font-size: 20px; text-align: center; }
.ed-choice-t { display: grid; line-height: 1.15; }
.ed-choice-t small { font-size: 16px; opacity: .9; }
.ed-choice:has(input:checked) { border-color: var(--ed-accent); background: var(--ed-accent); color: #fff; box-shadow: inset 0 0 0 2px #fff; }
html[data-theme="dark"] .ed-choice:has(input:checked) { color: #0d1b28; box-shadow: inset 0 0 0 2px #0d1b28; }
.ed-choice:has(input:focus-visible) { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.ed-choice:hover:not(:has(input:disabled)) { border-color: var(--ed-accent); }
.ed-choice:has(input:disabled) { cursor: default; }
.ed-ion-m { margin: 0; font-weight: 800; font-size: 16px; }
.ed-ion-m.is-ok { color: var(--ed-ok); } .ed-ion-m.is-bad { color: var(--ed-bad); }
.ed-meter { visibility: hidden; min-height: 68px; overflow: hidden; }
.ed-meter.is-on { visibility: visible; animation: ed-in .35s ease-out; }
.ed-meter svg { display: block; }
.ed-m-bar { fill: var(--ed-card2); stroke: var(--ed-panel-line); stroke-width: 1.5; }
.ed-m-ion { fill: #7d5ad6; opacity: .45; }
.ed-m-tick { stroke: var(--ed-ink); stroke-width: 1.5; }
.ed-m-thr { stroke: var(--ed-bad); stroke-width: 3; stroke-dasharray: 4 3; }
.ed-m-t { font: 16px var(--tlg-font, sans-serif); fill: var(--ed-ink); }
.ed-m-me { font-weight: 800; }
.ed-m-mark { fill: var(--ed-accent); stroke: var(--ed-ink); stroke-width: 1; }
.ed-m-mark.is-hi { fill: #e0a800; }

.ed-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ed-chips .ed-chip { padding: 1px 6px; gap: 2px 4px; border-width: 1.5px; }
.ed-num { display: grid; grid-template-columns: 128px 168px minmax(0, 1fr); align-items: center; gap: 0 8px; }
.ed-num-l { font-weight: 700; line-height: 1.15; }
.ed-num-x { display: grid; line-height: 1.15; min-width: 0; }
.ed-num-row { display: flex; align-items: center; gap: 6px; }
.ed-num input { width: 100%; min-width: 0; min-height: 42px; padding: 6px 8px; border: 2px solid var(--tlg-border-strong, #666); border-radius: 8px;
  background: var(--tlg-surface, #fff); color: var(--tlg-text, #111); font-variant-numeric: tabular-nums; }
.ed-num input:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.ed-num input:disabled { opacity: 1; }
.ed-unit { flex: none; min-width: 26px; font-weight: 700; }
.ed-echo { font-size: 16px; opacity: .85; font-variant-numeric: tabular-nums; }
.ed-echo.is-bad { color: var(--ed-bad); opacity: 1; }
.ed-mark { font-weight: 800; }
.ed-mark.is-ok { color: var(--ed-ok); } .ed-mark.is-bad { color: var(--ed-bad); }
.ed-about { margin-top: auto; padding: 4px 8px; border: 1px solid var(--ed-panel-line); border-radius: 8px; font-size: 16px; }
.ed-about summary { cursor: pointer; min-height: 30px; font-weight: 700; }
.ed-about p { margin: 6px 0; line-height: 1.35; }

/* Briefing example */
.ed-example { display: block; width: 100%; height: auto; max-height: 300px; }
.ed-ex-card { fill: #fffdf6; stroke: #1d8a83; stroke-width: 3; }
.ed-ex-band { fill: #13202b; } .ed-ex-band.is-on { fill: #2f6f3a; }
.ed-ex-t { font: 18px var(--tlg-font, sans-serif); fill: var(--tlg-text, #111); }
.ed-ex-band + .ed-ex-t { fill: #eaf4fb; font-size: 17px; }
.ed-ex-card ~ .ed-ex-t { fill: #1f2328; }
.ed-ex-plug { font: 800 14px var(--tlg-font, sans-serif); fill: #fff; }
.ed-ex-meter { fill: #ece3cf; stroke: #8a6a3c; }
.ed-ex-thr { stroke: #b3261e; stroke-width: 3; stroke-dasharray: 4 3; }
.ed-ex-mark { fill: #1f4e79; }

@keyframes ed-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── narrow screens: tickets stack, each with its own row of labelled jacks ── */
@media (max-width: 900px) {
  .ed { position: static; display: flex; flex-direction: column; overflow: visible; }
  .ed-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 4px; }
  .ed-head-tk { grid-column: 1 / -1; }
  .ed-band { border-radius: 8px; }
  .ed-band-i { display: none; }
  .ed-axis { grid-column: 1 / -1; flex-wrap: wrap; white-space: normal; }
  .ed-row { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
  .ed-ticket { grid-column: 1 / -1; margin: 4px 0; }
  .ed-tk-port, .ed-ticket::after, .ed-cables { display: none; }
  .ed-jack { min-height: 52px; grid-auto-flow: column; gap: 6px; margin: 0; background: rgba(0,0,0,.2); }
  .ed-jack-t { display: block; }
  .ed-lower { grid-template-columns: 1fr; }
  .ed-bench, .ed-calc { overflow: visible; }
}
@media (max-width: 520px) {
  .ed-bench-b { grid-template-columns: 1fr; justify-items: center; }
  .ed-bench-side { width: 100%; }
  .ed-num { grid-template-columns: 1fr; }
  .ed-choices { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .ed * { transition: none !important; animation: none !important; } }

/* The assignment card: labgames-assignment.js's place() writes an inline top, and the shell pins the card by its
   bottom during play, so it stretches down the stage over the Gamma column (shell request on the worker board).
   Workaround: keep it at the foot of the customer column, as Free-Body Garage does. */
@media (min-width: 901px) {
  html.ps-locked:has(.ed) .lga-card { top: auto !important; right: auto; left: 12px; }
  html.ps-locked:has(.ed):has(.lga-card) .ps-side { padding-bottom: 84px; }
}
