/* ==========================================================================
   ViT interactive lesson — styles
   ========================================================================== */
:root {
  --bg: #f7f5f0;
  --paper: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e3ded3;
  --accent: #d9480f;
  --accent-soft: #fff0e6;
  --q: #1c7ed6;
  --k: #e8590c;
  --v: #2f9e44;
  --cls: #9c36b5;
  --pos: #0c8599;
  --ln: #e67700;
  --ok: #2f9e44;
  --bad: #e03131;
  --ovw: 252px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Latin Modern Roman", "CMU Serif", Cambria, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { font-size: clamp(15px, calc(.55vw + .9vh + 2px), 18px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 1rem; line-height: 1.45;
}
a { color: var(--q); cursor: pointer; }
h1, h2, h3 { line-height: 1.15; margin: .2em 0 .45em; }
h1 { font-size: 2.6em; }
h2 { font-size: 1.75em; }
h3 { font-size: 1.1em; }
p { margin: .45em 0; }
ul, ol { margin: .3em 0; padding-left: 1.3em; }
li { margin: .2em 0; }
kbd {
  font-family: var(--mono); font-size: .8em; padding: 1px 6px; border-radius: 4px;
  border: 1px solid #cfc8b8; border-bottom-width: 2px; background: #fff;
}
code {
  font-family: var(--mono); background: #efeadf; padding: 1px 5px; border-radius: 4px; font-size: .86em;
}
.mono { font-family: var(--mono); }
.small { font-size: .85em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.shape { font-family: var(--mono); color: var(--accent); font-weight: 600; white-space: nowrap; }
.tq { color: var(--q); font-weight: 700; }
.tk { color: var(--k); font-weight: 700; }
.tv { color: var(--v); font-weight: 700; }
.tcls { color: var(--cls); font-weight: 700; }
.tpos { color: var(--pos); font-weight: 700; }
.tln { color: var(--ln); }

/* ---------- top bar & navigation ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 40; }
#progress > div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
#topbar {
  position: fixed; top: 4px; left: 0; right: 0; height: 48px; z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(247, 245, 240, .95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
#topbar .brand { font-weight: 800; white-space: nowrap; }
#tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
#tabs button {
  border: 0; background: transparent; padding: 5px 10px; border-radius: 999px; font-size: .8em;
  color: var(--muted); white-space: nowrap;
}
#tabs button:hover { background: #ece7dc; color: var(--ink); }
#tabs button.on { background: var(--ink); color: #fff; }
#topbar .right { display: flex; gap: 12px; align-items: center; font-size: .85em; white-space: nowrap; }
#counter { color: var(--muted); font-family: var(--mono); }
#ov-toggle { font-size: .9em; padding: 3px 10px; display: none; }
body.ov-has #ov-toggle { display: inline-block; }
#ov-toggle.on { background: #e7f5ff; border-color: var(--q); }
#navbtns { position: fixed; right: 18px; bottom: 16px; display: flex; gap: 8px; z-index: 20; }
#navbtns button { font-size: 1.2em; width: 46px; height: 40px; padding: 0; box-shadow: 0 2px 6px rgba(0,0,0,.08); }

main { padding: 70px 28px 90px; transition: margin-right .2s; }
.slide { display: none; max-width: 1280px; margin: 0 auto; }
.slide.active { display: block; animation: fadein .25s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .78em; font-weight: 700; color: var(--accent); }
.lead { font-size: 1.05em; color: #3b4252; max-width: 62em; }

/* ---------- overview panel ("you are here") ---------- */
#overview {
  display: none; position: fixed; top: 52px; right: 0; bottom: 0; width: var(--ovw); z-index: 25;
  overflow-y: auto; padding: 10px 12px 80px; background: #fbfaf7; border-left: 1px solid var(--line);
  font-size: .7em; line-height: 1.25;
}
@media (min-width: 1200px) {
  body.ov-has:not(.ov-off) #overview { display: block; }
  body.ov-has:not(.ov-off) main { margin-right: var(--ovw); }
  body.ov-has:not(.ov-off) #navbtns { right: calc(var(--ovw) + 18px); }
  body.ov-has:not(.ov-off) .minimap { display: none; }
}
@media (max-width: 1199px) {
  body.ov-has.ov-drawer #overview { display: block; box-shadow: -10px 0 30px rgba(0,0,0,.18); }
}
.ov-title { font-weight: 800; font-size: 1.15em; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.ov-close { font-size: .9em; padding: 0 6px; border: 0; background: transparent; color: var(--muted); }
.ov-flow { display: flex; flex-direction: column; }
.ov-node {
  display: flex; justify-content: space-between; gap: 6px; align-items: baseline;
  padding: 3px 7px; border-radius: 6px; border-width: 1.5px; border-style: solid; cursor: pointer;
  transition: opacity .2s, box-shadow .2s;
}
.ov-node:hover { transform: translateX(-2px); }
.ov-node .ov-shape { font-family: var(--mono); font-size: .84em; color: var(--muted); white-space: nowrap; }
.ov-node.dim { opacity: .42; }
.ov-node.on { opacity: 1; font-weight: 700; box-shadow: 0 0 0 3px rgba(217,72,15,.45); }
.ov-node.on .ov-shape { color: var(--accent); font-weight: 700; }
.ov-arrow { text-align: center; color: #adb5bd; height: 11px; line-height: 11px; font-size: .9em; }
.ov-group { border: 1.5px dashed #adb5bd; border-radius: 9px; padding: 16px 6px 6px; position: relative; display: flex; flex-direction: column; }
.ov-glabel { position: absolute; top: 2px; left: 8px; font-weight: 700; color: var(--muted); font-size: .92em; }
.ov-subs { display: none; margin: 3px 0 2px 12px; border-left: 2px solid var(--q); padding-left: 6px; }
#overview.mha-open .ov-subs { display: block; }
.ov-sub { display: flex; justify-content: space-between; gap: 4px; padding: 2px 5px; border-radius: 4px; cursor: pointer; color: #495057; }
.ov-sub:hover { background: #e7f5ff; }
.ov-sub.on { background: var(--q); color: #fff; font-weight: 700; }
.ov-here { margin-top: 12px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); border: 1px solid #ffd8a8; font-size: 1.08em; }
.ov-here:empty { display: none; }
.ov-kick { font-size: .85em; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; }
.ov-hint { margin-top: 8px; color: var(--muted); }
.k-io { border-color: #868e96; background: #f1f3f5; }
.k-emb { border-color: var(--pos); background: #e3fafc; }
.k-pos { border-color: var(--pos); background: #e3fafc; }
.k-cls { border-color: var(--cls); background: #f8f0fc; }
.k-norm { border-color: #f59f00; background: #fff9db; }
.k-attn { border-color: var(--q); background: #e7f5ff; }
.k-res { border-color: #adb5bd; background: #fff; }
.ov-node.k-res, .ab.k-res { border-style: dashed; }
.k-mlp { border-color: var(--v); background: #ebfbee; }
.k-head { border-color: var(--accent); background: var(--accent-soft); }

/* one-line mini-map (narrow screens, or overview hidden) */
.minimap { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 4px 0 6px; font-size: .68em; }
.minimap .mm-label { margin-right: 2px; }
.mm-chip { padding: 1px 6px; border-radius: 5px; border-width: 1.5px; border-style: solid; font-size: 1em; opacity: .5; }
.mm-chip.on { opacity: 1; font-weight: 700; box-shadow: 0 0 0 2px rgba(217,72,15,.45); }
.mm-sep { color: #adb5bd; }
.mm-group { display: inline-flex; align-items: center; gap: 3px; border: 1.5px dashed #adb5bd; border-radius: 7px; padding: 1px 4px; }
.mm-x { color: var(--muted); font-weight: 700; margin-left: 2px; }

/* ---------- layout helpers ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; margin: 12px 0; }
.cols > * { min-width: 0; }
.cols.c64 { grid-template-columns: 3fr 2fr; }
.cols.c46 { grid-template-columns: 2fr 3fr; }
.cols.c37 { grid-template-columns: 3fr 7fr; }
.cols.c55 { grid-template-columns: 11fr 9fr; }
.cols.c3 { grid-template-columns: 1fr 1fr 1fr; }
.cols.tight { gap: 12px; margin: 8px 0; }
.cols.tight .card { margin: 0; }
@media (max-width: 980px) { .cols, .cols.c64, .cols.c46, .cols.c37, .cols.c55, .cols.c3 { grid-template-columns: 1fr; } }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
.card > h3:first-child { margin-top: 0; }
.note { border-left: 4px solid var(--pos); background: #e9f7f9; padding: 8px 14px; border-radius: 6px; margin: 10px 0; }
.warn { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 8px 14px; border-radius: 6px; margin: 10px 0; }
.big { font-size: 1.5em; }
.cap { font-size: .85em; color: var(--muted); margin: 4px 0; }
table.plain { border-collapse: collapse; font-size: .92em; }
table.plain th, table.plain td { border-bottom: 1px solid var(--line); padding: 4px 10px; text-align: left; }
table.plain th { color: var(--muted); font-weight: 600; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; vertical-align: middle; }
.badge.toy { color: #8a5a00; background: #fff4d6; border-color: #f1c96b; }
.badge.exact { color: #1864ab; background: #e7f5ff; border-color: #a5d8ff; }
.badge.schema { color: #5f3dc4; background: #f3f0ff; border-color: #d0bfff; }
.legend-row { margin: 4px 0 0 4px; font-size: .92em; }

/* ---------- buttons & controls ---------- */
button {
  font: inherit; font-size: .88em; padding: 5px 12px; border-radius: 8px; border: 1px solid #cfc8b8;
  background: #fff; color: var(--ink); cursor: pointer;
}
button:hover { background: #f3efe6; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover { background: #374151; }
.seg { display: inline-flex; border: 1px solid #cfc8b8; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid #cfc8b8; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }
.small-seg button { font-size: .78em; padding: 4px 9px; }
select, input[type=text] { font: inherit; font-size: .9em; padding: 3px 6px; border-radius: 6px; border: 1px solid #cfc8b8; background: #fff; }
input[type=range] { vertical-align: middle; accent-color: var(--accent); }
label { white-space: nowrap; }

canvas { max-width: 100%; height: auto; display: block; }
canvas.strip { width: 100%; height: 22px; border: 1px solid var(--line); }
canvas.pix { image-rendering: pixelated; }
canvas.clickable { cursor: crosshair; }
canvas.wide { width: 100%; }
canvas.anim { width: 100%; max-width: 760px; }
canvas.dark { border-radius: 12px; }
canvas.mini { width: 100%; max-width: 460px; margin: 6px 0; }
canvas.illu { display: block; width: 100%; max-width: 1100px; margin: 4px auto 8px; }

/* ---------- steppers ---------- */
.stepper { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 8px 0; }
.dots { display: inline-flex; gap: 4px; }
.dots button { width: 30px; height: 30px; padding: 0; border-radius: 50%; font-size: .78em; }
.dots button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.caps > div { display: none; font-size: 1.02em; background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 8px; padding: 9px 14px; }
.caps > div.on { display: block; animation: fadein .25s ease-out; }
ol.steps { margin: 6px 0; padding-left: 1.6em; font-size: .88em; }
ol.steps li { cursor: pointer; color: #adb5bd; padding: 1px 4px; border-radius: 4px; }
ol.steps li.done { color: #6b7280; }
ol.steps li.on { color: var(--ink); font-weight: 700; background: var(--accent-soft); }
.swatch { display: inline-block; width: 15px; height: 15px; vertical-align: -3px; border-radius: 3px; border: 1px solid #adb5bd; }

/* ---------- code & math ---------- */
pre.code {
  background: #1f2430; color: #e9e6df; padding: 12px 14px; border-radius: 10px; margin: 8px 0;
  font-family: var(--mono); font-size: .72em; line-height: 1.5; overflow-x: auto; white-space: pre;
}
pre.code .kw { color: #ff922b; }
pre.code .cm { color: #8b94a7; font-style: italic; }
pre.code .st { color: #8ce99a; }
pre.code .fn { color: #74c0fc; }
pre.code .nu { color: #ffd43b; }
.formula { text-align: center; font-family: var(--serif); font-size: 1.35em; margin: 10px 0; line-height: 1.9; }
.math { font-family: var(--serif); font-size: 1.1em; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .12em; line-height: 1.25; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .25em .05em; }
.frac > span:last-child { padding-top: .05em; }
.formula select { font-family: var(--serif); font-size: .8em; }

/* ---------- quiz (only "Put it together") ---------- */
.quiz { background: #fffbea; border: 1px solid #f1d98b; border-left: 6px solid #f2b705; border-radius: 10px; padding: 10px 16px 12px; margin: 12px 0; }
.quiz.solved { background: #effaf1; border-color: #b7e4c0; border-left-color: var(--ok); }
.quiz.revealed { background: #f4f4f2; border-color: #dcdcd6; border-left-color: #adb5bd; }
.q-head { font-weight: 800; display: flex; gap: 6px; align-items: center; font-size: .8em; text-transform: uppercase; letter-spacing: .06em; color: #8a6d00; }
.quiz.solved .q-head { color: var(--ok); }
.q-ok { display: none; }
.quiz.solved .q-ok { display: inline; }
.q-q { margin: 4px 0 6px; }
.q-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.q-ctrl button { font-size: .8em; padding: 3px 10px; }
.fb { font-size: .9em; }
.fb.ok { color: var(--ok); font-weight: 600; }
.fb.bad { color: var(--bad); }
.opts { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.opt { text-align: left; font-size: .9em; padding: 6px 12px; }
.opt.correct { background: #d3f9d8; border-color: var(--ok); font-weight: 600; }
.opt.wrong { background: #ffe3e3; border-color: var(--bad); text-decoration: line-through; color: #888; }
.explain, .hint { display: none; margin-top: 8px; padding: 8px 12px; background: #fff; border-radius: 8px; border: 1px dashed #cfc8b8; font-size: .92em; }
.show-explain > .explain, .show-hint > .hint { display: block; }
input.ans { font-family: var(--mono); font-size: .95em; padding: 2px 6px; width: 7.5em; border: 2px solid #cfc8b8; border-radius: 6px; }
input.ans.wide { width: 13em; }
input.ans.ok, select.ans.ok { border-color: var(--ok); background: #ebfbee; }
input.ans.bad, select.ans.bad { border-color: var(--bad); background: #fff5f5; }
select.ans { border-width: 2px; }
.shape-table td { padding: 4px 8px; vertical-align: middle; }
.shape-table td:first-child { font-family: var(--mono); font-size: .85em; }

/* ---------- title & intro ---------- */
.title-slide h1 { margin-top: .3em; }
.roadmap li { margin: .35em 0; }
.title-img-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
table.nlp { margin-top: 6px; }

/* ---------- architecture diagram ---------- */
.cfg { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .8em; margin-bottom: 10px; }
.cfg select { font-size: .95em; }
.arch { display: flex; flex-direction: column; align-items: stretch; max-width: 470px; }
.ab {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 3px 12px; border-radius: 8px; border-width: 2px; border-style: solid; cursor: pointer; font-size: .84em;
  transition: transform .1s;
}
.ab:hover { transform: translateX(3px); }
.ab.sel { box-shadow: 0 0 0 3px rgba(217, 72, 15, .4); font-weight: 700; }
.ab .shape { font-size: .85em; }
.aarrow { text-align: center; color: #adb5bd; line-height: 1; font-size: .55em; height: 9px; }
.agroup { border: 2px dashed #adb5bd; border-radius: 12px; padding: 20px 10px 8px; position: relative; display: flex; flex-direction: column; }
.agroup > .glabel { position: absolute; top: 2px; left: 12px; font-size: .75em; font-weight: 700; color: var(--muted); }
.warnbox { color: var(--bad); font-weight: 600; }

/* ---------- patch → vector ---------- */
.flow { display: flex; flex-direction: column; gap: 6px; }
.flow .lbl { font-size: .8em; color: var(--muted); margin-bottom: 2px; }
.flow .op { font-family: var(--serif); font-size: 1.2em; padding-left: 20px; }
.card.impl { border: 2px solid #ffd8a8; background: #fffaf5; }
table.equiv { font-size: .82em; margin-bottom: 6px; }

/* ---------- shuffle verdict ---------- */
.verdict { min-height: 2.6em; padding: 8px 14px; border-radius: 8px; background: #f1f3f5; font-size: .95em; }
.verdict.ok { background: #ebfbee; border-left: 5px solid var(--ok); }
.verdict.bad { background: #fff5f5; border-left: 5px solid var(--bad); }

/* ---------- token + position = input ---------- */
.pa-row { display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 8px; }
.pa-row canvas { width: 100%; }
.pa-lab { font-size: .82em; }
.pa-op { font-family: var(--serif); font-size: 1.5em; line-height: 1; padding-left: 80px; color: #868e96; }
.seqsum { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
.seqsum > div:not(.op) { flex: 1 1 200px; min-width: 180px; }
.seqsum .op { font-family: var(--serif); font-size: 1.8em; color: #868e96; }
.seqsum .lbl { font-size: .8em; font-weight: 600; }
.hm { position: relative; }
.hm canvas { width: 100%; height: 110px; border: 1px solid var(--line); }
.pa-mark, .pe-rowmark { position: absolute; left: 0; right: 0; border: 2px solid var(--accent); border-radius: 2px; pointer-events: none; min-height: 3px; }

/* ---------- learned or not ---------- */
.pe-groups { display: flex; font-size: .7em; font-family: var(--mono); color: #495057; }
.pe-groups span { border: 1px solid #ced4da; border-bottom: 0; text-align: center; padding: 1px 2px; background: #f8f9fa; overflow: hidden; white-space: nowrap; }
.pe-matwrap { position: relative; }
.pe-matwrap canvas { width: 100%; height: 150px; border: 1px solid var(--line); }
.pe-colmark { position: absolute; top: -3px; bottom: -3px; border: 2px solid #f59f00; pointer-events: none; min-width: 3px; }
.pe-dimrow { display: flex; gap: 14px; align-items: center; margin: 8px 0; }
.pe-dimrow canvas { width: 140px; flex: none; border-radius: 4px; }

/* ---------- attention heads on the image ---------- */
.heads4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 980px) { .heads4 { grid-template-columns: repeat(2, 1fr); } }
.heads4 canvas { width: 100%; border-radius: 6px; }
.heads4 .hcap { font-size: .82em; font-weight: 700; margin-bottom: 4px; }
.heads4 .hrule { font-size: .74em; font-family: var(--serif); color: #495057; margin-top: 2px; }
.heads4 .hsub { font-size: .72em; color: var(--muted); }

/* ---------- head split ---------- */
.splitw .srow { display: flex; align-items: center; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
.splitw .slabel { width: 210px; font-size: .8em; color: var(--muted); text-align: right; flex: none; }
.cells { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.cell {
  width: 24px; height: 24px; border-radius: 3px; font-size: 10px; color: rgba(255,255,255,.95);
  display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono);
}
.cell.grey { background: #adb5bd; }
.qkvgroup { display: inline-flex; gap: 2px; padding: 3px; border-radius: 5px; border: 2px solid; margin-right: 6px; }
.qkvgroup.gq { border-color: var(--q); } .qkvgroup.gk { border-color: var(--k); } .qkvgroup.gv { border-color: var(--v); }
.headgrid { display: grid; gap: 6px 12px; align-items: center; }
.headgrid .hh { font-size: .75em; font-weight: 700; text-align: center; }

/* ---------- scores, softmax ---------- */
.detail { font-family: var(--mono); font-size: .8em; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 6px 0; }
table.smt { border-collapse: separate; border-spacing: 4px 3px; width: 100%; font-size: .85em; }
table.smt th { font-weight: 400; text-align: left; vertical-align: middle; }
table.smt tr:first-child th { text-align: center; font-weight: 700; font-size: .9em; }
table.smt tr:first-child canvas { width: 26px; margin: 0 auto 2px; image-rendering: pixelated; }
table.smt td { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-family: var(--mono); width: 13%; }
table.smt td span { position: relative; }
table.smt td .smbar { height: 7px; border-radius: 3px; margin-bottom: 2px; }
table.smt td.sum { background: #f1f3f5; font-weight: 700; text-align: center; width: 8%; }
table.smt tr.hidden td, table.smt tr.hidden th { opacity: .08; }
table.smt th > b { white-space: nowrap; }
.story { font-size: .95em; background: var(--accent-soft); padding: 6px 12px; border-radius: 8px; }
table.amat { border-collapse: collapse; font-family: var(--mono); font-size: .78em; }
table.amat td, table.amat th { width: 56px; height: 30px; text-align: center; border: 1px solid #fff; }
table.amat th { color: var(--muted); font-weight: 600; }
table.amat td.sum { background: #f1f3f5 !important; color: var(--ink) !important; font-weight: 700; }

/* ---------- merge ---------- */
.mergew { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.mergew .blk { height: 28px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: .75em; font-family: var(--mono); }
.mergew .arrowtxt { font-size: .8em; color: var(--muted); font-family: var(--mono); padding-left: 8px; }

/* ---------- block diagram (LayerNorm slide) ---------- */
svg.blockdiag { width: 100%; max-width: 1000px; display: block; margin: 4px auto; }
.blockdiag .grp { fill: none; stroke: #adb5bd; stroke-width: 1.5; stroke-dasharray: 6 4; }
.blockdiag .glab { font: 700 12px var(--sans); fill: var(--muted); }
.blockdiag .b { fill: #f8f9fa; stroke: #ced4da; stroke-width: 1.5; }
.blockdiag .b.ln { fill: #fff9db; stroke: #f59f00; stroke-width: 3; }
.blockdiag .t { font: 700 15px var(--sans); text-anchor: middle; fill: var(--ink); }
.blockdiag .t.m { fill: #868e96; font-weight: 600; }
.blockdiag .io { font: italic 700 18px var(--serif); fill: var(--ink); }
.blockdiag .ar { stroke: #868e96; stroke-width: 1.6; marker-end: url(#bd-ah); }
.blockdiag .plus { fill: #fff; stroke: #868e96; stroke-width: 1.6; }
.blockdiag .skip { fill: none; stroke: #adb5bd; stroke-width: 1.6; stroke-dasharray: 5 4; marker-end: url(#bd-ah); }
.blockdiag .note { font: 12px var(--sans); fill: var(--muted); text-anchor: middle; }

/* ---------- layer norm ---------- */
table.lnbn { border-collapse: separate; border-spacing: 3px; font-family: var(--mono); font-size: .8em; }
table.lnbn td { width: 46px; height: 30px; text-align: center; border-radius: 4px; background: #f1f3f5; transition: background .2s; }
table.lnbn th { font-size: .8em; color: var(--muted); font-weight: 600; padding: 0 6px; }

/* ---------- cheat sheet ---------- */
.cheat td { vertical-align: top; }
.cheat code { font-size: .8em; }

@media (max-width: 1199px) {
  main { padding: 66px 18px 90px; }
  #topbar .brand { font-size: 0; }
  #topbar .brand::first-letter { font-size: 1.1rem; }
  #tabs button { padding: 5px 7px; }
}
@media print {
  #topbar, #navbtns, #progress, #overview { display: none !important; }
  .slide { display: block !important; page-break-after: always; }
  main { padding: 0; margin: 0 !important; }
}

details.peek { margin-top: 22px; padding-top: 12px; border-top: 2px dashed var(--line); }
details.peek > summary { cursor: pointer; font-size: 1.45em; font-weight: 800; color: var(--ink, #1f2430); padding: 4px 0; list-style: none; }
details.peek > summary::-webkit-details-marker { display: none; }
details.peek > summary::before { content: '▸'; display: inline-block; width: 1.1em; color: var(--accent, #d9480f); transition: transform .2s; }
details.peek[open] > summary::before { transform: rotate(90deg); }
details.peek > summary:hover { color: var(--accent, #d9480f); }
.heads4.h3 { grid-template-columns: repeat(3, 1fr); max-width: 900px; }
/* KaTeX: display maths inside .formula, and formulas laid over canvas drawings */
.formula .tex.d .katex-display { margin: 0; display: inline-block; }
.formula .tex.d { display: inline-block; vertical-align: middle; }
.formula.kx { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 22px; }
.katex { font-size: 1.12em; }
.texwrap { position: relative; display: block; width: 100%; max-width: 1100px; margin: 4px auto 8px; container-type: inline-size; }
.texwrap > canvas.illu { margin: 0; max-width: none; }
.texwrap > .texl { position: absolute; inset: 0; pointer-events: none; }
.texwrap .tx { position: absolute; white-space: nowrap; line-height: 1; }
.texwrap .tx .katex { font-size: 1em; }
.realheads img { display: block; width: 100%; max-width: 1000px; margin: 6px auto; border-radius: 6px; border: 1px solid var(--line); }
.refs ul { margin: 4px 0 0; padding-left: 20px; }
.refs li { margin: 3px 0; }
.title-slide .author { font-size: 1.25em; font-weight: 700; color: var(--ink, #1f2430); margin: 4px 0 10px; }
a.btnlink { display: inline-block; background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; border-radius: 10px; padding: 6px 14px; }
a.btnlink:hover { filter: brightness(1.08); }
.together { max-width: 860px; }

/* ---- extras: the 60 s film and the Patch Quest game ---- */
#topbar .tb-x { font-size: .9em; padding: 3px 10px; text-decoration: none; color: inherit; border: 1px solid var(--line, #ddd); border-radius: 8px; background: #fff; }
#topbar a.tb-x:hover { background: #f3efe6; }
.title-slide .extras { gap: 10px; margin: 4px 0 14px; }
a.btnlink.alt { background: #2f9e44; }
.kicker .gamechip { float: right; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--muted, #868e96); }
.kicker .gamechip a { color: #2f9e44; }
dialog#film { padding: 0; border: 0; border-radius: 12px; width: min(92vw, 1100px); background: #111; color: #eee; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
dialog#film::backdrop { background: rgba(10, 12, 20, .75); }
#film .film-head { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; }
#film .film-head .muted { color: #aaa; }
#film .film-head .close { margin-left: auto; background: transparent; color: #eee; border-color: #555; }
#film video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 0 0 12px 12px; }
@media (max-width: 900px) { .kicker .gamechip { float: none; display: block; margin-top: 2px; } }
.cheat-row { display: grid; grid-template-columns: auto minmax(220px, 1fr); gap: 24px; align-items: start; }
.cheat-row .playagain { margin: 0; }
@media (max-width: 1100px) { .cheat-row { grid-template-columns: 1fr; } }
#mh-caps { margin: 6px 0 4px; }
#mh-caps { display: grid; }
#mh-caps > div { display: block; grid-area: 1 / 1; visibility: hidden; }
#mh-caps > div.on { visibility: visible; }

/* ---- title slide: live background (js/title-bg.js) ---- */
#title-bg { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; pointer-events: none; display: none; opacity: .4; }
.title-slide .card { background: rgba(255, 255, 255, .84); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.labnote { margin: 10px 0; font-size: .95em; background: #ebfbee; border: 1px solid #b2f2bb; border-radius: 8px; padding: 6px 10px; }
.labnote.off { background: #fff4e6; border-color: #ffc078; }
.labnote button { font-size: .95em; margin-left: 6px; }
.cfg select.offlab { border-color: #f08c00; background: #fff4e6; }

/* ---- #2: the key idea, made shiny ---- */
li.key-li { list-style: none; margin-left: -1.1em; }
.shiny { display: inline-block; position: relative; overflow: hidden; padding: 6px 12px; border-radius: 10px; font-weight: 700;
  background: linear-gradient(90deg, #fff4e6, #fff9db, #f3f0ff); border: 1.5px solid #ffc078;
  box-shadow: 0 0 0 3px rgba(255, 192, 120, .25), 0 4px 18px rgba(217, 72, 15, .18); animation: shinyglow 2.4s ease-in-out infinite; }
.shiny b { color: var(--accent); }
.shiny::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .85) 50%, transparent 70%);
  transform: translateX(-120%); animation: shinysweep 3.2s ease-in-out infinite; }
@keyframes shinysweep { 0%, 55% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@keyframes shinyglow { 0%, 100% { box-shadow: 0 0 0 3px rgba(255, 192, 120, .25), 0 4px 18px rgba(217, 72, 15, .18); }
  50% { box-shadow: 0 0 0 5px rgba(255, 192, 120, .4), 0 6px 26px rgba(217, 72, 15, .32); } }
@media (prefers-reduced-motion: reduce) { .shiny, .shiny::after { animation: none; } .shiny::after { display: none; } }
canvas.rf { display: block; width: 100%; max-width: 540px; margin: 10px 0 2px; }
.rfcard { margin-top: 14px; border: 1.5px solid #ffc078; box-shadow: 0 0 0 3px rgba(255, 192, 120, .2); }
.rfcard canvas.rf { margin: 4px auto 6px; }

/* ---- the magical "What is this sorcery?" summary ---- */
details.magic > summary { display: inline-flex; align-items: center; gap: 10px; position: relative; color: #fff; padding: 12px 22px 12px 16px;
  border-radius: 16px; background: linear-gradient(120deg, #5f3dc4, #9c36b5, #e64980, #f59f00, #9c36b5, #5f3dc4); background-size: 300% 100%;
  box-shadow: 0 0 0 3px rgba(156, 54, 181, .25), 0 6px 26px rgba(156, 54, 181, .45); text-shadow: 0 1px 2px rgba(0,0,0,.25);
  animation: magicflow 6s linear infinite, magicglow 2.2s ease-in-out infinite; user-select: none; }
details.magic > summary:hover { color: #fff; transform: translateY(-1px) scale(1.02); }
details.magic > summary::before { color: #fff3bf; }
details.magic > summary .wiz { display: inline-block; animation: wizwave 1.6s ease-in-out infinite; transform-origin: 70% 90%; }
details.magic > summary .spk { display: inline-block; animation: twinkle 1.2s ease-in-out infinite; }
details.magic > summary .tap { font-size: .5em; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; opacity: .85;
  border: 1px solid rgba(255,255,255,.6); border-radius: 999px; padding: 2px 8px; }
details.magic[open] > summary { animation: magicflow 12s linear infinite; box-shadow: 0 0 0 3px rgba(156, 54, 181, .2); }
details.magic[open] > summary .tap, details.magic[open] > summary .wiz { animation: none; }
details.magic[open] > summary .tap { display: none; }
details.magic > summary .star { position: absolute; pointer-events: none; font-size: 14px; animation: twinkle 1.8s ease-in-out infinite; }
.magic-burst { position: fixed; pointer-events: none; z-index: 60; font-size: 18px; transition: transform .9s cubic-bezier(.2,.7,.3,1), opacity .9s ease-in; }
@keyframes magicflow { to { background-position: 300% 0; } }
@keyframes magicglow { 0%, 100% { box-shadow: 0 0 0 3px rgba(156, 54, 181, .25), 0 6px 22px rgba(156, 54, 181, .4); }
  50% { box-shadow: 0 0 0 6px rgba(230, 73, 128, .3), 0 8px 34px rgba(245, 159, 0, .5); } }
@keyframes wizwave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(10deg); } }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.7) rotate(0); } 50% { opacity: 1; transform: scale(1.2) rotate(20deg); } }
@media (prefers-reduced-motion: reduce) {
  details.magic > summary, details.magic > summary .wiz, details.magic > summary .spk, details.magic > summary .star { animation: none; }
}
.shiny.clickable { cursor: pointer; transition: transform .15s; }
.shiny.clickable:hover { transform: translateY(-1px) scale(1.01); }
.shiny .clickme { display: inline-block; margin-left: 6px; font-size: .72em; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: #fff; background: var(--accent); border-radius: 999px; padding: 2px 9px; vertical-align: middle; animation: clickbounce 1.4s ease-in-out infinite; }
@keyframes clickbounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.rfcard:not([hidden]) { animation: fadein .35s ease-out; }
@media (prefers-reduced-motion: reduce) { .shiny .clickme { animation: none; } }
.shiny.clsgoal { display: block; margin: 6px 0 14px; font-size: 1.08em; line-height: 1.5;
  background: linear-gradient(90deg, #f3f0ff, #fff9db, #fff0f6); border-color: #b197fc;
  box-shadow: 0 0 0 3px rgba(177, 151, 252, .25), 0 4px 18px rgba(156, 54, 181, .18); }
.shiny.clsgoal b { color: var(--cls, #9c36b5); }
