/* Receptive Fields & Weight Decay. Layout: title with the presets; the figure 4 matrix beside the role decoder and
   the pair compare; the weight-decay console with its telemetry; then the sweep across lambda, the decay-gradient
   balance and the noise test. 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(2 * 1.45em); }
.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: 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.on { border-color: var(--amber); color: var(--amber); background: rgba(255,184,0,.08); }
.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); }

.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); }
.cap .k { font-size: 13px; }
.k.c { color: var(--cyan); } .k.a { color: var(--amber); } .k.w { color: #cbd5e1; }
.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; }
.tag.good { color: var(--green); border-color: rgba(52,245,160,.5); }
.tag.warn { color: var(--amber); border-color: rgba(255,184,0,.5); }
canvas { display: block; max-width: 100%; width: 100%; border-radius: 6px; border: 1px solid var(--line); background: #05080e; }

/* main */
.main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; align-items: start; }
.stage-wrap { position: relative; }
#cvMat { height: 380px; cursor: crosshair; background: #0a0e15; }
.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(--amber); }
#matCap { height: calc(2 * 1.45em); overflow: hidden; }
.side { display: grid; gap: 12px; min-width: 0; }
.focus { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.focus .btn { justify-content: center; font-size: 12px; }
.roles { display: grid; gap: 3px; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.roles .rr { display: grid; grid-template-columns: 54px repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center; padding: 2px 4px; border-radius: 4px; }
.roles .rr.h { color: var(--dim); font-size: 10.5px; }
.roles .rr.sel { background: rgba(255,184,0,.08); outline: 1px solid rgba(255,184,0,.4); }
.roles .rr b { font-weight: 500; text-align: right; }
.roles .rr b.hi { color: var(--amber); }
#roleCap { height: calc(4 * 1.45em); overflow: hidden; }
#cvPair { height: 150px; }
#pairCap { height: calc(2 * 1.45em); overflow: hidden; }
.card-h select { min-height: 26px; padding: 1px 4px; font-size: 12px; }

/* console */
.dial { display: grid; gap: 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.row b { font: 500 12.5px var(--mono); color: var(--cyan); font-variant-numeric: tabular-nums; }
#cvTicks { height: 26px; border: 0; background: transparent; }
.tiles { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.tiles div { border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 9px; background: var(--panel-2); display: grid; gap: 1px; min-width: 0; }
.tiles span { font: 10.5px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiles b { font: 600 18px/1.2 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tiles .good b { color: var(--green); } .tiles .warn b { color: var(--amber); } .tiles .bad b { color: var(--mag); }
.prog { position: relative; display: inline-block; width: 200px; height: 22px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel-2); overflow: hidden; vertical-align: middle; }
.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/20px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
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: 15px; height: 15px; margin-top: -5.5px; border-radius: 50%; background: var(--fg); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--amber); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--fg); border: 2px solid var(--bg); }

.lower { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
#cvSweep, #cvBal { height: 220px; }
#cvNoise { height: 150px; }
#balCap, #noiseCap { height: calc(3 * 1.45em); overflow: hidden; }

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