/* ============================================================
   The Shepherd Mayfair — Opera training
   Palette is the hotel's: midnight navy ground, ivory type,
   brass for anything the trainee must act on.
   Every Opera code is set in mono, everywhere, without exception —
   so the shape of a code becomes recognisable before the meaning is.
   ============================================================ */

:root {
  --navy:        #010612;
  --navy-raise:  #080f1e;
  --navy-high:   #0d1626;
  --line:        #1a2438;
  --line-soft:   #121b2c;

  --ivory:       #ffead6;
  --ivory-dim:   #c9bcae;
  --slate:       #7f8ca3;

  --brass:       #c4a265;
  --brass-deep:  #8a7040;
  --brass-glow:  rgba(196, 162, 101, 0.16);

  --sage:        #7fa07a;
  --claret:      #b04a4a;

  --display: 'Archivo', 'Segoe UI', system-ui, sans-serif;
  --body:    'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:    'JetBrains Mono', 'Cascadia Mono', ui-monospace, monospace;

  --rail-w: 248px;
  --ease:   cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--navy);
  color: var(--ivory-dim);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Ambient: a slow brass wash in the top-left, like lamplight on a desk. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 620px at 12% -8%, rgba(196, 162, 101, 0.10), transparent 62%),
    radial-gradient(700px 500px at 96% 4%, rgba(255, 234, 214, 0.045), transparent 60%);
  z-index: 0;
}

/* ---------- shared type ---------- */

h1, h2, h3, h4 {
  font-family: var(--display);
  color: var(--ivory);
  margin: 0;
  line-height: 1.08;
  letter-spacing: -0.015em;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--brass); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin: 0 0 14px;
}

/* The code token — the one element repeated across the whole course. */
.code {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.86em;
  letter-spacing: 0.06em;
  color: var(--brass);
  background: var(--brass-glow);
  border: 1px solid rgba(196, 162, 101, 0.3);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}
.code--plain { background: none; border-color: transparent; padding: 0; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px; top: 12px; z-index: 99;
  background: var(--brass); color: var(--navy);
  padding: 10px 16px; border-radius: 4px;
  font-family: var(--display); font-weight: 600;
}

/* ---------- shell ---------- */

.shell > * { min-width: 0; }

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: 0;
  min-height: 100vh;
}

/* ---------- left rail ---------- */

.rail {
  border-right: 1px solid var(--line);
  padding: 34px 24px 40px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: rgba(1, 6, 18, 0.82);
  backdrop-filter: blur(6px);
}

.rail__mark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ivory);
  line-height: 1.35;
}
.rail__sub {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-top: 8px;
}

.rail__progress {
  margin: 26px 0 30px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ring { width: 42px; height: 42px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .ring__bg { stroke: var(--line); }
.ring .ring__fg {
  stroke: var(--brass);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s var(--ease);
}
.rail__pct {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--slate);
  letter-spacing: 0.06em;
}

.rail__list { list-style: none; margin: 0; padding: 0; }
.rail__item { margin-bottom: 2px; }

.rail__link {
  display: block;
  padding: 9px 12px 9px 14px;
  border-left: 2px solid transparent;
  color: var(--ivory-dim);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.rail__link:hover {
  color: var(--ivory);
  background: var(--line-soft);
}
.rail__link.is-active {
  color: var(--ivory);
  border-left-color: var(--brass);
  background: var(--line-soft);
}
.rail__link[aria-disabled="true"] {
  color: #4a556b;
  cursor: default;
}
.rail__link[aria-disabled="true"]:hover { background: none; color: #4a556b; }

.rail__soon {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-left: 8px;
}

.rail__group {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #4a556b;
  margin: 24px 0 10px 14px;
}

/* ---------- stage ---------- */

.stage {
  padding: 0 clamp(24px, 5vw, 76px) 120px;
  max-width: 1060px;
}

/* ---------- hero ---------- */

.hero {
  padding: clamp(64px, 11vh, 130px) 0 72px;
  border-bottom: 1px solid var(--line);
}

.hero__title {
  font-size: clamp(38px, 6.2vw, 74px);
  font-weight: 700;
  font-stretch: 118%;
  letter-spacing: -0.028em;
}
.hero__title em {
  font-style: normal;
  color: var(--brass);
}

.hero__lede {
  max-width: 54ch;
  margin-top: 26px;
  font-size: 17.5px;
  color: var(--ivory-dim);
}

/* Hero demo: an email resolving into two codes. */
.resolve {
  margin-top: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) auto minmax(0, 0.85fr);
  gap: 22px;
  align-items: center;
}

.resolve__note {
  background: var(--navy-raise);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 20px;
  min-height: 132px;
}
.resolve__from {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--brass-deep);
  letter-spacing: 0.04em;
  word-break: break-all;
}
.resolve__subj {
  font-family: var(--display);
  font-weight: 600;
  color: var(--ivory);
  font-size: 16px;
  margin: 8px 0 6px;
}
.resolve__body {
  font-size: 13.5px;
  color: var(--slate);
  line-height: 1.55;
}

.resolve__arrow {
  color: var(--brass-deep);
  font-family: var(--mono);
  font-size: 20px;
  text-align: center;
}

.resolve__out { display: grid; gap: 10px; }
.resolve__slot {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--navy-raise);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.resolve__key {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--slate);
}
.resolve__val {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 22px;
  color: var(--brass);
  letter-spacing: 0.04em;
}

/* ---------- bands ---------- */

.band {
  padding: 88px 0 0;
  scroll-margin-top: 24px;
}
.band__head { max-width: 62ch; margin-bottom: 34px; }
.band__title {
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 600;
  font-stretch: 112%;
}
.band__intro { margin-top: 16px; font-size: 16.5px; }

/* ---------- the two axes ---------- */

.axis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.axis__card {
  border: 1px solid var(--line);
  border-top: 2px solid var(--brass);
  border-radius: 4px;
  background: var(--navy-raise);
  padding: 26px 26px 28px;
}
.axis__q {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  color: var(--ivory);
  margin-bottom: 12px;
}
.axis__from {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--slate);
}

/* ---------- collisions ---------- */

.collide { display: grid; gap: 14px; }
.collide__row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--navy-raise);
  padding: 20px 22px;
}
.collide__code {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 26px;
  color: var(--brass);
  letter-spacing: 0.04em;
}
.collide__cell { font-size: 14.5px; }
.collide__tag {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-bottom: 5px;
}

/* ---------- annotated screenshots ---------- */

.shots { display: grid; gap: 46px; }

.shot__title {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 6px;
}
.shot__cap { font-size: 14.5px; color: var(--slate); margin-bottom: 16px; max-width: 66ch; }

.shot__frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--navy-high);
  line-height: 0;
}
.shot__frame img { width: 100%; height: auto; display: block; }

.spot {
  position: absolute;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 1.5px solid var(--brass);
  background: rgba(1, 6, 18, 0.72);
  color: var(--brass);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 23px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease);
}
.spot::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--brass);
  opacity: 0.55;
  animation: ping 2.8s var(--ease) infinite;
}
.spot:hover, .spot:focus-visible, .spot.is-open {
  transform: scale(1.18);
  background: var(--brass);
  color: var(--navy);
}
.spot.is-open::after { animation: none; opacity: 0; }

@keyframes ping {
  0%   { transform: scale(0.85); opacity: 0.6; }
  70%  { transform: scale(1.5);  opacity: 0; }
  100% { transform: scale(1.5);  opacity: 0; }
}

.spot__note {
  margin-top: 14px;
  border-left: 2px solid var(--brass);
  background: var(--navy-raise);
  padding: 14px 18px;
  border-radius: 0 4px 4px 0;
  font-size: 14.5px;
  line-height: 1.6;
  min-height: 62px;
}
.spot__note b {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
}

/* ---------- sorter ---------- */

.sorter { display: grid; grid-template-columns: minmax(0, 1fr) 268px; gap: 26px; align-items: start; }

.mailstack { position: relative; min-height: 268px; }

.mail {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--navy-raise);
  padding: 20px 22px 22px;
  cursor: grab;
  user-select: none;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease), border-color 0.25s var(--ease);
}
.mail:active { cursor: grabbing; }
.mail.is-drag { border-color: var(--brass); opacity: 0.55; }
.mail__from { font-family: var(--mono); font-size: 11.5px; color: var(--brass-deep); word-break: break-all; }
.mail__subj { font-family: var(--display); font-weight: 600; color: var(--ivory); font-size: 16.5px; margin: 8px 0 8px; }
.mail__body { font-size: 14px; color: var(--slate); line-height: 1.6; }
.mail__count {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: 12px;
}

.bins {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.bin {
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--ivory-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 13px 6px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.bin:hover, .bin:focus-visible { border-color: var(--brass); color: var(--brass); }
.bin.is-over { border-color: var(--brass); background: var(--brass-glow); color: var(--brass); transform: scale(1.04); }
.bin__label {
  display: block;
  font-family: var(--body);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--slate);
  margin-top: 3px;
  text-transform: none;
}

.verdict {
  margin-top: 16px;
  border-left: 2px solid var(--line);
  padding: 14px 18px;
  border-radius: 0 4px 4px 0;
  background: var(--navy-raise);
  font-size: 14.5px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.verdict.is-shown { opacity: 1; transform: none; }
.verdict.is-right { border-left-color: var(--sage); }
.verdict.is-wrong { border-left-color: var(--claret); }
.verdict__head {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
}
.verdict.is-right .verdict__head { color: var(--sage); }
.verdict.is-wrong .verdict__head { color: var(--claret); }

.done {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--navy-raise);
  padding: 32px;
  text-align: center;
}
.done__score { font-family: var(--mono); font-size: 34px; font-weight: 700; color: var(--brass); }

/* ---------- the mail reader ---------- */

.reader {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--navy-raise);
  overflow: hidden;
  position: relative;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

.reader__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--navy-high);
  border-bottom: 1px solid var(--line);
}
.reader__dots { display: flex; gap: 6px; }
.reader__dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block; }
.reader__box {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--slate);
}
.reader__unread {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--brass-deep);
}

.msg { padding: 24px 26px 28px; }

.msg__head { display: flex; gap: 14px; align-items: flex-start; }
.avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #fff;
}
.msg__who { min-width: 0; flex: 1; }
.msg__name { font-family: var(--display); font-weight: 600; font-size: 15.5px; color: var(--ivory); }
.msg__addr { font-family: var(--mono); font-size: 11.5px; color: var(--brass-deep); word-break: break-all; margin-top: 2px; }
.msg__to   { font-size: 12.5px; color: #56617a; margin-top: 4px; }
.msg__date { font-family: var(--mono); font-size: 11px; color: var(--slate); flex: none; white-space: nowrap; }

.msg__label {
  display: inline-block;
  margin: 18px 0 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-deep);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 3px 8px;
}

.msg__subject {
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  color: var(--ivory);
  line-height: 1.28;
  margin: 14px 0 18px;
}
.msg__label + .msg__subject { margin-top: 8px; }

.msg__body { font-size: 14.5px; line-height: 1.68; color: var(--ivory-dim); }
.msg__body p { margin: 0 0 0.9em; }
.msg__body.is-pre p {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  margin: 0;
  white-space: pre-wrap;
  color: var(--ivory-dim);
}

.msg__details {
  margin: 16px 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.msg__details div {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  padding: 9px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line-soft);
}
.msg__details div:last-child { border-bottom: none; }
.msg__details span:first-child {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate);
  padding-top: 2px;
}

.msg__quote {
  margin: 14px 0;
  border-left: 2px solid var(--line);
  padding: 8px 0 8px 16px;
  font-size: 13px;
  color: var(--slate);
  font-style: italic;
}

.msg__attach {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--ivory-dim);
}
.msg__attach::before {
  content: "PDF";
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--navy);
  background: var(--brass-deep);
  border-radius: 2px;
  padding: 3px 5px;
}

.msg__sig {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 13.5px;
  color: var(--slate);
  white-space: pre-line;
  line-height: 1.55;
}

/* the stamp */
.stamp {
  position: absolute;
  top: 26%; left: 50%;
  transform: translate(-50%, -50%) rotate(-11deg) scale(1.7);
  border: 3px solid currentColor;
  border-radius: 6px;
  padding: 10px 26px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  background: rgba(1, 6, 18, 0.55);
  backdrop-filter: blur(1px);
}
.stamp.is-on { animation: thud 0.5s var(--ease) forwards; }
.stamp--right { color: var(--sage); }
.stamp--wrong { color: var(--claret); }
.stamp small {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  margin-top: 4px;
  opacity: 0.85;
}

@keyframes thud {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(-11deg) scale(1.7); }
  55%  { opacity: 1; transform: translate(-50%, -50%) rotate(-11deg) scale(0.94); }
  75%  { transform: translate(-50%, -50%) rotate(-11deg) scale(1.03); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-11deg) scale(1); }
}

.reader.is-answered .msg { opacity: 0.42; transition: opacity 0.4s var(--ease); }

/* scoreboard */
.score {
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.score__item {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--slate);
}
.score__item b {
  font-size: 15px;
  color: var(--ivory);
  margin-left: 7px;
  letter-spacing: 0.04em;
}
.score__item.is-hot b { color: var(--brass); }

/* the tells revealed after answering */
.tells { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }
.tell {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--brass);
  border: 1px solid rgba(196, 162, 101, 0.32);
  background: var(--brass-glow);
  border-radius: 3px;
  padding: 4px 9px;
}
.tells__lead {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--slate);
  margin-top: 14px;
}

/* grid and flex children must be allowed to shrink below their content */
.sorter > *, .quiz > *, .axis > *, .collide__row > *, .resolve > * { min-width: 0; }
.mailstack, .reader, .msg, .msg__body { min-width: 0; }
.msg__subject, .msg__body p, .msg__name { overflow-wrap: anywhere; }
.reader__bar { flex-wrap: wrap; }
.msg__head { flex-wrap: wrap; }

/* ---------- matrix ---------- */

.matrix-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table.matrix { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 560px; }
table.matrix th, table.matrix td {
  text-align: left;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
table.matrix thead th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass-deep);
  background: var(--navy-raise);
  border-bottom-color: var(--line);
  font-weight: 700;
}
table.matrix tbody tr:last-child td { border-bottom: none; }
table.matrix tbody tr { transition: background 0.2s var(--ease); }
table.matrix tbody tr:hover { background: var(--line-soft); }

/* ---------- quiz + the tag ---------- */

.quiz { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 34px; align-items: start; }

.quiz__scenario {
  border: 1px solid var(--line);
  border-top: 2px solid var(--brass);
  border-radius: 4px;
  background: var(--navy-raise);
  padding: 26px 28px 28px;
}
.quiz__step {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-bottom: 12px;
}
.quiz__text { font-family: var(--display); font-size: 20px; font-weight: 500; color: var(--ivory); line-height: 1.35; }

.picker { margin-top: 24px; }
.picker__label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: 9px;
}
.picker__grid { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ivory-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 11px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.chip:hover, .chip:focus-visible { border-color: var(--brass); color: var(--brass); }
.chip.is-picked { border-color: var(--brass); background: var(--brass); color: var(--navy); }
.chip:disabled { cursor: default; opacity: 0.45; }
.chip.is-right { border-color: var(--sage); background: var(--sage); color: var(--navy); opacity: 1; }
.chip.is-wrong { border-color: var(--claret); background: var(--claret); color: var(--ivory); opacity: 1; }

.btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  background: var(--brass);
  color: var(--navy);
  border: 1px solid var(--brass);
  border-radius: 3px;
  padding: 11px 22px;
  cursor: pointer;
  margin-top: 24px;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover { background: var(--ivory); border-color: var(--ivory); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn--ghost { background: transparent; color: var(--brass); }
.btn--ghost:hover { background: var(--brass-glow); border-color: var(--brass); color: var(--brass); }

/* The signature: a luggage tag that fills in as the trainee decides. */
.tag {
  position: relative;
  background: linear-gradient(168deg, #0e1828, #060d1a);
  border: 1px solid var(--brass-deep);
  border-radius: 4px 4px 4px 4px;
  padding: 46px 26px 26px;
  transform-origin: 50% 0;
  animation: hang 6s ease-in-out infinite;
}
.tag::before {
  content: "";
  position: absolute;
  top: 16px; left: 50%;
  width: 15px; height: 15px;
  margin-left: -7.5px;
  border-radius: 50%;
  border: 2px solid var(--brass-deep);
  background: var(--navy);
}
.tag__prop {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory);
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.tag__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 0;
  border-bottom: 1px dashed var(--line);
}
.tag__row:last-of-type { border-bottom: none; }
.tag__key {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--slate);
}
.tag__val {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--brass-deep);
  transition: color 0.3s var(--ease);
}
.tag__val.is-set { color: var(--brass); animation: stamp 0.42s var(--ease); }
.tag__foot {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #46516a;
  text-align: center;
}

@keyframes hang {
  0%, 100% { transform: rotate(-0.7deg); }
  50%      { transform: rotate(0.7deg); }
}
@keyframes stamp {
  0%   { transform: scale(1.35); opacity: 0.2; }
  60%  { transform: scale(0.97); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---------- reveal on scroll ---------- */

.rise {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.rise.is-in { opacity: 1; transform: none; }

/* ---------- footer ---------- */

.foot {
  margin-top: 96px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: #4a556b;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

/* ---------- focus ---------- */

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

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .sorter, .quiz { grid-template-columns: 1fr; }
  .bins { grid-template-columns: repeat(4, 1fr); }
  .quiz aside { max-width: 320px; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    min-width: 0;
    overflow-x: hidden;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 22px 24px;
  }
  .rail__list {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 6px;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .rail__item { flex: none; }
  .rail__link { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .rail__link.is-active { border-left: none; border-bottom-color: var(--brass); }
  .rail__group { display: none; }
  .sorter, .quiz { grid-template-columns: 1fr; }
  .resolve { grid-template-columns: 1fr; }
  .resolve__arrow { transform: rotate(90deg); }
}

@media (max-width: 620px) {
  .collide__row { grid-template-columns: 1fr; gap: 12px; }
  .msg { padding: 20px 18px 22px; }
  .msg__details div { grid-template-columns: 1fr; gap: 2px; }
  .stamp { font-size: 22px; padding: 8px 18px; }
  .bins { grid-template-columns: repeat(2, 1fr); }
  .stage { padding-bottom: 80px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .rise { opacity: 1; transform: none; }
}

/* ============================================================
   Lesson layout
   ============================================================ */

.rail__mark { display: block; text-decoration: none; }

.rail__n {
  display: inline-block;
  width: 22px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--brass-deep);
  letter-spacing: 0.04em;
}
.rail__link { display: flex; gap: 2px; align-items: baseline; }
.rail__link.is-done .rail__n { color: var(--sage); }
.rail__link.is-done .rail__n::after { content: "\2713"; }
.rail__link.is-done .rail__n { font-size: 0; }
.rail__link.is-done .rail__n::after { font-size: 11px; }

/* ---------- home ---------- */

.parts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
  gap: 18px;
  padding: 56px 0 40px;
}
.partcard {
  border: 1px solid var(--line);
  border-top: 2px solid var(--brass);
  border-radius: 4px;
  background: var(--navy-raise);
  padding: 24px 24px 26px;
}
.partcard__n {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass-deep);
}
.partcard__t { font-family: var(--display); font-size: 20px; font-weight: 600; margin: 8px 0 8px; }
.partcard__b { font-size: 13.5px; color: var(--slate); margin-bottom: 16px; }
.partcard__list { list-style: none; margin: 0; padding: 0; }
.partcard__list li { margin-bottom: 7px; }
.partcard__list a {
  color: var(--ivory-dim);
  text-decoration: none;
  font-size: 14px;
  border-bottom: 1px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.partcard__list a:hover { color: var(--brass); border-bottom-color: var(--brass-deep); }
.partcard__list a.is-done { color: var(--sage); }

.hero .btn { display: inline-block; text-decoration: none; margin-top: 34px; }

/* ---------- lesson head ---------- */

.lesson__head {
  padding: clamp(48px, 8vh, 86px) 0 34px;
  border-bottom: 1px solid var(--line);
  max-width: 68ch;
}
.lesson__title {
  font-size: clamp(30px, 4.6vw, 52px);
  font-weight: 700;
  font-stretch: 116%;
  letter-spacing: -0.026em;
}
.lesson__lede {
  margin-top: 20px;
  font-size: 18px;
  color: var(--ivory-dim);
  max-width: 58ch;
}

.lesson__body { padding-top: 12px; }

/* ---------- blocks ---------- */

.blk { padding: 40px 0 0; max-width: 74ch; }
.blk__h {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  font-stretch: 108%;
  margin-bottom: 14px;
}
.blk__p { font-size: 16.5px; line-height: 1.72; }

.widget { max-width: none; padding-top: 52px; }

dl.defs { margin: 0; }
dl.defs dt {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brass);
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
dl.defs dt:first-child { border-top: none; padding-top: 0; }
dl.defs dd {
  margin: 5px 0 14px;
  font-size: 15px;
  line-height: 1.62;
  color: var(--ivory-dim);
}

ol.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
ol.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
  margin-bottom: 15px;
  font-size: 15.5px;
  line-height: 1.62;
}
ol.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 1px;
  width: 24px; height: 24px;
  border: 1px solid var(--brass-deep);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--brass);
  display: grid;
  place-items: center;
}

/* ---------- callouts ---------- */

.callout {
  margin: 34px 0 0;
  max-width: 74ch;
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass);
  border-radius: 0 4px 4px 0;
  background: var(--navy-raise);
  padding: 20px 24px 22px;
}
.callout__tone {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 8px;
}
.callout__h { font-family: var(--display); font-weight: 600; font-size: 16.5px; color: var(--ivory); margin-bottom: 7px; }
.callout__p { font-size: 15px; line-height: 1.66; color: var(--ivory-dim); }

.callout--watch { border-left-color: var(--claret); }
.callout--watch .callout__tone { color: var(--claret); }
.callout--why { border-left-color: var(--sage); }
.callout--why .callout__tone { color: var(--sage); }
.callout--author {
  border-left-color: var(--slate);
  border-style: dashed;
  background: transparent;
}
.callout--author .callout__tone { color: var(--slate); }

/* ---------- shots inside lessons ---------- */

.shot { margin: 46px 0 0; padding: 0; }
.shot__frame.is-missing { min-height: 180px; display: grid; place-items: center; }
.shot__missing {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--brass-deep);
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 14px 20px;
  line-height: 1.5;
}
.shot__frame.is-missing img { display: none; }

.soft { color: var(--slate); }

/* ---------- check yourself ---------- */

.check {
  margin-top: 66px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
  max-width: 74ch;
}
.check__card { margin-top: 18px; }
.check__q { font-family: var(--display); font-size: 18.5px; font-weight: 500; color: var(--ivory); line-height: 1.4; margin-bottom: 16px; }
.check__opts { display: grid; gap: 8px; }
.opt {
  text-align: left;
  font-family: var(--body);
  font-size: 15px;
  color: var(--ivory-dim);
  background: var(--navy-raise);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 13px 18px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.opt:hover:not(:disabled) { border-color: var(--brass); color: var(--brass); }
.opt:disabled { cursor: default; opacity: 0.5; }
.opt.is-right { border-color: var(--sage); color: var(--sage); opacity: 1; }
.opt.is-wrong { border-color: var(--claret); color: var(--claret); opacity: 1; }

/* ---------- lesson nav ---------- */

.lessonnav {
  margin-top: 72px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.lessonnav__link {
  display: block;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 20px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.lessonnav__link:hover { border-color: var(--brass); background: var(--line-soft); }
.lessonnav__link--next { text-align: right; }
.lessonnav__dir {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-bottom: 5px;
}
.lessonnav__t { font-family: var(--display); font-size: 15px; font-weight: 600; color: var(--ivory); }

@media (max-width: 620px) {
  .lessonnav { grid-template-columns: 1fr; }
  .lessonnav__link--next { text-align: left; }
}

/* ---------- load failure ---------- */

.fault {
  max-width: 62ch;
  margin: clamp(48px, 12vh, 120px) 0;
  border: 1px dashed var(--claret);
  border-radius: 5px;
  padding: 32px 34px 34px;
  background: var(--navy-raise);
}
.fault__tone {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--claret);
  margin-bottom: 10px;
}
.fault__h {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 16px;
}
.fault p { font-size: 15.5px; line-height: 1.68; margin-bottom: 1em; }
.fault ul { margin: 0 0 1.2em; padding-left: 20px; }
.fault li { font-family: var(--mono); font-size: 13px; color: var(--brass); margin-bottom: 4px; }
.fault code { font-family: var(--mono); font-size: 0.9em; color: var(--brass); }

/* ============================================================
   Finish
   The house style: brass on midnight, hairline rules, nothing
   that moves faster than a person walking through a lobby.
   ============================================================ */

/* ---------- scrollbars ---------- */

* { scrollbar-width: thin; scrollbar-color: var(--brass-deep) transparent; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track {
  background: var(--navy);
  border-left: 1px solid var(--line-soft);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--brass-deep), #6d5730);
  border: 3px solid var(--navy);
  border-radius: 99px;
  transition: background 0.3s var(--ease);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--brass), var(--brass-deep));
}
::-webkit-scrollbar-corner { background: var(--navy); }

/* Inner scrollers get a quieter treatment. */
.rail::-webkit-scrollbar,
.matrix-wrap::-webkit-scrollbar { width: 7px; height: 7px; }
.rail::-webkit-scrollbar-thumb,
.matrix-wrap::-webkit-scrollbar-thumb { border-width: 2px; }

/* ---------- selection ---------- */

::selection { background: var(--brass); color: var(--navy); }
::-moz-selection { background: var(--brass); color: var(--navy); }

/* ---------- grain ---------- */

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- scroll progress hairline ---------- */

.readbar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  z-index: 40;
  background: linear-gradient(90deg, var(--brass-deep), var(--brass), var(--ivory));
  box-shadow: 0 0 12px rgba(196, 162, 101, 0.5);
  transition: width 0.1s linear, opacity 0.4s var(--ease);
}

/* ---------- rail: a brass spine that fills with progress ---------- */

.rail { position: sticky; }
.rail__fill {
  position: absolute;
  top: 0; right: -1px;
  width: 2px;
  background: linear-gradient(180deg, var(--brass), var(--brass-deep));
  box-shadow: 0 0 10px rgba(196, 162, 101, 0.35);
  transition: height 0.8s var(--ease);
  height: 0;
}
@media (max-width: 980px) { .rail__fill { display: none; } }

.rail__link { position: relative; overflow: hidden; }
.rail__link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  height: 1px; width: 100%;
  background: var(--brass);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease);
  opacity: 0.45;
}
.rail__link:hover::after { transform: scaleX(1); }
.rail__link[aria-disabled="true"]::after { display: none; }

/* ---------- greeting ---------- */

.greet {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-bottom: 18px;
  min-height: 15px;
}
.greet b { color: var(--brass); font-weight: 700; }

.namebox {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 30px;
  flex-wrap: wrap;
}
.namebox input {
  font-family: var(--body);
  font-size: 15px;
  color: var(--ivory);
  background: var(--navy-raise);
  border: 1px solid var(--line);
  border-bottom: 1px solid var(--brass-deep);
  border-radius: 3px;
  padding: 11px 15px;
  width: 232px;
  transition: border-color 0.25s var(--ease);
}
.namebox input::placeholder { color: #4c566d; }
.namebox input:focus { outline: none; border-color: var(--brass); }
.namebox__hint { font-size: 12.5px; color: var(--slate); width: 100%; margin-top: 2px; }

/* ---------- lesson head: the room plate ---------- */

.lesson__head { position: relative; overflow: hidden; }

.plate {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  border: 1px solid var(--brass-deep);
  border-radius: 3px;
  padding: 6px 13px 7px;
  margin-bottom: 20px;
  background: linear-gradient(150deg, rgba(196,162,101,0.13), transparent 70%);
}
.plate__k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--brass-deep);
}
.plate__n {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brass);
}

.ghost {
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-46%);
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 125%;
  font-size: clamp(120px, 21vw, 250px);
  line-height: 0.8;
  color: var(--ivory);
  opacity: 0.028;
  pointer-events: none;
  user-select: none;
  letter-spacing: -0.05em;
}

.meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--slate);
}
.meta span::before {
  content: "·";
  margin-right: 18px;
  color: var(--brass-deep);
}
.meta span:first-child::before { content: none; margin: 0; }

/* ---------- entrance ---------- */

@keyframes lift {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.enter > * {
  opacity: 0;
  animation: lift 0.66s var(--ease) forwards;
}
.enter > *:nth-child(1) { animation-delay: 0.02s; }
.enter > *:nth-child(2) { animation-delay: 0.09s; }
.enter > *:nth-child(3) { animation-delay: 0.16s; }
.enter > *:nth-child(4) { animation-delay: 0.23s; }
.enter > *:nth-child(5) { animation-delay: 0.30s; }
.enter > *:nth-child(n+6) { animation-delay: 0.36s; }

/* ---------- warmer hover states ---------- */

dl.defs dt { transition: color 0.25s var(--ease), letter-spacing 0.25s var(--ease); }
dl.defs dt:hover { color: var(--ivory); letter-spacing: 0.09em; }

.partcard { transition: border-color 0.35s var(--ease), transform 0.35s var(--ease); }
.partcard:hover { border-color: var(--brass-deep); transform: translateY(-2px); }

.callout { transition: border-left-width 0.3s var(--ease); }
.callout:hover { border-left-width: 4px; }

ol.steps li::before { transition: background 0.3s var(--ease), color 0.3s var(--ease); }
ol.steps li:hover::before { background: var(--brass); color: var(--navy); }

.shot__frame { transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease); }
.shot__frame:hover {
  border-color: var(--brass-deep);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- completion seal ---------- */

.seal {
  margin: 44px 0 0;
  border: 1px solid var(--brass-deep);
  border-radius: 5px;
  background: linear-gradient(158deg, rgba(196,162,101,0.11), transparent 62%);
  padding: 40px 34px 38px;
  text-align: center;
}
.seal__ring {
  width: 74px; height: 74px;
  margin: 0 auto 20px;
  border: 2px solid var(--brass);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 26px;
  color: var(--brass);
  animation: hang 7s ease-in-out infinite;
}
.seal__h {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 600;
  font-stretch: 110%;
  margin-bottom: 10px;
}
.seal__b { font-size: 15px; color: var(--ivory-dim); max-width: 46ch; margin: 0 auto; }
.seal__n {
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass-deep);
}

/* ---------- keyboard hint ---------- */

.keys {
  margin-top: 26px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #465064;
  text-align: center;
}
.keys kbd {
  font-family: var(--mono);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 6px;
  color: var(--slate);
  margin: 0 2px;
}

/* ---------- print ---------- */

@media print {
  body { background: #fff; color: #111; }
  body::before, body::after, .readbar, .rail, .lessonnav, .keys { display: none !important; }
  .shell { display: block; }
  .stage { max-width: none; padding: 0; }
  h1, h2, h3, .lesson__title, .blk__h, .callout__h { color: #000; }
  .blk__p, .callout__p, dl.defs dd, ol.steps li, .lesson__lede { color: #222; }
  .callout, .partcard, .shot__frame, .quiz__scenario { background: #fff; border-color: #999; }
  dl.defs dt, .code, .plate__n, .eyebrow { color: #6d5730; }
  .ghost, .spot { display: none; }
  .rise { opacity: 1 !important; transform: none !important; }
  .enter > * { opacity: 1 !important; animation: none !important; }
  a { text-decoration: none; color: #000; }
}

.lessonwrap { display: block; }

/* ---------- code reference card ---------- */

.codecard {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--navy-raise);
  overflow: hidden;
}
.codecard__row {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 20px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.25s var(--ease);
}
.codecard__row:last-child { border-bottom: none; }
.codecard__row:hover { background: var(--line-soft); }
.codecard__k { padding-top: 1px; }
.codecard__m {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15.5px;
  color: var(--ivory);
}
.codecard__n { font-size: 14px; line-height: 1.6; color: var(--slate); margin-top: 5px; }

@media (max-width: 620px) {
  .codecard__row { grid-template-columns: 1fr; gap: 8px; }
}

/* ---------- diagrams ---------- */

.dgwrap {
  margin-top: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--navy-raise);
  padding: 26px 24px 22px;
}
.dg { width: 100%; height: auto; display: block; overflow: visible; }

.dg-box   { fill: var(--navy-high); stroke: var(--line); stroke-width: 1; }
.dg-key   { fill: rgba(196,162,101,0.07); stroke: var(--brass-deep); stroke-width: 1.4; }
.dg-good  { fill: rgba(127,160,122,0.08); stroke: var(--sage); stroke-width: 1.2; }
.dg-bad   { fill: rgba(176,74,74,0.08); stroke: var(--claret); stroke-width: 1.2; }
.dg-ghost { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; }

.dg-line  { stroke: var(--line); stroke-width: 1; fill: none; }
.dg-lead  { stroke: var(--brass-deep); stroke-width: 1.2; fill: none; }
.dg-dash  { stroke: var(--brass-deep); stroke-width: 1; fill: none; stroke-dasharray: 4 4; }

.dg-t {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  fill: var(--ivory);
}
.dg-c {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  fill: var(--brass);
  text-transform: uppercase;
}
.dg-s { font-family: var(--body); font-size: 11.5px; fill: var(--slate); }
.dg-l {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  fill: var(--brass-deep);
  text-transform: uppercase;
}
.dg-r { font-family: var(--body); font-size: 12.5px; fill: var(--ivory-dim); }
.dg-dot { fill: var(--brass); }
.dg-sage { fill: var(--sage); }
.dg-claret { fill: var(--claret); }

.dgcap {
  margin-top: 14px;
  font-size: 13px;
  color: var(--slate);
  line-height: 1.55;
}

@media print {
  .dg-box, .dg-key, .dg-good, .dg-bad { fill: #fff; stroke: #888; }
  .dg-t { fill: #000; } .dg-r { fill: #222; } .dg-s { fill: #555; }
  .dg-c, .dg-l { fill: #6d5730; }
  .dgwrap { background: #fff; }
}

.partcard__count {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-bottom: 14px;
}

/* ============================================================
   Mobile
   The rail becomes a drawer, and wide diagrams get a viewer.
   ============================================================ */

.rail__toggle { display: none; }

@media (max-width: 980px) {

  /* ---- the rail collapses to a compact bar ---- */
  .rail {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 11px 16px 11px;
    background: rgba(1, 6, 18, 0.94);
    backdrop-filter: blur(10px);
  }
  .rail__mark { font-size: 11.5px; letter-spacing: 0.13em; line-height: 1.25; }
  .rail__sub { display: none; }

  .rail__progress { margin: 0 0 0 auto; gap: 8px; }
  .ring { width: 30px; height: 30px; }
  .rail__pct { font-size: 10px; letter-spacing: 0.04em; }

  .rail__toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    order: 3;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brass);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 9px 13px;
    min-height: 40px;
    cursor: pointer;
  }
  .rail__toggle__bars { display: grid; gap: 3px; width: 13px; }
  .rail__toggle__bars i {
    display: block; height: 1.5px; background: var(--brass);
    transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
  }
  .rail.is-open .rail__toggle { border-color: var(--brass-deep); }
  .rail.is-open .rail__toggle__bars i:nth-child(1) { transform: translateY(4.5px) rotate(45deg); }
  .rail.is-open .rail__toggle__bars i:nth-child(2) { opacity: 0; }
  .rail.is-open .rail__toggle__bars i:nth-child(3) { transform: translateY(-4.5px) rotate(-45deg); }

  /* ---- the contents list, vertical and labelled again ---- */
  #railParts {
    display: none;
    width: 100%;
    order: 4;
    max-height: 66vh;
    overflow-y: auto;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  .rail.is-open #railParts { display: block; }

  .rail__group {
    display: block;
    margin: 18px 0 8px 2px;
    color: var(--brass-deep);
  }
  .rail__group:first-child { margin-top: 4px; }

  .rail__list { display: block; overflow: visible; padding-bottom: 0; }
  .rail__item { flex: none; }
  .rail__link {
    white-space: normal;
    border-left: 2px solid var(--line-soft);
    border-bottom: none;
    padding: 11px 12px 11px 14px;
    min-height: 44px;
    font-size: 14.5px;
  }
  .rail__link.is-active {
    border-left-color: var(--brass);
    border-bottom: none;
  }
  .rail__link.is-done { border-left-color: rgba(127, 160, 122, 0.55); }

  /* ---- comfortable tap targets ---- */
  .chip { padding: 10px 13px; font-size: 12.5px; min-height: 40px; }
  .opt { padding: 15px 18px; }
  .spot { width: 30px; height: 30px; margin: -15px 0 0 -15px; line-height: 27px; }

  /* ---- diagrams get an enlarge affordance ---- */
  .dgwrap { cursor: zoom-in; position: relative; padding-bottom: 34px; }
  .dgwrap::after {
    content: "Tap to enlarge";
    position: absolute;
    left: 0; right: 0; bottom: 12px;
    text-align: center;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--brass-deep);
  }
}

@media (max-width: 620px) {
  .lesson__title { font-size: clamp(27px, 8vw, 34px); }
  .hero__title, .lesson__title, .band__title { overflow-wrap: anywhere; }
  .ghost { right: -22px; opacity: 0.022; }
  .meta { gap: 12px; font-size: 9.5px; }
  .meta span::before { margin-right: 12px; }
  .plate { margin-bottom: 16px; }
}

/* ---- the full-screen diagram viewer ---- */

.dgview {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(1, 6, 18, 0.975);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.dgview.is-on { opacity: 1; }
.dgview__stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
}
.dgview__stage svg { display: block; }

.dgview__close {
  position: absolute;
  top: 14px; right: 14px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--navy-raise);
  color: var(--brass);
  font-family: var(--mono);
  font-size: 17px;
  cursor: pointer;
  z-index: 2;
}
.dgview__hint {
  position: absolute;
  bottom: 18px; left: 0; right: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-deep);
}
