/* v3 invention cockpit — v1's theme + the floating-card cockpit layout.
   Stage = a live scorecard canvas with floating control/verdict cards + a candidate aside. */

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--paper); }
.small { font-size: .82rem; }
.muted { color: var(--muted); }
.divider { border: 0; border-top: 1px solid var(--hair); margin: .55rem 0; }

.nav { border-bottom: 1px solid var(--hair); background: var(--paper); }
.nav .wrap { max-width: none; margin: 0; padding: .55rem 1rem; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; text-decoration: none; color: var(--ink); }
.brand svg { width: 26px; height: 26px; color: var(--molecular); }
.nav-links { display: flex; align-items: center; gap: 1rem; }

.stage { display: grid; grid-template-columns: 1fr 330px; height: calc(100vh - 52px); }
.viewer { position: relative; overflow: hidden; background:
  radial-gradient(120% 120% at 30% 10%, #fbfbfd 0%, #f2f3f6 60%, #eceef2 100%); }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.overlay { position: absolute; z-index: 4; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border: 1px solid var(--hair); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: .75rem .85rem; }
.overlay.controls { top: 14px; left: 14px; width: 268px; max-height: calc(100% - 28px); overflow: auto; }
.overlay.verdict { top: 14px; right: 14px; width: 248px; }
.eyebrow { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--molecular); font-weight: 700; }
.overlay h3 { margin: .15rem 0 .5rem; font-family: var(--serif); font-weight: 500; font-size: 1.15rem; }

label.fld { display: block; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: .55rem 0 .2rem; }
select, input.txt { width: 100%; padding: .5rem .6rem; border: 1px solid var(--hair); border-radius: 10px;
  background: #fff; font-family: var(--sans); font-size: .85rem; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input.txt::placeholder { color: var(--faint); }
input.txt:hover, select:hover { border-color: #c9c9d4; }
input.txt:focus, select:focus { outline: none; border-color: var(--molecular); box-shadow: 0 0 0 3px rgba(99,91,255,.14); }
/* custom dropdown chevron — native one sits awkwardly far right; replace it */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 2.1rem; cursor: pointer; font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f6f78' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; text-overflow: ellipsis;
}
select:hover { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23635bff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }

.btn { display: block; width: 100%; text-align: center; padding: .5rem .6rem; border-radius: 8px; margin-top: .7rem;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 700; font-size: .86rem; cursor: pointer; }
.btn:hover { opacity: .9; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--hair); font-weight: 600; }
.btn.ghost:hover { border-color: var(--molecular); color: var(--molecular); }

.seg { display: flex; gap: 0; border: 1px solid var(--hair); border-radius: 8px; overflow: hidden; margin-top: .2rem; }
.seg button { flex: 1; padding: .34rem 0; border: 0; background: #fff; font-family: var(--sans); font-weight: 700; font-size: .82rem; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--hair); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--molecular); color: #fff; }
.tourn-row { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; font-size: .78rem; padding: .2rem 0; border-bottom: 1px dashed var(--hair); }
.tourn-row .ln { font-family: "JetBrains Mono", monospace; font-size: .7rem; color: var(--muted); }
.tourn-row .sc { font-family: "JetBrains Mono", monospace; font-weight: 700; }
.tourn-row .dot { width: 8px; height: 8px; border-radius: 50%; }
.tourn-row .dot.p { background: var(--ok); } .tourn-row .dot.f { background: var(--no); }

.statrow { display: flex; justify-content: space-between; align-items: baseline; font-size: .84rem; padding: .14rem 0; }
.statrow span { color: var(--muted); } .statrow b { font-family: "JetBrains Mono", monospace; font-size: .8rem; }
.pill { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; color: #fff; }
.pill.pass { background: var(--ok); } .pill.fail { background: var(--no); }
.fid { display: inline-block; font-size: .66rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--hair); color: var(--muted); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: .3rem; }
.tag { font-size: .64rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; color: #fff; }
.tag.bio { background: var(--molecular); } .tag.hw { background: var(--scanner); } .tag.sw { background: var(--ink-2); }
.tag.tpl { background: var(--template); } .tag.venv { background: var(--venv); }
.mono { font-family: "JetBrains Mono", monospace; font-size: .74rem; }

/* candidate aside */
.aside { border-left: 1px solid var(--hair); background: var(--paper-2); padding: .85rem; overflow: auto; }
.aside h4 { margin: .1rem 0 .3rem; font-family: var(--sans); font-weight: 700; font-size: .95rem; }
.kv { font-family: "JetBrains Mono", monospace; font-size: .72rem; color: var(--ink-2); display: flex; justify-content: space-between; gap: 1rem; padding: .12rem 0; border-bottom: 1px dashed var(--hair); }
.kv b { color: var(--ink); }
.list { margin: .3rem 0 .6rem; padding-left: 1.1rem; font-size: .8rem; color: var(--ink-2); }
.list li { margin: .12rem 0; }

.nav-btn { padding: .34rem .8rem; border: 1px solid var(--hair); background: #fff; border-radius: 999px;
  font-family: var(--sans); font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink); }
.nav-btn:hover { border-color: var(--molecular); color: var(--molecular); }

/* detail sections + parts in the aside */
.detsec { margin: .5rem 0; } .detsec .lbl { font-size: .66rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--molecular); } .detsec p { margin: .12rem 0 0; font-size: .8rem; color: var(--ink-2); line-height: 1.45; }
.part { display: grid; grid-template-columns: 1fr; gap: 1px; font-size: .78rem; padding: .3rem 0; border-bottom: 1px dashed var(--hair); }
.part b { color: var(--ink); } .part span { color: var(--muted); font-size: .72rem; }
.chk { display: flex; align-items: flex-start; gap: .4rem; font-size: .74rem; color: var(--ink-2); margin: .5rem 0 .2rem; line-height: 1.3; cursor: pointer; }
.chk input { margin-top: .1rem; accent-color: var(--molecular); }
.cite { display: block; font-size: .76rem; padding: .25rem 0; border-bottom: 1px dashed var(--hair); }
.cite .src { display: inline-block; font-size: .62rem; font-weight: 700; text-transform: uppercase; color: #fff; background: var(--scanner); border-radius: 4px; padding: 1px 5px; margin-right: .35rem; }
.cite a { color: var(--template); text-decoration: none; } .cite a:hover { text-decoration: underline; }

/* saved-inventions modal, grouped by the 10 categories */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(20,20,26,.5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 3vh 3vw; }
.modal[hidden] { display: none; }
.modal-card { background: var(--paper); border-radius: var(--radius); max-width: 900px; width: 100%; max-height: 92vh; overflow: auto; padding: 1.3rem 1.5rem; box-shadow: var(--shadow); }
.modal-card h2 { font-family: var(--serif); font-weight: 500; font-size: 1.4rem; margin: .1rem 0 .3rem; }
.modal-close { float: right; border: 1px solid var(--hair); background: #fff; border-radius: 8px; cursor: pointer; width: 30px; height: 30px; font-size: 1rem; }
.cat { margin-top: 1.1rem; } .cat h3 { font-family: var(--sans); font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: .5rem; margin: 0 0 .3rem; }
.cat .n { font-family: "JetBrains Mono", monospace; font-size: .7rem; color: var(--muted); }
.inv-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto auto; gap: .6rem; align-items: center; padding: .35rem .5rem; border: 1px solid var(--hair); border-radius: 8px; margin: .25rem 0; font-size: .82rem; }
.inv-row .dot { width: 8px; height: 8px; border-radius: 50%; } .inv-row .dot.p { background: var(--ok); } .inv-row .dot.f { background: var(--no); }
.inv-row .ti { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-row .sc { font-family: "JetBrains Mono", monospace; font-weight: 700; }
.del { border: 0; background: transparent; cursor: pointer; font-size: 1rem; opacity: .5; padding: 0 .2rem; }
.del:hover { opacity: 1; }
.cat-empty { font-size: .78rem; color: var(--faint); font-style: italic; padding: .2rem .5rem; }

/* benchmark */
.bench-controls { display: flex; align-items: center; gap: .8rem; margin: .8rem 0; flex-wrap: wrap; }
.bench-controls input[type=number] { width: 56px; padding: .3rem .4rem; border: 1px solid var(--hair); border-radius: 8px; margin-left: .3rem; }
.bench-controls .btn { width: auto; display: inline-block; margin: 0; padding: .45rem 1rem; }
.bench-head { display: flex; gap: 1.4rem; flex-wrap: wrap; font-size: .84rem; margin: .4rem 0 .6rem; }
.bench-head b { font-family: "JetBrains Mono", monospace; }
.bench-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.bench-table th { text-align: right; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1.5px solid var(--rule); padding: 5px 8px; }
.bench-table th:first-child { text-align: left; }
.bench-table td { padding: 5px 8px; border-bottom: 1px solid var(--hair); text-align: right; font-family: "JetBrains Mono", monospace; }
.bench-table td:first-child { text-align: left; font-family: var(--sans); }
.bench-bar { height: 7px; border-radius: 4px; background: var(--ok); display: inline-block; vertical-align: middle; }
.bench-run { font-size: .76rem; color: var(--ink-2); padding: .25rem 0; border-bottom: 1px dashed var(--hair); display: flex; justify-content: space-between; gap: 1rem; }
.bench-run b { font-family: "JetBrains Mono", monospace; }

/* clickable saved row + full invention detail view */
.inv-row { cursor: pointer; } .inv-row:hover { border-color: var(--molecular); }
.inv-row .ti { pointer-events: none; }
.id-sec { margin: 1rem 0; } .id-sec h4 { font-family: var(--sans); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--molecular); margin: 0 0 .3rem; }
.id-sec p { margin: .1rem 0; font-size: .88rem; color: var(--ink-2); line-height: 1.5; }
.id-sec ul { margin: .2rem 0; padding-left: 1.2rem; font-size: .86rem; color: var(--ink-2); }
.id-meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .78rem; color: var(--muted); margin: .2rem 0 .5rem; }
.id-meta b { color: var(--ink); font-family: "JetBrains Mono", monospace; }
.id-kv { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; font-family: "JetBrains Mono", monospace; font-size: .78rem; }
.id-kv .k { color: var(--muted); } .id-kv .v { color: var(--ink); text-align: right; }
.id-domain { display: grid; grid-template-columns: 90px 1fr; gap: .4rem; margin: .3rem 0; font-size: .86rem; }
.id-domain .dl { font-size: .66rem; font-weight: 700; text-transform: uppercase; color: var(--molecular); padding-top: .15rem; }
.id-cite { display: block; font-size: .8rem; padding: .2rem 0; }
.id-cite .src { font-size: .62rem; font-weight: 700; text-transform: uppercase; color: #fff; background: var(--scanner); border-radius: 4px; padding: 1px 5px; margin-right: .35rem; }
.id-cite a { color: var(--template); text-decoration: none; } .id-cite a:hover { text-decoration: underline; }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; height: auto; }
  /* the two control panels are absolutely positioned over the chart on desktop; on a phone
     that overlaps — flow them as stacked full-width cards and drop the decorative canvas. */
  .viewer { height: auto; overflow: visible; display: flex; flex-direction: column;
    gap: 12px; padding: 12px; background: var(--paper-2); }
  #chart { display: none; }
  .overlay { position: static; width: auto !important; max-height: none !important;
    backdrop-filter: none; background: var(--paper); }
  .overlay.controls, .overlay.verdict { top: auto; left: auto; right: auto; }
  .aside { border-left: 0; border-top: 1px solid var(--hair); }
}
/* nav chips: let them scroll horizontally instead of overflowing the viewport on small screens */
@media (max-width: 640px) {
  .nav .wrap { gap: .5rem; }
  .nav-links { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links > * { flex: 0 0 auto; }

  /* Modals: on phones the grid's place-items:center sizes the card to its content's max width,
     so a wide row pushes the whole card off-screen. Make them full-screen sheets (stretch, not
     center) so the card width is fixed to the viewport, then wrap/scroll wide inner content. */
  .modal { padding: 0; place-items: stretch; }
  .modal-card { max-width: 100%; width: 100%; min-height: 100%; max-height: 100vh;
    border-radius: 0; padding: 1rem 1rem 2rem; }
  .modal-close { position: sticky; top: -.2rem; z-index: 2; }
  /* prototype / benchmark rows: wrap instead of overflowing */
  .bench-run { flex-wrap: wrap; gap: .15rem .5rem; }
  .bench-run .pname, .bench-run .pmeta { flex: 1 1 100%; }
  .proto-row .pdf { margin-top: .2rem; }
  /* dense saved-invention rows: tighten so all six columns fit */
  .inv-row { gap: .35rem; font-size: .78rem; }
  .inv-row .dt { font-size: .64rem; }
  /* the synthesize schematic is intentionally wide — let it scroll inside the card, not the page */
  .schematic { overflow-x: auto; }
  .synth-history { overflow-x: hidden; }
}

/* ── synthesis: progress table, gated button, end-to-end schematic ── */
.synth-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem .8rem; margin: .8rem 0; }
.synth-row { display: flex; align-items: center; gap: .5rem; font-size: .84rem; padding: .25rem .1rem; }
.synth-row .dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-size: .6rem; color: #fff; }
.synth-row .dot.on { background: var(--ok); } .synth-row .dot.off { background: var(--hair); color: var(--muted); }
.synth-row .nm { color: var(--ink-2); } .synth-row.on .nm { color: var(--ink); font-weight: 600; }
.synth-actions { display: flex; align-items: center; gap: .8rem; margin: .6rem 0 0; }
.synth-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
.synth-meter { height: 8px; border-radius: 6px; background: var(--hair); overflow: hidden; margin: .5rem 0; }
.synth-meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--molecular), var(--ok)); transition: width .4s; }

.sys-name { font-family: var(--serif); font-size: 1.35rem; margin: 1.2rem 0 .2rem; }
.sys-over { color: var(--ink-2); font-size: .92rem; line-height: 1.5; max-width: 72ch; }

/* the schematic: horizontal phase flow inside a safety envelope */
.schematic { border: 2px dashed var(--scanner); border-radius: var(--radius); padding: 1rem 1rem .6rem; margin: 1.1rem 0; position: relative; overflow-x: auto; }
.schematic .safety-tag { position: absolute; top: -.7rem; left: 1rem; background: var(--paper); padding: 0 .5rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--scanner); }
.flow { display: flex; align-items: stretch; gap: 0; min-width: max-content; }
.phase { display: flex; flex-direction: column; gap: .5rem; min-width: 190px; max-width: 230px; }
.phase > h5 { font-family: var(--sans); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--molecular); margin: 0 0 .1rem; }
.phase-why { font-size: .7rem; color: var(--muted); margin: -.2rem 0 .3rem; line-height: 1.35; }
.snode { background: var(--paper-2); border: 1px solid var(--hair); border-radius: var(--radius-sm); padding: .5rem .6rem; }
.snode .st { font-weight: 700; font-size: .82rem; color: var(--ink); }
.snode .sr { font-size: .72rem; color: var(--ink-2); margin: .15rem 0; line-height: 1.35; }
.snode .sp { font-size: .66rem; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.arrow { display: flex; align-items: center; padding: 0 .35rem; color: var(--scanner); font-size: 1.3rem; }
@media (max-width: 720px) { .synth-grid { grid-template-columns: 1fr; } }

.how ol { margin: .3rem 0; padding-left: 1.3rem; } .how li { font-size: .86rem; color: var(--ink-2); line-height: 1.5; margin: .2rem 0; }
.bom { display: grid; grid-template-columns: 1fr; gap: .25rem; margin: .3rem 0; }
.bom .bi { display: grid; grid-template-columns: 1fr auto; gap: .5rem; font-size: .82rem; padding: .25rem .1rem; border-bottom: 1px solid var(--hair); }
.bom .bi b { color: var(--ink); } .bom .bi .ph { font-size: .64rem; text-transform: uppercase; color: var(--muted); align-self: center; }
.proto-row { cursor: pointer; align-items: center; }
.proto-row:hover { border-color: var(--molecular); color: var(--ink); }
.proto-row .pname { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proto-row .pmeta { flex: 0 0 auto; }
.proto-row .pdf { flex: 0 0 auto; margin-left: auto; border: 1px solid var(--hair); background: transparent; color: var(--ink-2);
  cursor: pointer; font-size: .68rem; font-weight: 600; padding: .12rem .4rem; border-radius: 6px; white-space: nowrap; }
.proto-row .pdf:hover { border-color: var(--molecular); color: var(--molecular); }
.proto-row .pdf.research { margin-left: auto; }
.proto-row .pdf { margin-left: 0; }
.proto-row .pdf.research + .pdf { margin-left: .35rem; }
.proto-row .pdf.research:hover { border-color: var(--venv); color: var(--venv); }

/* saved-invention number + date */
.inv-row .num { font-family: "JetBrains Mono", monospace; font-size: .72rem; color: var(--muted); }
.inv-row .dt { font-family: "JetBrains Mono", monospace; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.inv-row .del { justify-self: end; }   /* delete pinned to the right corner */

/* synthesize per-topic invention picker */
.synth-pick { display: flex; flex-direction: column; gap: .4rem; margin: .3rem 0 .2rem; }
.synth-prow { display: grid; grid-template-columns: 18px minmax(160px, 1fr) minmax(220px, 1.4fr); align-items: center; gap: .5rem; }
.synth-prow .pt { font-size: .84rem; color: var(--ink-2); }
.synth-prow.on .pt { color: var(--ink); font-weight: 600; }
.synth-prow .psel { width: 100%; font-size: .74rem; padding: .3rem .4rem; border: 1px solid var(--hair); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font-family: "JetBrains Mono", monospace; }
.synth-prow .psel:hover, .synth-prow .psel:focus { border-color: var(--molecular); outline: none; }
.psel-locked { font-size: .74rem; color: var(--muted); }
@media (max-width: 720px) { .synth-prow { grid-template-columns: 18px 1fr; } .synth-prow .psel { grid-column: 1 / -1; } }
