/* Project case-study pages.
   Self-contained: matches the portfolio's palette and type without pulling in
   the 191KB template stylesheet, so nothing can fight the cascade here. */

:root {
  /* Was lime + orange. Moved onto the site navy so a reader arriving from
     the portfolio does not land on what looks like a different product. */
  --lime: hsl(222, 62%, 58%);
  --orange: hsl(222, 62%, 50%);
  --sig: #7aa8ff;
  --ink: #0d0d0d;
  --panel: #161616;
  --panel-2: #1e1e1e;
  --line: #2c2c2c;
  --text: #f2f2f2;
  --muted: #a3a3a3;
  --dim: #6f6f6f;
  --good: #7ddf9a;
  --bad: #ff6b5e;
  --warn: #f3c969;

  --head: "Phudu", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --measure: 68ch;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.5rem; }

h1, h2, h3, h4 { font-family: var(--head); font-weight: 700; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); line-height: 0.95; letter-spacing: -0.02em; text-transform: uppercase; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); line-height: 1.05; letter-spacing: -0.01em; text-transform: uppercase; }
h3 { font-size: 1.15rem; line-height: 1.25; }
p { margin: 0; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 0; }
.back {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--head); font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text); text-decoration: none; transition: color 0.15s;
}
.back:hover { color: var(--lime); }
.bar-links { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn {
  font-family: var(--head);
  font-size: 0.76rem; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--text); text-decoration: none;
  cursor: pointer; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn:hover { border-color: var(--lime); color: var(--lime); }
.btn.solid { background: var(--lime); border-color: var(--lime); color: #0d0d0d; font-weight: 700; }
.btn.solid:hover { background: #fff; border-color: #fff; color: #0d0d0d; }
.btn:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }

/* ---------- hero ---------- */
.hero { padding: 4.5rem 0 3rem; border-bottom: 1px solid var(--line); }
.eyebrow {
  font-family: var(--head); font-size: 0.78rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--lime); margin-bottom: 1rem;
}
.plain { font-size: clamp(1.15rem, 2.2vw, 1.5rem); color: var(--text); max-width: var(--measure); margin-top: 1.4rem; }
.tags { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.6rem; }
.tag {
  font-family: var(--head); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.4rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.tag.live { border-color: var(--lime); color: var(--lime); }

/* ---------- sections ---------- */
section { padding: 3.5rem 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
.lede { color: var(--muted); max-width: var(--measure); margin-top: 1.2rem; }
.stack-p { display: flex; flex-direction: column; gap: 1rem; max-width: var(--measure); margin-top: 1.2rem; color: var(--muted); }
.stack-p strong { color: var(--text); font-weight: 600; }

/* ---------- interactive: pipeline stepper ---------- */
.demo {
  margin-top: 1.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.5rem;
}
.demo-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.demo-title { font-family: var(--head); font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.demo-ctl { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.track { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.6rem; }
.node {
  flex: 0 0 auto;
  min-width: 108px;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-2); color: var(--dim);
  font-family: var(--head); font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase;
  text-align: center; cursor: pointer;
  transition: all 0.25s;
}
.node:hover { border-color: var(--muted); color: var(--muted); }
.node[data-lane="llm"] { border-style: dashed; }
.node.on { background: var(--lime); border-color: var(--lime); color: #0d0d0d; font-weight: 700; }
.node.done { border-color: var(--lime); color: var(--lime); }
.node.failed { background: var(--bad); border-color: var(--bad); color: #0d0d0d; font-weight: 700; }
.node.fellback { border-color: var(--warn); color: var(--warn); border-style: solid; }

.readout {
  margin-top: 1.1rem; padding: 1.1rem 1.2rem;
  background: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  min-height: 118px;
}
.readout h4 { font-size: 1rem; margin-bottom: 0.45rem; }
.readout p { color: var(--muted); font-size: 0.96rem; }
.lane {
  display: inline-block; margin-top: 0.7rem;
  font-family: var(--head); font-size: 0.66rem; letter-spacing: 0.09em; text-transform: uppercase;
  padding: 0.25rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--dim);
}
.lane.det { border-color: var(--good); color: var(--good); }
.lane.llm { border-color: var(--orange); color: var(--orange); }

.legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: 1rem; font-size: 0.8rem; color: var(--dim); }
.legend i { font-style: normal; display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 14px; height: 10px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }
.swatch.det { border-color: var(--good); }
.swatch.llm { border-color: var(--orange); border-style: dashed; }

/* ---------- interactive: checker (DocsGuard) ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 0.5rem; }
.field label { font-family: var(--head); font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
.field select, .field textarea {
  background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.8rem; font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem;
  resize: vertical;
}
.field select:focus, .field textarea:focus { outline: 2px solid var(--lime); outline-offset: 1px; }

.verdict { margin-top: 1.1rem; padding: 1.1rem 1.2rem; border-radius: 12px; border: 1px solid var(--line); background: var(--ink); }
.verdict.blocked { border-color: var(--bad); }
.verdict.warned { border-color: var(--warn); }
.verdict.clean { border-color: var(--good); }
.verdict-label { font-family: var(--head); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; }
.verdict.blocked .verdict-label { color: var(--bad); }
.verdict.warned .verdict-label { color: var(--warn); }
.verdict.clean .verdict-label { color: var(--good); }
.cite {
  margin-top: 0.8rem; padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--lime); background: var(--panel-2);
  font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; color: var(--muted);
}
.cite b { color: var(--lime); font-weight: 400; }
.why { margin-top: 0.8rem; color: var(--muted); font-size: 0.94rem; }

/* ---------- decision callout ---------- */
.callout {
  margin-top: 1.6rem; padding: 1.4rem 1.5rem;
  border-left: 3px solid var(--lime); background: var(--panel);
  border-radius: 0 12px 12px 0;
}
.callout p { max-width: var(--measure); }
.callout p + p { margin-top: 0.9rem; }
.quote { font-family: var(--head); font-size: 1.2rem; line-height: 1.35; color: var(--text); }

/* ---------- stack chips + facts ---------- */
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.4rem; }
.chip {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem;
  padding: 0.4rem 0.75rem; border: 1px solid var(--line); border-radius: 8px; color: var(--muted);
}
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1.5rem; margin-top: 1.6rem; }
.fact b { display: block; font-family: var(--head); font-size: 2.2rem; line-height: 1; color: var(--lime); font-variant-numeric: tabular-nums; }
.fact span { display: block; margin-top: 0.4rem; color: var(--muted); font-size: 0.88rem; }

/* ---------- footer nav ---------- */
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 2.5rem 0 4rem; }
.pager a { color: var(--muted); text-decoration: none; font-family: var(--head); font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase; }
.pager a:hover { color: var(--lime); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}


/* =====================================================================
   SIMULATOR
   A run console rather than a stage list: payload in and out, a live log,
   meters that accumulate, and transport controls. A claim is easier to
   believe when you can watch the step that produces it.
   ===================================================================== */
.sim {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel), #121212);
  overflow: hidden;
}
.sim-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.sim-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--head);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.sim-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dim);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.sim.is-playing .sim-dot {
  background: var(--sig);
  animation: simPulse 1.4s ease-out infinite;
}
.sim.is-degraded .sim-dot { background: var(--warn); animation: none; }
@keyframes simPulse {
  0% { box-shadow: 0 0 0 0 rgba(122,168,255,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(122,168,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(122,168,255,0); }
}
.sim-ctl { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.sim-btn {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.42rem 0.85rem;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.sim-btn:hover { border-color: var(--lime); color: var(--lime); }
.sim-btn.solid { background: var(--lime); border-color: var(--lime); color: #06122e; font-weight: 700; }
.sim-btn.solid:hover { color: #06122e; }
.sim-btn.ghost { color: var(--muted); }
.sim-btn.on { border-color: var(--warn); color: var(--warn); }
.sim-btn:focus-visible { outline: 2px solid var(--sig); outline-offset: 2px; }

.sim-prog { height: 2px; background: #232323; }
.sim-prog span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, rgba(122,168,255,0.4), var(--sig));
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.sim-body { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
@media (max-width: 780px) { .sim-body { grid-template-columns: 1fr; } }

.sim-rail {
  margin: 0; padding: 0.6rem; list-style: none;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
@media (max-width: 780px) {
  .sim-rail {
    flex-direction: row; overflow-x: auto; border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
.sim-node {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  cursor: pointer;
  color: var(--dim);
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.25s ease, color 0.25s ease;
}
.sim-node:hover { background: #1c1c1c; color: var(--text); }
.sim-node-i {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem; opacity: 0.6;
}
.sim-node-l { flex: 1; }
.sim-node-s {
  width: 7px; height: 7px; border-radius: 50%;
  background: #333;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.sim-node.done { color: var(--muted); }
.sim-node.done .sim-node-s { background: var(--lime); }
.sim-node.on {
  background: rgba(122, 168, 255, 0.12);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--sig);
}
.sim-node.on .sim-node-s { background: var(--sig); box-shadow: 0 0 0 4px rgba(122,168,255,0.18); }
.sim-node.fellback { background: rgba(243, 201, 105, 0.1); color: var(--warn); box-shadow: inset 2px 0 0 var(--warn); }
.sim-node.fellback .sim-node-s { background: var(--warn); }
.sim-node.failed { background: rgba(255, 107, 94, 0.1); color: var(--bad); box-shadow: inset 2px 0 0 var(--bad); }
.sim-node.failed .sim-node-s { background: var(--bad); }

.sim-view { padding: 1.15rem 1.25rem 1.3rem; min-width: 0; }
.sim-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.sim-head h4 { font-size: 1.15rem; }
.sim-lane {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.25rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--dim);
}
.sim-lane.det { color: var(--lime); border-color: rgba(122,168,255,0.4); }
.sim-lane.llm { color: var(--sig); border-color: rgba(122,168,255,0.4); border-style: dashed; }
.sim-lane.warn { color: var(--warn); border-color: rgba(243,201,105,0.45); }
.sim-lane.bad { color: var(--bad); border-color: rgba(255,107,94,0.45); }
.sim-text { color: var(--muted); margin: 0.6rem 0 0; max-width: 62ch; }

.sim-io {
  display: flex; align-items: stretch; gap: 0.6rem; flex-wrap: wrap;
  margin-top: 1rem;
}
.sim-io-cell {
  flex: 1 1 240px; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.6rem 0.75rem; background: #131313;
}
.sim-io-cell span {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 0.25rem;
}
.sim-io-cell code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; color: var(--text); word-break: break-word;
}
.sim-io-cell.out { border-color: rgba(122,168,255,0.35); }
.sim-io-cell.out code { color: var(--sig); }
.sim-io-arrow { align-self: center; color: var(--dim); }

.sim-log {
  margin-top: 0.9rem;
  border-radius: 10px;
  background: #0a0a0a;
  border: 1px solid var(--line);
  padding: 0.7rem 0.85rem;
  min-height: 7.4rem;
  max-height: 11rem;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.75;
  color: var(--muted);
}
.sim-line { animation: simIn 0.24s ease-out both; }
@keyframes simIn { from { opacity: 0; transform: translateY(4px); } }
.sim-caret { color: var(--sig); }

.sim-meters {
  display: flex; gap: 1.6rem; flex-wrap: wrap;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--line);
}
.sim-meter b {
  display: block;
  font-family: var(--head); font-size: 1.5rem; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sim-meter span {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim);
}
.sim-legend {
  display: flex; gap: 1.2rem; flex-wrap: wrap;
  padding: 0.75rem 1.25rem 0.95rem;
  border-top: 1px solid var(--line);
  font-size: 0.76rem; color: var(--dim);
}
.sim-legend i { font-style: normal; display: inline-flex; align-items: center; gap: 0.4rem; }
.sim-legend .swatch { width: 14px; height: 10px; border-radius: 3px; border: 1px solid var(--lime); }
.sim-legend .swatch.llm { border-style: dashed; border-color: var(--sig); }
.sim-hint { margin-left: auto; opacity: 0.75; }
@media (max-width: 780px) { .sim-hint { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .sim-prog span, .sim-line, .sim.is-playing .sim-dot { transition: none; animation: none; }
}


/* =====================================================================
   READING LAYER
   Long pages need handholds: how far in you are, where the sections are,
   and a way to skim before committing. None of this edits the copy.
   ===================================================================== */
.rp {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60;
  background: rgba(255, 255, 255, 0.06);
}
.rp-fill {
  display: block; height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: left center;
  background: linear-gradient(90deg, rgba(122,168,255,0.5), var(--sig));
}

/* Section nav. Fixed on wide screens where there is a margin to spare, and
   simply absent on narrow ones rather than stealing space from the text. */
.toc {
  position: fixed; z-index: 55;
  top: 50%; right: 1.4rem; transform: translateY(-50%);
  max-width: 210px;
}
.toc-label {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 0.5rem;
}
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.toc a {
  display: block;
  font-size: 0.78rem; line-height: 1.3;
  color: var(--dim); text-decoration: none;
  padding: 0.32rem 0 0.32rem 0.7rem;
  border-left: 2px solid var(--line);
  transition: color 0.25s ease, border-color 0.25s ease, padding-left 0.25s ease;
}
.toc a:hover { color: var(--text); }
.toc a.on { color: var(--sig); border-left-color: var(--sig); padding-left: 0.95rem; }
@media (max-width: 1280px) { .toc { display: none; } }

.totop {
  position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 55;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer; font-size: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.25s ease;
  transform: translateY(8px);
}
.totop.on { opacity: 1; pointer-events: auto; transform: translateY(0); }
.totop:hover { border-color: var(--sig); color: var(--sig); }

/* The first paragraph carries the point, so it is set larger. */
.lead-p {
  font-size: 1.18rem;
  line-height: 1.6;
  color: var(--text);
}

/* Everything past the second paragraph folds away until asked for. */
.fold {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  opacity: 0;
}
.fold > * { overflow: hidden; }
.fold.open { grid-template-rows: 1fr; opacity: 1; }
.fold-btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  margin-top: 0.9rem;
  font: inherit; font-size: 0.82rem;
  padding: 0.45rem 0.95rem; min-height: 38px;
  border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease;
}
.fold-btn:hover { border-color: var(--sig); color: var(--sig); }
.fold-btn i {
  font-style: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem; color: var(--dim);
}
.fold-btn::after {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.3s ease;
}
.fold-btn[aria-expanded="true"]::after { transform: rotate(-135deg) translate(-2px, -2px); }

/* Section reveals. */
.rv { opacity: 0; transform: translateY(16px); transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.16, 1, 0.3, 1); }
.rv.in { opacity: 1; transform: none; }
.fact b { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .rv, .fold, .totop, .rp-fill { transition: none; }
}


/* =====================================================================
   RESPONSIVE - case-study pages
   ===================================================================== */
:root {
  --page-x: clamp(18px, 5vw, 40px);
}
.wrap { padding: 0 var(--page-x); }

@media (max-width: 900px) {
  .hero h1 { font-size: clamp(2.1rem, 9vw, 3.6rem); line-height: 1.04; }
  .hero .plain { font-size: clamp(1rem, 3.9vw, 1.2rem); }
  section h2 { font-size: clamp(1.45rem, 6vw, 2.2rem); }
  .lede { font-size: clamp(0.95rem, 3.7vw, 1.1rem); }
  .callout .quote { font-size: clamp(1.15rem, 5vw, 1.6rem); }
  .facts { gap: 1rem; }
  .fact b { font-size: clamp(1.6rem, 7vw, 2.4rem); }
}

/* The bar collapses to two rows rather than squeezing the label. */
@media (max-width: 560px) {
  .bar-in { flex-wrap: wrap; gap: 0.6rem; }
  .bar-links { width: 100%; }
  .bar-links .btn, .bar-links .tag { width: 100%; text-align: center; }
  .tags { gap: 0.4rem; }
  .tag { font-size: 0.66rem; padding: 0.3rem 0.5rem; }
  .pager { flex-direction: column; gap: 0.5rem; text-align: center; }
}

/* Simulator: the rail becomes a scrollable strip, the console keeps its
   payload panels stacked so nothing is squeezed to a sliver. */
@media (max-width: 780px) {
  .sim-top { padding: 0.75rem 0.85rem; }
  .sim-ctl { width: 100%; }
  .sim-btn { flex: 1 1 auto; text-align: center; }
  .sim-view { padding: 1rem 0.95rem 1.1rem; }
  .sim-head h4 { font-size: 1.02rem; }
  .sim-io { flex-direction: column; gap: 0.45rem; }
  /* flex-basis becomes the HEIGHT once the axis flips, so the 240px basis was
     turning each payload cell into a 240px-tall empty box. */
  .sim-io-cell { flex: 0 0 auto; width: 100%; }
  .sim-io-arrow { transform: rotate(90deg); align-self: flex-start; margin: -2px 0 -2px 6px; }
  .sim-log { min-height: 6rem; font-size: 0.72rem; }
  .sim-meters { gap: 1.1rem; padding: 0.8rem 0.95rem; }
  .sim-meter b { font-size: 1.25rem; }
  .sim-legend { padding: 0.7rem 0.95rem 0.85rem; font-size: 0.7rem; }
}
@media (max-width: 480px) {
  .sim-node { padding: 0.5rem 0.6rem; font-size: 0.8rem; }
  .sim-title { font-size: 0.7rem; }
}

/* Touch targets on the reading layer. */
@media (pointer: coarse) {
  .toc a, .fold-btn, .btn, .sim-btn, .back, .pager a { min-height: 44px; display: inline-flex; align-items: center; }
  .sim-node { min-height: 44px; }
}
