/* whatyouinherit — a public-facing tool page, in SeqBench's visual language.
 *
 * What is borrowed from seqbench.com: a slate neutral scale on #f8fafc, one
 * emerald accent, flat cards drawn with a 1px border and a tinted fill rather
 * than a shadow, restrained radii (6px controls, 12px cards), outline buttons,
 * and small uppercase labels over each block.
 *
 * What is ours: everything the reader has to understand. The page talks about
 * families, not pedigrees; percentages come with a picture; and the parts that
 * belong to a clinic are folded away rather than laid out.
 */

:root {
  --page: #ffffff;          /* the page and its content are one surface */
  --bg: #f8fafc;            /* slate-50, for tints inside the sheet */
  --panel: #ffffff;
  --tint: #f8fafcb3;        /* slate-50/70, the "worked example" card fill */
  --ink: #0f172a;           /* slate-900 */
  --ink-2: #334155;         /* slate-700 */
  --muted: #64748b;         /* slate-500 */
  --faint: #94a3b8;         /* slate-400 */
  --line: #e2e8f0;          /* slate-200 */
  --line-strong: #cbd5e1;   /* slate-300 */

  --accent: #059669;        /* emerald-600 */
  --accent-ink: #047857;    /* emerald-700 */
  --accent-line: #6ee7b7;   /* emerald-300 */
  --accent-soft: #ecfdf5;   /* emerald-50  */

  --info: #0369a1;          /* sky-700 */
  --info-soft: #f0f9ff;     /* sky-50  */
  --flag: #d97706;          /* amber-600 — someone who has the condition */
  --flag-soft: #fffbeb;     /* amber-50 */
  --danger: #be123c;        /* rose-700 */
  --danger-soft: #fff1f2;   /* rose-50 */

  --radius: 7px;
  --radius-sm: 3px;

  /* A neutral grotesque rather than the rounded humanist the OS hands out by
   * default: this page reports numbers, and the type should say so. */
  --sans: "Helvetica Neue", Helvetica, "Segoe UI", Roboto, "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #111a2e; --bg: #0b1120; --panel: #111a2e; --tint: #0f1830b3;
    --ink: #e2e8f0; --ink-2: #cbd5e1; --muted: #94a3b8; --faint: #64748b;
    --line: #1e293b; --line-strong: #334155;
    --accent: #34d399; --accent-ink: #6ee7b7; --accent-line: #047857;
    --accent-soft: #052e21;
    --info: #7dd3fc; --info-soft: #0c2437;
    --flag: #fbbf24; --flag-soft: #2b1f08;
    --danger: #fb7185; --danger-soft: #2d1117;
  }
}

* { box-sizing: border-box; }

/* One ring, one accent, one easing — the things that make a page feel of a
 * piece rather than assembled. */
:root {
  --ease: cubic-bezier(.32, .72, 0, 1);
  --ring: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
input, select, textarea, [type="checkbox"] { accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
b, strong { font-weight: 600; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* A small uppercase label over a block, the way SeqBench labels INPUT/RESULT. */
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint);
}

/* ------------------------------------------------------------- top bar */

/* One measure for the whole site — bar, content and footer alike — so a wide
 * window gives the page margins to sit in rather than more room to fill.
 * What is inside the measure is a sheet: white, edge to edge, no cards. */
:root {
  --measure: 1140px;        /* the bar, the footer, the two-column workbench */
  --column: 872px;          /* the article, when the page is only reading */
  --gutter: max(20px, calc((100% - var(--measure)) / 2));
}

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px var(--gutter); background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  font-size: 17px; width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--accent-soft); display: grid; place-items: center;
  border: 1px solid var(--accent-line);
}
.brand h1 { font-size: 18px; font-weight: 600; }
.brand p { margin: 0; font-size: 13px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

button {
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--panel); padding: 6px 12px; cursor: pointer; color: var(--ink-2);
  transition: border-color .14s var(--ease), color .14s var(--ease), background .14s var(--ease);
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; padding: 7px 18px;
  box-shadow: 0 1px 2px rgba(5, 150, 105, .22);
}
button.primary:active:not(:disabled) { transform: translateY(.5px); }
button.primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover:not(:disabled) { border-color: var(--line-strong); }
.danger-text { color: var(--danger); }
.danger-text:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }

button.lang { font-size: 13px; padding: 5px 10px; min-width: 48px; }
#btn-more { font-size: 16px; line-height: 1.2; padding: 5px 12px; }

.menu { position: relative; }
.menu-list {
  display: none; position: absolute; right: 0; top: 40px; z-index: 40;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); min-width: 240px; padding: 6px;
  box-shadow: 0 10px 24px rgba(15,23,42,.10);
}
.menu-list.open { display: block; }
.menu-list button {
  display: block; width: 100%; text-align: left; border: 1px solid transparent;
  background: none; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px;
}
.menu-list button:hover { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.menu-title {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); padding: 6px 10px 2px;
}
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* -------------------------------------------------------------- banner */

.banner { padding: 8px var(--gutter); font-size: 13px; display: none; border-bottom: 1px solid var(--line); }
.banner.show { display: block; }
.banner.loading { background: var(--info-soft); color: var(--info); }
.banner.error { background: var(--danger-soft); color: var(--danger); }

/* -------------------------------------------------------------- layout */

/* The conversation is the page. It sits alone in a readable column until
 * someone asks for the diagram, and only then does the layout split in two. */
main {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 760px); justify-content: center;
  gap: 16px; padding: 28px max(20px, calc((100% - var(--column)) / 2)) 34px;
}
/* With the diagram open the page is one surface, not three cards on a tray:
 * no gutters, no card edges, a single hairline between the halves.
 *
 * The conversation is what this page is for; the drawing is how somebody
 * checks it. So the conversation takes the room and the first position, and
 * the drawing sits beside it as a reference column. */
body.with-panel main {
  grid-template-columns: minmax(0, 1fr) minmax(430px, 560px);
  grid-template-rows: minmax(0, 1fr);
  justify-content: stretch;
  gap: 0; padding: 0 var(--gutter);
}
body.with-panel .panel { border: 0; border-radius: 0; }
/* Both halves are placed, or auto-placement drops the second one onto a
 * row of its own and leaves the first column empty above it. One rule
 * between them is all the structure the two halves need. */
body.with-panel .chat-panel { grid-area: 1 / 1; }
body.with-panel .view-panel { grid-area: 1 / 2; border-left: 1px solid var(--line); }
/* Reading mode: the front page explains itself and scrolls like a document.
 * Opening the diagram turns the same markup back into a fixed workbench. */
body:not(.with-panel) { height: auto; min-height: 100vh; overflow: auto; }
body:not(.with-panel) .chat-panel {
  height: min(460px, 58vh); border-radius: 0;
  border-left: 0; border-right: 0; border-bottom: 0;
}
body.with-panel .intro, body.with-panel .about { display: none; }

.intro { padding-top: 6px; }
.intro h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.intro .lede { font-size: 16px; color: var(--ink-2); margin: 10px 0 0; }
.intro .privacy {
  display: inline-block; margin: 14px 0 0; padding: 5px 11px; border-radius: var(--radius-sm);
  background: var(--info-soft); color: var(--info); font-size: 12.5px; line-height: 1.6;
}
.intro .privacy b { color: inherit; font-weight: 600; }
.intro .intro-body { font-size: 14.5px; color: var(--muted); margin: 14px 0 0; }

.about { padding: 8px 0 12px; }
/* Section headings here carry real sentences in two writing systems; the tiny
 * uppercase eyebrow that suits "INPUT" is unreadable at that job in Chinese. */
.about h3 {
  display: block; margin: 24px 0 10px; font-size: 15px; font-weight: 600;
  color: var(--ink); letter-spacing: 0; text-transform: none;
}
.about h3:first-child { margin-top: 6px; }
.steps { margin: 0; padding-left: 20px; font-size: 14.5px; color: var(--ink-2); }
.steps li { margin-bottom: 8px; }
.steps li::marker { color: var(--accent); font-weight: 600; }
.method { font-size: 14px; color: var(--muted); }
.method p { margin: 0 0 10px; }
.method b { color: var(--ink-2); font-weight: 600; }

.formula {
  font-family: var(--mono); font-size: 13px; color: var(--ink-2);
  background: var(--tint); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 0 0 12px; overflow-x: auto; white-space: pre;
}
.terms { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.terms dt { font-family: var(--mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.terms dd { margin: 0; color: var(--muted); }

table.sources { width: 100%; border-collapse: collapse; font-size: 13px; }
table.sources td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
table.sources td:first-child { color: var(--ink-2); white-space: nowrap; }
table.sources td.num { font-family: var(--mono); font-size: 12px; text-align: right; padding-right: 0; white-space: nowrap; }
.about > .muted { margin: 8px 0 0; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.scroll { overflow: auto; flex: 1; min-height: 0; }

/* ------------------------------------------------------------ pedigree */

.view-panel { position: relative; }

.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line);
}

/* A segmented control: three views of one thing, and it shows which. */
.seg-tabs {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--bg); border-radius: 7px;
}
.seg-tabs button {
  border: 0; background: none; border-radius: 5px;
  padding: 5px 14px; font-size: 13px; color: var(--muted);
  transition: background .14s, color .14s, box-shadow .14s;
}
.seg-tabs button:hover:not(.on) { color: var(--ink-2); }
.seg-tabs button.on {
  background: var(--panel); color: var(--ink); font-weight: 500;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .10), 0 0 0 1px rgba(15, 23, 42, .04);
}

.icon-btn {
  margin-left: auto; border: 0; background: none; color: var(--faint);
  font-size: 18px; line-height: 1; padding: 3px 7px; border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--bg); color: var(--ink-2); border: 0; }

/* The family's own line, under the switcher and above the drawing. */
.sub-head {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--tint);
}
.sub-head .head-right {
  margin-left: auto; display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.sub-head select {
  padding: 4px 9px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); font-size: 13px; max-width: 170px;
}

.canvas-wrap { flex: 1; min-height: 260px; position: relative; overflow: auto; background: var(--bg); }
#pedigree { width: 100%; height: 100%; display: block; cursor: grab; }
#pedigree.dragging { cursor: grabbing; }
.canvas-tip {
  position: absolute; left: 14px; top: 12px; font-size: 12px; color: var(--info);
  pointer-events: none; background: var(--info-soft); border: 1px solid transparent;
  padding: 3px 9px; border-radius: var(--radius-sm); transition: opacity .15s;
}
/* It has been taken up on; it can stop asking, and stop sitting on a name. */
.sheet-open .canvas-tip { opacity: 0; }

/* One shape for everyone: colour reinforces the words underneath, it does
 * not stand in for them. */
.node .shape {
  fill: var(--panel); stroke: var(--line-strong); stroke-width: 1.25;
  transition: fill .12s, stroke .12s;
}
.node.affected .shape { fill: var(--flag-soft); stroke: var(--flag); }
.node.unknown .shape { stroke-dasharray: 3 3; }
.node.selected .shape { stroke: var(--accent); stroke-width: 2; stroke-dasharray: none; }
.node:hover .shape { stroke: var(--accent); }
.node .name { font-size: 12.5px; fill: var(--ink); text-anchor: middle; font-weight: 500; }
.node .sub  { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.node .status { font-size: 11px; fill: var(--muted); }
.node.affected .status { fill: var(--flag); font-weight: 500; }
.node .onset { font-size: 10.5px; fill: var(--flag); }
.node .dx    { font-size: 10.5px; fill: var(--flag); font-weight: 500; }
.node .tag, .node .gt { font-size: 10.5px; fill: var(--faint); }
.node { cursor: pointer; }
.link { stroke: var(--line-strong); stroke-width: 1; fill: none; shape-rendering: crispEdges; }
.me-tag { font-size: 10.5px; fill: var(--accent-ink); text-anchor: middle; font-weight: 600; }
.me-tag-bg { fill: var(--accent-soft); stroke: var(--accent-line); stroke-width: .75; }
.risk-track { fill: var(--line); }
.risk-fill { fill: var(--accent); }
.risk-text { font-size: 10px; fill: var(--accent-ink); text-anchor: middle; font-family: var(--mono); }

/* ------------------------------------------------- one relative's detail */

/* A narrow column beside the drawing rather than a lid over it: opening it
 * squeezes the paper, so the person being edited stays where they were. */
.canvas-area { flex: 1; min-height: 0; display: flex; overflow: hidden; position: relative; }
.canvas-area .canvas-wrap { flex: 1; min-width: 0; }

.person-sheet {
  position: absolute; inset: 0; z-index: 12; overflow: auto;
  background: var(--panel);
  transform: translateX(100%); transition: transform .18s ease;
}
.person-sheet.open { transform: none; }

/* This column is too narrow for a label and its control side by side. */
.person-sheet .card-head { flex-wrap: wrap; }
.person-sheet .name-input { flex: 1 0 100%; }
.person-sheet .card-grid { grid-template-columns: 1fr; gap: 4px; }
.person-sheet .card-grid > label { margin-top: 10px; }
.person-sheet .seg { width: 100%; }
.person-sheet .seg button { flex: 1; padding: 7px 4px; }
.person-sheet .age-row input { flex: 1; width: auto; min-width: 64px; }
.sheet-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 12px 18px 0;
}
.sheet-head .who {
  font-size: 13px; color: var(--ink-2); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}


.toolbar {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 12px 18px 16px; border-top: 1px solid var(--line); background: var(--tint);
}
.toolbar-label { font-size: 13px; color: var(--muted); margin-right: 2px; }
.toolbar button { padding: 5px 12px; font-size: 13.5px; }

.member-card { padding: 10px 18px 16px; }
.card-head { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.name-input {
  flex: 1; min-width: 0; padding: 7px 11px; font-size: 15px; font-weight: 600;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel);
}
.name-input:focus, .age-row input:focus, .search-wrap input:focus, .chat-form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.panel-head select:focus, .sub-head select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.pill { padding: 6px 12px; font-size: 13.5px; white-space: nowrap; }
.pill.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); font-weight: 600; }

.card-grid { display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: center; }
.card-grid > * { min-width: 0; }
.card-grid > label { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.age-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.age-row input {
  width: 82px; padding: 6px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--panel);
}

/* A segmented control, drawn as one bordered strip like SeqBench's toggles. */
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; width: fit-content; }
.seg button { border: 0; border-radius: 0; padding: 6px 16px; font-size: 13.5px; background: var(--panel); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.checkline { display: flex; align-items: center; gap: 9px; margin: 14px 0 0; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.checkline input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); }

.sym-block { margin-top: 18px; }
.sym-block > label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 7px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-ink); font-size: 13.5px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; border: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 3px; background: var(--accent-soft);
  color: var(--accent-ink); border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm); padding: 2px 6px 2px 10px; font-size: 13px;
}
.chip button { border: 0; background: none; padding: 0 3px; font-size: 15px; line-height: 1; color: inherit; opacity: .6; }
.chip button:hover { opacity: 1; color: var(--danger); border: 0; }

.search-wrap { position: relative; margin-top: 7px; }
.search-wrap input {
  width: 100%; padding: 7px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--panel);
}
.search-results {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; max-height: 240px;
  overflow: auto; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: 0 10px 24px rgba(15,23,42,.10);
  display: none; margin-top: 4px; padding: 5px;
}
.search-results.open { display: block; }
.search-results div { padding: 7px 10px; cursor: pointer; font-size: 14px; border-radius: var(--radius-sm); }
.search-results div:hover, .search-results div.active { background: var(--accent-soft); }
.search-results .code, .code { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-left: 7px; }

details.more { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
details.more > summary, details.soft > summary {
  cursor: pointer; font-size: 13.5px; color: var(--muted); list-style: none; padding: 5px 0;
}
details.more > summary:hover, details.soft > summary:hover { color: var(--accent-ink); }
details.more > summary::before, details.soft > summary::before { content: '▸ '; }
details.more[open] > summary::before, details.soft[open] > summary::before { content: '▾ '; }
details.more > label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); margin: 14px 0 6px;
}
.mini-row { display: flex; gap: 7px; align-items: center; margin-bottom: 6px; font-size: 14px; }
.mini-row > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row select {
  padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); font-size: 13.5px; max-width: 150px;
}
.mini-row .x { border: 0; background: none; color: var(--faint); padding: 0 5px; font-size: 16px; }
.mini-row .x:hover { color: var(--danger); border: 0; }


/* ----------------------------------------------------------- side panel */

.tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-body:not(.hidden) { animation: view-in .18s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(3px); } }

.chat-log {
  flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 840px; margin: 0 auto;
}
.msg { max-width: min(88%, 620px); padding: 11px 15px; border-radius: var(--radius); font-size: 14.5px; line-height: 1.62; }
.msg.bot { background: var(--tint); border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.me { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--ink); border-bottom-right-radius: 4px; align-self: flex-end; }
.msg.note { background: var(--flag-soft); border: 1px solid transparent; color: var(--flag); font-size: 13px; align-self: stretch; max-width: 100%; }
.msg.thinking { color: var(--muted); font-style: italic; }
.msg i { color: var(--muted); }

/* Full width so the rule above it spans the half, but the field itself keeps
 * to the same measure as the conversation over it. */
.chat-form {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 14px max(18px, calc((100% - 840px) / 2)) 16px;
  border-top: 1px solid var(--line);
}
.chat-form textarea {
  flex: 1; resize: none; padding: 10px 13px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: var(--panel); max-height: 130px; font-size: 14.5px;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}

/* --------------------------------------------- the family, as a worksheet */

#people { padding: 16px 0 20px; display: flex; flex-direction: column; min-height: 0; }
.table-note, .table-foot { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; padding: 0 16px; }
.table-foot { margin: 12px 0 0; color: var(--faint); line-height: 1.6; }

.sheet-scroll { overflow: auto; min-height: 0; flex: 1; padding: 0 16px; }

table.sheet { border-collapse: separate; border-spacing: 0; font-size: 13.5px; }

/* Column heads: who. Row heads: what. Both stay put while the other scrolls. */
table.sheet th, table.sheet td {
  border-bottom: 1px solid var(--line); padding: 0; vertical-align: middle;
}
table.sheet thead th {
  position: sticky; top: 0; z-index: 3; background: var(--panel);
  padding: 2px 4px 7px; text-align: left; font-weight: 500;
  border-bottom: 1px solid var(--line-strong); min-width: 92px;
}
table.sheet thead th.rowhead { z-index: 4; }
table.sheet th.rowhead {
  position: sticky; left: 0; z-index: 2; background: var(--panel);
  width: 124px; min-width: 124px; padding: 7px 12px 7px 0;
  font-size: 12.5px; font-weight: 400; color: var(--muted);
  text-align: left; white-space: nowrap;
}
table.sheet tbody td { padding: 1px 3px; }
table.sheet thead th.on, table.sheet tbody td.on { background: var(--accent-soft); }
table.sheet tbody tr:hover > td { background: var(--tint); }
table.sheet tbody tr:hover > th.rowhead { color: var(--ink-2); }

table.sheet thead th .name { font-weight: 600; font-size: 13.5px; }
table.sheet tr.tick td { text-align: center; }
table.sheet tr.tick input { width: 15px; height: 15px; accent-color: var(--accent); margin: 4px 0; }
table.sheet tr.ro-row td { padding: 6px 7px; }
table.sheet tr.dx-row th.rowhead { color: var(--flag); }
table.sheet tr.dx-row td { border-top: 1px solid var(--line); }
.ro { font-size: 12.5px; color: var(--muted); display: block;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.ro.none { color: var(--faint); }
.ro.dx { color: var(--flag); font-weight: 500; }

/* A control that reads as text until it is pointed at: a check turns into a
 * correction without a mode, and without looking like a form. */
.flat {
  width: 100%; min-width: 0; padding: 5px 7px; font: inherit; color: inherit;
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.flat:hover { border-color: var(--line-strong); }
.flat:focus, .flat:focus-visible {
  outline: none; border-color: var(--accent); background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.flat.num { font-family: var(--mono); font-size: 12.5px; }
.flat::placeholder { color: var(--faint); }
/* No spinner: two digits and a placeholder dash need every pixel of the cell. */
.flat.num::-webkit-outer-spin-button, .flat.num::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.flat.num { -moz-appearance: textfield; }
/* The native arrow stays: it is the only thing telling somebody the value can
 * be changed without their having to hover over it to find out. */
select.flat { cursor: pointer; padding-left: 4px; }
select.flat:hover { background: var(--panel); }

.star {
  display: block; margin: 2px 0 0 7px; border: 0; background: none; padding: 0;
  font-size: 10.5px; color: var(--faint); letter-spacing: .04em;
  opacity: 0; transition: opacity .12s, color .12s;
}
.star:hover { color: var(--accent-ink); border: 0; background: none; }
.star.on, table.sheet thead th:hover .star, .star:focus-visible { opacity: 1; }
/* A finger cannot hover, so nothing may hide behind one. */
@media (hover: none) { .star { opacity: 1; } }
.star.on { color: var(--accent-ink); font-weight: 600; }

.cell-btn {
  font-size: 12px; padding: 3px 10px; color: var(--muted);
  border-color: var(--line); background: var(--panel);
}
.cell-btn:hover { border-color: var(--accent); color: var(--accent-ink); }

/* -------------------------------------------------------------- results *//* -------------------------------------------------------------- results */

#results { padding: 18px; width: 100%; max-width: 760px; margin: 0 auto; }
.empty { color: var(--muted); text-align: center; padding: 56px 24px; }
.empty p { margin: 7px 0; font-size: 14.5px; }

.stale {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--flag-soft); color: var(--flag);
  border-radius: var(--radius); padding: 9px 13px; font-size: 13px; margin-bottom: 14px;
}
.stale button { padding: 4px 12px; font-size: 13px; background: var(--panel); }

.person-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.person-tabs button { padding: 4px 11px; font-size: 12.5px; }
.person-tabs button.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); font-weight: 600; }

/* The headline result, built like SeqBench's worked-example card: a bordered
 * panel on a slate tint, each number under its own small uppercase label. */
.headline {
  background: var(--tint); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.big-label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint);
}
.big-number { font-family: var(--mono); 
  font-size: 44px; font-weight: 600; line-height: 1.05; color: var(--accent-ink);
  margin: 4px 0 12px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.plain-line { font-size: 14px; color: var(--ink-2); margin: 0 0 4px; }

/* What the engine actually did, said in one line above the fold. */
.run-line {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  margin: 0 0 14px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--tint); line-height: 1.5;
}
.plain-line b { color: var(--accent-ink); font-weight: 600; }

.dots { display: grid; grid-template-columns: repeat(20, 1fr); gap: 4px; max-width: 280px; margin: 0 0 12px; }
.dots span { aspect-ratio: 1; border-radius: 1px; background: var(--line); }
.dots span.on { background: var(--accent); }

.bar { height: 8px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.big { height: 10px; }
.bar.thin { height: 4px; margin: 5px 0; }
.headline .second {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); margin: 16px 0 6px; padding-top: 14px; border-top: 1px solid var(--line);
}
.headline .second b {
  font-size: 20px; color: var(--accent-ink); letter-spacing: 0; font-family: var(--mono);
  font-variant-numeric: tabular-nums; text-transform: none;
}

button.explain {
  width: 100%; margin: 0 0 20px; padding: 10px; border-radius: var(--radius-sm);
  background: var(--panel); border-color: var(--accent-line); color: var(--accent-ink);
  font-weight: 600; font-size: 14.5px;
}
button.explain:hover { background: var(--accent-soft); border-color: var(--accent); }

.risk-row { margin-bottom: 10px; }
.risk-row .label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.risk-row .label b { font-variant-numeric: tabular-nums; }

.result-block { margin-bottom: 22px; }
.result-block > h3 { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.result-block > .h-note { font-size: 13px; color: var(--muted); margin: 0 0 11px; }

.disease {
  display: grid; grid-template-columns: 54px 1fr; gap: 12px;
  padding: 12px; margin-bottom: 8px; align-items: start;
  background: var(--tint); border: 1px solid var(--line); border-radius: var(--radius);
}
.disease .pct { font-family: var(--mono); font-weight: 600; text-align: right; font-size: 16px; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.disease .name { font-weight: 600; font-size: 14.5px; }
.disease .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.disease.null { background: var(--flag-soft); border-color: transparent; }
.disease.null .pct, .disease.null .name { color: var(--flag); }
.badge {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-ink); margin-right: 6px; font-weight: 600;
}
.badge.mol { background: var(--flag-soft); color: var(--flag); }

.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 0; font-size: 14px; border-bottom: 1px solid var(--line);
}
.feature-list li:last-child { border-bottom: 0; }
.feature-list li b { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

details.soft { margin-bottom: 16px; }

table.evidence { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.evidence td { padding: 6px 0; border-bottom: 1px solid var(--line); }
table.evidence tr:last-child td { border-bottom: 0; }
table.evidence td.lr { text-align: right; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
table.evidence td.lr.pos { color: var(--accent-ink); }
table.evidence td.lr.neg { color: var(--danger); }

.notes { background: var(--flag-soft); color: var(--flag); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }
.notes ul { margin: 0; padding-left: 17px; }

footer {
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 9px var(--gutter); font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
footer b { color: var(--ink-2); font-weight: 600; }

/* ------------------------------------------------- narrow: one column */

@media (max-width: 1040px) {
  body { height: auto; overflow: auto; }
  main { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 18px; }
  body.with-panel main { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
  /* Stacked, first position is the top of the page: the conversation. */
  body.with-panel main { grid-template-rows: auto auto; padding: 0; }
  body.with-panel .chat-panel { grid-area: 1 / 1; border-left: 0; }
  body.with-panel .view-panel {
    grid-area: 2 / 1; border-left: 0; border-right: 0;
    border-top: 1px solid var(--line);
  }
  .chat-panel, body:not(.with-panel) .chat-panel { height: auto; min-height: 520px; }
  /* No room to float anything over a phone-sized drawing: the sheet takes its
   * turn underneath instead, and the panel grows to hold it. */
  .canvas-area { display: block; overflow: visible; }
  .person-sheet {
    display: none; position: static; transform: none;
    border-top: 1px solid var(--line);
  }
  .person-sheet.open { display: block; }
  .canvas-wrap { min-height: 300px; }
}

/* ----------------------------------------------------------------- phone */

/* On a narrow screen the bar cannot hold the name and the actions on one
 * line, and something has to give — never the button that runs the thing. */
@media (max-width: 640px) {
  :root { --gutter: 14px; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; }
  .brand p { display: none; }
  .canvas-tip { font-size: 11.5px; left: 10px; top: 10px; }
  .card-grid { grid-template-columns: 1fr; gap: 4px; }
  .card-grid > label { margin-top: 10px; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 8px 4px; }
  .age-row input { flex: 1; width: auto; min-width: 70px; }
  .intro h2 { font-size: 22px; }
  .dots { max-width: 100%; }
  .disease { grid-template-columns: 48px 1fr; gap: 10px; }
  .table-note, .table-foot { padding: 0 14px; }
  .sheet-scroll { padding: 0 14px; }
  .sub-head { flex-wrap: wrap; }
  .sub-head .head-right { margin-left: 0; width: 100%; }
  .seg-tabs button { padding: 5px 11px; }
  .terms { grid-template-columns: 1fr; gap: 2px; }
  .terms dd { margin-bottom: 8px; }
  table.sources td { display: block; padding: 2px 0; border: 0; }
  table.sources tr { display: block; padding: 7px 0; border-bottom: 1px solid var(--line); }
  table.sources td.num { text-align: left; }
}
