/* ===========================================================================
   Codes.Live — map.css
   The Path (core/map.js) — the curriculum drawn as the dependency graph it
   actually is.

   This view uses the app's own design language throughout: the same surfaces,
   borders, radii, type scale and motion as the list. It adds no palette of its
   own. Colour carries exactly one meaning here — progress — so the brand green
   always reads as "you have done this", and the difficulty tokens keep their
   usual job on problem rows. Structure is carried by position (which row) and
   by the arrows (what depends on what), never by hue. The one exception is
   selection, which borrows --violet / --brand-gold for "leads here" and
   "opens next" only while a topic is selected.
   ========================================================================== */

.map {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 56px) 64px;
}
.map.is-entering .map__sheet { opacity: 0; transform: translateY(8px); }
.map__sheet { transition: opacity .34s var(--ease), transform .34s var(--ease); }

/* ------------------------------------------------------------ Intro + key */
.map__intro { display: flex; align-items: center; justify-content: space-between; gap: 10px 28px; flex-wrap: wrap; margin-bottom: 6px; }
.map__hint { font-size: 13px; color: var(--muted); }
.map__legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.map__key { display: inline-flex; align-items: center; gap: 7px; }
.map__key-line { width: 22px; height: 0; border-top: 2px solid var(--border-strong); }
.map__key-line.is-soft { border-top-style: dashed; }
.map__key-line.is-solved { border-top-color: var(--indigo); }
.atlas__toggle {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 8px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  transition: color var(--dur), border-color var(--dur);
}
.atlas__toggle:hover { color: var(--text); border-color: var(--border-strong); }
.atlas__toggle-box {
  width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; transition: background var(--dur), border-color var(--dur);
}
.atlas__toggle[aria-pressed="true"] { color: var(--text); }
.atlas__toggle[aria-pressed="true"] .atlas__toggle-box { background: var(--indigo); border-color: var(--indigo); }
.atlas__toggle[aria-pressed="true"] .atlas__toggle-box::after {
  content: ""; width: 6px; height: 3px; margin-top: -2px;
  border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: rotate(-45deg);
}

/* ============================================================== THE ATLAS */
.atlas__body { position: relative; }
.atlas__links { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 0; }
.atlas__rows { position: relative; z-index: 1; display: flex; flex-direction: column; }

/* ---- one dependency row: its name in a left gutter, its topics beside ---- */
.atlas__row {
  display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: 18px; align-items: center;
  padding: 26px 0; border-top: 1px dashed var(--border);
}
.atlas__row:first-child { border-top: 0; }
.atlas__row-head { display: flex; align-items: flex-start; gap: 11px; }
.atlas__row-no {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
}
.atlas__row-titles { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.atlas__row-titles b { font-size: 13.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.atlas__row-titles span { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.atlas__row-titles .atlas__row-meta { font-family: var(--font-mono); font-size: 10.5px; margin-top: 3px; }
.atlas__track { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ---- a topic card ---- */
.tcard {
  position: relative; display: flex; flex-direction: column; gap: 9px;
  flex: 1 1 0; max-width: 190px; min-width: 150px; padding: 12px 13px 11px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); font: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), opacity .2s var(--ease);
}
.tcard:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.tcard:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.tcard__top { display: flex; align-items: center; gap: 9px; }
.tcard__icon {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.tcard__icon svg { width: 15px; height: 15px; }
.tcard__name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
.tcard__pill {
  position: absolute; top: -9px; right: 10px; z-index: 1;
  font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--on-accent); background: var(--indigo); border-radius: 999px; padding: 3px 8px;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--indigo) 55%, transparent);
}

/* One segment per pattern, sized by how many problems it holds. */
.tcard__meter, .tview__meter, .mpop__meter { display: flex; gap: 2px; height: 5px; }
.tcard__meter > span, .tview__meter > span, .mpop__meter > span {
  flex: 1 1 0; min-width: 3px; border-radius: 2px; background: var(--surface-2); overflow: hidden;
}
.tcard__meter i, .tview__meter i, .mpop__meter i { display: block; height: 100%; background: var(--indigo); transition: width .4s var(--ease); }
:root[data-theme="light"] .tcard__meter > span,
:root[data-theme="light"] .tview__meter > span,
:root[data-theme="light"] .mpop__meter > span { background: #e7e9ee; }

.tcard__foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
.tcard__count { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.tcard__count b { color: var(--text); font-weight: 700; }
.tcard__status { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.tcard__also {
  font-size: 10.5px; color: var(--muted); line-height: 1.35;
  padding-top: 7px; border-top: 1px dashed var(--border);
}
.tcard__hits:empty { display: none; }
.tcard__hits {
  align-self: flex-start; font-size: 10.5px; font-weight: 700; font-family: var(--font-mono);
  color: var(--text); background: color-mix(in srgb, var(--brand-gold) 22%, transparent);
  border-radius: 999px; padding: 1px 8px;
}

/* progress is the only thing that changes a card's colour */
.tcard.is-started { border-color: color-mix(in srgb, var(--indigo) 35%, var(--border)); }
.tcard.is-started .tcard__status { color: var(--indigo); }
.tcard.is-ready .tcard__status { color: var(--text-dim); }
.tcard.is-waiting { box-shadow: none; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.tcard.is-waiting .tcard__name { color: var(--text-dim); }
.tcard.is-done { border-color: color-mix(in srgb, var(--indigo) 45%, transparent); background: color-mix(in srgb, var(--indigo) 6%, var(--surface)); }
.tcard.is-done .tcard__icon { background: color-mix(in srgb, var(--indigo) 16%, transparent); border-color: transparent; color: var(--indigo); }
.tcard.is-done .tcard__status { color: var(--indigo); }
.tcard.is-next { border-color: var(--indigo); box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 16%, transparent), var(--shadow-sm); }

/* ---- selection: the chain into a topic, and what it opens ---- */
.atlas__body.is-focused .tcard { opacity: .35; }
.atlas__body.is-focused .tcard.is-focus,
.atlas__body.is-focused .tcard.is-up,
.atlas__body.is-focused .tcard.is-down { opacity: 1; }
.atlas__body.is-focused .tcard.is-focus {
  border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 14%, transparent), var(--shadow);
}
.atlas__body.is-focused .tcard.is-up { border-color: color-mix(in srgb, var(--violet) 65%, transparent); }
.atlas__body.is-focused .tcard.is-down { border-color: color-mix(in srgb, var(--brand-gold) 70%, transparent); }

/* ---- connectors ---- */
.atlas__link {
  fill: none; stroke: var(--border-strong); stroke-width: 1.7; stroke-linecap: round;
  transition: stroke .2s var(--ease), stroke-width .2s var(--ease), opacity .2s var(--ease);
}
.atlas__link.is-solved { stroke: color-mix(in srgb, var(--indigo) 70%, transparent); }
/* Optional links and arrows that jump several rows stay out of the way
   until asked for (the toggle) or until their chain is selected. */
.atlas__link.is-soft { stroke-dasharray: 3 5; display: none; }
.atlas__body.show-soft .atlas__link.is-soft { display: inline; opacity: .75; }
.atlas__link.is-far { display: none; }
.atlas__head { fill: var(--border-strong); }
.atlas__head--solved { fill: color-mix(in srgb, var(--indigo) 70%, transparent); }
.atlas__head--up { fill: var(--violet); }
.atlas__head--down { fill: var(--brand-gold); }
.atlas__body.is-focused .atlas__link { opacity: .1; }
.atlas__body.is-focused .atlas__link.is-up,
.atlas__body.is-focused .atlas__link.is-down { display: inline; opacity: 1; stroke-width: 2.4; }
.atlas__body.is-focused .atlas__link.is-up { stroke: var(--violet); marker-end: url(#lnkArrowUp); }
.atlas__body.is-focused .atlas__link.is-down { stroke: var(--brand-gold); marker-end: url(#lnkArrowDown); }

/* ============================================================== ONE TOPIC */
.tview__hero {
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px 20px 18px; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.tview__nav-top { display: flex; align-items: center; gap: 12px; }
.tview__back {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 13px 6px 10px;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tview__back:hover { color: var(--text); border-color: var(--border-strong); }
.tview__pos { margin-left: auto; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.tview__stepper { display: inline-flex; gap: 4px; }
.tview__step {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border); color: var(--text-dim);
  transition: color var(--dur), border-color var(--dur);
}
.tview__step:hover { color: var(--text); border-color: var(--border-strong); }
.tview__step.is-off { opacity: .35; }
.tview__title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tview__icon {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.tview__icon svg { width: 22px; height: 22px; }
.tview__title-text { flex: 1; min-width: 200px; }
.tview__title-text h2 { font-size: clamp(21px, 2.4vw, 27px); font-weight: 800; letter-spacing: -.025em; }
.tview__title-text p { margin-top: 3px; font-size: 13px; color: var(--muted); }
.tview__title-text p b { color: var(--text); font-family: var(--font-mono); font-size: 12.5px; }
.tview__status { font-weight: 600; }
.tview__status.is-done, .tview__status.is-started { color: var(--indigo); }
.tview__go { flex: 0 1 auto; gap: 12px; padding: 9px 14px; max-width: 100%; text-align: left; }
.tview__go-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.tview__go-text small { font-size: 11px; font-weight: 600; opacity: .8; }
.tview__go-text span { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28ch; }
.tview__go-arrow { display: grid; place-items: center; }
.tview__go.is-done {
  display: inline-flex; align-items: center; padding: 9px 14px; border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 700; color: var(--indigo);
  border: 1px dashed color-mix(in srgb, var(--indigo) 45%, transparent);
}
.tview__meter { height: 6px; }
.tview__facts { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 28px; flex-wrap: wrap; }
.tview__diffs { display: flex; flex-wrap: wrap; gap: 6px; }
.tview__diff {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-dim);
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2);
}
.tview__diff i { width: 7px; height: 7px; border-radius: 50%; }
.tview__diff[data-diff="intro"] i  { background: var(--intro); }
.tview__diff[data-diff="easy"] i   { background: var(--easy); }
.tview__diff[data-diff="medium"] i { background: var(--medium); }
.tview__diff[data-diff="hard"] i   { background: var(--hard); }
.tview__deps { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.tview__dep { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tview__dep-label {
  flex: 0 0 auto; width: 72px; white-space: nowrap;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.tview__dep-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tview__dep-none { font-size: 12.5px; color: var(--muted); font-style: italic; }
.dchip {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.dchip:hover { color: var(--text); border-color: var(--border-strong); }
.dchip.is-complete { color: var(--indigo); border-color: color-mix(in srgb, var(--indigo) 35%, transparent); }
.dchip__check { display: grid; place-items: center; }
.dchip__check svg { width: 11px; height: 11px; }

/* ---- outline rail + stages ---- */
.tview__layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; margin-top: 22px; align-items: start; }
.tview__outline {
  position: sticky; top: calc(var(--hbar-h, 58px) + 16px);
  max-height: calc(100vh - var(--topbar-h) - var(--hbar-h, 58px) - 32px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; scrollbar-width: none;
}
.tview__outline::-webkit-scrollbar { display: none; }
.tview__outline-title { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 0 4px; }
.tview__ol-stage { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; }
.tview__ol-no {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; margin-top: 6px;
  border: 1px solid var(--border-strong); font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; color: var(--text-dim);
}
.tview__ol-list { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tview__ol-stage.is-split .tview__ol-list { border-left: 2px dotted var(--border-strong); padding-left: 6px; }
.tview__ol-link {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; align-items: start;
  width: 100%; padding: 6px 8px; border-radius: var(--r-sm); text-align: left; font-family: inherit;
  color: var(--text-dim); transition: background .14s ease, color .14s ease;
}
.tview__ol-link:hover { background: var(--surface-2); color: var(--text); }
.tview__ol-link.is-current { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--indigo) 45%, transparent); }
.tview__ol-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.tview__ol-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.tview__ol-link.is-complete .tview__ol-count { color: var(--indigo); font-weight: 700; }
.tview__ol-bar { grid-column: 1 / -1; height: 3px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.tview__ol-bar i { display: block; height: 100%; background: var(--indigo); border-radius: inherit; }

.tview__body { position: relative; min-width: 0; }
.tview__track { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.tview__trail { fill: none; stroke: var(--border-strong); stroke-width: 1.7; stroke-linecap: round; }
.tview__trail.is-solved { stroke: color-mix(in srgb, var(--indigo) 70%, transparent); }
.tview__stages { position: relative; z-index: 1; }

/* ---- the step between stages ---- */
.tstep { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 16px 0 18px; }
.tstep.is-first { padding-top: 0; }
.tstep__no {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--text-dim);
}
.tstep__label:not(:empty) {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: var(--bg); padding: 3px 12px; border-radius: 999px;
  box-shadow: 0 0 0 5px var(--bg);
}
.tstage { display: grid; gap: 14px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tstage[data-coves="1"] { grid-template-columns: minmax(0, 1fr); }

/* ---- a pattern (group of problems) ---- */
.cove {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); padding: 13px 12px 12px; min-width: 0;
  scroll-margin-top: calc(var(--hbar-h, 58px) + 16px);
  box-shadow: var(--shadow-sm);
  transition: opacity .2s var(--ease), box-shadow .3s var(--ease);
}
.cove.is-complete { border-color: color-mix(in srgb, var(--indigo) 35%, transparent); }
.cove.is-current { border-color: var(--indigo); box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 12%, transparent); }
.cove.is-flash { animation: cove-flash 1.2s var(--ease); }
@keyframes cove-flash {
  0%, 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 22%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.cove__head { display: flex; align-items: flex-start; gap: 10px; padding: 0 4px; }
.cove__range {
  flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-top: 1px;
}
.cove__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cove__name { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
.cove__note { font-size: 12px; color: var(--muted); line-height: 1.4; }
.cove__here {
  flex: 0 0 auto; font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--on-accent); background: var(--indigo); border-radius: 999px; padding: 3px 8px; margin-top: 1px;
}
.cove__count { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.cove.is-complete .cove__count { color: var(--indigo); font-weight: 700; }
.cove__meter { display: block; height: 3px; margin: 10px 4px 8px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.cove__meter i { display: block; height: 100%; background: var(--indigo); border-radius: inherit; }
.cove__list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
/* A pattern alone on its stage has the whole width — flow its problems
   into columns rather than one long ladder. */
.cove.is-wide .cove__list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); column-gap: 8px; }

/* ---- a problem ---- */
.pnode {
  display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; padding: 7px 8px;
  border: 1px solid transparent; border-radius: var(--r-sm); cursor: pointer;
  background: none; color: var(--text); font: inherit; text-align: left;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity .2s var(--ease);
}
.pnode:hover { background: var(--surface-2); }
.pnode:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.pnode__no {
  flex: 0 0 20px; text-align: right; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.pnode__icon {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.pnode__icon svg { width: 13px; height: 13px; }
.pnode__name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnode__next {
  flex: 0 0 auto; font-size: 9.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--on-accent); background: var(--indigo); border-radius: 999px; padding: 2px 7px;
}
.pnode__diff { flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; }
.pnode__diff[data-diff="intro"]  { color: var(--intro);  background: color-mix(in srgb, var(--intro) 15%, transparent); }
.pnode__diff[data-diff="easy"]   { color: var(--easy);   background: color-mix(in srgb, var(--easy) 15%, transparent); }
.pnode__diff[data-diff="medium"] { color: var(--medium); background: color-mix(in srgb, var(--medium) 15%, transparent); }
.pnode__diff[data-diff="hard"]   { color: var(--hard);   background: color-mix(in srgb, var(--hard) 15%, transparent); }
.pnode.is-done .pnode__name { color: var(--muted); }
.pnode.is-done .pnode__icon { background: color-mix(in srgb, var(--indigo) 15%, transparent); border-color: transparent; color: var(--indigo); }
.pnode.is-next { border-color: color-mix(in srgb, var(--indigo) 45%, transparent); background: color-mix(in srgb, var(--indigo) 7%, transparent); }
.pnode.is-next .pnode__name { font-weight: 700; }

/* ---- a folded run of solved problems ---- */
.pfold {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 10px; margin: 1px 0;
  cursor: pointer; font: inherit; text-align: left;
  border: 1px dashed color-mix(in srgb, var(--indigo) 40%, transparent); border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--indigo) 6%, transparent); color: var(--indigo);
  transition: background var(--dur) var(--ease);
}
.pfold:hover { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.pfold__check { display: grid; place-items: center; flex: 0 0 auto; }
.pfold__check svg { width: 14px; height: 14px; }
.pfold__text { flex: 1; font-size: 12px; font-weight: 700; }
.pfold__more {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px; opacity: .8;
}

/* ---- onward ---- */
.tview__nav {
  display: flex; align-items: center; gap: 14px; margin-top: 30px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.tview__nav-link {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; min-width: 0; max-width: 46%;
  padding: 10px 15px; border-radius: var(--r-md); border: 1px solid var(--border); color: var(--text);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease);
}
.tview__nav-link:hover { border-color: var(--border-strong); }
.tview__nav-link.is-next { margin-left: auto; text-align: right; }
.tview__nav-link span { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tview__nav-link b { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =============================================================== The popup */
.mpop {
  position: absolute; left: 0; top: 0; z-index: 40; width: min(350px, calc(100vw - 28px));
  padding: 14px 15px 14px; border-radius: var(--r-lg);
  border: 1px solid var(--border-strong); background: var(--elevated); color: var(--text);
  box-shadow: 0 24px 60px -26px rgba(0,0,0,.65), 0 2px 8px -4px rgba(0,0,0,.3);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .16s var(--ease), visibility .16s;
}
.mpop.is-on { opacity: 1; visibility: visible; pointer-events: auto; }
/* pinned to the view's bottom-left corner (left / bottom / max-height set by map.js) */
.mpop.is-pinned { position: fixed; top: auto; overflow-y: auto; overscroll-behavior: contain; }
/* Dragged by its grip / header, to uncover the connections beneath it. */
.mpop__grip { width: 36px; height: 4px; margin: -6px auto 9px; border-radius: 999px; background: var(--border-strong); cursor: grab; }
.mpop__head { display: flex; align-items: flex-start; gap: 11px; cursor: grab; user-select: none; touch-action: none; }
.mpop.is-dragging { cursor: grabbing; transition: none; }
.mpop.is-dragging .mpop__head, .mpop.is-dragging .mpop__grip { cursor: grabbing; }
.mpop.is-dragging .mpop__grip { background: var(--muted); }
.mpop__icon {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.mpop__icon svg { width: 17px; height: 17px; }
.mpop__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mpop__title { font-size: 15px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
.mpop__sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; color: var(--muted); }
.mpop__sub b { color: var(--text); font-family: var(--font-mono); font-size: 11.5px; }
.mpop__status { font-weight: 600; }
.mpop__status.is-done, .mpop__status.is-started { color: var(--indigo); font-weight: 700; }
.mpop__x {
  flex: 0 0 auto; width: 28px; height: 28px; margin: -3px -4px 0 0; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted);
}
.mpop__x:hover { background: var(--surface-2); color: var(--text); }
.mpop__x svg { width: 14px; height: 14px; }
.mpop__meter { margin-top: 12px; }
.mpop__section { margin-top: 13px; }
.mpop__label { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.mpop__coves { display: flex; flex-direction: column; gap: 1px; max-height: 188px; overflow-y: auto; margin: 0 -6px; }
.mpop__cove {
  display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 7px;
  font-size: 12.5px; color: var(--text-dim);
}
.mpop__cove:hover { background: var(--surface-2); color: var(--text); }
.mpop__cove-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpop__cove-count { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.mpop__cove.is-complete .mpop__cove-count { color: var(--indigo); font-weight: 700; }
.mpop__deps { margin-top: 12px; display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; align-items: start; }
.mpop__deps dt { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-top: 5px; white-space: nowrap; }
.mpop__deps dd { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; }
.mpop__none { font-size: 12.5px; color: var(--muted); font-style: italic; padding-top: 4px; }
.mpop__actions { display: flex; gap: 8px; margin-top: 14px; }
.mpop__start { flex: 1; min-width: 0; justify-content: space-between; gap: 10px; text-align: left; }
.mpop__start-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mpop__start-text small { font-size: 10.5px; font-weight: 600; opacity: .8; }
.mpop__start-text span { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mpop__start-arrow { flex: 0 0 auto; display: grid; place-items: center; }
.mpop__open { flex: 0 0 auto; }

/* ------------------------------------------------------------- Filtering */
.map .tcard.is-miss { opacity: .28; }
.map .pnode.is-miss { opacity: .25; }
.map .cove.is-miss { opacity: .5; }
.map .tcard.is-hit { border-color: color-mix(in srgb, var(--brand-gold) 70%, var(--border)); }
.map .pnode.is-hit { background: color-mix(in srgb, var(--brand-gold) 10%, transparent); }

/* --------------------------------------------------- The List / Map pill */
.home__viewtoggle {
  display: inline-flex; align-items: stretch; padding: 3px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
}
.home__viewtoggle a {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 13px;
  border-radius: 999px; text-decoration: none; font-size: 13px; font-weight: 600;
  color: var(--text-dim); transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.home__viewtoggle a:hover { color: var(--text); }
.home__viewtoggle a.is-current { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px -4px rgba(0,0,0,.45); }
.home__viewtoggle svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------ Responsive */
@media (max-width: 1100px) {
  .atlas__row { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 20px 0; }
  .atlas__row-titles { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
  .atlas__row-titles .atlas__row-meta { margin-top: 0; }
  .atlas__row-head { align-items: center; }
  .tview__layout { grid-template-columns: minmax(0, 1fr); }
  .tview__outline { display: none; }
}
@media (max-width: 820px) {
  .map { padding: 16px 12px 48px; }
  .map__legend { display: none; }
  .atlas__row { grid-template-columns: minmax(0, 1fr); padding: 16px 0; gap: 12px; }
  .atlas__track { flex-direction: column; align-items: stretch; gap: 10px; }
  .tcard { width: 100%; flex: none; }
  /* Stacked cards make the arrow layer unreadable; the row numbers already
     carry the order, so the connectors stand down. */
  .atlas__links { display: none; }
  .tview__hero { padding: 14px; }
  .tview__pos { display: none; }
  .tview__stepper { margin-left: auto; }
  .tview__go { width: 100%; justify-content: space-between; }
  .tstage { grid-template-columns: minmax(0, 1fr); }
  .cove.is-wide .cove__list { grid-template-columns: minmax(0, 1fr); }
  .tview__nav-link { max-width: 48%; }
  .mpop {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; z-index: 60;
    border-radius: var(--r-xl) var(--r-xl) 0 0; border-width: 1px 0 0;
    transform: none !important; padding-bottom: calc(16px + env(safe-area-inset-bottom));
    max-height: 80vh; overflow-y: auto;
  }
  .mpop__grip { display: none; }
  .mpop__head { cursor: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .map__sheet, .tcard, .pnode, .mpop, .atlas__link { transition: none; }
}
