/* Family Trees & Distributed Representations. Layout: title with the two networks; the query card (both family trees,
   the relationships, the readout and answers); the five-layer network beside the person space; then the receptive
   fields of figure 4 with the unit decoder, and the retraining card. Changing text has a fixed size. */
: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); }
.note { margin: 0; font-size: 13.5px; color: #c6cfdf; max-width: 135ch; }
.note b { color: var(--fg); }

select, .btn { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r); padding: 4px 9px; min-height: 30px; max-width: 100%; }
.btn { 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.sm { min-height: 24px; padding: 1px 8px; font-size: 11.5px; }
.btn.primary { background: rgba(0,245,255,.09); border-color: rgba(0,245,255,.5); color: var(--cyan); }
.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: 3px 9px; font: 12px 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); }
.seg.big .segb { padding: 6px 12px; font-size: 12.5px; }

.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-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; }
#netTag { white-space: normal; max-width: 100%; }
.tag.good { color: var(--green); border-color: rgba(52,245,160,.5); }
.tag.warn { color: var(--amber); border-color: rgba(255,184,0,.5); }
.card > * { min-width: 0; }
canvas { display: block; max-width: 100%; width: 100%; border-radius: 6px; border: 1px solid var(--line); background: #05080e; }

/* query */
.q-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: start; }
#cvTrees { height: 330px; cursor: pointer; }
.q-side { display: grid; gap: 8px; }
.rels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.rels button { padding: 5px 4px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--panel-2); font: 12px var(--mono); cursor: pointer; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rels button.on { border-color: var(--amber); color: var(--amber); background: rgba(255,184,0,.08); }
.rels button.none { opacity: .4; }
.readout { font: 600 15px var(--mono); padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout .p1 { color: var(--cyan); } .readout .r { color: var(--amber); } .readout .q { color: var(--dim); }
.readout .ho { font: 500 11px var(--mono); color: var(--mag); margin-left: 8px; }
.answers { display: grid; gap: 3px; font: 12px var(--mono); font-variant-numeric: tabular-nums; height: 128px; align-content: start; overflow: hidden; }
.answers .ar { display: grid; grid-template-columns: 96px minmax(0, 1fr) 46px 64px; gap: 8px; align-items: center; }
.answers .ar span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.answers .ar .t { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.answers .ar .t i { display: block; height: 100%; background: var(--cyan); }
.answers .ar b { text-align: right; font-weight: 500; }
.answers .ar em { font-style: normal; font-size: 11px; text-align: right; }
.answers .ar.right em { color: var(--green); } .answers .ar.wrong em { color: var(--mag); } .answers .ar.miss em { color: var(--amber); }
.answers .head { font-size: 11px; color: var(--dim); }
.answers .head span:first-child { grid-column: 1 / -1; color: var(--amber); }
.held { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font: 11.5px var(--mono); color: var(--dim); }
.held .btn.on { border-color: var(--mag); color: var(--mag); }

/* main */
.main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; align-items: start; }
#cvNet { height: 520px; cursor: pointer; background: #0a0e15; }
.map-wrap { position: relative; }
#cvMap { height: 470px; }
.tip { position: absolute; z-index: 2; pointer-events: none; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line-2); background: rgba(8,12,20,.96); font: 11.5px/1.5 var(--mono); white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.5); }
.tip b { color: var(--cyan); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); }
.row select { min-height: 26px; font-size: 12px; padding: 1px 4px; }
.row .cap { flex: 1; min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row select { min-width: 0; }
.row b { font: 500 12px var(--mono); color: var(--cyan); }

/* lower */
.lower { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 12px; align-items: start; }
#cvFields { height: 300px; cursor: pointer; background: #0a0e15; }
.role { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2fr); gap: 6px 10px; align-items: center; font: 12px var(--mono); min-height: 56px; }
.role .f { display: grid; gap: 2px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; }
.role .f span { color: var(--dim); font-size: 10.5px; }
.role .f b { font-weight: 600; font-variant-numeric: tabular-nums; }
.role .f.best { border-color: var(--amber); } .role .f.best b { color: var(--amber); }
.role p { margin: 0; font: 12px/1.45 var(--sans); color: #c6cfdf; height: calc(3 * 1.45em); overflow: hidden; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; 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); }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.prog { position: relative; height: 18px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel-2); overflow: hidden; }
.prog i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, rgba(0,245,255,.25), rgba(0,245,255,.55)); }
.prog span { position: relative; display: block; text-align: center; font: 11px/16px var(--mono); color: var(--muted); white-space: nowrap; }
#cvLoss { height: 120px; }
#trainCap { height: calc(4 * 1.45em); overflow: hidden; }

@media (max-width: 1200px) {
  .q-grid, .main, .lower { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  h1 { font-size: 20px; }
  .rels { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #cvNet { height: 420px; }
  #cvMap { height: 360px; }
  .role { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role p { grid-column: 1 / -1; }
}
.pg-embedded .top > div:first-child { display: none; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }
