:root {
  --pur: #7c3aed;      /* N, the total number of items */
  --pur-bg: #f3ecff;
  --bg: #ffffff;
  --ink: #1b2333;
  --mute: #6a7386;
  --line: #e3e6ec;
  --panel: #f5f7fa;
  --tgt: #1f5fd6;      /* target word X */
  --tgt-bg: #e4edff;
  --col: #e0570f;      /* collocate Y */
  --col-bg: #ffe8d9;
  --win: #f4b400;      /* window / horizon */
  --win-bg: #fff6d6;
  --ok: #157a3c;
  --ok-bg: #e0f4e7;
  --bad: #b42318;
  --latin: "Avenir Book", "Avenir", "Avenir Next", "Nunito Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --cjk: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0f1218; overflow: hidden; }
body { font-family: var(--latin), var(--cjk); color: var(--ink); -webkit-font-smoothing: antialiased; }

/* fixed 1280x720 stage, scaled to fit the window */
#stage { position: absolute; left: 50%; top: 50%; width: 1280px; height: 720px; transform-origin: center; background: var(--bg); overflow: hidden; }

.slide { position: absolute; inset: 0; padding: 40px 100px 44px 72px; opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility .35s; }
.slide.active { opacity: 1; visibility: visible; }
.slide.full { padding-right: 72px; }

/* bilingual text: Chinese large, English smaller */
.zh { font-family: var(--cjk), var(--latin); font-size: 1.22em; font-weight: 500; }
.en { font-family: var(--latin), var(--cjk); font-size: .8em; color: var(--mute); }
.bi > .zh, .bi > .en { display: block; }
.bi > .zh { font-size: 32px; line-height: 1.3; }
.bi > .en { font-size: 21px; line-height: 1.3; margin-top: 2px; }
.bi.sm > .zh { font-size: 24px; } .bi.sm > .en { font-size: 17px; }
.bi.xs > .zh { font-size: 19px; } .bi.xs > .en { font-size: 14px; }
.bi + .bi { margin-top: 12px; }
.il .zh { font-size: 1.15em; } .il .en { font-size: .8em; margin-left: .35em; }

h2 { margin: 0 0 14px; }
h2.bi > .zh { font-size: 44px; font-weight: 600; letter-spacing: .01em; }
h2.bi > .en { font-size: 23px; }
.kicker { font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--tgt); font-weight: 600; margin-bottom: 4px; height: 18px; }

.tgt-c { color: var(--tgt); font-weight: 600; }
.col-c { color: var(--col); font-weight: 600; }
.ok-c { color: var(--ok); font-weight: 600; }
.bad-c { color: var(--bad); font-weight: 600; }
b, strong { font-weight: 600; }
.small { font-size: 18px; color: var(--mute); }
.sp { height: 14px; }

/* step reveal */
[data-step] { opacity: 0; transform: translateY(10px); transition: opacity .4s ease, transform .4s ease; pointer-events: none; }
[data-step].on { opacity: 1; transform: none; pointer-events: auto; }
.swap { display: grid; }
.swap > * { grid-area: 1 / 1; }

/* title slide */
.title-slide { display: flex; flex-direction: column; justify-content: center; padding-left: 96px; }
.title-slide .big-zh { font-size: 110px; font-weight: 600; letter-spacing: .04em; line-height: 1.1; }
.title-slide .big-en { font-size: 46px; color: var(--mute); margin-top: 6px; letter-spacing: .01em; }
.title-slide .rule { width: 90px; height: 6px; background: var(--tgt); border-radius: 3px; margin: 30px 0; }
.title-slide .quote { margin-top: 10px; max-width: 900px; }
.title-slide .quote .zh { font-size: 30px; } .title-slide .quote .en { font-size: 22px; font-style: italic; }
.hint { position: absolute; bottom: 30px; left: 96px; font-size: 16px; color: var(--mute); }
kbd { border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 7px; background: #fff; font-family: inherit; font-size: .9em; }

/* definition / callout */
.def { border-left: 5px solid var(--tgt); padding: 4px 0 4px 24px; margin: 8px 0 18px; }
.def .src { font-size: 15px; color: var(--mute); margin-top: 6px; }
.callout { background: var(--panel); border-left: 5px solid var(--win); border-radius: 10px; padding: 12px 24px; margin-top: 16px; }
.callout.key { border-left-color: var(--tgt); }
.eq { font-family: var(--latin), var(--cjk); font-size: 26px; background: var(--panel); border-radius: 10px; padding: 10px 20px; display: inline-block; margin: 6px 0; line-height: 1.5; }
.eq.big { font-size: 32px; }

/* pairs */
.pairrow { display: flex; align-items: center; gap: 22px; margin: 10px 0; }
.pairrow .bi { width: 210px; flex: none; margin: 0; }
.pairs { display: flex; flex-wrap: wrap; gap: 12px; }
.pair { font-size: 28px; padding: 8px 20px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); }
.pair.no { background: var(--panel); color: var(--mute); }
.pair b { font-weight: 400; opacity: .5; padding: 0 .25em; }

/* token chips */
.toks { display: flex; flex-wrap: wrap; gap: 6px 4px; position: relative; }
.toks.sparse { row-gap: 40px; padding-top: 16px; padding-bottom: 12px; }
.lines.tight .toks { padding: 3px 0; }
.lines.win .toks.sparse { padding-top: 14px; padding-bottom: 5px; }
.tok { position: relative; display: inline-block; padding: 3px 9px; border-radius: 9px; font-family: var(--cjk), var(--latin); font-size: 30px; line-height: 1.3; border: 2px solid transparent; transition: background .35s, color .35s, border-color .35s, opacity .35s; white-space: nowrap; }
.tok.punct { padding: 3px 1px; color: var(--mute); }
.tok.win { background: var(--win-bg); }
.tok.tgt { background: var(--tgt); color: #fff; }
.tok.col { background: var(--col); color: #fff; }
.tok.pairA { background: var(--tgt-bg); border-color: var(--tgt); }
.tok.pairB { background: var(--col-bg); border-color: var(--col); }
.tok.dim { opacity: .3; }
.tok[data-d]::before { content: attr(data-d); position: absolute; top: -17px; left: 0; right: 0; text-align: center; font-family: var(--latin); font-size: 13px; color: #a67c00; }
.hz { position: absolute; height: 9px; border: 3px solid var(--win); border-top: none; border-radius: 0 0 8px 8px; animation: hz-in .45s ease both; }
@keyframes hz-in { from { opacity: 0; transform: scaleX(.3); } to { opacity: 1; transform: none; } }
.shuffle .tok { background: #eef0f4; font-size: 32px; }
.shuffle.ordered .tok { background: var(--ok-bg); }
.tag { display: inline-block; font-size: 15px; font-weight: 600; padding: 3px 12px; border-radius: 999px; margin-right: 6px; vertical-align: middle; }
.tag.tgt { background: var(--tgt); color: #fff; }
.tag.col { background: var(--col); color: #fff; }
.tag.win { background: var(--win-bg); border: 2px solid var(--win); color: #7a5c00; }

/* cards */
.card { border: 1.5px solid var(--line); border-radius: 16px; background: #fff; padding: 16px 24px; box-shadow: 0 2px 10px rgba(20, 30, 60, .05); }
.cards { display: flex; gap: 22px; }
.cards .card { flex: 1; }
.card h3 { margin: 0; font-weight: 600; }
.card .nums { font-size: 20px; line-height: 1.6; margin-top: 8px; }
.card .nums b { font-size: 22px; }

/* balls */
.balls { display: flex; gap: 12px; margin: 22px 0 14px; }
.ball { width: 64px; height: 64px; border-radius: 50%; background: #cfd4dc; transition: transform .35s, box-shadow .35s, opacity .35s; }
.ball.red { background: #d92d20; }
.balls.picking .ball { opacity: .28; }
.balls.picking .ball.picked { opacity: 1; box-shadow: 0 0 0 4px var(--tgt); }
.red-c { color: #d92d20; font-weight: 600; }

/* contingency table */
table.ct { border-collapse: separate; border-spacing: 6px; }
table.ct th { white-space: nowrap; font-weight: 400; padding: 4px 10px; text-align: center; vertical-align: middle; }
table.ct th.rh { text-align: right; }
table.ct td { text-align: center; min-width: 118px; height: 78px; background: #fff; border: 2px solid var(--line); border-radius: 12px; font-size: 34px; font-weight: 600; transition: background .35s, border-color .35s; position: relative; }
table.ct td.hl { background: var(--col-bg); border-color: var(--col); }
table.ct td .letter { position: absolute; top: 4px; left: 9px; font-size: 13px; color: var(--mute); font-weight: 500; }
table.ct.mini td { min-width: 82px; height: 50px; font-size: 24px; }
table.ct.mini .letter { display: none; }
table.ct .z { display: block; font-family: var(--cjk); font-size: 18px; color: var(--ink); line-height: 1.2; }
table.ct .e { display: block; font-size: 13px; color: var(--mute); line-height: 1.2; }
table.ct.mini .z { font-size: 15px; } table.ct.mini .e { font-size: 12px; }
.ct-title { font-size: 15px; color: var(--mute); margin-bottom: 2px; text-align: center; }
.fisher { display: flex; gap: 32px; align-items: flex-start; margin: 10px 0 0; }
.fisher .col { text-align: center; }
.fisher .pv { font-size: 22px; margin-top: 4px; font-family: "SF Mono", Menlo, monospace; }

.two { display: flex; gap: 40px; align-items: flex-start; }
.two > .grow { flex: 1; min-width: 0; }
.lines { display: flex; flex-direction: column; gap: 0; }
.line { display: flex; align-items: center; gap: 12px; }
.line .sid { width: 34px; font-size: 15px; color: var(--mute); flex: none; }
.line .toks { flex-wrap: nowrap; }
.line .toks .tok { font-size: 24px; padding: 2px 6px; }
.badge { font-size: 14px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; transition: opacity .4s; }
.badge.both { background: var(--ok-bg); color: var(--ok); }
.badge.xonly { background: var(--tgt-bg); color: var(--tgt); }
.badge.none { background: var(--panel); color: var(--mute); }
.sig { font-family: "SF Mono", Menlo, monospace; font-size: 16px; color: var(--mute); }
.ctrl { position: absolute; right: 100px; top: 44px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 14px; font-size: 18px; box-shadow: 0 2px 10px rgba(20, 30, 60, .05); }

/* bars */
.bars { margin: 14px 0; }
.barrow { display: flex; align-items: center; gap: 18px; margin: 14px 0; }
.barrow .bi { width: 230px; flex: none; margin: 0; }
.bar { height: 46px; border-radius: 8px; display: flex; align-items: center; justify-content: flex-end; padding-right: 14px; color: #fff; font-size: 24px; font-weight: 600; }
.bar.e { background: var(--tgt); width: 108px; } .bar.o { background: var(--col); width: 720px; }

/* comparison */
table.cmp { border-collapse: collapse; width: 100%; }
table.cmp th, table.cmp td { text-align: left; padding: 3px 12px; border-bottom: 1.5px solid var(--line); vertical-align: middle; }
table.cmp thead th { border-bottom: 2px solid var(--ink); }
table.cmp th.rh { width: 190px; }
table.cmp .bi + .bi { margin: 0; }

/* sidebar: slim strip of section numbers, invisible until the mouse is over the right edge; name on hover */
#side { position: absolute; right: 0; top: 0; bottom: 0; width: 64px; background: var(--panel); border-left: 1px solid var(--line); z-index: 6; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; opacity: 0; transition: opacity .25s; }
#side:hover, #stage:has(#nav:hover) #side { opacity: 1; }
#side.hide { opacity: 0 !important; pointer-events: none; }
#side .item { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 16px; font-weight: 600; color: var(--mute); border: 2px solid transparent; transition: background .2s, color .2s; }
#side .item:hover { background: #e4e9f2; color: var(--ink); }
#side .item.done { color: var(--ink); }
#side .item.cur { background: var(--tgt); color: #fff; }
#side .item .tip { display: none; position: absolute; right: 50px; top: 50%; transform: translateY(-50%); background: var(--ink); color: #fff; border-radius: 10px; padding: 8px 14px; white-space: nowrap; box-shadow: 0 4px 16px rgba(20, 30, 60, .25); text-align: left; font-weight: 400; pointer-events: none; }
#side .item:hover .tip { display: block; }
#side .item .tip .zh { display: block; font-size: 18px; color: #fff; font-weight: 500; }
#side .item .tip .en { display: block; font-size: 13px; color: #b9c2d3; margin-top: 1px; }

/* chrome */
#bar { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--tgt); width: 0; transition: width .3s; z-index: 7; }
#nav { position: absolute; right: 4px; bottom: 14px; width: 56px; display: flex; gap: 4px; z-index: 8; }
#nav button { flex: 1; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--mute); font: inherit; font-size: 20px; line-height: 1; cursor: pointer; padding: 0; }
#nav button:hover { background: #e4e9f2; color: var(--ink); }
/* practice rows: label left, equation right */
.prac .prow { display: flex; align-items: center; gap: 24px; min-height: 50px; }
.prac .prow .bi { width: 430px; flex: none; margin: 0; }
.prac .prow .eq { margin: 0; }
#num { position: absolute; right: 68px; bottom: 14px; height: 30px; line-height: 30px; font-size: 13px; color: var(--mute); z-index: 5; }

.ctlist { min-height: 250px; }
.ctlist .bi + .bi { margin-top: 14px; }

/* tea experiment */
.cups { display: flex; gap: 14px; margin: 10px 0 4px; }
.cup { display: flex; flex-direction: column; align-items: center; width: 92px; }
.cup svg { width: 88px; height: 68px; }
.pour { font-size: 16px; font-weight: 700; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; margin-top: 2px; }
.pour.m { background: var(--tgt); } .pour.t { background: var(--col); }

/* portraits */
.portrait { position: absolute; margin: 0; text-align: center; font-size: 15px; line-height: 1.3; }
.portrait img { display: block; width: 100%; border-radius: 10px; box-shadow: 0 4px 18px rgba(20, 30, 60, .22); }
.portrait figcaption { margin-top: 8px; font-weight: 600; }
.portrait figcaption span { font-weight: 400; color: var(--mute); }
.title-portrait { right: 110px; top: 50%; width: 190px; margin-top: -175px; }
.title-slide .quote { max-width: 760px; }
.tea-portrait { right: 100px; top: 34px; width: 128px; z-index: 2; }

/* binomial coefficients and fractions */
.pl { display: flex; align-items: center; gap: 12px; font-size: 34px; font-family: var(--latin); }
.bn { display: inline-flex; align-items: center; }
.bn .p { font-size: 74px; font-weight: 200; line-height: 1; transform: scaleX(.8); color: var(--mute); }
.bn .st { display: flex; flex-direction: column; align-items: center; line-height: 1.1; margin: 0 -3px; font-size: .92em; }
.bn .n { color: var(--tgt); } .bn .k { color: var(--col); }
.frac { display: inline-flex; flex-direction: column; align-items: center; }
.frac .num { padding: 4px 12px 6px; border-bottom: 3px solid var(--ink); display: flex; align-items: center; gap: 2px; }
.frac .den { padding: 6px 12px 2px; display: flex; }
.fp { border-radius: 12px; padding: 0 6px; transition: box-shadow .3s, background .3s; display: inline-flex; }
.fp.act { box-shadow: 0 0 0 3px var(--win); background: var(--win-bg); }
table.ct.fm td { min-width: 96px; height: 62px; font-size: 30px; }
table.ct td.tot { border: none; background: none; font-size: 24px; color: var(--mute); font-weight: 500; min-width: 84px; box-shadow: none; }
table.ct td.bl { border-color: #4a86e8; background: #eaf1fe; box-shadow: 0 0 0 2px #4a86e8 inset; }
table.ct td.rd { border-color: #e03a2f; background: #fdeceb; box-shadow: 0 0 0 2px #e03a2f inset; }
table.ct td.tot.bl { background: none; box-shadow: none; color: #2f6fd8; font-weight: 700; }
table.ct td.tot.rd { background: none; box-shadow: none; color: #d02a20; font-weight: 700; }
table.ct.mini.tight td { min-width: 60px; height: 46px; font-size: 22px; }
table.ct.mini.tight .z { font-size: 13px; } table.ct.mini.tight .e { font-size: 11px; }
.pairs6 { display: grid; grid-template-columns: repeat(3, auto); gap: 10px; margin-top: 10px; justify-content: start; }
.pairs6 span { font-size: 28px; background: var(--win-bg); border: 2px solid var(--win); border-radius: 10px; padding: 4px 16px; text-align: center; }

table.cmp td.num, table.cmp th.num { text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
table.cmp td.zero { color: #b6bcc8; }
table.cmp tr.neg td { background: #fdf3f2; }
table.cmp tr.zer td { background: var(--panel); }
table.cmp tr.pos td { background: #f1f8f3; }
sub { font-size: .6em; }

.defs { margin-top: 8px; } .defs .bi + .bi { margin-top: 7px; }
.defs .legend { color: var(--col); }
table.ct.mini.showl .letter { display: block; font-size: 11px; top: 2px; left: 6px; }
table.ct.mini.showl td { height: 48px; }

/* n choose k */
.chipset { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.chipset span { font-size: 26px; background: var(--win-bg); border: 2px solid var(--win); border-radius: 10px; padding: 3px 14px; }
.chipset.big span { font-size: 40px; padding: 6px 20px; background: var(--tgt-bg); border-color: var(--tgt); color: var(--tgt); font-weight: 600; }
.chipset.same span { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.slots { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.slots > div { display: flex; flex-direction: column; align-items: center; border: 2px solid var(--line); border-radius: 12px; padding: 4px 22px; min-width: 84px; background: #fff; }
.slots > div b { font-size: 38px; font-weight: 600; } .slots > div span { font-size: 13px; color: var(--mute); }
.slots > div.res { border-color: var(--col); background: var(--col-bg); }
.slots > div.res b { color: var(--col); }
.slots > i { font-style: normal; font-size: 30px; color: var(--mute); }

.chartbox { width: 420px; flex: none; }
#ball-chart { width: 100%; height: auto; display: block; margin: 4px 0; }
#ball-chart text { font-family: var(--latin), var(--cjk); font-size: 15px; fill: var(--mute); }

.pl.s { font-size: 26px; gap: 8px; }
.pl.s .frac .num { padding: 2px 10px 3px; } .pl.s .frac .den { padding: 3px 10px 0; }
.pl.s .bn { font-size: 26px; }
.chipset.big { flex-wrap: nowrap; flex: none; margin: 0; }
.chipset.big span { font-size: 30px; padding: 3px 14px; }
.slots > div { padding: 2px 18px; min-width: 76px; } .slots > div b { font-size: 32px; }

.pur-c { color: var(--pur); }
table.ct td.pu { border-color: var(--pur); background: var(--pur-bg); box-shadow: 0 0 0 2px var(--pur) inset; }
table.ct td.tot.pu { background: none; box-shadow: none; color: var(--pur); font-weight: 700; }
#fp3 .n { color: var(--pur); }
#obs-toks .tok { font-size: 23px; padding: 2px 6px; }
#obs-toks { gap: 6px 3px; }

img.fig { display: block; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }

.chipset .grp { display: flex; gap: 4px; padding: 4px; border: 2px dashed var(--ok); border-radius: 12px; }
.chipset .grp span { font-size: 24px; padding: 2px 12px; }
.chipset.same { gap: 12px; }
s { text-decoration-color: var(--mute); color: var(--mute); }

.card .toks .tok { font-size: 24px; padding: 2px 8px; }

/* rectangles drawn over the table on the formula slide */
.rect { position: absolute; border: 4px solid; border-radius: 14px; pointer-events: none; animation: hz-in .35s ease both; }
.rect.bl { border-color: #4a86e8; } .rect.rd { border-color: #e03a2f; } .rect.pu { border-color: var(--pur); }

/* KaTeX */
.tex .katex { font-size: 1.12em; }
.eq .tex .katex { font-size: 1.02em; }
.nums .tex .katex { font-size: 1em; }
.frac .num .katex, .frac .den .katex { font-size: 1.05em; }
.fp .katex { font-size: 1.25em; }
.tex-block { display: block; }

/* recap */
.recap { margin-top: 12px; }
.rrow { display: flex; align-items: center; gap: 18px; margin: 12px 0; }
.rrow i { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--tgt); color: #fff; font-style: normal; font-weight: 600; font-size: 20px; display: grid; place-items: center; }

.logex { margin: 10px 0 0; font-size: 22px; line-height: 2; }
#log-chart { width: 100%; height: auto; display: block; }
#log-chart text { font-family: var(--latin), var(--cjk); font-size: 14px; fill: var(--mute); }

/* significance vs. strength */
.sig-c { color: var(--pur); font-weight: 600; }
.str-c { color: var(--ok); font-weight: 600; }
.qcard { border-top: 6px solid; }
.qcard.sig { border-top-color: var(--pur); } .qcard.sig h3 .zh { color: var(--pur); }
.qcard.str { border-top-color: var(--ok); } .qcard.str h3 .zh { color: var(--ok); }
.meas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.meas span { font-size: 17px; border-radius: 999px; padding: 3px 12px; border: 1.5px solid var(--line); background: var(--panel); }
.qcard.sig .meas span { border-color: var(--pur); color: var(--pur); background: var(--pur-bg); }
.qcard.str .meas span { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.propbar { height: 30px; border-radius: 8px; background: var(--line); margin: 12px 0 10px; overflow: hidden; }
.propbar span { display: flex; align-items: center; justify-content: flex-end; height: 100%; padding-right: 10px; background: var(--ok); color: #fff; font-weight: 600; font-size: 17px; }
.kv { display: flex; align-items: baseline; gap: 12px; margin-top: 8px; font-size: 18px; }
.kv > span:first-child { width: 170px; flex: none; }
.kv b { font-size: 21px; }
table.cmp.scale td.num { font-size: 20px; }
table.cmp.scale th.str-h { color: var(--ok); } table.cmp.scale th.sig-h { color: var(--pur); }
table.cmp.scale tr.grp th { font-size: 14px; text-align: center; border-bottom: none; padding-bottom: 0; }
table.cmp.scale tr.here td { background: var(--win-bg); }
.callout.str-b { border-left-color: var(--ok); margin-top: 0; } .callout.sig-b { border-left-color: var(--pur); margin-top: 0; }
.rrow i.sig-bg { background: var(--pur); } .rrow i.str-bg { background: var(--ok); }
pre.code { flex: none; width: 560px; margin: 0; font-family: Menlo, "SF Mono", Consolas, monospace; font-size: 16px; line-height: 1.55; background: #1b2333; color: #e6e9ef; border-radius: 12px; padding: 16px 20px; white-space: pre; }
pre.code .k { color: #c792ea; } pre.code .s { color: #c3e88d; } pre.code .n { color: #f78c6c; }
code { font-family: Menlo, "SF Mono", Consolas, monospace; font-size: .85em; background: var(--panel); border-radius: 4px; padding: 0 4px; }
#s-recap .rrow { margin: 8px 0; }

/* ===== networks deck ===== */
.two3 { display: flex; gap: 20px; } .two3 > * { flex: 1; margin-top: 0 !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; margin-top: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 20px; margin-top: 12px; }
.grid2 .card, .grid3 .card { padding: 12px 20px; }
.callout { margin-top: 14px; }
.small { font-size: 15px; color: var(--mute); }
em.en { font-style: normal; font-family: var(--latin), var(--cjk); font-size: .75em; color: var(--mute); margin-left: .3em; }

/* routes, readings */
.route { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.rstop { display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 18px; background: #fff; }
.rstop i { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--tgt); color: #fff; font-style: normal; font-weight: 600; display: grid; place-items: center; }
.rarrow, .absarrow, .ca, .parr { color: var(--mute); font-size: 28px; }
.reads { margin: 8px 0 0; padding-left: 22px; font-size: 21px; line-height: 1.7; }
.reads .role { font-size: 14px; color: var(--tgt); background: var(--tgt-bg); border-radius: 999px; padding: 2px 10px; margin-left: 8px; }
.reads .opt { color: var(--mute); }

/* relation grid, chips, tables */
.relgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 4px; }
.rel { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 18px; background: var(--panel); }
.rel b { display: block; font-size: 24px; font-weight: 600; } .rel span { font-size: 15px; color: var(--mute); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.chips span { font-size: 22px; background: var(--win-bg); border: 2px solid var(--win); border-radius: 10px; padding: 3px 14px; }
.chips.sm span { font-size: 16px; padding: 2px 10px; }
table.tbl { border-collapse: collapse; width: 100%; margin: 10px 0 4px; font-size: 22px; }
table.tbl th, table.tbl td { text-align: left; padding: 7px 14px; border-bottom: 1.5px solid var(--line); }
table.tbl thead th { border-bottom: 2px solid var(--ink); font-size: 15px; color: var(--mute); font-weight: 500; }
table.tbl.sm { font-size: 18px; } table.tbl.sm td, table.tbl.sm th { padding: 5px 12px; }
.absrow { display: flex; align-items: center; gap: 22px; margin-top: 16px; } .absrow .card { flex: 1; }

/* svg networks */
svg.net { display: block; overflow: visible; }
.netbox { position: relative; flex: none; width: 640px; }
.toycap { font-size: 13px; color: var(--mute); margin-top: 2px; }
.ge { stroke: #b8c0cf; stroke-width: 2.2; fill: none; transition: stroke .3s, opacity .3s; }
.ge.hot { stroke: var(--col); stroke-width: 3; }
.ge.dim { opacity: .18; }
g.ge { stroke-width: 3; }
svg.net .gn circle { fill: var(--tgt-bg); stroke: var(--tgt); stroke-width: 2.5; transition: fill .3s, stroke .3s; }
svg.net .gn text { font-family: var(--cjk), var(--latin); font-size: 15px; fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
svg.net .gn.dim { opacity: .22; }
svg.net .glabel { font-family: var(--latin); font-size: 14px; font-weight: 700; fill: #7a2e00; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.cl-n, g.cl circle { fill: var(--tgt-bg); stroke: var(--tgt); stroke-width: 2.5; }
g.cl2 rect { fill: var(--col-bg); stroke: var(--col); stroke-width: 2.5; }
g.cl2b circle { fill: var(--tgt-bg); stroke: var(--tgt); stroke-width: 2.5; }
.cl-t { font-family: var(--cjk), var(--latin); font-size: 17px; fill: var(--ink); }
.edgegrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0 0; }
.ecell { border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 12px 12px; background: #fff; }
.ecell svg { width: 100%; height: 90px; display: block; }
.legend { margin-top: 10px; transition: opacity .4s; } .legend > div { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.legend i { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.idcol { flex: 1; }

/* stats, ranks, kv */
.stat { margin: 10px 0 12px; } .stat .n { font-size: 52px; font-weight: 600; color: var(--tgt); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats3 { display: flex; gap: 40px; margin-top: 14px; }
.rankrow { display: flex; align-items: center; gap: 14px; margin: 8px 0; font-size: 26px; }
.rankrow i { width: 34px; height: 34px; border-radius: 50%; background: var(--col); color: #fff; font-style: normal; font-weight: 600; font-size: 18px; display: grid; place-items: center; }
.rankrow .nm { flex: 1; font-family: var(--cjk); } .rankrow b { font-variant-numeric: tabular-nums; color: var(--col); }
.kv { flex-wrap: wrap; } .kv > span:first-child { width: 270px; }
.ex { margin-top: 12px; font-size: 18px; color: var(--tgt); }
.laynames { margin-top: 12px; } .lay-name { font-size: 24px; padding: 8px 16px; border-radius: 10px; margin: 8px 0; border: 2px solid var(--line); color: var(--mute); transition: all .3s; }
.lay-name.cur { border-color: var(--tgt); background: var(--tgt-bg); color: var(--ink); }

/* case slides */
.lists { display: flex; gap: 18px; margin: 20px 0 10px; }
.lcard { flex: 1; border: 1.5px solid var(--line); border-radius: 16px; padding: 18px 22px; background: #fff; box-shadow: 0 2px 10px rgba(20,30,60,.05); }
.lcard b { display: block; font-size: 30px; } .lcard .yr { color: var(--tgt); font-weight: 600; margin-right: 12px; } .lcard .cnt { color: var(--mute); font-size: 18px; }
.flow { display: flex; flex-direction: column; gap: 6px; }
.fstep { display: flex; align-items: center; gap: 16px; padding: 3px 0; }
.fstep i, .rrow i { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--tgt); color: #fff; font-style: normal; font-weight: 600; font-size: 18px; display: grid; place-items: center; }
.flow.h { flex-direction: row; align-items: center; gap: 14px; }
.bx { flex: 1; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px; background: #fff; } .bx b { display: block; font-size: 22px; } .bx span { font-size: 14px; color: var(--mute); }
.bx.hl { border-color: var(--col); background: var(--col-bg); }
.pipe { display: flex; align-items: stretch; gap: 8px; margin-top: 16px; }
.pstep { flex: 1; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 12px; text-align: center; background: #fff; }
.pstep b { display: block; font-size: 20px; } .pstep span { display: block; font-size: 13px; color: var(--mute); } .pstep em { display: block; font-style: normal; font-size: 13px; color: var(--tgt); margin-top: 6px; }
.parr { align-self: center; }
.loop { margin-top: 14px; font-size: 20px; color: var(--ink); } .loop .en-s { color: var(--mute); font-size: 16px; }
.chain { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.cn { border: 2px solid var(--tgt); background: var(--tgt-bg); border-radius: 12px; padding: 8px 16px; font-size: 22px; text-align: center; } .cn span { display: block; font-size: 12px; color: var(--mute); }
.cn.hl { border-color: var(--col); background: var(--col-bg); }
.bul { margin: 6px 0 0; padding-left: 22px; font-size: 20px; line-height: 1.7; }

/* figures */
.figbox { flex: none; } .figbox .fig.tall { max-height: 520px; width: auto; max-width: 560px; }
img.fig.wide { width: 100%; max-height: 400px; object-fit: contain; }
.figcap { font-size: 13px; color: var(--mute); margin-top: 4px; max-width: 560px; }
.two > .figbox + .grow { padding-top: 6px; }

svg.net .gh { stroke: transparent; stroke-width: 16; pointer-events: stroke; }
svg.net .gn { cursor: pointer; }
.tl { margin-top: 14px; border-left: 4px solid var(--tgt); padding-left: 22px; }
.tle { display: flex; gap: 20px; align-items: baseline; margin: 10px 0; }
.tle > b { flex: none; width: 90px; font-size: 24px; color: var(--tgt); }
.stat .n { font-size: 44px; }
svg.net.mini { width: 100%; height: auto; margin-top: 8px; } svg.net.mini .ge { stroke-width: 3.5; }
#s-central-def svg.net.mini { height: 175px; } #s-central-def .card { padding: 12px 20px; }

.brief { background: var(--panel); border-radius: 10px; padding: 8px 16px; margin: 4px 0 8px; }
.brief .en { display: block; order: -1; font-size: 18px; line-height: 1.4; color: var(--ink); }
.brief .zh { display: block; font-size: 14px; line-height: 1.35; font-weight: 400; color: var(--mute); margin-top: 4px; }
.brief { display: flex; flex-direction: column; }
#num { pointer-events: auto; cursor: pointer; } #num:hover { color: var(--ink); }
#num input { width: 3.2ch; font: inherit; color: var(--ink); background: transparent; border: none; border-bottom: 1px solid var(--mute); padding: 0; text-align: right; outline: none; }

/* English is the primary line; Chinese is the smaller gloss */
.bi:has(> .en) { display: flex; flex-direction: column; }
.bi > .en { order: -1; color: var(--ink); margin: 0 0 2px; font-size: 28px; line-height: 1.3; }
.bi > .zh { order: 0; color: var(--mute); font-size: 20px; font-weight: 400; line-height: 1.3; }
.bi.sm > .en { font-size: 22px; } .bi.sm > .zh { font-size: 17px; }
.bi.xs > .en { font-size: 18px; } .bi.xs > .zh { font-size: 14px; }
h2.bi > .en { font-size: 40px; font-weight: 600; } h2.bi > .zh { font-size: 22px; }
.title-slide .big-en { font-size: 84px; font-weight: 600; color: var(--ink); line-height: 1.1; margin: 0; order: 0; }
.title-slide .big-zh { font-size: 40px; font-weight: 500; color: var(--mute); letter-spacing: .1em; order: 1; }
.title-slide .quote .en { font-size: 28px; font-style: italic; } .title-slide .quote .zh { font-size: 20px; }

/* language switch: both languages by default; button / T hides the Chinese */
.lcard p { margin: 8px 0 0; font-size: 16px; line-height: 1.45; color: var(--ink); }
.lcard b { font-size: 24px; }
.lang-en .zh, .lang-en .zh-s, .lang-en .big-zh { display: none !important; }
.lang-en em.en { margin-left: 0; font-size: 1em; color: inherit; }
#lang { position: absolute; right: 128px; bottom: 14px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--mute); font: inherit; font-size: 12px; padding: 0 9px; cursor: pointer; z-index: 8; }
#lang:hover { background: #e4e9f2; color: var(--ink); }

/* period portraits (Wikimedia Commons, public domain) */
.portraits { flex: none; width: 190px; display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.portraits figure { margin: 0; display: flex; align-items: center; gap: 10px; }
.portraits img { height: 112px; width: 84px; object-fit: cover; object-position: top; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; }
.portraits figcaption { font-size: 14px; color: var(--mute); line-height: 1.3; }
.tle > b { width: 112px; }
h2.bi > .en { font-size: 36px; }
.callout.bi > .en, .callout > .bi > .en { font-size: 24px; }
table.tbl.sm { font-size: 17px; } table.tbl.sm td, table.tbl.sm th { padding: 4px 12px; }
.tl { margin-top: 8px; } .tle { margin: 7px 0; }

/* period images, placed below the text so they never overlap it */
.banner { margin: 16px 0 0; }
.banner img { display: block; width: 100%; height: 190px; object-fit: cover; border-radius: 10px; border: 1.5px solid var(--line); }
.banner figcaption { font-size: 12px; color: var(--mute); margin-top: 4px; }

.rel { display: flex; align-items: center; gap: 14px; }
.rel .ric { flex: none; width: 44px; height: 44px; color: var(--tgt); }
.rel b { font-size: 21px; line-height: 1.25; } .rel .zh-s { font-size: 15px; color: var(--mute); }
.tle > b { width: 140px; white-space: nowrap; }

/* compact tuning for the bilingual view */
.bi.sm > .zh { font-size: 15px; } .bi.xs > .zh { font-size: 13px; } .bi > .zh { font-size: 18px; }
.banner img { height: 150px; }
.tl .bi.xs > .en { font-size: 17px; } .tl .bi.xs > .zh { font-size: 13px; line-height: 1.3; }
.tle { margin: 5px 0; }
#s-comm .bi.xs > .en { font-size: 16px; } #s-comm .bi.xs > .zh { font-size: 12.5px; }
.lcard { padding: 12px 18px; } .lcard p { font-size: 14px; margin-top: 5px; }
#s-faction-q .def .bi.xs > .en { font-size: 16px; }
#s-faction-q .lists { margin: 10px 0 6px; }
table.tbl.sm td, table.tbl.sm th { padding: 3px 10px; } table.tbl.sm { font-size: 16px; }
#s-props .banner img { height: 110px; }
.tl .bi.xs > .en { font-size: 16px; line-height: 1.3; } .tl .bi.xs > .zh { font-size: 12.5px; }
#s-toy-bg .callout { margin-top: 8px; } #s-toy-bg .callout .en { font-size: 20px; }
#s-faction-q .def { margin: 4px 0 4px !important; } #s-faction-q .callout .en { font-size: 20px; }
table.tbl.sm td, table.tbl.sm th { padding: 2px 10px; }
#s-toy-bg .tle > b { width: 120px; } #s-toy-bg .portraits { width: 170px; }
#s-toy-bg .portraits img { height: 100px; width: 75px; }
.title-slide .rule, .title-slide .quote { order: 2; } .title-slide .hint { order: 3; }
#s-comm .bi.xs > .en { font-size: 15px; line-height: 1.3; } #s-comm .bi.xs > .zh { font-size: 12px; }
#s-comm .grow > .bi, #s-comm .grow > .stat { margin-top: 6px !important; }
#s-comm .callout { margin-top: 8px !important; padding-top: 6px; padding-bottom: 6px; } #s-comm .callout .en { font-size: 18px; }
#s-central-def .card { display: flex; flex-direction: column; } #s-central-def .card .ex { margin-top: auto; }
#s-central-def .card .bi.sm { min-height: 72px; }
