:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --dim: #6d6d68;
  --line: #dedcd6;
  --line-soft: #ebe9e4;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --green: #2f7d4f;
  --green-bg: #e6f2ea;
  --amber: #9a6206;
  --amber-bg: #fbf0dc;
  --red: #a32b20;
  --red-bg: #fbe9e7;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius: 7px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --panel: #1f2124;
    --ink: #e8e6e1;
    --dim: #9a9893;
    --line: #34373b;
    --line-soft: #2a2c30;
    --accent: #6fb0dc;
    --accent-ink: #10161b;
    --green: #74c493;
    --green-bg: #1c2f24;
    --amber: #e0ab54;
    --amber-bg: #33280f;
    --red: #f08b7f;
    --red-bg: #351b18;
  }
}

* { box-sizing: border-box; }

/* Any author `display` rule beats the UA's [hidden] { display: none }, so a
   flex/grid element with the hidden attribute would stay visible. Guard it
   once, globally, rather than remembering per selector. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); }

/* ---------- chrome ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: inherit;
  text-decoration: none;
  letter-spacing: .01em;
}
.brand b { font-weight: 650; }

.top nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}
.top nav a { text-decoration: none; color: var(--dim); }
.top nav a:hover { color: var(--ink); }
.top nav a.on { color: var(--ink); font-weight: 600; }
.top nav .role {
  font: 11px/1 var(--mono);
  letter-spacing: .04em;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 8px;
}
.top nav form { margin: 0; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}

footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 22px 40px;
  color: var(--dim);
  font-size: 13px;
}

/* ---------- structure ---------- */

h1 { font-size: 21px; margin: 0 0 4px; font-weight: 650; }
.lede { margin: 0; color: var(--dim); font-size: 14px; max-width: 62ch; }
.head { margin-bottom: 22px; }
.small { font-size: 13px; }
.dim { color: var(--dim); }
.opt { color: var(--dim); font-weight: 400; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.narrow { max-width: 380px; margin: 40px auto; }

fieldset {
  position: relative;   /* anchors the custom-sequence button to the top edge */
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  margin: 0 0 16px;
}

legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  padding: 0 6px;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 11px/1 var(--mono);
}

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
label.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 400;
  color: var(--dim);
  font-size: 13px;
  cursor: pointer;
}
label.check input { margin-top: 3px; flex: none; }
label.check span { max-width: 62ch; }

input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

button {
  font: inherit;
  font-weight: 600;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.linkish, a.linkish {
  background: none;
  border: none;
  color: var(--dim);
  font-weight: 400;
  padding: 0;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
button.linkish:hover, a.linkish:hover { color: var(--ink); }

.actions { display: flex; align-items: center; gap: 18px; }

/* ---------- login ---------- */

form.login { margin-top: 16px; }
form.login button { width: 100%; margin-top: 14px; }
.error { color: var(--red); font-size: 13px; min-height: 1em; margin: 12px 0 0; }

/* ---------- mode switch ---------- */

.modes { display: flex; gap: 10px; margin-bottom: 16px; }
@media (max-width: 620px) { .modes { flex-direction: column; } }

button.mode {
  flex: 1;
  display: block;
  text-align: left;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--dim);
  font-weight: 400;
}
button.mode b { display: block; color: var(--ink); font-size: 14px; }
button.mode span { font-size: 12.5px; }
button.mode.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
button.mode.on b { color: var(--accent); }

#pool-block { margin-top: 18px; border-top: 1px solid var(--line-soft); padding-top: 6px; }
#pool-blurb { margin: 9px 0 0; max-width: 66ch; }

/* localization checkboxes */
.locs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 4px 16px;
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.locs li { margin: 0; }
.locs label.check { align-items: center; padding: 5px 0; }
.locs label.check input { margin-top: 0; }
.locs label.check > span { display: flex; align-items: baseline; gap: 7px; }
.locs b { color: var(--ink); font-weight: 500; font-size: 13.5px; }
.locs .count { font: 12px/1 var(--mono); color: var(--dim); }

/* pasted custom sequences */
/* Sits on the fieldset's top border, mirroring the legend on the other side.
   translateY(-50%) centres it on the edge exactly; the panel-coloured
   background masks the border behind it, the way a legend does. */
button.corner {
  position: absolute;
  top: 0;
  right: 16px;
  transform: translateY(-50%);
  background: var(--panel);
  padding: 0 7px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}
button.corner:hover { color: var(--accent); text-decoration: underline; }
button.corner[aria-expanded="true"] { text-decoration: underline; }
#custom-block {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
#custom-block textarea {
  font: 12.5px/1.5 var(--mono);
  word-break: break-all;
}
#custom-block .actions { margin-top: 12px; }
#custom-status { margin: 7px 0 0; min-height: 1.2em; font-size: 13px; }
#custom-status.bad { color: var(--red); }
.picked li.is-custom { border-left: 2px solid var(--accent); padding-left: 10px; }

.req {
  font: 600 10px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 5px;
}

.screen-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}
.screen-stats li { display: flex; flex-direction: column; }
.screen-stats b { font: 650 17px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.screen-stats span { font-size: 12px; color: var(--dim); }

.kind {
  font: 600 10px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--dim);
  margin-top: 3px;
}

/* ---------- typeahead ---------- */

.search-wrap { position: relative; }

.suggest {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 330px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0,0,0,.14);
}
.suggest li {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 4px;
  cursor: pointer;
}
.suggest li[aria-selected=true] { background: var(--line-soft); }
.suggest li.none { cursor: default; color: var(--dim); font-size: 13px; }
.suggest .tag { font: 600 13px/1.3 var(--mono); }
.suggest .len { font: 12px/1.3 var(--mono); color: var(--dim); flex: none; }
.suggest .gene { font-style: italic; font-size: 13px; }
.suggest .prod {
  color: var(--dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.flag {
  flex: none;
  font: 600 10px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 5px;
  border-radius: 3px;
}
.flag.variant { background: var(--amber-bg); color: var(--amber); }
.flag.orf { background: var(--line-soft); color: var(--dim); }
.flag.toobig { background: var(--red-bg); color: var(--red); }

/* ---------- picked rows ---------- */

.picked { list-style: none; margin: 12px 0 0; padding: 0; }
.picked li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-top: 1px solid var(--line-soft);
}
.picked li:first-child { border-top: none; }
.picked .name { flex: 1; min-width: 0; }
.picked .name b { font: 600 13px/1.4 var(--mono); }
.picked .name .sub {
  display: block;
  color: var(--dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picked .aa { font: 13px/1 var(--mono); color: var(--dim); flex: none; }

.copies { display: flex; align-items: center; gap: 2px; flex: none; }
.copies button {
  width: 26px;
  height: 26px;
  padding: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  line-height: 1;
}
.copies span {
  min-width: 30px;
  text-align: center;
  font: 13px/1 var(--mono);
}
.remove {
  flex: none;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 17px;
  line-height: 1;
  padding: 4px 6px;
}
.remove:hover { color: var(--red); }

.ligand-row { display: flex; gap: 8px; align-items: center; }
.ligand-row select { flex: 2; }
.ligand-row input { flex: 1; }
.ligand-row button { flex: none; }
@media (max-width: 620px) { .ligand-row { flex-wrap: wrap; } }

/* ---------- size meter ---------- */

.size-panel { border-radius: var(--radius); }

.size-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.size-head .total b { font: 650 26px/1 var(--mono); font-variant-numeric: tabular-nums; }
.size-head .total span { color: var(--dim); font-size: 13px; }

/* Band is no longer labelled with a chip; it survives as the meter colour and
   the wording of the note underneath. */
.pill {
  font: 600 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 5px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.meter {
  position: relative;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--line-soft);
  margin-bottom: 26px;
}
.meter-green, .meter-amber { position: absolute; top: 0; bottom: 0; }
.meter-green { left: 0; width: 68.75%; background: var(--green-bg); }
.meter-amber { left: 68.75%; right: 0; background: var(--amber-bg); }
.meter-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0;
  background: var(--green);
  transition: width .12s ease-out;
}
.size-panel[data-band=amber] .meter-fill { background: var(--amber); }
.size-panel[data-band=red] .meter-fill { background: var(--red); }

.tick { position: absolute; top: 100%; border-left: 1px solid var(--line); height: 6px; }
.tick span {
  position: absolute;
  top: 7px;
  left: 0;
  transform: translateX(-50%);
  font: 11px/1 var(--mono);
  color: var(--dim);
  white-space: nowrap;
}
.tick-green { left: 68.75%; }
.tick-amber { left: 100%; }
.tick-amber span { transform: translateX(-100%); }

.size-note { font-size: 13px; color: var(--dim); margin: 0; max-width: 66ch; }
.size-panel[data-band=amber] .size-note { color: var(--amber); }
.size-panel[data-band=red] .size-note { color: var(--red); }

/* ---------- callouts ---------- */

.callout {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13.5px;
  margin: 14px 0 0;
  border: 1px solid transparent;
}
.callout.warn { background: var(--amber-bg); color: var(--amber); border-color: currentColor; }
.callout.bad  { background: var(--red-bg);   color: var(--red);   border-color: currentColor; }
.callout.good { background: var(--green-bg); color: var(--green); border-color: currentColor; }
.callout b { font-family: var(--mono); }
.callout p { margin: 0 0 7px; }
.callout p:last-child { margin-bottom: 0; }
.callout p.excluded {
  font: 12.5px/1.6 var(--mono);
  opacity: .85;
}

/* ---------- queue ---------- */

.queue-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.filters { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.export { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.export[data-admin="0"] { display: none; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; vertical-align: top; }
thead th {
  font: 600 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody tr:not(.why):not(.empty) td { border-top: 1px solid var(--line-soft); }
tbody tr:first-child td { border-top: none; }
td.ref { font: 600 13px/1.5 var(--mono); white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.empty td { padding: 30px; text-align: center; color: var(--dim); }

tr.why td {
  padding: 0 12px 11px;
  color: var(--dim);
  font-size: 13px;
}

.pill { display: inline-block; background: var(--line-soft); color: var(--dim); }
.s-pending { background: var(--line-soft); color: var(--ink); }
.s-in-progress { background: var(--amber-bg); color: var(--amber); }
.s-done { background: var(--green-bg); color: var(--green); }

/* Three-segment status switch (admin). Active segment borrows the same
   colour pairs as the read-only pills, so both themes work for free. */
.switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg);
}
.switch .seg {
  background: none;
  border: none;
  border-right: 1px solid var(--line);
  border-radius: 0;
  color: var(--dim);
  font: 600 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 6px 11px;
  white-space: nowrap;
}
.switch .seg:last-child { border-right: none; }
.switch .seg:hover { color: var(--ink); }
.switch .seg:focus-visible { outline-offset: -2px; }
.switch .seg.on { color: var(--ink); background: var(--line-soft); cursor: default; }
.switch .seg.on[data-status="in-progress"] { background: var(--amber-bg); color: var(--amber); }
.switch .seg.on[data-status="done"] { background: var(--green-bg); color: var(--green); }
input.note { padding: 4px 7px; font-size: 12.5px; min-width: 130px; }
tr.saved input.note, tr.saved .switch { border-color: var(--green); }

.warn-dot {
  display: inline-block;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--amber-bg);
  color: var(--amber);
  text-align: center;
  font: 600 11px/15px var(--mono);
  cursor: help;
}

/* prey rows whose pair exceeds the hard cap */
.picked li.over { opacity: .55; }
.picked li.over .aa { color: var(--red); }
p.lead { margin: 0 0 10px; max-width: 66ch; }

/* admin result cell: ipTM, path, note */
.result { display: flex; flex-direction: column; gap: 4px; min-width: 190px; }
.result .res { padding: 3px 6px; font-size: 12px; }
.result .iptm { width: 70px; font-family: var(--mono); }

/* sequence-type pill inside the custom-sequence panel */
#custom-type { margin-top: 5px; flex-wrap: wrap; }
#custom-type .seg { padding: 7px 10px; }

/* ---------- queue sections ---------- */

.qsec { margin-bottom: 30px; }
.qhead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.qhead h2 { font-size: 16px; margin: 0 0 2px; font-weight: 650; }
.qhead p { margin: 0; }

a.download {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 5px;
  text-decoration: none;
  white-space: nowrap;
}
a.download:hover { filter: brightness(1.08); }
/* Per-row export. Reads as a control, not as a caption -- the previous
   10.5px bare link was routinely missed. */
a.rowdl {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 9px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--accent);
  font: 600 11px/1 var(--mono);
  text-decoration: none;
  white-space: nowrap;
}
a.rowdl:hover { background: var(--accent); color: var(--accent-ink); }

/* ligand picker sits collapsed until the corner button opens it */
#ligand-block { margin-top: 4px; }
#ligand-list:not(:empty) { margin-top: 12px; }

/* Primary "add" affordance inside a box: big, left-aligned, sitting in the
   normal flow rather than pinned to a corner. Outlined so it never competes
   with the solid submit button. */
button.big-add {
  display: block;
  margin: 6px 0 2px;
  padding: 7px 14px;
  background: none;
  border: 1px dashed var(--line);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
}
button.big-add:hover {
  border-color: var(--accent);
  border-style: solid;
  background: var(--line-soft);
}


/* inline sequence viewer on picked rows */
button.seqbtn {
  flex: none;
  background: none;
  border: 1px solid var(--line);
  color: var(--dim);
  font: 600 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 5px 8px;
}
button.seqbtn:hover { color: var(--ink); border-color: var(--dim); }
button.seqbtn.on { color: var(--accent); border-color: var(--accent); }
.picked li.seqrow { display: block; border-top: none; padding: 0 0 10px; }
.seqtext {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  font: 12px/1.7 var(--mono);
  letter-spacing: .5px;
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 190px;
  overflow-y: auto;
  user-select: all;
}

/* ccd / smiles switch inside the ligand row */
#ligand-kind { flex: none; }
#ligand-kind .seg { padding: 8px 10px; }
.ligand-row input[type=text] { flex: 1; min-width: 150px; }
.picked .name .sub { word-break: break-all; }

/* priority pill in the requester box */
.who { margin-top: 4px; }
#priority { margin-top: 5px; }
#priority .seg { padding: 8px 14px; }
#priority .seg.on[data-priority="high"] { background: var(--amber-bg); color: var(--amber); }
#priority .seg.on[data-priority="low"] { background: var(--line-soft); color: var(--dim); }
.pill.prio-high { background: var(--amber-bg); color: var(--amber); }
.pill.prio-low { background: var(--line-soft); color: var(--dim); }

/* a required field that was submitted empty */
input.bad, textarea.bad {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}
a.rowdl + a.rowdl { margin-left: 5px; }
