/* PURPLE concept lab — page layout on top of lab/lab.css (tokens, type roles, buttons, badges, deltas: docs/DESIGN_SYSTEM.md).
   Three columns at 1440×900 / 1280×800, no page scroll: leaderboard + distance | hero car + progress | lineage + car sheet.
   Below 1200 px wide the columns stack and the page scrolls. Dark only. */
.clab-page { display: flex; flex-direction: column; }
.clab-page .top { flex: none; gap: 12px; }
.clab-page .top .sub { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.clab-page .top .spacer { flex: 1 1 0; min-width: 0; }
.top .back { flex: none; text-decoration: none; white-space: nowrap; }
.top .back:hover { color: var(--purple); }
#genBadge { flex: none; white-space: nowrap; min-width: 168px; text-align: center; }

/* controls */
.ctl { flex: none; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ctl .btn { min-width: 50px; }
.ctl #btnRun { min-width: 76px; }
.ctl .f { display: flex; align-items: center; gap: 5px; font: 500 11px/1 var(--sans); color: var(--muted); letter-spacing: .04em; }
.ctl input, .ctl select { background: #1a1a20; border: 1px solid var(--line); border-radius: var(--r); padding: 3px 6px; font: 500 12px/1.2 var(--mono); color: var(--text); }
.ctl input[type=number] { width: 64px; }
.ctl #seed { width: 58px; }
.ctl input:disabled { opacity: .5; }

/* frame */
.clab { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 25fr) minmax(0, 43fr) minmax(0, 32fr); gap: 12px; padding: 12px 12px 8px; }
.clab .col { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.ph { flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 12px 6px; border-bottom: 1px solid var(--line); min-width: 0; }
.ph .label { flex: none; }
.ph .src { min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf { flex: none; padding: 5px 12px 6px; border-top: 1px solid var(--line); font-size: 10px; line-height: 1.35; }
.empty { padding: 12px; font-family: var(--sans); color: var(--muted); font-size: 12px; line-height: 1.45; }
.warn { color: var(--amber); }
.muted { color: var(--muted); }
.flag { display: inline-block; padding: 0 4px; border: 1px solid; border-radius: 4px; font: 600 9px/1.35 var(--sans); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; cursor: help; }
.flag.green { color: var(--green); border-color: rgba(74, 222, 128, .5); }
.flag.amber { color: var(--amber); border-color: rgba(251, 191, 36, .5); }
.flag.muted { color: var(--muted); border-color: var(--line); }

/* ---- leaderboard */
.board { flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
.board .rows { flex: 1 1 auto; min-height: 0; overflow: hidden auto; padding: 3px 0; scrollbar-width: thin; }
.brow { display: grid; grid-template-columns: 22px 4px 40px minmax(0, 1fr) 52px 54px; gap: 0 7px; align-items: center; padding: 0 12px 0 8px; height: 17px; font-size: 11.5px; border-left: 2px solid transparent; }
.brow .pos { text-align: right; color: var(--muted); }
.brow .sw { width: 4px; height: 12px; border-radius: 1px; }
.brow .code { font-weight: 600; }
.brow .team { font: 400 11px/1.2 var(--sans); color: var(--muted); }
.brow .lap, .brow .gap { text-align: right; }
.brow .gap.flat { color: var(--muted); }
.brow.concept { background: rgba(178, 108, 255, .14); border-left-color: var(--purple); }
.brow.concept .code, .brow.concept .lap { color: var(--purple); }
.brow.concept .team { color: var(--text); }
.brow.concept .pos { color: var(--purple); font-weight: 600; }
.brow.base { color: var(--muted); font-style: italic; }
.brow.base .sw { border: 1px dashed var(--muted); width: 4px; }
.brow.base .code { font-weight: 500; }
.board .pf div + div { margin-top: 2px; }
.tag { display: inline-block; padding: 0 4px; border-radius: 3px; font: 600 9px/1.4 var(--sans); letter-spacing: .05em; text-transform: uppercase; border: 1px solid var(--line); }
.tag.real { color: var(--text); }
.tag.concept { color: var(--purple); border-color: var(--purple); }

/* ---- how different */
.dist { flex: 0 0 auto; display: flex; flex-direction: column; overflow: hidden; }
.dist-head { display: flex; align-items: center; gap: 12px; padding: 7px 12px 3px; }
.dist-head .big { color: var(--purple); font-size: 26px; white-space: nowrap; flex: none; }
.dist-head .dh-t { font: 500 12px/1.35 var(--sans); min-width: 0; }
.dist-rows { padding: 2px 0 8px; }
.drow { display: grid; grid-template-columns: 82px minmax(30px, 1fr) 36px 26px minmax(0, 1.25fr); gap: 0 6px; align-items: center; padding: 0 12px; height: 17px; font-size: 11px; }
.drow .dn { font: 500 11px/1 var(--sans); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drow .dbar { position: relative; height: 6px; background: #1a1a20; border-radius: 2px; overflow: hidden; }
.drow .dbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--purple); border-radius: 2px; transition: width var(--t-settle) var(--ease); }
.drow .dv { text-align: right; }
.drow .dc { font-size: 10px; text-align: right; }
.drow .dt { font-size: 10px; }
.drow.hi .dn { color: var(--amber); }
.drow.hi .dbar i { background: var(--amber); }

/* ---- hero */
.hero { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: radial-gradient(120% 90% at 50% 40%, #16161c 0%, var(--panel) 60%); }
#view3d { position: absolute; inset: 0; }
#view3d canvas { display: block; width: 100%; height: 100%; }
#view3d .view-wait { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); pointer-events: none; }
.plan { position: absolute; inset: 40px 12px 100px 12px; display: flex; flex-direction: column; }
.plan svg { flex: 1 1 auto; min-height: 0; width: 100%; }
.plan-note { flex: none; text-align: center; font-size: 10px; line-height: 1.4; margin-top: 2px; }
.plan .ghost { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; opacity: .75; }
.plan .ghost.el { opacity: .4; }
.plan .cur { fill: rgba(178, 108, 255, .10); stroke: var(--purple); stroke-width: 1.3; vector-effect: non-scaling-stroke; }
.plan .cur.floor { fill: rgba(178, 108, 255, .05); }
.plan .cur.wheel { fill: #1c1c22; stroke: #5a5a64; }
.plan .cur.wing { fill: rgba(178, 108, 255, .22); }
.plan .cur.el { stroke: rgba(178, 108, 255, .65); stroke-width: 1; }
.plan .cur.cockpit { fill: #0a0a0c; stroke: #5a5a64; }
.plan .cur.hi, .plan .ballast.hi { stroke: var(--amber); fill: rgba(251, 191, 36, .16); stroke-width: 2; }
.plan .ghost.cockpit { display: none; }
.plan .cog { fill: none; stroke: var(--text); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.plan .cogx { stroke: var(--text); stroke-width: 1; vector-effect: non-scaling-stroke; }
.plan .ballast { fill: rgba(232, 232, 236, .18); stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.plan .dim { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.plan .ptxt { fill: var(--muted); font: 500 110px var(--sans); }
.hero-tl { position: absolute; top: 10px; left: 12px; display: flex; gap: 6px; align-items: center; }
.hero-tr { position: absolute; top: 10px; right: 12px; max-width: 52%; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.hero-tr #heroModes { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hero-tr #heroModes:empty { display: none; }
.hero-tr .modes { display: flex; gap: 4px; }
.hero-tr .vlabel, .hero-tr .warn { font-size: 10px; }
.hero-bl { position: absolute; left: 12px; bottom: 10px; max-width: calc(100% - 24px); display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.hero-bl .src { pointer-events: auto; max-width: 100%; font-size: 10px; }
.kpis { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.kpi { display: flex; flex-direction: column; gap: 3px; }
.kpi .label { font-size: 10px; }
.kpi .big { font-size: 26px; }
.kpi .gv { white-space: nowrap; }
.kpi .of { color: var(--muted); font-size: 13px; }
.kpi-sub { font-size: 11px; color: var(--muted); }
.hero-chg { max-width: 100%; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; background: rgba(10, 10, 12, .72); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 9px; }
.hero-chg .label { font-size: 10px; }
.hero-chg .chg { font: 500 12px/1.35 var(--sans); max-width: 100%; }
.hero-chg .dotp { display: inline-block; width: 6px; height: 6px; border-radius: 1px; background: var(--amber); margin-right: 6px; vertical-align: middle; }
.hero-chg .delta { font-size: 12px; }

/* ---- progress chart */
.chart { flex: 0 0 214px; display: flex; flex-direction: column; overflow: hidden; }
.chart .legend { display: flex; gap: 10px; align-items: baseline; min-width: 0; overflow: hidden; white-space: nowrap; font: 500 10.5px/1 var(--sans); color: var(--muted); }
.chart .lg { display: inline-flex; align-items: center; gap: 4px; }
.chart .lg i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.chart .lg i.k { background: var(--purple); }
.chart .lg i.r { border: 1px solid var(--muted); }
.chart .lg i.x { background: var(--red); border-radius: 1px; width: 6px; height: 6px; }
.svgwrap { flex: 1 1 auto; min-height: 0; position: relative; }
.svgwrap svg { position: absolute; inset: 0; display: block; }
.svgwrap .grid { stroke: var(--line); stroke-width: 1; }
.svgwrap .ax { fill: var(--muted); font: 500 10px var(--mono); }
.svgwrap .ax.ttl, .svgwrap .ax.hint { font-family: var(--sans); }
.svgwrap .ref { stroke-width: 1; stroke-dasharray: 4 3; }
.svgwrap .ref.pole { stroke: var(--text); opacity: .55; }
.svgwrap .ref.base { stroke: var(--muted); }
.svgwrap .reft { fill: var(--muted); font: 500 10px var(--sans); }
.svgwrap .bestline { fill: none; stroke: var(--purple); stroke-width: 2; }
.svgwrap .kept { fill: var(--purple); stroke: var(--panel); stroke-width: 1; }
.svgwrap .rej { fill: none; stroke: var(--muted); stroke-width: 1; opacity: .75; }
.svgwrap .ill { stroke: var(--red); stroke-width: 1.2; fill: none; }

/* ---- lineage feed */
.feed { flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
.feed .lines { flex: 1 1 auto; min-height: 0; overflow: hidden auto; scrollbar-width: thin; }
.ln { padding: 5px 12px 6px; border-bottom: 1px solid var(--line); border-left: 2px solid transparent; animation: arrive var(--t-trace) var(--ease); }
.lines.fast .ln { animation: none; }
.ln.kept { border-left-color: var(--purple); background: rgba(178, 108, 255, .05); }
.ln.illegal { border-left-color: var(--red); }
.ln .l1 { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11.5px; }
.ln .l1 > * { flex: none; }
.ln .l1 .why { flex: 1 1 auto; text-align: right; font-size: 10px; }
.ln .g { color: var(--muted); width: 34px; }
.ln .lt { color: var(--muted); font-size: 11px; }
.ln .chgs { display: flex; flex-wrap: wrap; gap: 0 12px; margin-top: 2px; font: 500 11.5px/1.4 var(--sans); }
.ln .chgs .chg { min-width: 0; }
.ln.kept .chgs { color: var(--text); }
.ln:not(.kept) .chgs { color: #b9b9c2; }
.ln .hyp2 { font: 400 11px/1.35 var(--sans); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 1px; }
.ln .vios { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 4px; margin-top: 3px; }
.ln .vios .src { font-size: 10px; margin-right: 2px; }
.chip.vio { border-color: rgba(240, 80, 110, .55); color: var(--red); font-size: 10px; padding: 0 5px; cursor: help; }

/* ---- car sheet */
.sheet { flex: 0 0 auto; display: flex; flex-direction: column; overflow: hidden; }
.sheet .ph .src { display: flex; align-items: center; gap: 4px; font-size: 10px; }
.sheet-body { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.25fr); gap: 0 14px; padding: 6px 12px 8px; }
.mass .sub { margin-bottom: 3px; }
.mrow { display: grid; grid-template-columns: 62px minmax(16px, 1fr) 38px 32px; gap: 0 5px; align-items: center; height: 16px; font-size: 10.5px; }
.mrow .mn { font: 500 10.5px/1 var(--sans); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow .mv, .mrow .md { text-align: right; }
.mrow .md { font-size: 10px; }
.mbar { position: relative; height: 6px; background: #1a1a20; border-radius: 2px; }
.mbar i.cur { position: absolute; left: 0; top: 0; bottom: 0; background: var(--purple); border-radius: 2px; opacity: .85; transition: width var(--t-settle) var(--ease); }
.mbar i.ghost { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 1px dashed var(--text); opacity: .7; }
.mtot { margin-top: 5px; display: flex; flex-direction: column; gap: 2px; }
.mtot .src { font-size: 10px; }
.mbar.tot { height: 7px; background: rgba(232, 232, 236, .28); }
.mbar.tot i.parts { position: absolute; left: 0; top: 0; bottom: 0; background: var(--purple); border-radius: 2px 0 0 2px; }
.mbar.tot i.minl { position: absolute; top: -3px; bottom: -3px; border-left: 2px solid var(--green); }
.kvs { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1px 6px; align-items: center; align-content: start; font-size: 11px; }
.kvs .k { font: 500 10.5px/1.45 var(--sans); color: var(--muted); white-space: nowrap; }
.kvs .v { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kvs .u { color: var(--muted); font-size: 10px; }

/* ---- honest footer */
.honest { flex: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; padding: 0 12px 8px; font: 400 10.5px/1.4 var(--sans); color: var(--muted); }
.honest .label { color: var(--amber); font-size: 10px; }
.honest .txt { display: inline; }
.honest .sim { color: #a5a5ae; }

/* ---- 1280-class screens */
@media (max-width: 1365px) {
  .clab-page .top .sub { display: none; }
  .clab { grid-template-columns: minmax(0, 25fr) minmax(0, 42fr) minmax(0, 33fr); gap: 10px; padding: 10px 10px 6px; }
  .clab .col { gap: 10px; }
  .brow { height: 17px; font-size: 11px; grid-template-columns: 20px 4px 38px minmax(0, 1fr) 50px 52px; gap: 0 6px; }
  .kpis { gap: 14px; }
  .kpi .big { font-size: 22px; }
  .chart { flex-basis: 186px; }
  .drow { height: 16px; grid-template-columns: 76px minmax(24px, 1fr) 34px 24px minmax(0, 1.1fr); }
  .dist-head .big { font-size: 22px; }
  .sheet-body { gap: 0 10px; }
  .mrow { grid-template-columns: 58px minmax(16px, 1fr) 36px; height: 15px; }
  .mrow .md { display: none; }   /* the dashed ghost tick on each bar still shows the baseline */
  .ln .chgs { font-size: 11px; }
}
/* stacked under 1200 px */
@media (max-width: 1199px) {
  body.clab-page { overflow: auto; height: auto; }
  .clab-page .top { height: auto; flex-wrap: wrap; padding: 6px 12px; row-gap: 6px; }
  .ctl { flex-wrap: wrap; }
  .clab { grid-template-columns: 1fr; }
  .hero { min-height: 420px; }
  .board { min-height: 480px; }
  .feed { min-height: 420px; }
}
@media (max-width: 560px) {
  .sheet-body { grid-template-columns: 1fr; gap: 8px; }
  .hero-chg { display: none; }
  /* phone: the view-mode buttons sat on the "ghost = baseline" badge and the lap numbers on the car: stack them, car in between */
  .hero { min-height: 580px; }
  .hero-tr { top: 42px; max-width: calc(100% - 24px); }
  #view3d { top: 96px; bottom: 210px; }
}

/* ---- Mubit loop drawer (concept/lab/loop-panel.js, docs/concept/LOOP.md): over the lab, below the header, its own scroll */
.top .mubit-btn { flex: none; border-color: var(--mubit); color: var(--mubit); }
.top .mubit-btn.on { background: rgba(255, 69, 0, .14); }
.loopd { position: fixed; top: 40px; right: 0; bottom: 0; width: min(820px, 100vw); z-index: 20; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--mubit); box-shadow: -12px 0 32px rgba(0, 0, 0, .55); }
.loopd[hidden] { display: none; }
.loopd .ph .label { color: var(--mubit); }
.loop-ctl { flex: none; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.loop-ctl #loopIters, .loop-ctl #loopSeed { width: 64px; }
.loop-status { flex: none; padding: 6px 12px; border-bottom: 1px solid var(--line); white-space: normal; text-align: left; }
.loop-status .badge { margin-right: 6px; }
.loop-summary { flex: none; padding: 6px 12px; font-size: 12px; border-bottom: 1px solid var(--line); }
.loop-summary:empty { display: none; }
.loop-summary b { color: var(--purple); }
.loop-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.lcard { border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: var(--r); padding: 6px 8px 6px 10px; background: #15151a; font-size: 11.5px; }
.lcard.is-kept { border-left-color: var(--green); }
.lcard.is-rejected { border-left-color: var(--muted); }
.lc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.lc-k { font-weight: 700; color: var(--text); }
.lc-badges { display: flex; gap: 4px; margin-left: auto; }
.rid { font: 500 10.5px/1.2 var(--mono); color: var(--mubit); word-break: break-all; }
.lc-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.lc-sec { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lc-sec .label { margin-bottom: 2px; }
.lc-t { padding-left: 6px; border-left: 2px solid var(--line); }
.lc-t.last { border-left-color: var(--mubit); }
.lc-t .chg, .lc-prop .chg { color: var(--text); }
.lc-sec .seg { white-space: normal; }
.lc-hyp { font: 400 11px/1.35 var(--sans); color: var(--text); font-style: italic; white-space: normal; }
.lc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lc-meas .secs { display: flex; gap: 8px; flex-wrap: wrap; }
.lc-meas .ok { color: var(--green); font: 400 11px/1.3 var(--sans); }
.lc-meas .warn, .lc-prop .warn { font: 400 11px/1.3 var(--sans); }
.lc-exact summary { cursor: pointer; margin-top: 3px; }
.lc-exact pre { max-height: 260px; overflow: auto; margin: 4px 0 0; padding: 6px; background: #0d0d10; border: 1px solid var(--line); border-radius: 4px; font: 400 10px/1.35 var(--mono); white-space: pre-wrap; word-break: break-all; }
.lc-foot { margin-top: 4px; padding-top: 3px; border-top: 1px dashed var(--line); white-space: normal; }
.lc-foot .fed { color: var(--text); }
@media (max-width: 760px) { .lc-grid { grid-template-columns: minmax(0, 1fr); } .loopd { top: 0; } }
.loopd .ph .label { min-width: 0; flex: 1 1 auto; white-space: normal; }
.loopd .ph .btn.icon { flex: none; }
