/* ==========================================================================
   17q12 Knowledge Platform - self-contained stylesheet (no CDN)
   ========================================================================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --ink: #131a26;
  --ink-2: #46536b;
  --ink-3: #64738c;
  --line: #dfe4ee;
  --brand: #1f5f8b;
  --brand-2: #2b7fb8;
  --brand-soft: #e7f1f8;
  --accent: #b6465f;
  --ok: #1f7a5a;
  --ok-soft: #e3f3ec;
  --warn: #7a5206;
  --warn-soft: #fdf3dd;
  --bad: #a3313b;
  --bad-soft: #fbe9ea;
  --info: #4a4f9e;
  --info-soft: #ececfb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(19,26,38,.05), 0 8px 24px -12px rgba(19,26,38,.14);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15.5px; line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2);
       padding: .1em .35em; border-radius: 4px; }
pre { background: #10161f; color: #dfe6f1; padding: 14px 16px; border-radius: var(--radius-sm);
      overflow: auto; font-size: 12.5px; }
h1,h2,h3,h4 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; margin: 0 0 .4rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 .8rem; }
h3 { font-size: 1.06rem; margin: 1.4rem 0 .5rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.6rem 0; }
small, .small { font-size: .84rem; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: .85em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center;
                gap: 18px; padding: 10px 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 9px; font-weight: 700; color: var(--ink);
         font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand .dna { width: 22px; height: 22px; flex: none; }
.brand span small { display: block; font-weight: 500; font-size: .68rem; color: var(--ink-3);
                    letter-spacing: .06em; text-transform: uppercase; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { padding: 7px 11px; border-radius: 999px; color: var(--ink-2); font-size: .9rem;
         font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.lang-btn { padding: 3px 10px; font-size: .78rem; font-weight: 600; letter-spacing: .04em;
  color: var(--ink-2); text-decoration: none; line-height: 1.6; }
.lang-btn:hover { color: var(--ink); background: var(--surface-2); }
.lang-btn.active { background: var(--brand); color: #fff; }

.aud-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; background: var(--surface); }
.aud-btn { padding: 3px 9px; font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  color: var(--ink-2); text-decoration: none; line-height: 1.6; white-space: nowrap; }
.aud-btn:hover { color: var(--ink); background: var(--surface-2); }
.aud-btn.active { background: var(--brand); color: #fff; }

/* ---------- source drill-down: hover tooltip + click-through ---------- */
.src-ref { position: relative; cursor: help; }
.src-ref > a { border-bottom: 1px dotted var(--brand-2); text-decoration: none; cursor: pointer; }
.src-ref > a:hover { border-bottom-style: solid; }
.src-ref > a.src-chip { border-bottom: none; }
.src-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 2px; }
.src-chip { display: inline-flex; align-items: center; max-width: 100%; font-size: .76rem;
  line-height: 1.5; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); text-decoration: none; }
.src-chip:hover { border-color: var(--brand-2); color: var(--brand); background: var(--brand-soft); }
.src-chip .src-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.src-chip.more { border-style: dashed; }
.kb-tip { position: fixed; z-index: 90; max-width: 420px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 12px; font-size: .8rem; line-height: 1.45; color: var(--ink-2);
  opacity: 0; pointer-events: none; transition: opacity .12s ease; }
.kb-tip.show { opacity: 1; }
.kb-tip .tip-title { font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.kb-tip .tip-meta { font-size: .72rem; color: var(--ink-3); margin-bottom: 6px; }
.kb-tip .tip-snip { font-size: .76rem; color: var(--ink-2); background: var(--surface-2);
  border-left: 3px solid var(--brand-2); padding: 6px 8px; border-radius: 4px;
  max-height: 150px; overflow: hidden; }
.kb-tip .tip-hint { font-size: .7rem; color: var(--ink-3); margin-top: 6px; font-style: italic; }

/* ---------- chromosome tab ---------- */
.chrom-scroll { overflow-x: auto; }
#chromSvg { width: 100%; min-width: 860px; height: auto; display: block; }
#chromSvg .chr-label { font-size: 12px; fill: var(--ink-2); font-weight: 600; }
#chromSvg .region-label { font-size: 11px; fill: var(--brand); font-weight: 700; }
#chromSvg .tick-label { font-size: 9.5px; fill: var(--ink-3); font-family: var(--mono); }
#chromSvg .gene-label { font-size: 11px; fill: var(--ink); font-weight: 600; pointer-events: none; }
#chromSvg .gene-count { font-size: 9px; fill: var(--ink-3); font-weight: 400; }
#chromSvg .ctx-label { font-size: 10px; fill: var(--ink-3); font-weight: 400; pointer-events: none; }
#chromSvg .gene-node { cursor: pointer; scroll-margin-top: 130px; }
#chromSvg .gene-node .hit { fill: none; stroke: none; }
#chromSvg .gene-node:hover rect, #chromSvg .gene-node:focus rect {
  stroke-width: 2; filter: brightness(1.15); }
#chromSvg .gene-node:hover .gene-label, #chromSvg .gene-node:focus .gene-label { fill: var(--brand); }
#chromSvg .gene-node:focus { outline: none; }
#chromSvg .gene-node.ctx line { cursor: pointer; }
#chromSvg .gene-node.ctx:hover line, #chromSvg .gene-node.ctx:focus line { stroke: var(--brand); }
.chrom-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  margin-top: 10px; font-size: .78rem; color: var(--ink-2); }
.chrom-legend .swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px;
  background: var(--brand); opacity: .35; margin-right: 5px; vertical-align: baseline; }
.chrom-legend .swatch.hot { opacity: 1; }
.chrom-legend .swatch.ctx { background: var(--ink-3); opacity: .6; }
.gene-panel { margin-top: 16px; border-left: 4px solid var(--brand); }
.gene-panel-body h3 { margin: 14px 0 6px; font-size: .95rem; }
#geneTable tr.gene-node { cursor: pointer; }
#geneTable tr.gene-node:hover td { background: var(--brand-soft); }

main { max-width: 1280px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head { display: flex; gap: 18px; align-items: flex-end; justify-content: space-between;
             flex-wrap: wrap; margin-bottom: 18px; }
.page-head p.lede { margin: .35rem 0 0; color: var(--ink-2); max-width: 70ch; }

footer.site { border-top: 1px solid var(--line); background: var(--surface); margin-top: 40px; }
footer.site .inner { max-width: 1280px; margin: 0 auto; padding: 22px 20px 34px;
                     color: var(--ink-3); font-size: .84rem; }
.disclaimer { background: var(--warn-soft); border: 1px solid #f0dcae; color: #6b4a05;
              border-radius: var(--radius); padding: 12px 15px; font-size: .86rem; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
              margin-bottom: 12px; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
/* grid items must not be forced wider than the viewport by wide tables/charts */
.grid > * { min-width: 0; }
svg.chart, .table-wrap, table, img { max-width: 100%; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.wide-left { grid-template-columns: minmax(0,2.1fr) minmax(0,1fr); }
.grid.wide-right { grid-template-columns: minmax(0,1fr) minmax(0,2.1fr); }
@media (max-width: 1000px) {
  .grid.cols-3, .grid.cols-4, .grid.wide-left, .grid.wide-right { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.wide-left, .grid.wide-right { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  main { padding: 18px 14px 44px; }
  .card { padding: 15px 15px; }
}

/* ---------- stats ---------- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { color: var(--ink-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.stat .s { color: var(--ink-2); font-size: .8rem; margin-top: 3px; }
.stat.accent .n { color: var(--brand); }
.stat.good .n { color: var(--ok); }
.stat.warn .n { color: var(--warn); }

/* ---------- badges & chips ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem;
         font-weight: 600; letter-spacing: .02em; background: var(--surface-2); color: var(--ink-2);
         border: 1px solid var(--line); white-space: nowrap; }
.badge.brand { background: var(--brand-soft); color: #14496b; border-color: #c9e0f0; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #c6e6d9; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f0dcae; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #f2ccd0; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: #d6d6f5; }
.badge.new { background: #1f5f8b; color: #fff; border-color: #1f5f8b; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
        background: var(--surface); border: 1px solid var(--line); font-size: .82rem; color: var(--ink-2); }
.chip:hover { border-color: var(--brand-2); color: var(--brand); text-decoration: none; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .count { color: var(--ink-3); font-size: .74rem; }
.chip.active .count { color: #d6e9f6; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm);
       border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .87rem;
       font-weight: 600; cursor: pointer; font-family: inherit; }
.btn:hover { border-color: var(--brand-2); color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.sm { padding: 5px 10px; font-size: .8rem; }
form.inline { display: inline; }
.search { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=search], select {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font: inherit; font-size: .9rem; color: var(--ink); min-width: 0; }
input[type=text]:focus, input[type=search]:focus, select:focus { outline: 2px solid #bcd9ec; border-color: var(--brand-2); }
input[type=search] { flex: 1 1 240px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3);
     font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
table.compact th, table.compact td { padding: 5px 8px; font-size: .83rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- insight cards ---------- */
.insight { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
           padding: 14px 16px; display: flex; flex-direction: column; gap: 7px; }
.insight + .insight { margin-top: 12px; }
.insight:hover { border-color: #c8d6e6; }
.insight .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.insight h3 { margin: 0; font-size: 1rem; }
.insight h3 a { color: var(--ink); }
.insight p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.insight .meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--ink-3); font-size: .78rem; }
.confbar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.confbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--ok)); }

blockquote { margin: .5rem 0; padding: .5rem .9rem; border-left: 3px solid var(--brand-2);
             background: var(--brand-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
             color: #1c3d55; font-size: .9rem; }
.evidence { border-left: 3px solid var(--line); padding-left: 14px; margin: 10px 0; }
.evidence .src { font-size: .8rem; color: var(--ink-3); }

/* ---------- markdown content ---------- */
.prose { max-width: 78ch; }
.prose h2 { margin-top: 1.8rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
.prose h3 { color: var(--brand); }
.prose p { margin: .7rem 0; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .28rem 0; }
.prose table { font-size: .85rem; margin: 1rem 0; }
.prose blockquote { font-size: .92rem; }
.layman { background: var(--brand-soft); border: 1px solid #cfe3f1; border-radius: var(--radius);
          padding: 4px 20px 14px; margin-bottom: 22px; }
.layman::before { content: "In plain language"; display: inline-block; margin-top: 12px;
                  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
                  color: #14496b; }
html[lang="nl"] .layman::before { content: "In gewone taal"; }
.auto-note { font-size: .8rem; color: var(--ink-3); font-style: italic; }

/* ---------- charts (inline svg) ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; opacity: .8; }
.chart .bar { fill: var(--brand-2); }
.chart .bar:hover { fill: var(--brand); }
.chart .bar-alt { fill: #6aa9d0; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.2; }
.chart .area { fill: rgba(43,127,184,.14); }
.chart .dot { fill: var(--brand); }
.chart text { font-size: 10px; fill: var(--ink-3); font-family: var(--sans); }
.chart text.value { fill: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .8rem; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; }
.axis-labels { display: flex; justify-content: space-between; font-size: .76rem; color: var(--ink-3);
               margin-top: 2px; }
.rank-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px;
            align-items: center; padding: 4px 0; font-size: .86rem; }
.rank-row .bar-track { background: var(--surface-2); border-radius: 4px; height: 12px; overflow: hidden; }
.rank-row .bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.rank-row .v { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .8rem; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .87rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.timeline-day { margin-bottom: 22px; }
.timeline-day h3 { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.tl-item { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 6px 0;
           border-bottom: 1px dashed var(--line); font-size: .87rem; }
.tl-item .kind { color: var(--ink-3); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 620px) { .tl-item { grid-template-columns: 1fr; } }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.diff-add { background: #e6f6ec; border-left: 3px solid var(--ok); padding: 6px 10px; margin: 4px 0;
            font-size: .85rem; border-radius: 0 6px 6px 0; }
.diff-del { background: #fbeaec; border-left: 3px solid var(--bad); padding: 6px 10px; margin: 4px 0;
            font-size: .85rem; border-radius: 0 6px 6px 0; color: #6b2b32; text-decoration: line-through; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 13px; font-size: .88rem; color: var(--ink-2); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--surface-2); border-radius: 6px 6px 0 0; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 20px;
         font-size: .86rem; color: var(--ink-2); }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--ink); color: #fff;
         padding: 11px 15px; border-radius: var(--radius-sm); font-size: .86rem; box-shadow: var(--shadow);
         opacity: 0; transform: translateY(8px); transition: .25s; pointer-events: none; z-index: 90; }
.toast.show { opacity: 1; transform: none; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot-live.busy { background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); }
.empty h3 { color: var(--ink-2); }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { padding: 7px 0; border-bottom: 1px dashed var(--line); min-height: 24px; }
.recent-list li:last-child { border-bottom: 0; }
.recent-list .meta-line { display: block; color: var(--ink-3); font-size: .8rem; margin-top: 2px; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 10px; top: 10px; background: #fff; padding: 8px; z-index: 100; }

/* ---------- disclaimer ---------- */
.disclaimer-banner { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline;
  justify-content: center; text-align: center;
  background: var(--brand-soft); border-bottom: 1px solid var(--line);
  padding: 7px 18px; font-size: .8rem; color: var(--ink-2); line-height: 1.45; }
.disclaimer-banner a { color: var(--brand); font-weight: 600; white-space: nowrap; }
.disclaimer-page section.card { margin-bottom: 14px; }
.disclaimer-page h2 { font-size: 1.15rem; margin-bottom: 8px; }
.disclaimer-page p { margin: 0 0 10px; }
.disclaimer-page p:last-child { margin-bottom: 0; }

/* Kids reading level: bigger, rounder, friendlier. Same content, softer read. */
html.aud-kid body { font-size: 1.06rem; line-height: 1.75; }
html.aud-kid h1 { font-size: 2rem; }
html.aud-kid h2 { font-size: 1.45rem; }
html.aud-kid .card { border-radius: 18px; box-shadow: 0 2px 10px rgba(31, 95, 139, .08); }
html.aud-kid .layman { background: #fff7e6; border-color: #f0d9a8; border-radius: 16px;
  font-size: 1.08rem; }
html.aud-kid .layman::before { content: "In simple words"; background: #e8a33d; color: #fff; }
html.aud-kid[lang="nl"] .layman::before { content: "In eenvoudige woorden"; }
html.aud-kid .badge, html.aud-kid .chip { font-size: .82rem; }
html.aud-kid .nav a { font-size: .95rem; }
