/* qRNAmap site styles. Light and dark follow the system (prefers-color-scheme).
   A saved choice sets <html data-theme="light"> or <html data-theme="dark"> (theme.js).
   No external fonts, images or scripts. */
:root {
  --bg: #fbfbfa; --fg: #1d2024; --muted: #5b6470; --line: #d9dde2; --link: #0b5cad;
  --note: #f1f3f5; --accent: #0b5cad; --accent-fg: #ffffff; --warn: #8a4b00; --warn-bg: #fff4e0;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a; --fg: #e6e8ea; --muted: #9aa4af; --line: #2c3238; --link: #6cb2ff;
    --note: #1c2024; --accent: #6cb2ff; --accent-fg: #0b1218; --warn: #ffc875; --warn-bg: #2a2114;
  }
}
:root[data-theme="dark"] {
  --bg: #14171a; --fg: #e6e8ea; --muted: #9aa4af; --line: #2c3238; --link: #6cb2ff;
  --note: #1c2024; --accent: #6cb2ff; --accent-fg: #0b1218; --warn: #ffc875; --warn-bg: #2a2114;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--fg); }
body { font: 16px/1.55 system-ui, sans-serif; margin: 0 auto; max-width: 46rem; padding: 2rem 16px 4rem; background: var(--bg); overflow-wrap: break-word; }
h1 { margin: 0 0 .25rem; font-size: 1.8rem; }
/* Logo tile in the page title (decorative: the title text names the page). */
.brand-icon { height: 1.3em; width: 1.3em; vertical-align: -.28em; margin-right: .5rem; }
h2 { margin: 2rem 0 .5rem; font-size: 1.15rem; }
h3 { margin: 1.2rem 0 .3rem; font-size: 1rem; }
p.lead { margin: 0 0 1.5rem; color: var(--muted); }
a { color: var(--link); }
ul { padding-left: 1.2rem; }
code { font-family: var(--mono); font-size: .9em; overflow-wrap: anywhere; }
.note { background: var(--note); border: 1px solid var(--line); border-radius: 6px; padding: .75rem 1rem; }
.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); border-radius: 6px; padding: .6rem 1rem; }
.button { display: inline-block; background: var(--accent); color: var(--accent-fg); text-decoration: none; font-weight: 600;
  padding: .7rem 1.4rem; border-radius: 6px; border: 0; font-size: 1.05rem; }
.button:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid var(--fg); outline-offset: 2px; }
.topbar { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.button-reset { background: var(--note); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: .25rem .65rem; font: inherit; font-size: .85rem; cursor: pointer; transition: border-color .15s ease; }
.button-reset:hover { border-color: var(--warn); color: var(--warn); }
.themes { display: flex; gap: .4rem; }
.themes button { background: var(--note); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: .25rem .6rem; font: inherit; font-size: .85rem; cursor: pointer; }
.themes button[aria-pressed="true"] { border-color: var(--accent); font-weight: 600; }
table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
th, td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: left; vertical-align: top; }
footer { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1rem; color: var(--muted); font-size: .9rem; }

/* Tool shell: three steps, enabled in order */
.step { border: 1px solid var(--line); border-radius: 6px; padding: .25rem 1rem 1rem; margin: 1rem 0; }
.step > h2 { margin-top: .75rem; }
.step[data-state="locked"] { opacity: .6; }
.step[data-state="done"] > h2::after { content: " (done)"; color: var(--muted); font-weight: 400; }
.step .reason { color: var(--muted); margin: 0 0 .5rem; }
.step fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.preview-label { font-weight: 600; }

/* Step 1: genome */
.choice { display: flex; flex-direction: column; gap: .2rem; margin: .5rem 0 .75rem; }
#genome-panel label { display: block; margin-top: .5rem; }
#genome-panel .choice label { margin-top: 0; }
#genome-filter, #genome-menu { width: 100%; font: inherit; margin: .25rem 0; }
#genome-panel input[type="file"] { max-width: 100%; }
#genome-panel button:not(.button) { font: inherit; padding: .35rem .9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--note); color: var(--fg); cursor: pointer; }
#genome-panel .button { margin-top: .5rem; cursor: pointer; }
#genome-progress { width: 100%; }
.small { font-size: .9rem; color: var(--muted); }
.error { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); border-radius: 6px; padding: .6rem 1rem; white-space: pre-wrap; }

/* Step 2: samples */
#samples-panel details label { display: block; margin-top: .5rem; }
#samples-panel input[type="file"] { max-width: 100%; }
#samples-panel button:not(.button) { font: inherit; padding: .3rem .8rem; border-radius: 6px; border: 1px solid var(--line); background: var(--note); color: var(--fg); cursor: pointer; }
#samples-panel .button { margin-top: .5rem; cursor: pointer; }
#sample-table { margin: .75rem 0 .25rem; }
#sample-table input[type="text"] { font: inherit; max-width: 9rem; }
#sample-table input[type="file"] { max-width: 12rem; }
#sample-table .status { min-width: 12rem; font-size: .9rem; }
.mate-name { display: block; font-size: .85rem; }
.mate-name.missing, tr[data-invalid="true"] .status, tr[data-status="error"] .status { color: var(--warn); font-weight: 600; }
#samples-progress { width: 100%; }
ul.error { padding-left: 2rem; }

.testset-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; }
#testset-section { margin-bottom: 1rem; }
#testset-section button { font: inherit; padding: .35rem .8rem; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; }
#testset-section button:hover { border-color: var(--accent); }
#testset-status { margin-top: .5rem; }

/* Step 3: results */
#results-panel button:not(.button) { font: inherit; padding: .3rem .8rem; border-radius: 6px; border: 1px solid var(--line); background: var(--note); color: var(--fg); cursor: pointer; }
#results-panel .button { cursor: pointer; }
.download-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
#reads-folder { width: 100%; max-width: 20rem; font: inherit; margin: .25rem 0; }
#results-downloads { margin-bottom: 1.5rem; }
#results-mapping-table, #results-count-table { width: 100%; margin: .5rem 0 1rem; }
#results-count-table th { cursor: pointer; user-select: none; }
#results-count-table th:hover { background: var(--note); }
#results-count-table th[data-sort="asc"]::after { content: " \25B2"; font-size: .8em; }
#results-count-table th[data-sort="desc"]::after { content: " \25BC"; font-size: .8em; }
#count-search { width: 100%; max-width: 20rem; font: inherit; padding: .25rem .5rem; }
#heatmap-container, #pca-container, #volcano-container { margin: .5rem 0 1.5rem; overflow-x: auto; }
#volcano-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: .5rem 0; }
.qc-message { color: var(--muted); font-style: italic; }
svg.heatmap, svg.pca-plot, svg.volcano-plot { max-width: 100%; height: auto; font-family: system-ui, sans-serif; }
svg.volcano-plot a.volcano-gene-link { cursor: pointer; }
svg.volcano-plot a.volcano-gene-link:hover text { text-decoration: underline; }

/* ---------------------------------------------------------------------------------------------
   Controls: one button system for every panel, choice cards for radio groups, and file pickers that
   look like buttons. Labels never break inside a button; groups wrap as whole items instead. */
:root { --accent-hover: #094a8c; --ring: color-mix(in srgb, var(--accent) 35%, transparent); --radius: 8px; }
:root[data-theme="dark"] { --accent-hover: #8ec4ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --accent-hover: #8ec4ff; } }

button, .button, .file-button {
  font: inherit; font-size: .95rem; line-height: 1.2; white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.25rem; padding: .45rem .95rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--note); color: var(--fg);
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .05s ease;
}
button:hover, .file-button:hover { border-color: var(--accent); }
button:active, .button:active, .file-button:active { transform: translateY(1px); }
button:disabled, button:disabled:hover { opacity: .5; cursor: not-allowed; border-color: var(--line); transform: none; }
.button, button.button { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; padding: .55rem 1.2rem; font-size: 1rem; }
.button:hover, button.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-small, button.button.button-small { padding: .45rem .95rem; font-size: .95rem; margin-top: 0 !important; }
button:focus-visible, .file-button:focus-within { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--accent); }
/* The panel rules above set padding per panel; these keep every panel on the same sizes. */
#genome-panel button:not(.button), #samples-panel button:not(.button), #results-panel button:not(.button), #testset-section button {
  padding: .45rem .95rem; border-radius: var(--radius);
}
.themes button, .button-reset { min-height: 1.9rem; padding: .25rem .7rem; font-size: .85rem; }

/* File inputs: the real input stays (keyboard, tests) but is hidden inside a label styled as a button. */
.file-button { position: relative; font-size: .875rem; min-height: 2rem; padding: .3rem .75rem; }
.file-button input[type="file"] { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
#sample-table td.mate { min-width: 11rem; }
#sample-table .mate-name { margin-top: .3rem; overflow-wrap: anywhere; }
#sample-table td { vertical-align: middle; }
#sample-table th { white-space: nowrap; background: var(--note); font-weight: 600; font-size: .9rem; }
#sample-table th input.col-name { width: 7rem; }
#sample-table input[type="text"], #samples-panel input[type="number"], #native-sheet-path, #genome-filter {
  padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg);
}
#sample-table input[type="text"]:focus, #samples-panel input:focus, #genome-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* Rows of controls: items wrap as a whole, never in the middle of a label. */
.field-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .35rem 0 .25rem; }
.field-row input[type="text"] { flex: 1 1 18rem; min-width: 0; font: inherit; }
.testset-buttons button { white-space: normal; text-align: left; justify-content: flex-start; }

/* Radio groups as cards: a grid that stacks when narrow instead of wrapping text around the radios. */
fieldset.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .6rem; border: 0; padding: 0; margin: .75rem 0; }
fieldset.choice-cards[hidden] { display: none; }
fieldset.choice-cards legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
.choice-card { display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; row-gap: .15rem; align-items: start;
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease; }
.choice-card:hover { border-color: var(--accent); }
.choice-card input[type="radio"] { grid-row: 1 / span 2; margin: .2rem 0 0; accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }
.choice-card .choice-title { font-weight: 600; white-space: nowrap; }
.choice-card .choice-desc { grid-column: 2; font-size: .875rem; color: var(--muted); line-height: 1.4; }
.choice-card:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--ring); }
/* The genome-source radios: the same look as a segmented control. */
.choice[role="radiogroup"] { flex-direction: row; flex-wrap: wrap; gap: .5rem; }
.choice[role="radiogroup"] label { display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; padding: .45rem .8rem;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--bg); }
.choice[role="radiogroup"] label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.choice[role="radiogroup"] input { accent-color: var(--accent); margin: 0; }

#desktop-native-banner[data-native="false"] { border-color: var(--warn); background: var(--warn-bg); }
#desktop-native-banner p { margin: .2rem 0; }
#samples-busy:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
#samples-busy progress { flex: 1 1 100%; }
#samples-busy p { margin: 0; flex: 1 1 auto; }

/* Desktop app: a wider page (the window is 1100 px or more), so the sample table and plots need no side scroll. */
#frag-mean, #frag-sd { width: 6rem; }
#preview-pairs { width: 8rem; }
html.desktop body { max-width: min(76rem, 100%); padding-top: 1.25rem; }
html.desktop .step { padding: .5rem 1.25rem 1.25rem; }

/* Gene count table: a scroll box with a sticky header, a pager, an optional wrapping gene-info column and a gene popup. */
#count-table-wrap { max-height: 26rem; overflow: auto; resize: vertical; border: 1px solid var(--line); border-radius: 6px; margin: .5rem 0; }
#count-table-wrap.tall { max-height: 80vh; }
#count-table-wrap #results-count-table { margin: 0; }
#results-count-table thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; box-shadow: 0 1px 0 var(--line); }
#results-count-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#results-count-table td.gene-info { min-width: 12rem; max-width: 24rem; white-space: normal; font-size: .85em; color: var(--muted); }
#results-count-table td.gene-info .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#results-count-table td.gene-info b { color: var(--fg); font-weight: 600; }
#results-panel button.gene-link { font: inherit; color: var(--link); background: none; border: 0; border-radius: 0; padding: 0; min-height: 0; box-shadow: none; font-weight: 400; cursor: pointer; text-align: left; text-decoration: underline dotted; text-underline-offset: 2px; }
#results-panel button.gene-link:hover { text-decoration-style: solid; }
#count-pager { gap: .4rem; align-items: center; }
#count-page { width: 5rem; font: inherit; padding: .15rem .35rem; }
#gene-popup { position: fixed; inset: auto; margin: 0; max-width: min(26rem, calc(100vw - 32px)); padding: .75rem 1rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--fg); box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: .9rem; }
#gene-popup h4 { margin: 0 0 .25rem; font-size: 1rem; }
#gene-popup p { margin: .25rem 0; }
#gene-popup dl { display: grid; grid-template-columns: auto 1fr; gap: .1rem .75rem; margin: .4rem 0; font-size: .85rem; }
#gene-popup dt { color: var(--muted); }
#gene-popup dd { margin: 0; overflow-wrap: anywhere; }
#gene-popup .links a { margin-right: .75rem; }

/* Sample sheet builder (site/sheet/) */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.drop-zone { border: 2px dashed var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin: .75rem 0; text-align: center; transition: border-color .15s ease, background .15s ease; }
.drop-zone p { margin: .25rem 0; justify-content: center; }
.drop-zone.over { border-color: var(--accent); background: var(--note); }
#paste-names { width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: .85rem; }
.sheet-tools { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin: .5rem 0; }
.sheet-tools .tool-group { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.table-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 6px; }
.builder-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.builder-table th, .builder-table td { border-bottom: 1px solid var(--line); padding: .3rem .45rem; text-align: left; vertical-align: top; }
.builder-table thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; white-space: nowrap; }
.builder-table input[type="text"] { font: inherit; max-width: 12rem; }
.builder-table .col-name { font-weight: 600; }
.builder-table button.remove-col { min-height: 0; padding: 0 .4rem; margin-left: .2rem; line-height: 1.4; }
.builder-table td.files { font-family: var(--mono); font-size: .8rem; word-break: break-all; min-width: 12rem; }
.builder-table td.notes { min-width: 12rem; max-width: 22rem; }
.builder-table tr.has-problem td { background: var(--warn-bg); }
.builder-table .problem { color: var(--warn); font-weight: 600; }
.sheet-preview { font-family: var(--mono); font-size: .8rem; background: var(--note); border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; overflow: auto; max-height: 20rem; white-space: pre; }
body.wide-page { max-width: 80rem; }
.table-scroll .builder-table { display: table; }
.builder-table td.files { min-width: 16rem; }
/* A link styled as a button wraps on a narrow screen (the nowrap of buttons would make the page scroll sideways). */
a.button { white-space: normal; max-width: 100%; box-sizing: border-box; text-align: center; }

/* Public-data page (site/sra/) */
.sra-form .field-row { flex-wrap: wrap; }
details.study { border: 1px solid var(--line); border-radius: var(--radius); margin: .5rem 0; padding: .3rem .6rem; }
details.study > summary { cursor: pointer; }
.runs-table { border-collapse: collapse; width: 100%; font-size: .85rem; margin-top: .4rem; }
.runs-table th, .runs-table td { border-bottom: 1px solid var(--line); padding: .2rem .4rem; text-align: left; vertical-align: top; }
.attr-choice { border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .8rem; margin: .6rem 0; }
.attr-choice label { margin-right: .8rem; }
