/* ── Tokens ── */
:root {
  color-scheme: light;
  --paper: #f7f3ec;
  --card: #fffdf9;
  --ink: #1f1a16;
  --ink-2: #463b32;
  --muted: #64574b;
  --line: #d9cdbd;
  --accent: #9a3d2f;
  --accent-soft: #f3e0d9;
  --on-accent: #ffffff;
  --bad: #9b1c1c;
  --bad-soft: #fdecea;
  --bad-line: #b42318;
  --good: #14532d;
  --good-soft: #e3f4e8;
  --good-line: #1d7a45;
  --warn: #7a4a00;
  --warn-soft: #fdf1d8;
  --info: #1e3a5f;
  --info-soft: #e6eef8;
  --term-bg: #1f1b18;
  --term-ink: #f4ede4;
  --term-muted: #c2b6a8;
  --term-bad: #ffa59b;
  --term-good: #a6e3ad;
  --term-info: #a9c9f5;
  --term-warn: #ffd88a;
  --radius: 0.6rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --hog-base: clamp(140px, 20vh, 220px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
}

p,
ul,
ol,
pre,
figure,
h2 {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

#headline:focus {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 20;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ── Buttons ── */
.primary,
.nav,
.ghost,
.scene-action {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.nav,
.scene-action {
  background: var(--card);
  color: var(--accent);
}

.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-2);
}

button:disabled,
.scene-action[aria-disabled="true"] {
  cursor: default;
}

.nav:disabled {
  border-color: var(--line);
  color: var(--muted);
}

.scene-action[aria-disabled="true"] {
  border-color: var(--good-line);
  background: var(--good-soft);
  color: var(--good);
}

/* ── Shell (mobile first) ── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 56px;
  padding: 0.4rem 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.lesson-title,
.act-label {
  display: none;
}

.lesson-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

/* Phones show the compact label instead, so the page's h1 stays for screen readers only. */
@media (max-width: 767px) {
  .lesson-title {
    position: absolute;
    display: block;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* The series title links back to the landing page. */
.lesson-title a {
  color: inherit;
  text-decoration: none;
}

.lesson-title a:hover {
  text-decoration: underline;
}

.act-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.compact-label {
  display: grid;
  min-width: 0;
  font-weight: 700;
  line-height: 1.15;
}

.compact-phase {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

/* Up to two lines, so a phone shows "3/12 · Pre-commit hook" instead of "3/12 · Pre-…". */
.compact-step {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.9rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.topbar .ghost {
  flex: none;
  padding: 0.5rem 0.7rem;
  white-space: nowrap;
}

.topbar .ghost:first-of-type {
  margin-left: auto;
}

.rail {
  display: none;
}

.stage {
  display: grid;
  gap: 1rem;
  padding: 1rem 16px;
}

/* ── Journey strip ── */
.rail {
  position: relative;
  height: 64px;
  padding: 0 16px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  scrollbar-width: thin;
}

.rail-list,
.act-stages,
.map-list {
  list-style: none;
  padding: 0;
}

.rail-list {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  height: 100%;
  width: max-content;
  min-width: 100%;
  justify-content: center;
  padding-bottom: 2px;
}

.rail-act {
  display: grid;
  gap: 0;
  padding: 0 0.25rem;
  border-left: 1px solid var(--line);
}

.rail-act:first-of-type {
  border-left: 0;
}

.act-name {
  padding-left: 0.4rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.act-stages {
  display: flex;
}

.rail-node {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.15rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0.15rem 0.3rem;
  border: 0;
  border-radius: 0.4rem;
  background: transparent;
  cursor: pointer;
}

.node-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: var(--card);
}

.node-label {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.rail-node.is-past .node-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.rail-node.is-past .node-label {
  color: var(--ink-2);
}

.rail-node.is-current .node-dot {
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--card);
}

.rail-node.is-current .node-label {
  color: var(--ink);
  font-weight: 700;
}

.rail-node:hover .node-label {
  text-decoration: underline;
}

.rail-cap .node-dot {
  width: 10px;
  height: 10px;
}

.rail-cap .rail-node.is-current .node-dot {
  width: 18px;
  height: 18px;
}

.key-glyph {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  color: var(--accent);
  pointer-events: none;
  transform: translate(calc(var(--x, -40px) - 50%), calc(var(--y, 0px) - 50%));
  transition: transform 400ms ease-in-out;
}

.key-glyph .icon {
  width: 100%;
  height: 100%;
  stroke-width: 3;
}

/* ── Scene canvas ── */
/* The panel comes first in the DOM so the headline is read before the scene.
   On phones the story starts above the scene: see "Phones: story, then scene" at the end of this file. */
.scene-col {
  order: -1;
  min-width: 0;
}

.canvas {
  /* The hog stays one size on every step. */
  --hog-w: calc(var(--hog-base) * 0.5);
  position: relative;
  min-height: 18rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.5);
  background: linear-gradient(180deg, var(--card) 0%, #f3ece1 100%);
  overflow: hidden;
}

.scene-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 0.9rem;
  padding: 3.5rem 1rem calc(var(--hog-w) * 0.71 + 1.5rem);
}

.chip {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem 0.3rem 0.55rem;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: var(--card);
  font-size: 0.9rem;
  font-weight: 700;
}

.chip[data-chip="none"] {
  display: none;
}

.chip[data-chip="exposed"],
.chip[data-chip="missed"],
.chip[data-chip="spreading"],
.chip[data-chip="shared"],
.chip[data-chip="copied"],
.chip[data-chip="live"] {
  color: var(--bad);
  background: var(--bad-soft);
}

.chip[data-chip="detected"],
.chip[data-chip="assessed"] {
  color: var(--warn);
  background: var(--warn-soft);
}

.chip[data-chip="assigned"] {
  color: var(--info);
  background: var(--info-soft);
}

.chip[data-chip="rotated"],
.chip[data-chip="confirmed"] {
  color: var(--good);
  background: var(--good-soft);
}

.icon {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.chip[data-chip="live"] .icon {
  fill: currentColor;
}

/* ── Frames ── */
.frame {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgb(31 26 22 / 8%);
  overflow: hidden;
}

.frame-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 0.82rem;
  font-weight: 600;
}

.frame-title::before {
  content: "";
  width: 2.2rem;
  height: 0.55rem;
  flex: none;
  background: radial-gradient(circle, var(--line) 0.26rem, transparent 0.28rem) 0 0 / 0.75rem 0.55rem repeat-x;
}

.frame-terminal,
.frame-editor {
  background: var(--term-bg);
  border-color: var(--term-bg);
}

.frame-terminal .frame-title,
.frame-editor .frame-title {
  background: #2c2622;
  border-color: #2c2622;
  color: var(--term-muted);
}

.code {
  padding: 0.85rem 1rem;
  color: var(--term-ink);
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code .line {
  display: block;
}

.code .tone-bad {
  color: var(--term-bad);
}

.code .tone-good {
  color: var(--term-good);
}

/* Info lines need a light blue on the dark terminal; the page's --info is a dark navy. */
.code .tone-info {
  color: var(--term-info);
}

.code .tone-warn {
  color: var(--term-warn);
}

.code .tone-muted {
  color: var(--term-muted);
  font-style: italic;
}

.lines {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  list-style: none;
}

.lines .line {
  display: grid;
  grid-template-columns: 1.2rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: baseline;
  overflow-wrap: anywhere;
}

.mark {
  font-weight: 800;
  text-align: center;
}

.tone-bad {
  color: var(--bad);
}

.tone-good {
  color: var(--good);
}

.tone-warn {
  color: var(--warn);
}

.tone-info {
  color: var(--info);
}

.tone-muted {
  color: var(--muted);
}

.frame-intro .lines .line:first-child {
  grid-template-columns: minmax(0, 1fr);
  font-size: 1.25rem;
  padding-bottom: 0.35rem;
}

.frame-intro .lines .line:first-child .mark {
  display: none;
}

.scene-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  justify-self: start;
}

.scene-actions.rotate-action {
  justify-content: center;
  justify-self: center;
}

.rotate-action .scene-action {
  justify-self: center;
  min-height: 52px;
  padding: 0.7rem 1.6rem;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.1rem;
}

/* ── Key pills ── */
.key-pill {
  display: inline;
  padding: 0.08em 0.3em 0.08em 0.4em;
  border: 2px solid;
  border-radius: 0.4em;
  font-family: var(--mono);
  font-size: 0.92em;
  font-weight: 600;
  overflow-wrap: anywhere;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.key-pill code {
  font: inherit;
  overflow-wrap: anywhere;
}

.key-tag {
  margin-left: 0.35em;
  padding: 0 0.3em;
  border-radius: 0.25em;
  font-family: var(--font);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.key-old {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
}

.key-old .key-tag {
  background: var(--bad-line);
  color: #ffffff;
}

.key-new {
  border-color: var(--good-line);
  background: var(--good-soft);
  color: var(--good);
}

.key-new .key-tag {
  background: var(--good-line);
  color: #ffffff;
}

/* ── Rotation ── */
.frame-rotate {
  display: grid;
}

.rotate-keys {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
  align-items: center;
  padding: 1rem;
}

.rk {
  display: grid;
  gap: 0.3rem;
  justify-items: start;
}

.rk-arrow {
  color: var(--muted);
  font-size: 1.4rem;
  transform: rotate(90deg);
  justify-self: center;
}

.key-state {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-2);
}

.key-slot {
  padding: 0.35rem 0.7rem;
  border: 2px dashed var(--line);
  border-radius: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.rotate-keys.is-rotated .rk-old .key-pill {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.rotate-keys.is-rotated .rk-old .key-state {
  color: var(--bad);
}

.rotate-keys.is-rotated .rk-new .key-state {
  color: var(--good);
}

.rotate-steps {
  display: grid;
  gap: 0.4rem;
  margin: 0 1rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--paper);
  list-style: none;
  counter-reset: step;
}

.rotate-steps li {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  overflow-wrap: anywhere;
  counter-increment: step;
}

.rotate-steps .mark {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--muted);
  border-radius: 50%;
  font-size: 0.8rem;
}

.rotate-steps li:not(.is-done) .mark::before {
  content: counter(step);
  color: var(--muted);
}

.rotate-steps li.is-done .mark {
  border-color: var(--good-line);
  background: var(--good-line);
  color: #ffffff;
}

/* ── Images ── */
.scene-figure {
  justify-self: start;
}

.scene-figure img {
  display: block;
  width: 160px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius);
}

.img-fallback {
  display: grid;
  place-items: center;
  width: 160px;
  min-height: 100px;
  padding: 0.5rem;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.img-fallback[hidden] {
  display: none;
}

/* ── Mascot ── */
.mascot {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 1;
  width: var(--hog-w);
  transition: left 300ms ease-out;
  pointer-events: none;
}

.mascot svg {
  display: block;
  width: 100%;
  height: auto;
}

.mascot.is-center {
  left: calc(50% - var(--hog-w) / 2);
}

.mascot.is-settled svg {
  transform: rotate(-4deg);
  transform-origin: 50% 100%;
}

/* ── Narrative panel ── */
/* Positioned so screen-reader-only text inside it stays inside its scroll box
   instead of stretching the page and scrolling it when a Copy button takes focus. */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
}

.eyebrow {
  display: grid;
  gap: 0.1rem;
}

.eyebrow-stage {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.eyebrow-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.eyebrow-sub::first-letter {
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.story {
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.takeaway {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--good-line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--good-soft);
  color: var(--good);
  font-size: 1.05rem;
  font-weight: 700;
}

.bridge {
  padding: 0.5rem 0.85rem;
  border-left: 4px solid var(--info);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--info-soft);
  color: var(--ink-2);
  font-size: 0.92rem;
}

.bridge strong {
  color: var(--info);
}

.why,
.try {
  color: var(--ink-2);
  font-size: 0.95rem;
}

.why strong,
.try strong {
  color: var(--ink);
}

/* The same finding, read by the key's owner or by the security team. */
.perspective {
  display: grid;
  gap: 0.4rem;
  justify-items: start;
}

.perspective-head {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.perspective-text {
  margin: 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--accent);
  color: var(--ink-2);
  font-size: 0.95rem;
}

@media (pointer: coarse) {
  .perspective .seg {
    min-height: 44px;
  }
}

.more summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.25rem;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.more-body {
  display: grid;
  gap: 0.5rem;
  max-height: 8.5rem;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.more-source {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── SDLC tag, tools, and teams ── */
.phase-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  min-height: 32px;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--info);
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.phase-tag::after {
  content: "›";
  font-weight: 800;
}

.phase-kicker {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.real {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 0.9rem;
}

.real-part {
  display: grid;
  gap: 0.4rem;
}

.real-head,
.phase-facts dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tools,
.phase-facts {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.tool-group {
  display: grid;
  gap: 0.2rem;
}

.tool-group dt {
  color: var(--ink-2);
  font-weight: 600;
}

.tools dd,
.phase-facts dd {
  margin: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 0.82rem;
}

.roles {
  display: grid;
  gap: 0.3rem;
  padding: 0;
  list-style: none;
}

.roles strong {
  color: var(--ink);
}

.roles span {
  color: var(--ink-2);
}

.roles li {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.roles-mode {
  margin: 0.6rem 0 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Research evidence under a block ── */
.evidence {
  margin: 0;
  padding: 0.5rem 0.6rem;
  border-left: 3px solid var(--info);
  border-radius: 0.3rem;
  background: var(--info-soft);
  color: var(--ink);
  font-size: 0.86rem;
}

.evidence-kind {
  display: block;
  color: var(--info);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.evidence-source {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ── What sits behind the key, and which key first ── */
.behind,
.priority {
  display: grid;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.behind h3,
.priority h3 {
  margin: 0;
  font-size: 1rem;
}

.behind-intro,
.priority-intro {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.9rem;
}

.behind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.5rem;
  margin: 0;
}

.behind-grid > div {
  padding: 0.5rem 0.6rem;
  border-radius: 0.4rem;
  background: var(--paper);
}

.behind-grid dt {
  margin-bottom: 0.15rem;
}

.behind-label {
  font-weight: 700;
}

.behind-ask {
  color: var(--muted);
  font-size: 0.82rem;
}

.behind-grid dd {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.88rem;
}

.priority-list {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0 0 0 1.4rem;
}

.priority-item {
  padding: 0.45rem 0.6rem;
  border-left: 3px solid var(--line);
  border-radius: 0.3rem;
  background: var(--paper);
  font-size: 0.88rem;
}

.priority-item p {
  margin: 0;
}

.priority-item.is-now {
  border-left-color: var(--bad-line);
}

.priority-item.is-soon {
  border-left-color: var(--warn);
}

.priority-item.is-here {
  outline: 1px solid var(--bad-line);
}

.priority-key {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.priority-here {
  margin-left: 0.25rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 0.72rem;
  font-weight: 700;
}

.priority-verdict {
  display: inline-block;
  margin-right: 0.25rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
}

.is-now .priority-verdict {
  background: var(--bad-soft);
  color: var(--bad);
}

.is-soon .priority-verdict {
  background: var(--warn-soft);
  color: var(--warn);
}

.priority-meta {
  color: var(--ink-2);
}

/* ── How it often goes: the messy version, told by the cast ── */
.usual {
  display: grid;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-soft);
}

.usual p {
  margin: 0;
}

.usual-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: baseline;
}

.usual-kind {
  color: var(--warn);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.usual-title {
  font-weight: 700;
}

.usual-text {
  color: var(--ink-2);
  font-size: 0.92rem;
}

.usual-thread {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.usual-thread li {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.usual-thread .avatar {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.66rem;
}

.usual-turn {
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

/* ── Cast: the same people in every part ── */
.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1.5px solid currentcolor;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.ring-build {
  background: var(--accent-soft);
  color: var(--accent);
}

.ring-run {
  background: var(--warn-soft);
  color: var(--warn);
}

.ring-secure {
  background: var(--good-soft);
  color: var(--good);
}

.ring-lead {
  background: var(--info-soft);
  color: var(--info);
}

.ring-machine {
  border-radius: 0.35rem;
  background: var(--paper);
  color: var(--ink-2);
}

.ring-outside {
  border-style: dashed;
  background: var(--bad-soft);
  color: var(--bad);
}

.cast-strip {
  display: grid;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.cast-head {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: space-between;
}

.cast-kicker,
.cast-mode {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cast-doing,
.cast-chips,
.cast-cards,
.cast-steps,
.cast-recap-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cast-doing {
  display: grid;
  gap: 0.35rem;
}

.cast-person {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  width: 100%;
  padding: 0.2rem;
  border: 0;
  border-radius: 0.4rem;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cast-person:hover {
  background: var(--paper);
}

.cast-text {
  font-size: 0.9rem;
  line-height: 1.35;
}

.cast-name {
  font-weight: 700;
}

.cast-title {
  color: var(--muted);
  font-size: 0.82rem;
}

.cast-does {
  display: block;
  color: var(--ink-2);
}

.cast-row {
  display: grid;
  gap: 0.3rem;
}

.cast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.cast-chip {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.15rem 0.6rem 0.15rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.cast-chip .avatar {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.66rem;
}

.cast-chip:hover {
  border-color: var(--ink-2);
}

.cast-ring h3 {
  margin: 0;
  font-size: 1rem;
}

.cast-ring-text {
  margin: 0.15rem 0 0.6rem;
  color: var(--muted);
}

.cast-cards {
  display: grid;
  gap: 0.75rem;
}

.cast-card {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cast-card p {
  margin: 0 0 0.3rem;
}

.cast-card.is-absent {
  opacity: 0.7;
}

.cast-card.is-focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.cast-card-name span {
  color: var(--muted);
}

.cast-hard {
  color: var(--ink-2);
}

.cast-absent {
  color: var(--muted);
  font-style: italic;
}

.cast-steps {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.4rem;
  font-size: 0.86rem;
}

.cast-steps li {
  display: grid;
  grid-template-columns: minmax(5.5rem, 7.5rem) 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.cast-steps .cast-step {
  justify-self: start;
  padding: 0;
  text-align: left;
}

.cast-recap-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  margin: 0.15rem 0 0;
  padding: 0;
  font-size: 0.86rem;
  list-style: none;
}

.cast-recap-steps .cast-step {
  padding: 0;
}

.cast-step {
  font-weight: 600;
}

.cast-step-does {
  color: var(--ink-2);
}

.cast-step-mode {
  display: inline-block;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.75rem;
}

.cast-recap {
  margin: 1rem 0;
}

.cast-recap h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.cast-recap-list {
  display: grid;
  gap: 0.45rem;
}

.cast-recap-list > li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}

.cast-recap-name {
  font-weight: 700;
}

/* ── Limits and process ── */
.limits {
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-soft);
}

.limits.process {
  border-color: var(--good-line);
  background: var(--good-soft);
}

.limits-list {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0 1rem 0.9rem 2.1rem;
  color: var(--ink-2);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.limits-head {
  padding: 0.6rem 0.9rem 0.4rem;
  color: var(--warn);
  font-weight: 700;
}

.limits.process .limits-head {
  color: var(--good);
}

.tabpanel > .limits + .limits {
  margin-top: 0.6rem;
}

/* ── Panel tabs ── */
.tabs {
  display: grid;
  gap: 0.6rem;
}

.tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 40px;
  margin-bottom: -1px;
  padding: 0.35rem 0.8rem;
  border: 1px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  border-color: var(--line);
  border-bottom-color: var(--paper);
  background: var(--paper);
  color: var(--accent);
}

.tabpanel {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.tabpanel[hidden] {
  display: none;
}

/* ── Integration layers: family row → details → integration ── */
.integrations {
  display: grid;
  gap: 0.45rem;
}

.int-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.layer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.layer > summary {
  position: relative;
  display: grid;
  gap: 0.2rem;
  padding: 0.6rem 2.2rem 0.6rem 0.85rem;
  list-style: none;
  cursor: pointer;
}

.layer > summary::-webkit-details-marker {
  display: none;
}

.layer > summary::after {
  content: "›";
  position: absolute;
  top: 0.55rem;
  right: 0.85rem;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  transition: transform 150ms ease-out;
}

.layer[open] > summary::after {
  transform: rotate(90deg);
}

.layer > summary:hover {
  background: var(--paper);
}

.layer-body {
  display: grid;
  gap: 0.5rem;
  padding: 0 0.85rem 0.8rem;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.layer-title {
  color: var(--ink);
  font-weight: 800;
}

.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow li {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.75rem;
  font-weight: 700;
}

.flow li:not(:last-child)::after {
  content: " →";
  color: var(--muted);
}

.flow-detail {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-2);
}

.flow-note {
  color: var(--accent);
  font-weight: 600;
}

.fam-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.fam-name {
  margin-right: auto;
  color: var(--ink);
  font-weight: 800;
}

.fam-summary {
  color: var(--ink-2);
  font-size: 0.86rem;
}

.fam-facts,
.int-facts {
  display: grid;
  gap: 0.4rem;
  margin: 0;
}

.fam-facts > div,
.int-facts > div {
  display: grid;
  gap: 0.1rem;
}

.fam-facts dt,
.int-facts dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.places {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 0.85rem;
}

.places-lead {
  margin: 0;
  color: var(--ink-2);
}

.places-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 0.82rem;
}

.places-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.place-group > summary {
  align-items: center;
}

.place-sum {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}

.place-count {
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.place-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0 0.85rem 0.8rem;
  list-style: none;
}

.place {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 0.6rem;
  align-items: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.place:first-child {
  padding-top: 0;
  border-top: 0;
}

.place-name {
  color: var(--ink);
  font-weight: 800;
}

.place p {
  grid-column: 1 / -1;
  color: var(--ink-2);
  font-size: 0.86rem;
}

.place-seen {
  padding: 0.08rem 0.45rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}

.place-seen-read {
  background: var(--good-soft);
  color: var(--good);
}

.place-seen-optional {
  background: var(--warn-soft);
  color: var(--warn);
}

.place-seen-skipped {
  background: var(--paper);
  color: var(--muted);
}

.fam-facts dd,
.int-facts dd {
  margin: 0;
  color: var(--ink-2);
}

.int-list {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.int {
  background: var(--paper);
}

.int > summary {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.int-name {
  color: var(--ink);
  font-weight: 700;
}

.int-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.int-use {
  color: var(--ink-2);
  font-size: 0.84rem;
}

.int-facts {
  padding: 0 0.85rem 0.7rem;
  font-size: 0.85rem;
}

.fam-uses {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink-2);
}

.pill {
  padding: 0.05rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill-good {
  background: var(--good-soft);
  color: var(--good);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill-info {
  background: var(--info-soft);
  color: var(--info);
}

.pill-muted {
  background: var(--paper);
  color: var(--muted);
}

/* ── SDLC loop diagram ── */
.loop {
  margin: 0;
}

.loop svg {
  display: block;
  width: 100%;
  height: auto;
}

.loop-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}

.loop-ring-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.loop-arrow {
  stroke: var(--muted);
  stroke-width: 2;
}

.loop-headshape {
  fill: var(--muted);
}

.loop-node rect {
  fill: var(--card);
  stroke: var(--line);
  stroke-width: 1.5;
}

.loop-node circle {
  fill: var(--ink-2);
}

.loop-num {
  fill: var(--card);
  font-size: 10px;
  font-weight: 800;
  text-anchor: middle;
}

.loop-label {
  fill: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}

.loop-node.is-current rect {
  fill: var(--info-soft);
  stroke: var(--info);
  stroke-width: 2.5;
}

.loop-node.is-current circle {
  fill: var(--info);
}

.loop-node.is-current .loop-label {
  fill: var(--info);
}

.loop-center {
  fill: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}

.loop-center-sub {
  fill: var(--muted);
  font-weight: 500;
}

.sdlc-list .phase {
  position: relative;
}

.sdlc-list .phase:not(:last-child)::after {
  content: "↓";
  position: absolute;
  bottom: -0.95rem;
  left: 50%;
  z-index: 1;
  padding: 0 0.4rem;
  background: var(--card);
  color: var(--muted);
  font-weight: 800;
  line-height: 1;
  transform: translateX(-50%);
}

.sdlc-list .phase:last-child::after {
  content: "↻ back to Plan for the next change";
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.sdlc-list {
  gap: 1.1rem;
}

/* ── Code security tools (SDLC sheet) ── */
.sec-tools {
  display: grid;
  gap: 0.6rem;
}

.sheet-head {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

.sec-list {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.sec-type {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sec-phase {
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ── Where TruffleHog fits ── */
.th {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.9rem;
}

.th-rows {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.th-row {
  display: grid;
  gap: 0.15rem;
}

.th-row dt {
  color: var(--accent);
  font-weight: 800;
}

.th-row dd {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.th-command {
  justify-self: start;
  max-width: 100%;
  padding: 0.15rem 0.45rem;
  border-radius: 0.3rem;
  background: var(--term-bg);
  color: var(--term-ink);
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.th-source {
  color: var(--muted);
  font-size: 0.78rem;
}

.th-note {
  color: var(--accent);
  font-weight: 600;
}

/* ── Side leaks ── */
.leak {
  border: 1px solid var(--bad-line);
  border-radius: var(--radius);
  background: var(--bad-soft);
}

.leak > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.5rem;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  color: var(--bad);
  cursor: pointer;
}

.leak-badge {
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--bad-line);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
}

.leak-label {
  font-weight: 700;
}

.leak-tools {
  color: var(--ink-2);
  font-size: 0.85rem;
}

.leak-body {
  display: grid;
  gap: 0.6rem;
  padding: 0.25rem 0.9rem 0.9rem;
  color: var(--ink-2);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.leak-title {
  color: var(--ink);
  font-weight: 700;
}

.leak-body strong {
  color: var(--ink);
}

.chat {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  list-style: none;
}

.msg {
  display: grid;
  gap: 0.1rem;
}

.msg-who {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}

.msg-note {
  font-size: 0.82rem;
}

/* ── SDLC side sheet ── */
.side-sheet {
  width: 100%;
  max-width: 100%;
  max-height: 85dvh;
  margin: auto 0 0;
  padding: 0 0 env(safe-area-inset-bottom);
  border: 0;
  border-radius: 1rem 1rem 0 0;
  background: var(--card);
  color: var(--ink);
}

.side-sheet::backdrop {
  background: rgb(31 26 22 / 45%);
}

.sdlc-body {
  display: grid;
  gap: 1rem;
  padding: 1rem 16px 1.5rem;
  font-size: 0.92rem;
}

.sdlc-intro {
  color: var(--ink-2);
}

.sdlc-list {
  display: grid;
  gap: 0.6rem;
  padding: 0;
  list-style: none;
  counter-reset: phase;
}

.phase,
.around {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  counter-increment: phase;
}

.phase.is-current {
  border: 2px solid var(--info);
  background: var(--info-soft);
}

.phase-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 700;
}

.phase .phase-name::before {
  content: counter(phase);
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--ink-2);
  color: var(--card);
  font-size: 0.75rem;
}

.phase.is-current .phase-name::before {
  background: var(--info);
}

.here {
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--info);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
}

.phase-facts > div {
  display: grid;
  gap: 0.15rem;
}

.around {
  border-style: dashed;
  background: var(--paper);
}

/* ── Control bar ── */
.controls {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 72px;
  padding: 0.75rem 16px calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
}

.controls button {
  min-height: 48px;
}

.count {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.controls .primary {
  max-width: 60%;
}

/* ── Map sheet ── */
.map-sheet {
  width: 100%;
  max-width: 100%;
  max-height: 85dvh;
  margin: auto 0 0;
  padding: 0 0 env(safe-area-inset-bottom);
  border: 0;
  border-radius: 1rem 1rem 0 0;
  background: var(--card);
  color: var(--ink);
}

.map-sheet::backdrop {
  background: rgb(31 26 22 / 45%);
}

.map-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 16px;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.map-title {
  font-weight: 700;
}

.map-list {
  display: grid;
  padding: 0.5rem 16px 1rem;
}

.map-list .rail-node {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 48px;
}

.map-list .node-label {
  font-size: 1rem;
}

/* ── Motion ── */
@keyframes scene-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes old-out {
  30% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes new-in {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  55% {
    opacity: 1;
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes glow {
  0% {
    box-shadow: 0 0 0 0 rgb(29 122 69 / 0%);
  }
  40% {
    box-shadow: 0 0 0 8px rgb(29 122 69 / 35%);
  }
  100% {
    box-shadow: 0 0 0 0 rgb(29 122 69 / 0%);
  }
}

@keyframes cheer {
  0%,
  100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-14%);
  }
  45% {
    transform: translateY(0);
  }
  65% {
    transform: translateY(-7%);
  }
}

.scene-body.enter,
.panel.enter {
  animation: scene-in 240ms ease-out;
}

.line.is-new {
  animation: reveal 240ms ease-out both;
}

.frame-recheck .line {
  animation: reveal 300ms ease-out both;
}

.frame-recheck .line:nth-child(2) {
  animation-delay: 700ms;
}

.frame-recheck .line:nth-child(3) {
  animation-delay: 1000ms;
}

.frame-recheck .line:nth-child(4) {
  animation-delay: 1300ms;
}

.app.is-rotating .canvas {
  animation: glow 1.2s ease-out;
}

.app.is-rotating .rk-old .key-pill {
  display: inline-block;
  animation: old-out 1.2s ease-out;
}

.app.is-rotating .rk-new .key-pill {
  display: inline-block;
  animation: new-in 1.2s ease-out;
}

.app.is-rotating .rotate-steps li.is-done {
  animation: reveal 300ms ease-out both;
}

.app.is-rotating .rotate-steps li:nth-child(2) {
  animation-delay: 300ms;
}

.app.is-rotating .rotate-steps li:nth-child(3) {
  animation-delay: 600ms;
}

.app.is-rotating .mascot svg {
  animation: cheer 1.2s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }

  .mascot.is-settled svg {
    transform: none;
  }
}

/* ── Tablet and up: full header, journey strip, left-docked mascot ── */
@media (min-width: 768px) {
  .lesson-title,
  .act-label {
    display: block;
  }

  .compact-label,
  .map-button {
    display: none;
  }

  .topbar .ghost:first-of-type {
    margin-left: 0;
  }

  .topbar [data-action="start-over"] {
    margin-left: auto;
  }

  .rail {
    display: block;
  }

  .canvas {
    min-height: 16rem;
  }

  .scene-body {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 3.5rem 1.25rem 1.25rem calc(var(--hog-w) + 1.75rem);
  }

  .scene-body > .frame,
  .scene-body > .scene-actions {
    grid-column: 1;
  }

  .scene-figure {
    grid-column: 2;
    grid-row: 1;
  }

  .canvas[data-frame="rotate"] .scene-body {
    grid-template-columns: minmax(0, 1fr);
    padding: 3.5rem 1.25rem calc(var(--hog-w) * 0.71 + 1.25rem);
  }

  .rotate-keys {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .rk-arrow {
    transform: none;
  }

  .stage {
    padding: 1.25rem 24px;
  }

  .side-sheet {
    width: min(440px, 100%);
    height: 100dvh;
    max-height: 100dvh;
    margin: 0 0 0 auto;
    border-radius: 0;
    border-left: 1px solid var(--line);
  }
}

/* ── Desktop: one full-viewport grid, no page scroll ── */
@media (min-width: 1080px) and (min-height: 600px) {
  .app {
    display: grid;
    grid-template-rows: 56px 64px minmax(0, 1fr) 72px;
    height: 100dvh;
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  .topbar {
    min-height: 0;
  }

  .stage {
    grid-template-columns: minmax(640px, 1fr) minmax(360px, 440px);
    gap: 1.5rem;
    min-height: 0;
    padding: 1rem 24px;
  }

  .scene-col {
    display: grid;
    place-items: center;
    min-height: 0;
    container-type: size;
  }

  .canvas {
    width: min(100cqw, 160cqh);
  }

  .panel {
    gap: 0.6rem;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
    align-self: center;
    max-height: 100%;
  }

  .more-body {
    max-height: 5.25rem;
  }

  .takeaway {
    padding: 0.55rem 0.9rem;
  }

  .controls {
    position: static;
    padding: 0 24px;
  }

  .controls .primary {
    min-width: 11rem;
  }
}

/* ── The safer way, secret managers, and keys kept on purpose ── */
.safer {
  border-color: var(--good-line);
  background: var(--good-soft);
}

.safer > summary {
  color: var(--good);
}

.safer .leak-badge {
  background: var(--good-line);
}

.group-note {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.stores {
  border-color: var(--good-line);
}

.key-notes {
  border-color: var(--info);
}

.store-difference {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-left: 4px solid var(--info);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--info-soft);
  color: var(--ink);
}

.store-kinds {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.store-kind {
  display: grid;
  gap: 0.2rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.store-kind dt {
  color: var(--ink);
  font-weight: 800;
}

.store-kind dd {
  display: grid;
  gap: 0.15rem;
  margin: 0;
}

.store-kind p {
  margin: 0;
}

.store-leaks {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0.6rem 0.75rem 0.6rem 1.35rem;
  border-left: 4px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--warn-soft);
  color: var(--ink-2);
}

/* ── Scan flow focus and command toggles ── */
.flow li.is-current {
  background: var(--info);
  color: #ffffff;
}

.flow-detail li.is-current {
  color: var(--ink);
  font-weight: 600;
}

.flow-hint {
  color: var(--muted);
  font-size: 0.78rem;
}

.th-cmd summary {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

/* ── SDLC phase card: where you are, in three plain lines ── */
.sdlc-body > .loop {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

/* On a short phone screen the card leads with the words, so the loop stays small. */
@media (max-width: 480px) {
  .sdlc-body > .loop {
    max-width: 230px;
  }
}

.side-sheet.is-guide .sdlc-body > .loop {
  max-width: 360px;
}

.phase-card {
  display: grid;
  gap: 0.75rem;
  /* Leave vertical scrolling to the browser so a sideways swipe can change phase. */
  touch-action: pan-y;
}

.phase-icon {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: var(--info-soft);
  color: var(--info);
}

.phase-name .phase-icon {
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.4rem;
  vertical-align: middle;
  font-size: 0.85rem;
}

.phase-step-nav,
.guide-open,
.guide-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.guide-open {
  justify-content: center;
}

.phase-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.phase-card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.phase-card-title:focus {
  outline: none;
}

.phase-card-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.phase-card-sub {
  margin: -0.4rem 0 0;
  color: var(--ink-2);
}

.phase-card-facts {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase-card-facts li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-left: 3px solid var(--line);
  border-radius: 0.4rem;
  line-height: 1.4;
}

.phase-card-facts li > .icon {
  margin-top: 0.15em;
}

.phase-card-facts strong {
  margin-right: 0.15rem;
}

.phase-card-facts .pc-slip {
  border-left-color: var(--bad-line);
  background: var(--bad-soft);
}

.phase-card-facts .pc-slip > .icon,
.phase-card-facts .pc-slip strong {
  color: var(--bad);
}

.phase-card-facts .pc-ai {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.phase-card-facts .pc-ai > .icon,
.phase-card-facts .pc-ai strong {
  color: var(--warn);
}

.phase-card-facts .pc-catch {
  border-left-color: var(--good-line);
  background: var(--good-soft);
}

.phase-card-facts .pc-catch > .icon,
.phase-card-facts .pc-catch strong {
  color: var(--good);
}

.ai-layer {
  gap: 0.45rem;
}

.ai-leaks {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding-left: 1.1rem;
}

.ai-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  justify-self: start;
}

.phase-card-step-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

.phase-card-step-list [aria-current="step"] {
  font-weight: 800;
  text-decoration: none;
}

.phase-card-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.phase-step-nav {
  min-height: 44px;
}

/* Only touch screens can swipe, so only they see the hint. */
.swipe-hint {
  display: none;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

@media (pointer: coarse) {
  .swipe-hint {
    display: block;
  }
}

.phase-back-here,
.guide-back {
  justify-self: start;
}

.guide-open {
  width: 100%;
}

.guide-head {
  margin: 0.5rem 0 0;
  font-size: 1rem;
}

.sdlc-intro:focus {
  outline: none;
}

/* ── Other names for the same loop ── */
.models-scroll {
  overflow-x: auto;
}

.models-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.models-table th,
.models-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.models-table thead th {
  color: var(--muted);
  font-size: 0.75rem;
}

/* ── Collapsible SDLC phases ── */
.phase-sum {
  display: grid;
  gap: 0.3rem;
  list-style: none;
  cursor: pointer;
}

.phase-sum::-webkit-details-marker {
  display: none;
}

.phase-details:not([open]) > .phase-sum::after {
  content: "Show details ›";
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.phase-details > :not(summary) {
  margin-top: 0.45rem;
}

/* ── Hover and press ── */
.primary,
.nav,
.ghost,
.scene-action,
.tab,
.phase-tag,
.node-dot {
  transition:
    background-color 120ms var(--ease-out-3),
    border-color 120ms var(--ease-out-3),
    color 120ms var(--ease-out-3),
    box-shadow 120ms var(--ease-out-3),
    transform 200ms var(--ease-spring-3);
}

@media (hover: hover) {
  .primary:not(:disabled):hover {
    border-color: color-mix(in srgb, var(--accent) 80%, #000000);
    background: color-mix(in srgb, var(--accent) 80%, #000000);
  }

  .nav:not(:disabled):hover,
  .scene-action:not([aria-disabled="true"]):hover {
    background: var(--accent-soft);
  }

  .ghost:hover {
    border-color: var(--ink-2);
    color: var(--ink);
  }

  .tab:not([aria-selected="true"]):hover {
    background: var(--card);
    color: var(--ink);
  }

  .phase-tag:hover {
    background: color-mix(in srgb, var(--info) 14%, var(--info-soft));
  }

  .rail-node:not(.is-current):hover .node-dot {
    border-color: var(--accent);
    transform: scale(1.2);
  }

  .int > summary:hover {
    background: var(--card);
  }

  .leak > summary:hover {
    background: color-mix(in srgb, var(--bad-line) 8%, transparent);
  }

  .safer > summary:hover {
    background: color-mix(in srgb, var(--good-line) 10%, transparent);
  }

  .more summary:hover,
  .th-cmd summary:hover,
  .phase-sum:hover,
  .kind > summary:hover {
    text-decoration: underline;
  }
}

.primary:not(:disabled):active,
.nav:not(:disabled):active,
.ghost:active,
.scene-action:not([aria-disabled="true"]):active {
  transform: translateY(1px);
}

/* ── One chevron for everything that opens ── */
.leak > summary {
  position: relative;
  padding-right: 2.2rem;
  border-radius: var(--radius);
  list-style: none;
}

.leak > summary::-webkit-details-marker,
.more summary::-webkit-details-marker,
.th-cmd summary::-webkit-details-marker {
  display: none;
}

.leak > summary::after,
.more summary::after,
.th-cmd summary::after {
  content: "›";
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  transition: transform 150ms ease-out;
}

.leak > summary::after {
  position: absolute;
  top: 50%;
  right: 0.85rem;
  margin-top: -0.6rem;
}

.more summary::after,
.th-cmd summary::after {
  margin-left: 0.35rem;
}

.leak[open] > summary::after,
.more[open] summary::after,
.th-cmd[open] summary::after {
  transform: rotate(90deg);
}

/* ── Opening a section ── */
.layer[open] > .layer-body,
.layer[open] > .int-facts,
.leak[open] > .leak-body,
.more[open] > .more-body,
.th-cmd[open] > code,
.phase-details[open] > :not(summary),
.tabpanel.enter {
  animation: reveal 220ms var(--ease-out-3);
}

.panel details {
  scroll-margin-top: 0.5rem;
  scroll-margin-bottom: calc(88px + env(safe-area-inset-bottom));
}

/* ── Status chip changes ── */
@keyframes chip-pop {
  0% {
    transform: scale(0.85);
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.chip.enter {
  animation: chip-pop 360ms var(--ease-out-4);
}

/* ── Steps slide the way the reader is moving ── */
@keyframes slide-next {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

@keyframes slide-prev {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
}

.stage {
  overflow-x: clip;
}

.app[data-dir="next"] .scene-body.enter,
.app[data-dir="next"] .panel.enter {
  animation-name: slide-next;
}

.app[data-dir="prev"] .scene-body.enter,
.app[data-dir="prev"] .panel.enter {
  animation-name: slide-prev;
}

.panel.enter {
  animation-delay: 40ms;
  animation-fill-mode: both;
}

/* ── More to read: fade the panel edge that hides content ── */
.panel {
  --fade-top: 0px;
  --fade-bottom: 0px;
}

.panel.has-above {
  --fade-top: 1.25rem;
}

.panel.has-more {
  --fade-bottom: 2.5rem;
}

.panel.has-above,
.panel.has-more {
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000000 var(--fade-top),
    #000000 calc(100% - var(--fade-bottom)),
    transparent 100%
  );
}

/* ── Sheets slide in over a fading backdrop ── */
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-left {
  from {
    transform: translateX(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.side-sheet[open],
.map-sheet[open] {
  animation: sheet-up 320ms var(--ease-out-5);
}

.side-sheet[open]::backdrop,
.map-sheet[open]::backdrop {
  animation: fade-in 200ms ease-out;
}

html:has(dialog[open]) {
  overflow: hidden;
}

@media (min-width: 768px) {
  .side-sheet[open] {
    animation-name: sheet-left;
  }
}

/* ── Copies of the key ── */
.copies {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  max-width: calc(100% - 10rem);
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--bad-line);
  border-radius: 999px;
  background: var(--card);
  color: var(--bad);
  font-size: 0.85rem;
  font-weight: 700;
}

.copies[hidden] {
  display: none;
}

.copies-num {
  display: inline-block;
  min-width: 1.2ch;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.copies-label {
  color: var(--ink-2);
  font-size: 0.78rem;
  font-weight: 600;
}

.copy-dots {
  display: none;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 7.5rem;
}

.copy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bad-line);
  transition: background-color 400ms var(--ease-out-3);
}

.copies[data-dead="true"] {
  border-color: var(--line);
  color: var(--muted);
}

.copies[data-dead="true"] .copy-dot {
  background: var(--line);
}

@media (min-width: 768px) {
  .copies-label {
    font-size: 0.85rem;
  }

  .copy-dots {
    display: inline-flex;
  }
}

/* ── Hog body, scan sweep, and sliding tab bar ── */
.hog-body {
  display: block;
  transform-origin: 50% 100%;
}

.frame.is-scanning {
  position: relative;
  overflow: hidden;
}

.scan-sweep {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5rem;
  background: linear-gradient(180deg, transparent, rgb(30 58 95 / 22%), transparent);
  pointer-events: none;
}

.tablist {
  position: relative;
}

.tab-ink {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  pointer-events: none;
}

.line.is-typing::after {
  content: "▍";
  margin-left: 1px;
  color: var(--accent);
  animation: blink 0.8s steps(1) infinite;
}

.frame-terminal .line.is-typing::after,
.frame-editor .line.is-typing::after {
  color: var(--term-ink);
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* With Motion running, it drives these instead of the CSS fallbacks. */
.app.fx .key-glyph {
  transition: none;
}

.app.fx .line.is-new,
.app.fx.is-rotating .mascot svg {
  animation: none;
}

/* ── Sections grow open and shrink closed (where the browser supports it) ── */
:root {
  interpolate-size: allow-keywords;
}

details::details-content {
  block-size: 0;
  overflow-y: clip;
  transition:
    block-size 280ms var(--ease-out-3),
    content-visibility 280ms allow-discrete;
}

details[open]::details-content {
  block-size: auto;
}

@media (prefers-reduced-motion: reduce) {
  details::details-content {
    transition: none;
  }
}

/* ── Journey bar: title, every stop on one track, and restart ── */
.topbar {
  position: relative;
}

/* Phones have no rail, so a thin line along the bar shows progress. */
.topbar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: calc(var(--progress, 0) * 100%);
  height: 3px;
  background: var(--accent);
  transition: width 450ms var(--ease-out-3);
}

.brand {
  display: none;
  min-width: 0;
}

.restart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.topbar .restart,
.topbar .copy-link {
  padding: 0.5rem;
}

.copy-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 44px;
}

.copy-link .icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.copy-link-label {
  display: none;
  font-size: 0.8rem;
}

.copy-link[data-state] .copy-link-label {
  display: inline;
}

.copy-link[data-state="copied"] {
  border-color: var(--good-line);
  color: var(--good);
}

.restart-label {
  display: none;
}

.restart .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.rail-track {
  position: absolute;
  top: var(--track-y, 50%);
  left: var(--track-left, 0);
  width: var(--track-width, 0);
  height: 2px;
  margin-top: -1px;
  border-radius: 2px;
  background: var(--line);
  pointer-events: none;
}

.rail-fill {
  display: block;
  width: var(--track-fill, 0);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 450ms var(--ease-out-3);
}

.rail-act.is-past .act-name {
  color: var(--ink-2);
}

.rail-act.is-current .act-name {
  color: var(--accent);
}

@media (min-width: 768px) {
  .topbar {
    gap: 1.25rem;
    min-height: 72px;
    padding: 0 24px;
  }

  .topbar::after {
    display: none;
  }

  .brand {
    display: grid;
    flex: none;
    gap: 0.05rem;
  }

  .lesson-title {
    line-height: 1.2;
  }

  .act-label {
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
  }

  .topbar .rail {
    flex: 1;
    min-width: 0;
    height: 72px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .topbar .rail-list {
    position: relative;
    z-index: 1;
    gap: 4px;
  }

  .topbar .rail-act {
    padding: 0 0.15rem;
    border-left: 0;
  }

  .topbar .rail-node {
    grid-template-rows: 22px auto;
  }

  .topbar .node-dot {
    align-self: center;
  }

  .topbar .rail-node {
    min-width: 32px;
  }

  .topbar .rail-node:not(.is-current) .node-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .topbar .rail-act {
    padding: 0 0.4rem;
  }

  .topbar .act-name {
    max-width: 7.5em;
    margin-inline: auto;
    padding-left: 0;
    font-size: 0.64rem;
    line-height: 1.1;
    text-align: center;
    white-space: normal;
  }

  .topbar .rail-act {
    display: grid;
    align-content: end;
  }

  .topbar .act-stages {
    justify-content: center;
  }

  .topbar .key-glyph {
    z-index: 2;
  }

  .topbar [data-action="start-over"] {
    margin-left: 0;
  }
}

@media (min-width: 1080px) and (min-height: 600px) {
  .app {
    grid-template-rows: 72px minmax(0, 1fr) 72px;
  }
}

/* ── Tooltips and glossary terms ── */
.tip {
  position: absolute;
  z-index: 50;
  max-width: min(18rem, calc(100vw - 16px));
  padding: 0.45rem 0.7rem;
  border-radius: 0.5rem;
  background: var(--ink);
  color: var(--card);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 140ms var(--ease-out-3),
    transform 180ms var(--ease-out-3);
}

.tip.is-below {
  transform: translateY(-4px);
}

.tip.is-open {
  opacity: 1;
  transform: none;
}

.tip::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: var(--arrow-x, 50%);
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: inherit;
  transform: rotate(45deg);
}

.tip.is-below::after {
  top: -5px;
  bottom: auto;
}

.term {
  border-bottom: 1.5px dotted var(--accent);
  cursor: help;
}

.term:hover,
.term[aria-describedby] {
  border-bottom-style: solid;
  color: var(--accent);
}

.chip[data-tip],
.copies,
.pill[data-tip],
.int-meta[data-tip] {
  cursor: help;
}

/* ── Replay, open all, and the keyboard hint ── */
.replay,
.link-button {
  min-height: 36px;
  padding: 0.25rem 0.6rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.rotate-action .replay {
  font-size: 0.95rem;
}

@media (hover: hover) {
  .replay:hover,
  .link-button:hover {
    background: var(--accent-soft);
  }
}

.int-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.kbd-hint {
  display: none;
  color: var(--muted);
  font-size: 0.82rem;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 0.3rem;
  background: var(--card);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
}

@media (min-width: 1080px) and (hover: hover) {
  .kbd-hint {
    display: block;
  }
}

/* ── Story first, deep dive one click away ── */
.panel-story,
.panel-deep {
  display: flex;
  flex-direction: column;
  gap: inherit;
  min-width: 0;
}

.deep-open,
.deep-head {
  display: none;
}

@media (min-width: 1080px) and (min-height: 600px) {
  .panel[data-view="story"] .panel-deep,
  .panel[data-view="deep"] .panel-story,
  .panel[data-view="deep"] .deep-open {
    display: none;
  }

  /* The scene button already says what to press. */
  .try {
    display: none;
  }

  .deep-open {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.1rem 0.75rem;
    flex: none;
    width: 100%;
    margin-top: auto;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
  }

  .deep-open-title {
    color: var(--accent);
    font-weight: 800;
  }

  .deep-open-list {
    grid-column: 1;
    color: var(--ink-2);
    font-size: 0.82rem;
  }

  .deep-open-arrow {
    grid-row: 1 / span 2;
    grid-column: 2;
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    transition: transform 200ms var(--ease-spring-3);
  }

  .deep-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.15rem 0 0.4rem;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
  }

  .deep-back {
    min-height: 40px;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
  }

  .deep-title {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel-deep.enter {
    animation: slide-next 260ms var(--ease-out-3);
  }

  .panel-story.enter {
    animation: slide-prev 260ms var(--ease-out-3);
  }
}

@media (min-width: 1080px) and (min-height: 600px) and (hover: hover) {
  .deep-open:hover {
    background: var(--accent-soft);
  }

  .deep-open:hover .deep-open-arrow {
    transform: translateX(3px);
  }

  .deep-back:hover {
    border-color: var(--accent);
  }
}

@media (min-width: 1080px) and (min-height: 600px) {
  .panel {
    gap: 0.5rem;
  }

  .leak-tools {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bridge {
    padding: 0.4rem 0.75rem;
  }
}

/* ── Basics: the loop scene, key types, and the way out ── */
.loop-scene {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
}

.loop-scene .loop {
  max-width: 22rem;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .loop-scene:has(.lines) {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: center;
  }
}

@keyframes node-light {
  0% {
    fill: var(--card);
    stroke: var(--line);
  }
  40% {
    fill: var(--info-soft);
    stroke: var(--info);
    stroke-width: 3;
  }
  100% {
    fill: var(--info-soft);
    stroke: var(--info);
  }
}

.frame-loop.is-walked .loop-node rect {
  animation: node-light 500ms var(--ease-out-3) both;
}

.frame-loop.is-walked .loop-node:nth-of-type(2) rect {
  animation-delay: 150ms;
}

.frame-loop.is-walked .loop-node:nth-of-type(3) rect {
  animation-delay: 300ms;
}

.frame-loop.is-walked .loop-node:nth-of-type(4) rect {
  animation-delay: 450ms;
}

.frame-loop.is-walked .loop-node:nth-of-type(5) rect {
  animation-delay: 600ms;
}

.key-types {
  padding: 0.55rem 0.8rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 0.9rem;
}

.out-link {
  display: inline-block;
  min-height: 24px;
  padding-block: 0.2rem;
  color: var(--accent);
  font-weight: 700;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.out-link:hover {
  text-decoration-thickness: 2px;
}

.skip {
  align-self: flex-start;
  padding-left: 0;
}

@media (min-width: 768px) {
  .topbar {
    gap: 1rem;
  }

  .topbar .rail-node {
    padding: 0.15rem 0.18rem;
  }

  .topbar .rail-act {
    padding: 0 0.1rem;
  }
}

.loop-scene {
  padding: 0.5rem 0.75rem;
}

.loop-scene .lines {
  gap: 0.3rem;
}

@media (min-width: 768px) {
  .topbar .rail-list {
    gap: 2px;
  }
}

/* ── Golden rule, .env checklist, and the findings toggle ── */
.rule {
  padding: 0.55rem 0.8rem;
  border-left: 4px solid var(--bad-line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bad-soft);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.practices {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--good-line);
  border-radius: var(--radius);
  background: var(--card);
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}

.seg {
  min-height: 34px;
  padding: 0.2rem 0.8rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 160ms var(--ease-out-3),
    color 160ms var(--ease-out-3);
}

.seg[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

@media (hover: hover) {
  .seg[aria-pressed="false"]:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }
}

@media (min-width: 1080px) and (min-height: 600px) {
  .rule,
  .key-types {
    padding: 0.4rem 0.75rem;
    font-size: 0.86rem;
  }
}

/* ── Close: what remains, then the open question ── */
.debrief {
  display: grid;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.debrief h3 {
  font-size: 1rem;
}

.debrief-facts {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.debrief-facts div {
  display: grid;
  gap: 0.1rem;
}

.debrief-facts dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.debrief-facts dd {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.9rem;
}

.debrief-copies {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.debrief-copies li,
.copy-map-list li.is-dead {
  display: grid;
  gap: 0.15rem;
}

.debrief-place,
.copy-name {
  font-weight: 700;
}

.debrief-marks,
.copy-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.debrief-marks span,
.copy-place,
.copy-map-list .copy-state {
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 0.72rem;
  font-weight: 800;
}

.debrief-marks span:last-child,
.copy-map-list li.is-dead .copy-state {
  background: var(--paper);
  color: var(--muted);
}

.real-case {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-left: 3px solid var(--info);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--info-soft);
  color: var(--ink-2);
  font-size: 0.9rem;
}

.real-case p {
  margin: 0;
}

.real-case-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: baseline;
}

.real-case-kind {
  color: var(--info);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.real-case-who {
  color: var(--ink);
  font-weight: 600;
}

.real-case-source {
  color: var(--muted);
  font-size: 0.8rem;
}

.quiz {
  display: grid;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.quiz h3 {
  margin: 0;
  font-size: 0.95rem;
}

.quiz-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding-left: 1.4rem;
}

.quiz-question {
  margin: 0 0 0.35rem;
  font-weight: 600;
  color: var(--ink);
}

.quiz-options {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quiz-option {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.quiz-option:hover {
  border-color: var(--ink-2);
}

.quiz-option.is-right {
  border-color: var(--good-line);
  background: var(--good-soft);
  color: var(--good);
}

.quiz-option.is-wrong {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
}

.quiz-feedback {
  margin: 0.35rem 0 0;
  color: var(--ink-2);
}

.debrief-step {
  color: var(--muted);
  font-size: 0.8em;
  font-weight: 400;
}

.ladder {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.ladder h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.ladder ol {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding-left: 1.4rem;
}

.ladder strong {
  color: var(--ink);
}

.ladder-line {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.closing {
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem 0.8rem;
  border-left: 4px solid var(--info);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--info-soft);
  color: var(--ink-2);
  font-size: 0.9rem;
}

.closing strong {
  color: var(--ink);
}

.closing-loop {
  color: var(--info);
}

@media (min-width: 1080px) and (min-height: 600px) {
  .closing {
    gap: 0.2rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.86rem;
  }
}

@media (min-width: 1080px) and (min-height: 600px) {
  .takeaway {
    padding: 0.4rem 0.8rem;
    font-size: 0.98rem;
  }
}

@media (min-width: 1080px) and (min-height: 600px) {
  .deep-open-list {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ── Copy map ── */
button.copies {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.copies-caret {
  font-size: 0.7rem;
  transition: transform 160ms var(--ease-out-3);
}

.copies[aria-expanded="true"] .copies-caret {
  transform: rotate(180deg);
}

.copy-dot.is-found {
  box-shadow:
    0 0 0 2px var(--card),
    0 0 0 3.5px var(--warn);
}

.copy-map {
  position: absolute;
  top: 3rem;
  left: 0.75rem;
  z-index: 4;
  width: min(19rem, calc(100% - 1.5rem));
  max-height: calc(100% - 4rem);
  overflow-y: auto;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 10px 28px rgb(31 26 22 / 18%);
  font-size: 0.85rem;
  animation: reveal 200ms var(--ease-out-3);
}

.copy-map-title {
  margin-bottom: 0.35rem;
  color: var(--ink);
  font-weight: 800;
}

.copy-map-list {
  display: grid;
  gap: 0.2rem;
  margin: 0;
  padding-left: 1.3rem;
  color: var(--ink-2);
}

.copy-map-list li.is-found {
  color: var(--ink);
  font-weight: 600;
}

.copy-map-list li:not(.is-dead) .copy-state {
  margin-left: 0.4rem;
  background: var(--warn-soft);
  color: var(--warn);
}

.copy-map-note {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── Rotate in order ── */
.rotate-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0.2rem 0.4rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.rotate-step[aria-disabled="true"] {
  border-style: solid;
  border-color: var(--good-line);
  background: var(--good-soft);
  cursor: default;
}

@media (hover: hover) {
  .rotate-step:not([aria-disabled="true"]):hover {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
}

.rotate-warn {
  margin: 0;
  padding: 0.45rem 0.65rem;
  border-left: 4px solid var(--bad-line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 0.88rem;
  font-weight: 700;
  animation: reveal 200ms var(--ease-out-3);
}

.rotate-hint,
.process-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.process-note {
  color: var(--ink-2);
  font-weight: 600;
}

/* ── Tappable secret kinds and sources ── */
.kind {
  scroll-margin-top: 4.5rem;
  scroll-margin-bottom: calc(88px + env(safe-area-inset-bottom));
}

.kind > summary {
  cursor: pointer;
  list-style: none;
  border-radius: 0.25rem;
}

.kind > summary::-webkit-details-marker {
  display: none;
}

.kind > summary::after {
  content: " ›";
  color: var(--accent);
  font-weight: 800;
}

.kind[open] > summary::after {
  content: " ⌄";
}

.kind > p {
  margin-top: 0.2rem;
  color: var(--ink-2);
  font-size: 0.85rem;
}

.kind-facts {
  display: grid;
  gap: 0.4rem;
  margin: 0.35rem 0 0.1rem;
  color: var(--ink-2);
  font-size: 0.88rem;
  line-height: 1.45;
}

.kind-facts dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.kind-facts dd {
  margin: 0;
  color: var(--ink);
}

.kind-line {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 0.15rem 0.65rem;
  align-items: baseline;
}

.kind-jobs {
  display: grid;
  gap: 0.25rem;
}

.kind-uses {
  display: grid;
  gap: 0.28rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kind-use {
  margin: 0;
  padding-left: 0.65rem;
  border-left: 3px solid var(--line);
}

.kind-use.is-today {
  border-left-color: var(--info);
}

.kind-who {
  color: var(--ink);
  font-weight: 800;
}

.kind-today {
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.kind > summary .kind-today {
  vertical-align: 0.1em;
}

@media (max-width: 479px) {
  .kind-line {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.05rem;
  }
}

@media (min-width: 768px) {
  .kind {
    scroll-margin-top: 0.75rem;
  }
}

.sources-list {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding-left: 1.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (min-width: 768px) {
  .topbar .node-label {
    font-size: 0.68rem;
  }
}

/* Each rotation step is now one button, so the list item is a plain block. */
.rotate-steps li {
  display: block;
}

.rotate-step .mark {
  flex: none;
}

.rotate-steps {
  gap: 0.3rem;
  padding: 0.5rem 0.75rem;
}

.rotate-hint,
.rotate-warn {
  margin: -0.5rem 1rem 0;
}

@media (min-width: 768px) {
  .canvas[data-frame="rotate"] .scene-body {
    padding-top: 3rem;
    padding-bottom: calc(var(--hog-w) * 0.62 + 0.75rem);
  }

  .rotate-action .scene-action {
    min-height: 44px;
    padding: 0.5rem 1.4rem;
  }

  .rotate-keys {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}

/* ── Action first: the scene button leads until it's pressed ── */
.primary.is-secondary {
  background: var(--card);
  color: var(--accent);
}

@media (hover: hover) {
  .primary.is-secondary:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
  }
}

.canvas.is-pending .scene-action:not([aria-disabled="true"]) {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 4px 14px rgb(154 61 47 / 25%);
}

@keyframes ready-pulse {
  0% {
    box-shadow: 0 0 0 0 rgb(154 61 47 / 45%);
  }
  100% {
    box-shadow: 0 0 0 12px rgb(154 61 47 / 0%);
  }
}

.primary.enter {
  animation: ready-pulse 700ms var(--ease-out-3);
}

/* ── Copies flying to the counter ── */
.copy-fly {
  position: fixed;
  z-index: 60;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  color: var(--accent);
  pointer-events: none;
}

.copy-fly .icon {
  width: 100%;
  height: 100%;
  stroke-width: 3;
}

/* ── The day heals, and the replay ── */
.rail-fill,
.key-glyph,
.rail-node .node-dot {
  transition:
    background-color 600ms var(--ease-out-3),
    border-color 600ms var(--ease-out-3),
    color 600ms var(--ease-out-3);
}

.app.is-healed .rail-fill {
  background: var(--good-line);
}

.app.is-healed .key-glyph {
  color: var(--good);
}

.app.is-healed .rail-node.is-past .node-dot,
.app.is-healed .rail-node.is-current .node-dot {
  border-color: var(--good-line);
}

.app.is-healed .rail-node.is-past .node-dot {
  background: var(--good-line);
}

.app.is-reviewing .rail-node .node-dot {
  border-color: var(--muted);
  background: var(--card);
}

.app.is-reviewing .rail-node .node-dot.is-lit {
  border-color: var(--accent);
  background: var(--accent);
}

.app.is-reviewing.is-healed .rail-node .node-dot.is-lit {
  border-color: var(--good-line);
  background: var(--good-line);
}

.replay-day {
  margin-top: 0.25rem;
}

/* ── Time of day beside each step's name ── */
.eyebrow-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.35rem;
  line-height: 1.25;
}

.eyebrow-time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.copy-map-side {
  padding-top: 0.35rem;
  border-top: 1px dashed var(--line);
}

/* ── Plain / Dev scene switch ── */
.frame-toggle {
  flex: none;
  margin-left: auto;
  padding: 1px;
}

.frame-toggle .seg {
  min-height: 24px;
  padding: 0.05rem 0.55rem;
  font-size: 0.74rem;
}

/* Lines with an explanation get a quiet underline, like glossary terms. */
.line.has-tip {
  text-decoration: underline dotted rgb(244 237 228 / 45%);
  text-underline-offset: 3px;
  cursor: help;
}

.frame-panel .line.has-tip,
.lines .line.has-tip {
  text-decoration-color: var(--accent);
}

.line.has-tip:hover,
.line.has-tip[aria-describedby] {
  text-decoration-style: solid;
}

/* ── TruffleHog open-source terminal in the TruffleHog tab ── */
.oss-term {
  display: grid;
  gap: 0.35rem;
  margin: 0;
}

.oss-term figcaption {
  display: grid;
  gap: 0.1rem;
}

.oss-term-title {
  color: var(--ink);
  font-weight: 800;
}

.oss-term-caption {
  color: var(--ink-2);
  font-size: 0.85rem;
}

.oss-term-note {
  color: var(--muted);
}

.oss-term .code {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius);
  background: var(--term-bg);
  color: var(--term-ink);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ── Stage and Rail ──
   On wide screens the scene fills the whole stage, the journey rail stays pinned in the
   header, and the story sits in a card docked on the stage's right edge. Smaller screens
   keep the stacked layout: story first in reading order, scene above it on screen. */
/* Desktop layout: story column on the left, scene on the right.
   This matches DOM order (headline first) and keeps the two from overlapping. */
@media (min-width: 1080px) and (min-height: 600px) {
  .stage {
    --card-w: clamp(380px, 34vw, 460px);
    --hog-base: clamp(150px, 24vh, 240px);
    grid-template-columns: var(--card-w) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .panel {
    grid-column: 1;
    grid-row: 1;
    align-self: stretch;
    max-height: 100%;
    padding: 1.25rem 1.25rem 1rem;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) * 1.5);
    background: var(--card);
    box-shadow: 0 1px 2px rgb(31 26 22 / 6%);
  }

  .scene-col {
    grid-column: 2;
    grid-row: 1;
    display: block;
  }

  .canvas {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  /* Center the scene in the space above the hog instead of pinning it to the top. */
  .scene-body,
  .canvas[data-frame="rotate"] .scene-body {
    box-sizing: border-box;
    min-height: 100%;
    align-content: center;
    padding: 4rem 2rem calc(var(--hog-w) * 0.71 + 1.5rem);
  }
}

/* The rotation scene is the climax: it grows to fit its steps, so the centered hog never
   covers the buttons on tablet layouts. */
@media (min-width: 768px) and (max-width: 1079px), (min-width: 768px) and (max-height: 599px) {
  .canvas[data-frame="rotate"] {
    aspect-ratio: auto;
  }

  .canvas[data-frame="rotate"] .scene-body {
    max-height: none;
    padding-bottom: calc(var(--hog-w) * 0.71 + 1.5rem);
    overflow: visible;
  }
}

/* Tablets keep the phone header: the 18-step rail does not fit beside the title
   until desktop width. The Map sheet holds every step name. */
@media (min-width: 768px) and (max-width: 1079px) {
  .brand,
  .topbar .rail {
    display: none;
  }

  .compact-label,
  .map-button {
    display: grid;
  }

  .topbar .map-button {
    display: inline-flex;
    margin-left: auto;
  }

  .topbar {
    min-height: 64px;
  }

  .topbar::after {
    display: block;
  }
}

/* ── Copy trail: a drawn map of where the key has spread (desktop only) ── */
.copy-trail {
  display: none;
}

@media (min-width: 1080px) and (min-height: 600px) {
  .canvas {
    display: flex;
    flex-direction: column;
  }

  .copy-trail {
    display: grid;
    gap: 0.55rem;
    margin: 3.75rem 1.5rem 0;
    padding: 0.85rem 1rem 1rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: rgb(255 253 249 / 70%);
  }

  .trail-title {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .trail-sum {
    margin-left: 0.4rem;
    color: var(--ink-2);
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
  }

  .trail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .trail-stop {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border: 1.5px solid var(--accent);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
  }

  /* Arrows join the stops in the order the copies were made. */
  .trail-stop + .trail-stop::before {
    content: "";
    order: -1;
    width: 1.1rem;
    height: 1.5px;
    margin: 0 0.35rem 0 -1.6rem;
    background: var(--line);
  }

  .trail-stop + .trail-stop {
    margin-left: 1.6rem;
  }

  .trail-stop.is-origin {
    border-color: var(--line);
    background: var(--paper);
    color: var(--muted);
  }

  .trail-stop.is-new {
    background: var(--accent);
    color: var(--on-accent);
  }

  .trail-tag {
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgb(255 255 255 / 25%);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .trail-stop.is-found {
    border-color: var(--good-line);
    background: var(--good-soft);
    color: var(--good);
  }

  .trail-stop.is-found .trail-tag {
    background: var(--good-line);
    color: #fff;
  }

  .trail-stop.is-dead {
    border-color: var(--line);
    background: var(--paper);
    color: var(--muted);
  }

  .trail-stop.is-dead .trail-name {
    text-decoration: line-through;
  }

  .trail-stop.is-dead .trail-tag {
    background: var(--line);
    color: var(--ink-2);
  }

  .scene-body,
  .canvas[data-frame="rotate"] .scene-body {
    flex: 1;
    min-height: 0;
    padding-top: 1.25rem;
  }
}

@media (min-width: 1080px) and (min-height: 600px) and (prefers-reduced-motion: no-preference) {
  .trail-stop.is-new {
    animation: trail-in 420ms var(--ease-out-3, ease-out) both;
  }

  @keyframes trail-in {
    from {
      opacity: 0;
      transform: translateY(4px) scale(0.92);
    }
  }
}

/* Short desktop screens: a tighter trail so the scene keeps its room. */
@media (min-width: 1080px) and (min-height: 600px) and (max-height: 840px) {
  .copy-trail {
    gap: 0.4rem;
    margin-top: 3.5rem;
    padding: 0.55rem 0.75rem 0.65rem;
  }

  .trail {
    gap: 0.35rem 0;
  }

  .trail-stop {
    padding: 0.16rem 0.5rem;
    font-size: 0.72rem;
  }

  .trail-stop + .trail-stop {
    margin-left: 1.2rem;
  }

  .trail-stop + .trail-stop::before {
    width: 0.8rem;
    margin: 0 0.3rem 0 -1.2rem;
  }
}

/* ── Place band: copies grouped by where they sit, with the check that runs there ──
   Parts opt in with copyMap.places. Unlike the trail, it shows on phones too, as a row of counts. */
.copy-trail.is-band {
  display: grid;
  gap: 0.5rem;
  margin: 3.5rem 0 0;
  padding: 0.7rem 0.8rem 0.8rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgb(255 253 249 / 70%);
}

.copy-trail.is-band .trail-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.copy-trail.is-band .trail-sum {
  margin-left: 0.4rem;
  color: var(--bad);
  letter-spacing: 0;
  text-transform: none;
}

.place-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.place-band.places-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.band-place {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.band-place.is-empty {
  opacity: 0.72;
}

.band-place.is-new {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* The tab sits on the card's top edge, so it costs no height. */
.band-new {
  position: absolute;
  top: -0.6rem;
  left: 0.45rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.15rem;
}

.place-band > .band-place {
  align-items: stretch;
  justify-content: flex-start;
}

.place-band > .band-place > .band-head {
  min-width: 0;
}

.band-dots + .band-check {
  margin-top: auto;
}

.band-place.is-dead {
  border-color: var(--line);
  background: #f1ece4;
}

.band-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
  margin: 0;
}

.band-name {
  overflow: hidden;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.band-count {
  flex: none;
  min-width: 1.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #efe7da;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.78rem;
  text-align: center;
}

.band-place.has-copies .band-count,
.band-place.is-new .band-count {
  background: var(--bad);
  color: var(--on-accent);
}

.band-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 9px;
}

.band-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bad);
}

.band-dot.is-new {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.band-dot.is-found {
  background: var(--warn);
}

.band-dot.is-dead {
  background: #b8ada0;
}

.band-check {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1rem 0.3rem;
  margin: 0;
  padding-top: 0.3rem;
  border-top: 1px dashed var(--line);
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--ink-2);
}

.band-check + .band-check {
  border-top: 0;
  padding-top: 0;
}

.band-check-name {
  font-weight: 600;
}

.band-state {
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.68rem;
}

.band-short {
  display: none;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.68rem;
}

.state-off {
  background: var(--bad-soft);
  color: var(--bad);
}

.state-none {
  background: #efe7da;
  color: var(--muted);
}

.state-on {
  background: var(--good-soft);
  color: var(--good);
}

@media (min-width: 1080px) and (min-height: 600px) {
  .copy-trail.is-band {
    margin: 3.75rem 1.5rem 0;
  }
}

@media (min-width: 1080px) and (min-height: 600px) and (prefers-reduced-motion: no-preference) {
  .band-place.is-new {
    animation: trail-in 420ms var(--ease-out-3, ease-out) both;
  }
}

/* Short desktop screens: no dots, so the scene keeps its room. The Copies button has them. */
@media (min-width: 1080px) and (max-height: 840px) {
  .copy-trail.is-band {
    gap: 0.35rem;
    margin-top: 3.4rem;
    padding: 0.45rem 0.6rem 0.55rem;
  }

  .band-place {
    gap: 0.2rem;
    padding: 0.35rem 0.45rem;
  }

  .band-dots,
  .band-place:has(.band-short) .band-check-name,
  .band-place:has(.band-short) .band-state {
    display: none;
  }

  .band-place:has(.band-short) .band-short {
    display: inline;
  }

  .band-check {
    padding-top: 0.2rem;
  }
}

/* Phones: the band sits above the story, outside the scene card. */
.copy-trail.is-band.is-top {
  margin: 0;
  background: var(--card);
}

/* Phones and tablets: counts only, so the scene keeps its room. The Copies list has the names. */
@media (max-width: 1079px) {
  .copy-trail.is-band {
    margin: 3.25rem 0.75rem 0;
    padding: 0.5rem;
  }

  .copy-trail.is-band .trail-title {
    font-size: 0.7rem;
  }

  .place-band > .band-place {
    align-items: center;
    padding: 0.4rem 0.25rem;
    text-align: center;
  }

  .band-head {
    flex-direction: column-reverse;
    align-items: center;
    gap: 0.15rem;
  }

  .band-name {
    font-size: 0.68rem;
    font-weight: 600;
    white-space: normal;
  }

  .band-new {
    left: auto;
    right: 50%;
    transform: translateX(50%);
    white-space: nowrap;
  }

  .band-count {
    font-size: 0.95rem;
  }

  .band-dots,
  .band-check {
    display: none;
  }
}

/* ── Retro computer around the coding steps (Part 1) ──
   An original beige desktop computer with a 1-bit screen, to match the pixel hog. */
@font-face {
  font-family: "VT323";
  src: url("../vendor/vt323/vt323-latin-400-normal.woff2") format("woff2");
  font-display: swap;
}

.ide {
  --pixel: "VT323", var(--mono);
  --case: #d9cfba;
  --case-dark: #b9ad94;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.5rem;
  border: 2px solid var(--ink);
  border-radius: 0.6rem;
  background: var(--case);
  box-shadow:
    inset -3px -3px 0 var(--case-dark),
    inset 3px 3px 0 #ece5d4,
    4px 4px 0 var(--ink);
}

.ide-screen {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 0.35rem;
  background: #fff;
}

/* Faint scanlines over the screen. */
.ide-screen::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: repeating-linear-gradient(0deg, rgb(0 0 0 / 3.5%) 0 1px, transparent 1px 3px);
  content: "";
  pointer-events: none;
}

.ide-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.6rem;
  padding: 0 2.25rem;
  border-bottom: 2px solid var(--ink);
  background:
    repeating-linear-gradient(180deg, var(--ink) 0 1px, #fff 1px 3px) 0 5px / 100% calc(100% - 10px) no-repeat,
    #fff;
}

.ide-close {
  position: absolute;
  left: 0.6rem;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid var(--ink);
  background: #fff;
}

.ide-title {
  overflow: hidden;
  padding: 0 0.5rem;
  background: #fff;
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 1.05rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ide-body {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.ide-explorer {
  display: none;
  overflow: hidden;
}

.ide-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.ide-tab {
  display: flex;
  margin: 0;
  border-bottom: 2px solid var(--ink);
  background: #fff;
  font-family: var(--pixel);
  font-size: 1rem;
  line-height: 1.2;
}

.ide-tab span {
  padding: 0.15rem 0.75rem;
  border-right: 2px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.ide .frame {
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.ide-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.9rem;
  padding: 0.1rem 0.6rem;
  border-top: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 1rem;
  line-height: 1.3;
}

.ide-note {
  color: var(--ink-2);
}

.ide-warn {
  padding: 0 0.35rem;
  background: var(--bad-line);
  color: #fff;
}

/* The case below the screen: a floppy slot and a power light. */
.ide-chin {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  height: 1rem;
  margin-top: 0.4rem;
  padding: 0 0.5rem;
}

.ide-slot {
  width: 4.5rem;
  height: 0.3rem;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 1px 0 #ece5d4;
}

.ide-led {
  width: 0.4rem;
  height: 0.4rem;
  background: #3c9a52;
}

@media (min-width: 768px) {
  .ide {
    padding: 0.75rem 0.75rem 0.4rem;
  }

  .ide-body {
    grid-template-columns: 11rem minmax(0, 1fr);
  }

  .ide-explorer {
    display: block;
    padding: 0.35rem 0 0.5rem;
    border-right: 2px solid var(--ink);
    background: #fff;
    font-family: var(--pixel);
    font-size: 1rem;
    line-height: 1.2;
  }

  .ide-head {
    margin: 0 0 0.15rem;
    padding: 0 0.6rem;
    color: var(--ink);
    font-size: 0.95rem;
    text-transform: uppercase;
  }

  .ide-scm {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding-top: 0.3rem;
    border-top: 2px dotted var(--ink);
  }

  .ide-count {
    padding: 0 0.3rem;
    background: var(--ink);
    color: #fff;
  }

  .ide-folder {
    margin: 0;
    padding: 0 0.6rem;
    color: var(--ink);
  }

  .ide-folder.is-nested {
    padding-left: 1.2rem;
  }

  .ide-files {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .ide-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0 0.6rem 0 1.2rem;
    color: var(--ink);
  }

  .ide-file.is-nested {
    padding-left: 1.8rem;
  }

  .ide-file.is-active {
    background: var(--ink);
    color: #fff;
  }

  .ide-file.is-hot .ide-fname {
    color: var(--bad-line);
  }

  .ide-file.is-hot.is-active .ide-fname {
    color: #ffb4a8;
  }

  .ide-badge {
    min-width: 1rem;
    text-align: center;
  }
}

/* Phones and short desktop screens: drop the tab row, which repeats the panel header. */
@media (max-width: 767px), (min-width: 1080px) and (max-height: 840px) {
  .ide-tab {
    display: none;
  }
}

@media (min-width: 1080px) and (max-height: 840px) {
  /* Chat screens drop the channel list here: it is decoration, and the messages need the width. */
  .ide-explorer.chat-rooms {
    display: none;
  }

  .ide-body:has(> .chat-rooms) {
    grid-template-columns: minmax(0, 1fr);
  }

  .ide {
    padding: 0.5rem 0.5rem 0.25rem;
  }

  .ide-chin {
    height: 0.7rem;
    margin-top: 0.25rem;
  }

  .ide .frame .line {
    padding-block: 0.1rem;
  }
}

/* Very short desktop screens: the computer needs the room more than the trail.
   The Copies button above still lists every copy. */
@media (min-width: 1080px) and (max-height: 760px) {
  .canvas:has(.ide) .copy-trail {
    display: none;
  }

  .canvas:has(.ide) .scene-body {
    padding-top: 3.6rem;
  }
}

/* ── Apps on the retro computer: browser, chat, console, terminal ── */
.app-urlbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.5rem;
  border-bottom: 2px solid var(--ink);
  background: #fff;
  font-family: var(--pixel);
  font-size: 1rem;
  line-height: 1.2;
}

.app-nav {
  color: var(--muted);
  letter-spacing: 0.15em;
  white-space: nowrap;
}

.app-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0 0.45rem;
  border: 2px solid var(--ink);
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-lock {
  margin-right: 0.3rem;
  font-size: 0.8em;
}

.app-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.app-tabs {
  display: flex;
  border-bottom: 2px solid var(--ink);
  background: #fff;
  font-family: var(--pixel);
  font-size: 1rem;
  line-height: 1.3;
}

.app-tabs span {
  padding: 0.05rem 0.75rem;
  border-right: 2px solid var(--ink);
  color: var(--ink-2);
}

.app-tabs span.is-active {
  background: var(--ink);
  color: #fff;
}

.chat-room {
  padding: 0 0.6rem 0 1.2rem;
  color: var(--ink);
}

.chat-room.is-active {
  background: var(--ink);
  color: #fff;
}

/* Inside an app, the app's own bar names the place, so the panel header only stays
   where it carries the Plain/Dev toggle. */
.computer:not(.computer-ide) .frame-title:not(:has(.frame-toggle)) {
  display: none;
}

@media (max-width: 767px) {
  .app-nav,
  .app-tabs span:not(.is-active) {
    display: none;
  }
}

/* ── Clock timeline in the header (desktop) ──
   Steps sit by time of day. Bands show how long the key was out unnoticed, then
   how long the fix took. Step names stay as accessible labels and hover tips. */
@media (min-width: 1080px) {
  .topbar .rail {
    flex: 1;
    min-width: 0;
    height: 64px;
    padding: 0 24px;
    overflow: visible;
  }

  .topbar .rail-list {
    position: relative;
    display: block;
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .topbar .rail-item {
    position: absolute;
    top: 30px;
    left: var(--pos);
    z-index: 2;
    transform: translate(-50%, -50%);
  }

  .topbar .rail-node {
    display: grid;
    place-items: center;
    min-width: 26px;
    min-height: 26px;
    padding: 0;
  }

  .topbar .rail-node .node-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .tl-deco {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  .tl-band {
    position: absolute;
    top: 23px;
    left: var(--from);
    width: calc(var(--to) - var(--from));
    height: 14px;
    border-radius: 7px;
    background: rgb(180 35 24 / 13%);
  }

  .tl-band.is-response {
    background: rgb(176 120 0 / 20%);
  }

  .tl-band-label {
    position: absolute;
    top: -19px;
    left: 0;
    color: var(--bad-line);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }

  .tl-band.is-response .tl-band-label {
    color: #8a5a00;
  }

  .tl-tick,
  .tl-break {
    position: absolute;
    top: 45px;
    left: var(--pos);
    transform: translateX(-50%);
    color: var(--muted);
    font-size: 0.64rem;
    white-space: nowrap;
  }

  .tl-break {
    font-style: italic;
  }

  /* Once the old key is off, the exposure bands fade: the risk is over. */
  .is-healed .tl-band {
    background: rgb(180 35 24 / 6%);
  }

  .is-healed .tl-band.is-response {
    background: rgb(176 120 0 / 9%);
  }

  /* The label stays at full contrast; only the band behind it fades. */
  .is-healed .tl-band-label {
    color: var(--muted);
  }
}

/* Safer way: the leaky picture beside the fixed one when the card has room. Both stay visible. */
.compare {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.leak-body:has(> .compare) {
  container-type: inline-size;
}

@container (min-width: 520px) {
  .compare {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.compare-side {
  display: grid;
  gap: 0.3rem;
  align-content: start;
  min-width: 0;
  margin: 0;
}

.compare-side figcaption {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.compare-side.is-before figcaption {
  color: var(--accent);
}

.compare-side.is-after figcaption {
  color: var(--good);
}

/* ── Linked citations ── */
.cite {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.15em;
}

/* A citation that sits alone in a list item is a touch target of its own. */
li > .cite {
  display: inline-block;
  min-height: 24px;
  padding-block: 0.2rem;
}

.cite:hover,
.cite:focus-visible {
  text-decoration-color: currentcolor;
}

/* ── Folds: secondary detail the reader can open ── */
.fold {
  margin: 0.25rem 0 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.fold > summary {
  padding: 0.6rem 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.fold[open] > summary {
  border-bottom: 1px solid var(--line);
}

.fold > :not(summary) {
  margin: 0;
  border: 0;
}

.fold > section > h3:first-child {
  display: none;
}

/* ── What auditors ask for ── */
.audit,
.safe-replace,
.next-steps {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
}

.audit p,
.safe-replace p {
  margin: 0;
}

.audit-intro {
  color: var(--ink-2);
}

.audit-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.audit-list > li {
  display: grid;
  gap: 0.15rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.4rem;
  background: var(--paper);
}

.audit-control {
  font-weight: 700;
}

.audit-note {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── Replace it without breaking anything ── */
.safe-replace {
  margin: 0.25rem 0 0.75rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--good-line);
  border-radius: var(--radius);
  background: var(--card);
}

.safe-replace h3 {
  margin: 0;
  font-size: 1rem;
}

.safe-fear {
  color: var(--ink-2);
  font-style: italic;
}

.safe-replace ol {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding-left: 1.3rem;
  font-size: 0.9rem;
}

.safe-exception {
  font-size: 0.86rem;
}

/* ── Where to go next ── */
.next-steps {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0;
  padding: 0.85rem;
  border: 1px solid var(--good-line);
  border-radius: var(--radius);
  background: var(--good-soft);
}

.next-steps h3 {
  margin: 0;
  font-size: 1rem;
}

.finish-kicker {
  margin: 0;
  color: var(--good);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.finish-next {
  display: block;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}

.finish-next:hover,
.finish-next:focus-visible {
  background: var(--bad);
}

.finish-links {
  margin: 0;
  font-size: 0.9rem;
}

.finish-all {
  justify-self: start;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.next-steps ul {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.next-step {
  display: grid;
  gap: 0.1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}

.next-step:hover,
.next-step:focus-visible {
  border-color: var(--accent);
}

.next-step-label {
  color: var(--accent);
  font-weight: 700;
}

.next-step-note {
  color: var(--ink-2);
  font-size: 0.86rem;
}

/* ── View as: follow one person through the part ── */
.lens {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: center;
  margin: 0.25rem 0 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 0.9rem;
}

.lens.is-here {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lens > span:not(.avatar) {
  flex: 1 1 12rem;
}

.rail-item.has-lens .node-dot {
  box-shadow:
    0 0 0 3px var(--accent-soft),
    0 0 0 4.5px var(--accent);
}

.cast-follow {
  margin-top: 0.4rem;
  font-weight: 600;
}

/* ── Dig deeper: everything past the story, one tap away ── */
.dig {
  display: grid;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.dig-head {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dig > .fold,
.dig > .leak {
  margin: 0;
}

.fold > summary {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.92rem;
  list-style: none;
}

.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary::after {
  content: "›";
  margin-left: auto;
  color: var(--muted);
  font-size: 1.1rem;
  transition: transform 0.15s ease;
}

.fold[open] > summary::after {
  transform: rotate(90deg);
}

.fold > .real-case,
.fold > .usual,
.fold > .debrief,
.fold > .cast-recap,
.fold > .ladder,
.fold > .quiz {
  margin: 0;
  padding: 0.75rem;
  border: 0;
  border-radius: 0;
}

.fold > .real-case .real-case-head,
.fold > .usual .usual-head,
.fold > .debrief > h3,
.fold > .cast-recap > h3,
.fold > .ladder > h3,
.fold > .quiz > h3 {
  display: none;
}

.cast-fold {
  margin: 0.25rem 0 0.75rem;
}

.cast-fold > summary {
  font-weight: 400;
}

.cast-fold > .cast-strip {
  margin: 0;
  border: 0;
}

.cast-faces {
  display: inline-flex;
  flex: none;
}

.cast-faces .avatar {
  width: 1.5rem;
  height: 1.5rem;
  margin-right: -0.3rem;
  font-size: 0.66rem;
}

.cast-kicker-inline {
  font-weight: 700;
}

.cast-more {
  color: var(--muted);
  font-size: 0.85rem;
}

.cast-fold .cast-kicker {
  visibility: hidden;
}

/* Cast names in text: a quieter underline than glossary terms. */
.person-ref {
  border-bottom: 1.5px dotted var(--muted);
}

/* ── Lighter story panel ──
   The story column keeps the headline, story, and why it matters. People, the second reading,
   and the research sit behind Go deeper. The scene gets the space. */
.fast-path {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--warn-soft);
  color: var(--ink-2);
  font-size: 0.92rem;
}

.on-this-step {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.on-this-step .dig {
  margin: 0;
}

.step-people {
  display: grid;
  gap: 0.4rem;
}

/* The hog is TruffleHog: it steps out of scenes where TruffleHog has no part. */
.mascot.is-away {
  visibility: hidden;
  opacity: 0;
}

@media (min-width: 1080px) and (min-height: 600px) {
  .canvas.no-hog .scene-body {
    padding-bottom: 2.5rem;
  }

  .scene-body > .computer {
    width: 100%;
  }

  /* When the scene is taller than its space, keep the top in view instead of sliding under the copy trail. */
  .scene-body,
  .canvas[data-frame="rotate"] .scene-body {
    align-content: safe center;
  }

  /* With less in the story column, Go deeper sits right under it instead of at the bottom. */
  .deep-open {
    margin-top: 0.5rem;
  }
}

/* Scene buttons stay above the hog. At the climax on wide screens, the full-size hog stands in
   the corner instead of under the Rotate button, so it never covers the button. */
.scene-actions {
  position: relative;
  z-index: 2;
}

@media (min-width: 1080px) and (min-height: 600px) {
  .mascot.is-center {
    left: calc(100% - var(--hog-w) - 0.75rem);
  }

  /* The rotation panel shows every step and its button; it is never cut short. */
  .scene-body > .frame-rotate {
    min-height: max-content;
  }

  .canvas[data-frame="rotate"] .scene-body {
    padding-bottom: calc(var(--hog-w) * 0.71 + 1rem);
  }
}

/* The bigger computer only where there is height for it and the hog. */
@media (min-width: 1080px) and (min-height: 860px) {
  .scene-body > .ide {
    min-height: clamp(200px, 28vh, 380px);
  }
}

/* Wide screens: the scene sits on the floor, with its button beside the hog instead of above it,
   so the computer gets the height the hog used to reserve. */
@media (min-width: 1080px) and (min-height: 600px) {
  .scene-body {
    align-content: safe end;
    padding-bottom: 1rem;
  }

  .canvas:not(.no-hog) .scene-body > .scene-actions {
    padding-left: calc(var(--hog-w) + 1.25rem);
    min-height: calc(var(--hog-w) * 0.71);
    align-items: flex-end;
  }

  .canvas[data-frame="rotate"] .scene-body {
    padding-bottom: calc(var(--hog-w) * 0.71 + 1rem);
  }
}

/* The story carries the lesson, so on wide screens its column is wider and its text larger. */
@media (min-width: 1080px) and (min-height: 600px) {
  .stage {
    /* More room for the story: the computer is capped below, so the scene doesn't need it. */
    --card-w: clamp(460px, 45vw, 680px);
  }

  .panel {
    padding: 1.75rem 1.75rem 1.25rem;
  }

  .panel h2 {
    font-size: clamp(2rem, 2.6vw, 2.6rem);
  }

  .panel .story {
    font-size: 1.2rem;
    line-height: 1.55;
  }

  .panel .why {
    font-size: 1.05rem;
  }

  .bridge {
    font-size: 1rem;
  }
}

/* A scene line can be a highlighted header, like an alert, with numbered locations indented under it. */
.line.line-highlight {
  padding: 0.3rem 0.6rem;
  border-left: 4px solid var(--bad-line);
  border-radius: 0.25rem;
  background: var(--bad-soft);
  font-weight: 700;
}

.line.line-indent {
  padding-left: 1.75rem;
}

.line .line-num {
  min-width: 1.4rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.lines:has(> .line-indent) {
  gap: 0.25rem;
}

/* Wide screens: a scene can ask its computer to grow to fit what it shows, up to a cap. */
@media (min-width: 1080px) and (min-height: 600px) {
  .canvas.grow-screen .scene-body > .ide {
    height: max-content;
    max-height: 46vh;
  }
}

/* A computer screen with more text below: a fade and a quiet cue, pinned to the bottom edge. */
.ide-main.has-more::after,
.app-main.has-more::after {
  content: "More below ↓" / "";
  position: sticky;
  bottom: 0;
  display: block;
  margin-top: -1.6rem;
  padding: 1rem 0 0.15rem;
  background: linear-gradient(rgb(255 255 255 / 0%), #fff 55%);
  color: var(--muted);
  font-family: var(--pixel, var(--mono));
  font-size: 0.95rem;
  text-align: center;
  pointer-events: none;
}

/* ── Open source: copyable commands, the step peek, and the end-of-part kit ── */
.cmd {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  min-width: 0;
}

.cmd-text {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  overflow-x: auto;
  border-radius: 0.35rem;
  background: var(--term-bg);
  color: var(--term-ink);
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cmd-copy {
  flex: none;
  min-width: 4.5rem;
  min-height: 36px;
  padding: 0 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
  background: var(--card);
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.cmd-copy:hover,
.cmd-copy:focus-visible {
  background: var(--accent-soft);
}

.cmd-copy[data-state="copied"] {
  border-color: var(--good-line);
  background: var(--good-soft);
  color: var(--good);
}

.cmd-copy[data-state="failed"] {
  border-color: var(--bad-line);
  color: var(--bad);
}

.oss-peek,
.oss-kit {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.oss-peek > summary,
.oss-kit > summary {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  color: var(--ink);
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.oss-peek > summary::-webkit-details-marker,
.oss-kit > summary::-webkit-details-marker {
  display: none;
}

.oss-peek > summary::after,
.oss-kit > summary::after {
  content: "›";
  margin-left: auto;
  color: var(--accent);
  font-size: 1.2rem;
  transition: transform 150ms ease;
}

.oss-peek[open] > summary::after,
.oss-kit[open] > summary::after {
  transform: rotate(90deg);
}

.oss-peek-kicker {
  flex: none;
  white-space: nowrap;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.oss-peek-body,
.oss-kit-body {
  display: grid;
  gap: 0.5rem;
  padding: 0 0.75rem 0.75rem;
  font-size: 0.9rem;
}

.oss-peek-body p,
.oss-kit-body p {
  margin: 0;
}

.kit-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: kit;
}

.kit-list li {
  display: grid;
  gap: 0.25rem;
  counter-increment: kit;
}

.kit-step {
  font-weight: 700;
}

.kit-step::before {
  content: counter(kit) ". ";
  color: var(--accent);
}

.oss-kit-body a {
  color: var(--accent);
  font-weight: 600;
}

.kit-what {
  color: var(--ink-2);
  font-size: 0.86rem;
}

@media (prefers-reduced-motion: reduce) {
  .oss-peek > summary::after,
  .oss-kit > summary::after {
    transition: none;
  }
}

/* ── Phones: story, then scene ── */
@media (max-width: 767px) {
  /* Flatten the panel so its parts can sit either side of the scene:
     headline through "Try it" first, then the scene, then the extra detail. */
  .panel,
  .panel-story {
    display: contents;
  }

  .scene-col {
    order: 1;
  }

  /* Until the first render fills the story, the scene would sit at the top and then jump down. */
  .app:not([data-ready]) .scene-col,
  .app:not([data-ready]) .controls {
    display: none;
  }

  .panel-story > .try ~ *,
  .panel-story ~ * {
    order: 2;
  }
}

/* ── Wide screens: centre the scene window in the space above its button row ──
   The button row stays on the floor beside the hog. The window used to sit on the floor too,
   which left an empty band under the copy trail. */
@media (min-width: 1080px) and (min-height: 600px) {
  .canvas:not([data-frame="rotate"]) .scene-body {
    /* minmax(0, …): the row can shrink below its content, so a tall computer stays inside its
       slot instead of spilling over the band above it. */
    grid-template-rows: minmax(0, 1fr) auto;
    align-content: stretch;
  }

  .canvas:not([data-frame="rotate"]) .scene-body > .ide {
    max-height: 100%;
  }

  .canvas:not([data-frame="rotate"]) .scene-body > .ide,
  .canvas:not([data-frame="rotate"]) .scene-body > .frame {
    align-self: center;
  }
}

/* ── Below desktop the header shows the compact label, but the series title stays the page's
   level-one heading for screen readers instead of being removed with display: none. ── */
@media (max-width: 1079px), (max-height: 599px) {
  .brand {
    position: absolute;
    display: block;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Where each check runs: the laptop, the code server and the pull request are separate places. */
.checkpoints {
  margin: 0.25rem 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.cp-head {
  margin: 0 0 0.4rem;
  font-weight: 600;
  color: var(--ink);
}

.cp-list {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cp-row {
  display: grid;
  grid-template-columns: minmax(6.5rem, auto) 1fr auto;
  gap: 0.15rem 0.6rem;
  align-items: baseline;
  font-size: 0.9rem;
}

.cp-row p {
  margin: 0;
}

.cp-where {
  font-weight: 600;
  color: var(--ink);
}

.cp-check {
  color: var(--ink-2);
}

.cp-state {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.cp-off .cp-state {
  background: var(--bad-soft);
  color: var(--bad);
}

.cp-on .cp-state {
  background: var(--good-soft);
  color: var(--good);
}

.cp-note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 560px) {
  .cp-row {
    grid-template-columns: 1fr auto;
  }

  .cp-check {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1080px) and (min-height: 600px) {
  .checkpoints.has-band .cp-row {
    grid-template-columns: minmax(6.5rem, auto) 1fr;
  }

  .checkpoints.has-band .cp-state {
    display: none;
  }
}

.check-head {
  margin: 0.8rem 0 0.3rem;
  font-weight: 600;
  color: var(--ink);
}

/* A guess before the answer. */
.predict {
  margin: 0.25rem 0;
  padding: 0.6rem 0.7rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.predict-q {
  margin: 0 0 0.4rem;
  color: var(--ink);
}

.predict-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.predict-option {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.predict-option:hover {
  border-color: var(--ink-2);
}

.predict.is-answered .predict-option[aria-pressed="true"]:not(.is-right) {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
}

.predict.is-answered .predict-option.is-right {
  border-color: var(--good-line);
  background: var(--good-soft);
  color: var(--good);
}

.predict-reply {
  margin: 0.45rem 0 0;
  color: var(--ink-2);
}

.cp-next .cp-state {
  background: var(--warn-soft);
  color: var(--warn);
}

/* What usually happens when nobody looks, and the best-case note on the last step. */
.later,
.best-case {
  margin: 0.25rem 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--bad-line);
  border-radius: var(--radius);
  background: var(--bad-soft);
  color: var(--ink);
}

.later p,
.best-case p {
  margin: 0 0 0.35rem;
}

.later-head,
.best-case-head {
  font-weight: 700;
  color: var(--bad);
}

.best-case ul {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.best-case li + li {
  margin-top: 0.3rem;
}

.later .evidence-source,
.best-case .evidence-source {
  color: var(--ink-2);
  font-size: 0.85rem;
}

/* ── The computer as an old-school monitor ──
   A thick beige bezel, a dark ring around rounded glass, and a small stand. The screen itself stays
   black on white, so nothing gets harder to read. Capped in width: wider adds empty space, not content. */
.ide {
  position: relative;
  width: 100%;
  max-width: 42rem;
  margin-inline: auto;
  border-radius: 1.1rem;
}

.ide-screen {
  margin: 4px;
  border-radius: 0.7rem;
  box-shadow: 0 0 0 5px #3a332c;
}

@media (min-width: 768px) {
  .ide {
    padding: 1.1rem 1.1rem 0.45rem;
  }
}

/* The stand: a neck and a foot under the case. Only where there is height to spare. */
@media (min-width: 768px) and (min-height: 841px) {
  .ide {
    margin-bottom: 1.6rem;
  }

  .ide::before,
  .ide::after {
    position: absolute;
    left: 50%;
    border: 2px solid var(--ink);
    background: var(--case);
    content: "";
    pointer-events: none;
    transform: translateX(-50%);
  }

  .ide::before {
    bottom: calc(-0.9rem - 2px);
    width: 5rem;
    height: 0.9rem;
    border-top: 0;
    border-bottom: 0;
    background: var(--case-dark);
  }

  .ide::after {
    bottom: calc(-1.6rem - 2px);
    width: 13rem;
    height: 0.7rem;
    border-radius: 0.5rem 0.5rem 0.25rem 0.25rem;
    box-shadow: 3px 3px 0 var(--ink);
  }
}
