/* Design tokens mirror sfm-mass-spec/docs/demo.html so the portal reads as part of
   the same family. Structure tiles stay light in dark mode because RDKit draws in
   black. */
:root {
  --bg: #f3f3f8; --surface: #ffffff; --surface-2: #fafaff; --ink: #16161f;
  --muted: #6a6a7e; --faint: #9797ab; --border: #e5e5ef; --border-strong: #d3d3e2;
  --accent: #5b4de0; --accent-soft: #ece9fc; --signal: #e0862f; --precursor: #c0392b;
  --good: #0e9d78; --good-soft: #dcf5ec; --warn: #b4690e; --warn-soft: #fdf3e2;
  --tile: #ffffff; --tile-border: #e5e5ef;
  --shadow: 0 1px 2px rgba(20,20,40,.05), 0 8px 24px rgba(20,20,40,.06);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d13; --surface: #16161f; --surface-2: #1b1b26; --ink: #ececf4;
    --muted: #a0a0b6; --faint: #6c6c82; --border: #262633; --border-strong: #34344a;
    --accent: #8f80f5; --accent-soft: #23213a; --signal: #f0a44e; --precursor: #f0655a;
    --good: #2dd4a7; --good-soft: #123329; --warn: #f0a44e; --warn-soft: #2a2113;
    --tile: #f4f4f8; --tile-border: #2a2a38;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 22px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.brand { font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
.brand small {
  display: block; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 400;
}
.topbar .spacer { flex: 1; }
.who { font-family: var(--mono); font-size: 11.5px; color: var(--muted); text-align: right; }
.who b { color: var(--ink); font-weight: 600; }

.tabs { display: flex; gap: 4px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tab {
  border: 0; background: none; padding: 10px 14px; font-size: 13px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; width: auto; border-radius: 0;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 22px 80px; }

/* ---------- shared ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 16px; }
h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.015em; }
h2 { margin: 0 0 14px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h3 { margin: 26px 0 8px; font-size: 15px; }
h4 {
  margin: 20px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: .03em; text-transform: uppercase;
}
/* Swagger UI renders inside an iframe so it keeps its own stylesheet without
   fighting the portal's, and so the reference is unambiguously the generated
   document rather than a re-styled copy of it. */
#swagger-frame {
  width: 100%; height: 78vh; min-height: 520px; border: 0; display: block;
  background: #fff;   /* Swagger UI is light-only; a dark backdrop shows through while it loads */
}
p.sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; max-width: 74ch; }

label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; }
input, select, textarea, button {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 132px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.field { margin-bottom: 12px; }
.hint { font-size: 11.5px; color: var(--faint); margin-top: 5px; }
.opt {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint); margin-left: 4px;
}

button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer; padding: 11px; margin-top: 4px;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.primary:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { width: auto; padding: 6px 12px; font-size: 12.5px; cursor: pointer; }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.danger { width: auto; padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--precursor); border-color: var(--border-strong); }
button.danger:hover { border-color: var(--precursor); }
select.inline { width: auto; padding: 5px 8px; font-size: 12.5px; }

.banner { border-radius: 9px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px; border: 1px solid; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.banner.err { background: var(--warn-soft); border-color: var(--precursor); color: var(--precursor); }
.banner.ok { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.empty { color: var(--muted); font-size: 13.5px; }
.spinner {
  display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
code, pre { font-family: var(--mono); }
pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px; overflow-x: auto; font-size: 12px; margin: 0 0 12px;
}
code.inline { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: 12px; }

/* ---------- login ---------- */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
/* /auth/callback. On screen for the moment between the redirect landing and
   the token exchange finishing, and for as long as it takes to read an error. */
.callback { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
#cognito-or { text-align: center; margin: 10px 0; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 21px; }

/* ---------- match ---------- */
.grid { display: grid; grid-template-columns: 370px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.plot { width: 100%; height: auto; display: block; margin: 2px 0 14px; }
.plot .axis { stroke: var(--border-strong); stroke-width: 1; }
.plot .grid { stroke: var(--border); stroke-width: 1; }
.plot .peak { stroke: var(--signal); stroke-width: 2; stroke-linecap: round; }
/* Peaks the service will drop, per the band reported by /limits. Drawn rather than
   hidden so a mis-declared unit is visible instead of mysterious. */
.plot .peak.dropped { stroke: var(--precursor); stroke-dasharray: 2 2; opacity: .8; }
.plot .prec { stroke: var(--precursor); stroke-width: 1.5; stroke-dasharray: 3 3; }
.plot text { fill: var(--faint); font-family: var(--mono); font-size: 10px; }
.plot text.tick { fill: var(--faint); font-size: 10px; }
.plot text.axis-title { fill: var(--muted); font-size: 10px; }
.plot text.prec-label { fill: var(--precursor); font-size: 10px; }
.plot text.warn { fill: var(--precursor); }

/* ---------- studio framing ---------- */
.lede {
  display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap;
  margin-bottom: 18px;
}
.lede h1 { font-size: 20px; margin: 0; }
.lede p { margin: 0; color: var(--muted); font-size: 13px; max-width: 70ch; }
.lede code { font-size: 12px; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button {
  width: auto; border: 0; border-radius: 0; padding: 5px 12px; font-size: 12px;
  cursor: pointer; background: var(--surface-2); color: var(--muted);
}
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; }

pre.res { max-height: 520px; overflow: auto; margin: 0; }

/* A section heading with the one fact that frames what follows. */
.sec-head { display: flex; align-items: baseline; gap: 12px; margin: 22px 0 6px; }
.sec-head h4 { margin: 0; }
.sec-head .meta {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .04em; text-transform: uppercase; color: var(--faint);
}

/* The response header. Each figure gets a labelled cell so the eye can land on
   one without reading the whole line, and the dividers do the separating that
   whitespace was being asked to do. */
.summary {
  /* Grid, because a wrapped flex row leaves a divider hanging at the end of the
     line and :last-child cannot see where the rows broke. Dividers are inset
     shadows on the cells rather than gaps showing a darker background: the last
     row is usually part empty, and a gap-coloured hole there reads as a missing
     panel. Inset shadows are clipped to the cell, so the ones along the right and
     bottom edges land on the container border instead of doubling it. */
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  margin: 0 0 16px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.summary .stat {
  padding: 9px 14px;
  box-shadow: inset -1px 0 0 var(--border), inset 0 -1px 0 var(--border);
}
.summary .stat.wide { grid-column: span 2; }
/* Below two columns the span would leave a one-cell row on its own. */
@media (max-width: 700px) { .summary .stat.wide { grid-column: span 1; } }
.stat .k {
  display: block; font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 2px; white-space: nowrap;
}
.stat .v { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--ink); }
.stat .u { font-style: normal; font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 4px; }
.hits { display: flex; flex-direction: column; gap: 10px; }
.hit {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center;
  border: 1px solid var(--border); border-radius: 11px; padding: 12px; background: var(--surface-2);
}
.hit.top { border-color: var(--good); background: var(--good-soft); }
.tile {
  width: 96px; height: 96px; background: var(--tile); border: 1px solid var(--tile-border);
  border-radius: 8px; display: grid; place-items: center; overflow: hidden;
}
.tile svg { width: 100%; height: 100%; }
.tile .none { font-size: 10px; color: var(--faint); font-family: var(--mono); }
/* Row-sized tile for the catalogue listing. Small enough that fifty of them scan
   as a column rather than a gallery, large enough to tell two skeletons apart. */
.tile.sm { width: 54px; height: 54px; border-radius: 6px; }
.tile.sm .none { font-size: 8.5px; }
table.entries td { padding: 5px 10px 5px 0; }
table.entries td.row-action { text-align: right; padding-right: 0; width: 1%; white-space: nowrap; }
table.entries td.row-action button { padding: 4px 10px; font-size: 11.5px; }
.hit-name { font-weight: 600; font-size: 14.5px; margin: 0 0 2px; }
.hit-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.hit-smiles { font-family: var(--mono); font-size: 11px; color: var(--faint); word-break: break-all; margin-top: 3px; }
.rank { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.score { text-align: right; min-width: 92px; }
.score-val { font-family: var(--mono); font-size: 17px; font-weight: 600; }
.bar { height: 4px; border-radius: 2px; background: var(--border); margin-top: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.hit.top .bar > i { background: var(--good); }
.ood { margin-top: 6px; font-size: 11.5px; color: var(--warn); }

/* ---------- keys ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 600; padding: 0 10px 8px 0; }
td { padding: 9px 10px 9px 0; border-top: 1px solid var(--border); vertical-align: middle; }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
.pill { display: inline-block; font-family: var(--mono); font-size: 10.5px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted); margin: 0 3px 3px 0; }
.pill.dead { color: var(--precursor); border-color: var(--precursor); }
.secret { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.secret input { font-family: var(--mono); font-size: 12px; }
.scope-picker { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0 12px; }
.scope-picker label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); margin: 0; }
.scope-picker input { width: auto; }

/* ---------- catalogues ---------- */
.cat-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: left; cursor: pointer; padding: 9px 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; margin-bottom: 6px; font-size: 13.5px; color: var(--ink);
}
.cat-row:hover { border-color: var(--accent); }
.cat-row.active { border-color: var(--accent); background: var(--accent-soft); }
.cat-row .nm { font-weight: 600; }
.cat-row .sub2 { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.cat-row .count { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

input[type="file"] {
  padding: 7px 9px; font-size: 12.5px; cursor: pointer;
}
input[type="file"]::file-selector-button {
  font-family: inherit; font-size: 12px; margin-right: 10px; cursor: pointer;
  padding: 4px 10px; border-radius: 6px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong);
}
input[type="file"]:hover::file-selector-button { border-color: var(--accent); color: var(--accent); }

.pager { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

.cbx {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  color: var(--ink); margin: 0 0 12px;
}
.cbx input { width: auto; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
