/* =====================================================================
   module.css: lesson page layout + interactive widget styling
   ===================================================================== */

/* ---- Reading-progress bar (under nav) ------------------------------ */
.progressbar { position: fixed; top: var(--nav-h); left: 0; right: 0; height: 2px; z-index: 90; background: transparent; }
.progressbar i { display: block; height: 100%; width: 0%; background: var(--text); transform-origin: left; }

/* ---- Page shell ---------------------------------------------------- */
.mpage { padding-top: calc(var(--nav-h) + 2px); }
.mlayout {
  display: grid; grid-template-columns: 260px minmax(0, 1fr);
  gap: clamp(28px, 5vw, 64px);
  max-width: 1160px; margin-inline: auto; padding-inline: clamp(20px, 5vw, 40px);
}
@media (max-width: 940px) { .mlayout { grid-template-columns: 1fr; } }

/* ---- Sidebar ------------------------------------------------------- */
.side { position: sticky; top: calc(var(--nav-h) + 28px); align-self: start; height: fit-content;
  padding-block: 40px; }
@media (max-width: 940px) {
  .side { position: static; padding-block: 20px; border-bottom: 1px solid var(--line-soft); }
}
.side__back { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--text-3);
  margin-bottom: 22px; transition: color var(--dur-1); }
.side__back:hover { color: var(--text); }
.side__back svg { width: 13px; height: 13px; stroke: currentColor; }
.side__label { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin-bottom: 12px; }
.side__toc { list-style: none; display: flex; flex-direction: column; gap: 2px; margin-bottom: 26px; }
.side__toc a { border: 2px solid transparent; display: block; padding: 7px 12px; border-radius: 8px; font-size: 0.88rem; color: var(--text-2);
  transition: color var(--dur-1), background var(--dur-1); line-height: 1.35; }
.side__toc a:hover { background: var(--bg-subtle); color: var(--text); }
.side__toc a.is-active { color: var(--text); font-weight: 560; background: var(--bg-subtle); border-color: var(--accent); }
.side__coursetoggle { display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.side__coursetoggle .side__label { margin-bottom: 0; }
.side__coursetoggle svg { width: 16px; height: 16px; stroke: currentColor; display: none; transition: transform var(--dur-1); }
.side__modnav { list-style: none; display: flex; flex-direction: column; gap: 1px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.side__modnav a { display: flex; gap: 10px; align-items: baseline; padding: 6px 8px; border-radius: 7px; font-size: 0.82rem; color: var(--text-3); }
.side__modnav a:hover { background: var(--bg-subtle); color: var(--text); }
.side__modnav a.is-current { color: var(--text); font-weight: 560; }
.side__modnav .num { font-variant-numeric: tabular-nums; color: var(--text-3); font-size: 0.78rem; }
.side__modnav a.is-done .num { color: var(--success); }

.nav__coursetoggle { display: none; }
@media (max-width: 940px) {
  .side__tocsec { display: none; }
  .side__coursetoggle { display: none; }
  .nav__coursetoggle { display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: 0; background: none; color: var(--text-2);
    cursor: pointer; border-radius: 8px; padding: 0; }
  .nav__coursetoggle:hover { background: var(--bg-subtle); color: var(--text); }
  .nav__coursetoggle svg { width: 18px; height: 18px; stroke: currentColor; transition: transform var(--dur-1); }
  .nav__coursetoggle[aria-expanded="true"] svg { transform: rotate(90deg); }
  .side__modnav { display: none; position: fixed; z-index: 101; left: 16px; right: 16px;
    top: calc(var(--nav-h) + 12px); max-height: calc(100vh - var(--nav-h) - 24px); overflow-y: auto;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-lg); padding: 10px; margin: 0; }
  .side__coursetoggle[aria-expanded="true"] + .side__modnav { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
  .nav__coursetoggle svg { transition: none; }
}

/* ---- Content column ----------------------------------------------- */
.content { max-width: 740px; padding-block: 40px 90px; min-width: 0; }
.mhead { margin-bottom: 40px; padding-bottom: 30px; border-bottom: 1px solid var(--line-soft); }
.mhead__tag { display: inline-flex; gap: 8px; align-items: center; font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 16px; }
.mhead__tag b { color: var(--accent); font-weight: 620; }
.mhead h1 { margin-bottom: 14px; }
.mhead__sub { font-size: 1.16rem; color: var(--text-2); line-height: 1.5; }
.mhead__facts { display: flex; gap: 16px; margin-top: 20px; font-size: 0.84rem; color: var(--text-3); flex-wrap: wrap; }
.mhead__facts span { display: inline-flex; gap: 6px; align-items: center; }

/* Lessons */
.lesson { padding-block: 22px; scroll-margin-top: calc(var(--nav-h) + 20px); }
.lesson + .lesson { border-top: 1px solid var(--line-soft); }
.lesson__k { font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.lesson h2 { margin-bottom: 18px; }
.content p { margin-bottom: 16px; font-size: 1.03rem; line-height: 1.62; }
.content h3 { margin: 30px 0 12px; }
.content ul, .content ol { margin: 0 0 18px 0; padding-left: 22px; color: var(--text-2); }
.content li { margin-bottom: 8px; line-height: 1.55; }
.content li::marker { color: var(--text-3); }
.content a.inline { color: var(--accent); border-bottom: 1px solid var(--accent-soft); }
.content a.inline:hover { border-bottom-color: var(--accent); }

/* ---- Three-tier list (module 3) ----------------------------------- */
.tiers3 { display: flex; flex-direction: column; gap: 12px; margin: 22px 0; }
.t3 { display: grid; grid-template-columns: 40px 1fr; gap: 18px; align-items: start;
  padding: 20px 22px; background: var(--bg-subtle); border: 1px solid var(--line-soft); border-radius: var(--radius);
  position: relative; }
.t3::before { content: ""; position: absolute; left: 39px; top: 54px; bottom: -12px; width: 1px; background: var(--line); }
.t3:last-child::before { display: none; }
.t3__n { width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 640; position: relative; z-index: 1; }
.t3 h4 { margin-bottom: 5px; }
.t3 p { font-size: 0.94rem; margin: 0; }

/* ---- Context-window tiers (Module 3) ------------------------------ */
.ctxwin { margin: 22px 0; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--card); box-shadow: var(--shadow-md); }
.ctxwin__head { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); }
.ctxwin__lab { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-3); }
.ctxwin__play { margin-left: auto; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 13px; font: inherit; font-size: 0.85rem; cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1); }
.ctxwin__play:hover { background: var(--bg-subtle); border-color: var(--text-3); }
.ctxwin__play.is-playing { color: var(--text-3); cursor: default; }
/* below the full-width context bar: tier cards on the left, window body on the right */
.ctxwin__stage { display: grid; grid-template-columns: 1fr 1fr;
  grid-template-areas: "tiers body"; }
@media (max-width: 760px) { .ctxwin__stage { grid-template-columns: 1fr;
  grid-template-areas: "tiers" "body"; } }

/* left: the three tier cards */
.ctxwin__tiers { grid-area: tiers; list-style: none; margin: 0; padding: 16px; display: flex; flex-direction: column;
  gap: 10px; border-right: 1px solid var(--line-soft); }
@media (max-width: 760px) { .ctxwin__tiers { border-right: none; border-bottom: 1px solid var(--line-soft); } }
.ctxwin__tier { padding: 13px 15px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--bg-sink); cursor: pointer;
  transition: opacity var(--dur-2), background var(--dur-1), border-color var(--dur-1), box-shadow var(--dur-1); }
.ctxwin__tier:hover { border-color: var(--text-3); }
.ctxwin__tier:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctxwin__tier h4 { margin: 0 0 5px; font-size: 0.98rem; }
.ctxwin__tier p { margin: 0; font-size: 0.9rem; color: var(--text-2); }
/* active-tier emphasis only appears once JS has enhanced the widget */
.ctxwin.is-live .ctxwin__tier { opacity: .55; }
.ctxwin.is-live .ctxwin__tier.is-active { opacity: 1; background: var(--card); box-shadow: var(--shadow-sm);
  border-color: var(--accent); }

/* full-width: the context window bar + fill meter */
.ctxwin__win { display: flex; flex-direction: column;
  background: var(--bg-sink); border-bottom: 1px solid var(--line-soft); }
.ctxwin__winbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #1d1d1f; }
.ctxwin__winname { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: .04em; color: #a1a1a6; }
.ctxwin__cost { margin-left: auto; font-family: var(--font-mono); font-size: 0.74rem; color: #fff;
  background: var(--accent); padding: 2px 10px; border-radius: 20px; transition: background var(--dur-2); }
/* right: the context window body (tier groups) */
.ctxwin__body { grid-area: body; padding: 14px; display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-sink); }
.ctxwin__grp { border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--card); overflow: hidden; }
.ctxwin__grplab { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: .03em; color: var(--text-3);
  padding: 7px 11px; background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); }
.ctxwin__meta, .ctxwin__file { padding: 9px 11px; display: flex; flex-direction: column; gap: 4px; }
.ctxwin__chip, .ctxwin__code { font-family: var(--font-mono); font-size: 0.76rem; line-height: 1.5; margin: 0;
  color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctxwin__chip b { color: var(--text); }
.ctxwin__chip--match { color: var(--text); }
.ctxwin__chip--match b { color: var(--accent); }
.ctxwin__chip--more { color: var(--text-3); font-style: italic; }
.ctxwin__code em { color: var(--accent); font-style: normal; }

/* reveal behaviour: only when enhanced; static page shows every group */
.ctxwin.is-live .ctxwin__grp { display: none; }
.ctxwin.is-live .ctxwin__grp.is-shown { display: block; animation: ctxfade var(--dur-2) var(--ease-out) both; }
@keyframes ctxfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* cost meter: a prominent bar spanning the top of the window, filled by
   three cumulative segments, each a distinct shade of orange per tier */
.ctxwin__meter { position: relative; height: 26px; margin: 0; background: #26262a;
  border-bottom: 1px solid rgba(255,255,255,.06); overflow: hidden; }
.ctxwin__seg { position: absolute; top: 0; height: 100%; transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-3) var(--ease-emph); }
.ctxwin__seg.is-shown { transform: scaleX(1); }
.ctxwin__seg[data-seg="1"] { left: 0;   width: 5%;  background: #e9b79f; }  /* tier 1, lightest */
.ctxwin__seg[data-seg="2"] { left: 5%;  width: 21%; background: #d17f5c; }  /* tier 2, mid */
.ctxwin__seg[data-seg="3"] { left: 26%; width: 36%; background: #bf5a3c; }  /* tier 3, deepest (accent) */

@media (prefers-reduced-motion: reduce) {
  .ctxwin__tier, .ctxwin__cost, .ctxwin__seg { transition: none; }
  .ctxwin.is-live .ctxwin__grp.is-shown { animation: none; }
}

/* ---- Context-window fill + compaction (Module 2) ----------------- */
.ctxfill { margin: 22px 0; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--card); box-shadow: var(--shadow-md); }
.ctxfill__head { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); }
.ctxfill__lab { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-3); }

.ctxfill__ctawrap { list-style: none; display: flex; animation: ctxfade var(--dur-2) var(--ease-out) both; }
.ctxfill__play { border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 13px; font: inherit; font-size: 0.85rem; cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1); }
.ctxfill__play:hover { background: var(--bg-subtle); border-color: var(--text-3); }
.ctxfill__play.is-playing { color: var(--text-3); cursor: default; }

.ctxfill__win { display: flex; flex-direction: column; background: var(--bg-sink); }
.ctxfill__winbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #1d1d1f; }
.ctxfill__winname { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: .04em; color: #a1a1a6; }
.ctxfill__phase { font-family: var(--font-mono); font-size: 0.72rem; color: #e9b79f; opacity: 0;
  transition: opacity var(--dur-2); }
.ctxfill__phase.is-shown { opacity: 1; }
.ctxfill__cost { margin-left: auto; font-family: var(--font-mono); font-size: 0.74rem; color: #fff;
  background: var(--accent); padding: 2px 10px; border-radius: 20px; transition: background var(--dur-2); }

/* meter: a 256k track filled by one colored segment per context type,
   each appended to the end of the previous one */
.ctxfill__meter { position: relative; height: 26px; background: #26262a;
  border-bottom: 1px solid rgba(255,255,255,.06); overflow: hidden; }
.ctxfill__seg { position: absolute; top: 0; height: 100%; width: 0; left: 0;
  transition: width var(--dur-3) var(--ease-emph), left var(--dur-3) var(--ease-emph), opacity var(--dur-2); }
.ctxfill__limit { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); z-index: 2;
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: .03em; color: #6f6f74; }
.ctxfill__flash { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  font-family: var(--font-mono); font-size: 0.72rem; color: #fff; background: #6f6f74;
  padding: 2px 12px; border-radius: 20px; opacity: 0; transition: opacity var(--dur-1); pointer-events: none; }
.ctxfill.is-compacting .ctxfill__flash { opacity: 1; }

.ctxfill__body { list-style: none; margin: 0; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ctxfill__block { border: 1.5px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--card); overflow: hidden; cursor: pointer;
  transition: border-color var(--dur-1), box-shadow var(--dur-1), filter var(--dur-2), opacity var(--dur-2); }
/* each form of context gets its own shade of orange, lightest → deepest,
   surrounding the whole block */
.ctxfill__block[data-block="1"] { border-color: #e9b79f; }
.ctxfill__block[data-block="2"] { border-color: #dda17f; }
.ctxfill__block[data-block="3"] { border-color: #cc7a56; }
.ctxfill__block[data-block="4"] { border-color: #bf5a3c; }
.ctxfill__block[data-block="5"] { border-color: #b9b9be; }   /* compaction is grey, not orange */
.ctxfill__block[data-block="1"] .ctxfill__name { color: #b06a44; }
.ctxfill__block[data-block="2"] .ctxfill__name { color: #b3623c; }
.ctxfill__block[data-block="3"] .ctxfill__name { color: #bf5a3c; }
.ctxfill__block[data-block="4"] .ctxfill__name { color: #a8432b; }
.ctxfill__block[data-block="5"] .ctxfill__name { color: var(--text-2); }
.ctxfill__block:hover { box-shadow: var(--shadow-sm); }
.ctxfill__block:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* compaction folds a block away without removing it: grey out in place */
.ctxfill__block.is-greyed { border-color: var(--line-soft); filter: grayscale(1); opacity: 0.5; }
.ctxfill__block.is-greyed .ctxfill__name { color: var(--text-3); }
.ctxfill__bh { display: flex; align-items: baseline; gap: 10px; padding: 7px 11px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); }
.ctxfill__name { font-size: 0.9rem; font-weight: 650; color: var(--text); }
.ctxfill__note { margin-left: auto; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-3); }
.ctxfill__lines { padding: 9px 11px; display: flex; flex-direction: column; gap: 4px; }
.ctxfill__code { font-family: var(--font-mono); font-size: 0.76rem; line-height: 1.5; margin: 0;
  color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctxfill__code b { color: var(--accent); }
.ctxfill__code--more { color: var(--text-3); font-style: italic; }
.ctxfill__hint { margin: 12px 16px 14px; font-size: 0.82rem; color: var(--text-3); }
.ctxfill__code h1 { font-size: 0.9rem; line-height: 1.5; margin: 0;
  color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* reveal behaviour: only when enhanced; static page shows everything readably */
.ctxfill.is-live .ctxfill__block { display: none; }
.ctxfill.is-live .ctxfill__block.is-shown { display: block; animation: ctxfade var(--dur-2) var(--ease-out) both; }
.ctxfill.is-live .ctxfill__bulk { display: none; }
.ctxfill.is-live.is-ballooning .ctxfill__bulk { display: block; }

@media (prefers-reduced-motion: reduce) {
  .ctxfill__seg, .ctxfill__cost, .ctxfill__phase, .ctxfill__flash { transition: none; }
  .ctxfill.is-live .ctxfill__block.is-shown { animation: none; }
  .ctxfill__block { transition: none; }
}

/* ---- Callouts ----------------------------------------------------- */
.callout { display: grid; grid-template-columns: 24px 1fr; gap: 14px; padding: 18px 20px; border-radius: var(--radius);
  background: var(--bg-subtle); border: 1px solid var(--line-soft); margin: 22px 0; }
.callout__ic { width: 22px; height: 22px; }
.callout__ic svg { width: 22px; height: 22px; stroke: var(--text-3); }
.callout p { margin: 0; font-size: 0.96rem; }
.callout p + p { margin-top: 8px; }
.callout b { color: var(--text); }
.callout--key { background: var(--accent-soft); border-color: rgba(191,90,60,0.22); }
.callout--key .callout__ic svg { stroke: var(--accent); }
.callout--key .callout__lab { color: var(--accent); }
.callout--warn { background: var(--danger-soft); border-color: rgba(154,52,18,0.22); }
.callout--warn .callout__ic svg { stroke: var(--danger); }
.callout--warn .callout__lab { color: var(--danger); }
.callout__lab { display: block; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 620;
  color: var(--text-3); margin-bottom: 6px; }

/* ---- Info tooltip (hover or click) -------------------------------- */
.infotip { position: relative; display: inline-flex; vertical-align: middle; margin-left: 5px; }
.infotip__btn { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; flex: none;
  border: 1px solid var(--line); border-radius: 50%; background: var(--bg-subtle); color: var(--text-3); cursor: pointer;
  transition: color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out); }
.infotip__btn:hover, .infotip__btn:focus-visible { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.infotip__btn svg { width: 13px; height: 13px; stroke: currentColor; }
.infotip__pop { position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%) translateY(4px);
  width: min(320px, 78vw); z-index: 30; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--text); color: #fff; font-size: 0.85rem; line-height: 1.5; font-style: normal; text-align: left;
  box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out); }
.infotip__pop b { color: #fff; }
.infotip__pop em { color: #fff; opacity: 0.85; }
.infotip__pop::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--text); }
.infotip:hover .infotip__pop, .infotip:focus-within .infotip__pop, .infotip.is-open .infotip__pop {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .infotip__btn, .infotip__pop { transition: none; } }

/* ---- Good/bad comparison ------------------------------------------ */
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0; }
@media (max-width: 640px) { .cmp { grid-template-columns: 1fr; } }
.cmp__col { padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line-soft); background: var(--bg-subtle); }
.cmp__col code { display: block; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.5; color: var(--text);
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 8px; padding: 12px; margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }
.cmp__col p { font-size: 0.88rem; margin: 0; color: var(--text-2); }
.cmp__lab { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 620; margin-bottom: 10px; }
.cmp__col--bad .cmp__lab { color: var(--danger); }
.cmp__col--good .cmp__lab { color: var(--success); }
.cmp__col--good { border-color: rgba(29,122,77,0.28); }

/* ---- Code / walkthrough ------------------------------------------- */
.code { position: relative; background: #1d1d1f; border-radius: var(--radius); overflow: hidden; margin: 22px 0;
  box-shadow: var(--shadow-md); }
.code__bar { display: flex; align-items: center; gap: 7px; padding: 11px 16px; background: #2a2a2c; }
.code__bar span { width: 10px; height: 10px; border-radius: 50%; background: #4a4a4d; }
.code__name { margin-left: 8px; font-family: var(--font-mono); font-size: 0.76rem; color: #a1a1a6; }
.code pre { margin: 0; padding: 18px 20px; overflow-x: auto; }
.code code { font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.7; color: #f5f5f7; white-space: pre; }
.code .c-key { color: #d6b98c; }        /* keys, warm, muted */
.code .c-str { color: #9fb8ad; }        /* strings, muted sage */
.code .c-com { color: #6e6e73; font-style: italic; }
.code .c-punct { color: #86868b; }
.code .c-cmd { color: #c8a2c8; }         /* shell */
.code .c-add { display: block; color: #a9d9bf; background: rgba(29,122,77,0.18);   /* an added line */
  border-radius: 4px; box-shadow: inset 2px 0 0 var(--success); }

/* Annotated walkthrough: numbered lines + callout panel */
.walk { margin: 24px 0; }
.walk__code .ln { display: block; padding: 1px 8px; border-radius: 5px; transition: background var(--dur-1); }
.walk__code .ln[data-note] { border-left: 2px solid transparent; cursor: pointer; }
.walk__code .ln[data-note]::after { content: attr(data-badge); display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; margin-left: 10px; padding: 0 4px; font-size: 0.64rem; font-family: var(--font-ui); font-weight: 640;
  color: #1d1d1f; background: #d6b98c; border-radius: 999px; vertical-align: middle; }
.walk__code .ln[data-note]:hover, .walk__code .ln.is-active { background: rgba(255,255,255,0.07); border-left-color: #d6b98c; }
.walk__notes { margin-top: 14px; display: grid; gap: 8px; }
.walk__note { display: none; gap: 12px; padding: 14px 16px; background: var(--bg-subtle); border: 1px solid var(--line-soft);
  border-radius: var(--radius); font-size: 0.94rem; color: var(--text-2); }
.walk__note.is-shown { display: grid; grid-template-columns: 22px 1fr; }
.walk__note .b { width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: #fff; display: grid;
  place-items: center; font-size: 0.7rem; font-weight: 640; }
.walk__note b { color: var(--text); }
.walk__hint { margin-top: 10px; font-size: 0.8rem; color: var(--text-3); }

/* ---- Interactive: live SKILL.md editor ---------------------------- */
.editor { margin: 26px 0; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); }
.editor__grid { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .editor__grid { grid-template-columns: 1fr; } }
.editor__pane { min-width: 0; }
.editor__pane--in { border-right: 1px solid var(--line); }
@media (max-width: 720px) { .editor__pane--in { border-right: none; border-bottom: 1px solid var(--line); } }
.editor__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 15px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); font-size: 0.76rem; color: var(--text-3);
  font-family: var(--font-mono); }
.editor textarea { width: 100%; min-height: 320px; resize: vertical; border: none; outline: none; padding: 16px;
  font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.65; color: var(--text); background: #fff; tab-size: 2; }
.editor__out { padding: 16px; min-height: 320px; background: var(--bg-sink); font-size: 0.9rem; }
.editor__cmd { font-family: var(--font-mono); font-size: 1.05rem; margin-bottom: 4px; }
.editor__cmd b { color: var(--accent); }
.editor__cmdlab { font-size: 0.76rem; color: var(--text-3); margin-bottom: 18px; }
.ecard { background: #fff; border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.ecard__name { font-weight: 620; margin-bottom: 4px; }
.ecard__desc { font-size: 0.9rem; color: var(--text-2); line-height: 1.5; }
.ecard__desc.empty { color: var(--text-3); font-style: italic; }
.echecks { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.echeck { display: flex; gap: 9px; align-items: flex-start; font-size: 0.86rem; color: var(--text-2); }
.echeck svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.echeck.ok { color: var(--success); }
.echeck.ok svg { stroke: var(--success); }
.echeck.warn { color: var(--danger); }
.echeck.warn svg { stroke: var(--danger); }

/* ---- Interactive: folder tree (name-the-folder exercise) ---------- */
.editor__head--split { border-top: 1px solid var(--line-soft); }
.ftree { padding: 14px 15px; background: #fff; display: flex; flex-direction: column; gap: 6px; font-family: var(--font-mono); font-size: 0.86rem; }
.ftree__row { display: flex; align-items: center; gap: 8px; }
.ftree__row--file { padding-left: 10px; color: var(--text-2); }
.ftree__ic { width: 18px; height: 18px; flex: none; stroke: var(--text-3); stroke-width: 1.5; }
.ftree__branch { color: var(--text-3); }
.ftree__slash { color: var(--text-3); }
.ftree__file { color: var(--text-2); }
.ftree__folder { flex: 1 1 auto; min-width: 0; border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 9px; font-family: var(--font-mono); font-size: 0.86rem; color: var(--text); background: var(--bg-subtle);
  outline: none; transition: border-color .18s ease, background .18s ease, color .18s ease; }
.ftree__folder:focus { border-color: var(--text-3); background: #fff; }
.ftree__folder::placeholder { color: var(--text-3); font-style: italic; }
.ftree__mark { width: 18px; height: 18px; flex: none; }
.ftree__mark svg { width: 100%; height: 100%; }
/* matched: folder name === skill name */
.ftree.is-match .ftree__ic { stroke: var(--success); }
.ftree.is-match .ftree__folder { border-color: var(--success); background: rgba(52,168,83,.08); color: var(--success); }
.ftree.is-match .ftree__mark { color: var(--success); }
/* mismatch (folder typed but doesn't match) */
.ftree.is-miss .ftree__folder { border-color: var(--danger); }
.ftree.is-miss .ftree__mark { color: var(--danger); }

/* ---- Interactive: with vs without the skill ----------------------- */
.vs { margin: 26px 0; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); background: #fff; }
.vs__prompt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); }
.vs__promptlab { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; }
.vs__prompttxt { font-size: 0.95rem; color: var(--text); font-style: italic; }
.vs__run { margin-left: auto; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px;
  padding: 7px 15px; font-size: 0.82rem; font-weight: 560; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.vs__run:hover { background: var(--bg-subtle); border-color: var(--text-3); }
.vs__run.is-playing { color: var(--text-3); cursor: default; }
.vs__lanes { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .vs__lanes { grid-template-columns: 1fr; } }
.vs__lane { padding: 16px; min-width: 0; }
.vs__lane--no { border-right: 1px solid var(--line-soft); background: var(--bg-sink); }
@media (max-width: 720px) { .vs__lane--no { border-right: none; border-bottom: 1px solid var(--line-soft); } }
.vs__lanehead { display: flex; align-items: center; gap: 8px; font-weight: 620; font-size: 0.92rem; margin-bottom: 12px; }
.vs__lanehead code { font-size: 0.82em; }
.vs__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.vs__lane--no .vs__dot { background: var(--text-3); }
.vs__lane--yes .vs__dot { background: var(--success); }

.vs__ctx { border: 1px solid var(--line-soft); border-radius: 9px; padding: 10px 11px; margin-bottom: 14px; background: #fff; }
.vs__ctxlab { display: block; font-size: 0.68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.vs__ctxbars { display: flex; flex-direction: column; gap: 5px; }
.vs__ctxbar { position: relative; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-2);
  padding: 4px 8px; border-radius: 5px; background: var(--bg-subtle); width: var(--w); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs__ctxbar--t1 { background: rgba(52,168,83,.12); color: var(--success); }
.vs__ctxbar--t2 { background: repeating-linear-gradient(45deg, var(--bg-subtle), var(--bg-subtle) 6px, #fff 6px, #fff 12px);
  color: var(--text-3); opacity: .55; border: 1px dashed var(--line); transition: opacity .3s ease, background .3s ease, color .3s ease; }
.vs__ctxbar--t2.is-loaded { background: rgba(52,168,83,.12); color: var(--success); opacity: 1; border-style: solid; border-color: transparent; }

.vs__steps { list-style: none; display: flex; flex-direction: column; gap: 9px; counter-reset: vstep; }
.vs__step { position: relative; padding: 9px 11px 9px 34px; border-radius: 8px; background: #fff; border: 1px solid var(--line-soft);
  font-size: 0.84rem; color: var(--text-2); line-height: 1.45; counter-increment: vstep;
  opacity: 0; transform: translateY(6px); transition: opacity .35s ease, transform .35s ease, border-color .35s ease; }
.vs__step::before { content: counter(vstep); position: absolute; left: 9px; top: 9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-subtle); color: var(--text-3); font-size: 0.7rem; font-weight: 640; display: grid; place-items: center; }
.vs__step b { color: var(--text); font-weight: 600; }
.vs__step.is-shown { opacity: 1; transform: none; }
.vs__lane--yes .vs__step.is-shown::before { background: rgba(52,168,83,.14); color: var(--success); }
.vs__step[data-ctx-trigger].is-shown { border-color: var(--success); background: rgba(52,168,83,.05); }

.vs__verdict { margin-top: 14px; padding: 11px 12px; border-radius: 8px; font-size: 0.82rem; line-height: 1.45;
  opacity: 0; transition: opacity .4s ease; }
.vs__verdict.is-shown { opacity: 1; }
.vs__verdict--no { background: var(--bg-subtle); color: var(--text-2); border: 1px solid var(--line-soft); }
.vs__verdict--yes { background: rgba(52,168,83,.08); color: var(--success); border: 1px solid rgba(52,168,83,.3); }

@media (prefers-reduced-motion: reduce) {
  .vs__step, .vs__verdict { transition: none; }
}

/* ---- Interactive: quiz -------------------------------------------- */
.quiz { margin: 28px 0; padding: 24px; background: var(--bg-subtle); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); }
.quiz__q { font-size: 1.06rem; font-weight: 560; margin-bottom: 4px; letter-spacing: -0.01em; }
.quiz__hint { font-size: 0.8rem; color: var(--text-3); margin-bottom: 16px; }
.quiz__opts { display: flex; flex-direction: column; gap: 10px; }
.qopt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 14px 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 11px; font-size: 0.95rem; color: var(--text);
  transition: border-color var(--dur-1), background var(--dur-1), transform var(--dur-1) var(--ease-out); }
.qopt:hover:not(:disabled) { border-color: var(--text-3); transform: translateY(-1px); }
.qopt__mark { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; margin-top: 1px; }
.qopt__mark svg { width: 12px; height: 12px; opacity: 0; }
.qopt.correct { border-color: var(--success); background: var(--success-soft); }
.qopt.correct .qopt__mark { background: var(--success); border-color: var(--success); }
.qopt.correct .qopt__mark svg { opacity: 1; stroke: #fff; }
.qopt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.qopt.wrong .qopt__mark { background: var(--danger); border-color: var(--danger); }
.qopt.wrong .qopt__mark svg { opacity: 1; stroke: #fff; }
.qopt:disabled { cursor: default; }
.qexplain { display: none; margin-top: 16px; padding: 15px 17px; border-radius: 11px; font-size: 0.92rem; line-height: 1.55;
  background: #fff; border: 1px solid var(--line-soft); }
.qexplain.is-shown { display: block; }
.qexplain b { color: var(--text); }
.qexplain .verdict { font-weight: 620; }
.qexplain .verdict.ok { color: var(--success); }
.qexplain .verdict.no { color: var(--danger); }

/* ---- Interactive: debug drill (spot the bad skill) ---------------- */
.drill { margin: 28px 0; }
.drill__frame { background: #1d1d1f; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md); }
.drill__bar { display: flex; align-items: center; gap: 7px; padding: 11px 16px; background: #2a2a2c; }
.drill__bar span { width: 10px; height: 10px; border-radius: 50%; background: #4a4a4d; }
.drill__name { margin-left: 8px; font-family: var(--font-mono); font-size: 0.76rem; color: #a1a1a6; }
.drill__code { padding: 16px 18px; margin: 0; overflow-x: auto; }
.drill__code code { font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.75; color: #f5f5f7; white-space: pre; }
.drill__code .flaw { border-bottom: 2px dotted #b0704f; cursor: pointer; transition: background var(--dur-1); padding: 0 2px; border-radius: 3px; }
.drill__code .flaw:hover { background: rgba(191,90,60,0.22); }
.drill__code .flaw.found { background: rgba(154,52,18,0.30); border-bottom-color: transparent; }
.drill__prompt { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 14px; font-size: 0.9rem; color: var(--text-2); }
.drill__score { font-weight: 620; color: var(--text); font-variant-numeric: tabular-nums; }
.drill__score.done { color: var(--success); }
.drill__found { margin-top: 14px; display: grid; gap: 8px; }
.dfind { display: none; gap: 12px; grid-template-columns: 22px 1fr; padding: 13px 15px; background: var(--bg-subtle);
  border: 1px solid var(--line-soft); border-radius: var(--radius); font-size: 0.92rem; color: var(--text-2); }
.dfind.is-shown { display: grid; }
.dfind .n { width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff; display: grid;
  place-items: center; font-size: 0.68rem; font-weight: 640; }
.dfind b { color: var(--text); }

/* ---- Interactive: decision tree (composition module) ------------- */
.dtree { margin: 26px 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.dtree__q { font-size: 1.05rem; font-weight: 560; margin-bottom: 16px; min-height: 1.6em; }
.dtree__opts { display: flex; flex-direction: column; gap: 10px; }
.dtree__opts button { text-align: left; padding: 13px 16px; background: #fff; border: 1px solid var(--line); border-radius: 11px;
  font-size: 0.94rem; transition: border-color var(--dur-1), transform var(--dur-1) var(--ease-out); }
.dtree__opts button:hover { border-color: var(--text-3); transform: translateX(3px); }
.dtree__result { display: none; }
.dtree__result.is-shown { display: block; }
.dtree__badge { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-weight: 640;
  font-size: 1.1rem; padding: 8px 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.dtree__why { font-size: 0.96rem; color: var(--text-2); line-height: 1.55; margin-bottom: 16px; }
.dtree__restart { font-size: 0.86rem; color: var(--text-3); text-decoration: underline; }

/* ---- Interactive: CLI command explainer (approving what it runs) -- */
.cmdex { margin: 26px 0; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); background: #fff; }
.cmdex__bar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: #1d1d1f; }
.cmdex__prompt { font-family: var(--font-mono); font-size: 0.95rem; color: var(--success); flex: none; }
.cmdex__in { flex: 1 1 auto; min-width: 0; border: none; outline: none; background: transparent; color: #f5f5f7;
  font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.5; padding: 2px 0; }
.cmdex__in::placeholder { color: #6e6e73; }

.cmdex__out { padding: 16px 18px; min-height: 132px; background: var(--bg-sink); }
.cmdex__hint { font-size: 0.9rem; color: var(--text-3); font-style: italic; margin: 0; }

.cmdex__verdict { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line-soft); }
.cmdex__badge { flex: none; font-size: 0.7rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 640;
  padding: 4px 10px; border-radius: 999px; }
.cmdex__cmd { font-size: 0.95rem; color: var(--text); line-height: 1.5; }
.cmdex__cmd code { font-family: var(--font-mono); font-size: 0.86em; color: var(--text); background: var(--bg-subtle);
  border: 1px solid var(--line-soft); border-radius: 5px; padding: 1px 6px; }
.cmdex__verdict--safe .cmdex__badge { background: var(--success-soft); color: var(--success); }
.cmdex__verdict--caution .cmdex__badge { background: var(--accent-soft); color: var(--accent); }
.cmdex__verdict--danger .cmdex__badge { background: var(--danger-soft); color: var(--danger); }
.cmdex__verdict--unknown .cmdex__badge { background: var(--bg-subtle); color: var(--text-3); }

.cmdex__notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.cmdex__notes li { position: relative; padding-left: 18px; font-size: 0.9rem; color: var(--text-2); line-height: 1.5; margin: 0; }
.cmdex__notes li::before { content: ""; position: absolute; left: 3px; top: 0.62em; width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-3); }

.cmdex__exs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 14px 16px; background: var(--bg-subtle);
  border-top: 1px solid var(--line-soft); }
.cmdex__exlab { font-size: 0.72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin-right: 2px; }
.cmdex__ex { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-2); background: #fff; border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 10px; cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1), color var(--dur-1); }
.cmdex__ex:hover { border-color: var(--text-3); color: var(--text); }
.cmdex__ex:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Interactive: MCP call trace (single-lane sequenced reveal) --- */
.trace { margin: 26px 0; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); background: #fff; }
.trace__prompt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); }
.trace__promptlab { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; }
.trace__prompttxt { font-size: 0.95rem; color: var(--text); font-style: italic; }
.trace__run { margin-left: auto; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px;
  padding: 7px 15px; font-size: 0.82rem; font-weight: 560; cursor: pointer; transition: background var(--dur-1), border-color var(--dur-1); }
.trace__run:hover { background: var(--bg-subtle); border-color: var(--text-3); }
.trace__run.is-playing { color: var(--text-3); cursor: default; }

.trace__flow { list-style: none; margin: 0; padding: 18px 18px 22px; display: flex; flex-direction: column; gap: 0; }
.trace__step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding-bottom: 18px;
  opacity: 0; transform: translateY(8px); transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out); }
.trace__step:last-child { padding-bottom: 0; }
.trace__step.is-shown { opacity: 1; transform: none; }

/* the vertical rail + node dot down the left */
.trace__rail { position: relative; display: flex; justify-content: center; }
.trace__rail::before { content: ""; position: absolute; top: 30px; bottom: -18px; width: 2px; background: var(--line-soft); }
.trace__step:last-child .trace__rail::before { display: none; }
.trace__node { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; z-index: 1;
  background: var(--bg-subtle); border: 1px solid var(--line); color: var(--text-2); }
.trace__node svg { width: 15px; height: 15px; stroke: currentColor; }
.trace__step.is-shown .trace__node { background: var(--card); border-color: var(--accent); color: var(--accent); }
/* the final "plain English" step reads as a success outcome */
.trace__step:last-child.is-shown .trace__node { border-color: var(--success); color: var(--success); }

.trace__body { min-width: 0; padding-top: 3px; }
.trace__role { display: block; font-size: 0.72rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 620; color: var(--text-3); margin-bottom: 6px; }
.trace__lede { font-size: 0.92rem; color: var(--text-2); line-height: 1.55; margin: 0; }
.trace__body .trace__code { margin: 12px 0 0; }
.trace__body .trace__code code { font-size: 0.8rem; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }

/* step 2: tool candidates, kept vs dropped */
.trace__pick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.trace__opt { font-family: var(--font-mono); font-size: 0.76rem; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line-soft); }
.trace__opt--drop { color: var(--text-3); background: var(--bg-sink); text-decoration: line-through; text-decoration-color: var(--line); }
.trace__opt--keep { color: var(--success); background: var(--success-soft); border-color: rgba(29,122,77,0.28); }
.trace__opt--keep::after { content: " ✓"; }

/* step 4: the server working line: spinner → check */
.trace__wire { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 11px 13px;
  background: var(--bg-sink); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.trace__wirelab { font-size: 0.72rem; letter-spacing: .04em; text-transform: uppercase; font-weight: 620; color: var(--text-3); }
.trace__wireop { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-2); flex: 1 1 auto; min-width: 0; }
.trace__spin { width: 15px; height: 15px; flex: none; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  opacity: 0; animation: trace-spin 0.7s linear infinite; }
.trace__wire.is-working .trace__spin { opacity: 1; }
.trace__wire.is-done .trace__spin { display: none; }
.trace__done { width: 18px; height: 18px; flex: none; display: none; place-items: center; color: var(--success); }
.trace__done svg { width: 15px; height: 15px; stroke: var(--success); }
.trace__wire.is-done .trace__done { display: grid; }
@keyframes trace-spin { to { transform: rotate(360deg); } }

/* step 6: the agent's plain-English reply bubble */
.trace__reply { margin-top: 12px; padding: 12px 14px; background: var(--success-soft); border: 1px solid rgba(29,122,77,0.28); border-radius: var(--radius-sm); }
.trace__replylab { display: block; font-size: 0.68rem; letter-spacing: .05em; text-transform: uppercase; font-weight: 620; color: var(--success); margin-bottom: 5px; }
.trace__reply p { font-size: 0.92rem; color: var(--text); line-height: 1.5; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .trace__step { transition: none; }
  .trace__spin { animation: none; }
}

/* ---- Agent loop diagram (send-to-play) ------------------------------ */
.loop { margin: 26px 0; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); background: #fff; }
.loop__prompt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--line-soft); }
.loop__promptlab { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.loop__input { flex: 1 1 220px; min-width: 0; font-size: 0.92rem; font-style: italic; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; }
.loop__input:disabled { color: var(--text-2); background: var(--bg-sink); }
.loop__send { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px;
  padding: 8px 14px; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.loop__send:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--text-3); }
.loop__send:disabled { color: var(--text-3); cursor: default; }

.loop__flow { list-style: none; margin: 0; padding: 18px 18px 22px; display: flex; flex-direction: column; gap: 0; }
.loop__step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding-bottom: 18px;
  opacity: .45; transition: opacity var(--dur-2) var(--ease-out); }
.loop__step:last-child { padding-bottom: 0; }
.loop__step.is-done { opacity: 1; }

.loop__rail { position: relative; display: flex; justify-content: center; }
.loop__rail::before { content: ""; position: absolute; top: 30px; bottom: -18px; width: 2px; background: var(--line-soft); }
.loop__step:last-child .loop__rail::before { display: none; }
.loop__node { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; z-index: 1;
  background: var(--card); border: 1px solid var(--line); color: var(--text-3);
  transition: border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out); }
.loop__node svg { width: 15px; height: 15px; stroke: currentColor; }
.loop__step.is-done .loop__node { border-color: var(--text-3); color: var(--text-2); }
.loop__step.is-active .loop__node { border-color: var(--accent); color: var(--accent); transform: scale(1.12); }
.loop__step:last-child.is-active .loop__node,
.loop__step:last-child.is-done .loop__node { border-color: var(--success); color: var(--success); }

.loop__body { min-width: 0; padding-top: 3px; }
.loop__role { display: block; font-size: 0.72rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 620; color: var(--text-3); margin-bottom: 6px; }
.loop__lede { font-size: 0.92rem; color: var(--text-2); line-height: 1.55; margin: 0; }

.loop__flags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.loop__flag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 620; color: var(--text-2); background: var(--bg-subtle); border: 1px solid var(--line-soft);
  transition: color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
.loop__flag svg { width: 13px; height: 13px; stroke: currentColor; }
.loop__flag--again.is-active { color: var(--accent); background: var(--accent-soft); border-color: rgba(191,90,60,.28); }
.loop__flag--done.is-active { color: var(--success); background: var(--success-soft); border-color: rgba(29,122,77,.28); }

.loop__tool { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-2); background: var(--bg-subtle);
  border: 1px solid var(--line-soft); border-radius: 6px; padding: 2px 7px; }

@media (prefers-reduced-motion: reduce) {
  .loop__step, .loop__node, .loop__flag { transition: none; }
}

/* ---- Complete + prev/next ---------------------------------------- */
.mfoot { margin-top: 50px; padding-top: 34px; border-top: 1px solid var(--line-soft); }
.complete { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 22px 24px; border-radius: var(--radius-lg);
  background: var(--bg-subtle); border: 1px solid var(--line-soft); margin-bottom: 30px; }
.complete__txt { flex: 1; min-width: 200px; }
.complete__txt h4 { margin-bottom: 3px; }
.complete__txt p { font-size: 0.88rem; color: var(--text-3); margin: 0; }
.complete.is-done { background: var(--success-soft); border-color: rgba(29,122,77,0.28); }
.btn--done { background: var(--success); }
.btn--done[disabled] { opacity: 1; cursor: default; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pager a { display: flex; flex-direction: column; gap: 5px; padding: 18px 20px; border: 1px solid var(--line-soft);
  border-radius: var(--radius); transition: border-color var(--dur-1), border-width var(--dur-1), transform var(--dur-1) var(--ease-out); background: var(--card); box-sizing: border-box; }
.pager a:hover { border-color: var(--line); transform: translateY(-2px); }
.pager__dir { font-size: 0.74rem; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
.pager__title { font-weight: 560; letter-spacing: -0.01em; }
.pager a.next { text-align: right; border-color: var(--accent); }
.pager a.next:hover { border-color: var(--accent); border-width: 2px; padding: 17px 19px; }
.pager a.is-empty { visibility: hidden; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } }

/* ==================================================================
   REVIEW CAPSTONE (Module 9): scoreboard, matcher, sequence, flip
   ================================================================== */

/* ---- Scoreboard --------------------------------------------------- */
.rscore { position: sticky; top: 74px; z-index: 5; margin: 0 0 30px; padding: 16px 18px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.rscore__count { font-size: 0.86rem; font-weight: 560; color: var(--text-2); margin: 0 0 9px; }
.rscore.is-complete .rscore__count { color: var(--success); }
.rscore__meter { height: 8px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; }
.rscore__meter i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent);
  transition: width var(--dur-3) var(--ease-out); }
.rscore.is-complete .rscore__meter i { background: var(--success); }
.rscore__done { display: none; margin-top: 15px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--success-soft); border: 1px solid rgba(29,122,77,0.28); }
.rscore__done.is-shown { display: block; animation: rscorePop var(--dur-3) var(--ease-out); }
.rscore__done h4 { margin: 0 0 4px; color: var(--success); }
.rscore__done p { margin: 0; font-size: 0.9rem; color: var(--text-2); }
@keyframes rscorePop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Shared draggable chip --------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--card); font-size: 0.86rem; font-weight: 540; color: var(--text);
  cursor: grab; user-select: none; transition: border-color var(--dur-1), background var(--dur-1), transform var(--dur-1) var(--ease-out); }
.chip:hover { border-color: var(--text-3); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip.is-picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); cursor: grabbing; }
.chip.is-correct { border-color: rgba(29,122,77,0.4); background: var(--success-soft); color: var(--success); cursor: default; }
.chip.is-wrong { border-color: rgba(154,52,18,0.4); background: var(--danger-soft); color: var(--danger); }

/* ---- Term matcher ------------------------------------------------- */
.match { margin: 22px 0; }
.match__bank { display: flex; flex-wrap: wrap; gap: 9px; min-height: 54px; padding: 12px; margin-bottom: 16px;
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg-sink); align-content: flex-start; }
.match__bank.is-armed { border-color: var(--accent); }
.match__banklab { display: block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.match__slots { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; }
.match__slot { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--card); }
.match__def { font-size: 0.92rem; color: var(--text-2); line-height: 1.5; }
.match__drop { display: inline-flex; align-items: center; justify-content: center; min-width: 150px; min-height: 40px;
  padding: 4px; border-radius: 99px; transition: background var(--dur-1), box-shadow var(--dur-1); }
.match__drop.is-empty { border: 1px dashed var(--line); background: var(--bg-subtle); }
.match__drop.is-empty::before { content: "drop here"; font-size: 0.76rem; color: var(--text-3); }
.match__drop.is-empty .chip { display: none; }
.match__drop.is-armed.is-empty { border-color: var(--accent); }
.match__drop.is-over { box-shadow: 0 0 0 2px var(--accent); }
.match__status { margin-top: 14px; font-size: 0.85rem; font-weight: 560; color: var(--text-3); }
.match__status.done { color: var(--success); }
@media (max-width: 560px) { .match__slot { grid-template-columns: 1fr; } .match__drop { justify-self: start; } }

/* ---- Sequence order ---------------------------------------------- */
.seq { margin: 22px 0; }
.seq__list { list-style: none; display: flex; flex-direction: column; gap: 9px; margin: 0 0 14px; padding: 0; counter-reset: seq; }
.seq__item { display: flex; align-items: center; gap: 12px; padding: 13px 15px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); cursor: grab; box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-1), transform var(--dur-1) var(--ease-out), background var(--dur-1); }
.seq__item::before { counter-increment: seq; content: counter(seq); flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-subtle); color: var(--text-3); display: grid; place-items: center; font-size: 0.78rem; font-weight: 640; }
.seq__item > span:not(.seq__ctrl) { flex: 1; font-size: 0.92rem; }
.seq__item.is-dragging { opacity: 0.5; cursor: grabbing; }
.seq__item.is-right { border-color: rgba(29,122,77,0.4); background: var(--success-soft); }
.seq__item.is-right::before { background: var(--success); color: #fff; }
.seq__item.is-wrong { border-color: rgba(154,52,18,0.35); background: var(--danger-soft); }
.seq__ctrl { display: inline-flex; flex-direction: column; gap: 2px; flex: none; }
.seq__ctrl button { width: 24px; height: 18px; border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  border-radius: 5px; font-size: 0.6rem; cursor: pointer; line-height: 1; }
.seq__ctrl button:hover { border-color: var(--text-3); color: var(--text); }
.seq__actions { display: flex; gap: 10px; }
.seq__actions button { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px;
  padding: 8px 16px; font-size: 0.86rem; font-weight: 540; cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.seq__actions button:hover { border-color: var(--text-3); background: var(--bg-subtle); }
.seq__status { margin-top: 12px; font-size: 0.85rem; font-weight: 560; color: var(--text-3); }
.seq__status.done { color: var(--success); }

/* ---- Flip cards --------------------------------------------------- */
.flip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 22px 0; }
.flip__card { position: relative; min-height: 96px; border: none; padding: 0; background: transparent; cursor: pointer;
  perspective: 900px; font: inherit; text-align: center; }
.flip__inner, .flip__card { display: block; }
.flip__face { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); backface-visibility: hidden; transition: transform var(--dur-2) var(--ease-emph); }
.flip__front { background: var(--card); color: var(--text); font-weight: 600; font-size: 0.95rem; box-shadow: var(--shadow-sm); }
.flip__back { background: var(--card); color: var(--text); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent);
  font-size: 0.82rem; line-height: 1.45; transform: rotateY(180deg); }
.flip__card.is-flipped .flip__front { transform: rotateY(180deg); }
.flip__card.is-flipped .flip__back { transform: rotateY(360deg); }
.flip__card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius); }
.flip__hint { grid-column: 1 / -1; margin: 0; font-size: 0.8rem; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
  .rscore__meter i, .chip, .seq__item, .rscore__done { transition: none; animation: none; }
  .flip__face { transition: none; }
  .flip__card.is-flipped .flip__front { transform: rotateY(180deg); }
}

/* ---- Scripted terminal (data-term) -------------------------------- */
.term { position: relative; background: #1d1d1f; border-radius: var(--radius); overflow: hidden;
  margin: 22px 0; box-shadow: var(--shadow-md); }
.term__bar { display: flex; align-items: center; flex-wrap: nowrap; gap: 7px; padding: 11px 16px; background: #2a2a2c; }
.term__bar > span { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #4a4a4d; }
.term__title { margin-left: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.76rem; color: #a1a1a6; }
.term__run { flex: none; margin-left: auto; border: 1px solid #4a4a4d; background: #1d1d1f; color: #f5f5f7;
  border-radius: 8px; padding: 5px 12px; font: inherit; font-size: 0.78rem; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease); }
.term__run:hover { background: #2f2f31; border-color: #6e6e73; }
.term__run.is-playing { color: #a1a1a6; cursor: default; }
.term__run:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.term__body { margin: 0; padding: 18px 20px; overflow-x: auto; font-family: var(--font-mono);
  font-size: 0.85rem; line-height: 1.7; color: #f5f5f7; }
.term__line { display: block; white-space: pre-wrap; word-break: break-word; }
.term__line + .term__line { margin-top: 0.5em; }
.term__line b { color: #fff; font-weight: 640; }
.term__line--dim { color: #86868b; }
.term__line--ok { color: #a9d9bf; }        /* success outcomes (green family) */
.term__prompt { color: var(--success); font-weight: 640; }
.term__prompt--chat { color: #86868b; }

/* Armed = JS is driving the reveal. With JS off, every line stays visible. */
.term.is-armed .term__line { opacity: 0; transition: opacity 0.28s var(--ease); }
.term.is-armed .term__line.is-shown { opacity: 1; }
.term.is-armed .term__line--cmd.is-typing .term__typed::after {
  content: "\258B"; margin-left: 1px; color: #f5f5f7; animation: term-blink 1s steps(1) infinite; }

@keyframes term-blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .term.is-armed .term__line { transition: none; }
  .term.is-armed .term__line--cmd.is-typing .term__typed::after { animation: none; }
  .term__run { transition: none; }
}
