/* Arduino Ladder 3D labs: the concept labs, the "View in 3D" build viewer,
   full screen, and the "3D" links in each band's section bar.
   The look is the BIH JHS Tech Club's (src/site.css, "3D lab" and "callouts"),
   rebuilt on this course's tokens so it follows the page's light and dark
   themes. Every colour falls back to a BIH value if a token is missing. */

.lab, .lab-skel, .lab-index {
  --lab-ink: var(--ink, #24182e);
  --lab-text: var(--ink-2, #3b3343);
  --lab-muted: var(--muted, #6b6373);
  --lab-line: var(--line, #e8e3ec);
  --lab-paper: var(--surface, #ffffff);
  --lab-panel: var(--ground, #f9f9f9);
  --lab-tint: var(--surface-2, #f4f0f6);
  --lab-accent: var(--accent, #ca1f3f);
  --lab-gold: var(--gold, #ffbe00);
  --lab-gold-ink: var(--copper, var(--gold-ink, #8a5c00));
  --lab-good: var(--good, #1f8a70);
  --lab-plum: var(--plum, #24182e);
  --lab-card: var(--surface, #fffdf9);
  --lab-hud: rgba(36, 24, 46, 0.9);
  --lab-grid: rgba(36, 24, 46, 0.055);
  --lab-shadow: 0 1px 2px rgba(36, 24, 46, 0.06), 0 8px 22px -6px rgba(36, 24, 46, 0.18);
  --lab-font: var(--text, "Rubik", "Segoe UI", Roboto, Arial, sans-serif);
  --lab-display: var(--display, "Outfit", "Rubik", "Segoe UI", Arial, sans-serif);
  --lab-mono: var(--mono, "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace);
  --lab-side-w: 380px;
  --lab-h: clamp(440px, calc((var(--lab-w, 1000px) - var(--lab-side-w)) * 0.625), calc(100vh - 9rem));
  /* code colours (light) */
  --lab-code-bg: #fbf9fc;
  --lab-code-ink: #24182e;
  --lab-code-gutter: #a59bae;
  --tk-kw: #8a2a9e;
  --tk-type: #0b6e78;
  --tk-fn: #b4460f;
  --tk-num: #1c62a8;
  --tk-str: #2c7a3a;
  --tk-com: #857b8f;
  --tk-pre: #a8172f;
  --tk-const: #0b6e78;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lab, :root:not([data-theme="light"]) .lab-skel, :root:not([data-theme="light"]) .lab-index {
    --lab-grid: rgba(255, 255, 255, 0.05); --lab-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 24px -8px rgba(0, 0, 0, 0.7); --lab-hud: rgba(10, 6, 14, 0.88);
    --lab-code-bg: #120d17; --lab-code-ink: #ede6f2; --lab-code-gutter: #6f637b;
    --tk-kw: #e29cf2; --tk-type: #6fd6e0; --tk-fn: #ffb37a; --tk-num: #8cc4ff; --tk-str: #9fdc8f; --tk-com: #8f839b; --tk-pre: #ff8fa3; --tk-const: #6fd6e0;
  }
}
:root[data-theme="dark"] .lab, :root[data-theme="dark"] .lab-skel, :root[data-theme="dark"] .lab-index {
  --lab-grid: rgba(255, 255, 255, 0.05); --lab-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 24px -8px rgba(0, 0, 0, 0.7); --lab-hud: rgba(10, 6, 14, 0.88);
  --lab-code-bg: #120d17; --lab-code-ink: #ede6f2; --lab-code-gutter: #6f637b;
  --tk-kw: #e29cf2; --tk-type: #6fd6e0; --tk-fn: #ffb37a; --tk-num: #8cc4ff; --tk-str: #9fdc8f; --tk-com: #8f839b; --tk-pre: #ff8fa3; --tk-const: #6fd6e0;
}

.lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--lab-side-w);
  grid-template-rows: var(--lab-h);
  position: relative;
  background: var(--lab-paper);
  color: var(--lab-ink);
  border: 1px solid var(--lab-line);
  border-radius: 18px;
  overflow: hidden;
  font-family: var(--lab-font);
  font-size: 15px;
  line-height: 1.5;
  margin: 0.8rem 0 0.4rem;
  max-width: none;
  box-shadow: var(--lab-shadow);
}
.lab:empty { display: none; }
.lab[hidden] { display: none; }
.lab .lab-ico { width: 1.15em; height: 1.15em; flex: none; display: block; max-width: none; min-width: 0; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; color: inherit; }
figure .lab svg.lab-ico, figure .lab-skel svg, figure .lab-index svg { padding: 0 !important; border: 0; background: none; border-radius: 0; min-width: 0 !important; }
.lab .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the canvas ---------- */
.lab-canvas {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
  outline: none;
  /* drawing paper with a faint grid, behind a transparent 3D canvas */
  background-color: var(--lab-paper);
  background-image: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(36, 24, 46, 0.035) 100%), linear-gradient(var(--lab-grid) 1px, transparent 1px), linear-gradient(90deg, var(--lab-grid) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px, 28px 28px;
}
.lab-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--lab-gold); }
.lab-canvas canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; cursor: grab; }
.lab-canvas canvas:active { cursor: grabbing; }

.lab-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; color: var(--lab-muted); z-index: 6; }
.lab-status b { font: 600 16px/1.3 var(--lab-display); color: var(--lab-ink); }
.lab-status small { font-size: 13px; }
.lab-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--lab-line); border-top-color: var(--lab-accent); animation: lab-spin 0.9s linear infinite; }
@keyframes lab-spin { to { transform: rotate(360deg); } }

/* the "how to move it" chip, above the toolbar */
.lab-hint { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); display: flex; gap: 0; white-space: nowrap; font: 500 12px/1 var(--lab-font); color: #fff; background: var(--lab-hud); padding: 7px 12px; border-radius: 999px; pointer-events: none; transition: opacity 0.6s, transform 0.6s; z-index: 4; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); }
.lab-hint span + span::before { content: "·"; margin: 0 7px; opacity: 0.6; }
.lab .lab-hint kbd { font: 600 11px/1 var(--lab-mono); color: #fff; background: none; border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 4px; padding: 1px 4px; min-width: 0; }
.lab-canvas.touched .lab-hint { opacity: 0; transform: translate(-50%, 6px); }
@container (max-width: 520px) { .lab-hint span:nth-child(n+3) { display: none; } .lab-hint { bottom: 60px; } }

/* a message over the model (a mission done) */
.lab-toast { position: absolute; left: 50%; top: 14px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; z-index: 7; display: flex; align-items: center; gap: 10px; max-width: min(460px, calc(100% - 24px)); padding: 9px 14px 9px 10px; background: var(--lab-card); border: 1.5px solid var(--lab-good); border-radius: 14px; box-shadow: var(--lab-shadow); transition: opacity 0.3s, transform 0.3s; }
.lab-toast.on { opacity: 1; transform: translate(-50%, 0); }
.lab-toast > .lab-ico { width: 28px; height: 28px; padding: 5px; border-radius: 50%; background: var(--lab-good); color: #fff; stroke-width: 2.6; }
.lab-toast b { display: block; font: 600 14px/1.25 var(--lab-display); color: var(--lab-ink); }
.lab-toast small { display: block; font-size: 12.5px; line-height: 1.35; color: var(--lab-muted); }
.lab-fs .lab-toast { top: 66px; }

/* the title bar, in full screen only */
.lab-topbar { display: none; position: absolute; left: 12px; right: 12px; top: 10px; z-index: 5; align-items: center; justify-content: space-between; gap: 10px; pointer-events: none; }
.lab-fs .lab-topbar { display: flex; }
.lab-topbar-title { pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: calc(100% - 60px); font: 600 15px/1.2 var(--lab-display); color: var(--lab-ink); background: var(--lab-card); border: 1px solid var(--lab-line); padding: 8px 14px 8px 10px; border-radius: 12px; box-shadow: var(--lab-shadow); }
.lab-topbar-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-topbar-title .lab-ico { width: 20px; height: 20px; color: var(--lab-accent); }
.lab-iconbtn { pointer-events: auto; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--lab-line); background: var(--lab-card); color: var(--lab-ink); cursor: pointer; box-shadow: var(--lab-shadow); }
.lab-iconbtn:hover { border-color: var(--lab-ink); }
.lab-iconbtn .lab-ico { width: 20px; height: 20px; }

/* ---------- view toolbar under the model ---------- */
.lab-viewbar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--lab-card); border: 1px solid var(--lab-line); border-radius: 14px; box-shadow: var(--lab-shadow); z-index: 4; }
.lab-viewbar button { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border: 0; background: transparent; border-radius: 10px; color: var(--lab-ink); cursor: pointer; padding: 0; }
.lab-viewbar button .lab-ico { width: 19px; height: 19px; }
.lab-viewbar button:hover { background: var(--lab-tint); }
.lab-viewbar button.on { background: rgba(255, 190, 0, 0.26); color: var(--lab-ink); }
.lab-viewbar .lab-tourbtn { color: var(--lab-accent); }
.lab-viewbar .lab-tourbtn .lab-ico { fill: currentColor; }
.lab-viewbar .lab-fsbtn { background: var(--lab-plum); color: #fff; }
.lab-viewbar .lab-fsbtn:hover { background: var(--lab-accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lab-viewbar .lab-fsbtn { background: var(--lab-gold); color: #24182e; } :root:not([data-theme="light"]) .lab-btn.active, :root:not([data-theme="light"]) .lab-btn[aria-pressed="true"] { background: var(--lab-gold); border-color: var(--lab-gold); color: #24182e; } }
:root[data-theme="dark"] .lab-viewbar .lab-fsbtn { background: var(--lab-gold); color: #24182e; }
:root[data-theme="dark"] .lab-btn.active, :root[data-theme="dark"] .lab-btn[aria-pressed="true"] { background: var(--lab-gold); border-color: var(--lab-gold); color: #24182e; }
.lab-sep { width: 1px; height: 22px; background: var(--lab-line); margin: 0 3px; }
.lab-fullonly { display: none !important; }
.lab-full .lab-fullonly { display: grid !important; }
.lab-full .lab-sep.lab-fullonly { display: block !important; }
/* tooltips */
.lab-viewbar button[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translate(-50%, 4px); white-space: nowrap; font: 500 12px/1 var(--lab-font); color: #fff; background: var(--lab-hud); padding: 6px 9px; border-radius: 7px; opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; }
.lab-viewbar button[data-tip]:hover::after, .lab-viewbar button[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
@media (hover: none) { .lab-viewbar button[data-tip]::after { display: none; } }
@container (max-width: 520px) {
  .lab-viewbar { gap: 0; padding: 3px; bottom: 8px; }
  .lab-viewbar button { width: 34px; height: 36px; }
  .lab-sep { margin: 0 1px; }
}
@container (max-width: 360px) { .lab-viewbar button:nth-of-type(1), .lab-viewbar button:nth-of-type(2) { display: none; } }

/* ---------- callout cards: pinned to parts with a ring and a leader line ---------- */
.lab-callouts { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.lab-callouts.off .lab-callout:not(.sel):not(.tour), .lab-callouts.off .lab-callout-dot:not(.keep) { display: none; }
.lab .lab-leaders { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; overflow: visible; background: none; border: 0; border-radius: 0; padding: 0; margin: 0; display: block; }
.lab-leaders path { fill: none; stroke: var(--lab-ink); stroke-width: 1.3; stroke-dasharray: 3 4; stroke-linecap: round; opacity: 0.55; }
.lab-leaders path.hot { stroke: var(--lab-accent); stroke-dasharray: none; stroke-width: 1.8; opacity: 0.9; }
.lab-leader-end { fill: var(--lab-ink); opacity: 0.55; }
.lab-callout { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; max-width: 236px; text-align: left; font: inherit; font-size: 14px; color: var(--lab-ink); background: var(--lab-card); border: 1px solid var(--lab-line); border-radius: 12px; padding: 9px 12px 9px 9px; box-shadow: var(--lab-shadow); will-change: transform; transition: opacity 0.25s, border-color 0.15s, box-shadow 0.15s; }
button.lab-callout { cursor: pointer; }
button.lab-callout:hover, button.lab-callout:focus-visible { border-color: var(--lab-accent); outline: none; box-shadow: 0 0 0 3px rgba(202, 31, 63, 0.18), var(--lab-shadow); }
.lab-callout-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--lab-tint); color: var(--lab-ink); }
.lab-callout-icon .lab-ico { width: 20px; height: 20px; }
.lab-callout-emoji { font-size: 18px; line-height: 1; }
.lab-callout-txt { min-width: 0; padding-top: 1px; }
.lab-callout b { display: block; font: 600 12.5px/1.2 var(--lab-display); letter-spacing: 0.07em; text-transform: uppercase; }
.lab-callout small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.35; color: var(--lab-muted); }
.lab-callout.sel, .lab-callout.tour { border-color: var(--lab-gold); box-shadow: 0 0 0 4px rgba(255, 190, 0, 0.35), var(--lab-shadow); z-index: 2; }
.lab-callout.sel .lab-callout-icon, .lab-callout.tour .lab-callout-icon { background: var(--lab-gold); color: #24182e; }
.lab-callouts.touring .lab-callout:not(.tour) { opacity: 0.18; }
.lab-callouts.touring .lab-leaders { opacity: 0.5; }
.lab-callout-dot { position: absolute; left: 0; top: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--lab-paper); border: 3.5px solid var(--lab-accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); animation: lab-dot 2.4s infinite; z-index: 1; }
@keyframes lab-dot { 0% { box-shadow: 0 0 0 0 rgba(202, 31, 63, 0.45); } 70% { box-shadow: 0 0 0 10px rgba(202, 31, 63, 0); } 100% { box-shadow: 0 0 0 0 rgba(202, 31, 63, 0); } }
.lab-callout[hidden], .lab-callout-dot[hidden], .tag3d[hidden] { display: none; }
/* small canvases (phones): titles only */
@container (max-width: 560px) {
  .lab-callout small { display: none; }
  .lab-callout { padding: 5px 9px 5px 5px; max-width: 160px; gap: 6px; align-items: center; }
  .lab-callout-icon { width: 24px; height: 24px; border-radius: 6px; }
  .lab-callout-icon .lab-ico { width: 15px; height: 15px; }
  .lab-callout b { font-size: 11px; letter-spacing: 0.05em; }
}

/* floating text tags (HTML, so they stay sharp) */
.tag3d { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; white-space: nowrap; text-align: center; font: 700 13px/1.2 var(--lab-display); padding: 3px 9px; border-radius: 8px; box-shadow: 0 2px 8px rgba(36, 24, 46, 0.1); border: 1px solid rgba(36, 24, 46, 0.12); will-change: transform; }
.tag3d.bare { box-shadow: none; border: 0; padding: 0; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }

/* ---------- the side panel ---------- */
.lab-side { border-left: 1px solid var(--lab-line); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; background: var(--lab-paper); contain: size; }
.lab-side-head { display: none; }
.lab-next, .lab-info, .lab-tabs { flex-shrink: 0; }
.lab-next[hidden] { display: none; }

/* the next mission, always in view */
.lab-next { padding: 10px 12px 0; }
.lab-next-btn { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; font: inherit; color: var(--lab-ink); background: linear-gradient(180deg, rgba(255, 190, 0, 0.14), rgba(255, 190, 0, 0.05)); border: 1.5px solid var(--lab-gold); border-radius: 12px; padding: 9px 11px; cursor: pointer; }
.lab-next-btn:hover { box-shadow: 0 0 0 3px rgba(255, 190, 0, 0.25); }
.lab-next-btn > .lab-ico { width: 22px; height: 22px; color: var(--lab-gold-ink); margin-top: 1px; }
.lab-next-btn.done { border-color: var(--lab-good); background: rgba(31, 138, 112, 0.08); }
.lab-next-btn.done > .lab-ico { color: var(--lab-good); stroke-width: 2.6; }
.lab-next-k { display: block; font: 700 11px/1.2 var(--lab-font); text-transform: uppercase; letter-spacing: 0.1em; color: var(--lab-gold-ink); }
.lab-next-btn b { display: block; font-size: 14px; line-height: 1.35; font-weight: 600; margin-top: 2px; }
.lab-next-btn small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; line-height: 1.35; color: var(--lab-muted); margin-top: 2px; }
.lab-next .meter { height: 4px; margin: 6px 4px 0; }
.lab-next.pop, .lab-missions.pop { animation: lab-pop 0.5s ease; }
@keyframes lab-pop { 50% { transform: scale(1.02); } }

.lab-info { padding: 12px 16px; border-bottom: 1px solid var(--lab-line); font-size: 14.5px; color: var(--lab-text); max-height: 42%; overflow: auto; overscroll-behavior: contain; }
.lab-info.fresh { animation: lab-fresh 0.7s ease; }
@keyframes lab-fresh { from { background: rgba(255, 190, 0, 0.16); } to { background: transparent; } }
.lab-info h4 { margin: 0 0 6px; font: 600 17px/1.25 var(--lab-display); color: var(--lab-ink); }
.lab-info p { margin: 0 0 8px; }
.lab-info ul { margin: 0 0 8px; padding-left: 18px; }
.lab-info li { margin: 2px 0; }
.lab-info code { font-size: 0.88em; }
.lab-where { color: var(--lab-ink); }
.lab-how { color: var(--lab-muted); font-size: 0.92em; }
.lab-tip { color: var(--lab-muted); font-size: 13.5px; }
.lab-joins { border-left: 3px solid var(--lab-gold); padding: 2px 0 2px 10px; margin: 6px 0 8px; }
.lab-joins > b { font: 600 12px/1.2 var(--lab-display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--lab-gold-ink); }
.lab-joins ul { margin: 4px 0 0; padding-left: 16px; }
.lab-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }

/* tabs */
.lab-tabs { display: flex; gap: 0; padding: 0 6px; border-bottom: 1px solid var(--lab-line); background: var(--lab-paper); overflow-x: auto; scrollbar-width: none; }
.lab-tabs:empty { display: none; }
.lab-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: 1 0 auto; font: 600 12px/1 var(--lab-display); letter-spacing: 0.05em; text-transform: uppercase; color: var(--lab-muted); background: none; border: 0; border-bottom: 2.5px solid transparent; padding: 12px 5px 10px; cursor: pointer; white-space: nowrap; }
.lab-tabs button .lab-ico { width: 16px; height: 16px; }
.lab-tabs button:hover { color: var(--lab-ink); }
.lab-tabs button[aria-selected="true"] { color: var(--lab-ink); border-bottom-color: var(--lab-accent); }
.lab-tabs button:focus-visible { outline: 3px solid var(--lab-gold); outline-offset: -3px; border-radius: 6px; }
.lab-badge { font: 700 10.5px/1 var(--lab-font); letter-spacing: 0; padding: 3px 6px; border-radius: 999px; background: var(--lab-tint); color: var(--lab-ink); }
.lab-badge.done { background: var(--lab-good); color: #fff; }
.lab-panes { flex: 1 1 0; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.lab-pane[hidden] { display: none !important; }
.lab-pane[data-pane="code"] { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 14px; }

.lab-controls { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.lab-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lab-group-title { width: 100%; font: 700 11.5px/1.2 var(--lab-font); text-transform: uppercase; letter-spacing: 0.12em; color: var(--lab-muted); }
.lab-group > div { width: 100%; }
.lab-btn { font: inherit; font-size: 13.5px; font-weight: 500; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--lab-line); background: var(--lab-paper); color: var(--lab-ink); cursor: pointer; line-height: 1.3; }
.lab-btn:hover { border-color: var(--lab-ink); }
.lab-btn:disabled { opacity: 0.5; cursor: default; }
.lab-btn:focus-visible, .lab-viewbar button:focus-visible, .view3d-btn:focus-visible, .lab-next-btn:focus-visible, .lab-code-btn:focus-visible, .lab-iconbtn:focus-visible { outline: 3px solid var(--lab-gold); outline-offset: 2px; }
.lab-btn.active, .lab-btn[aria-pressed="true"] { background: var(--lab-plum); border-color: var(--lab-plum); color: #fff; }
.lab-btn.primary { background: var(--lab-accent); border-color: var(--lab-accent); color: #fff; }
.lab-btn.lab-part { font-size: 12.5px; padding: 4px 10px; text-align: left; }
.lab-find { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; }
.lab-find input { font: 600 14px var(--lab-mono); width: 5.2em; padding: 5px 8px; margin-left: 4px; border: 1.5px solid var(--lab-line); border-radius: 8px; background: var(--lab-paper); color: var(--lab-ink); }
.lab-find-msg { width: 100%; color: var(--lab-muted); font-size: 13px; }
.lab-find-msg:empty { display: none; }
.lab-parts summary { cursor: pointer; font: 700 11.5px/1.2 var(--lab-font); text-transform: uppercase; letter-spacing: 0.12em; color: var(--lab-muted); padding: 2px 0 8px; }
.lab-partlist { gap: 5px; }

/* missions tab */
.lab-missions:empty { display: none; }
.lab-missions { padding: 14px 16px; font-size: 14px; }
.mission-head { display: flex; align-items: center; gap: 8px; }
.mission-head b { color: var(--lab-ink); font: 600 16px var(--lab-display); }
.mission-head span { margin-left: auto; font-weight: 600; color: var(--lab-muted); font-size: 13px; }
.mission-reset { border: 1px solid var(--lab-line); background: var(--lab-paper); color: var(--lab-ink); border-radius: 8px; cursor: pointer; font-size: 13px; padding: 2px 7px; }
.meter { width: 100%; height: 8px; background: var(--lab-line); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--lab-gold); transition: width 0.4s; }
.mission-meter { margin: 8px 0 12px; }
.mission-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.mission-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--lab-line); border-radius: 12px; color: var(--lab-muted); }
.mission-list li b { display: block; font-weight: 500; line-height: 1.4; }
.mission-list li small { display: block; margin-top: 3px; font-size: 12.5px; color: var(--lab-muted); }
.mission-list li.now { border: 1.5px solid var(--lab-gold); color: var(--lab-ink); background: rgba(255, 190, 0, 0.07); }
.mission-list li.now b { font-weight: 600; }
.mission-list li.ok { color: var(--lab-ink); }
.mission-mark { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--lab-line); font: 700 12px/1 var(--lab-font); }
.mission-mark .lab-ico { width: 14px; height: 14px; stroke-width: 3; }
.mission-list li.ok .mission-mark { background: var(--lab-good); border-color: var(--lab-good); color: #fff; }
.mission-list li.now .mission-mark { border-color: var(--lab-gold); background: var(--lab-gold); color: #24182e; }
.mission-all { margin: 12px 0 0; color: var(--lab-good); font-weight: 600; }

/* help tab */
.lab-help { padding: 14px 16px 18px; font-size: 14px; color: var(--lab-text); }
.lab-help h5 { margin: 0 0 8px; font: 700 11.5px/1.2 var(--lab-font); text-transform: uppercase; letter-spacing: 0.12em; color: var(--lab-muted); }
.lab-help h5 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.lab-keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0 0 16px; align-items: baseline; }
.lab-keys dt { font-weight: 600; color: var(--lab-ink); white-space: nowrap; }
.lab-keys dd { margin: 0; }
.lab kbd { display: inline-block; min-width: 1.6em; text-align: center; font: 600 12px/1.5 var(--lab-mono); color: var(--lab-ink); background: var(--lab-paper); border: 1px solid var(--lab-line); border-bottom-width: 2.5px; border-radius: 6px; padding: 0 5px; }
.lab-help p { margin: 0 0 8px; }
.lab-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

/* ---------- code view ---------- */
.lab-code { width: 100%; border: 1px solid var(--lab-line); border-radius: 12px; overflow: hidden; background: var(--lab-code-bg); color: var(--lab-code-ink); }
.lab-code-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-bottom: 1px solid var(--lab-line); background: var(--lab-paper); }
.lab-code-dots { display: inline-flex; gap: 4px; }
.lab-code-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--lab-line); }
.lab-code-dots i:first-child { background: var(--lab-accent); opacity: 0.8; }
.lab-code-dots i:nth-child(2) { background: var(--lab-gold); opacity: 0.9; }
.lab-code-head { flex-wrap: wrap; }
.lab-code-file { flex: 1 1 150px; min-width: 0; font: 600 12px/1.2 var(--lab-mono); color: var(--lab-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-code-acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.lab-code-btn { display: inline-flex; align-items: center; gap: 5px; font: 600 12px/1 var(--lab-font); color: var(--lab-ink); background: var(--lab-paper); border: 1px solid var(--lab-line); border-radius: 8px; padding: 6px 9px; cursor: pointer; }
.lab-code-btn .lab-ico { width: 14px; height: 14px; }
.lab-code-btn:hover { border-color: var(--lab-ink); }
.lab-code-btn.primary { background: var(--lab-accent); border-color: var(--lab-accent); color: #fff; }
.lab-code-btn.done { border-color: var(--lab-good); color: var(--lab-good); }
.lab-code-btn:disabled { opacity: 0.5; cursor: default; }
.lab-code-body { font: 13px/1.6 var(--lab-mono); padding: 6px 0; overflow: auto; max-height: 340px; }
.lab .lab-code .cl-line { display: flex; gap: 0; width: 100%; min-width: max-content; border: 0; border-left: 3px solid transparent; background: none; color: inherit; font: inherit; text-align: left; padding: 0 12px 0 0; white-space: pre; cursor: default; }
.lab .lab-code button.cl-line { cursor: pointer; }
.lab .lab-code button.cl-line:hover { background: rgba(128, 112, 140, 0.1); }
.lab .lab-code .cl-line .n { flex: none; width: 3.2em; padding-right: 0.9em; text-align: right; color: var(--lab-code-gutter); user-select: none; }
.lab .lab-code .cl-line.run { background: rgba(255, 190, 0, 0.2); border-left-color: var(--lab-gold); }
.lab .lab-code .cl-line.run .n { color: var(--lab-gold-ink); font-weight: 700; }
.lab .lab-code .cl-line.err { background: rgba(202, 31, 63, 0.14); border-left-color: var(--lab-accent); }
.lab .lab-code .cl-line.ok { background: rgba(31, 138, 112, 0.16); border-left-color: var(--lab-good); }
.lab .lab-code .cl-line:focus-visible { outline: 3px solid var(--lab-gold); outline-offset: -3px; }
/* the highlighting (also used in the labs' own code boxes) */
.lab .tk-kw { color: var(--tk-kw); font-weight: 600; }
.lab .tk-type { color: var(--tk-type); }
.lab .tk-fn { color: var(--tk-fn); }
.lab .tk-num { color: var(--tk-num); }
.lab .tk-str { color: var(--tk-str); }
.lab .tk-com { color: var(--tk-com); font-style: italic; }
.lab .tk-pre { color: var(--tk-pre); }
.lab .tk-const { color: var(--tk-const); font-weight: 600; }
.lab pre.cb-code { background: var(--lab-code-bg); color: var(--lab-code-ink); border-radius: 8px; }

/* ---------- the panel's narrow layout (tablets and phones, in the page) ---------- */
@media (max-width: 899px) {
  .lab { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .lab-canvas { height: clamp(340px, 108vw, 62vh); }
  .lab-side { border-left: 0; border-top: 1px solid var(--lab-line); contain: none; overflow: visible; }
  .lab-info { max-height: none; }
  .lab-panes { flex: none; overflow: visible; }
  .lab-code-body { max-height: 300px; }
}

/* ---------- full screen (and the "theatre" where full screen is not allowed) ---------- */
:root .lab.lab-full { width: 100vw !important; height: 100vh; height: 100dvh; max-width: none; margin: 0 !important; border: 0; border-radius: 0; box-shadow: none; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 100%; background: var(--lab-paper); }
:root .lab.lab-theatre { position: fixed; inset: 0; z-index: 2147483000; }
:root .lab.lab-full .lab-canvas { grid-row: 1; grid-column: 1; height: 100%; }
:root .lab.lab-full .lab-side { grid-row: 1; grid-column: 2; width: 400px; height: 100%; max-height: none; contain: size; overflow: hidden; border-top: 0; border-left: 1px solid var(--lab-line); }
:root .lab.lab-full .lab-side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 4px 16px; font: 700 11.5px/1.2 var(--lab-font); text-transform: uppercase; letter-spacing: 0.12em; color: var(--lab-muted); }
:root .lab.lab-full .lab-side-head .lab-iconbtn { box-shadow: none; width: 34px; height: 34px; border-radius: 10px; }
:root .lab.lab-full .lab-info { max-height: 36%; }
:root .lab.lab-full .lab-panes { flex: 1 1 0; overflow: auto; }
:root .lab.lab-full.drawer-closed .lab-side { display: none; }
:root .lab.lab-full .lab-code-body { max-height: none; }
:root .lab.lab-full .cb-strip { display: grid; grid-template-columns: minmax(0, 1fr); border: 0; padding: 0; background: none; }
.lab:fullscreen { width: 100vw; height: 100vh; }
.lab::backdrop { background: var(--lab-paper, #fff); }
html.lab-theatre-on, html.lab-theatre-on body { overflow: hidden !important; }
@media (max-width: 759px) {
  /* on a phone the panel slides up over the bottom of the model */
  :root .lab.lab-full { grid-template-columns: minmax(0, 1fr); }
  :root .lab.lab-full .lab-side { position: absolute; grid-column: 1; grid-row: 1; top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 52%; z-index: 6; border-left: 0; border-top: 1px solid var(--lab-line); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.18); }
  :root .lab.lab-full .lab-info { max-height: 30%; }
  :root .lab.lab-full:not(.drawer-closed) .lab-viewbar { bottom: calc(52% + 10px); }
  :root .lab.lab-full:not(.drawer-closed) .lab-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) { .lab-callout-dot { animation: none; } .lab-callout, .lab-hint, .lab-toast { transition: none; } .lab-spin { animation-duration: 3s; } }
@media print { .lab, .view3d, .lab-skel, .nav-3d { display: none !important; } }

/* ---------- when there is no 3D ---------- */
.lab.lab-failed { grid-template-rows: auto; }
.lab.lab-failed .lab-side { display: none; }
.lab.lab-failed .lab-canvas { grid-column: 1 / -1; height: auto; min-height: 260px; }
.lab-nogl { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 36px 24px; max-width: 560px; margin: 0 auto; color: var(--lab-text); }
.lab-nogl .lab-ico { width: 54px; height: 54px; color: var(--lab-muted); stroke-width: 1.4; }
.lab-nogl b { font: 600 18px/1.3 var(--lab-display); color: var(--lab-ink); }
.lab-nogl p { margin: 0; font-size: 14.5px; }
.lab-nogl ul { text-align: left; margin: 4px 0 0; padding-left: 20px; font-size: 14px; color: var(--lab-muted); }

/* ---------- while the 3D bundle downloads ---------- */
.lab-skel { display: grid; place-items: center; height: clamp(300px, 46vw, 560px); margin: 0.8rem 0 0.4rem; border: 1px solid var(--lab-line); border-radius: 18px; background-color: var(--lab-paper); background-image: linear-gradient(var(--lab-grid) 1px, transparent 1px), linear-gradient(90deg, var(--lab-grid) 1px, transparent 1px); background-size: 28px 28px; color: var(--lab-muted); font-family: var(--lab-font); }
.lab-skel-in { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(340px, 80%); text-align: center; }
.lab-skel-cube { width: 54px; height: 54px; color: var(--lab-accent); animation: lab-bob 1.6s ease-in-out infinite; }
@keyframes lab-bob { 50% { transform: translateY(-6px) rotate(-6deg); } }
.lab-skel b { font: 600 16px/1.3 var(--lab-display); color: var(--lab-ink); }
.lab-skel .meter { height: 6px; }
.lab-skel .meter span { background: var(--lab-accent); }
.lab-skel .meter.busy span { width: 35% !important; animation: lab-busy 1.2s ease-in-out infinite; }
@keyframes lab-busy { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.lab-skel small { font-size: 12.5px; }
@media (max-width: 899px) { .lab-skel { border-radius: 0; border-left: 0; border-right: 0; height: clamp(300px, 100vw, 60vh); } }

/* ---------- "View in 3D" beside a wiring figure ---------- */
.view3d { margin: 0 0 0.5rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.view3d[hidden] { display: none; }
.view3d-btn { display: inline-flex; align-items: center; gap: 0.5em; font: 600 0.88rem/1.2 var(--lab-display, var(--display, "Outfit", Arial, sans-serif)); color: #fff; background: var(--plum, #24182e); border: 1.5px solid var(--plum, #24182e); border-radius: 999px; padding: 0.5rem 1.05rem; cursor: pointer; box-shadow: 0 6px 16px -8px rgba(36, 24, 46, 0.5); }
.view3d-btn::before { content: ""; width: 1.05em; height: 1.05em; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M12 2 21 7v10l-9 5-9-5V7z'/%3E%3Cpath d='M3 7l9 5 9-5M12 12v10'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M12 2 21 7v10l-9 5-9-5V7z'/%3E%3Cpath d='M3 7l9 5 9-5M12 12v10'/%3E%3C/svg%3E") center / contain no-repeat; }
.view3d-btn:hover { background: var(--red, #ca1f3f); border-color: var(--red, #ca1f3f); }
.view3d-btn[aria-pressed="true"], .view3d-btn[aria-expanded="true"] { background: var(--surface, #fff); color: var(--ink, #24182e); border-color: var(--line, #d3d9d3); box-shadow: none; }
.view3d-btn[aria-busy="true"] { cursor: progress; opacity: 0.7; }
.view3d-full { font: 600 0.82rem/1.2 var(--display, "Outfit", Arial, sans-serif); color: var(--ink-2, #3b3343); background: none; border: 1.5px solid var(--line, #e4dee9); border-radius: 999px; padding: 0.45rem 0.85rem; cursor: pointer; }
.view3d-full:hover { border-color: var(--ink, #24182e); color: var(--ink, #24182e); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .view3d-btn:not([aria-pressed="true"]):not([aria-expanded="true"]) { background: var(--gold, #ffbe00); border-color: var(--gold, #ffbe00); color: #24182e; }
}
:root[data-theme="dark"] .view3d-btn:not([aria-pressed="true"]):not([aria-expanded="true"]) { background: var(--gold, #ffbe00); border-color: var(--gold, #ffbe00); color: #24182e; }
figure.is-3d > svg, figure.is-3d > img { display: none; }
figure.wiring.is-3d { overflow: visible; }
figure.wiring .lab { min-width: 0; }

/* ---------- the "3D lab" pill in a band's section bar, and its menu ---------- */
nav[aria-label="Sections"] a.nav-3d { display: inline-flex; align-items: center; gap: 0.4em; font-weight: 600; color: #fff; background: var(--plum, #24182e); border-color: var(--plum, #24182e); padding-left: 0.6rem; }
nav[aria-label="Sections"] a.nav-3d::before { content: ""; width: 1.05em; height: 1.05em; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M12 2 21 7v10l-9 5-9-5V7z'/%3E%3Cpath d='M3 7l9 5 9-5M12 12v10'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M12 2 21 7v10l-9 5-9-5V7z'/%3E%3Cpath d='M3 7l9 5 9-5M12 12v10'/%3E%3C/svg%3E") center / contain no-repeat; }
nav[aria-label="Sections"] a.nav-3d:hover, nav[aria-label="Sections"] a.nav-3d:focus-visible, nav[aria-label="Sections"] a.nav-3d[aria-expanded="true"] { color: #fff; background: var(--red, #ca1f3f); border-color: var(--red, #ca1f3f); }
nav[aria-label="Sections"] a.nav-3d .n3 { font: 700 0.68rem/1 var(--text, Arial); background: rgba(255, 255, 255, 0.2); border-radius: 99px; padding: 0.18em 0.45em; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) nav[aria-label="Sections"] a.nav-3d { color: #24182e; background: var(--gold, #ffbe00); border-color: var(--gold, #ffbe00); }
  :root:not([data-theme="light"]) nav[aria-label="Sections"] a.nav-3d .n3 { background: rgba(36, 24, 46, 0.15); }
}
:root[data-theme="dark"] nav[aria-label="Sections"] a.nav-3d { color: #24182e; background: var(--gold, #ffbe00); border-color: var(--gold, #ffbe00); }
:root[data-theme="dark"] nav[aria-label="Sections"] a.nav-3d .n3 { background: rgba(36, 24, 46, 0.15); }

.lab-index { position: fixed; z-index: 60; width: min(360px, calc(100vw - 24px)); max-height: min(70vh, 520px); overflow: auto; background: var(--lab-paper); color: var(--lab-ink); border: 1px solid var(--lab-line); border-radius: 16px; box-shadow: 0 18px 50px -12px rgba(36, 24, 46, 0.45); padding: 8px; font-family: var(--lab-font); }
.lab-index[hidden] { display: none; }
.lab-index h2 { font: 700 11.5px/1.2 var(--lab-font); text-transform: uppercase; letter-spacing: 0.12em; color: var(--lab-muted); margin: 8px 10px 6px; }
.lab-index ul { list-style: none; margin: 0; padding: 0; }
.lab-index a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--lab-ink); text-decoration: none; font-size: 14px; line-height: 1.3; }
.lab-index a:hover, .lab-index a:focus-visible { background: var(--lab-tint); outline: none; }
.lab-index a:focus-visible { box-shadow: inset 0 0 0 2px var(--lab-gold); }
.lab-index .ix-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--lab-tint); color: var(--lab-ink); }
.lab-index .ix-ico svg { width: 18px; height: 18px; }
.lab-index .ix-main .ix-ico { background: var(--lab-plum); color: #fff; }
.lab-index small { display: block; font-size: 12px; color: var(--lab-muted); }
.lab-index .ix-all { border-top: 1px solid var(--lab-line); margin-top: 6px; padding-top: 6px; }
.lab-moved .lab-btn { display: inline-flex; align-items: center; gap: 6px; }
.lab-moved .lab-btn .lab-ico { width: 15px; height: 15px; }
