/* Lab sheet: a left-aligned reading column with a margin rail for notes; figures break out to the
   full sheet width. Events are drawn as cells, in the colours of the chart of nuclides
   (yellow alpha, blue beta-minus, red beta-plus, black stable). */
:root {
  --paper: #ffffff;
  --ink: #15181d;
  --ink-2: #3c434f;
  --muted: #687180;
  --rule: #dde1e6;
  --tint: #f4f6f8;
  --blue: #2a7bcf;
  --red: #d6453a;
  --yellow: #f0be2c;
  --yellow-ink: #8c6a00;
  --green: #3a9b5c;
  --violet: #8a63c9;
  --orange: #e2862a;

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --text: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --sheet: 1120px;
  --col: 680px;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101317; --ink: #e8ebef; --ink-2: #c2c8d1; --muted: #8b94a2; --rule: #272c34; --tint: #171b21;
    --blue: #5ea6ee; --red: #f06a5d; --yellow: #f3c94a; --yellow-ink: #f3c94a; --green: #5cc282; --violet: #a98be0; --orange: #f0a04e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101317; --ink: #e8ebef; --ink-2: #c2c8d1; --muted: #8b94a2; --rule: #272c34; --tint: #171b21;
  --blue: #5ea6ee; --red: #f06a5d; --yellow: #f3c94a; --yellow-ink: #f3c94a; --green: #5cc282; --violet: #a98be0; --orange: #f0a04e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--text); font-size: 17px; line-height: 1.6; font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
code, pre, kbd { font-family: var(--mono); }
p code, li code, td code, dd code { font-size: .86em; background: var(--tint); padding: 1px 4px; }
::selection { background: var(--yellow); color: #15181d; }

.sheet { max-width: var(--sheet); margin: 0 auto; padding-inline: var(--gutter); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding-block: 18px; border-bottom: 1px solid var(--ink); }
.mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 18px; font-variation-settings: "wdth" 125; letter-spacing: -0.01em; }
.mark .cells { display: inline-flex; gap: 2px; }
.mark .cells i { width: 9px; height: 9px; display: block; }
.top nav { display: flex; gap: 6px 20px; flex-wrap: wrap; font-size: 14px; }
.top nav a { color: var(--ink-2); text-decoration: none; }
.top nav a:hover { color: var(--ink); text-decoration: underline; }
.c-a { background: var(--yellow); } .c-b { background: var(--blue); } .c-r { background: var(--red); } .c-k { background: var(--ink); }

/* ---------- reading layout ---------- */
.row { display: grid; grid-template-columns: minmax(0, var(--col)) minmax(0, 1fr); gap: 0 48px; }
.row > * { min-width: 0; }
.row .note { font-size: 13.5px; line-height: 1.5; color: var(--muted); padding-top: 8px; }
.row .note b { color: var(--ink-2); font-weight: 600; }
.row .note p { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
@media (max-width: 900px) { .row { grid-template-columns: minmax(0, 1fr); } .row .note { padding-top: 0; margin-bottom: 12px; } }

section { padding-block: 60px 8px; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); text-wrap: balance; margin: 0; }
h1 { font-size: clamp(52px, 10vw, 112px); line-height: .9; font-weight: 700; font-variation-settings: "wdth" 125; letter-spacing: -0.04em; }
h2 { font-size: clamp(26px, 3.2vw, 34px); line-height: 1.1; font-weight: 650; font-variation-settings: "wdth" 112; letter-spacing: -0.015em; margin-bottom: 16px; }
h3 { font-size: 18px; line-height: 1.25; font-weight: 650; font-variation-settings: "wdth" 105; margin: 26px 0 6px; }
p { margin: 0 0 16px; color: var(--ink-2); text-wrap: pretty; }
p strong { color: var(--ink); font-weight: 650; }
.eq { font-family: var(--mono); font-size: 15px; color: var(--ink); background: var(--tint); padding: 10px 14px; margin: 4px 0 18px; overflow-x: auto; white-space: nowrap; }

/* ---------- intro ---------- */
.intro { padding-block: 40px 20px; }
.intro .dek { font-size: clamp(19px, 2.1vw, 23px); line-height: 1.45; color: var(--ink); max-width: 34ch; margin: 22px 0 26px; }
.get { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; }
.pip { display: inline-flex; align-items: stretch; border: 1px solid var(--ink); font-family: var(--mono); font-size: 15px; max-width: 100%; }
.pip span { padding: 9px 14px; white-space: nowrap; overflow-x: auto; }
.pip span::before { content: "$ "; color: var(--muted); }
.pip button, .copy { appearance: none; border: 0; border-left: 1px solid var(--ink); background: var(--ink); color: var(--paper); font: 500 13px var(--mono); padding: 0 14px; cursor: pointer; }
.copy { border-left: 1px solid var(--ink); padding: 8px 14px; }
.pip button:hover, .copy:hover { background: var(--blue); }
.pip button[data-copied], .copy[data-copied] { background: var(--green); }
.facts { font-size: 14px; color: var(--muted); margin: 0; }
.facts a { color: var(--ink-2); }

/* ---------- figures ---------- */
figure { margin: 0; }
.fig { margin-block: 30px 10px; border-top: 2px solid var(--ink); padding-top: 12px; }
.fig-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 24px; flex-wrap: wrap; margin-bottom: 14px; }
.fig-no { font-family: var(--display); font-weight: 700; font-size: 15px; font-variation-settings: "wdth" 115; color: var(--ink); }
.fig-no span { font-weight: 500; color: var(--ink-2); margin-left: 8px; font-variation-settings: "wdth" 100; }
figcaption.cap { font-size: 14px; line-height: 1.55; color: var(--muted); margin-top: 14px; max-width: 900px; }
figcaption.cap b { color: var(--ink); font-weight: 650; }
.seg { display: inline-flex; border: 1px solid var(--ink); flex-wrap: wrap; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--ink); font: 500 12.5px var(--text); padding: 6px 11px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

/* Figure 1: churn explainer */
.f1 { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 28px; }
@media (max-width: 900px) { .f1 { grid-template-columns: minmax(0, 1fr); } }
.f1 > * { min-width: 0; }
.map-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 8px; }
.map-wrap { position: relative; width: 100%; max-width: 100%; aspect-ratio: 1 / 1; background: var(--tint); }
.map-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 18px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; display: inline-block; }
.legend .ramp { width: 110px; height: 8px; background: linear-gradient(90deg, var(--blue), var(--rule) 50%, var(--red)); }
.tip { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; background: var(--paper); border: 1px solid var(--ink); padding: 6px 8px; font-size: 12.5px; line-height: 1.4; max-width: 250px; color: var(--ink); }
.tip small { display: block; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.who { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.who select { flex: 1; min-width: 0; font: 14px var(--text); color: var(--ink); background: var(--paper); border: 1px solid var(--ink); padding: 7px 8px; border-radius: 0; }
.who button { appearance: none; flex: none; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); width: 34px; height: 34px; font-size: 15px; cursor: pointer; }
.who button:hover { background: var(--ink); color: var(--paper); }
.risk { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--ink); margin-bottom: 8px; }
.risk .num { font-family: var(--display); font-size: 60px; line-height: .85; font-weight: 700; font-variation-settings: "wdth" 115; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.risk .num small { font-size: 24px; letter-spacing: 0; }
.risk .what { font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.risk .what b { color: var(--ink); font-weight: 650; }
.ok { color: var(--green); font-weight: 650; } .miss { color: var(--red); font-weight: 650; }
.bd-h { font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 12px 0 2px; display: flex; justify-content: space-between; gap: 8px; }
.bd-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(70px, 120px) 50px; gap: 10px; align-items: center; padding: 2px 0; font-size: 13.5px; }
.bd-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bd-row .nm small { color: var(--muted); margin-left: 6px; font-family: var(--mono); font-size: 11px; }
.bd-row .tr { position: relative; height: 10px; }
.bd-row .tr::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.bd-row .tr i { position: absolute; top: 0; height: 100%; }
.bd-row .v { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .bd-row .nm { white-space: normal; } }
.bd-row.sum { border-top: 1px solid var(--ink); margin-top: 6px; padding-top: 6px; }
.bd-row.sum .nm, .bd-row.sum .v { color: var(--ink); font-weight: 650; }
.bd-gap { height: 6px; }
.bd-row.hl { background: color-mix(in srgb, var(--yellow) 30%, transparent); }
.strip-wrap { margin-top: 24px; position: relative; }
.strip-wrap canvas { display: block; width: 100%; height: 150px; }

/* tables */
.tbl { overflow-x: auto; margin-block: 6px 18px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-weight: 600; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--ink); }
td.n, th.n { text-align: right; font-family: var(--mono); font-size: 13.5px; white-space: nowrap; }
tr.us td { color: var(--ink); font-weight: 650; }
td .bar { display: inline-block; height: 8px; background: var(--muted); vertical-align: middle; margin-left: 8px; }
tr.us td .bar { background: var(--blue); }
td.lose { color: var(--muted); }

/* Figure 2: schematic */
.f2 svg { display: block; width: 100%; height: auto; }
.f2 .t { font-family: var(--mono); font-size: 12px; fill: var(--muted); }
.f2 .tk { font-family: var(--display); font-size: 15px; font-weight: 650; fill: var(--ink); }
.f2 .fa { fill: var(--yellow); } .f2 .fb { fill: var(--blue); } .f2 .fr { fill: var(--red); } .f2 .fk { fill: var(--ink); }
.f2 .sa { stroke: var(--yellow); } .f2 .sb { stroke: var(--blue); } .f2 .sr { stroke: var(--red); } .f2 .sk { stroke: var(--ink); }
.f2 .arr { fill: none; stroke-width: 2.4; stroke-linecap: round; }
.f2 .dash { stroke-dasharray: 5 4; }
.f2 .rule { stroke: var(--rule); stroke-width: 1; fill: none; }
.f2 .axis { stroke: var(--ink); stroke-width: 1; fill: none; }

/* Figure 3: language */
.f3-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .f3-pair { grid-template-columns: 1fr; } }
.f3-pair > * { min-width: 0; }
.f3-pair .ttl { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.f3-pair .ttl b { color: var(--ink); }
.f3-pair canvas { display: block; width: 100%; height: 300px; background: var(--tint); }

/* Figure 4: geometries */
.geo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 20px; }
@media (max-width: 1000px) { .geo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .geo-grid { grid-template-columns: minmax(0, 1fr); } }
.geo { min-width: 0; border-top: 1px solid var(--ink); padding-top: 10px; }
.geo canvas { display: block; width: 100%; height: 150px; background: var(--tint); margin-bottom: 10px; }
.geo > code { font-size: 14px; font-weight: 500; color: var(--ink); }
.geo .rule { margin: 2px 0 6px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.geo p { margin: 0; font-size: 14px; line-height: 1.5; }
.geo-code pre { height: 100%; font-size: 12px; padding: 12px 14px; }

/* code */
.code { border: 1px solid var(--ink); margin-block: 10px 20px; }
.code-bar { display: flex; justify-content: space-between; align-items: stretch; border-bottom: 1px solid var(--ink); flex-wrap: wrap; }
.code-bar .seg { border: 0; }
.code-bar .seg button { border-right: 1px solid var(--ink); padding: 8px 12px; }
.code-bar .seg button + button { border-left: 0; }
pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.65; color: var(--ink-2); background: var(--tint); }
pre .k { color: var(--blue); } pre .s { color: var(--green); } pre .n { color: var(--yellow-ink); } pre .c { color: var(--muted); }

dl.qa { margin: 0; }
dl.qa dt { font-weight: 650; color: var(--ink); margin-top: 18px; font-variation-settings: "wdth" 105; }
dl.qa dd { margin: 4px 0 0; color: var(--ink-2); }

.foot { margin-top: 72px; border-top: 1px solid var(--ink); padding-block: 18px 40px; display: flex; justify-content: space-between; gap: 10px 24px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.foot a { color: var(--ink-2); }
