/* CAT Bridge web app. One system: 5 font sizes, 3 weights, an 8-step spacing scale, one primary colour. */
:root {
  /* colour: primary (from the original interface), neutrals, semantic */
  --primary: #4a54b2;
  --primary-strong: #3a4296;
  --primary-soft: #eef0fa;
  --primary-line: #c9cef0;
  --ink: #1f2330;
  --ink-2: #454b5e;
  --ink-3: #636a80;
  --line: #dcdfe8;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --error: #b42318;
  --error-soft: #fdecea;
  --warn: #8a4b00;
  --warn-soft: #fff3d6;
  --ok: #17693a;
  --ok-soft: #e4f4ea;
  /* chart: colour-blind safe pair (blue-violet and vermilion) plus grey */
  --c-gene: #4a54b2;
  --c-target: #d55e00;
  --c-other: #8b91a8;
  /* type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-bold: 700;
  /* space (4-based) */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(31, 35, 48, 0.06), 0 2px 8px rgba(31, 35, 48, 0.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; padding-bottom: var(--s7); }
img { max-width: 100%; }
/* icons: 24-unit grid, one stroke width, round caps and joins, colour from the text (see the sprite in index.html) */
.ico { display: inline-block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 16px; height: 16px; stroke-width: 2.25; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-strong); }
p { margin: 0; }
h1 { margin: 0; font-size: var(--fs-xl); line-height: 1.25; font-weight: var(--fw-bold); letter-spacing: -0.01em; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-inline: var(--s4); }
.skip { position: absolute; left: var(--s2); top: -48px; background: var(--surface); padding: var(--s2) var(--s3); border-radius: var(--radius-sm); z-index: 20; }
.skip:focus { top: var(--s2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header and footer */
.site-header { background: var(--primary); color: #fff; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: var(--s3); color: #fff; text-decoration: none; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.brand img { height: 36px; width: auto; display: block; }
.brand:hover { color: #fff; }
.nav { display: flex; gap: var(--s4); align-items: center; }
.nav a { color: #fff; text-decoration: none; font-size: var(--fs-sm); font-weight: var(--fw-medium); padding: var(--s2) var(--s1); border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current] { color: #fff; border-bottom-color: #fff; }
.site-header :focus-visible, .site-footer :focus-visible { outline-color: #fff; }
.site-footer { background: var(--primary); color: #fff; padding-block: var(--s6); font-size: var(--fs-sm); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s4) var(--s6); }
.site-footer a { color: #fff; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.site-footer .legal { display: flex; flex-direction: column; gap: var(--s1); }

/* intro */
.intro { display: flex; align-items: center; justify-content: space-between; gap: var(--s6); padding-block: var(--s6) var(--s5); }
.intro .text { max-width: 680px; display: flex; flex-direction: column; gap: var(--s3); }
.lead { color: var(--ink-2); }
.intro .logo { width: 280px; height: auto; flex: none; }
.intro-actions { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s1); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: var(--s2) var(--s4);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: 1.2;
  color: var(--primary-strong); background: var(--surface); border: 1px solid var(--primary-line); border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-soft); color: var(--primary-strong); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); min-height: 48px; padding-inline: var(--s6); font-size: var(--fs-md); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; color: var(--ink-3); background: #e9ebf2; border-color: #e9ebf2; }
.btn-primary:disabled { color: #fff; background: #9aa0d3; border-color: #9aa0d3; }
.btn-quiet { background: transparent; border-color: transparent; padding-inline: var(--s2); min-height: 32px; }
.btn-quiet:hover { background: var(--primary-soft); }
.btn-danger-quiet { color: var(--error); }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s5); }
.panel + .panel { margin-top: var(--s5); }
.stack { display: flex; flex-direction: column; gap: var(--s5); }

/* upload slots */
.slots { display: grid; grid-template-columns: 1fr; gap: var(--s5); }
.slot { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.slot-head { display: flex; align-items: center; gap: var(--s2); min-height: 32px; }
.slot-icon { flex: none; width: 28px; height: 28px; color: var(--primary); }
.slot-label { font-weight: var(--fw-medium); }
.slot-head .push { margin-left: auto; }
.tag { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 var(--s2); line-height: 20px; }
.tag-req { color: var(--primary-strong); border-color: var(--primary-line); background: var(--primary-soft); }
.drop { position: relative; border: 1.5px dashed var(--primary-line); border-radius: var(--radius); background: var(--surface); min-height: 72px; transition: background 0.15s, border-color 0.15s; }
.drop:hover, .drop.over { background: var(--primary-soft); border-color: var(--primary); }
.drop:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-body { display: flex; flex-direction: column; justify-content: center; gap: var(--s1); padding: var(--s3) var(--s4); min-height: 70px; pointer-events: none; }
.drop-main { font-size: var(--fs-sm); color: var(--ink-2); }
.drop-main strong { color: var(--primary-strong); font-weight: var(--fw-medium); }
.drop-meta { font-size: var(--fs-xs); color: var(--ink-3); }
.drop.has-file { border-style: solid; background: var(--primary-soft); }
.drop.has-file .drop-main { color: var(--ink); font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.drop.is-error { border-color: var(--error); background: var(--error-soft); border-style: solid; }
.hint { font-size: var(--fs-xs); color: var(--ink-3); }

/* messages: one style for errors and warnings, kept next to the field */
.msgs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.msgs:empty { display: none; }
.msg { font-size: var(--fs-sm); line-height: 1.4; padding: var(--s2) var(--s3); border-radius: var(--radius-sm); border-left: 4px solid; display: flex; gap: var(--s2); overflow-wrap: anywhere; }
.msg-error { color: var(--error); background: var(--error-soft); border-color: var(--error); }
.msg-warn { color: var(--warn); background: var(--warn-soft); border-color: #c77700; }
.msg-ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }
.msg .kind { font-weight: var(--fw-bold); flex: none; }
.msg .body { color: var(--ink); }

/* parameters */
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }
.options { display: grid; grid-template-columns: 1fr; gap: var(--s5); align-items: start; }
.field { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.field > label, .field .label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
input[type=text], input[type=number], input[type=search], select {
  font: inherit; font-size: var(--fs-md); color: var(--ink); background: var(--surface);
  min-height: 44px; padding: var(--s2) var(--s3); border: 1px solid #b9bdcc; border-radius: var(--radius); width: 100%;
}
input:disabled, select:disabled { background: #eceef4; color: var(--ink-3); cursor: not-allowed; }
input[aria-invalid="true"] { border-color: var(--error); background: var(--error-soft); }
input:focus-visible, select:focus-visible { outline: 3px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.combo { position: relative; }
.combo input { padding-right: var(--s6); }
.listbox { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: var(--s1); list-style: none; max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid #b9bdcc; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(31, 35, 48, 0.14); }
.listbox li { padding: var(--s2) var(--s3); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.listbox li[aria-selected="true"], .listbox li:hover { background: var(--primary-soft); color: var(--primary-strong); }
.listbox li.more { color: var(--ink-3); cursor: default; font-size: var(--fs-xs); }
.listbox li.more:hover { background: transparent; color: var(--ink-3); }
details.adv { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.adv summary { cursor: pointer; padding: var(--s3) var(--s4); font-size: var(--fs-sm); font-weight: var(--fw-medium); min-height: 44px; display: flex; align-items: center; list-style: none; gap: var(--s2); border-radius: var(--radius); }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary .chev { color: var(--ink-2); transition: transform 0.15s; }
details.adv[open] summary .chev { transform: rotate(90deg); }
.adv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s4); padding: 0 var(--s4) var(--s4); }
.adv-grid .full { grid-column: 1 / -1; }

/* run bar */
.runbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s5); }
.run-status { flex: 1 1 260px; font-size: var(--fs-sm); color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.run-status.has-error { color: var(--error); }
.privacy { font-size: var(--fs-xs); color: var(--ink-3); }
.runtime { font-size: var(--fs-xs); color: var(--ink-3); }

/* progress */
.progress-card { display: flex; flex-direction: column; gap: var(--s4); }
.progress-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s3); }
.progress-title { font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.bar { height: 8px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); width: 0; transition: width 0.3s; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); font-size: var(--fs-sm); }
.steps li { display: grid; grid-template-columns: 20px 1fr auto; gap: var(--s2); align-items: baseline; color: var(--ink-3); }
.steps li .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); align-self: center; justify-self: center; }
.steps li.done { color: var(--ink-2); }
.steps li.done .dot { background: var(--ok); border-color: var(--ok); }
.steps li.active { color: var(--ink); font-weight: var(--fw-medium); }
.steps li.active .dot { border-color: var(--primary); background: var(--primary-soft); animation: pulse 1.2s ease-in-out infinite; }
.steps .detail { font-size: var(--fs-xs); font-weight: var(--fw-regular); color: var(--ink-3); overflow-wrap: anywhere; }
.steps .time { font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--primary-soft); } }
.progress-note { font-size: var(--fs-sm); color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* failure */
.failure { display: flex; flex-direction: column; gap: var(--s3); }
.failure details { font-size: var(--fs-sm); }
.failure summary { cursor: pointer; font-weight: var(--fw-medium); color: var(--ink-2); padding: var(--s1) 0; }
.failure pre { margin: var(--s2) 0 0; padding: var(--s3); background: #1f2330; color: #e8eaf2; border-radius: var(--radius-sm); overflow: auto; font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.5; max-height: 320px; white-space: pre-wrap; word-break: break-word; }

/* results */
.result-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s3) var(--s5); }
.result-sum { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; flex: 1 1 360px; }
.result-sum .main { font-weight: var(--fw-medium); }
.result-sum .sub { font-size: var(--fs-sm); color: var(--ink-2); }
.result-sum code, .msg code { font-family: var(--mono); font-size: var(--fs-xs); background: var(--primary-soft); color: var(--primary-strong); padding: 1px 6px; border-radius: var(--radius-sm); }
.charts { display: grid; grid-template-columns: 1fr; gap: var(--s5); }
figure { margin: 0; display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
figcaption { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.5; }
.chart-box { position: relative; width: 100%; background: var(--surface); }
.chart-box svg, .chart-box canvas { display: block; width: 100%; }
.chart-box canvas { cursor: crosshair; touch-action: manipulation; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: var(--fs-xs); padding: var(--s1) var(--s2); border-radius: var(--radius-sm); white-space: nowrap; z-index: 5; transform: translate(-50%, calc(-100% - 10px)); }
.chart-svg text { font-family: var(--font); fill: var(--ink-2); font-size: 12px; }
.chart-svg .axis-title { fill: var(--ink); font-weight: 500; }

.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); margin-bottom: var(--s3); }
.table-tools .search { flex: 1 1 240px; max-width: 360px; }
.table-tools .count { font-size: var(--fs-sm); color: var(--ink-2); }
.table-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--fs-sm); }
th, td { padding: var(--s2) var(--s3); text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { position: sticky; top: 0; background: #eef0f7; z-index: 2; font-weight: var(--fw-medium); color: var(--ink); padding: 0; }
thead th button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: var(--s1); width: 100%; padding: var(--s2) var(--s3); cursor: pointer; font-weight: var(--fw-medium); }
thead th button:hover { background: var(--primary-line); }
thead th button:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
thead th .arrow { display: inline-flex; width: 16px; height: 16px; color: var(--primary); }
td.num, th.num, th.num button { text-align: right; justify-content: flex-end; font-variant-numeric: tabular-nums; }
td.desc { white-space: normal; min-width: 240px; max-width: 420px; color: var(--ink-2); }
td.name { font-family: var(--mono); font-size: var(--fs-xs); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--primary-soft); }
tbody tr[aria-selected="true"] { background: #e2e5f8; box-shadow: inset 4px 0 0 var(--primary); }
tbody tr:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
tbody tr.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #ffe3c9; } to { background: transparent; } }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap; }
.table-foot .count { font-size: var(--fs-sm); color: var(--ink-2); }
.empty { padding: var(--s5); text-align: center; color: var(--ink-3); font-size: var(--fs-sm); }

@media (min-width: 720px) {
  .wrap { padding-inline: var(--s5); }
  .slots { grid-template-columns: 1fr 1fr; }
  .options { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .adv-wrap { grid-column: 1 / -1; }
  .adv-grid { grid-template-columns: repeat(4, 1fr); }
  .adv-grid .full { grid-column: auto; }
}
@media (min-width: 960px) {
  .charts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 719px) {
  h1 { font-size: var(--fs-lg); }
  .intro { flex-direction: column; align-items: flex-start; padding-block: var(--s5) var(--s4); }
  .intro .logo { display: none; }
  .panel { padding: var(--s4); }
  .site-header .wrap { min-height: 56px; }
  .nav { gap: var(--s3); }
  .runbar .btn-primary { width: 100%; }
  .brand span { font-size: var(--fs-md); }
}
@media (max-width: 380px) {
  .nav a:nth-child(n+3) { display: none; }
}

/* tutorial */
.doc { max-width: 800px; margin: 0 auto; padding-block: var(--s6) var(--s7); display: flex; flex-direction: column; gap: var(--s5); }
.doc p, .doc li, .doc dd { color: var(--ink-2); }
.doc strong { color: var(--ink); font-weight: var(--fw-medium); }
.doc ul, .doc ol { margin: 0; padding-left: var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.doc code { font-family: var(--mono); font-size: var(--fs-sm); background: var(--primary-soft); color: var(--primary-strong); padding: 1px 6px; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.doc dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: var(--s3); }
.doc dt { font-weight: var(--fw-medium); color: var(--ink); }
.doc dd { margin: 0; }
.doc .figure-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); }
.doc .figure-box img { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; }
.mk { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1; vertical-align: 1px; }
.doc .formula { font-family: var(--mono); font-size: var(--fs-sm); background: var(--primary-soft); color: var(--ink); padding: var(--s3) var(--s4); border-radius: var(--radius); overflow-x: auto; }
.doc .errs { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.doc .errs th, .doc .errs td { white-space: normal; vertical-align: top; }
.doc .errs thead th { position: static; padding: var(--s2) var(--s3); }
.doc .errs td:first-child { width: 42%; color: var(--ink); }
.doc .errs-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
@media (min-width: 720px) { .doc dl { grid-template-columns: 140px 1fr; gap: var(--s3) var(--s5); } }
