/* ---------- Article layout ---------- */
.article { max-width: 720px; margin: 0 auto; padding: 48px 20px 0; }
.back { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); }
.back:hover { color: var(--accent); text-decoration: none; }
.article-head { margin: 22px 0 34px; }
.article-head h1 {
  font-size: clamp(1.9rem, 4.6vw, 2.6rem); line-height: 1.15; letter-spacing: -.025em;
  font-weight: 700; margin: 10px 0 14px;
}
.article-meta { font-family: var(--mono); font-size: 12px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.lede { font-size: 1.15rem; color: var(--text-2); margin: 0 0 16px; line-height: 1.6; }

.prose { font-size: 16.5px; line-height: 1.75; }
.prose p { margin: 0 0 1.15em; }
.prose h2 {
  font-size: 1.35rem; letter-spacing: -.015em; line-height: 1.3; font-weight: 650;
  margin: 2.2em 0 .7em; scroll-margin-top: 72px;
}
.prose h3 { font-size: 1.08rem; font-weight: 600; margin: 1.7em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.15em; }
.prose li { margin: .3em 0; }
.prose code {
  font-family: var(--mono); font-size: .86em; padding: .1em .35em; border-radius: 5px;
  background: var(--accent-soft); color: var(--text);
}
.prose blockquote {
  margin: 1.4em 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--warm);
  color: var(--text-2); font-style: italic;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose .katex-display { margin: 1.1em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* Variate-type inline markers */
.vt { font-weight: 600; white-space: nowrap; }
.vt::before { content: ""; display: inline-block; width: .62em; height: .62em; border-radius: 2px; margin-right: .32em; vertical-align: .04em; }
.vt-x { color: var(--c-target); } .vt-x::before { background: var(--c-target); }
.vt-y { color: var(--c-past); }   .vt-y::before { background: var(--c-past); }
.vt-z { color: var(--c-future); } .vt-z::before { background: var(--c-future); }

/* Figures */
.fig { margin: 2em 0; }
.fig-wide { margin-left: -40px; margin-right: -40px; }
@media (max-width: 800px) { .fig-wide { margin-left: 0; margin-right: 0; } }
.fig-frame {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 18px;
}
.fig-frame.paper { background: #fff; }
.fig figcaption { font-size: 13.5px; color: var(--text-3); margin-top: 10px; line-height: 1.55; }
.fig figcaption b { color: var(--text-2); font-weight: 600; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 1.4em 0; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { font-family: var(--mono); font-size: 11.5px; font-weight: 500; color: var(--text-3); letter-spacing: .02em; }
table.data tbody tr.base td { font-weight: 600; }
table.data .worse { color: var(--c-block); }
table.data .num { font-variant-numeric: tabular-nums; }

/* Mask matrix */
table.mask { border-collapse: separate; border-spacing: 4px; margin: 1.2em auto; font-family: var(--mono); font-size: 12.5px; }
table.mask th { font-weight: 500; color: var(--text-3); padding: 2px 8px; }
table.mask td {
  width: 64px; height: 38px; text-align: center; border-radius: 7px; font-weight: 600;
  background: color-mix(in srgb, var(--c-future) 14%, transparent); color: var(--c-future);
}
table.mask td.no { background: color-mix(in srgb, var(--c-block) 14%, transparent); color: var(--c-block); }
table.mask caption { caption-side: bottom; font-family: var(--font); font-size: 12.5px; color: var(--text-3); padding-top: 6px; }

/* Controls used by the interactive figures */
.fig-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.chip-btn {
  font-family: var(--mono); font-size: 12px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--text-2);
  transition: color .15s, border-color .15s, background .15s;
}
.chip-btn:hover { color: var(--text); border-color: var(--text-3); }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.chip-btn .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.chip-btn.x .sw { background: var(--c-target); }
.chip-btn.y .sw { background: var(--c-past); }
.chip-btn.z .sw { background: var(--c-future); }
.chip-btn.leak { border-style: dashed; }
.chip-btn.leak[aria-pressed="true"] { background: var(--c-block); border-color: var(--c-block); }
.fig-spacer { flex: 1; }

.fig-explain {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px; min-height: 76px;
  background: var(--bg); border: 1px solid var(--line); font-size: 14px; color: var(--text-2); line-height: 1.6;
}
.fig-explain strong { color: var(--text); }

/* ---------- Architecture diagram ---------- */
svg.arch { display: block; width: 100%; min-width: 560px; height: auto; font-family: var(--font); }
.arch text { fill: var(--text-2); font-size: 13px; }
.arch .t-title { font-family: var(--mono); font-size: 11.5px; fill: var(--text-3); letter-spacing: .04em; }
.arch .t-lab { font-size: 13.5px; font-weight: 600; }
.arch .t-sub { font-size: 11.5px; fill: var(--text-3); }
.arch .t-small { font-family: var(--mono); font-size: 10.5px; fill: var(--text-3); }
.arch .panel { fill: var(--bg); stroke: var(--line); }
.arch .divider { stroke: var(--text-3); stroke-dasharray: 3 4; opacity: .6; }
.arch .tok { stroke-width: 1.6; }
.arch .tok.pad { fill: none; stroke-dasharray: 3 3; }
.arch .x .tok { stroke: var(--c-target); }  .arch .x .tok:not(.pad) { fill: color-mix(in srgb, var(--c-target) 16%, var(--bg-elev)); }
.arch .y .tok { stroke: var(--c-past); }    .arch .y .tok:not(.pad) { fill: color-mix(in srgb, var(--c-past) 16%, var(--bg-elev)); }
.arch .z .tok { stroke: var(--c-future); }  .arch .z .tok:not(.pad) { fill: color-mix(in srgb, var(--c-future) 16%, var(--bg-elev)); }
.arch .x .t-lab { fill: var(--c-target); } .arch .y .t-lab { fill: var(--c-past); } .arch .z .t-lab { fill: var(--c-future); }
.arch .edge { fill: none; stroke: var(--text-3); stroke-width: 1.6; opacity: .55; }
.arch .x .edge, .arch .edge.x { stroke: var(--c-target); }
.arch .y .edge, .arch .edge.y { stroke: var(--c-past); }
.arch .z .edge, .arch .edge.z { stroke: var(--c-future); }
.arch .edge.blocked { stroke: var(--c-block); stroke-dasharray: 4 4; opacity: .35; }
.arch .blocked-x { stroke: var(--c-block); stroke-width: 2; stroke-linecap: round; opacity: .5; }
.arch .node { stroke-width: 2; fill: var(--bg-elev); }
.arch .node.x { stroke: var(--c-target); } .arch .node.y { stroke: var(--c-past); } .arch .node.z { stroke: var(--c-future); }
.arch .box { fill: var(--bg-elev); stroke: var(--text-3); stroke-width: 1.4; }
.arch .fan { fill: var(--c-target); opacity: .18; }
.arch .fan-med { fill: none; stroke: var(--c-target); stroke-width: 2; stroke-dasharray: 4 3; }
.arch .fan-hist { fill: none; stroke: var(--c-target); stroke-width: 2; }
.arch .hit { fill: transparent; cursor: pointer; }
.arch .leak { fill: none; stroke: var(--c-block); stroke-width: 2.6; stroke-dasharray: 6 5; opacity: 0; transition: opacity .25s; }
.arch .leak-dot { fill: var(--c-block); opacity: 0; transition: opacity .25s; }
.arch .leak-label { fill: var(--c-block); font-family: var(--mono); font-size: 11px; opacity: 0; transition: opacity .25s; }

/* Focus mode: dim everything that's not on the active path */
.arch [data-k] { transition: opacity .2s ease, stroke-width .2s ease; }
.arch.focus [data-k] { opacity: .13; }
.arch.focus [data-k].on { opacity: 1; }
.arch.focus .edge.on { stroke-width: 2.6; }
.arch.focus .edge.blocked.on { opacity: .9; }
.arch.focus .blocked-x.on { opacity: 1; }
.arch.show-leak .leak, .arch.show-leak .leak-dot, .arch.show-leak .leak-label { opacity: 1; }
.arch.show-leak .leak { animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -22; } }
@media (prefers-reduced-motion: reduce) { .arch.show-leak .leak { animation: none; } }
.arch.focus .flow.on, .arch.focus .on .flow { animation: dash 1.1s linear infinite; stroke-dasharray: 6 5; }
@media (prefers-reduced-motion: reduce) { .arch.focus .flow.on, .arch.focus .on .flow { animation: none; stroke-dasharray: none; } }

/* ---------- Coupling demo ---------- */
.coupling svg { display: block; width: 100%; height: auto; }
.coupling .lane-bg { fill: var(--bg); stroke: var(--line); }
.coupling .src { fill: none; stroke: var(--text-3); stroke-width: 1.6; stroke-linejoin: round; }
.coupling .out { fill: none; stroke-width: 2; stroke-linejoin: round; transition: d .25s ease; }
.coupling .out.o0 { stroke: var(--c-target); } .coupling .out.o1 { stroke: var(--c-past); } .coupling .out.o2 { stroke: var(--c-future); }
.coupling text { font-family: var(--mono); font-size: 11px; fill: var(--text-3); }
.coupling .arrow { stroke: var(--text-3); stroke-width: 1.5; fill: none; }
.coupling .mech-name { font-family: var(--mono); font-size: 12px; fill: var(--text); font-weight: 500; }
.coupling .mech-box { fill: var(--warm-soft); stroke: var(--warm); stroke-width: 1.2; }

/* Article footer */
.article-end {
  margin: 3em 0 0; padding: 18px 20px; border-radius: 14px;
  background: var(--bg-elev); border: 1px solid var(--line); font-size: 14.5px; color: var(--text-2);
}
.article-end p { margin: 0 0 .5em; }
.article-end p:last-child { margin: 0; }
.next-post { display: block; margin-top: 2em; font-size: 14px; }
.next-post span { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.coupling .src-lane .src, .coupling .src-arrow { transition: opacity .25s; }
.coupling .src-lane.is-unused .src, .coupling .src-arrow.is-unused { opacity: .22; }
.coupling .unused { font-size: 10px; fill: var(--text-3); opacity: 0; transition: opacity .25s; }
.coupling .src-lane.is-unused .unused { opacity: 1; }

/* ---------- Coupling pipeline figure ---------- */
.pipe svg { display: block; width: 100%; min-width: 620px; height: auto; font-family: var(--font); }
.pipe .pp-title { font-size: 14px; font-weight: 650; fill: var(--text); }
.pipe .pp-t, .pipe .pp-small { font-size: 11.5px; fill: var(--text-2); font-style: italic; }
.pipe .pp-math { font-size: 13px; fill: var(--text-2); font-style: italic; }
.pipe .pp-muted { font-size: 16px; fill: var(--text-3); }
.pipe .pp-box { fill: color-mix(in srgb, var(--accent) 7%, var(--bg-elev)); stroke: color-mix(in srgb, var(--accent) 35%, var(--line)); stroke-width: 1.2; }
.pipe .pp-sample { fill: color-mix(in srgb, var(--accent) 7%, var(--bg-elev)); stroke: color-mix(in srgb, var(--accent) 35%, var(--line)); stroke-width: 1.2; }
.pipe .pp-panel { fill: var(--bg); stroke: color-mix(in srgb, var(--text-3) 45%, var(--line)); stroke-width: 1.2; }
.pipe .pp-line { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.pipe .pp-aug { fill: none; stroke: var(--c-target); stroke-width: 1.8; stroke-linejoin: round; }
.pipe .pp-aug-dash { fill: none; stroke: var(--c-target); stroke-width: 1.4; stroke-dasharray: 3 3; }
.pipe .pp-future { fill: none; stroke: var(--c-target); stroke-width: 1.4; stroke-dasharray: 2 3; }
.pipe .pp-mask { fill: none; stroke: var(--c-target); stroke-width: 1.3; stroke-dasharray: 3 3; }
.pipe .pp-fill { fill: var(--text); }
.pipe .pp-dot { fill: var(--text); }
.pipe .pp-arrow { fill: none; stroke: var(--text-2); stroke-width: 1.4; }
.pipe .pp-pill { fill: var(--bg-elev); stroke: var(--line); stroke-width: 1.2; }
.pipe .pp-pill-sel { fill: color-mix(in srgb, var(--accent) 10%, var(--bg-elev)); stroke: var(--accent); stroke-width: 1.6; }
.pipe .pp-pill-t { font-size: 11px; fill: var(--text-3); font-family: var(--mono); letter-spacing: .02em; }
.pipe .pp-pill-t-sel { font-size: 11px; fill: var(--accent); font-family: var(--mono); font-weight: 500; letter-spacing: .02em; }

/* ---------- Architecture figure (redrawn) ---------- */
.archfig svg { display: block; width: 100%; min-width: 680px; height: auto; font-family: var(--font); }
.archfig .af-panel-t { fill: color-mix(in srgb, var(--accent) 6%, var(--bg-elev)); stroke: color-mix(in srgb, var(--accent) 30%, var(--line)); stroke-width: 1.2; }
.archfig .af-panel-v { fill: var(--bg); stroke: color-mix(in srgb, var(--text-3) 45%, var(--line)); stroke-width: 1.2; }
.archfig .af-wedge-t { fill: color-mix(in srgb, var(--accent) 6%, transparent); }
.archfig .af-wedge-v { fill: color-mix(in srgb, var(--text-3) 8%, transparent); }
.archfig .af-block { fill: none; stroke: color-mix(in srgb, var(--text-3) 60%, var(--line)); stroke-width: 1.3; }
.archfig .af-tm { fill: color-mix(in srgb, var(--accent) 12%, var(--bg-elev)); stroke: color-mix(in srgb, var(--accent) 45%, var(--line)); stroke-width: 1.3; }
.archfig .af-vm { fill: var(--bg); stroke: color-mix(in srgb, var(--text-3) 60%, var(--line)); stroke-width: 1.3; }
.archfig .af-box { fill: var(--bg-elev); stroke: color-mix(in srgb, var(--text) 55%, var(--line)); stroke-width: 1.3; }
.archfig .af-pill { fill: var(--bg-elev); stroke: color-mix(in srgb, var(--text) 55%, var(--line)); stroke-width: 1.3; rx: 13; }
.archfig .af-head { font-size: 14px; font-weight: 650; fill: var(--text); }
.archfig .af-bt { font-size: 12.5px; fill: var(--text); }
.archfig .af-bt-b { font-weight: 650; }
.archfig .af-small { font-size: 10.5px; fill: var(--text-3); font-style: italic; }
.archfig .af-leg { font-style: normal; fill: var(--text-2); }
.archfig .af-math { font-size: 14px; fill: var(--text); }
.archfig .af-math-s { font-size: 12px; fill: var(--text-2); }
.archfig .af-m { font-family: KaTeX_Math, "Times New Roman", serif; font-style: italic; }
.archfig .af-mb { font-family: KaTeX_Main, "Times New Roman", serif; font-weight: bold; }
.archfig .af-xt { fill: var(--c-target); } .archfig .af-yt { fill: var(--c-past); } .archfig .af-zt { fill: var(--c-future); }
.archfig .af-ln { fill: none; stroke: var(--text-2); stroke-width: 1.4; stroke-linejoin: round; }
.archfig .af-skip { stroke: var(--text-3); }
.archfig .af-dot { fill: var(--text-2); }
.archfig .af-op { fill: var(--bg-elev); stroke: var(--text-2); stroke-width: 1.4; }
.archfig .af-p { stroke-width: 1.3; }
.archfig .af-p-x { fill: color-mix(in srgb, var(--c-target) 16%, var(--bg-elev)); stroke: var(--c-target); }
.archfig .af-p-y { fill: color-mix(in srgb, var(--c-past) 16%, var(--bg-elev)); stroke: var(--c-past); }
.archfig .af-p-z { fill: color-mix(in srgb, var(--c-future) 16%, var(--bg-elev)); stroke: var(--c-future); }
.archfig .af-p-fc { fill: none; stroke: var(--c-block); stroke-dasharray: 3 2.5; }
.archfig .af-p-out { fill: color-mix(in srgb, var(--c-target) 10%, var(--bg-elev)); stroke: var(--c-block); stroke-dasharray: 3 2.5; }
.archfig .af-wave { fill: none; stroke: var(--c-target); stroke-width: 1.3; stroke-linecap: round; }
.archfig .af-divider { stroke: var(--text-3); stroke-dasharray: 2 3; opacity: .7; }
.archfig .af-mask-on { fill: color-mix(in srgb, var(--c-future) 28%, var(--bg-elev)); stroke: var(--line); stroke-width: .6; }
.archfig .af-mask-off { fill: var(--bg-elev); stroke: var(--line); stroke-width: .6; }
.archfig .af-mask-block { fill: color-mix(in srgb, var(--c-block) 38%, var(--bg-elev)); stroke: var(--line); stroke-width: .6; }
.archfig .af-mask-frame { fill: none; stroke: color-mix(in srgb, var(--text) 50%, var(--line)); stroke-width: 1.1; }
/* Figure 2: the active variate's path through the time mixer glows (cycles x -> y -> z) */
.archfig .af-hover { cursor: pointer; }
.archfig .af-hit { fill: transparent; }
.archfig svg.k-x { --k: var(--c-target); }
.archfig svg.k-y { --k: var(--c-past); }
.archfig svg.k-z { --k: var(--c-future); }
.archfig svg .af-ln, .archfig svg .af-box, .archfig svg .af-pill, .archfig svg .af-op, .archfig svg .af-p {
  transition: stroke .15s ease, stroke-width .15s ease;
}
.archfig svg .on .af-ln { stroke: var(--k); stroke-width: 2.3; }
.archfig svg .on .af-box, .archfig svg .on .af-op, .archfig svg .on .af-glowable, .archfig svg .on .af-pill {
  stroke: var(--k); stroke-width: 2;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--k) 65%, transparent));
}
.archfig svg .on .af-dot { fill: var(--k); }
.archfig svg .on .af-p { stroke-width: 2; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--k) 60%, transparent)); }
@media (prefers-reduced-motion: reduce) {
  .archfig svg .af-ln, .archfig svg .af-box, .archfig svg .af-op, .archfig svg .af-p { transition: none; }
}
/* Variate mixer mask: the active variate's query row lights up */
.archfig svg .af-mask-on, .archfig svg .af-mask-block { transition: fill .15s ease; }
.archfig svg .af-mask-on.on { fill: color-mix(in srgb, var(--k) 70%, var(--bg-elev)); stroke: var(--k); stroke-width: 1; }
.archfig svg .af-mask-block.on {
  fill: var(--c-block); stroke: var(--c-block); stroke-width: 1;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--c-block) 75%, transparent));
}
.archfig svg .af-mask-label { font-size: 11px; font-family: var(--mono); fill: var(--k, var(--text-3)); }

/* Mask table: cycles through the query rows x -> y -> z */
table.mask tr[data-q="x"] { --k: var(--c-target); }
table.mask tr[data-q="y"] { --k: var(--c-past); }
table.mask tr[data-q="z"] { --k: var(--c-future); }
table.mask td, table.mask th { transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
table.mask tr.active th { color: var(--k); }
table.mask tr.active td:not(.no) {
  background: color-mix(in srgb, var(--k) 30%, var(--bg-elev)); color: var(--k);
  box-shadow: 0 0 0 1.5px var(--k), 0 0 10px color-mix(in srgb, var(--k) 45%, transparent);
}
table.mask tr.active td.no {
  background: color-mix(in srgb, var(--c-block) 38%, var(--bg-elev));
  box-shadow: 0 0 0 1.5px var(--c-block), 0 0 12px color-mix(in srgb, var(--c-block) 55%, transparent);
}
table.mask tbody tr { cursor: pointer; }
.mask-note {
  text-align: center; font-family: var(--mono); font-size: 13px; min-height: 1.4em;
  margin: -.4em 0 1.4em; color: var(--mask-k, var(--text-3));
}
@media (prefers-reduced-motion: reduce) { table.mask td, table.mask th { transition: none; } }

/* ---------- Phone layout for wide figures (see fig-split.js) ---------- */
.fig-mobile { display: none; }
.fig-part svg { display: block; width: 100%; min-width: 0 !important; height: auto; margin: 0 auto; }
.fig-part + .fig-part { margin-top: 18px; }
.fig-part-arrow { width: 2px; height: 22px; margin: 6px auto; background: var(--text-3); position: relative; opacity: .7; }
.fig-part-arrow::after {
  content: ''; position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  border: 6px solid transparent; border-top: 8px solid var(--text-3); border-bottom: 0;
}
@media (max-width: 640px) {
  .fig-wide .fig-frame { padding: 14px 10px; }
  .fig.split .scroll-x { display: none; }
  .fig.split .fig-mobile { display: block; }
  .coupling .coupling-svg { min-width: 0 !important; }
}
/* Phone parts of Figure 1: labels get a halo so the context/horizon divider passes behind them. */
.fig-part svg.arch .t-small { paint-order: stroke; stroke: var(--bg-elev); stroke-width: 5px; stroke-linejoin: round; }
.only-narrow { display: none; }
@media (max-width: 640px) { .only-wide { display: none; } .only-narrow { display: inline; } }
/* Phone version of Figure 2: live subtitles in the mixer boxes. */
.archfig .fig-mobile .af-tm-sub, .archfig .fig-mobile .af-vm-sub { font-family: var(--mono); font-style: normal; font-size: 11.5px; fill: var(--k, var(--text-3)); }
.only-narrow-block { display: none; }
@media (max-width: 640px) {
  .only-narrow-block { display: block; }
  /* Data tables fit the phone width: headers and row labels wrap, numbers stay on one line. */
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 7px 6px; }
  table.data thead th, table.data td:first-child { white-space: normal; }
}
/* Very narrow phones: display formulas a little smaller so they fit without scrolling. */
@media (max-width: 380px) { .prose .katex-display > .katex { font-size: 1.04em; } }

/* ---------- Post-processing demo (reuses the coupling demo styles) ---------- */
.postproc .ghost { fill: none; stroke: var(--text-3); stroke-width: 1.4; opacity: .35; stroke-linejoin: round; }
.postproc .out.pp-out { stroke: var(--accent); }
.postproc .mech-detail { font-size: 10.5px; fill: var(--text-3); }
