.mg-directory,
.mg-reader,
.mg-bridge {
  --mg-ink: #1b2420;
  --mg-muted: #5c6862;
  --mg-line: #dce2de;
  --mg-line-strong: #c3cec8;
  --mg-accent: #25634d;
  --mg-accent-soft: #e7f2ed;
  --mg-paper: #ffffff;
  --mg-surface: #f4f6f5;
  color: var(--mg-ink);
  font-family: inherit;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

/* Directory Layout */
.mg-directory {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 0 48px;
}

.mg-directory > header {
  margin-bottom: 14px;
}

.mg-directory h1,
.mg-reader h1 {
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.3;
  letter-spacing: -0.035em;
  margin: 6px 0 8px;
  text-wrap: balance;
}

.mg-directory header > p,
.mg-dek {
  max-width: 740px;
  margin: 0;
  color: var(--mg-muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.mg-meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--mg-muted);
  line-height: 1.5;
  margin: 0;
}

/* Sticky Dashboard Filter Bar */
.mg-filters {
  position: sticky;
  top: calc(var(--mg-header-height, 64px) + 6px);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 14px;
  background: var(--mg-paper);
  border: 1px solid var(--mg-line-strong);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.mg-filters label {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--mg-muted);
}

.mg-filters label:first-child {
  flex: 1 1 220px;
}

.mg-filters select[name="path"] {
  max-width: 220px;
}

.mg-filters input,
.mg-filters select,
.mg-filters button {
  min-height: 38px;
  border: 1px solid var(--mg-line-strong);
  border-radius: 7px;
  background: var(--mg-surface);
  color: var(--mg-ink);
  font: inherit;
  font-size: 13.5px;
  padding: 6px 10px;
  max-width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mg-filters input:focus,
.mg-filters select:focus {
  background: var(--mg-paper);
  border-color: var(--mg-accent);
  outline: none;
}

.mg-filters input {
  width: 100%;
}

.mg-filters button {
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
  background: var(--mg-paper);
}

.mg-filters button:hover {
  border-color: var(--mg-accent);
  color: var(--mg-accent);
}

/* Collapsible Reading Paths & Track Drawer */
.mg-directory-help {
  margin: 12px 0;
  border: 1px solid var(--mg-line);
  border-radius: 10px;
  background: var(--mg-paper);
}

.mg-directory-help > summary {
  min-height: 40px;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--mg-ink);
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mg-directory-help > .mg-track,
.mg-directory-help > .mg-paths {
  margin: 12px 14px 14px;
}

.mg-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.mg-track a {
  padding: 10px 12px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  font-weight: 650;
  font-size: 13px;
  line-height: 1.4;
  color: var(--mg-ink);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mg-track a:hover {
  border-color: var(--mg-accent);
  background: var(--mg-accent-soft);
}

.mg-track span {
  display: block;
  margin-bottom: 2px;
  color: var(--mg-accent);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* Curriculum Jump Bar & Section Groups */
.mg-section-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 6px;
}

.mg-section-jump a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--mg-paper);
  border: 1px solid var(--mg-line);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--mg-ink);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mg-section-jump a:hover {
  border-color: var(--mg-accent);
  background: var(--mg-accent-soft);
  color: var(--mg-accent);
}

.mg-section-jump a span {
  font-size: 11px;
  font-weight: 600;
  color: var(--mg-muted);
}

/* Directory Results & Consolidated Series Cards */
.mg-results {
  color: var(--mg-muted);
  font-size: 12.5px;
  font-weight: 600;
  margin: 12px 0 14px;
}

.mg-sections {
  display: grid;
  gap: 32px;
}

.mg-section-group {
  scroll-margin-top: calc(var(--mg-header-height, 64px) + 70px);
}

.mg-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--mg-line-strong);
}

.mg-section-header h2 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0;
}

.mg-section-header span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mg-muted);
}

.mg-series-list {
  display: grid;
  gap: 16px;
}

.mg-series-card {
  background: var(--mg-surface);
  border: 1px solid var(--mg-line-strong);
  border-radius: 12px;
  padding: 18px;
  scroll-margin-top: calc(var(--mg-header-height, 64px) + 70px);
}

.mg-series-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--mg-line);
}

.mg-series-card__info {
  min-width: 0;
  flex: 1;
}

.mg-series-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--mg-accent-soft);
  color: var(--mg-accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.mg-series-card__info h3 {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}

.mg-series-card__info h3 a {
  color: var(--mg-ink);
  text-decoration: none;
}

.mg-series-card__info h3 a:hover {
  color: var(--mg-accent);
}

.mg-series-card__info p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--mg-muted);
}

.mg-series-start {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 7px 13px;
  border-radius: 8px;
  background: var(--mg-paper);
  border: 1px solid var(--mg-line-strong);
  color: var(--mg-accent);
  font-size: 12.5px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mg-series-start:hover {
  border-color: var(--mg-accent);
  background: var(--mg-accent-soft);
}

.mg-series-chapters,
.mg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mg-series-chapters.is-roster {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mg-series-chapters > div,
.mg-grid > div {
  min-width: 0;
}

.mg-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  border: 1px solid var(--mg-line);
  border-radius: 9px;
  color: var(--mg-ink);
  background: var(--mg-paper);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mg-card:hover {
  border-color: var(--mg-accent);
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.06);
}

.mg-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.mg-chapter-num {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  color: var(--mg-accent);
  font-size: 11px;
  font-weight: 800;
}

.mg-card h3 {
  font-size: 14.5px;
  font-weight: 750;
  line-height: 1.4;
  margin: 2px 0 5px;
  letter-spacing: -0.02em;
}

.mg-card p {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--mg-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Article Reader Layout */
.mg-reader {
  display: grid;
  grid-template-columns: minmax(0, 780px) minmax(175px, 215px);
  gap: 28px;
  justify-content: center;
  max-width: 1080px;
  margin: 16px auto 56px;
}

.mg-article {
  min-width: 0;
}

/* Main Article Paper (Focused Content Container) */
.mg-paper {
  background: var(--mg-paper);
  border: 1px solid var(--mg-line-strong);
  border-radius: 12px;
  padding: 26px 30px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.03);
}

.mg-article-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--mg-line);
}

.mg-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
}

.mg-back-link {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--mg-accent);
  text-decoration: none;
}

.mg-back-link:hover {
  border-color: var(--mg-accent);
  background: var(--mg-accent-soft);
}

/* Integrated Series Chapter Switcher (In-Page Tabs) */
.mg-series-nav {
  margin: 16px 0 22px;
  padding: 12px 14px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line-strong);
  border-radius: 10px;
}

.mg-series-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 10px;
}

.mg-series-nav__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.mg-series-count {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--mg-muted);
}

.mg-series-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mg-series-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--mg-paper);
  border: 1px solid var(--mg-line);
  color: var(--mg-ink);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mg-series-tab:hover {
  border-color: var(--mg-accent);
}

.mg-series-tab.is-active {
  background: var(--mg-accent);
  border-color: var(--mg-accent);
  color: #ffffff;
  font-weight: 750;
}

.mg-series-tab__num {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.75;
}

.mg-series-tab.is-active .mg-series-tab__num {
  opacity: 0.95;
}

/* Series Prev/Next Chapter Pager inside Paper */
.mg-series-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--mg-line);
}

.mg-series-pager__link {
  display: grid;
  gap: 3px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--mg-line-strong);
  background: var(--mg-surface);
  color: var(--mg-ink);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mg-series-pager__link.is-next {
  text-align: right;
}

.mg-series-pager__link:hover {
  border-color: var(--mg-accent);
  background: var(--mg-accent-soft);
}

.mg-series-pager__link small {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--mg-accent);
}

.mg-series-pager__link strong {
  font-size: 13.5px;
  line-height: 1.4;
}

/* Inline Reading Path Bar */
.mg-reading {
  margin: 18px 0 0;
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--mg-paper);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
}

.mg-reading label {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--mg-muted);
}

.mg-reading select {
  min-height: 32px;
  max-width: 100%;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 8px;
  border: 1px solid var(--mg-line-strong);
  border-radius: 6px;
  background: var(--mg-surface);
  color: var(--mg-ink);
}

.mg-reading .mg-journey {
  flex: 1 1 260px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}

.mg-reading .mg-meta {
  margin: 0;
  font-size: 12px;
  color: var(--mg-accent);
  font-weight: 700;
}

.mg-reading details {
  width: 100%;
}

.mg-reading summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--mg-muted);
}

.mg-reading details > p {
  font-size: 12.5px;
  color: var(--mg-muted);
  margin: 6px 0;
}

/* Article Body Typography & Tables */
.mg-body {
  font-size: 15.2px;
  line-height: 1.82;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.mg-body h2 {
  scroll-margin-top: 24px;
  font-size: 18.5px;
  font-weight: 780;
  line-height: 1.4;
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--mg-line);
  letter-spacing: -0.02em;
}

.mg-body > h2:first-child,
.mg-body > .mg-legacy-anchor + h2 {
  margin-top: 12px;
}

.mg-body p {
  margin: 12px 0;
}

.mg-body ul {
  padding-left: 20px;
  margin: 12px 0;
}

.mg-body li {
  padding-left: 2px;
  margin: 8px 0;
}

.mg-body li > ul {
  margin: 6px 0;
}

.mg-body strong {
  font-weight: 700;
}

.mg-value {
  background: var(--mg-accent-soft);
  color: var(--mg-accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.94em;
}

.mg-body a,
.mg-summary a {
  color: var(--mg-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mg-body code,
.mg-summary code {
  font-size: 0.88em;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: normal;
}

.mg-body pre {
  max-width: 100%;
  overflow: auto;
  padding: 14px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: 8px;
}

.mg-body pre code {
  white-space: pre;
  padding: 0;
  border: 0;
}

.mg-body kbd,
.mg-summary kbd {
  display: inline-block;
  border: 1px solid var(--mg-line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font: inherit;
  font-size: 0.84em;
  background: var(--mg-paper);
}

.mg-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  overscroll-behavior-x: contain;
}

.mg-body table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 520px;
  font-size: 13.5px;
  line-height: 1.6;
}

.mg-body td,
.mg-body th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--mg-line);
  text-align: left;
  vertical-align: top;
  min-width: 130px;
}

.mg-body thead th {
  background: var(--mg-surface);
  font-weight: 700;
  font-size: 12.5px;
}

.mg-body th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--mg-surface);
  min-width: 115px;
  max-width: 200px;
  box-shadow: 1px 0 var(--mg-line);
}

.mg-body tr:last-child > * {
  border-bottom: 0;
}

/* Sticky Right TOC & Mobile TOC Pill */
.mg-toc {
  position: sticky;
  top: calc(var(--mg-header-height, 64px) + 16px);
  align-self: start;
  max-height: calc(100dvh - var(--mg-header-height, 64px) - 32px);
  overflow: auto;
  border-left: 1px solid var(--mg-line);
  padding-left: 16px;
  font-size: 12px;
}

.mg-toc nav,
.mg-mobile-toc nav {
  display: grid;
  gap: 8px;
}

.mg-toc a {
  color: var(--mg-muted);
  text-decoration: none;
  line-height: 1.45;
  transition: color 0.15s ease;
}

.mg-toc a:hover {
  color: var(--mg-ink);
}

.mg-toc a[aria-current] {
  color: var(--mg-accent);
  font-weight: 750;
}

.mg-toc strong {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mg-muted);
  margin-bottom: 4px;
}

.mg-mobile-toc {
  display: none;
}

/* Separated Article Footer (Recommendations, Encyclopedia & Paths) */
.mg-article-footer {
  margin-top: 28px;
  padding: 22px 26px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line-strong);
  border-radius: 12px;
}

.mg-footer-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.mg-footer-divider span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mg-accent);
  background: var(--mg-accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.mg-footer-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--mg-line-strong);
}

.mg-guide-connections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.mg-guide-connections .mg-references {
  margin: 0;
  background: var(--mg-paper);
}

.mg-bridge {
  margin: 20px 0;
  padding: 14px 16px;
  border: 1px solid var(--mg-line);
  border-radius: 10px;
  background: var(--mg-surface);
}

.mg-bridge h2,
.mg-references h2,
.mg-destinations h2,
.mg-related h2 {
  font-size: 14.5px;
  font-weight: 750;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.mg-bridge summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 13px;
  padding: 6px 0;
}

.mg-bridge .mg-body {
  font-size: 13.5px;
}

.mg-bridge .mg-body h3 {
  font-size: 15px;
  line-height: 1.5;
  margin: 16px 0 8px;
}

.mg-read-link {
  display: inline-block;
  padding: 6px 0;
  font-weight: 700;
  font-size: 13px;
}

.mg-reference-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.mg-reference-list li {
  margin: 0;
  min-width: 0;
}

.mg-reference-list a {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  border: 1px solid var(--mg-line);
  border-radius: 7px;
  text-decoration: none;
  color: var(--mg-ink);
  background: var(--mg-paper);
  line-height: 1.45;
  transition: border-color 0.15s ease;
}

.mg-reference-list a:hover {
  border-color: var(--mg-accent);
}

.mg-reference-list strong {
  font-size: 13.5px;
}

.mg-reference-list small {
  font-size: 11.5px;
  color: var(--mg-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mg-reference-list .mg-meta:empty {
  display: none;
}

.mg-references > details {
  margin-top: 8px;
}

.mg-references > details > summary,
.mg-more-entities > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--mg-muted);
  padding: 6px 0;
}

.mg-related,
.mg-destinations {
  margin-top: 18px;
}

.mg-footer-divider + .mg-related,
.mg-footer-divider + .mg-destinations {
  margin-top: 0;
}

.mg-more-entities {
  margin-top: 8px;
}

.mg-related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mg-related-grid a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  background: var(--mg-paper);
  color: var(--mg-ink);
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.mg-related-grid a:hover {
  border-color: var(--mg-accent);
}

.mg-related-grid img {
  object-fit: contain;
  flex: none;
  width: 32px;
  height: 32px;
}

.mg-related-grid strong {
  font-size: 13.5px;
  line-height: 1.35;
}

.mg-related-grid small {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--mg-muted);
  margin-top: 2px;
}

.mg-next {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mg-next > div > p {
  font-size: 12px;
  color: var(--mg-muted);
}

.mg-next .mg-card {
  height: auto;
}

.mg-path-nav > a {
  display: grid;
  gap: 3px;
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  padding: 11px 14px;
  color: var(--mg-ink);
  text-decoration: none;
  background: var(--mg-paper);
  transition: border-color 0.15s ease;
}

.mg-path-nav > a:hover {
  border-color: var(--mg-accent);
}

.mg-path-nav strong {
  font-size: 13.5px;
  line-height: 1.45;
}

.mg-path-nav small {
  font-size: 11.5px;
  color: var(--mg-muted);
}

/* Reading Paths Grid */
.mg-paths {
  margin: 16px 0 0;
}

.mg-path-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.mg-path-heading h2 {
  font-size: 16px;
  margin: 0;
}

.mg-path-heading > a {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mg-accent);
}

.mg-paths > p {
  font-size: 13px;
  color: var(--mg-muted);
  margin: 4px 0 10px;
}

.mg-path-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.mg-path-grid > details {
  border: 1px solid var(--mg-line);
  border-radius: 8px;
  background: var(--mg-surface);
  padding: 0 12px;
  min-width: 0;
  scroll-margin-top: 90px;
}

.mg-path-grid summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 13.5px;
}

.mg-path-grid summary span {
  font-size: 11.5px;
  color: var(--mg-muted);
  margin-left: 8px;
  white-space: nowrap;
}

.mg-path-grid details > p {
  font-size: 12.5px;
  color: var(--mg-muted);
  margin: 0 0 10px;
}

.mg-path-steps {
  list-style: none;
  padding: 0;
  margin: 10px 0 14px;
  display: grid;
  gap: 8px;
}

.mg-path-steps li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.5;
}

.mg-path-steps li > span {
  border: 1px solid var(--mg-line);
  border-radius: 50%;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--mg-paper);
}

.mg-path-steps a {
  color: var(--mg-ink);
  text-decoration: none;
}

.mg-path-steps a:hover {
  text-decoration: underline;
}

.mg-path-steps small {
  display: block;
  color: var(--mg-accent);
  font-size: 11px;
}

.mg-path-steps li[aria-current] {
  font-weight: 750;
}

.mg-path-steps li[aria-current] > span {
  background: var(--mg-accent);
  color: #fff;
  border-color: var(--mg-accent);
}

.mg-journey[hidden],
.mg-path-nav[hidden],
.mg-directory [hidden] {
  display: none !important;
}

/* Inline Term Links */
.mg-term {
  display: inline-flex;
  align-items: baseline;
  max-width: 100%;
  gap: 0.2em;
  vertical-align: baseline;
}

.mg-term-label {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.mg-term-icon {
  display: inline-block;
  flex: none;
  object-fit: contain;
  vertical-align: -0.22em;
  margin-right: 0;
  border-radius: 50%;
  background: #34534b;
  padding: 1px;
  box-sizing: border-box;
}

.mg-term:focus-visible {
  outline: 2px solid var(--mg-accent);
  outline-offset: 2px;
}

/* Legacy Preview & Search Dropdowns */
.mg-preview {
  position: fixed;
  z-index: 1000;
  width: 310px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--mg-line-strong);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.15);
  pointer-events: auto;
  color: var(--mg-ink);
  font: 13.5px/1.6 system-ui, sans-serif;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}

.mg-preview__heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mg-preview__heading strong {
  display: block;
  flex: 1;
  min-width: 0;
}

.mg-preview__heading img {
  display: block;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  margin: 0;
  object-fit: contain;
}

.mg-preview p {
  margin: 8px 0 0;
}

/* Unified Site Family Top Strip */
.mg-family {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 6px 0;
  font-size: 11.5px;
  color: var(--mg-muted);
}

.mg-family a {
  color: inherit;
  text-decoration: none;
}

.mg-family a:hover {
  text-decoration: underline;
}

.site-header .mg-family.header-inner {
  display: flex;
  flex-wrap: wrap;
  color: #c8d4c5;
  line-height: 1.4;
  min-height: 0;
  padding-top: 4px;
  padding-bottom: 4px;
  justify-content: flex-start;
  gap: 16px;
  font-size: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.workspace > .mg-family {
  padding: 5px 28px;
  border-bottom: 1px solid var(--mg-line, #dce2de);
  gap: 2px 18px;
}

.workspace > .mg-family a {
  padding: 3px 0;
}

.workspace > .mg-family a[aria-current] {
  font-weight: 700;
  color: var(--mg-accent);
}

.sidebar-foot a {
  display: block;
  padding: 4px 0;
}

.global-search,
.search-form,
.mg-quick-search {
  position: relative;
}

.mg-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  background: #ffffff;
  border: 1px solid var(--mg-line-strong);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  width: min(500px, 84vw);
  max-height: 65vh;
  overflow: auto;
}

.mg-search-dropdown[hidden],
.mg-search-results[hidden] {
  display: none;
}

.mg-search-dropdown h3,
.mg-search-results h3 {
  font-size: 12px;
  color: var(--mg-muted);
  margin: 8px 0 4px;
}

.mg-search-dropdown a,
.mg-search-results > a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--mg-ink);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.5;
}

.mg-search-dropdown a:hover,
.mg-search-dropdown a:focus {
  background: var(--mg-surface);
}

.mg-search-dropdown small,
.mg-search-results small {
  display: block;
  color: var(--mg-muted);
  font-size: 11.5px;
  white-space: normal;
}

.mg-search-results {
  margin: 18px 0;
  border: 1px solid var(--mg-line);
  border-radius: 10px;
  padding: 16px;
}

.mg-search-results > a {
  border-top: 1px solid var(--mg-line);
}

.mg-legacy-anchor {
  scroll-margin-top: 24px;
}

html:has([data-guide-reader], [data-guide-directory]) {
  scroll-padding-top: var(--mg-header-height, 64px);
}

/* Term Preview Popover (duplicated for standalone guide-reader.css consumers) */
.gnpc-term-preview {
  position: fixed;
  z-index: 10000;
  width: min(340px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  overflow: auto;
  box-sizing: border-box;
  padding: 14px 16px;
  background: #ffffff;
  color: #18221f;
  border: 1px solid #cfd8d3;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  font: 13.5px/1.55 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

.gnpc-preview-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid #e6ece8;
}

.gnpc-preview-heading img {
  flex: none;
  object-fit: contain;
  border-radius: 8px;
  background: #f2f5f3;
  padding: 2px;
}

.gnpc-preview-heading strong {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.gnpc-term-preview small {
  display: block;
  margin-top: 2px;
  color: #5c6b64;
  font-size: 12px;
}

.gnpc-term-preview dl {
  margin: 10px 0;
  display: grid;
  gap: 6px;
}

.gnpc-term-preview dl > div {
  display: grid;
  grid-template-columns: minmax(64px, auto) 1fr;
  gap: 10px;
  font-size: 12.5px;
}

.gnpc-term-preview dt {
  color: #63726b;
  font-weight: 600;
}

.gnpc-term-preview dd {
  margin: 0;
  color: #18221f;
  overflow-wrap: anywhere;
}

.gnpc-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e6ece8;
}

.gnpc-preview-actions a {
  color: #235c46;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}

.gnpc-preview-actions button {
  margin-left: auto;
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid #cfd8d3;
  border-radius: 6px;
  background: #f6f8f7;
  color: #36453f;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
}

.gnpc-term-preview :focus-visible {
  outline: 2px solid #235c46;
  outline-offset: 2px;
}

@media (max-width: 1200px) {
  .mg-series-chapters,
  .mg-series-chapters.is-roster,
  .mg-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mg-reader {
    gap: 24px;
    grid-template-columns: minmax(0, 740px) 170px;
  }
}

@media (max-width: 1023px) {
  .mg-reader {
    display: block;
    max-width: 780px;
  }
  .mg-toc {
    display: none;
  }
  .mg-mobile-toc {
    display: block;
    position: fixed;
    right: 16px;
    bottom: 18px;
    top: auto;
    z-index: 20;
    width: fit-content;
    max-width: calc(100vw - 32px);
    margin: 0;
    border: 1px solid var(--mg-line-strong);
    background: var(--mg-paper);
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
  }
  .mg-mobile-toc[open] {
    border-radius: 12px;
  }
  .mg-mobile-toc summary {
    cursor: pointer;
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 700;
  }
  .mg-mobile-toc nav {
    max-height: 50vh;
    overflow: auto;
    padding: 8px 14px 12px;
    font-size: 12.5px;
    max-width: 300px;
    border-top: 1px solid var(--mg-line);
  }
  .mg-mobile-toc a {
    color: var(--mg-ink);
    text-decoration: none;
  }
  .mg-track {
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    overflow: auto;
  }
  .mg-filters {
    position: static;
  }
  .mg-filters label:first-child {
    flex-basis: 100%;
  }
}

@media (max-width: 600px) {
  .mg-series-chapters,
  .mg-series-chapters.is-roster,
  .mg-grid,
  .mg-related-grid,
  .mg-next,
  .mg-series-pager,
  .mg-path-grid,
  .mg-guide-connections {
    grid-template-columns: minmax(0, 1fr);
  }
  .mg-series-card {
    padding: 14px;
  }
  .mg-series-card__head {
    flex-direction: column;
    align-items: flex-start;
  }
  .mg-paper {
    padding: 18px 16px;
  }
  .mg-article-footer {
    padding: 18px 16px;
  }
  .mg-series-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }
  .mg-series-tab {
    flex: none;
    white-space: nowrap;
  }
  .mg-series-pager__link.is-next {
    text-align: left;
  }
  .mg-card {
    padding: 12px 13px;
  }
  .mg-reader {
    margin: 12px auto 40px;
  }
  .mg-body {
    font-size: 14.5px;
  }
  .mg-body h2 {
    font-size: 17.5px;
  }
  .mg-filters {
    gap: 8px;
    padding: 10px 12px;
  }
  .mg-filters label:not(:first-child) {
    flex: 1 1 110px;
  }
  .mg-filters select,
  .mg-filters select[name="path"] {
    width: 100%;
    max-width: 100%;
  }
  .mg-body table {
    min-width: 480px;
  }
  .mg-body th:first-child {
    min-width: 90px;
    max-width: 125px;
  }
  .mg-body td,
  .mg-body th {
    padding: 8px 10px;
  }
  .mg-directory {
    padding-top: 8px;
  }
  .mg-path-nav > span:empty {
    display: none;
  }
  .workspace > .mg-family,
  .site-shell .site-header .mg-family.header-inner {
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
  }
  .workspace > .mg-family {
    padding-inline: 16px;
    padding-block: 4px;
  }
  .site-shell .site-header .mg-family.header-inner {
    display: flex;
    padding-block: 3px;
  }
  .mg-family > a {
    flex: none;
  }
}
