/* KernelTSLM article on the ActivePair Labs site (variant E).
   The original chart-paper styles, re-cut for the lab system: near-black, mono labels, one accent. */
:root {
  --paper: var(--panel); --ink: var(--fg);
  --minor: var(--grid-minor); --major: var(--grid-major);
  --marker: var(--accent); --right: var(--ok); --wrong: var(--no);
}

/* Article frame */
.back-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.back { font-family: var(--mono); font-size: 12px; color: var(--muted); text-decoration: none; display: inline-flex; gap: 8px; padding-block: 10px; transition: color .2s var(--ease-out); }
.back i { font-style: normal; display: inline-block; transition: transform .3s var(--ease-out); }
.back:hover { color: var(--fg); }
.back:hover i { transform: translateX(-4px); color: var(--accent); }

.blk { padding-block: 28px 32px; }
/* Reading column: running text is capped at ~700px and starts on the container's left edge, in line with the figures. Everything else in a section (figures, tables,
   stat rows, demos) is a plain block child of the page container, so it spans exactly that
   container (max 1280px, side margins from .frame), centred, and can never exceed the viewport. */
.blk > :not(.read):not(.num):not(.sec-h):not(.lede):not(.dh) { max-width: 100%; }
.blk > .num, .blk > .sec-h, .blk > .lede, .blk > .dh { max-width: var(--read); }
.blk.tight { padding-block: 18px; }
.num { display: block; margin-bottom: 8px; }

/* Section nav: sticky, scrolls sideways inside itself on small screens */
.toc { position: sticky; top: 54px; z-index: 5; background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.toc ul { list-style: none; display: flex; justify-content: flex-start; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-inline: -10px; }
@media (max-width: 760px) { .toc ul { justify-content: flex-start; } }
.toc ul::-webkit-scrollbar { display: none; }
.toc a { display: block; white-space: nowrap; font-family: var(--mono); font-size: 11.5px; color: var(--muted); text-decoration: none; padding: 13px 10px; border-bottom: 1px solid transparent; transition: color .2s var(--ease-out), border-color .2s var(--ease-out); }
.toc a:hover { color: var(--fg); }
.toc a.on { color: var(--fg); border-bottom-color: var(--accent); }
.toc a.out::after { content: " ↗"; color: var(--accent); }
[id] { scroll-margin-top: 112px; }
@media (max-width: 640px) { .toc { top: 52px; } }

/* Grid paper */
.paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--major) 1px, transparent 1px), linear-gradient(90deg, var(--major) 1px, transparent 1px),
    linear-gradient(var(--minor) 1px, transparent 1px), linear-gradient(90deg, var(--minor) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 8px 8px, 8px 8px;
  background-position: -1px -1px;
}

/* Headings */
.sec-h { font-weight: 600; font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.1; letter-spacing: -0.025em; max-width: 32ch; text-wrap: balance; }
.lede { max-width: 66ch; color: var(--body); margin-top: 10px; }
.lede a { color: var(--fg); }

/* Intro */
.intro { padding-block: 32px 28px; }
.intro h1 { font-weight: 700; font-size: clamp(2.8rem, 7vw, 5.4rem); line-height: 0.95; letter-spacing: -0.045em; margin: 12px 0 16px; }
.intro .badge-win { margin-bottom: 20px; }
.intro p:not(.label) { color: var(--body); font-size: 1.1rem; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.links a { font-family: var(--mono); font-size: 12px; text-decoration: none; color: var(--fg); padding: 10px 12px; border: 1px solid var(--line-2); transition: border-color .2s var(--ease-out), background-color .2s var(--ease-out); }
.links a:hover { border-color: var(--accent); background: var(--accent-soft); }
.links a span { color: var(--accent); }
.cover { position: relative; height: clamp(150px, 18vw, 260px); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; display: block; filter: grayscale(1) contrast(1.15) brightness(.82); }
.cover figcaption { position: absolute; left: 12px; bottom: 10px; background: var(--glass); padding: 4px 8px; }

/* Live demo: the chart sheet */
.sheet { background: var(--paper); border: 1px solid var(--line-2); }
.shead { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px 40px; padding: 18px 22px 16px; border-bottom: 1px solid var(--line-2); }
.who { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.rtext { margin-top: 6px; font-size: 1.02rem; line-height: 1.55; min-height: 5.4em; max-width: 64ch; color: var(--fg); }
.rtext .try { display: block; margin-top: 6px; color: var(--body); }
.wait { color: var(--muted); }
.lim { display: flex; align-items: baseline; gap: 12px; margin-top: 8px; }
.lim span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.lim strong { font-weight: 600; font-size: 1.6rem; line-height: 1.1; letter-spacing: -0.02em; color: var(--accent); }
.meta { display: grid; gap: 6px; align-content: start; font-size: 0.95rem; }
.meta div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.meta div:last-child { border-bottom: 0; }
.meta dt { font-family: var(--mono); font-size: 11px; color: var(--muted); padding-top: 3px; }
.meta dd { min-height: 1.6em; color: var(--body); }
.meta dd b { font-weight: 600; color: var(--fg); }
.ok, .no { font-weight: 500; }
.ok { color: var(--right); } .no { color: var(--wrong); }

.leads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px 14px 4px; }
.lead { position: relative; height: 50px; border-left: 1px solid var(--line-2); }
.lead:nth-child(4n+1) { border-left-color: transparent; }
.lead canvas, .rhythm canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ln { position: absolute; left: 6px; top: 3px; z-index: 1; font-family: var(--mono); font-size: 10.5px; line-height: 1.4; padding: 0 4px; color: var(--body); background: linear-gradient(var(--marker), var(--marker)) no-repeat left / 0% 100%; transition: background-size .45s var(--ease-out), color .45s var(--ease-out); }
.lead.marked .ln { background-size: 100% 100%; color: var(--accent-ink); }
.rhythm { position: relative; height: 66px; margin: 4px 14px 0; border-top: 1px solid var(--line-2); }
.bands { display: flex; height: 22px; margin: 0 14px 12px; border: 1px solid var(--line-2); }
.bands div { height: 100%; display: flex; align-items: center; padding-left: 6px; font-family: var(--mono); font-size: 10.5px; white-space: nowrap; overflow: hidden; border-left: 1px solid var(--line-2); color: var(--fg); }
.bands div:first-child { border-left: 0; }
.bands .busy { background: var(--busy); }
.bands .idle { background: var(--paper); color: var(--muted); }
.bands .unlabeled { background: repeating-linear-gradient(45deg, var(--hatch-a) 0 4px, var(--hatch-b) 4px 6px); }
.sfoot { display: flex; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; padding: 10px 22px; border-top: 1px solid var(--line-2); font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.sfoot i { display: inline-block; width: 22px; height: 10px; background: var(--marker); vertical-align: -1px; margin-right: 6px; }

.sheets { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; margin-top: 12px; }
.sbtn { position: relative; background: none; border: 0; padding: 10px 12px 12px; cursor: pointer; text-align: left; color: var(--muted); font-size: 0.95rem; transition: color .2s var(--ease-out); }
.sbtn:hover { color: var(--fg); }
.sbtn[aria-current="true"] { color: var(--fg); font-weight: 600; }
.sbtn[aria-current="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px; background: linear-gradient(90deg, var(--accent) var(--p, 100%), var(--line-2) var(--p, 100%)); }
.play { margin-left: auto; background: transparent; border: 1px solid var(--line-2); padding: 8px 14px; cursor: pointer; font-family: var(--mono); font-size: 11.5px; transition: border-color .2s var(--ease-out); }
.play:hover { border-color: var(--accent); }
.play:active, .sbtn:active { transform: scale(.98); }

/* Fact sheet */
.facts { margin-top: 18px; border: 1px solid var(--line-2); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.facts div { padding: 12px 18px; border-top: 1px solid var(--line); display: grid; gap: 4px; align-content: start; }
.facts div:nth-child(-n+2) { border-top: 0; }
.facts div:nth-child(odd) { border-right: 1px solid var(--line); }
.facts div:last-child { grid-column: 1 / -1; border-right: 0; }
.facts dt { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.facts dd { color: var(--body); font-size: 0.96rem; line-height: 1.6; }
.facts i { color: var(--fg); }

.dh { font-weight: 600; font-size: 1.15rem; margin-top: 22px; letter-spacing: -0.01em; }
.tstats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 14px; border: 1px solid var(--line-2); }
.tstats div { padding: 9px 14px; border-left: 1px solid var(--line); }
.tstats div:first-child { border-left: 0; }
.tstats dt { font-size: 1.5rem; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.tstats dd { font-size: 0.86rem; color: var(--muted); margin-top: 2px; }

/* Use cases */
.ucs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-top: 18px; border: 1px solid var(--line-2); }
.uc { display: grid; grid-template-rows: auto auto 1fr auto; gap: 10px; padding: 14px 16px 14px; border-left: 1px solid var(--line); }
.uc:first-child { border-left: 0; }
.uc h3 { font-weight: 600; font-size: 1.15rem; line-height: 1.2; letter-spacing: -0.01em; }
.uc h3 .label { display: block; margin-bottom: 6px; }
.uc .use { font-size: 0.92rem; color: var(--body); line-height: 1.55; }
.uc .ex { background: var(--desk); border: 1px solid var(--line); border-left: 2px solid var(--accent); padding: 10px 12px; display: grid; gap: 6px; align-content: start; }
.uc .ex .q { font-family: var(--mono); font-size: 11px; line-height: 1.55; color: var(--fg); }
.uc .ex .a { font-size: 0.88rem; color: var(--body); line-height: 1.5; }
.uc .claim { font-size: 0.88rem; color: var(--body); line-height: 1.4; }
.uc .claim b { display: block; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; color: var(--fg); }

/* Training */
.arch { margin-top: 18px; background: var(--paper); border: 1px solid var(--line-2); padding: 10px 14px; }
.arch svg { display: block; width: 100%; height: auto; font-family: var(--sans); }
.arch .st { fill: none; stroke: var(--stroke); stroke-width: 1.3; }
.arch .ar { stroke: var(--stroke); stroke-width: 1.5; fill: none; }
.arch .tr { fill: var(--accent-soft); stroke: var(--accent); }
.arch .fz { fill: var(--frozen); stroke: var(--line-2); }
.arch .bx { fill: var(--desk); stroke: var(--line-2); }
.arch text { fill: var(--fg); }
.arch text.dim { fill: var(--muted); }
.arch marker path { fill: var(--stroke); }
.arch figcaption { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 20px; }
.arch figcaption i { display: inline-block; width: 20px; height: 10px; vertical-align: -1px; margin-right: 6px; border: 1px solid var(--line-2); }
.arch figcaption i.t { background: var(--accent-soft); border-color: var(--accent); }
.arch figcaption i.f { background: var(--frozen); }
/* line drawing on entry */
.arch .draw { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.1s var(--ease-out); transition-delay: var(--d, 0ms); }
.arch .fill-in { transition: fill-opacity .6s var(--ease-out), opacity .6s var(--ease-out); transition-delay: var(--d, 0ms); }
.arch:not(.in) .fill-in { fill-opacity: 0; }
.arch:not(.in) text { opacity: 0; }
.arch text { transition: opacity .5s var(--ease-out) .5s; }
.arch.in .draw { stroke-dashoffset: 0; }

.tcols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 32px; margin-top: 22px; }
.tcols article { border-top: 1px solid var(--fg); padding-top: 14px; display: grid; gap: 12px; align-content: start; }
.tcols h3 { font-weight: 600; font-size: 1.12rem; line-height: 1.25; letter-spacing: -0.01em; }
.tcols p, .tcols li { font-size: 0.94rem; color: var(--body); }
.tcols ul { padding-left: 1.1rem; display: grid; gap: 6px; margin: 0; }
.seen { background: var(--desk); border: 1px solid var(--line-2); font-family: var(--mono); font-size: 10.5px; line-height: 1.6; padding: 10px 12px; color: var(--body); }
.seen .txt { background: var(--accent-soft); color: var(--fg); padding: 0 2px; }
.seen canvas { display: block; width: 100%; height: 34px; margin: 4px 0 8px; }
.breaks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.breaks figure { background: var(--paper); border: 1px solid var(--line-2); padding: 6px 8px; }
.breaks figcaption { font-family: var(--mono); font-size: 10.5px; color: var(--fg); }
.breaks figcaption span { color: var(--muted); }
.breaks canvas { display: block; width: 100%; height: 40px; }
.big2 { display: flex; align-items: baseline; gap: 12px; }
.big2 b { font-size: 2.1rem; font-weight: 600; line-height: 1; letter-spacing: -0.02em; color: var(--accent); }
.big2 span { font-size: 0.88rem; color: var(--muted); }
.mt { width: 100%; border-collapse: collapse; border: 1px solid var(--line-2); font-size: 0.9rem; }
.mt th, .mt td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); font-weight: 400; color: var(--body); }
.mt thead th { font-family: var(--mono); font-size: 10.5px; color: var(--muted); border-top: 0; border-bottom: 1px solid var(--line-2); }
.mt td.n { font-variant-numeric: tabular-nums; }
.mt .us { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
.mt thead .us { color: var(--fg); }

/* Results */
.pair2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px 48px; }
.pair2 .sec-h { font-size: clamp(1.4rem, 2.4vw, 1.8rem); }
.pair2 .lede { font-size: 0.96rem; margin-bottom: 18px; }
.tblwrap { overflow-x: auto; }
.cap2 { font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
.ba { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line-2); font-size: 0.92rem; color: var(--body); }
.ba b { font-size: 1.5rem; font-weight: 600; color: var(--fg); line-height: 1; }
.ba b:last-of-type { color: var(--accent); }
.ba .arrow { color: var(--muted); font-size: 1.2rem; }

.cmp { width: 100%; border-collapse: collapse; border: 1px solid var(--line-2); }
.cmp th, .cmp td { text-align: left; vertical-align: top; padding: 11px 14px; border-top: 1px solid var(--line); color: var(--body); }
.cmp thead th { font-family: var(--mono); font-weight: 400; font-size: 10.5px; color: var(--muted); border-top: 0; border-bottom: 1px solid var(--line-2); line-height: 1.5; }
.cmp tbody th { font-weight: 600; font-size: 0.96rem; line-height: 1.3; color: var(--fg); }
.cmp span { display: block; font-weight: 400; font-size: 0.8rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.cmp td.n { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.cmp .us { background: var(--accent-soft); color: var(--fg); }
.cmp thead .us { color: var(--fg); }
.cmp tbody tr { transition: opacity .5s var(--ease-out), transform .5s var(--ease-out); }
.tblwrap:not(.in) .cmp tbody tr { opacity: 0; transform: translateY(6px); }
.cmp tbody tr:nth-child(2) { transition-delay: 80ms; } .cmp tbody tr:nth-child(3) { transition-delay: 160ms; } .cmp tbody tr:nth-child(4) { transition-delay: 240ms; }

/* Dot plot (from results.js) */
.plot { display: grid; gap: 6px; align-content: start; }
.prow { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 14px; align-items: center; font-size: 0.92rem; color: var(--body); }
.prow.ours { color: var(--fg); font-weight: 600; }
.track { position: relative; height: 26px; }
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line-2); }
.dot { position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.ours .dot { background: var(--fg); border-color: var(--fg); width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px; }
.ours .dot.open { background: var(--bg); }
.ours .dot.hl { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.val { position: absolute; top: 50%; transform: translate(10px, -50%); font-family: var(--mono); font-size: 10.5px; font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.val.left { transform: translate(calc(-100% - 10px), -50%); }
.bar { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: var(--fg); transform-origin: left; }
.pair .track { height: 44px; }
.pair .track::before, .pair .bar, .pair .dot { top: 34%; }
.val.under { top: 60%; transform: translateX(-50%); font-size: 10px; }
.gridbg { position: absolute; inset: 0; pointer-events: none; }
.gridbg i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.axis { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 14px; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.axis .ticks { position: relative; height: 18px; }
.axis .ticks span { position: absolute; transform: translateX(-50%); }
/* draw on entry: bars grow from the left, dots and values follow */
.check .bar { transition: transform .9s var(--ease-out) .15s; }
.check .dot, .check .val { transition: opacity .5s var(--ease-out) .55s; }
.check:not(.in) .bar { transform: scaleX(0); }
.check:not(.in) .dot, .check:not(.in) .val { opacity: 0; }

/* Findings */
.finds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 36px; margin-top: 18px; }
.finds article { border-top: 1px solid var(--fg); padding-top: 14px; display: grid; gap: 10px; align-content: start; }
.finds h3 { font-weight: 600; font-size: 1.15rem; line-height: 1.25; letter-spacing: -0.01em; }
.finds p { font-size: 0.95rem; color: var(--body); }
.finds .src { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.fbar { display: grid; gap: 8px; margin-top: 4px; font-size: 0.84rem; color: var(--body); }
.fbar div { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) 3.6rem; gap: 10px; align-items: center; }
.fbar .t { height: 12px; background: var(--desk); border: 1px solid var(--line-2); position: relative; overflow: hidden; }
.fbar .t i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--fg); transform-origin: left; transition: transform 1s var(--ease-out) .1s; }
.fbar .t i.hl { background: var(--accent); }
.fbar:not(.in) .t i { transform: scaleX(0); }
.fbar b { font-family: var(--mono); font-weight: 400; font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; color: var(--fg); }

/* Limits, next, reproduce */
.closing { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 36px; margin-top: 18px; }
.closing h3 { font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--accent); margin-bottom: 10px; }
.closing ul { padding-left: 1.1rem; display: grid; gap: 8px; font-size: 0.95rem; color: var(--body); }
.closing li::marker { color: var(--muted); }
pre { margin: 0; background: var(--desk); border: 1px solid var(--line-2); padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 11.5px; line-height: 1.7; color: var(--fg); }
.closing .note { font-size: 0.85rem; color: var(--muted); margin-top: 10px; }
.credits { font-size: 0.88rem; color: var(--muted); max-width: 90ch; }

@media (max-width: 900px) {
  .intro, .shead, .finds, .closing, .tcols, .pair2 { grid-template-columns: minmax(0, 1fr); }
  .leads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead:nth-child(4n+1) { border-left-color: var(--line-2); }
  .lead:nth-child(2n+1) { border-left-color: transparent; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .facts div:nth-child(odd) { border-right: 0; }
  .facts div:nth-child(2) { border-top: 1px solid var(--line); }
  .ucs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .uc:nth-child(3) { border-left: 0; }
  .uc:nth-child(n+3) { border-top: 1px solid var(--line); }
  .tstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tstats div:nth-child(odd) { border-left: 0; }
  .tstats div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .cmp th, .cmp td { padding: 8px 8px; } .cmp td span { display: none; }
  .ucs { grid-template-columns: minmax(0, 1fr); }
  .uc { border-left: 0; } .uc:nth-child(n+2) { border-top: 1px solid var(--line); }
  /* stack label over track so the paired values have the full width */
  .prow, .axis { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .axis > span:first-child { display: none; }
  .prow { font-size: 0.86rem; margin-bottom: 6px; }
  .val { font-family: var(--sans); font-size: 11px; }
  .fbar div { grid-template-columns: 6.8rem minmax(0, 1fr) 3.4rem; }
}
@media (max-width: 520px) {
  .shead { padding: 14px 16px; } .sfoot { padding: 9px 16px; }
  .rtext { min-height: 9.6em; } .meta dd { min-height: 3.2em; }
  .meta div { grid-template-columns: 5.5rem minmax(0, 1fr); }
  .play { margin-left: 0; margin-top: 6px; }
  .leads { padding-inline: 8px; } .rhythm, .bands { margin-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .arch .draw { stroke-dashoffset: 0; }
  .arch:not(.in) .fill-in, .arch:not(.in) text { fill-opacity: 1; opacity: 1; }
}
