/* ============================================================
   instrument.css — the shared "optical bench" design system.

   Used by every interactive playground on this blog (camera
   geometry, colour science, …). Page-specific rules live in a
   companion stylesheet that @imports this one.

   Visual language: a calibrated instrument. Hairline rules,
   tabular numerics, phosphor accents, no decoration that isn't
   carrying information. Channel A is always cyan, channel B always
   amber, error always red — that mapping never varies, so colour
   alone tells you what you're looking at.

   Everything is scoped to .cam so it cannot leak into the rest of
   the blog. (The `cam-` prefix is historical — it started life on
   the camera page — but the rules here are page-agnostic. Treat it
   as short for "canvas bench", and don't rename it without
   updating every playground that ships with it.)

   Theme follows the site's data-theme attribute.
   ============================================================ */

:root,
[data-theme="light"] {
  --cam-bg:        #f6f7f9;
  --cam-panel:     #ffffff;
  --cam-panel-2:   #f0f2f5;
  --cam-sunk:      #e9ecf1;
  --cam-ink:       #0c1017;
  --cam-soft:      #47536a;
  --cam-muted:     #8993a6;
  --cam-rule:      #e0e4ea;
  --cam-rule-hard: #c7cedb;
  --cam-a:         #0a7ea4;
  --cam-a-soft:    rgba(10, 126, 164, 0.12);
  --cam-b:         #b4600a;
  --cam-b-soft:    rgba(180, 96, 10, 0.12);
  --cam-err:       #cf2a3f;
  --cam-err-soft:  rgba(207, 42, 63, 0.12);
  --cam-good:      #06845c;
  --cam-glow:      none;
  --cam-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --cam-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  --cam-bg:        #06080c;
  --cam-panel:     #0c1118;
  --cam-panel-2:   #111823;
  --cam-sunk:      #080c12;
  --cam-ink:       #dfe7f2;
  --cam-soft:      #94a1b5;
  --cam-muted:     #58657a;
  --cam-rule:      #1b2431;
  --cam-rule-hard: #2b3747;
  --cam-a:         #4cc9f0;
  --cam-a-soft:    rgba(76, 201, 240, 0.14);
  --cam-b:         #ffb454;
  --cam-b-soft:    rgba(255, 180, 84, 0.14);
  --cam-err:       #ff5470;
  --cam-err-soft:  rgba(255, 84, 112, 0.14);
  --cam-good:      #5fe3a1;
  --cam-glow:      0 0 12px rgba(76, 201, 240, 0.25);
}

/* ============================================================
   Shell
   ============================================================ */

.cam {
  background: var(--cam-bg);
  color: var(--cam-ink);
  font-family: var(--cam-sans);
  font-size: 15px;
  line-height: 1.6;
  margin: 2rem 0 3rem;
  padding: 0 0 3rem;
  border-top: 1px solid var(--cam-rule-hard);
  border-bottom: 1px solid var(--cam-rule-hard);
  --cam-max: 1180px;
}

.cam *,
.cam *::before,
.cam *::after { box-sizing: border-box; }

.cam-inner {
  max-width: var(--cam-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.cam ::selection { background: var(--cam-a-soft); }

/* Numbers are read by comparison here, so lock the column widths. */
.cam [data-num],
.cam .cam-mono {
  font-family: var(--cam-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* ============================================================
   Masthead
   ============================================================ */

.cam-masthead {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 1rem;
  padding: 2.25rem 0 1rem;
  border-bottom: 1px solid var(--cam-rule-hard);
  margin-bottom: 2.5rem;
}

.cam-masthead .rule-label {
  font-family: var(--cam-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cam-muted);
  margin: 0 0 0.4rem;
}

.cam-masthead h2 {
  font-size: clamp(1.4rem, 3.4vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 600;
}

.cam-masthead .cam-serial {
  font-family: var(--cam-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--cam-muted);
  text-align: right;
  white-space: nowrap;
}

/* ============================================================
   The governing equation
   ============================================================ */

.cam-relation {
  background: var(--cam-panel);
  border: 1px solid var(--cam-rule);
  border-radius: 3px;
  padding: 2rem 1.5rem 1.25rem;
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}

.cam-relation::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: linear-gradient(180deg, var(--cam-a), transparent);
}

/* Spacing between the equation's terms comes from this gap, not from
   LaTeX \; thin-spaces. A CMS round-trip strips the backslash out of
   `\;` and silently turns the maths into stray semicolons; a flex gap
   cannot be damaged that way. */
.cam-relation-eq {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.1em 0.3em;
  text-align: center;
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  padding: 0.5rem 0 1.25rem;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Each symbol in the equation is hoverable and cross-links to its bay. */
.cam-sym {
  cursor: pointer;
  border-radius: 2px;
  padding: 0.1em 0.15em;
  transition: background 0.15s ease, color 0.15s ease;
  border-bottom: 1px dashed var(--cam-rule-hard);
}
.cam-sym:hover,
.cam-sym.is-on {
  background: var(--cam-a-soft);
  color: var(--cam-a);
  border-bottom-color: transparent;
}

.cam-relation-key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 0;
  border-top: 1px solid var(--cam-rule);
}

.cam-key-item {
  padding: 0.85rem 0.9rem;
  border-right: 1px solid var(--cam-rule);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--cam-soft);
  transition: background 0.15s ease;
}
.cam-key-item:last-child { border-right: none; }
.cam-key-item.is-on { background: var(--cam-a-soft); }
.cam-key-item b {
  display: block;
  font-family: var(--cam-mono);
  font-size: 0.82rem;
  color: var(--cam-ink);
  margin-bottom: 0.2rem;
  font-weight: 600;
}

/* ============================================================
   Bay — one lesson module
   ============================================================ */

.cam-bay {
  margin: 0 0 4.5rem;
  scroll-margin-top: 2rem;
}

.cam-bay-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--cam-rule-hard);
  margin-bottom: 0.9rem;
}

.cam-bay-id {
  font-family: var(--cam-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--cam-a);
  white-space: nowrap;
}

.cam-bay-name {
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.3;
}

.cam-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--cam-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cam-muted);
  border: 1px solid var(--cam-rule);
  border-radius: 2px;
  padding: 0.16rem 0.45rem;
  white-space: nowrap;
}
.cam-chip .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cam-muted);
}
.cam-chip.live { color: var(--cam-a); border-color: color-mix(in srgb, var(--cam-a) 35%, transparent); }
.cam-chip.live .dot { background: var(--cam-a); box-shadow: var(--cam-glow); animation: cam-pulse 2.4s ease-in-out infinite; }

@keyframes cam-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .cam-chip.live .dot { animation: none; }
}

.cam-note {
  color: var(--cam-soft);
  font-size: 0.9rem;
  line-height: 1.65;
  margin: 0 0 1.15rem;
  max-width: 68ch;
}
.cam-note strong { color: var(--cam-ink); font-weight: 600; }
.cam-note code {
  font-family: var(--cam-mono);
  font-size: 0.86em;
  background: var(--cam-panel-2);
  border: 1px solid var(--cam-rule);
  border-radius: 2px;
  padding: 0.05em 0.3em;
}

/* ============================================================
   Rig — the stage + control-rail layout
   ============================================================ */

.cam-rig {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: 1px;
  background: var(--cam-rule);
  border: 1px solid var(--cam-rule);
  border-radius: 3px;
  overflow: hidden;
}

.cam-rig.wide-rail { grid-template-columns: minmax(0, 1fr) 340px; }
.cam-rig.no-rail   { grid-template-columns: minmax(0, 1fr); }

@media (max-width: 900px) {
  .cam-rig,
  .cam-rig.wide-rail { grid-template-columns: minmax(0, 1fr); }
}

/* --- stage --- */

.cam-stage {
  background: var(--cam-sunk);
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cam-stage.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--cam-rule);
}

@media (max-width: 620px) {
  .cam-stage.split { grid-template-columns: 1fr; }
}

.cam-pane {
  position: relative;
  background: var(--cam-sunk);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cam-pane-label {
  position: absolute;
  top: 8px; left: 10px;
  z-index: 3;
  font-family: var(--cam-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cam-muted);
  pointer-events: none;
  background: color-mix(in srgb, var(--cam-sunk) 82%, transparent);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
}
.cam-pane-label.a { color: var(--cam-a); }
.cam-pane-label.b { color: var(--cam-b); }

.cam-pane-corner {
  position: absolute;
  top: 8px; right: 10px;
  z-index: 3;
  font-family: var(--cam-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--cam-muted);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* Height comes from the aspect-ratio class below, never from the
   parent — these canvases live in flex columns that have no
   intrinsic height, so `height: 100%` would collapse them to zero
   and the painters would never fire. */
.cam-stage canvas,
.cam-pane canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

/* Aspect boxes, so canvases reserve height before JS measures them. */
.cam-ar-4-3  { aspect-ratio: 4 / 3; }
.cam-ar-1-1  { aspect-ratio: 1 / 1; }
.cam-ar-16-9 { aspect-ratio: 16 / 9; }
.cam-ar-3-2  { aspect-ratio: 3 / 2; }

/* --- control rail --- */

.cam-rail {
  background: var(--cam-panel);
  padding: 0.9rem 0.95rem 1.1rem;
  overflow-y: auto;
  max-height: 640px;
  min-width: 0;
}

.cam-rail-group + .cam-rail-group { margin-top: 1.15rem; }

.cam-rail-title {
  font-family: var(--cam-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cam-muted);
  padding-bottom: 0.35rem;
  margin: 0 0 0.6rem;
  border-bottom: 1px solid var(--cam-rule);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.cam-rail-title .accent-a { color: var(--cam-a); }
.cam-rail-title .accent-b { color: var(--cam-b); }

/* ============================================================
   Controls
   ============================================================ */

.cam-ctl {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.15rem 0.5rem;
  margin-bottom: 0.55rem;
}

.cam-ctl-label {
  font-size: 0.74rem;
  color: var(--cam-soft);
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  min-width: 0;
}
.cam-ctl-label .sym {
  font-family: var(--cam-mono);
  color: var(--cam-ink);
  font-weight: 600;
}
.cam-ctl-label .unit { color: var(--cam-muted); font-size: 0.68rem; }

.cam-ctl-val {
  font-family: var(--cam-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  color: var(--cam-a);
  text-align: right;
  white-space: nowrap;
}

.cam-ctl input[type="range"] { grid-column: 1 / -1; }

/* Range input, restyled to a machined slider. */
.cam input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
.cam input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--cam-rule-hard);
  border-radius: 1px;
}
.cam input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--cam-rule-hard);
  border-radius: 1px;
}
.cam input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--cam-panel);
  border: 2px solid var(--cam-a);
  box-shadow: var(--cam-glow);
  transition: transform 0.12s ease;
}
.cam input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--cam-panel);
  border: 2px solid var(--cam-a);
  box-shadow: var(--cam-glow);
}
.cam input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.18); }
.cam input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--cam-a); outline-offset: 2px; }

/* A rail marked .rail-b drives camera B, so its controls go amber. */
.cam .rail-b input[type="range"]::-webkit-slider-thumb { border-color: var(--cam-b); box-shadow: none; }
.cam .rail-b input[type="range"]::-moz-range-thumb { border-color: var(--cam-b); box-shadow: none; }
.cam .rail-b .cam-ctl-val { color: var(--cam-b); }

/* Buttons */
.cam-btn {
  font-family: var(--cam-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cam-ink);
  background: var(--cam-panel-2);
  border: 1px solid var(--cam-rule-hard);
  border-radius: 2px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}
.cam-btn:hover { border-color: var(--cam-a); color: var(--cam-a); }
.cam-btn:active { transform: translateY(1px); }
.cam-btn:focus-visible { outline: 2px solid var(--cam-a); outline-offset: 2px; }
.cam-btn.primary { border-color: var(--cam-a); color: var(--cam-a); background: var(--cam-a-soft); }
.cam-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.cam-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

/* Segmented control */
.cam-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--cam-rule-hard);
  border-radius: 2px;
  overflow: hidden;
}
.cam-seg button {
  font-family: var(--cam-mono);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.4rem 0.3rem;
  background: var(--cam-panel-2);
  color: var(--cam-soft);
  border: none;
  border-right: 1px solid var(--cam-rule-hard);
  cursor: pointer;
  transition: all 0.14s ease;
}
.cam-seg button:last-child { border-right: none; }
.cam-seg button:hover { color: var(--cam-ink); }
.cam-seg button[aria-pressed="true"] {
  background: var(--cam-a);
  color: var(--cam-bg);
  font-weight: 600;
}

/* Checkbox row */
.cam-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.74rem;
  color: var(--cam-soft);
  cursor: pointer;
  padding: 0.2rem 0;
  user-select: none;
}
.cam-check input { accent-color: var(--cam-a); cursor: pointer; margin: 0; }
.cam-check:hover { color: var(--cam-ink); }

/* ============================================================
   Matrix readouts
   ============================================================ */

.cam-mat-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.cam-mat-name {
  font-family: var(--cam-mono);
  font-size: 0.8rem;
  color: var(--cam-ink);
  font-weight: 600;
  white-space: nowrap;
}

/* Bracketed grid. The brackets are borders on ::before/::after so
   they scale with the content instead of being glyphs. */
.cam-mat {
  display: inline-grid;
  gap: 0.1rem 0.55rem;
  padding: 0.4rem 0.5rem;
  position: relative;
  font-family: var(--cam-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.73rem;
  line-height: 1.5;
}
.cam-mat::before,
.cam-mat::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 5px;
  border: 1px solid var(--cam-rule-hard);
}
.cam-mat::before { left: 0;  border-right: none; }
.cam-mat::after  { right: 0; border-left: none; }

.cam-mat span {
  text-align: right;
  color: var(--cam-ink);
  padding: 0 0.1rem;
  border-radius: 2px;
  transition: background 0.4s ease, color 0.4s ease;
}
.cam-mat span.zero { color: var(--cam-muted); }
/* Flash a cell when its value changes — makes cause and effect legible. */
.cam-mat span.hot {
  background: var(--cam-a-soft);
  color: var(--cam-a);
  transition: background 0s, color 0s;
}
.cam-mat.tone-b span.hot { background: var(--cam-b-soft); color: var(--cam-b); }

/* Partitioned [R | t] gets a divider before the last column. */
.cam-mat.partition span:nth-child(4n) {
  border-left: 1px solid var(--cam-rule-hard);
  padding-left: 0.5rem;
  margin-left: 0.1rem;
}

/* ============================================================
   Readouts / stat strips
   ============================================================ */

.cam-readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  border-top: 1px solid var(--cam-rule);
  border-left: 1px solid var(--cam-rule);
  background: var(--cam-panel);
}

.cam-stat {
  padding: 0.55rem 0.65rem;
  border-right: 1px solid var(--cam-rule);
  border-bottom: 1px solid var(--cam-rule);
  min-width: 0;
}
.cam-stat .k {
  display: block;
  font-family: var(--cam-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cam-muted);
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cam-stat .v {
  font-family: var(--cam-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  color: var(--cam-ink);
  white-space: nowrap;
}
.cam-stat .v small { font-size: 0.66rem; color: var(--cam-muted); margin-left: 0.15rem; }
.cam-stat.accent .v { color: var(--cam-a); }
.cam-stat.warn .v   { color: var(--cam-b); }
.cam-stat.bad .v    { color: var(--cam-err); }
.cam-stat.good .v   { color: var(--cam-good); }

/* Error bar that fills as reprojection error grows. */
.cam-meter {
  height: 3px;
  background: var(--cam-rule);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.35rem;
}
.cam-meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--cam-good);
  transition: width 0.2s ease, background 0.2s ease;
}

/* ============================================================
   Point table
   ============================================================ */

.cam-tablewrap {
  max-height: 210px;
  overflow: auto;
  border-top: 1px solid var(--cam-rule);
  background: var(--cam-panel);
}

.cam-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--cam-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.7rem;
}
.cam-table th {
  position: sticky;
  top: 0;
  background: var(--cam-panel-2);
  color: var(--cam-muted);
  font-weight: 500;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: right;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--cam-rule-hard);
  white-space: nowrap;
  z-index: 2;
}
.cam-table th:first-child,
.cam-table td:first-child { text-align: left; }
.cam-table td {
  padding: 0.3rem 0.55rem;
  text-align: right;
  border-bottom: 1px solid var(--cam-rule);
  color: var(--cam-ink);
  white-space: nowrap;
}
.cam-table tr.out td { color: var(--cam-muted); }
.cam-table tr.behind td { color: var(--cam-err); }
.cam-table tr.hl td { background: var(--cam-a-soft); }
.cam-table .swatch {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: baseline;
}
.cam-table tbody tr { transition: background 0.12s ease; }
.cam-table tbody tr:hover td { background: var(--cam-panel-2); }

/* ============================================================
   Legend + captions
   ============================================================ */

.cam-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.55rem 0.75rem;
  background: var(--cam-panel);
  border-top: 1px solid var(--cam-rule);
  font-family: var(--cam-mono);
  font-size: 0.64rem;
  color: var(--cam-soft);
}
.cam-legend i {
  display: inline-block;
  width: 9px; height: 2px;
  vertical-align: middle;
  margin-right: 0.35rem;
}
.cam-legend .sq {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  vertical-align: baseline;
  margin-right: 0.35rem;
}

.cam-caption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--cam-mono);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  color: var(--cam-muted);
  margin: 0.55rem 0 0;
}

/* ============================================================
   Takeaway callout
   ============================================================ */

.cam-takeaway {
  margin-top: 1rem;
  padding: 0.8rem 1rem 0.85rem 1.1rem;
  background: var(--cam-panel);
  border: 1px solid var(--cam-rule);
  border-left: 2px solid var(--cam-a);
  border-radius: 0 3px 3px 0;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--cam-soft);
}
.cam-takeaway b {
  color: var(--cam-ink);
  font-family: var(--cam-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.3rem;
  color: var(--cam-a);
}
.cam-takeaway em { color: var(--cam-ink); font-style: italic; }

/* ============================================================
   Try-this prompts — small guided experiments
   ============================================================ */

.cam-try {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.3rem;
}
.cam-try li {
  font-size: 0.8rem;
  color: var(--cam-soft);
  padding-left: 1.4rem;
  position: relative;
  line-height: 1.55;
}
.cam-try li::before {
  content: "▸";
  position: absolute;
  left: 0.35rem;
  color: var(--cam-a);
  font-size: 0.7rem;
}
.cam-try button {
  font: inherit;
  font-family: var(--cam-mono);
  font-size: 0.76rem;
  background: none;
  border: none;
  border-bottom: 1px dashed var(--cam-a);
  color: var(--cam-a);
  padding: 0;
  cursor: pointer;
}
.cam-try button:hover { border-bottom-style: solid; }

/* ============================================================
   Bay navigation strip
   ============================================================ */

.cam-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--cam-bg) 92%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--cam-rule);
  margin-bottom: 2rem;
}
.cam-nav ol {
  max-width: var(--cam-max);
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  list-style: none;
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.cam-nav ol::-webkit-scrollbar { display: none; }
.cam-nav a {
  display: block;
  font-family: var(--cam-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  color: var(--cam-muted);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.14s ease;
}
.cam-nav a:hover { color: var(--cam-ink); background: var(--cam-panel-2); }
.cam-nav a.is-on {
  color: var(--cam-a);
  border-color: color-mix(in srgb, var(--cam-a) 35%, transparent);
  background: var(--cam-a-soft);
}

/* ============================================================
   Misc
   ============================================================ */

.cam-end {
  text-align: center;
  font-family: var(--cam-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cam-muted);
  padding-top: 1.5rem;
  border-top: 1px solid var(--cam-rule);
  margin-top: 1rem;
}

.cam-hint {
  font-family: var(--cam-mono);
  font-size: 0.62rem;
  color: var(--cam-muted);
  text-align: center;
  padding: 0.35rem;
  background: var(--cam-panel);
  border-top: 1px solid var(--cam-rule);
}

/* KaTeX sizing inside the instrument, so display math doesn't
   blow out the panel width on small screens. */
.cam .katex { font-size: 1em; }
.cam .katex-display { margin: 0; overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0; }

/* The blog's post-body adds vertical rhythm we don't want here. */
.post-body .cam p { margin: 0 0 1rem; }
.post-body .cam h3 { margin: 0; }
.post-body .cam ul { margin: 0; }

/* ============================================================
   Breakout

   The surrounding prose wants a reading column; the bench wants
   room for two panes plus a control rail. Give each what it needs
   rather than splitting the difference.
   ============================================================ */

.post-body > p,
.post-body > h2,
.post-body > ul {
  max-width: 68ch;
  margin-left: auto;
  margin-right: auto;
}

.post-body .cam {
  width: min(100vw, 1400px);
  margin-left: calc(50% - min(50vw, 700px));
  margin-right: calc(50% - min(50vw, 700px));
}

/* Below the breakout width the negative margins would overflow, so
   fall back to a plain full-width block. */
@media (max-width: 1100px) {
  .post-body .cam {
    width: auto;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }
}

/* ============================================================
   Narrow screens
   ============================================================ */

@media (max-width: 680px) {
  .cam { font-size: 14px; }
  .cam-inner { padding: 0 1rem; }

  /* Coordinate triples like "(3.20, 2.40, 6.00)" are wider than a
     stat tile at this size. Left nowrap they push the whole page
     sideways, so let them break instead. */
  .cam-stat .v {
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 0.84rem;
  }

  .cam-rail { max-height: none; }
  .cam-masthead { grid-template-columns: 1fr; }
  .cam-masthead .cam-serial { text-align: left; }
  .cam-relation { padding: 1.25rem 1rem 0.75rem; }
  .cam-mat { font-size: 0.66rem; gap: 0.1rem 0.4rem; }
}
