:root {
  color-scheme: light;
  --ink: #242222;
  --muted: #5e5854;
  --surface: #faf7f1;
  --paper: #fffdf9;
  --line: #e5ded2;
  --plum: #443268;
  --purple-wash: #f1ebfa;
  --orange: #a24722;
  --goal-bg: #fbf3e8;
  --goal-border: #d9824f;
  --check-bg: #eef6f2;
  --check-ink: #1e4b3e;
  --note-bg: #f6f1e7;
  font: 16px/1.75 system-ui, "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--surface); }
a { color: var(--plum); text-underline-offset: .22em; }
a:hover { color: var(--orange); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid #805fbb; outline-offset: 4px; }

/* === Site Topbar === */
.site-topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.site-topbar-inner {
  width: min(1080px, calc(100% - 48px));
  margin-inline: auto;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 0;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 750;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.site-brand img {
  height: 30px;
  width: auto;
  display: block;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
}
.site-nav a {
  text-decoration: none;
  font-size: .92rem;
  font-weight: 600;
  color: var(--muted);
  padding: .24rem .45rem;
  border-radius: 6px;
}
.site-nav a:hover, .site-nav a.active {
  color: var(--plum);
  background: var(--purple-wash);
}
.tutorial-language {
  position: relative;
  margin-inline-start: auto;
}
.tutorial-language summary {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 44px;
  padding: .24rem .72rem;
  border: 1px solid #b7d7c8;
  border-radius: 999px;
  background: #e9f3ee;
  color: var(--check-ink);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.tutorial-language summary::-webkit-details-marker { display: none; }
.tutorial-language summary::after {
  content: "";
  width: .42rem;
  height: .42rem;
  border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  transform: translateY(-.1rem) rotate(45deg);
}
.tutorial-language[open] summary::after { transform: translateY(.1rem) rotate(225deg); }
.tutorial-language summary:hover, .tutorial-language[open] summary {
  background: #d8ece2;
  border-color: #7eb69c;
}
.tutorial-language-options {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  min-width: max(9rem, 100%);
  max-height: min(60dvh, 28rem);
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 6px 18px #2422221a;
}
.tutorial-language-options a, .tutorial-language-options [aria-current] {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: .35rem .7rem;
}
.tutorial-language-options [aria-current] {
  border-radius: 6px;
  background: var(--check-bg);
  color: var(--check-ink);
  font-size: .92rem;
  font-weight: 700;
}

/* === Main Page Layout === */
header.page-header, main, footer.site-footer {
  width: min(1080px, calc(100% - 48px));
  margin-inline: auto;
}
header.page-header {
  padding: 28px 0 26px;
  border-bottom: 1px solid var(--line);
}

/* === Breadcrumb === */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  font-size: .86rem;
  color: var(--muted);
}
.breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb li + li::before { content: "/"; color: #b5aca0; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--plum); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 600; }

.top-nav { display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.top-nav a, nav.pills a {
  display: inline-block; font-size: .9rem; border: 1px solid #dcd3e9;
  border-radius: 8px; padding: .32rem .72rem; background: var(--paper); text-decoration: none;
}
.top-nav a:hover, nav.pills a:hover { border-color: #a587d0; background: var(--purple-wash); }
.top-nav a.primary, nav.pills a.primary { background: var(--plum); color: #fff; border-color: var(--plum); }
.top-nav a.primary:hover, nav.pills a.primary:hover { background: #5a4287; color: #fff; }

.hero { display: grid; grid-template-columns: 1.45fr .9fr; align-items: center; gap: 30px; }
.hero.single { grid-template-columns: 1fr; }
.hero-thumb {
  display: block; width: 100%; max-height: 280px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: #1a1f28;
}
.kicker { color: var(--orange); font-size: .88rem; font-weight: 720; margin: 0; letter-spacing: .02em; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  font-size: clamp(1.9rem, 4.2vw, 2.85rem);
  letter-spacing: -.025em;
  line-height: 1.2;
  margin: .24em 0 .28em;
  text-wrap: balance;
}
.subtitle {
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--plum);
  margin: 0 0 .65em;
  line-height: 1.48;
}
h2 { font-size: clamp(1.42rem, 2.7vw, 1.95rem); line-height: 1.3; margin-bottom: .45em; }
h3 { font-size: 1.18rem; line-height: 1.4; margin: 0 0 .65em; }
p { margin-bottom: .85em; }
header.page-header p:last-child { margin-bottom: 0; }
.lede { color: var(--muted); max-width: 52rem; }
.meta-links { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: .5rem; }
.source-link { display: inline-block; font-weight: 600; }
.pill-link {
  display: inline-block; font-size: .9rem; font-weight: 600;
  padding: .28rem .75rem; border-radius: 999px; background: var(--purple-wash);
  border: 1px solid #d2c2e8; text-decoration: none;
}
.pill-link:hover { background: #e6dbf6; }
nav.pills { display: flex; gap: 8px 10px; flex-wrap: wrap; padding-top: 18px; }

.overview {
  margin: 26px 0 20px; padding: clamp(16px, 2.8vw, 24px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
}
.overview h2 { font-size: 1.22rem; margin-bottom: .65rem; color: var(--plum); }
.concepts { margin: 0 0 .9rem; padding-left: 1.25rem; max-width: 82ch; }
.concepts li { margin-bottom: .42rem; }
.concepts li:last-child { margin-bottom: 0; }
.overview .concepts { margin-bottom: 0; }

.video-card {
  margin: 20px 0; padding: clamp(16px, 2.8vw, 24px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
}
.video-card h2 { font-size: 1.18rem; margin-bottom: .65rem; }
.video-card video {
  display: block; width: 100%; max-width: 760px; border-radius: 8px;
  border: 1px solid var(--line); background: #14171f;
}
.video-meta {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  margin-top: .65rem; font-size: .9rem; color: var(--muted);
}

.step {
  padding: clamp(18px, 3vw, 28px); margin-block: 18px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  scroll-margin-top: 76px;
}
.step > p { max-width: 82ch; }
.manual-practice > strong {
  display: block; margin-bottom: .25em; color: var(--plum);
}
.step ol { margin: .55rem 0 1rem; padding-left: 1.4rem; max-width: 82ch; }
.step ol li { margin-bottom: .55rem; }
.step ol li:last-child { margin-bottom: 0; }
.when {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  margin-bottom: .5em; font-size: .9rem; color: var(--muted);
}
.step-badge {
  display: inline-block; font-weight: 700; color: var(--orange);
  background: var(--goal-bg); border: 1px solid #ecc6aa;
  border-radius: 999px; padding: .05rem .62rem; font-size: .82rem;
}
.blend-dl {
  display: inline-block; font-size: .86rem; font-weight: 600;
  color: var(--plum); background: #f8f5fc; border: 1px solid #d8cbe9;
  border-radius: 6px; padding: .06rem .56rem; text-decoration: none;
}
.blend-dl:hover { background: var(--purple-wash); }
.goal {
  background: var(--goal-bg); border-inline-start: 3px solid var(--goal-border);
  border-radius: 4px 8px 8px 4px; padding: .62rem .95rem; margin: 0 0 .9rem; max-width: 82ch;
}
.goal strong { color: var(--orange); }
.prompt {
  background: var(--purple-wash); border-inline-start: 3px solid #785aa8;
  border-radius: 4px 8px 8px 4px; padding: .8rem 1rem; margin: 1em 0;
}
.prompt-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: .25rem .7rem; flex-wrap: wrap; margin-bottom: .35rem;
}
.prompt strong { color: var(--plum); }
.prompt p { margin: 0; user-select: text; max-width: 82ch; }
.copy-status { font-size: .84rem; color: var(--muted); }
button { font: inherit; cursor: pointer; }
.copy, .close {
  color: var(--plum); background: var(--paper); border: 1px solid #c7b5de;
  border-radius: 6px; padding: .12rem .65rem; font-size: .87rem;
}
.copy:hover, .close:hover { background: #e9dff6; }
.verify {
  background: var(--check-bg); border-radius: 8px;
  padding: .72rem .95rem; margin: .9rem 0 .6rem; max-width: 82ch;
}
.check { font-weight: 700; color: var(--check-ink); margin-right: .35em; }
details { color: var(--muted); margin: .55rem 0; }
summary { width: fit-content; cursor: pointer; color: var(--plum); font-weight: 550; }
details p { margin: .45rem 0 .6rem 1rem; max-width: 78ch; color: var(--ink); }

.evidence { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 1.15rem; }
.evidence figure { margin: 0; }
.evidence figure.wide { grid-column: 1 / -1; }
.evidence button {
  display: block; width: 100%; padding: 0; margin: 0;
  background: #171923; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.evidence button:hover { outline: 3px solid #9f87be; outline-offset: 2px; }
.evidence img { display: block; width: 100%; height: auto; }
figcaption { font-size: .88rem; line-height: 1.55; margin-top: .45rem; color: var(--muted); }

.notes {
  margin: 1.3rem 0 0; padding: 1rem 1.2rem; background: var(--note-bg);
  border: 1px solid var(--line); border-radius: 10px;
}
.notes dt { font-weight: 700; color: var(--ink); margin-top: .55rem; }
.notes dt:first-child { margin-top: 0; }
.notes dd { margin: .2rem 0 0; color: var(--muted); }
.notes strong { color: var(--ink); }
.notes p:last-child { margin-bottom: 0; }

.files {
  margin: 1.2rem 0 0; padding: 1rem 1.2rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px;
}
.files ul { margin: .4rem 0 0; padding-left: 1.35rem; }
.files li { margin-bottom: .25rem; }

/* === Contextual Internal Links Callout === */
.related-links {
  margin: 1.2rem 0 0;
  padding: .95rem 1.2rem;
  background: #f7f4fc;
  border: 1px solid #d9cce9;
  border-inline-start: 4px solid var(--plum);
  border-radius: 8px 10px 10px 8px;
}
.related-links strong {
  display: block;
  color: var(--plum);
  font-size: .92rem;
  margin-bottom: .35rem;
}
.related-links ul {
  margin: 0;
  padding-left: 1.25rem;
}
.related-links li {
  margin-bottom: .25rem;
  font-size: .93rem;
}
.related-links li:last-child { margin-bottom: 0; }
.related-links a { font-weight: 600; }

code, .manual-practice kbd {
  font-size: .88rem; overflow-wrap: anywhere; background: #efe9dd;
  padding: .08em .35em; border-radius: 4px;
}

.captioned-frames figcaption strong {
  display: block;
  color: var(--ink);
  margin-bottom: .15rem;
}

/* === 7-Part Series Layout & Hub Enhancements === */
.ep-pill {
  display: inline-block; font-weight: 750; font-size: .82rem; letter-spacing: .03em;
  color: var(--orange); background: var(--goal-bg); border: 1px solid #ecc6aa;
  border-radius: 999px; padding: .12rem .68rem; vertical-align: middle;
}
.part-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.stat-chip {
  font-size: .85rem; font-weight: 600; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: .18rem .72rem;
}
.stat-chip.accent {
  color: var(--plum); background: var(--purple-wash); border-color: #d2c2e8;
}
.part-toc-bar {
  margin-top: 20px; padding: 14px 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
}
.part-toc-label {
  font-size: .86rem; font-weight: 700; color: var(--muted); margin: 0 0 8px;
}
.quick-index { display: flex; flex-wrap: wrap; gap: 7px; }
.quick-index a {
  display: inline-flex; align-items: center; gap: 5px;
  padding: .28rem .68rem; font-size: .88rem; font-weight: 600;
  border-radius: 6px; border: 1px solid #dcd3e9; background: var(--paper); text-decoration: none;
}
.quick-index a:hover { background: var(--purple-wash); border-color: #a587d0; }
.quick-index .toc-code { color: var(--orange); font-weight: 750; }

.lesson-block {
  padding: 34px 0 36px; border-bottom: 2px solid var(--line); scroll-margin-top: 76px;
}
.lesson-block:last-of-type { border-bottom: none; }
.lesson-head {
  background: linear-gradient(180deg, #fffdf9 0%, #f8f3ea 100%);
  border: 1px solid var(--line); border-left: 4px solid var(--plum);
  border-radius: 12px; padding: clamp(16px, 2.5vw, 24px); margin-bottom: 20px;
}
.lesson-head-top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 14px; margin-bottom: 6px;
}
.lesson-head h2 {
  font-size: clamp(1.38rem, 2.6vw, 1.88rem); margin: 4px 0 8px; color: var(--ink);
}
.lesson-head .lede { margin-bottom: 10px; }

.part-switcher {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line);
}
.part-switcher a, .part-switcher .switch-placeholder {
  display: flex; flex-direction: column; justify-content: center;
  padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--paper); text-decoration: none; min-height: 78px;
}
.part-switcher a:hover { border-color: #a587d0; background: var(--purple-wash); }
.part-switcher a.sw-cta {
  background: var(--plum); border-color: var(--plum); color: #fff;
}
.part-switcher a.sw-cta .sw-label { color: #e2d7f4; }
.part-switcher a.sw-cta .sw-title { color: #fff; }
.part-switcher a.sw-cta:hover { background: #5a4287; }
.part-switcher .sw-label { font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.part-switcher .sw-title { font-weight: 700; font-size: .95rem; color: var(--plum); }
.part-switcher .sw-center { text-align: center; align-items: center; }
.part-switcher .sw-next { text-align: right; align-items: flex-end; }
.part-switcher .switch-placeholder { opacity: .55; color: var(--muted); font-size: .9rem; }

/* === Series Hub Styles === */
.milestone-strip {
  margin: 26px 0 10px; padding: 18px 20px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
}
.milestone-strip h2 { font-size: 1.16rem; color: var(--plum); margin-bottom: 12px; }
.milestone-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px;
}
.milestone-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; font-size: .86rem; text-decoration: none; color: inherit;
  display: block; transition: border-color .15s ease;
}
.milestone-item:hover { border-color: #b79fd8; }
.milestone-item strong { display: block; color: var(--orange); font-size: .84rem; margin-bottom: 3px; }
.milestone-item b { display: block; color: var(--ink); font-size: .92rem; margin-bottom: 4px; }
.milestone-item span { color: var(--muted); font-size: .82rem; }

.part-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px;
  margin-top: 16px;
}
.part-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  transition: border-color .15s ease, transform .15s ease;
}
.part-card:hover { border-color: #b79fd8; transform: translateY(-1px); }
.part-card.featured { grid-column: 1 / -1; display: grid; grid-template-columns: 1.05fr 1.25fr; }
.part-card-media {
  position: relative; background: #171923; aspect-ratio: 16 / 9; overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.part-card.featured .part-card-media {
  aspect-ratio: auto; height: 100%; border-bottom: 0; border-right: 1px solid var(--line);
}
.part-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.part-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.part-card-top { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-bottom: 8px; }
.tag {
  font-size: .78rem; padding: .12rem .52rem; border-radius: 999px;
  background: #f3ede2; color: var(--muted); white-space: nowrap;
}
.tag.ext { background: var(--goal-bg); color: var(--orange); font-weight: 600; }
.part-card h3 { font-size: 1.18rem; margin: 2px 0 4px; line-height: 1.35; }
.part-card h3 a { text-decoration: none; color: var(--ink); }
.part-card h3 a:hover { color: var(--plum); }
.part-card .card-subtitle {
  font-size: .9rem; font-weight: 600; color: var(--plum); margin: 0 0 8px;
}
.part-card p.desc { font-size: .92rem; color: var(--muted); margin-bottom: 12px; flex: 1; }
.part-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.part-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-read {
  display: inline-block; font-size: .9rem; font-weight: 650;
  background: var(--plum); color: #fff; border: 1px solid var(--plum);
  border-radius: 8px; padding: .42rem .92rem; text-decoration: none;
}
.btn-read:hover { background: #5a4287; color: #fff; }
.btn-secondary {
  display: inline-block; font-size: .88rem; font-weight: 600;
  background: var(--paper); color: var(--plum); border: 1px solid #d2c2e8;
  border-radius: 8px; padding: .4rem .82rem; text-decoration: none;
}
.btn-secondary:hover { background: var(--purple-wash); color: var(--plum); }

.single-index-sec { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.single-group {
  margin: 12px 0; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 16px;
}
.single-group summary { font-weight: 700; color: var(--ink); width: 100%; padding: 2px 0; }
.single-group summary span { color: var(--muted); font-weight: 500; font-size: .9rem; margin-left: 8px; }
.single-list {
  list-style: none; margin: 12px 0 4px; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px;
}
.single-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 7px; background: var(--surface); border: 1px solid var(--line);
  font-size: .9rem;
}
.single-list li a { text-decoration: none; display: flex; gap: 8px; align-items: baseline; width: 100%; }
.single-list li a:hover .s-title { text-decoration: underline; }
.single-list .s-code { font-weight: 750; color: var(--orange); flex-shrink: 0; }
.single-list .s-title { color: var(--ink); }

/* === Footer === */
footer.site-footer {
  color: var(--muted);
  font-size: .9rem;
  padding: 28px 0 44px;
  margin-top: 34px;
  border-top: 1px solid var(--line);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 10px 0 14px;
}
.bottom-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.bottom-nav a {
  display: inline-block; font-size: .9rem; border: 1px solid #dcd3e9;
  border-radius: 8px; padding: .32rem .75rem; background: var(--paper); text-decoration: none;
}
.bottom-nav a:hover { background: var(--purple-wash); border-color: #a587d0; }

/* === Lightbox === */
dialog {
  width: min(96vw, 1700px); max-width: none; padding: .7rem;
  border: 0; border-radius: 10px; background: #1b1820; color: #fff;
}
dialog::backdrop { background: #14111ade; }
.dialog-top {
  display: flex; justify-content: space-between; gap: 12px;
  align-items: center; padding-bottom: .55rem; font-size: .93rem;
}
dialog img { display: block; width: auto; height: auto; max-width: 100%; max-height: 83vh; margin: 0 auto; border-radius: 6px; }

@media (max-width: 900px) {
  .milestone-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .part-grid { grid-template-columns: 1fr; }
  .part-card.featured { grid-template-columns: 1fr; }
  .part-card.featured .part-card-media { aspect-ratio: 16 / 9; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .site-topbar-inner, header.page-header, main, footer.site-footer { width: calc(100% - 28px); }
  header.page-header { padding-top: 20px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  h1, h2, h3 { overflow-wrap: anywhere; }
  .evidence { grid-template-columns: 1fr; gap: 11px; }
  .milestone-grid { grid-template-columns: 1fr; }
  .part-switcher { grid-template-columns: 1fr; }
  .part-switcher .sw-next { text-align: left; align-items: flex-start; }
  .single-list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  body { background: #fff; color: #111; }
  .site-topbar, .copy, dialog { display: none !important; }
  .step, .overview, .video-card, .files, .related-links { break-inside: avoid; }
}
