/* BioGraphs: app layout. Components and colour tokens come from ui/ui.css (load it first);
   this file only places things. Every colour is a token, so both themes work everywhere. */

h1, h2, h3 { color: var(--ink); }
h3 { font-size: 14px; margin: 22px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.spacer { flex: 1; }
label.check { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.brand { display: flex; gap: 8px; align-items: center; min-width: 0; }
.brand strong { font-size: 15px; letter-spacing: -.01em; }
/* the logo: stacked bars (the same drawing as favicon.svg) in the accent colour, "Bio" bold in the accent, "Graphs" light */
.brand-mark { width: 22px; height: 22px; flex: none; color: var(--accent); }
.brand strong.brand-name { font-weight: 450; color: var(--ink); white-space: nowrap; }
.brand-name > span { font-weight: 700; color: var(--accent); }
a.brand { color: inherit; text-decoration: none; }
.tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill-busy { background: var(--warn-soft); color: var(--warn); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }

.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }
.banner .report-link { margin-top: 6px; font-family: var(--font); }
.notice { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: 13px; line-height: 1.6; }

/* ---------- chooser ---------- */
.chooser { margin: 16px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow-sm); }
.chooser h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
.chooser-grid { margin: 8px 0 12px; }
.chooser-group { font-size: 13px; font-weight: 600; margin: 20px 0 10px; color: var(--ink); }
.chooser-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.chart-card { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 4px; text-align: left; padding: 12px 14px; border-radius: var(--radius-sm); min-height: 86px; }
.chart-card strong { font-size: 14px; font-weight: 600; }
.chart-card span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.chart-card:not(.soon):hover { border-color: var(--accent); background: var(--accent-soft); }
.chart-card.soon { opacity: .55; }
.chart-card em { font-size: 11px; font-style: normal; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }

/* ---------- workspace ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; padding: 16px 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.controls { position: sticky; top: calc(58px + env(safe-area-inset-top, 0px)); max-height: calc(100vh - 74px); overflow-y: auto; padding: 4px 16px; }
.controls section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.controls section:last-child { border-bottom: 0; }
.controls h2 { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.controls h2 .link { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 450; font-size: 12px; }
.controls details.ui-fold > summary > h2 { margin: 0; }
.controls details.ui-fold.section-fold > summary { padding: 0; }
.controls details.ui-fold.section-fold[open] > summary { margin-bottom: 10px; }
#roles .ui-field:last-child, #options > :last-child { margin-bottom: 0; }
#options:empty, #statOptions:empty, #optionsMore:empty { display: none; }
#moreWrap { margin-top: 6px; }
.main-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; flex-wrap: wrap; }
.panel-head #runStatus { min-width: 0; flex: 1 1 260px; }
.export { display: flex; gap: 2px; flex-wrap: wrap; }

/* The figure is publication output, drawn by the script: always on white "paper", light tokens inside. */
.plot { min-height: 520px; overflow-x: auto; background: var(--paper); border-radius: var(--radius-sm); border: 1px solid var(--line);
  color-scheme: light; --ink: #1d2433; --muted: #5f6b7d; --line: #e3e6eb; --accent: #3554d1; --ok: #137a3f; color: var(--ink); }
.loading { max-width: 460px; margin: 90px auto; padding: 0 16px; }
.loading-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.steps { list-style: none; padding: 0; margin: 0 0 12px; }
.steps li { padding: 5px 0 5px 28px; position: relative; color: var(--muted); }
.steps li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); }
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tabs, script, console ---------- */
/* (overflow-y hidden: the strip scrolls sideways only when the tabs do not fit; it never gets a vertical scrollbar) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -4px 0 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; box-shadow: none; color: var(--muted); padding: 8px 12px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); background: none; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 550; }
.script-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sync { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.sync.ok { background: var(--ok-soft); color: var(--ok); }
.sync.edited { background: var(--warn-soft); color: var(--warn); }
#editor { width: 100%; min-height: 460px; font: 12px/1.55 var(--mono); background: var(--code-bg); color: var(--code-ink); border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid var(--line); resize: vertical; tab-size: 4; white-space: pre; }
.console { margin: 0; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--code-line); padding: 12px 14px; border-radius: var(--radius-sm); font: 12px/1.45 var(--mono); max-height: 520px; overflow: auto; white-space: pre; }
.console .err { color: var(--code-err); }
.script-foot { margin-top: 10px; }
.libs { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12px; columns: 2 260px; }
.libs li { padding: 3px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.notice a, .libs a { color: var(--accent); }

/* ---------- tables ---------- */
/* a 1 px frame with rounded corners (as the data table in step 1); the last row's line is the frame itself */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tablewrap tbody tr:last-child td { border-bottom: 0; }
table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
th, td { text-align: left; padding: 5px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: var(--panel-2); }
td.num, th.num { text-align: right; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
tr.sub td { color: var(--muted); }
.table-title { font-weight: 600; margin: 14px 0 6px; }
.table-title:first-child { margin-top: 0; }
.src-network { color: var(--warn); }
.src-cache { color: var(--ok); }

/* ---------- modals ---------- */
.modal-box h2 { font-size: 18px; color: var(--bad); margin: 0 0 6px; }
.modal-box.wide { max-width: 1200px; }
.modal-box.wide h2 { color: var(--ink); }
.modal-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.err-code { margin: 0 0 10px; font-family: var(--mono); }
.modal-box .console { max-height: 200px; white-space: pre-wrap; }


/* ---------- performance (debug build) ---------- */
.perf { margin: 0 20px 24px; }
.perf-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.perf-head h2 { margin: 0; font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--panel-2); }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card .s { font-size: 12px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.waterfall { font-size: 11.5px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; max-height: 520px; overflow: auto; }
.wf-row { display: grid; grid-template-columns: 300px 1fr 80px; gap: 8px; align-items: center; height: 18px; }
.wf-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-track { position: relative; height: 10px; background: var(--sunken); border-radius: 2px; }
.wf-bar { position: absolute; top: 0; height: 10px; border-radius: 2px; min-width: 2px; }
.wf-ms { text-align: right; font-family: var(--mono); color: var(--muted); }
/* timeline categories: fixed hues, readable on both themes */
.c-network { background: #e08a1e; } .c-cache { background: #2e9d5b; } .c-app-server { background: #8b95a7; }
.c-wasm { background: #7b4fd6; } .c-boot { background: #3554d1; } .c-packages { background: #1f7fb5; }
.c-wheels { background: #0f9aa0; } .c-pyc { background: #b8860b; } .c-import { background: #c2417a; } .c-page { background: #6b7588; } .c-run { background: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .controls { position: static; max-height: none; }
  .two { grid-template-columns: 1fr; }
  .wf-row { grid-template-columns: 140px 1fr 60px; }
  .tag { display: none; }
  .topbar { padding: 8px 16px; flex-wrap: wrap; row-gap: 8px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; flex: 1 1 auto; }
  .pill { max-width: 100%; }
  .panel-head .export { width: 100%; }
}
@media (max-width: 560px) {
  .topbar-right { justify-content: flex-start; }
  #status { order: 5; flex: 1 1 100%; }
}
