:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #8a8984;
  --line: #e4e3df;
  --soft: #f5f5f3;
  --accent: #001e62;
  --font: Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

.site-header { border-bottom: 3px solid var(--accent); padding: 20px 0 14px; }
.site-header h1 { margin: 0; font-size: 1.6rem; font-weight: 600; color: var(--accent); }
.subtitle { margin: 4px 0 0; color: var(--ink-2); }

.filters, .controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.filters { padding-top: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.controls { margin: 16px 0 8px; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group > label, .filter-group > .label { font-size: 0.8rem; color: var(--ink-2); }
.filter-group.check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 6px; }
.filter-group.check label { font-size: 0.9rem; color: var(--ink); }

select, input[type="date"] {
  font: inherit; font-size: 0.9rem; color: var(--ink); background: #fff;
  border: 1px solid #c9c8c3; border-radius: 6px; padding: 5px 8px; min-height: 34px;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.seg { display: inline-flex; border: 1px solid #c9c8c3; border-radius: 6px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: inherit; font-size: 0.85rem; background: #fff; color: var(--ink); border: 0; border-right: 1px solid #c9c8c3; padding: 6px 10px; cursor: pointer; min-height: 34px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg button:hover:not([aria-pressed="true"]) { background: var(--soft); }

.btn { font: inherit; font-size: 0.85rem; background: #fff; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 6px 12px; cursor: pointer; min-height: 34px; }
.btn:hover:not(:disabled) { background: var(--accent); color: #fff; }
.btn:disabled { color: var(--muted); border-color: var(--line); cursor: default; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 8px; overflow-x: auto; }
.tabs button { font: inherit; font-size: 0.95rem; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.panel { padding-bottom: 24px; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 20px 0 4px; }

.chart { width: 100%; height: 360px; }
.chart-tall { height: 520px; }
.note { color: var(--ink-2); font-size: 0.9rem; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: 0.82rem; margin: 2px 0 0; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.tile .k { font-size: 0.8rem; color: var(--ink-2); }
.tile .v { font-size: 1.35rem; font-weight: 600; color: var(--ink); }
.tile .s { font-size: 0.8rem; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }

.wx-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; align-items: start; }
.stats { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 0.9rem; margin-top: 12px; }
.stats h3 { font-size: 0.85rem; margin: 0 0 6px; color: var(--ink-2); font-weight: 600; }
.stats table { border-collapse: collapse; width: 100%; }
.stats td { padding: 3px 0; }
.stats td.num { text-align: right; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.stats p { margin: 8px 0 0; color: var(--muted); font-size: 0.8rem; }

.prose { max-width: 760px; }
.prose ul { padding-left: 20px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table#data-table { border-collapse: collapse; font-size: 0.85rem; width: 100%; }
#data-table th, #data-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
#data-table th { background: var(--soft); cursor: pointer; position: sticky; top: 0; font-weight: 600; }
#data-table th:first-child, #data-table td:first-child, #data-table td.txt, #data-table th.txt { text-align: left; }
#data-table tr.suspect td { color: #b0302f; }

.footer { color: var(--muted); font-size: 0.8rem; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 12px; padding-bottom: 24px; }
.footer { text-align: center; }
/* footer credit: the name links to LinkedIn, quietly */
.footer a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.footer a:hover { color: var(--accent); border-bottom-style: solid; }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .wx-layout { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-tall { height: 420px; }
}
@media (max-width: 520px) {
  .filters .filter-group { flex: 1 1 140px; }
  .filters select, .filters input[type="date"] { width: 100%; }
  .filters .presets { flex-basis: 100%; }
  .chart { height: 320px; }
  .chart-tall { height: 380px; }
}

/* ---------- Model explorer ---------- */
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86em; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.nowrap { white-space: nowrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.linkbtn { font: inherit; font-size: 0.82rem; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

.mx-sample { margin-top: 14px; max-width: 980px; }
.mx-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 8px; }
.mx-side-panel { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; }
.mx-side-panel h2 { margin-top: 14px; font-size: 0.95rem; }
.mx-top select { width: 100%; }
.mx-group { border: 0; padding: 0; margin: 0 0 10px; }
.mx-group legend { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); padding: 0; margin-bottom: 2px; }
.mx-pred { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 2px 0; font-size: 0.88rem; }
.mx-pred label { display: block; padding-left: 22px; text-indent: -22px; cursor: pointer; }
.mx-pred input { vertical-align: -3px; margin: 0 4px 0 0; }
.mx-pred .muted { font-size: 0.8rem; }
.mx-base { font-size: 0.8rem; min-height: 26px; padding: 1px 4px; margin-left: 22px; }
.mx-inter-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mx-inter-row select { min-width: 0; flex: 1 1 90px; }
.mx-inters { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.86rem; }
.mx-inters li { padding: 2px 0; }

.mx-main { min-width: 0; }
.mx-main.dim > *:not(#mx-warn) { opacity: 0.35; pointer-events: none; }
.tiles.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.tile .s { overflow-wrap: anywhere; }
.chart-sq { height: 340px; }

.callout { border-left: 4px solid var(--accent); background: var(--soft); padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 12px 0; font-size: 0.9rem; }
.callout p { margin: 0 0 6px; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn { border-left-color: #b0302f; background: #fbf0ef; }
.callout.good { border-left-color: #1b7f4b; background: #eff7f2; }

table.coef, table.mini { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
table.coef th, table.coef td, table.mini th, table.mini td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.coef th, table.mini th { background: var(--soft); font-weight: 600; }
table.coef th:first-child, table.coef td:first-child, table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.coef tr.sig td:first-child { box-shadow: inset 4px 0 0 #1b7f4b; }
table.coef tr.nsig td:first-child { box-shadow: inset 4px 0 0 #b0302f; }
table.coef tr.sig td:nth-child(5) { color: #1b7f4b; font-weight: 600; }
table.coef tr.nsig td:nth-child(5) { color: #b0302f; }
table.vif tr.nsig td:nth-child(2) { color: #b0302f; font-weight: 600; }
table.vif td:last-child { text-align: left; color: var(--ink-2); white-space: normal; }
table.coef td.stars { text-align: left; width: 32px; }
table.mini { width: auto; margin-top: 8px; background: #fff; }
table.hist td.formula { text-align: left; white-space: normal; min-width: 260px; }
table.hist tr.current td { background: #eef1f8; }
table.hist tr.other td { color: var(--muted); }
table.hist td.best { font-weight: 700; color: var(--accent); }
table.side td.sigtxt { color: #1b7f4b; }
table.side td.nsigtxt { color: #b0302f; }
table.side .st { color: var(--muted); margin-left: 2px; display: inline-block; min-width: 1.6em; text-align: left; }
table.side tr.sum td { font-weight: 600; background: var(--soft); }
.controls.tight { margin-top: 4px; }
.controls.tight select { max-width: 100%; }
#mx-vif .table-wrap { max-height: 440px; overflow-y: auto; }
#mx-compare .filter-group { min-width: 0; flex: 1 1 200px; }
.formula-line { font-variant-numeric: tabular-nums; }

.pred-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 16px; }
.pred-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--ink-2); }
.pred-grid input { font: inherit; font-size: 0.9rem; border: 1px solid #c9c8c3; border-radius: 6px; padding: 5px 8px; min-height: 34px; }

.code-wrap { position: relative; }
.code-wrap pre { background: #f6f6f4; border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow-x: auto; font-size: 0.82rem; line-height: 1.45; margin: 6px 0 0; }
.code-wrap .copy { position: absolute; top: 8px; right: 8px; }

@media (max-width: 1000px) {
  .mx-layout { grid-template-columns: minmax(0, 1fr); }
  .mx-side-panel { position: static; max-height: none; }
  .tiles.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .tiles.five, .tiles.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Smoking and Birth Weight Lab additions ---------- */
.site-header .subtitle { max-width: 820px; }
.panel { padding-top: 4px; }
.chart-heat { height: 640px; }
.table-tall { max-height: 520px; overflow: auto; }
#data-table td.na { color: var(--muted); font-style: italic; }
table.coef tr.hl td { color: #b0302f; font-weight: 600; }
.seg-stack { display: flex; flex-direction: column; width: 100%; }
.seg-stack button { border-right: 0; border-bottom: 1px solid #c9c8c3; text-align: left; }
.seg-stack button:last-child { border-bottom: 0; }
.chart-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filter-group.inline { flex-direction: row; align-items: center; gap: 8px; margin-top: 20px; }
table.hist td.flag { color: #b0302f; font-weight: 600; }
.tag { font-size: 0.72rem; background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--ink-2); white-space: nowrap; }
table.side tr.b td { border-bottom: 0; padding-bottom: 0; }
table.side tr.se td { color: var(--muted); padding-top: 0; font-size: 0.8rem; }
#s-ttest { white-space: pre; }

/* two-sample t-test, laid out as in the Hypothesis Testing Lab */
.card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin-top: 12px; background: #fff; }
.card h3 { font-size: 0.95rem; margin: 0 0 6px; color: var(--accent); }
.tt-grid { gap: 0 16px; }
.kpi-grid.kpi-2x2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.kpi { border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; background: #fff; }
.kpi-title { font-size: 0.8rem; color: var(--ink-2); }
.kpi-value { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 0.8rem; color: var(--muted); }
.diff-working { font-size: 1.05rem; }
.diff-working > span { white-space: nowrap; }
.verdict { margin: 12px 0 6px; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 0.85rem; }
.pill-yes { background: #e6f2ea; color: #1b7a3d; }
.pill-no { background: #f1f1f1; color: var(--ink); }
.steps { overflow-x: auto; }
.steps p { margin: 10px 0; }
mjx-container { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.chart-curve { height: 300px; }
.nb-output { margin-top: 10px; }
.nb-output summary { cursor: pointer; color: var(--ink-2); font-size: 0.88rem; }
