/* WCMD dashboard. Dark by default (the 3D views read best on dark); light on request. */
:root {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242422;
  --border: #383835;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #3987e5;
  /* categorical slots (dark steps), fixed per entity everywhere */
  --c-protein: #3987e5;
  --c-membrane: #d95926;
  --c-ribosome: #199e70;
  --c-dna: #c98500;
  --c-mrna: #d55181;
  --c-trna: #9085e9;
  /* status */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --neutral: #6d6c66;
  --grid: #2e2e2b;
}
:root[data-theme="light"] {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #eeeeeb;
  --border: #d9d8d3;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7973;
  --c-protein: #2a78d6;
  --c-membrane: #eb6834;
  --c-ribosome: #1baf7a;
  --c-dna: #eda100;
  --c-mrna: #e87ba4;
  --c-trna: #6250d6;
  --grid: #e6e5e0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
.muted { color: var(--text-muted); font-weight: normal; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--text-secondary); }
button, select, input { font: inherit; color: inherit; }

/* header */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: .02em; }
.server-host { font-weight: 600; color: #e8a33d; }   /* which machine serves this page */
:root[data-theme="light"] .server-host { color: #b06a00; }
.tabs { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  color: var(--text-secondary);
}
.tabs button.active { background: var(--surface-2); color: var(--text-primary); }
.runline { padding: 4px 16px; font-size: 12px; color: var(--text-muted); background: var(--surface-1);
  border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* experiment picker */
.exp-picker { position: relative; min-width: 0; flex: 1 1 380px; max-width: 640px; }
.exp-current, .exp-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer;
  background: var(--surface-2);
}
.exp-current .exp-label, .exp-item .exp-label { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.exp-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px;
  list-style: none; max-height: 70vh; overflow: auto; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .4);
}
.exp-item { border: 0; margin: 2px 0; background: transparent; }
.exp-item:hover, .exp-item.focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.exp-chip { flex: 0 0 auto; width: 46px; text-align: center; border-radius: 4px; padding: 1px 0;
  font-size: 12px; font-weight: 600; color: #0b0b0b; }
.hard-chip { flex: 0 0 auto; width: 22px; text-align: center; border-radius: 4px; padding: 1px 0;
  font-size: 12px; font-weight: 700; color: #fff; background: #d32f2f; }
.hard-chip.zero { background: hsl(0 0% 45% / .35); color: rgb(255 255 255 / .55); font-weight: 600; }
.hard-chip.none { background: transparent; }
.cell-icon { flex: 0 0 auto; width: 18px; height: 18px; }
.cell-icon.off { opacity: .18; }

/* tabs */
main { flex: 1; min-height: 0; position: relative; }
.tab { display: none; height: 100%; overflow: auto; padding: 16px; }
.tab.active { display: block; }
.tab3d.active { display: grid; grid-template-columns: 280px 1fr; grid-template-rows: 1fr auto;
  padding: 0; overflow: hidden; }
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }

/* gates: one box per group, as many columns as fit */
.gates-head { margin: 0 0 12px; }
.gate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 16px; align-items: start; }
.gates { list-style: none; margin: 0; padding: 0; }
.gate {
  display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start;
  padding: 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.gate:hover { border-color: var(--border); background: var(--surface-2); }
.ggroup { margin: 0; padding: 10px 10px 6px; }
.ghead { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px; margin-bottom: 4px; cursor: pointer;
  border-bottom: 1px solid var(--border); user-select: none; }
.gletter { font-weight: 700; font-size: 13px; color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; }
.ghead:hover { background: var(--surface-2); }
.gtitle { font-weight: 650; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-secondary); }
.gchips { margin-left: auto; display: inline-flex; gap: 4px; }
.gchips .badge { min-width: 20px; }
.gcaret { color: var(--text-muted); font-size: 11px; width: 10px; transition: transform 0.12s; }
.ggroup.closed .gcaret { transform: rotate(-90deg); }
.ggroup.closed > .gates { display: none; }
.gate .gname { font-weight: 600; }
.gate .gnote { color: var(--text-secondary); font-size: 12px; }
.badge { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 2px 6px;
  border-radius: 4px; font-size: 11px; font-weight: 700; color: #0b0b0b; white-space: nowrap; }
.badge.PASS { background: var(--good); }
.badge.FAIL { background: var(--critical); color: #fff; }
.badge.SOFT { background: var(--warning); }
.badge.NOT { background: var(--neutral); color: #fff; }
/* "to build": the model lacks the mechanism the gate tests. Hollow and dashed, so it reads as
   "not there yet" by shape, not by a fifth status colour. */
.badge.TODO { background: transparent; color: var(--text-primary); border: 1px dashed var(--accent); padding: 1px 5px; }
.gate .gnote.todo { color: var(--text-primary); }
/* where a gate's reference comes from, under its verdict: "Karr" = the Karr 2012 whole-cell model,
   not a measurement. Cyan: a hue no entity or status uses. */
.gbadge { display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.srctag { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-align: center; border-radius: 4px; padding: 0 4px; }
.srctag.KARR { color: #0b0b0b; background: #22b8cf; }
.srctag.TAG { color: #fff; background: #7e57c2; display: block; margin-top: 3px; font-size: 9px; line-height: 1.15; font-weight: 600; letter-spacing: 0; white-space: nowrap; padding: 1px 3px; }
.srctag.TAG.inline { display: inline-block; vertical-align: middle; margin: 0 0 0 6px; font-size: 11px; padding: 1px 6px; }
.tagkw { background: #7e57c2; color: #fff; padding: 0 4px; border-radius: 3px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.tile .tv { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .tl { font-size: 12px; color: var(--text-secondary); }
.tile .ts { font-size: 11px; color: var(--text-muted); }

/* 3D */
.controls { grid-row: 1 / span 2; overflow: auto; padding: 12px; background: var(--surface-1);
  border-right: 1px solid var(--border); font-size: 13px; }
.controls fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 10px; padding: 8px 10px; }
.controls legend { color: var(--text-secondary); font-size: 12px; padding: 0 4px; }
.controls label { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.controls label.disabled { opacity: .45; }
.controls .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.controls input[type=range] { flex: 1; min-width: 80px; }
.controls input[type=text], .controls input[type=number], .controls select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 3px 6px; }
.controls input[type=text] { width: 100%; }
.controls button.small { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 8px; cursor: pointer; }
.controls .note { font-size: 11px; color: var(--text-muted); margin: 4px 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 1px 8px;
  font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
.chip button { background: none; border: 0; cursor: pointer; color: var(--text-muted); padding: 0; }
.viewport { position: relative; min-height: 0; overflow: hidden; background: #0b0b0b; }
.viewport canvas { display: block; width: 100%; height: 100%; }
.overlay-msg { position: absolute; inset: auto 12px 12px 12px; background: rgb(26 26 25 / .9);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; z-index: 5; }
.pick-info { position: absolute; top: 10px; right: 10px; background: rgb(26 26 25 / .92); z-index: 5;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 12px; max-width: 280px; }
.pick-info .na-card { margin-top: 4px; display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; }
.pick-info .na-card .k { color: var(--text-muted); white-space: nowrap; }
.pick-info .na-seq { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; word-break: break-all; }
.pick-info .na-seq b { color: #e5484d; font-weight: 600; }
.pick-info .na-sec { margin-top: 6px; font-weight: 600; }
.pick-info { max-height: max(200px, calc(100% - 250px)); overflow-y: auto; }   /* clear of the bottom panel */
.pick-info .na-ref { font-weight: 600; font-size: 10px; color: #fab219; border: 1px dashed #fab219; border-radius: 4px;
  padding: 0 4px; margin-left: 4px; }
.sland .lhead select { font-size: 11px; max-width: 100%; background: #1a1a19; color: #c3c2b7;
  border: 1px solid #383835; border-radius: 4px; padding: 1px 4px; }
.legend3d { position: absolute; top: 10px; left: 10px; font-size: 12px; z-index: 4;
  background: rgb(26 26 25 / .8); border-radius: 8px; padding: 6px 10px; }
.legend3d:empty { display: none; }
.spanel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; gap: 10px;
  overflow-x: auto; padding: 8px 10px; background: #121211; border-top: 1px solid #2e2e2b; color: #c3c2b7; }
.spanel[hidden] { display: none; }
.scard { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; }
.scard canvas { display: block; border-radius: 6px; }
.sread { font-size: 11px; color: #8f8e86; padding-left: 4px; min-height: 14px; }
.snote { font-size: 12px; color: #c3c2b7; max-width: 260px; padding: 6px 8px; display: flex; flex-direction: column; gap: 6px; }
.snote .muted { color: #8f8e86; }
.sempty { width: 260px; height: 236px; box-sizing: border-box; border: 1px dashed #2e2e2b; border-radius: 6px; padding: 10px 12px; }
.triad { position: absolute; left: 10px; bottom: 10px; width: 84px; height: 84px; z-index: 4; pointer-events: none; }
.legend3d .li { display: flex; align-items: center; gap: 6px; }
.timebar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-1);
  border-top: 1px solid var(--border); }
.timebar input[type=range] { flex: 1; }
.play { width: 34px; height: 30px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2);
  cursor: pointer; }

/* summaries */
.summaries { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card .na { color: var(--text-muted); font-size: 13px; border-left: 3px solid var(--neutral); padding-left: 8px; }
table.t { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
table.t th, table.t td { padding: 3px 6px; border-bottom: 1px solid var(--border); text-align: right; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t th { color: var(--text-secondary); font-weight: 600; }
.chart { width: 100%; position: relative; }
.heatrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 8px; }
.chart.heat canvas { display: block; image-rendering: pixelated; border: 1px solid var(--border); max-width: 100%; }
.heatcap { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-muted); font-size: 11px; }
.chart .axis line, .chart .axis path { stroke: var(--border); }
.chart .gridline { stroke: var(--grid); }
.chart .legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-secondary); margin: 4px 0; }
.chart .legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart .title { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px; max-width: 320px; }
details.tbl summary { cursor: pointer; color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgb(0 0 0 / .55); z-index: 40; display: flex;
  align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto; }
.modal[hidden] { display: none; }
.modal-box { position: relative; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  width: min(920px, 100%); padding: 18px 20px; }
.modal-close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 18px;
  cursor: pointer; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; }
.kv .k { color: var(--text-muted); }

@media (max-width: 860px) {
  .gate-grid { grid-template-columns: 1fr; }
  .tab3d.active { grid-template-columns: 1fr; grid-template-rows: auto 60vh auto; }
  .controls { grid-row: auto; border-right: 0; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .summaries { grid-template-columns: 1fr; }
}

/* hover explanations */
.has-info { cursor: help; }
.i { display: inline-flex; align-items: center; justify-content: center; width: 12px; height: 12px; border: 1px solid var(--text-muted); border-radius: 50%; color: var(--text-muted); font-size: 9px; font-style: italic; font-weight: 600; vertical-align: 1px; margin-left: 2px; }
.infobox { max-width: 440px; white-space: normal; line-height: 1.4; }
.infobox p { margin: 0 0 6px; }
.infobox p:last-child { margin-bottom: 0; }
.infobox .ref { color: var(--text-muted); font-size: 11px; }
th.has-info, h3.has-info, .title.has-info { cursor: help; }
.gatedoc { margin: 10px 0 4px; display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.gatedoc .k { color: var(--text-muted); }
.off-orange { color: #eda100; font-weight: 600; }
.off-red { color: #e66767; font-weight: 600; }
