/* The Binding Problem. Layout: title with the experiments; the controls (scheme, dots, toggles, coarse settings);
   the plane beside the code reader and the cost card; then the response unit and the many-pairs test with the
   scaling chart. Changing text has a fixed size, so nothing moves. */
:root {
  color-scheme: dark;
  --bg: #080c14;
  --panel: #0d131e;
  --panel-2: #131b29;
  --line: #1b2536;
  --line-2: #2a3850;
  --fg: #e3e9f3;
  --muted: #8c98ad;
  --dim: #58647a;
  --cyan: #00f5ff;
  --amber: #ffb800;
  --mag: #ff2a6d;
  --green: #34f5a0;
  --display: "Literata", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--sans); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.app { display: grid; gap: 12px; padding-block: 12px 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.eyebrow { font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 4px 0 0; font: 600 24px/1.15 var(--display); text-wrap: balance; }
h1 span { display: block; margin-top: 3px; font: 400 13px/1.3 var(--sans); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 12.5px var(--sans); padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; transition: border-color .15s, color .15s; }
.chip:hover { border-color: var(--cyan); }
.chip.on { border-color: var(--cyan); color: var(--cyan); background: rgba(0,245,255,.07); }
.note { margin: 0; font-size: 13.5px; color: #c6cfdf; max-width: 135ch; min-height: calc(3 * 1.45em); }

.btn { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r); padding: 4px 9px; min-height: 30px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; transition: border-color .15s; white-space: nowrap; }
.btn:hover { border-color: var(--cyan); }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 14px; height: 14px; flex: none; }
.btn.sm { min-height: 26px; padding: 2px 9px; font-size: 12px; }
.btn.primary { background: rgba(0,245,255,.09); border-color: rgba(0,245,255,.5); color: var(--cyan); }
.btn.amber { border-color: rgba(255,184,0,.55); color: var(--amber); background: rgba(255,184,0,.07); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; flex: none; }
.segb { background: var(--panel-2); border: 0; padding: 4px 10px; font: 12.5px var(--mono); cursor: pointer; color: var(--muted); white-space: nowrap; }
.segb + .segb { border-left: 1px solid var(--line-2); }
.segb.on { background: rgba(0,245,255,.12); color: var(--cyan); }

.card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 10px 12px 12px; display: grid; gap: 8px; min-width: 0; align-content: start; }
.card > * { min-width: 0; }
.card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.sec-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0; font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.sec-h em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--dim); }
.cap { margin: 0; font: 11.5px/1.45 var(--mono); color: var(--dim); }
.tag { display: inline-block; white-space: nowrap; font: 500 11.5px/15px var(--mono); min-height: 23px; color: var(--muted); padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.tag:empty { visibility: hidden; }
canvas { display: block; max-width: 100%; width: 100%; border-radius: 6px; border: 1px solid var(--line); background: #05080e; }

.tr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.sl { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.sl input { width: 110px; }
.sl.grow { flex: 1; min-width: 260px; }
.sl.grow input { width: auto; flex: 1; }
.sl b { font: 500 12.5px var(--mono); min-width: 5ch; color: var(--cyan); font-variant-numeric: tabular-nums; }
.tg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.tg input { accent-color: var(--amber); }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 18px; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: var(--fg); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--cyan); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--fg); border: 2px solid var(--bg); }

.main { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 12px; align-items: start; }
#cvPlane { height: 640px; cursor: grab; touch-action: none; }
.side { display: grid; gap: 12px; min-width: 0; }
.coarse-only { display: inline-flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.coarse-only.off { opacity: .35; pointer-events: none; }
#cvCode { height: 92px; }
.hyp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.hyp span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hyp b { font-weight: 600; text-align: right; white-space: nowrap; }
.hyp .ok { color: var(--green); } .hyp .bad { color: var(--mag); } .hyp .na { color: var(--dim); }
#readCap { height: calc(4 * 1.45em); overflow: hidden; }
.tag.good { color: var(--green); border-color: rgba(52,245,160,.5); }
.tag.bad { color: var(--mag); border-color: rgba(255,42,109,.55); }
.tag.warn { color: var(--amber); border-color: rgba(255,184,0,.5); }
.info { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(0, 1fr)); gap: 4px 10px; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.info span { color: var(--dim); font-size: 11px; }
.info b { font-weight: 500; text-align: right; white-space: nowrap; }
.info b.l { text-align: left; color: var(--muted); }
.info .cur { color: var(--cyan); }

.lower { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.rbox { display: grid; gap: 8px; min-height: 300px; align-content: start; }
.wrow { display: grid; grid-template-columns: 70px minmax(0, 1fr) 56px; gap: 8px; align-items: center; font: 12px var(--mono); color: var(--muted); }
.wrow b { text-align: right; color: var(--fg); font-weight: 500; font-variant-numeric: tabular-nums; }
.wrow input { width: 100%; }
.cases { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); gap: 3px 10px; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.cases span { color: var(--dim); font-size: 11px; }
.cases b { font-weight: 500; text-align: right; white-space: nowrap; }
.cases b.l { text-align: left; }
.cases .ok { color: var(--green); } .cases .bad { color: var(--mag); }
.proof { font: 12px/1.6 var(--mono); color: #c6cfdf; border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; background: var(--panel-2); }
.proof b { color: var(--amber); font-weight: 500; }
.bars { height: 70px; }
#rCap { height: calc(3 * 1.45em); overflow: hidden; }
.mc { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 4px 10px; font: 12px var(--mono); font-variant-numeric: tabular-nums; min-height: 92px; align-content: start; }
.mc span { color: var(--dim); font-size: 11px; }
.mc b { font-weight: 500; text-align: right; white-space: nowrap; }
.mc b.l { text-align: left; color: var(--muted); }
#cvScale { height: 200px; }
#mcCap { height: calc(2 * 1.45em); overflow: hidden; }
#scaleCap { height: calc(3 * 1.45em); overflow: hidden; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 18px; margin: 0; }

@media (max-width: 1200px) {
  .main, .lower { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
}
@media (max-width: 720px) {
  h1 { font-size: 20px; }
  #cvPlane { height: 420px; }
  .sl input { width: 90px; }
  .note { min-height: 0; }
}
.pg-embedded .top > div:first-child { display: none; }
@media (prefers-reduced-motion: reduce) { .btn, .chip { transition: none; } }
