/* Long-form posts (public/writing/<slug>/). Loaded only on post pages.
   One comfortable reading column (~68ch, Bringhurst's 45–75 character measure), generous leading,
   headings that chunk the piece into scannable parts, code that never forces the page to scroll sideways. */

/* Post art: a generative canvas that opens every post (js/modules/post-art.js). Hidden until the script
   has drawn it, so a page without JS simply starts at the title. */
.post-art-wrap { display: none; padding-top: var(--space-m); }
.post-art-wrap.is-on { display: block; }
.post-art {
  display: block;
  width: 100%;
  height: clamp(150px, 24vw, 300px);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
}
.post-art-credit {
  margin-top: 0.55rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--step--1);
  text-align: right;
  color: var(--muted);
  opacity: 0;
  translate: 0 0.3rem;
  transition: opacity var(--dur-slow) var(--ease-out), translate var(--dur-slow) var(--ease-out);
}
.post-art-credit.is-shown { opacity: 1; translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .post-art-credit { transition: none; } }
.post-art-wrap.is-on + .post-head { padding-top: var(--space-l); }

/* One centred reading column shared by the post header, the article and the end matter. */
:root { --measure: 44rem; }
.post-head {
  display: grid;
  grid-template-columns: minmax(0, var(--measure));
  justify-content: center;
  padding-block: clamp(3rem, 2rem + 6vw, 7rem) var(--space-l);
}
.post-head .eyebrow a { color: inherit; text-decoration: none; }
.post-head .eyebrow a:hover { color: var(--ink); }
.post-head h1 {
  max-width: 20ch;
  margin-top: var(--space-s);
  font-size: clamp(2.4rem, 1.4rem + 4.2vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.post-dek {
  max-width: 46ch;
  margin-top: var(--space-m);
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-soft);
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-top: var(--space-m);
  font-size: var(--step--1);
  color: var(--muted);
}
.post-meta span { display: inline-flex; align-items: center; gap: 0.4rem; }
.post-meta .icon { width: 1em; height: 1em; }

/* ---------- Body ---------- */
.article {
  max-width: var(--measure);
  margin-inline: auto;
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--ink-soft);
}
@media (min-width: 720px) { .article { font-size: 1.125rem; } }
.article > * + * { margin-top: 1.25em; }
.article strong { color: var(--ink); font-weight: 600; }
.article a { color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 0.2em; }
.article a:hover { color: var(--accent); }

.article h2 {
  margin-top: 2.6em;
  font-size: var(--step-2);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.article h3 { margin-top: 2em; font-size: var(--step-1); color: var(--ink); }
.article h2 + *, .article h3 + * { margin-top: 0.75em; }

.article ul, .article ol { padding-left: 1.3em; }
.article ul { list-style: disc; }
.article ol { list-style: decimal; }
.article li + li { margin-top: 0.45em; }
.article li::marker { color: var(--muted); }

/* TL;DR up top: the whole post in three lines for skimmers (inverted pyramid). */
.tldr {
  padding: var(--space-m);
  border-radius: var(--radius-s);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
}
.tldr-label {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.tldr ul { margin-top: 0.6em; }

/* Pull quote: one line worth remembering, set large. */
.article blockquote {
  margin-block: 2em;
  padding-left: var(--space-m);
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--step-2);
  line-height: 1.3;
  color: var(--ink);
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

/* ---------- Code ---------- */
.article code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.12em 0.36em;
  border-radius: 6px;
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
}
.article pre {
  overflow-x: auto;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-s);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.86rem;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}
.article pre code { padding: 0; background: none; box-shadow: none; font-size: inherit; }
.article figure { margin-block: 2em; }
.article figcaption { margin-top: 0.6em; font-size: var(--step--1); color: var(--muted); }

.article hr { border: 0; height: 1px; margin-block: 2.5em; background: var(--line); }

/* ---------- End of post ---------- */
.post-end {
  max-width: var(--measure);
  margin-inline: auto;
  margin-top: var(--space-xl);
  padding-top: var(--space-l);
  border-top: 1px solid var(--line);
}
.post-end h2 { font-size: var(--step-2); }
.post-end p { max-width: 52ch; margin-top: var(--space-s); color: var(--ink-soft); }
.post-end .btn-group { margin-top: var(--space-m); }
/* Share row: plain text links on a hairline, no network logos or third-party scripts. */
.share { margin-top: var(--space-l); padding-top: var(--space-m); border-top: 1px solid var(--line); }
.share-list { display: flex; flex-wrap: wrap; gap: 0 var(--space-m); margin: 0.4rem 0 0; padding: 0; list-style: none; }
.share-list a, .share-list button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.share-list button[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) { .share-list a:hover, .share-list button:hover { color: var(--accent); } }
/* Comments (js/modules/comments.js, API in worker/index.js): hairline list, plain fields, quiet button.
   The section is hidden until the API answers, so nothing here shows on a broken or static preview. */
.comments { margin-top: var(--space-l); padding-top: var(--space-m); border-top: 1px solid var(--line); }
.comment-list { margin: 0.4rem 0 0; padding: 0; list-style: none; }
.comment { padding: var(--space-s) 0; border-bottom: 1px solid var(--line); }
.comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.6rem; margin: 0; font-size: var(--step--1); color: var(--muted); }
.comment-name { font-weight: 600; color: var(--ink); }
.post-end .comment-body { max-width: none; margin-top: 0.3rem; color: var(--ink-soft); white-space: pre-line; overflow-wrap: anywhere; }
.post-end .comment-empty { margin-top: 0.4rem; color: var(--muted); }
.comment-form { display: grid; gap: var(--space-s); margin-top: var(--space-m); }
.comment-form[hidden] { display: none; }
.field { display: grid; gap: 0.35rem; }
.field-label { font-size: var(--step--1); font-weight: 600; color: var(--ink); }
.field-hint { font-weight: 400; color: var(--muted); }
.field input, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.9rem;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink);
  font: inherit;
  font-size: max(16px, 1em); /* 16px stops iOS Safari zooming the page on focus */
  line-height: 1.5;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.field textarea { resize: vertical; min-height: 7.5rem; }
.field input:focus-visible, .field textarea:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--accent); }
.field-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.comment-check:empty { display: none; }
.comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-m); }
.post-end .comment-note { margin: 0; font-size: var(--step--1); color: var(--muted); }
.post-end .comment-status { margin: 0; min-height: 1.5em; font-size: var(--step--1); color: var(--ink-soft); }
.comment-status[data-tone="ok"] { color: var(--ink); }
.comment-status[data-tone="error"] { color: var(--accent); }
.comment-status { display: flex; align-items: flex-start; gap: 0.45rem; }
.comment-status .icon { flex: none; margin-top: 0.2em; }
.comment-status.is-new { animation: comment-rise var(--dur) var(--ease-out); }
.field textarea[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--accent); }

/* Sending: the arrow becomes a spinner and the fields step back while the button stays solid. */
.comment-spinner { display: none; }
.comment-form.is-busy .comment-submit .arrow { display: none; }
.comment-form.is-busy .comment-spinner { display: inline-block; animation: comment-spin 0.8s linear infinite; }
.comment-form .field { transition: opacity var(--dur) var(--ease-out); }
.comment-form.is-busy .field { opacity: 0.55; }
.comment-form.is-busy .comment-submit { pointer-events: none; }

/* Failure: one small shake, then the message rises in with an alert icon. Success: the form lifts away. */
.comment-form { transition: opacity var(--dur) var(--ease-out), translate var(--dur) var(--ease-out); }
.comment-form.is-shake { animation: comment-shake 420ms var(--ease-out); }
.comment-form.is-leaving { opacity: 0; translate: 0 -8px; }
.comment-form.is-back { animation: comment-rise var(--dur) var(--ease-out); }

/* Confirmation card: springs in, the badge pops, its check draws left to right, a ring pulses once,
   then the lines rise on the beat. Shows a short quote of what was sent, so it's clear it went through. */
.comment-sent {
  display: flex;
  align-items: flex-start;
  gap: var(--space-m);
  margin-top: var(--space-m);
  padding: var(--space-m);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
  outline: none;
  transition: opacity var(--dur-fast) var(--ease-out), translate var(--dur-fast) var(--ease-out);
}
.comment-sent[hidden] { display: none; }
.comment-sent.is-leaving { opacity: 0; translate: 0 6px; }
.comment-sent-badge {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}
.comment-sent-badge .icon { width: 22px; height: 22px; stroke-width: 2.6; }
.comment-sent-badge::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 2px var(--accent); opacity: 0; }
.comment-sent-main { min-width: 0; }
.post-end .comment-sent-title { max-width: none; margin: 0.35rem 0 0; font-family: var(--font-display); font-size: var(--step-1); line-height: 1.2; color: var(--ink); }
.post-end .comment-sent-text { margin-top: 0.25rem; }
.post-end .comment-sent-quote {
  margin-top: var(--space-s);
  padding-left: 0.9rem;
  border-left: 2px solid var(--line-strong);
  font-size: var(--step--1);
  color: var(--muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.comment-again { margin-top: var(--space-xs); margin-left: -0.6rem; gap: 0.45rem; }

.comment-sent.is-in { animation: comment-card var(--dur-slow) var(--ease-spring) both; }
.comment-sent.is-in .comment-sent-badge { animation: comment-pop 520ms var(--ease-spring) var(--beat) both; }
.comment-sent.is-in .comment-sent-badge .icon { animation: comment-draw 420ms var(--ease-out) calc(var(--beat) * 4) both; }
.comment-sent.is-in .comment-sent-badge::after { animation: comment-ring 900ms var(--ease-out) calc(var(--beat) * 5) both; }
.comment-sent.is-in .comment-sent-main > * { animation: comment-rise var(--dur-slow) var(--ease-out) both; }
.comment-sent.is-in .comment-sent-main > :nth-child(1) { animation-delay: calc(var(--beat) * 2); }
.comment-sent.is-in .comment-sent-main > :nth-child(2) { animation-delay: calc(var(--beat) * 3); }
.comment-sent.is-in .comment-sent-main > :nth-child(3) { animation-delay: calc(var(--beat) * 4); }
.comment-sent.is-in .comment-sent-main > :nth-child(4) { animation-delay: calc(var(--beat) * 6); }

@keyframes comment-spin { to { transform: rotate(360deg); } }
@keyframes comment-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes comment-shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes comment-card { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes comment-pop { from { opacity: 0; transform: scale(0.3); } }
@keyframes comment-draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes comment-ring { from { opacity: 0.6; transform: scale(1); } to { opacity: 0; transform: scale(1.9); } }

.post-end .post-more-label { margin-top: var(--space-xl); margin-bottom: var(--space-m); }

/* Phones: code runs edge to edge, so more of each line fits before it has to scroll sideways. */
@media (max-width: 560px) {
  .article pre {
    margin-inline: calc(-1 * max(var(--gutter), env(safe-area-inset-left, 0px)));
    padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px));
    border-radius: 0;
    box-shadow: inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line);
    font-size: 0.8rem;
  }
  .tldr { padding: var(--space-s) var(--space-m); }
}

/* ---------- Photos in posts ----------
   Portrait photos sit centred in the reading column; wide ones break out to the full content width like
   the visuals. Wide photos settle from a slight zoom as they scroll into view (scroll-driven, transform only;
   browsers without scroll timelines and reduced motion just show the still photo). */
.post-photo { margin: 2.4em 0; }
.post-photo img { display: block; width: 100%; height: auto; border-radius: var(--radius); background: var(--bg-raised); }
.post-photo figcaption { margin-top: 0.8em; font-size: var(--step--1); line-height: 1.6; color: var(--muted); }
.post-photo figcaption a { color: inherit; text-underline-offset: 0.2em; }
.post-photo--portrait { max-width: 30rem; margin-inline: auto; }
.post-photo--narrow { max-width: 22rem; margin-inline: auto; }
.post-photo--wide { width: 100cqi; max-width: none; margin-left: calc(50% - 50cqi); }
.post-photo-frame { overflow: hidden; border-radius: var(--radius); background: var(--bg-raised); }
.post-photo-frame img { border-radius: 0; }
.post-photo-frame { position: relative; }

/* Photo info: a frosted card with what, where, when and who, over the bottom of the photo. Fine pointers get it
   on hover; everyone gets it from the corner button (tap, click, or Enter). photo-info.js keeps aria-expanded
   in sync and closes it on Escape or a tap elsewhere. Transform and opacity only. */
.photo-info-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg-raised) 72%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 12%, transparent), 0 6px 18px -8px rgb(0 0 0 / 0.35);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--dur) var(--ease-spring), background var(--dur) var(--ease-out);
}
.photo-info-btn .icon { width: 1.15rem; height: 1.15rem; }
.photo-info-btn[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); transform: rotate(-12deg) scale(1.05); }
.photo-info {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 1;
  max-width: 22rem;
  padding: 0.85rem 1rem 0.9rem;
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--bg-raised) 80%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 10%, transparent), 0 18px 40px -18px rgb(0 0 0 / 0.5);
  font-size: var(--step--1);
  line-height: 1.45;
  color: var(--ink);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transform-origin: 0 100%;
  pointer-events: none;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-spring), visibility 0s linear var(--dur);
}
.photo-info-title { margin: 0 0 0.45rem; font-family: var(--font-display); font-size: var(--step-0); line-height: 1.2; letter-spacing: -0.01em; }
.photo-info dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.9rem; margin: 0; }
.photo-info dt { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; padding-top: 0.12rem; }
.photo-info dd { margin: 0; }
.photo-info a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.2em; }
.photo-info dl > * { opacity: 0; transform: translateY(4px); transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.photo-info-btn[aria-expanded="true"] + .photo-info {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s;
}
.photo-info-btn[aria-expanded="true"] + .photo-info dl > * { opacity: 1; transform: none; transition-delay: calc(var(--beat) * 1); }
@media (hover: hover) and (pointer: fine) {
  .post-photo-frame:hover .photo-info { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }
  .post-photo-frame:hover .photo-info dl > * { opacity: 1; transform: none; transition-delay: calc(var(--beat) * 1); }
  .post-photo-frame:hover .photo-info-btn { transform: scale(1.06); }
  .photo-info-btn:hover { background: var(--accent); color: var(--accent-ink); }
}
@media (max-width: 560px) { .photo-info { max-width: none; } }
.post-photo--wide figcaption { max-width: var(--measure); margin-inline: auto; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .post-photo--wide img {
      animation: photo-settle linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 50%;
    }
  }
}
@keyframes photo-settle { from { transform: scale(1.08); } to { transform: scale(1); } }

/* ==========================================================================
   Post visuals (<figure class="viz" data-viz="…">, bundles in js/viz/, sources in src/viz/)
   Each figure is complete without JS; the script upgrades it (3D stage, sliders, scan animation).
   ========================================================================== */
main > .container:has(> .article) { container-type: inline-size; }
.article .viz {
  width: 100cqi; /* break out of the reading column to the full content width, staying centred */
  max-width: none;
  margin: 2.6em 0 2.6em calc(50% - 50cqi);
}
.viz figcaption { max-width: var(--measure); margin: 0.9em auto 0; font-size: var(--step--1); line-height: 1.6; color: var(--muted); }
.viz figcaption code { font-size: 0.9em; }

/* ---------- 3D stage ---------- */
.viz-stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
}
.viz.is-3d .viz-stage { aspect-ratio: 16 / 9.5; }
.viz.is-3d .viz-stage--wide { aspect-ratio: 16 / 9; }
@media (max-width: 720px) { .viz.is-3d .viz-stage, .viz.is-3d .viz-stage--wide { aspect-ratio: 4 / 5; } }
@media (max-width: 720px) { .viz-merge.is-3d .viz-stage { aspect-ratio: 1; } }
.viz-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.viz-label {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--ink);
  background: color-mix(in srgb, var(--bg-raised) 82%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
  will-change: transform;
}
.viz.is-3d .viz-label { display: block; }
.viz-label.is-on { opacity: 1; }
.viz-label.is-bad { color: var(--accent); box-shadow: inset 0 0 0 1px currentColor; }
.viz-label--muted { color: var(--muted); }
.viz-label--axis { background: none; box-shadow: none; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font-body); }
.viz-label--twin { font-style: italic; }
/* Which side of its point a label sits on (JS sets the position; this sets the anchor). */
.viz-label[data-side="left"] { translate: -100% -50%; }
.viz-label[data-side="right"] { translate: 0 -50%; }
.viz-label[data-side="top"] { translate: -50% -100%; }

/* ---------- MERLIN: bars (no-WebGL version) and controls ---------- */
.viz-bars { display: grid; gap: 0.7rem; padding: var(--space-m); position: relative; }
.viz.is-3d .viz-bars { display: none; }
.viz-bar { display: grid; grid-template-columns: 6.5rem 1fr 3rem; align-items: center; gap: 0.75rem; font-size: var(--step--1); }
.viz-bar span { color: var(--muted); }
.viz-bar i { height: 10px; border-radius: 999px; background: linear-gradient(var(--ink-soft), var(--ink-soft)) 0 0 / var(--w, 0%) 100% no-repeat, var(--line); transition: background-size var(--dur) var(--ease-out); }
.viz-bar.is-over i { background-image: linear-gradient(var(--accent), var(--accent)); }
.viz-bar b { font-family: var(--font-mono); font-weight: 500; text-align: right; }
.viz-bar.is-over b { color: var(--accent); }
.viz-limit { position: absolute; top: var(--space-s); bottom: var(--space-s); left: calc(var(--space-m) + 7.25rem + (100% - 2 * var(--space-m) - 7.25rem - 3.75rem) / 2); border-left: 1px dashed var(--accent); }
.viz-limit span { position: absolute; top: -0.4rem; left: 0.4rem; font-size: 0.7rem; color: var(--accent); white-space: nowrap; }

.viz-panel {
  display: grid;
  gap: var(--space-s) var(--space-l);
  grid-template-columns: 1fr 1fr;
  align-items: end;
  margin-top: var(--space-s);
  padding: var(--space-m);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line);
}
.viz-panel[hidden] { display: none; }
@media (max-width: 720px) { .viz-panel { grid-template-columns: 1fr; } }
.viz-control { display: grid; gap: 0.5rem; font-size: var(--step--1); color: var(--ink-soft); }
.viz-control span { display: flex; align-items: baseline; gap: 0.4rem; }
.viz-control output { margin-left: auto; font-family: var(--font-mono); font-size: var(--step-0); color: var(--ink); }
.viz-control input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); cursor: pointer; }
.viz-readout { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin: 0; }
.viz-eq { font-family: var(--font-mono); font-size: var(--step-1); color: var(--ink); }
.viz-verdict { padding: 0.25rem 0.7rem; border-radius: 999px; font-size: var(--step--1); font-weight: 600; color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--line-strong); transition: color var(--dur) var(--ease-out); }
.viz-verdict.is-bad { color: var(--accent); box-shadow: inset 0 0 0 1px currentColor; }
.viz-note { margin: 0; font-size: var(--step--1); color: var(--muted); }

/* ---------- Digital twin: step captions ---------- */
.viz-steps { padding: var(--space-m) var(--space-m) var(--space-m) calc(var(--space-m) + 1.2em); list-style: decimal; display: grid; gap: 0.4rem; color: var(--ink-soft); }
.viz.is-3d .viz-steps {
  position: absolute;
  left: var(--space-m);
  right: var(--space-m);
  bottom: var(--space-m);
  padding: 0;
  list-style: none;
  display: block;
  min-height: 1.6em;
  pointer-events: none;
}
.viz.is-3d .viz-steps li {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: 30ch;
  text-align: right;
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.25;
  color: var(--ink);
  opacity: 0;
  translate: 0 0.4em;
  transition: opacity var(--dur-slow) var(--ease-out), translate var(--dur-slow) var(--ease-out);
}
.viz.is-3d .viz-steps li.is-current { opacity: 1; translate: 0 0; }
.viz.is-3d .viz-steps li::before { content: counter(list-item) " / 5"; display: block; margin-bottom: 0.25rem; font-family: var(--font-body); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
/* Reduced motion: one still frame, with every step listed in a quiet panel in the empty corner. */
.viz.is-3d.is-still .viz-steps {
  left: auto;
  right: var(--space-m);
  width: min(36ch, 46%);
  padding: 0.8rem 1rem 0.8rem 2rem;
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--bg-raised) 88%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
  list-style: decimal;
  display: grid;
  gap: 0.25rem;
}
.viz.is-3d.is-still .viz-steps li { position: static; max-width: none; opacity: 1; translate: none; text-align: left; font-family: var(--font-body); font-size: var(--step--1); line-height: 1.4; color: var(--ink-soft); }
.viz.is-3d.is-still .viz-steps li::before { content: none; }
@media (max-width: 720px) { .viz.is-3d.is-still .viz-steps { left: var(--space-s); right: var(--space-s); bottom: var(--space-s); width: auto; } }
@media (max-width: 720px) { .viz.is-3d .viz-steps li { left: 0; max-width: none; text-align: left; font-size: var(--step-0); } }

/* ---------- Mealcents: receipt scan ---------- */
.receipt-stage {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: var(--space-l);
  align-items: start;
  padding: var(--space-l);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
}
@media (max-width: 720px) { .receipt-stage { grid-template-columns: 1fr; padding: var(--space-m); gap: var(--space-m); } }
.receipt {
  position: relative;
  padding: 1.4rem 1.3rem 1.8rem;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.9;
  color: var(--ink-soft);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 14px 30px -18px rgb(0 0 0 / 0.45);
  rotate: -1.2deg;
  /* torn zigzag bottom edge */
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
}
.r-head { margin-bottom: 0.9rem; text-align: center; letter-spacing: 0.12em; color: var(--ink); }
.r-head span { letter-spacing: 0.04em; color: var(--muted); }
.r-line, .r-total { position: relative; display: flex; justify-content: space-between; gap: 1rem; }
.r-total { margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px dashed var(--line-strong); font-weight: 600; color: var(--ink); }
.r-line::after, .r-total::after {
  /* the OCR box that appears around each line as it's read */
  content: "";
  position: absolute;
  inset: 0.1rem -0.35rem;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px var(--accent);
  opacity: 0;
  scale: 0.96 0.7;
  transition: opacity var(--dur) var(--ease-out), scale var(--dur) var(--ease-spring);
}
.viz-receipt.is-playing .r-line.is-read::after, .viz-receipt.is-playing .r-total.is-read::after { opacity: 0.55; scale: 1; }
.r-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px 2px var(--accent), 0 0 40px 8px var(--accent-soft);
  opacity: 0;
  pointer-events: none;
}
.viz-receipt:not(.is-playing) .r-beam { display: none; }

.parsed { position: relative; display: grid; gap: 0.6rem; }
.parsed-label { font-size: var(--step--1); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.article .parsed-list { display: grid; gap: 0; padding: 0; list-style: none; }
.article .parsed-list li + li { margin-top: 0; }
.parsed-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.35rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: var(--step-0);
  color: var(--ink);
}
.parsed-price, .parsed-sum output, .parsed-total span:last-child { font-family: var(--font-mono); font-size: 0.86rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.parsed-sum, .parsed-total { display: flex; justify-content: space-between; margin: 0; font-size: var(--step--1); color: var(--muted); }
.parsed-sum { margin-top: 0.4rem; color: var(--ink); }
.parsed-sum output { color: var(--ink); font-weight: 600; }
.parsed-verdict { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0 0; font-size: var(--step--1); font-weight: 600; color: var(--accent); }
/* While the scan plays, parsed rows and the verdict start hidden and arrive one by one. */
.viz-receipt.is-playing .parsed-list li, .viz-receipt.is-playing .parsed-verdict { opacity: 0; translate: 0.6rem 0; transition: opacity 420ms var(--ease-out), translate 420ms var(--ease-out); }
.viz-receipt.is-playing .parsed-list li.is-in, .viz-receipt.is-playing .parsed-verdict.is-in { opacity: 1; translate: 0 0; }
.coin-fx {
  position: absolute;
  right: -1rem;
  bottom: -1.2rem;
  width: 264px; /* 176 × 1.5: pixel art scaled up crisply */
  height: 174px;
  image-rendering: pixelated;
  pointer-events: none;
}
.viz-replay { margin-top: var(--space-s); }
.viz-replay[hidden] { display: none; }
@media (max-width: 720px) { .coin-fx { right: -0.5rem; width: 176px; height: 116px; } }

/* ---------- Lineage (the-middle-generation): a typographic chain of makers and made ---------- */
.lineage { padding: var(--space-l) var(--space-m) var(--space-m); }
.lineage-heads,
.lineage-link { display: grid; grid-template-columns: 1fr 1fr; column-gap: clamp(1.5rem, 6cqi, 4rem); }
.lineage-heads {
  max-width: 44rem;
  margin: 0 auto var(--space-m);
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.lineage-heads span:first-child, .lineage-up { text-align: right; }
.article .lineage-chain { max-width: 44rem; margin: 0 auto; padding: 0; list-style: none; display: grid; }
.lineage-chain li { margin: 0; transition: opacity var(--dur-slow) var(--ease-out), translate var(--dur-slow) var(--ease-out); transition-delay: calc(var(--i) * var(--beat) * 1.5); }
.viz.is-waiting .lineage-chain li { opacity: 0; translate: 0 0.6rem; }
.lineage-node { display: grid; justify-items: center; gap: 0.15rem; padding: 0.5rem 0; text-align: center; }
.lineage-name { font-family: var(--font-display); font-size: var(--step-2); line-height: 1.1; color: var(--ink); }
.lineage-tag { font-size: var(--step--1); color: var(--muted); }
.lineage-node.is-us .lineage-name { font-size: var(--step-3); font-style: italic; color: var(--accent); }
.lineage-node.is-unknown .lineage-name { color: var(--muted); }
.lineage-link {
  position: relative;
  align-items: center;
  min-height: 5.5rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--step-0);
  line-height: 1.35;
  color: var(--ink-soft);
}
.lineage-link::before { content: ""; position: absolute; left: 50%; top: 0.4rem; bottom: 0.4rem; width: 1px; background: var(--line-strong); }
.lineage-link.is-faint { color: var(--muted); }
.lineage-link.is-faint::before { background: none; border-left: 1px dashed var(--line-strong); }
.lineage-up, .lineage-down, .lineage-heads span { transition: opacity var(--dur) var(--ease-out); }
.lineage[data-view="up"] .lineage-down, .lineage[data-view="up"] .lineage-heads span:last-child,
.lineage[data-view="down"] .lineage-up, .lineage[data-view="down"] .lineage-heads span:first-child { opacity: 0.12; }
.lineage-views { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: var(--space-m); }
.lineage-view {
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--ink-soft);
}
.lineage-view[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
@media (hover: hover) and (pointer: fine) { .lineage-view:not([aria-pressed="true"]):hover { border-color: var(--accent); color: var(--accent); } }
@media (max-width: 560px) {
  .lineage { padding-inline: var(--space-s); }
  .lineage-link { font-size: var(--step--1); min-height: 6rem; }
}
@media (prefers-reduced-motion: reduce) { .lineage-chain li, .lineage-up, .lineage-down { transition: none; } }

/* Lineage, 3D version: the typographic chain steps aside for the stage; quotes ride beside the strands. */
.viz.is-3d .lineage { padding: 0; }
.viz.is-3d .lineage-chain, .viz.is-3d .lineage-heads { display: none; }
.viz-label[data-side="bottom"] { translate: -50% 0; }
.viz-label--quote {
  padding: 0;
  background: none;
  box-shadow: none;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-soft);
}
@media (max-width: 560px) {
  .lineage-sub { display: none; }
  .viz-label--quote { width: 7.2rem; white-space: normal; font-size: 0.82rem; }
  .viz-label--quote[data-side="left"] { text-align: right; }
}
.viz.is-3d .lineage { touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.viz.is-3d .lineage:active { cursor: grabbing; }

/* ---------- Flow (five-to-nine): how Daisy works, as a map you can play ----------
   src/viz/flow.js adds the live Daisy (the app's own rig) and a card that walks the loop; the map lights the path
   taken. Without JS the map alone tells the story. Violet is Daisy's colour, used only here. */
.article .viz-flow ol, .article .viz-flow ul { list-style: none; padding-left: 0; }
.viz-flow { --daisy: #8f80ea; --daisy-soft: color-mix(in srgb, #8f80ea 16%, var(--bg-raised)); }
.flow {
  position: relative;
  display: grid;
  gap: var(--space-m);
  padding: var(--space-m);
  border-radius: calc(var(--radius) * 1.4);
  background:
    radial-gradient(60% 50% at 0% 0%, color-mix(in srgb, #b9a8ff 14%, transparent), transparent 70%),
    radial-gradient(50% 45% at 100% 100%, color-mix(in srgb, #ffb38a 12%, transparent), transparent 70%),
    var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line);
}
.flow-map {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1.45fr 1fr 1.05fr;
  align-items: center;
  gap: clamp(1.25rem, 3cqi, 2.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
}
.flow-step {
  position: relative;
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0.9rem;
  border-radius: 18px;
  background: color-mix(in srgb, var(--c, #b9a8ff) 11%, var(--bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, #b9a8ff) 32%, transparent);
  font-size: var(--step--1);
  line-height: 1.4;
  color: var(--muted);
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.flow-step > b { font-size: var(--step-0); font-weight: 600; color: var(--ink); line-height: 1.25; }
.flow-head { display: flex; align-items: center; gap: 0.55rem; }
.flow-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c, #b9a8ff) 34%, var(--bg));
  color: var(--ink);
}
.flow-badge .icon { width: 1rem; height: 1rem; }
.flow-n { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.flow-pills { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.flow-pills i { padding: 0.12rem 0.55rem; border-radius: 999px; background: color-mix(in srgb, var(--c, #b9a8ff) 24%, transparent); font-style: normal; font-size: 0.72rem; color: var(--ink-soft); }
.flow-quote { font: italic 500 var(--step--1)/1.35 var(--font-display); color: var(--ink-soft); }
.flow-lock { display: inline-flex; align-items: center; gap: 0.35rem; }
.flow-lock .icon { width: 0.85rem; height: 0.85rem; }
.flow-fork { background: none; box-shadow: none; padding: 0; }
.flow-moments { display: grid; grid-auto-rows: 1fr; gap: 0.5rem; margin: 0.15rem 0 0; padding: 0; list-style: none; }
.flow-moments li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  column-gap: 0.65rem;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--c) 14%, var(--bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent);
  font-size: var(--step--1);
  line-height: 1.3;
  color: var(--muted);
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.flow-moments .flow-badge { grid-row: span 2; width: 1.9rem; height: 1.9rem; }
.flow-moments b { font-size: var(--step--1); font-weight: 600; color: var(--ink); }
.flow-journal { display: grid; gap: 0.25rem; margin: 0.1rem 0 0; padding: 0; list-style: none; font-size: 0.75rem; color: var(--ink-soft); }
.flow-journal:empty { display: none; }
.flow-journal li { padding: 0.3rem 0.55rem; border-radius: 8px; background: color-mix(in srgb, #b9a8ff 22%, var(--bg)); }

.flow-lines { position: absolute; z-index: 0; inset: var(--space-m) var(--space-m) auto; width: calc(100% - 2 * var(--space-m)); height: auto; overflow: visible; pointer-events: none; }
.flow-lines path { fill: none; stroke: var(--line-strong); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 0.1 7; transition: stroke var(--dur) var(--ease-out); }
.flow-lines path.is-lit { stroke: #b9a8ff; stroke-width: 3; stroke-dasharray: none; }

/* The path taken. */
.viz-flow.is-live .flow-step.is-now, .viz-flow.is-live .flow-moments li.is-picked { box-shadow: inset 0 0 0 2px var(--c, #b9a8ff), 0 10px 28px -14px var(--c, #b9a8ff); transform: translateY(-2px); }
.viz-flow.is-live .flow-step.is-done { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c, #b9a8ff) 75%, transparent); }
.viz-flow.is-live .flow-fork.is-now, .viz-flow.is-live .flow-fork.is-done { box-shadow: none; transform: none; }
.viz-flow.is-live .flow-moments li { cursor: pointer; }
.viz-flow.is-live .flow-moments li:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Play: Daisy on the left, the step's card on the right. */
.flow-play { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(150px, 230px) 1fr; align-items: center; gap: var(--space-m); padding-top: var(--space-m); border-top: 1px solid var(--line); }
.flow-play[hidden] { display: none; }
.flow-daisy { position: relative; display: grid; justify-items: center; gap: 0.6rem; padding-top: 2.6rem; }
.flow-daisy::before { content: ""; position: absolute; inset: 1.5rem 0 0; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, #b9a8ff 30%, transparent), transparent); pointer-events: none; }
.flow-host { display: block; width: min(100%, 190px); transform-origin: 50% 92%; will-change: transform; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.flow-host .mascot { display: block; width: 100%; height: auto; overflow: visible; }
.flow-cue {
  position: absolute;
  top: 0;
  left: 50%;
  max-width: 15rem;
  margin: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 1rem;
  background: var(--daisy-soft);
  font: italic 500 var(--step--1)/1.35 var(--font-display);
  color: var(--ink);
  text-align: center;
  translate: -50% 0;
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}
.flow-cue.is-on { opacity: 1; }
.flow-card { display: grid; gap: 0.7rem; align-content: center; min-height: 12rem; opacity: 0; transform: translateY(6px); transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.flow-card.is-in { opacity: 1; transform: none; }
.flow-q { margin: 0; font: 500 var(--step-1)/1.2 var(--font-display); color: var(--ink); }
.flow-sub { margin: 0; font-size: var(--step--1); color: var(--muted); }
.flow-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.flow-chip, .flow-next, .flow-line {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font: 500 var(--step--1) var(--font-body);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.flow-chip:active, .flow-next:active, .flow-line:active { transform: scale(0.97); }
.flow-next { justify-self: start; background: var(--daisy); box-shadow: none; color: #fff; }
.flow-chips--moments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.flow-chips--moments .flow-chip { display: grid; grid-template-columns: auto 1fr; column-gap: 0.65rem; align-items: center; padding: 0.7rem 0.9rem; border-radius: 14px; text-align: left; background: color-mix(in srgb, var(--c, #b9a8ff) 14%, var(--bg)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, #b9a8ff) 40%, transparent); }
.flow-chips--moments .flow-badge { grid-row: span 3; }
.flow-chips--moments span { font-weight: 400; color: var(--muted); }
.flow-chips--moments i { grid-column: 2; justify-self: start; margin-top: 0.2rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--daisy-soft); font-style: normal; font-size: 0.7rem; color: var(--ink); }
.flow-lines-pick { display: grid; gap: 0.5rem; }
.flow-line { border-radius: 14px; text-align: left; font: italic 500 var(--step-0)/1.35 var(--font-display); }
.flow-line.is-kept { box-shadow: inset 0 0 0 2px var(--daisy); }
.flow-colour { width: 8.5rem; height: 8.5rem; }
.flow-colour ellipse { fill: var(--bg); stroke: var(--ink-soft); stroke-width: 1.2; cursor: pointer; transition: fill var(--dur) var(--ease-out); }
.flow-centre { fill: #ffd36e; stroke: var(--ink-soft); stroke-width: 1.2; }
.flow-swatches { display: flex; gap: 0.5rem; }
.flow-swatch { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); cursor: pointer; }
.flow-swatch.is-on { box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12), 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }

@media (hover: hover) and (pointer: fine) {
  .flow-chip:hover, .flow-line:hover { box-shadow: inset 0 0 0 1px var(--ink-soft); }
  .viz-flow.is-live .flow-moments li:hover { transform: translateY(-2px); }
}
/* Phones: the map stacks top to bottom with short joins, and Daisy sits above her card. */
@media (max-width: 720px) {
  .flow { padding: var(--space-s); }
  .flow-map { grid-template-columns: 1fr; }
  .flow-lines { display: none; }
  .flow-map { gap: 1.4rem; }
  .flow-step:not(:last-child)::after { content: ""; position: absolute; left: 50%; bottom: -1.3rem; height: 1.2rem; border-left: 2px dotted color-mix(in srgb, #b9a8ff 70%, transparent); }
  .flow-step:not(:last-child)::before { content: ""; position: absolute; left: calc(50% - 4px); bottom: -1.38rem; width: 7px; height: 7px; border-right: 2px solid color-mix(in srgb, #b9a8ff 70%, transparent); border-bottom: 2px solid color-mix(in srgb, #b9a8ff 70%, transparent); transform: rotate(45deg); }
  .flow-moments { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-moments li { grid-template-columns: 1fr; align-content: start; row-gap: 0.15rem; padding: 0.75rem; }
  .flow-moments .flow-badge { grid-row: auto; margin-bottom: 0.3rem; }
  .flow-play { grid-template-columns: 1fr; }
  .flow-host { width: 150px; }
  .flow-chips--moments { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .flow-step, .flow-moments li, .flow-card, .flow-cue, .flow-chip, .flow-line, .flow-lines path, .flow-colour ellipse { transition: none; }
}

/* ==========================================================================
   Side rail (desktop, 1280px and up): the article's sections, time left, and quick links. Fixed beside the
   centred reading column; js/modules/rail.js shows it only while the article is in view, steps it aside for
   full-width figures, highlights the current section and counts down the minutes. Transform and opacity only.
   ========================================================================== */
.post-rail { display: none; }
@media (min-width: 1280px) {
  .post-rail:not([hidden]) {
    position: fixed;
    top: 7.5rem;
    left: calc(50% + var(--measure) / 2 + clamp(2rem, 4vw, 4.5rem));
    z-index: 5;
    display: block;
    width: 13.5rem;
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    scrollbar-width: none;
    opacity: 0;
    transform: translateX(10px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), visibility 0s linear var(--dur);
  }
  .post-rail.is-shown { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }
}
.post-rail-label { margin: 0 0 0.6rem; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.post-rail-toc { position: relative; margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.post-rail-toc a {
  display: block;
  padding: 0.38rem 0 0.38rem 0.95rem;
  font-size: var(--step--1);
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out), transform var(--dur) var(--ease-out);
}
.post-rail-toc a.is-active { color: var(--ink); transform: translateX(2px); }
.post-rail-marker {
  position: absolute;
  top: 0;
  left: -1px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: transform var(--dur) var(--ease-spring), opacity var(--dur) var(--ease-out);
}
.post-rail-marker.is-on { opacity: 1; }
.post-rail-left { margin: 0.8rem 0 0 0.95rem; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.post-rail-actions { display: grid; gap: 0.1rem; margin: 1.1rem 0 0; padding: 0.9rem 0 0; list-style: none; border-top: 1px solid var(--line); }
.post-rail-actions a, .post-rail-actions button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 2.3rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--step--1);
  color: var(--ink-soft);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.post-rail-actions .icon { width: 1rem; height: 1rem; flex: none; transition: transform var(--dur) var(--ease-spring); }
.post-rail-count:not(:empty) {
  margin-left: auto;
  min-width: 1.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
}
@media (hover: hover) and (pointer: fine) {
  .post-rail-toc a:hover { color: var(--ink); }
  .post-rail-actions a:hover, .post-rail-actions button:hover { color: var(--accent); }
  .post-rail-actions a:hover .icon, .post-rail-actions button:hover .icon { transform: translateX(2px); }
  .post-rail-actions a[data-rail-top]:hover .icon { transform: translateY(-2px); }
}
