/* Course library: the course is a metro line, every lesson a station. Near-black, dimmed ink, no glow. */
:root {
  --ground: #121212;
  --raised: #1c1c1c;
  --deep: #0d0d0d;
  --line: #2a2a2a;
  --line-2: #3a3a3a;
  --ink: #b9b9b9;
  --ink-2: #9a9a9a;
  --ink-3: #858585;
  --porcelain: #d0d0d0;
  --bone: #c4c4c4;
  --rail: #7a7a7a;
  --rail-dim: #333333;
  --done: #7fa98a;
  --back: #c49a55;
  --f: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --gut: clamp(1rem, 4vw, 3rem);
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* each course carries its own line colour; the dim twin marks track not yet travelled */
.stop, .shop { --rail: var(--c); }
body, .stop, .shop { --rail-dim: color-mix(in srgb, var(--rail) 30%, var(--ground)); }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1.5rem; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 17px/1.8 var(--f); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  caret-color: var(--rail);
}
::selection { background: rgba(122, 122, 122, .38); color: var(--porcelain); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--porcelain); outline-offset: 3px; border-radius: 4px; }
.ic { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em; }
bdi { unicode-bidi: isolate; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 52px; padding: 0 var(--gut); border-bottom: 1px solid var(--line); font-size: .9rem;
}
.top-name { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; text-decoration: none; color: var(--ink); }
.top-name .ic { color: var(--rail); width: 1.35em; height: 1.35em; }
.top-name:hover { color: var(--porcelain); }
.top-course { color: var(--ink-3); }

/* ---------- the line strip ---------- */
.metro { border-bottom: 1px solid var(--line); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
@media (max-width: 900px) { .metro { -webkit-mask-image: linear-gradient(to left, transparent, #000 2.2rem, #000 calc(100% - 2.2rem), transparent); mask-image: linear-gradient(to left, transparent, #000 2.2rem, #000 calc(100% - 2.2rem), transparent); } }
.metro::-webkit-scrollbar { display: none; }
.stops { display: flex; list-style: none; margin: 0; padding: 2.1rem var(--gut) 2.3rem; min-width: max-content; }
.stop { position: relative; flex: 1 0 3.4rem; display: flex; justify-content: center; min-width: 3.4rem; }
.metro .stops { min-width: 100%; }
/* rail segment from this station to the next one (inline-end in RTL = to the left) */
.stop:not(:last-child)::before {
  content: ""; position: absolute; top: 50%; inset-inline-start: 50%; width: 100%; height: 5px; margin-top: -2.5px;
  background: var(--rail); border-radius: 3px; transform-origin: right;
}
.stop:not(.past):not(.now)::before, .stop.now::before { background: var(--rail-dim); }
.metro.draw .stop.past::before { transform: scaleX(0); }
.metro.drawn .stop.past::before { transform: scaleX(1); transition: transform var(--step, 40ms) linear calc(var(--i) * var(--step, 40ms)); }
.stop a { position: relative; z-index: 1; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; text-decoration: none; border-radius: 50%; }
.dot {
  display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--ground); border: 3.5px solid var(--rail); transition: transform .2s var(--ease), background-color .2s, border-color .2s;
}
.dot .n { font-size: .75rem; font-weight: 600; line-height: 1; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stop a:hover .dot { transform: scale(1.18); }
.di { display: none; width: .85rem; height: .85rem; stroke-width: 3; }
a[data-state="done"] .dot .n, a[data-state="review"] .dot .n { display: none; }
a[data-state="done"] .di-done, a[data-state="review"] .di-back { display: block; }
a[data-state="done"] .di-done { color: var(--ground); }
a[data-state="review"] .di-back { color: var(--back); }
.stop.now a .n { display: block !important; }
.stop.now a .di { display: none !important; }
a[data-state="done"] .dot { background: var(--rail); }
a[data-state="done"] .dot .n { color: var(--ground); }
a[data-state="review"] .dot { border-color: var(--back); }
a[data-state="review"] .dot .n { color: var(--back); }
.stop.now a { width: 3rem; height: 3rem; }
.stop.now .dot { width: 2.3rem; height: 2.3rem; background: var(--bone); border-color: var(--rail); border-width: 4px; }
.stop.now .dot .n { color: var(--ground); font-size: .95rem; font-weight: 700; }
.stop.now a[data-state="review"] .dot { border-color: var(--back); }
.seg, .here { position: absolute; inset-inline-start: 50%; transform: translateX(50%); white-space: nowrap; font-size: .8rem; line-height: 1; }
.seg { top: -1.5rem; color: var(--rail); font-weight: 600; }
.here { bottom: -1.65rem; color: var(--bone); font-weight: 600; }

/* ---------- platform sign ---------- */
.lesson { max-width: 1240px; margin: 0 auto; padding: 0 var(--gut); }
.station { display: flex; align-items: center; gap: clamp(1rem, 2.4vw, 1.75rem); padding: clamp(1.75rem, 4vw, 2.75rem) 0 1.5rem; }
.badge {
  flex: none; display: grid; place-items: center; width: 4.4rem; height: 4.4rem; border-radius: 50%;
  border: 5px solid var(--rail); font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.badge { position: relative; }
.badge-st { position: absolute; bottom: -.3rem; inset-inline-end: -.3rem; display: none; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--ground); border: 2px solid currentColor; }
.badge-st .di { width: .9rem; height: .9rem; }
.station[data-state="done"] .badge-st, .station[data-state="review"] .badge-st { display: grid; }
.station[data-state="done"] .badge-st { color: var(--done); }
.station[data-state="done"] .di-done, .station[data-state="review"] .di-back { display: block; }
.station[data-state="done"] .badge { background: var(--rail); color: var(--ground); }
.station[data-state="review"] .badge { border-color: var(--back); color: var(--back); }
.station-t { flex: 1; min-width: 0; }
.station h1 { margin: 0; font-size: clamp(1.75rem, 3.3vw, 2.75rem); font-weight: 700; line-height: 1.3; color: var(--porcelain); text-wrap: balance; }
.lesson-en .station h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.station-sub { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1.1rem; margin: .45rem 0 0; color: var(--ink-2); font-size: .95rem; }
.to-en { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink); text-decoration: underline; text-decoration-color: var(--rail); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.to-en:hover { text-decoration-color: var(--rail); }
.to-en .ic { color: var(--rail); }
.next-stop {
  flex: none; display: grid; grid-template-columns: 1fr auto; column-gap: .6rem; align-items: center; max-width: 17rem;
  padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink);
  transition: border-color .2s;
}
.next-stop small { grid-column: 1; color: var(--ink-3); font-size: .78rem; }
.next-stop span { grid-column: 1; font-weight: 600; font-size: .95rem; line-height: 1.5; }
.next-stop .ic { grid-column: 2; grid-row: 1 / 3; color: var(--rail); }
.next-stop:hover { border-color: var(--rail); }
.next-stop { border-color: color-mix(in srgb, var(--rail) 45%, var(--line)); }

/* ---------- lesson card (who, what, style) ---------- */
.band { background: var(--raised); border-radius: 10px; padding: 1rem clamp(1rem, 2.5vw, 1.6rem); font-size: .95rem; }
.band-top { display: flex; flex-wrap: wrap; gap: .4rem 2.2rem; }
.band-top p { margin: 0; display: flex; gap: .6rem; align-items: baseline; }
.band-k { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-3); font-weight: 500; font-size: .85rem; }
.band-top a { color: var(--ink); text-underline-offset: 5px; text-decoration-color: var(--line-2); }
.band-more { margin-top: .5rem; border-top: 1px solid var(--line); }
.band-more summary { display: flex; align-items: center; gap: .45rem; padding-top: .7rem; cursor: pointer; color: var(--ink-2); list-style: none; width: fit-content; }
.band-more summary::-webkit-details-marker { display: none; }
.band-more summary:hover { color: var(--ink); }
.chev { transition: transform .2s var(--ease); }
details[open] > summary .chev { transform: rotate(180deg); }
.band-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 2.5rem; padding: .6rem 0 .3rem; }
.band-cols p { margin: 0 0 .25rem; line-height: 1.85; }
.band-style .ic { color: var(--back); }
.band-warn .band-style p:last-child { color: var(--ink); }

/* ---------- reading grid ---------- */
.read { display: grid; grid-template-columns: minmax(0, 1fr) 16.5rem; grid-template-areas: "text rail"; gap: clamp(2rem, 5vw, 4.5rem); padding-top: 2.4rem; }
.text { grid-area: text; max-width: 68ch; font-size: 19px; line-height: 2; }
.text p { position: relative; margin: 0 0 1.15em; }
.text .sec { scroll-margin-top: 1.5rem; }
.text .sec + .sec { margin-top: 3rem; }
.text h2 { display: flex; align-items: center; gap: .8rem; margin: 0 0 1rem; font-size: 1.4rem; font-weight: 600; line-height: 1.5; color: var(--porcelain); text-wrap: balance; }
.sec-n {
  flex: none; display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  border: 3px solid var(--rail); font-size: .8rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums;
}
.text strong { font-weight: 600; color: var(--porcelain); }
.text p.arrive { animation: arrive 2.4s var(--ease); }
@keyframes arrive { 0%, 30% { background: rgba(122, 122, 122, .16); } 100% { background: transparent; } }
.text p.arrive { border-radius: 6px; }

/* paragraph mark: a bookmark tab in the margin */
.pmark {
  position: absolute; inset-inline-start: -3.1rem; top: .15em; width: 2.75rem; height: 2.75rem; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink-3); cursor: pointer; opacity: 0;
  transition: opacity .15s, color .15s;
}
.text p:hover .pmark, .pmark:focus-visible { opacity: 1; }
.pmark:hover { color: var(--ink); }
.text p.marked .pmark { opacity: 1; color: var(--rail); }
.text p.marked .pmark svg { fill: currentColor; }
@media (hover: none) { .pmark { opacity: .7; } }

.term { border-bottom: 1.5px dotted var(--rail); cursor: help; }
.term:hover, .term:focus-visible { border-bottom-color: var(--rail); color: var(--porcelain); }
#tip {
  position: fixed; z-index: 30; max-width: min(22rem, calc(100vw - 24px)); padding: .65rem .9rem; border-radius: 8px;
  background: #262626; color: var(--ink); font-size: .92rem; line-height: 1.8; box-shadow: 0 10px 28px -10px rgba(0, 0, 0, .7);
}
#tip b { color: var(--porcelain); margin-inline-end: .3rem; }
.tnote { margin: 0 0 1.15em; padding: .8rem 1.1rem; border-radius: 8px; background: var(--raised); color: var(--ink-2); font-size: .95rem; line-height: 1.9; }
.tnote b { color: var(--ink); font-weight: 600; }

/* ---------- section rail: a short line whose stations are the sections ---------- */
.rail { grid-area: rail; position: sticky; top: 1.5rem; align-self: start; max-height: calc(100vh - 3rem); overflow-y: auto; font-size: .92rem; padding-bottom: 1rem; }
.rail-h { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0 0 .8rem; color: var(--ink-3); font-size: .82rem; font-weight: 500; }
.rail-h .ic { color: var(--rail); }
.pct { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.rail-line { position: relative; }
.rail-line::before, .rail-fill { content: ""; position: absolute; inset-inline-start: .55rem; top: .9rem; width: 4px; margin-inline-start: -2px; border-radius: 2px; }
.rail-line::before { bottom: .9rem; background: var(--rail-dim); }
.rail-fill { top: 0; height: 0; background: var(--rail); transition: height .2s linear; }
.rail ol { list-style: none; margin: 0; padding: 0; position: relative; }
.rail-line a { display: grid; grid-template-columns: 1.1rem 1fr; gap: .7rem; align-items: start; padding: .4rem 0; text-decoration: none; color: var(--ink-3); line-height: 1.6; }
.rail-line .st { width: 1.1rem; height: 1.1rem; margin-top: .25rem; border-radius: 50%; background: var(--ground); border: 3px solid var(--rail-dim); transition: border-color .2s, background-color .2s; }
.rail-line a.past .st { border-color: var(--rail); background: var(--rail); }
.rail-line a.on .st { border-color: var(--rail); background: var(--bone); }
.rail-line a.on { color: var(--porcelain); font-weight: 600; }
.rail-line a:hover { color: var(--ink); }
.marks { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.marks ol { display: grid; gap: .3rem; }
.marks a { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--ink-2); text-decoration: none; font-size: .88rem; line-height: 1.65; padding: .2rem 0; }
.marks a:hover { color: var(--ink); }

/* learning state */
.status { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1.4rem; }
.rail .status { display: grid; justify-items: stretch; gap: .4rem; }
.status button {
  display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .85rem; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); font-size: .88rem; transition: border-color .15s, color .15s, background-color .15s;
}
.status button:hover { color: var(--ink); border-color: var(--ink-3); }
.status button.on[data-st="todo"] { color: var(--ink); border-color: var(--ink-2); }
.status button.on[data-st="done"] { color: var(--done); border-color: var(--done); background: rgba(127, 169, 138, .1); }
.status button.on[data-st="review"] { color: var(--back); border-color: var(--back); background: rgba(196, 154, 85, .1); }
.note {
  display: block; width: 100%; margin-top: 1rem; padding: .7rem .85rem; resize: none; border-radius: 8px;
  background: var(--deep); border: 1px solid var(--line); color: var(--ink); font: 400 .95rem/1.8 var(--f);
}
.note::placeholder { color: var(--ink-3); }
.note:focus { outline: none; border-color: var(--ink-3); }

/* ---------- glossary, apply, files ---------- */
.gloss { margin-top: 3rem; border-top: 1px solid var(--line); font-size: 1rem; line-height: 1.85; }
.gloss summary { display: flex; align-items: center; gap: .5rem; padding: 1rem 0; cursor: pointer; list-style: none; font-weight: 600; color: var(--ink); width: fit-content; }
.gloss summary::-webkit-details-marker { display: none; }
.gl-hint { color: var(--ink-3); font-size: .9rem; margin: 0 0 .8rem; }
.gloss dl { margin: 0; display: grid; gap: .55rem; }
.gl-row { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; }
.gl-row dt { font-weight: 600; color: var(--porcelain); text-align: right; }
.gl-row dd { margin: 0; color: var(--ink-2); }

.apply { margin-top: 3.5rem; }
.apply h2 .ic { color: var(--rail); }
.tasks { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: .6rem; font-size: 1.02rem; line-height: 1.85; }
.tasks label { display: flex; gap: .8rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 8px; background: var(--raised); cursor: pointer; }
.tasks input {
  appearance: none; flex: none; width: 1.2rem; height: 1.2rem; margin: .38rem 0 0; border: 2px solid var(--ink-3); border-radius: 4px; cursor: pointer;
  display: grid; place-items: center; transition: background-color .15s, border-color .15s;
}
.tasks input:checked { background: var(--done); border-color: var(--done); }
.tasks input:checked::after { content: ""; width: .35rem; height: .65rem; border: solid var(--ground); border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.tasks input:checked + span { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.fcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .9rem; }
.fcard { display: flex; flex-direction: column; padding: 1rem 1.15rem; border-radius: 10px; border: 1px solid var(--line); background: var(--deep); font-size: .92rem; line-height: 1.75; }
.fcard header { display: flex; align-items: flex-start; gap: .55rem; flex-wrap: wrap; }
.fcard header .ic { color: var(--rail); margin-top: .25rem; }
.fcard h3 { margin: 0; flex: 1; font-size: .98rem; font-weight: 600; text-align: right; line-height: 1.5; }
.fc-tag { font-size: .75rem; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-3); }
.fcard dl { margin: .7rem 0; display: grid; gap: .35rem; }
.fc-row { display: grid; grid-template-columns: 5rem 1fr; gap: .6rem; }
.fc-row dt { color: var(--ink-3); }
.fc-row dd { margin: 0; color: var(--ink-2); }
.fc-open { margin-top: auto; display: inline-flex; align-items: center; gap: .4rem; width: fit-content; color: var(--ink); text-underline-offset: 5px; text-decoration-color: var(--line-2); }
.fc-open:hover { text-decoration-color: var(--rail); }
.fcard-junk { border-style: dashed; color: var(--ink-3); }
.fcard-junk .fc-row dd, .fcard-junk h3 { color: var(--ink-3); }

.end { margin-top: 3.5rem; padding: 1.6rem 0 .5rem; border-top: 2px dashed var(--line-2); text-align: center; color: var(--ink-2); }
.end p { margin: 0; }
.end .status { justify-content: center; }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3.5rem; padding: 1.4rem 0 3rem; border-top: 1px solid var(--line); }
.pager a { display: flex; align-items: center; gap: .7rem; max-width: 46%; text-decoration: none; color: var(--ink); line-height: 1.5; }
.pager a .ic { color: var(--rail); }
.pager small { display: block; color: var(--ink-3); font-size: .8rem; }
.pager a:hover span { color: var(--porcelain); }
.nav-next { text-align: left; }

/* resume chip on a lesson he left halfway */
.chip-wrap {
  position: fixed; z-index: 20; bottom: 1.25rem; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch;
  border-radius: 999px; background: #262626; border: 1px solid var(--line-2); box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .8);
  animation: chip .35s var(--ease);
}
@keyframes chip { from { opacity: 0; transform: translate(-50%, 12px); } }
.resume-chip { display: flex; align-items: center; gap: .7rem; padding: .6rem 1.2rem; border: 0; background: transparent; cursor: pointer; font-weight: 600; white-space: nowrap; }
.resume-chip small { color: var(--ink-3); font-weight: 400; }
.resume-chip:hover span { color: var(--porcelain); }
.chip-x { border: 0; border-inline-start: 1px solid var(--line-2); background: transparent; padding: 0 .95rem; cursor: pointer; color: var(--ink-3); font-size: 1.2rem; }
.chip-x:hover { color: var(--ink); }

/* reading depth on narrow screens, where the rail sits below the text */
.readbar { display: none; }
@media (max-width: 900px) {
  .readbar { display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 10; margin: 0 calc(var(--gut) * -1); padding: .45rem var(--gut); background: var(--ground); border-bottom: 1px solid var(--line); }
  .readbar i { display: block; flex: 1; height: 4px; border-radius: 2px; background: var(--rail-dim); background-image: linear-gradient(var(--rail), var(--rail)); background-repeat: no-repeat; background-size: 0 100%; background-position: right; }
  .readbar b { font-size: .8rem; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 2.6rem; text-align: left; }
}

/* English original */
.text-en { font-size: 18px; line-height: 1.75; text-align: left; max-width: 70ch; margin: 1rem 0 4rem; }
.lesson-en .station-sub span { direction: rtl; }

/* ---------- home: the line map ---------- */
.home { max-width: 52rem; margin: 0 auto; padding: clamp(2rem, 5vw, 3.5rem) var(--gut) 4rem; }
.home h1 { margin: 0; font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; line-height: 1.2; color: var(--porcelain); direction: ltr; text-align: right; }
.home-sub { margin: .7rem 0 0; color: var(--ink-2); max-width: 46ch; }
.home-progress { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; margin: 1rem 0 0; color: var(--ink-3); font-size: .92rem; }
.home-progress .g { color: var(--done); }
.home-progress .a { color: var(--back); }
.resume {
  display: grid; margin-top: 1.5rem; padding: 1rem 1.25rem; border-radius: 12px; border: 1px solid var(--rail); background: var(--raised);
  text-decoration: none; transition: background-color .2s;
}
.resume small { color: var(--ink-3); font-size: .85rem; }
.resume span { font-size: 1.15rem; font-weight: 600; color: var(--porcelain); }
.resume:hover { background: #222222; }
.search { display: flex; align-items: center; gap: .6rem; margin-top: 1.5rem; padding: .7rem 1rem; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); color: var(--ink-3); }
.search:focus-within { border-color: var(--ink-3); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; outline: none; }
.search input::placeholder { color: var(--ink-3); }
.results { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .4rem; }
.results a { display: block; padding: .7rem 1rem; border-radius: 8px; background: var(--deep); text-decoration: none; font-weight: 600; }
.results a:hover { background: var(--raised); }
.results small { display: block; color: var(--ink-3); font-weight: 400; font-size: .8rem; }
.snip { color: var(--ink-2); font-weight: 400; font-size: .9rem; line-height: 1.8; }
.results mark { background: rgba(122, 122, 122, .3); color: var(--porcelain); border-radius: 3px; padding: 0 .1em; }

.map { --x: 1.15rem; margin-top: 2.6rem; }
.map-h { display: flex; align-items: center; gap: .6rem; margin: 0 0 1rem; color: var(--ink-2); font-weight: 600; }
.line-chip { width: 1.6rem; height: 5px; border-radius: 3px; background: var(--rail); }
.shop { position: relative; }
.shop-sign, .shop-list li { position: relative; padding-inline-start: 3.3rem; }
.shop-sign::before, .shop-list li::before {
  content: ""; position: absolute; inset-inline-start: var(--x); top: 0; bottom: 0; width: 5px; margin-inline-start: -2.5px; background: var(--rail-dim);
}
.shop-list li:has(a[data-state="done"])::before, .shop-list li:has(a[data-state="done"]) + li::before, .shop[data-state="done"] .shop-sign::before { background: var(--rail); }
.shop:first-of-type .shop-sign::before { top: 1.4rem; }
.shop-sign { padding-top: .9rem; padding-bottom: .5rem; }
.xing {
  position: absolute; z-index: 1; inset-inline-start: var(--x); top: 1.05rem; width: 1.9rem; height: 1.1rem; transform: translateX(50%);
  border-radius: 999px; background: var(--ground); border: 3.5px solid var(--rail);
}
.shop-sign h2 { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--porcelain); }
.shop-sign p { margin: 0; color: var(--ink-3); font-size: .85rem; line-height: 1.6; }
.shop-sign p[dir="ltr"] { text-align: right; }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list a { display: flex; align-items: center; gap: .9rem; padding: .55rem 0; text-decoration: none; color: var(--ink); line-height: 1.6; }
.shop-list .dot { position: absolute; z-index: 1; inset-inline-start: var(--x); width: 1.85rem; height: 1.85rem; transform: translateX(50%); }
.shop-list .dot .n { font-size: .78rem; }
.shop-list a:hover .dot { transform: translateX(50%) scale(1.12); }
.shop-list a:hover .li-t { color: var(--porcelain); }
.li-t { flex: 0 1 auto; }
.li-p { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-3); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
a[data-state="done"] .li-p { color: var(--done); }
a[data-state="review"] .li-p { color: var(--back); }
.shop:last-of-type .shop-list li:last-child::before { bottom: 50%; }
.map-end { position: relative; margin: 0; padding: 3.6rem 0 0; padding-inline-start: 3.3rem; color: var(--ink-3); font-size: .9rem; }
.bend { position: absolute; top: 0; inset-inline-start: calc(var(--x) - .625rem); width: 3.75rem; height: 4rem; overflow: visible;
  fill: none; stroke: var(--rail-dim); stroke-width: 5; stroke-dasharray: 1 9; stroke-linecap: round; }

/* ---------- interaction: train, focus, arrival, station preview, station-to-station travel ---------- */
.train {
  position: absolute; z-index: 2; inset-inline-start: .55rem; top: 0; width: .8rem; height: 1.55rem; margin-top: -.78rem;
  border-radius: .45rem; background: var(--rail); border: 2px solid var(--ground); transform: translate(50%, 0);
  transition: transform .25s var(--ease);
}
.text.focus .sec p, .text.focus .tnote { transition: opacity .45s var(--ease); }
.text.focus .sec p:not(.cur), .text.focus .tnote { opacity: .55; }
.text.focus .sec p:hover, .text.focus .sec p:focus-within { opacity: 1; }
.focus-t {
  display: block; width: 100%; margin-top: .9rem; padding: .4rem .85rem; border-radius: 999px; cursor: pointer; text-align: start;
  background: transparent; border: 1px dashed var(--line-2); color: var(--ink-3); font-size: .85rem;
}
.focus-t[aria-pressed="true"] { border-style: solid; border-color: var(--rail); color: var(--ink); }
.focus-t[aria-pressed="true"]::before { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-inline-end: .5rem; border-radius: 50%; background: var(--rail); vertical-align: .05em; }
.focus-t:hover { color: var(--ink); }

.stop.now.ran::before { background: var(--rail); animation: run .7s var(--ease) both; }
@keyframes run { from { transform: scaleX(0); } }
.badge.pop { animation: pop .5s var(--ease); }
@keyframes pop { 40% { transform: scale(1.12); } }
.arrive-msg { display: grid; margin: 0; padding: .55rem 1.2rem; line-height: 1.5; white-space: nowrap; }
.arrive-msg b { color: var(--porcelain); font-weight: 600; }
.arrive-msg small { color: var(--ink-3); font-size: .8rem; }
.arrive-go { display: flex; align-items: center; gap: .45rem; padding: 0 1.1rem; border-inline-start: 1px solid var(--line-2); color: var(--rail); font-weight: 600; text-decoration: none; white-space: nowrap; }
.arrive-go:hover { background: rgba(255, 255, 255, .04); }

.peek {
  position: fixed; z-index: 40; width: 19rem; padding: .8rem 1rem .85rem; border-radius: 8px; pointer-events: none;
  background: #1f1f1f; border: 1px solid var(--line-2); box-shadow: 0 14px 32px -14px rgba(0, 0, 0, .85); line-height: 1.7;
  animation: peek .18s var(--ease);
}
@keyframes peek { from { opacity: 0; transform: translateY(4px); } }
.peek small { display: block; color: var(--ink-3); font-size: .78rem; }
.peek b { display: block; color: var(--porcelain); font-weight: 600; font-size: 1rem; margin: .1rem 0 .3rem; }
.peek p { margin: 0; color: var(--ink-2); font-size: .86rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.peek-st { display: inline-flex; align-items: center; gap: .3rem; margin-top: .45rem; font-size: .8rem; color: var(--ink-3); }
.peek-st[data-state="done"] { color: var(--done); }
.peek-st[data-state="review"] { color: var(--back); }

/* moving between lessons: the big station slides to the new stop (browsers with cross-page view transitions) */
@view-transition { navigation: auto; }
.stop.now .dot { view-transition-name: now-dot; }
::view-transition-group(now-dot) { animation-duration: .5s; animation-timing-function: cubic-bezier(.16, 1, .3, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }

/* ---------- motion: the metro moves ---------- */
.stops { position: relative; }
.runner {
  position: absolute; z-index: 0; top: 50%; left: 0; width: 1.5rem; height: .7rem; margin: -.35rem 0 0 -.75rem;
  border-radius: .35rem; background: var(--bone); box-shadow: 0 0 0 2.5px var(--ground); pointer-events: none;
}
.stop.path::before { background: var(--rail) !important; filter: brightness(1.3); transition: filter .2s; }
.stop.path .dot { border-color: var(--rail); }
.sec-n { transition: background-color .45s var(--ease), color .45s var(--ease); }
.sec-n.lit { background: var(--rail); color: var(--ground); }
.cnt { display: inline-block; font-weight: 600; color: var(--ink); }
.cnt.tick { animation: tick .45s var(--ease); }
@keyframes tick { from { transform: translateY(-.6em); opacity: 0; } }
.map.intro .shop-sign::before, .map.intro .shop-list li::before { transform-origin: top; animation: grow 70ms linear both; animation-delay: calc(var(--k) * 70ms); }
.map.intro .shop-list .dot, .map.intro .xing { animation: popin .35s var(--ease) both; animation-delay: calc(var(--k) * 70ms + 120ms); }
.map.intro .shop-list .li-t, .map.intro .shop-list .li-p, .map.intro .shop-sign h2, .map.intro .shop-sign p { animation: fadein .4s var(--ease) both; animation-delay: calc(var(--k) * 70ms + 160ms); }
.map.intro .di-done path { stroke-dasharray: 24; animation: draw .4s var(--ease) both; animation-delay: calc(var(--k) * 70ms + 300ms); }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes popin { from { transform: translateX(50%) scale(0); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes draw { from { stroke-dashoffset: 24; } }
.tasks input:checked::after { animation: tickbox .28s var(--ease); }
@keyframes tickbox { from { transform: translateY(-1px) rotate(45deg) scale(0); } }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .read { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "rail"; }
  .rail { position: static; max-height: none; overflow: visible; padding-top: 1.6rem; border-top: 1px solid var(--line); }
  .station { flex-wrap: wrap; }
  .next-stop { flex: 1 1 100%; max-width: none; }
  .band-cols { grid-template-columns: 1fr; }
  .text p { padding-inline-end: 2rem; }
  .pmark { inset-inline-start: auto; inset-inline-end: -.4rem; width: 2rem; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .text { font-size: 18px; line-height: 1.95; }
  .badge { width: 3.4rem; height: 3.4rem; border-width: 4px; font-size: 1.2rem; }
  .station { gap: .9rem; padding-top: 1.5rem; }
  .top-course { display: none; }
  .stop { flex-basis: 2.9rem; min-width: 2.9rem; }
  .gl-row { grid-template-columns: 1fr; gap: 0; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .nav-next { justify-content: flex-end; }
  .chip-wrap { width: calc(100% - 2rem); }
  .resume-chip { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}
