/* TRACE. Black ground, one blue accent. Tokens match the BioPharma Foundry front page. */
:root {
  --bg: #0f1218;
  --surface: #161a22;
  --raised: #1c212b;
  --line: #272d39;
  --line-strong: #3a4252;
  --ink: #f4f4f7;
  --soft: #b4bac6;
  --muted: #8a92a2;
  --accent: #7ea6f5;
  --accent-hi: #bcd0fa;
  --accent-soft: rgba(126, 166, 245, 0.14);
  --danger: #ff8a65;
  --danger-soft: rgba(255, 138, 101, 0.1);
  --proj: rgba(255, 255, 255, 0.035);
  --font-display: myriad-variable, sans-serif;
  --font-body: myriad-variable, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --on-accent: #0a1430;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-stretch: 95%;
  font-variation-settings: "wdth" 95;
  font-weight: 450;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3 { font-stretch: 100%; font-variation-settings: normal; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.025em; margin: 0; text-wrap: balance; }
p { margin: 0; }
code, .mono { font-family: var(--font-body); }

.wrap {
  max-width: 1296px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px), 4vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 4vw);
}
@media (min-width: 1400px) { .wrap { padding-left: 48px; padding-right: 48px; } }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 32px; padding-top: 16px; padding-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.brand svg { flex: none; }
.brand-name { font-family: var(--font-mono); font-weight: 700; font-size: 20px; letter-spacing: 0.04em; text-transform: uppercase; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name { line-height: 1.1; }
.brand-full { font-family: var(--font-body); font-size: 11px; line-height: 1.25; color: var(--muted); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--soft); font-size: 15px; font-weight: 500; padding: 10px 14px; min-height: 44px; display: inline-flex; align-items: center; border-radius: 4px; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--accent); }

/* Page head */
.page-head { padding-top: clamp(28px, 5vw, 56px); padding-bottom: clamp(20px, 3vw, 32px); display: flex; flex-direction: column; gap: 12px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.page-head h1 { font-size: 34px; line-height: 1.1; }
.lede { color: var(--soft); font-size: 18px; max-width: 62ch; }
.page-head .lede { max-width: none; margin-top: 14px; }

/* App layout */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; padding-top: 28px; padding-bottom: 56px; }
@media (max-width: 920px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.rail { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 920px) { .rail { position: static; } }
.main { display: flex; flex-direction: column; gap: 20px; min-width: 0; transition: opacity 0.15s; }
.main.stale { opacity: 0.35; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.panel-title { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0; }
.panel-head .panel-title { margin: 0; }
.panel > .panel-title { margin-bottom: 14px; }
.panel > .panel-title + .field { margin-top: 0; }

label, .label { display: block; font-size: 13px; color: var(--soft); margin-bottom: 6px; }
textarea, input[type="number"], select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { height: 176px; resize: vertical; line-height: 1.5; white-space: pre; overflow: auto; }
select { font-family: var(--font-body); font-size: 14px; }
.field { margin-top: 14px; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; }
.drop.over textarea { border-color: var(--accent); background: var(--accent-soft); }

.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 500; color: var(--ink);
  background: transparent; border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 0 14px; min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; margin: 0;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); color: var(--on-accent); }
.btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }

.msg { font-size: 14px; border-radius: 4px; padding: 10px 12px; margin-top: 12px; border: 1px solid var(--line-strong); color: var(--soft); background: var(--raised); }
.msg.err { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.msg.warn { color: var(--accent-hi); background: var(--accent-soft); border-color: var(--accent); }

/* Parameters */
.params { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.param { padding: 16px 18px; border-right: 1px solid var(--line); min-width: 0; }
.param:last-child { border-right: 0; }
.param .sym { font-family: var(--font-display); font-size: 16px; color: var(--muted); }
.param .val { font-family: var(--font-body); font-size: 30px; font-weight: 500; color: var(--accent); letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.param .cap { font-size: 13px; color: var(--muted); }
@media (max-width: 600px) {
  .params { grid-template-columns: minmax(0, 1fr); }
  .param { border-right: 0; border-bottom: 1px solid var(--line); }
  .param:last-child { border-bottom: 0; }
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 16px 20px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.stat b { display: block; font-family: var(--font-body); font-weight: 500; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.reading { margin-top: 14px; color: var(--soft); }

/* Charts */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 7px; }
.legend i.dot { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--ink); }
.legend i.dash { border-top-style: dashed; }
.chart { width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 11.5px; fill: var(--muted); }
.chart text.lab { font-family: var(--font-body); font-size: 12px; }
.chart text.hot { fill: var(--accent); }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .ax { stroke: var(--line-strong); stroke-width: 1; }
.chart .cur { stroke: var(--ink); stroke-width: 1; opacity: 0; }
.chart .cdot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; opacity: 0; }
.chart .area { fill: var(--accent-soft); }
.chart .fitline { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; }
.chart .fitline.dash { stroke-dasharray: 6 5; }
.chart .actual { fill: var(--ink); }
.chart .region { fill: var(--proj); }
.chart .guide { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .guidedot { fill: var(--accent); }
.readout { font-family: var(--font-body); font-size: 12.5px; color: var(--ink); min-height: 22px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.readout em { font-style: normal; color: var(--muted); }

/* Tables */
.tablewrap { overflow: auto; max-height: 320px; border: 1px solid var(--line); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-family: var(--font-body); font-size: 12.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 12px; }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-family: var(--font-body); font-weight: 500; font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; }
td:first-child, th:first-child { text-align: left; }
tr.proj td { color: var(--muted); background: var(--proj); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1100px) { .two { grid-template-columns: minmax(0, 1fr); } }
.export { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; justify-content: space-between; }
.export p { color: var(--muted); font-size: 14px; max-width: 56ch; }
.export .btns { margin-top: 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); }
.site-footer .wrap { padding-top: 44px; padding-bottom: 56px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px 40px; color: var(--soft); font-size: 15px; }
.site-footer p { max-width: 60ch; margin: 0; }
.site-footer .ft-copy { margin-top: 14px; color: var(--muted); }
.ft-logo { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font: 700 12px/1 var(--font-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.ft-logo svg { width: 26px; height: 26px; }
.ft-a { stroke: var(--ink); }
.ft-b { stroke: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 22px; align-content: flex-start; }
.site-footer nav a { color: var(--soft); }
.site-footer nav a:hover { color: var(--ink); }

/* Help page */
.help { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; padding-bottom: 72px; align-items: start; }
@media (max-width: 860px) { .help { grid-template-columns: minmax(0, 1fr); gap: 24px; } }
.toc { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 860px) { .toc { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px 6px; } }
.toc a { color: var(--soft); font-size: 14px; padding: 8px 10px; border-radius: 4px; min-height: 40px; display: inline-flex; align-items: center; }
.toc a:hover { color: var(--accent); background: var(--raised); }
.doc { font-family: myriad-variable, sans-serif; display: flex; flex-direction: column; gap: 44px; min-width: 0; max-width: 78ch; }
.doc section { scroll-margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.doc h2 { font-size: 28px; line-height: 1.1; }
.doc h3 { font-size: 18px; margin-top: 8px; }
.doc p, .doc li { color: var(--soft); font-size: 18px; line-height: 26px; }
.doc ul, .doc ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.doc strong { color: var(--ink); font-weight: 600; }
.doc code { font-size: 13px; background: var(--raised); border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; color: var(--ink); }
.eq { font-family: var(--font-body); font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; overflow-x: auto; white-space: pre; line-height: 1.7; }
.codeblock { font-family: var(--font-body); font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; overflow-x: auto; white-space: pre; line-height: 1.6; }
.doc table { font-size: 13px; }
.doc td, .doc th { text-align: left; white-space: normal; vertical-align: top; }
.doc .tablewrap { max-height: none; }
details { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
details summary { cursor: pointer; padding: 14px 16px; min-height: 48px; color: var(--ink); font-weight: 500; }
details[open] summary { border-bottom: 1px solid var(--line); }
details p { padding: 14px 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Method page */
.math { font-family: var(--font-body); font-size: 18px; line-height: 1.5; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 16px 20px; color: var(--ink); overflow-x: auto; }
.math .eqrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 8px 0; }
.math .eqrow + .eqrow { border-top: 1px solid var(--line); }
.math .eqno { color: var(--muted); font-family: var(--font-body); font-size: 13px; }
.math var { font-style: italic; }
.math sub, .math sup { font-size: 0.7em; line-height: 0; }
.doc .words { color: var(--soft); font-size: 14.5px; line-height: 20px; margin-top: -6px; }
.doc .ref { font-size: 14px; }
.doc sup.cite { font-size: 0.72em; line-height: 0; margin-left: 1px; color: var(--muted); }
.doc ol.refs { padding-left: 28px; }
.doc .note { border-left: 2px solid var(--accent); padding: 4px 0 4px 14px; color: var(--soft); }


/* Light background. Chosen with the toggle in the header; Method and Help open light the first time. */
html[data-theme="light"] {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --raised: #f1f1f5;
  --line: #e4e4ea;
  --line-strong: #c9c9d3;
  --ink: #111113;
  --soft: #46464c;
  --muted: #6a6a72;
  --accent: #2563eb;
  --accent-hi: #1e40af;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger: #b3401a;
  --danger-soft: rgba(179, 64, 26, 0.08);
  --proj: rgba(0, 0, 0, 0.04);
  --on-accent: #ffffff;
  color-scheme: light;
}
html[data-theme="light"] .report { border: 1px solid var(--line); }
.themebtn { font: inherit; color: var(--soft); background: transparent; border: 1px solid var(--line-strong); border-radius: 4px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin-left: 8px; }
.themebtn:hover { color: var(--accent); border-color: var(--accent); }

/* Method and Help: banner, numbered section cards, tinted callouts */
.doc-hero { position: relative; overflow: hidden; isolation: isolate; background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); margin-bottom: 40px; }
.doc-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: repeating-radial-gradient(circle at 92% 50%, transparent 0 54px, color-mix(in srgb, var(--accent) 14%, transparent) 54px 55px); -webkit-mask-image: linear-gradient(to right, transparent 55%, #000 95%); mask-image: linear-gradient(to right, transparent 55%, #000 95%); }
.doc-hero .page-head { padding-top: clamp(32px, 4.5vw, 52px); padding-bottom: clamp(28px, 4vw, 44px); gap: 12px; }
.doc-hero .eyebrow { align-self: flex-start; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 999px; padding: 5px 12px; font-size: 11.5px; }
.doc-hero h1 { color: var(--ink); font-size: clamp(30px, 4vw, 42px); line-height: 1.08; }
.doc-hero .lede { color: var(--soft); font-size: 18px; margin-top: 0; max-width: none; }

.toc { background: var(--surface); padding: 18px 10px 12px; }
.toc::before { content: "On this page"; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 0 10px 10px; }
.toc a { border-left: 2px solid transparent; border-radius: 0 8px 8px 0; }
.toc a:hover { border-left-color: var(--accent); }
@media (max-width: 860px) { .toc { padding: 12px; } .toc::before { display: none; } .toc a { border-left: 0; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; min-height: 36px; } }

.doc { gap: 0; max-width: none; background: var(--surface); }
.doc section { padding: 36px 0 20px; }
.doc section:first-child { padding-top: 0; }
.doc section:last-child { padding-bottom: 0; }
.doc section h2 { font-size: 24px; }
.doc h3 { font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-top: 14px; }
.doc a { color: var(--accent); text-underline-offset: 3px; }
.doc .note { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0; padding: 14px 18px; color: var(--ink); }
.math { border-radius: 0; background: var(--raised); }
.eq, .codeblock { border-radius: 0; background: var(--raised); }
.doc thead th { background: var(--accent-soft); color: var(--ink); }
.doc .tablewrap { border-radius: 0; overflow-x: auto; }
details, details summary, details[open] summary { border-radius: 0; }
.doc li::marker { color: var(--accent); }
@media (max-width: 600px) { .doc section { padding: 28px 0 16px; } .doc section h2 { font-size: 22px; } }

/* Intro under the header on the app page: two small lines in the body face (Myriad Variable, width 95) */
.intro { gap: 0; padding-top: 18px; padding-bottom: 20px; }
.intro h1, .intro .inputs { font-family: var(--font-body); font-stretch: 95%; font-variation-settings: "wdth" 95; font-size: 16px; line-height: 1.48; font-weight: 450; letter-spacing: 0; margin: 0; }
.intro h1 { color: var(--ink); font-weight: 450; text-wrap: pretty; font-family: var(--font-body); font-stretch: 95%; font-variation-settings: "wdth" 95; }
.intro .inputs { color: var(--soft); }
.intro .req { font-family: var(--font-mono); font-size: 14px; color: var(--accent); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }

/* Docs: air under section headings; light-theme body text colour */
.doc section h2 { margin-bottom: 5px; }
html[data-theme="light"] .doc p, html[data-theme="light"] .doc li { color: #4b4b4b; }
html[data-theme="light"] .doc h2 { color: #2c2c2c; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Question rows: small chevron instead of the browser's large triangle */
details summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: ""; flex: none; width: 22px; height: 22px; background: var(--muted); -webkit-mask: url("chevron.svg") center / contain no-repeat; mask: url("chevron.svg") center / contain no-repeat; transition: transform 0.15s ease; }
details[open] summary::after { transform: rotate(90deg); }
details summary:hover::after { background: var(--accent); }

/* Results side: no borders around cards, tables or parameter tiles */
.main .panel, .main .params, .main .tablewrap, html[data-theme="light"] .main .report { border: 0; }
.main .param, .main .param:last-child { border: 0; }
@media (max-width: 920px) { .main .param { border: 0; } }


/* Method and Help: white page background in the light theme */
html.docpage[data-theme="light"] { --bg: #ffffff; }

/* App page background (light theme): soft cool grey that deepens slightly down the page, so white cards stand out */
html[data-theme="light"]:not(.docpage) body { background: linear-gradient(180deg, #f8f9fb 0%, #eff1f5 100%) fixed; }

/* Method and Help content: 20px above, 50px on the right (none on phones) */
.doc { padding: 20px 50px 0 0; }
@media (max-width: 860px) { .doc { padding-right: 0; } }

/* Docs panels share the page background, so padding is invisible in both themes */
.doc, .toc { background: transparent; }

/* Tables, charts and numbers: width 100 (the body text is width 95), weight 400 */
table, th, td, .chart text, .chart text.lab, .readout, .param .val, .stat b, .eq, .codeblock, .math .eqno, .doc code,
:root textarea, :root input, :root select { font-stretch: 100%; font-variation-settings: "wdth" 100; font-weight: 400; }
table, th, td, .chart text, .chart text.lab, .readout, .param .val, .stat b, .eq, .codeblock, .math .eqno, .doc code { font-weight: 400; }

/* Tables, chart labels, formulas and input fields: font size 14 */
table, td, .chart text, .chart text.lab, .readout, .eq, .codeblock, .math .eqno, .doc code,
:root textarea, :root input, :root select { font-size: 14px; }
th { font-size: 12.5px; }

/* References: the [n] in the text is the number, so no list marker */
.doc ol.refs { list-style: none; padding-left: 0; }
