:root {
  /* GeneRoute deep teal – deliberately not the NHS identity palette */
  --bg: #f3f7f7; --fg: #1f2d33; --muted: #4a5f66; --card: #ffffff; --border: #d5e0e2;
  --accent: #0b7285; --accent-dark: #08505d; --accent-soft: #e3f3f4;
  --head-bg: #0e5866; --head-fg: #ffffff; --head-edge: #3fc1c9; --head-focus: #9be7ec;
  --button: #0b7285; --button-hover: #08505d; --focus: #0b7285;
  --pill-bg: #fff9c4; --pill-fg: #4f3d00;
  --del-bg: #fde2e1; --del-fg: #8a1c14; --ins-bg: #dcf3e3; --ins-fg: #14532d;
  --warn-bg: #fff4e0; --warn-fg: #6b3d00;
  --shadow: 0 1px 2px rgb(33 43 50 / .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1b1e; --fg: #e6eeef; --muted: #a5b8bd; --card: #172629; --border: #2c4046;
    --accent: #5ccbd4; --accent-dark: #9fe3e8; --accent-soft: #143a40; --head-bg: #0a3c46; --pill-bg: #4a3d00; --pill-fg: #fff3b0;
    --button: #0f7f8f; --button-hover: #0b6675; --focus: #5ccbd4;
    --del-bg: #4a1d1b; --del-fg: #ffc9c4; --ins-bg: #14361f; --ins-fg: #b9f0c9; --warn-bg: #45300c; --warn-fg: #ffd9a0; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1b1e; --fg: #e6eeef; --muted: #a5b8bd; --card: #172629; --border: #2c4046;
  --accent: #5ccbd4; --accent-dark: #9fe3e8; --accent-soft: #143a40; --head-bg: #0a3c46; --pill-bg: #4a3d00; --pill-fg: #fff3b0;
  --button: #0f7f8f; --button-hover: #0b6675; --focus: #5ccbd4;
  --del-bg: #4a1d1b; --del-fg: #ffc9c4; --ins-bg: #14361f; --ins-fg: #b9f0c9; --warn-bg: #45300c; --warn-fg: #ffd9a0; --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.site-head :focus-visible { outline-color: var(--head-focus); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; margin: 4px 0 0; }
h2 { font-size: 1.35rem; margin: 0 0 6px; }
h3 { font-size: 1.1rem; margin: 0 0 10px; }

/* Header */
.site-head { background: var(--head-bg); color: var(--head-fg); padding: 14px 0; border-bottom: 4px solid var(--head-edge); }
.site-head a { color: var(--head-fg); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { flex: none; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.site-head a.brand-home { display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; text-decoration: none; opacity: .9; }
.brand-home::after { content: " ›"; }
.brand h1 { margin: 0; font-size: 1.4rem; line-height: 1.2; }
.brand h1 a { text-decoration: none; }
.brand p { margin: 2px 0 0; font-size: .9rem; opacity: .9; }
.pill { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--pill-bg); color: var(--pill-fg); font-size: .75rem; font-weight: 600; }
.head-link { font-size: .9rem; white-space: nowrap; }
main { padding: 20px 0 48px; }
.intro { color: var(--muted); max-width: 80ch; margin: 0 0 14px; }

/* Tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 14px; text-decoration: none; border-radius: 6px 6px 0 0; color: var(--muted); font-weight: 600; margin-bottom: -2px; border-bottom: 3px solid transparent; }
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* Cards and forms */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 12px 14px; align-items: start; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .95rem; }
.field input, .field select { width: 100%; padding: 9px 10px; font: inherit; color: var(--fg); background: var(--card); border: 2px solid var(--fg); border-radius: 4px; }
.field.actions { align-self: end; padding-bottom: 2px; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr 1fr; } .field.wide { grid-column: 1 / -1; } }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
button, .button { font: inherit; font-weight: 600; padding: 9px 16px; border: 0; border-radius: 4px; background: var(--button); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { background: var(--button-hover); color: #fff; }
button.secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); padding: 7px 14px; }
button.secondary:hover { background: var(--accent-soft); color: var(--accent-dark); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Result */
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.code { font-weight: 700; font-variant-numeric: tabular-nums; }
.versions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ver { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.ver .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.ver > strong { display: block; font-size: 1.05rem; }
@media (max-width: 640px) { .versions { grid-template-columns: 1fr; } }
.notice { background: var(--warn-bg); color: var(--warn-fg); border-radius: 6px; padding: 10px 12px; margin: 10px 0; }
.summary-text { white-space: pre-wrap; font: inherit; background: var(--accent-soft); border-radius: 6px; padding: 12px 14px; margin: 0 0 10px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 3px solid var(--border); }
.timeline > li { position: relative; margin: 0 0 14px; padding-left: 10px; }
.timeline > li::before { content: ""; position: absolute; left: -27px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--card); border: 3px solid var(--border); }
.timeline > li.changed::before { border-color: var(--accent); background: var(--accent); }
.timeline > li.endpoint::before { border-color: var(--head-edge); }
.timeline > li.outside { opacity: .65; }
.timeline .when { font-weight: 700; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; vertical-align: middle; }
.chip { font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); }
.chip.added { background: var(--ins-bg); color: var(--ins-fg); }
.chip.removed { background: var(--del-bg); color: var(--del-fg); }
.details-list { margin: 4px 0 0; padding-left: 20px; font-size: .92rem; }
.note { font-size: .92rem; color: var(--muted); margin: 4px 0 0; }

/* Text differences */
ins, del { text-decoration: none; border-radius: 2px; padding: 0 1px; }
ins { background: var(--ins-bg); color: var(--ins-fg); text-decoration: underline; text-decoration-thickness: 1px; }
del { background: var(--del-bg); color: var(--del-fg); text-decoration: line-through; }
.side { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side > div { min-width: 0; }
.side h4 { margin: 0 0 6px; font-size: .95rem; }
.crit { font-family: inherit; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 0; background: var(--card); }
@media (max-width: 760px) { .side { grid-template-columns: 1fr; } }
.legend { font-size: .85rem; color: var(--muted); }
.seg { display: inline-flex; border: 2px solid var(--accent); border-radius: 4px; overflow: hidden; }
.seg button { background: transparent; color: var(--accent); border-radius: 0; padding: 4px 12px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr.is-added td { background: var(--ins-bg); }
tr.is-removed td { background: var(--del-bg); }
.genes { font-size: .9rem; line-height: 1.7; }
.genes span { display: inline-block; margin: 0 6px 0 0; }

/* Choice list, release list */
.choice-list { list-style: none; padding: 0; margin: 0; }
.choice-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.rel-row { display: grid; grid-template-columns: 7ch 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
footer { border-top: 1px solid var(--border); padding: 16px 0 32px; font-size: .85rem; color: var(--muted); }

@media print {
  .site-head, .tabs, form, footer, .no-print, #choices { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid-page; }
  .crit { break-inside: auto; }
  details > summary { list-style: none; }
  ins { background: #dcf3e3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  del { background: #fde2e1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ---------- Round 1: form, search, start panel, short answer, changes ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-start; }
.form-row .field { flex: 1 1 200px; min-width: 0; }
.form-row .field.grow { flex: 3 1 320px; }
.form-row .field.actions { flex: 0 0 auto; align-self: flex-start; padding-top: 27px; }
.field input[type="text"], .field input[type="date"] { width: 100%; padding: 9px 10px; font: inherit; color: var(--fg); background: var(--card); border: 2px solid var(--fg); border-radius: 4px; }
#more-options { margin-top: 10px; }
#more-options summary { cursor: pointer; color: var(--accent); font-size: .92rem; }
#more-options .form-row { margin-top: 10px; }
.error { color: var(--del-fg); background: var(--del-bg); border-radius: 4px; padding: 6px 10px; margin: 10px 0 0; }
.combo { position: relative; }
#code-list { position: absolute; z-index: 10; left: 0; right: 0; top: 70px; margin: 0; padding: 4px 0; list-style: none; background: var(--card);
  border: 2px solid var(--fg); border-radius: 4px; box-shadow: 0 6px 18px rgb(0 0 0 / .18); max-height: 360px; overflow-y: auto; }
#code-list li { padding: 7px 10px; cursor: pointer; line-height: 1.35; }
#code-list li[aria-selected="true"], #code-list li:hover { background: var(--accent-soft); }
#code-list .why { display: block; font-size: .82rem; color: var(--muted); }
.start .steps { margin: 0 0 12px; padding-left: 22px; }
.start .steps li { margin-bottom: 6px; }
.examples-title { margin: 8px 0 4px; font-weight: 600; }
.examples { margin: 0; padding-left: 20px; }
.examples li { margin: 3px 0; }

.answer { border-left: 5px solid var(--accent); }
.answer h3 { font-size: 1.2rem; }
.summary-text { line-height: 1.55; }
.detail-record { margin-top: 12px; }
.detail-record summary { cursor: pointer; color: var(--accent); font-size: .92rem; margin-bottom: 8px; }

.changes { list-style: none; margin: 0; padding: 0; }
.changes > li { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; background: var(--card); }
.changes .ctx { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.changes .then, .changes .now { display: grid; grid-template-columns: 6.5em 1fr; gap: 8px; padding: 3px 0; }
.changes .txt { min-width: 0; overflow-wrap: anywhere; }
.changes .now { border-top: 1px dashed var(--border); }
.changes .gone { color: var(--muted); font-style: italic; }
.changes .tag { font-size: .8rem; font-weight: 700; color: var(--muted); padding-top: 2px; }
@media (max-width: 560px) { .changes .then, .changes .now { grid-template-columns: 1fr; gap: 0; } }
.step { margin: 8px 0 4px; }
.status { font-size: .8rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); white-space: nowrap; }
.status.added { background: var(--ins-bg); color: var(--ins-fg); }
.status.removed { background: var(--del-bg); color: var(--del-fg); }
.status.same { background: transparent; color: var(--muted); }
.panel-box { margin-bottom: 10px; }

/* tests table as cards on phones */
@media (max-width: 640px) {
  table.tests thead { display: none; }
  table.tests, table.tests tbody, table.tests tr, table.tests td { display: block; width: 100%; }
  table.tests tr { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 10px; padding: 6px 8px; }
  table.tests td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 9em 1fr; gap: 8px; }
  table.tests td::before { content: attr(data-label); font-size: .8rem; font-weight: 600; color: var(--muted); }
}
@media print { .start, #more-options { display: none !important; } .detail-record { display: none !important; } }

button.link { font: inherit; font-size: .9rem; font-weight: 600; background: none; border: 0; padding: 2px 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
button.link:hover { background: none; color: var(--accent-dark); }
.show-more { margin: 2px 0 10px; }

.timeline [data-step] { display: block; margin-top: 4px; }

@media (max-width: 640px) {
  .tabs { flex-wrap: nowrap; overflow-x: auto; gap: 0; }
  .tab { white-space: nowrap; padding: 8px 10px; font-size: .92rem; }
  .intro { font-size: .95rem; }
  .brand h1 { font-size: 1.2rem; }
  .form-row .field.actions { padding-top: 0; width: 100%; }
  .form-row .field.actions button { width: 100%; }
}

/* ---------- Round 2: answer tabs, glossary, limits ---------- */
.answer-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.answer-tabs [role=tab] { background: transparent; color: var(--accent); border: 2px solid var(--accent); padding: 6px 12px; }
.answer-tabs [role=tab][aria-selected="true"] { background: var(--accent); color: #fff; }
#out-hint { margin: -2px 0 8px; }
.term { border-bottom: 1px dotted currentColor; cursor: help; position: relative; }
.term:hover::after, .term:focus::after { content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 4px); z-index: 20; width: max-content; max-width: min(300px, 80vw);
  background: var(--fg); color: var(--bg); padding: 6px 8px; border-radius: 4px; font-size: .82rem; font-weight: 400; line-height: 1.4; white-space: normal;
  text-transform: none; letter-spacing: 0; box-shadow: 0 4px 12px rgb(0 0 0 / .2); }
.limits summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.limits ul { margin: 8px 0; padding-left: 20px; }
.limits li { margin: 4px 0; }
#start-limits { margin-top: 14px; }
@media print { .term { border-bottom: 0; } }

/* ---------- Gene changes ---------- */
fieldset.by { border: 0; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
fieldset.by legend { font-weight: 600; float: left; margin-right: 10px; padding: 0; }
fieldset.by label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
#g-list { position: absolute; z-index: 10; left: 0; right: 0; top: 70px; margin: 0; padding: 4px 0; list-style: none; background: var(--card);
  border: 2px solid var(--fg); border-radius: 4px; box-shadow: 0 6px 18px rgb(0 0 0 / .18); max-height: 360px; overflow-y: auto; }
#g-list li { padding: 7px 10px; cursor: pointer; line-height: 1.35; }
#g-list li[aria-selected="true"], #g-list li:hover { background: var(--accent-soft); }
#g-list .why { display: block; font-size: .82rem; color: var(--muted); }
dl.pair { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 6px 0 12px; }
dl.pair dt { font-weight: 600; } dl.pair dd { margin: 0; }
.rating { display: inline-block; font-size: .8rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.rating.green { background: #d6f0dd; color: #14532d; } .rating.amber { background: #fdebc8; color: #6b3d00; }
.rating.red { background: #fde2e1; color: #8a1c14; } .rating.none { background: transparent; color: var(--muted); border: 1px dashed var(--border); }
.other-ratings { margin-top: 10px; } .other-ratings summary { cursor: pointer; }
@media (max-width: 640px) {
  table.gene-table thead { display: none; }
  table.gene-table, table.gene-table tbody, table.gene-table tr, table.gene-table td { display: block; width: 100%; }
  table.gene-table tr { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; padding: 6px 8px; }
  table.gene-table td { border: 0; padding: 2px 0; display: grid; grid-template-columns: 6em 1fr; gap: 8px; }
  table.gene-table td::before { content: attr(data-label); font-size: .8rem; font-weight: 600; color: var(--muted); }
  dl.pair { grid-template-columns: 1fr; }
}
