/* The site theme: one stylesheet for the home, post, category and core pages.
   Colours, type and spacing are tokens; no reader-visible word lives here (theme/labels/ has them). */
:root {
  /* palette roles */
  --accent: #147D78;
  --accent-soft: #D7EBE7;
  --ink: #1F2D36;
  --muted: #4A5A62;
  --panel: #EEF4F1;
  --base-light: #F3E5CE;
  --bg: #FFFFFF;
  --line: color-mix(in srgb, var(--ink) 11%, var(--bg));
  --line-strong: color-mix(in srgb, var(--ink) 20%, var(--bg));
  --faint: color-mix(in srgb, var(--muted) 72%, var(--bg));

  /* type scale 14/16/18/20/24/30/36 (+48 display for the home hero only) */
  --font: 'Noto Sans TC', 'Noto Sans', system-ui, sans-serif;
  --fs-14: .875rem; --fs-16: 1rem; --fs-18: 1.125rem; --fs-20: 1.25rem;
  --fs-24: 1.5rem; --fs-30: 1.875rem; --fs-36: 2.25rem; --fs-display: 3rem;
  --lh-body: 1.8; --lh-head: 1.4;

  /* spacing 4/8/12/16/24/32/48/64 */
  --s-4: 4px; --s-8: 8px; --s-12: 12px; --s-16: 16px; --s-24: 24px; --s-32: 32px; --s-48: 48px; --s-64: 64px;
  --r-4: 4px; --r-8: 8px; --r-12: 12px;

  --content: 680px;       /* contentSize */
  --wide: 1200px;         /* wideSize */
  --page: 1360px;         /* three-column article shell */
  --gutter: 32px;
  --header-h: 72px;
  --shadow-hover: 0 6px 20px color-mix(in srgb, var(--ink) 10%, transparent);
}

/* palettes (SITE_STYLE_CONFIG.palettes): :root above is classic; each other one replaces the palette roles */
[data-palette="teal"] { --accent: #0F6E68; --accent-soft: #DDEFEC; --ink: #1F2D36; --muted: #4A5A62; --panel: #F2F7F6; --base-light: #E4EFEC; --bg: #FFFFFF; }
[data-palette="ink"] { --accent: #18181B; --accent-soft: #EDEDEF; --ink: #18181B; --muted: #52525B; --panel: #F6F6F7; --base-light: #EAEAEC; --bg: #FFFFFF; }
[data-palette="slate"] { --accent: #2F5D8A; --accent-soft: #E3EBF3; --ink: #1C2430; --muted: #505B68; --panel: #F4F6F9; --base-light: #E6EBF1; --bg: #FFFFFF; }
[data-palette="sage"] { --accent: #3E6B5A; --accent-soft: #E2ECE7; --ink: #1F2623; --muted: #535E59; --panel: #F4F6F5; --base-light: #E5EBE8; --bg: #FFFFFF; }
[data-palette="clay"] { --accent: #9A4B2B; --accent-soft: #F4E6DE; --ink: #262220; --muted: #5A524D; --panel: #F8F5F2; --base-light: #EFE6DE; --bg: #FFFFFF; }
[data-palette="indigo"] { --accent: #4338CA; --accent-soft: #E7E6FB; --ink: #1E1B2E; --muted: #545068; --panel: #F6F6FB; --base-light: #E9E8F5; --bg: #FFFFFF; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + var(--s-24)); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: var(--fs-16); line-height: 1.7;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: var(--lh-head); margin: 0; font-weight: 800; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--r-4); }

.wrap { width: min(100% - 2 * var(--gutter), var(--wide)); margin-inline: auto; }
.tpl-post .header-inner, .tpl-post .footer-grid, .tpl-post .footer-bottom { width: min(100% - 2 * var(--gutter), var(--page)); }
.wrap-narrow { width: min(100% - 2 * var(--gutter), var(--content)); margin-inline: auto; }

/* ---------- shared bits ---------- */
.text-link { color: var(--accent); font-weight: 700; font-size: var(--fs-16); display: inline-flex; gap: var(--s-8); align-items: center; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-link--arrow::after { content: ""; width: 7px; height: 7px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; }
.text-link--arrow:hover::after { transform: translateX(3px) rotate(45deg); }
.badge { display: inline-block; background: var(--accent); color: #fff; font-size: var(--fs-14); font-weight: 700; line-height: 1; padding: 6px 10px; border-radius: var(--r-4); letter-spacing: .02em; }
.btn { display: inline-flex; align-items: center; min-height: 48px; padding: 0 var(--s-24); border-radius: var(--r-8); font-weight: 700; font-size: var(--fs-16); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-8); }
.chip { display: inline-flex; align-items: center; gap: var(--s-8); padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-14); color: var(--muted); background: var(--bg); line-height: 1.4; transition: border-color .15s, color .15s; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 700; }
.chip-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chip.is-active .chip-count { color: var(--accent); }
.avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--panel); color: var(--accent); font-weight: 800; font-size: var(--fs-18); border: 1px solid var(--line); }
.tree-thumb { display: block; }
.avatar--mark svg { width: 70%; height: 70%; }

.crumbs ol { display: flex; flex-wrap: wrap; gap: var(--s-4) 0; font-size: var(--fs-14); color: var(--muted); }
.crumbs li:not(:last-child)::after { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 10px 2px 8px; border-top: 1.5px solid var(--faint); border-right: 1.5px solid var(--faint); transform: rotate(45deg); }
.crumbs a:hover { color: var(--accent); }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: var(--s-32); }
.brand { flex: none; display: block; }
.brand .logo { height: 40px; width: auto; }
.site-nav { margin-left: auto; min-width: 0; }
.site-nav ul { display: flex; gap: var(--s-4); }
.site-nav a { display: block; padding: var(--s-8) var(--s-12); border-radius: var(--r-8); font-size: var(--fs-16); font-weight: 500; color: var(--muted); white-space: nowrap; max-width: 15em; overflow: hidden; text-overflow: ellipsis; }
.site-nav a:hover { color: var(--ink); background: var(--panel); }
.site-nav a[aria-current] { color: var(--accent); font-weight: 700; }
.nav-toggle { display: none; margin-left: auto; align-items: center; gap: var(--s-8); background: none; border: 1px solid var(--line); border-radius: var(--r-8); padding: var(--s-8) var(--s-12); font-size: var(--fs-14); font-weight: 700; cursor: pointer; }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 2px; position: relative; transition: transform .2s, background .2s; }
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -5px; } .nav-toggle-bars::after { top: 5px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: translateY(5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after { transform: translateY(-5px) rotate(-45deg); }
.read-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.read-progress span { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- footer ---------- */
.site-footer { margin-top: var(--s-64); border-top: 1px solid var(--line); background: var(--bg); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1.2fr); gap: var(--s-48); padding: var(--s-64) 0 var(--s-48); }
.footer-brand .logo { height: 36px; width: auto; }
.footer-brand p { margin-top: var(--s-16); color: var(--muted); font-size: var(--fs-14); line-height: 1.8; max-width: 30em; }
.footer-title { font-size: var(--fs-14); font-weight: 700; color: var(--ink); margin-bottom: var(--s-12); }
.footer-title-gap { margin-top: var(--s-24); }
.footer-col li + li { margin-top: var(--s-8); }
.footer-col a { font-size: var(--fs-14); color: var(--muted); }
.footer-col a:hover { color: var(--accent); }
.footer-mail { font-size: var(--fs-14); color: var(--accent) !important; word-break: break-all; }
.footer-bottom { display: flex; justify-content: space-between; gap: var(--s-16); padding: var(--s-24) 0; border-top: 1px solid var(--line); font-size: var(--fs-14); color: var(--faint); }
.footer-bottom a:hover { color: var(--accent); }

/* ---------- cards ---------- */
.card { display: flex; flex-direction: column; gap: var(--s-16); min-width: 0; }
.card-media { display: block; aspect-ratio: 16 / 9; border-radius: var(--r-12); overflow: hidden; background: var(--panel); border: 1px solid var(--line); transition: box-shadow .2s; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card:hover .card-media { box-shadow: var(--shadow-hover); }
.card:hover .card-media img { transform: scale(1.03); }
.card-body { display: flex; flex-direction: column; gap: var(--s-8); min-width: 0; }
.card-cat { font-size: var(--fs-14); font-weight: 700; color: var(--accent); width: fit-content; }
.card-cat:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-title { font-size: var(--fs-20); font-weight: 700; line-height: var(--lh-head); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a:hover { color: var(--accent); }
.card-excerpt { font-size: var(--fs-16); color: var(--muted); line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; gap: var(--s-8); font-size: var(--fs-14); color: var(--faint); }

.card-grid--grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-48) var(--s-32); }
.card-grid--list { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: var(--s-32) var(--s-48); }
.card-grid--list .card { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--s-24); align-items: center; }
.card-grid--list .card:only-child { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--s-48); }
.card-grid--list .card-title { font-size: var(--fs-20); }
.card-grid--list .card:only-child .card-title { font-size: var(--fs-24); }
.card-grid--list .card-excerpt { -webkit-line-clamp: 3; }

/* ---------- sections ---------- */
.section { padding: var(--s-64) 0 0; }
.section--tight { padding-top: var(--s-48); }
.section-head { margin-bottom: var(--s-32); }
.section-head--split { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-24); padding-bottom: var(--s-16); border-bottom: 1px solid var(--line); }
.section-kicker { font-size: var(--fs-14); font-weight: 700; color: var(--faint); margin-bottom: var(--s-4); }
.section-title { font-size: var(--fs-30); }
.section-title a:hover { color: var(--accent); }
.section-title--sm { font-size: var(--fs-20); }

/* ---------- home ---------- */
/* Home carousel: every slide is in the HTML as a real link (crawlable without JS); CSS scroll-snap moves it,
   the dots are anchors, theme.js only adds the buttons, the active dot and a pausable autoplay.
   Two looks, set by the wrapper: .cv = cover (image fills the slide, text over it), .cd = card (image above text). */
.carousel { position: relative; }
.carousel-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; border-radius: 16px; }
.carousel-track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: start; min-width: 0; }
.slide-link { position: relative; display: block; height: 100%; color: inherit; }
.slide-media { display: block; overflow: hidden; background: var(--panel); }
.slide-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.slide-link:hover .slide-media img { transform: scale(1.03); }
.slide-body { display: flex; flex-direction: column; gap: var(--s-12); }
.slide-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-12); }
.slide-cat { font-size: var(--fs-14); font-weight: 700; color: var(--accent); }
.slide-title { line-height: 1.35; }
.slide-excerpt { color: var(--muted); line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slide-more { font-weight: 700; color: var(--accent); width: fit-content; border-bottom: 2px solid currentColor; padding-bottom: 2px; }
.carousel-nav { display: flex; align-items: center; gap: var(--s-12); margin-top: var(--s-16); }
.carousel-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); font-size: var(--fs-20); line-height: 1; cursor: pointer; display: grid; place-items: center; transition: border-color .15s, color .15s; }
.carousel-btn:hover { border-color: var(--accent); color: var(--accent); }
.carousel-dots { display: flex; gap: 6px; }
.carousel-dots a { display: block; width: 6px; height: 6px; border-radius: 999px; background: var(--line-strong); transition: width .25s, background .25s; }
.carousel-dots a.is-active { width: 22px; background: var(--accent); }

/* cover */
.cv .slide-link { aspect-ratio: 12 / 5; overflow: hidden; border-radius: 16px; isolation: isolate; }
.cv .slide-media { position: absolute; inset: 0; z-index: -2; }
.cv .slide-link::before { content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, color-mix(in srgb, var(--ink) 78%, transparent) 0, color-mix(in srgb, var(--ink) 45%, transparent) 42%, transparent 72%); }
.cv .slide-body { position: absolute; inset: 0 auto 0 0; width: min(560px, 62%); justify-content: flex-end; padding: var(--s-48); color: #fff; }
.cv .slide-title { font-size: var(--fs-36); color: #fff; }
.cv .slide-excerpt { color: color-mix(in srgb, #fff 86%, transparent); font-size: var(--fs-16); }
.cv .slide-cat, .cv .slide-more { color: #fff; }
.cv .carousel-nav { justify-content: flex-end; }

/* card */
.cd .slide-link { display: flex; flex-direction: column; gap: var(--s-16); }
.cd .slide-media { aspect-ratio: 16 / 9; border-radius: var(--r-12); }
.cd .slide-title { font-size: var(--fs-24); }
.cd .slide-link:hover .slide-title { color: var(--accent); }

@media (max-width: 1023px) {
  .cv .slide-link { aspect-ratio: 4 / 3; }
  .cv .slide-link::before { background: linear-gradient(0deg, color-mix(in srgb, var(--ink) 82%, transparent) 0, transparent 70%); }
  .cv .slide-body { width: auto; inset: auto 0 0 0; padding: var(--s-24); }
  .cv .slide-title { font-size: var(--fs-24); }
}
@media (max-width: 639px) { .cv .slide-link { aspect-ratio: 4 / 5; } .cv .slide-excerpt { display: none; } .cd .slide-title { font-size: var(--fs-20); } }
@media (prefers-reduced-motion: reduce) { .carousel-track { scroll-behavior: auto; } }
/* A post whose main image is a generated card (Carousel Images) has its title and subtitle in it: in every layout and width the
   slide shows the whole 16:9 card, uncropped and with nothing over it; its HTML words stay for screen readers and
   search engines. Three classes, so it wins over each layout's .cv / .cd / .sp slide rules. */
.carousel .slide--card .slide-link { display: block; aspect-ratio: 16 / 9; height: auto; padding: 0; border: 0;
  background: none; box-shadow: none; border-radius: 16px; overflow: hidden; }
.carousel .slide--card .slide-link::before { content: none; }
.carousel .slide--card .slide-media { position: static; display: block; width: 100%; height: 100%; aspect-ratio: 16 / 9; border-radius: 0; }
.carousel .slide--card .slide-body { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0; }

/* layout: classic — the first sites' home: hero, the carousel as split cards, topic cards, latest per topic */
.hero { padding: var(--s-64) 0 var(--s-48); background:
  radial-gradient(60% 120% at 100% 0%, color-mix(in srgb, var(--base-light) 55%, transparent) 0, transparent 70%),
  linear-gradient(180deg, var(--panel) 0, var(--bg) 100%); }
.hero-inner { max-width: var(--wide); }
.hero-title { font-size: var(--fs-display); letter-spacing: -.01em; line-height: 1.2; }
.hero-desc { margin-top: var(--s-16); font-size: var(--fs-20); line-height: 1.75; color: var(--ink); max-width: 36em; }
.hero-audience { margin-top: var(--s-12); font-size: var(--fs-16); color: var(--muted); max-width: 40em; padding-left: var(--s-12); border-left: 3px solid var(--accent-soft); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-24) var(--s-32); margin-top: var(--s-32); }
.hero-stats { display: flex; gap: var(--s-24); color: var(--muted); font-size: var(--fs-14); }
.hero-stats b { font-size: var(--fs-24); color: var(--ink); font-weight: 800; margin-right: 2px; font-variant-numeric: tabular-nums; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s-32); }
.topic-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-12); overflow: hidden; background: var(--bg); transition: box-shadow .2s, border-color .2s; }
.topic-card:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.topic-media { display: block; aspect-ratio: 16 / 9; background: var(--panel); overflow: hidden; }
.topic-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.topic-card:hover .topic-media img { transform: scale(1.03); }
.topic-body { display: flex; flex-direction: column; gap: var(--s-8); padding: var(--s-24); flex: 1; }
.topic-count { font-size: var(--fs-14); color: var(--faint); font-weight: 700; font-variant-numeric: tabular-nums; }
.topic-name { font-size: var(--fs-20); }
.topic-name a:hover { color: var(--accent); }
.topic-desc { color: var(--muted); font-size: var(--fs-16); line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.topic-body .chips { margin-top: auto; padding-top: var(--s-12); }
.sp .slide-link { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--s-48); align-items: center; padding: var(--s-24); border: 1px solid var(--line); border-radius: var(--r-12); background: var(--bg); box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 5%, transparent); }
.sp .carousel-track { border-radius: var(--r-12); }
.sp .slide-media { aspect-ratio: 16 / 9; border-radius: var(--r-8); }
.sp .slide-body { gap: var(--s-16); padding-right: var(--s-24); }
.sp .slide-title { font-size: var(--fs-30); }
.sp .slide-link:hover .slide-title { color: var(--accent); }
.sp .slide-excerpt { font-size: var(--fs-18); -webkit-line-clamp: 3; }
.sp .carousel-nav { justify-content: center; }
@media (max-width: 1023px) { .sp .slide-link { grid-template-columns: minmax(0, 1fr); gap: var(--s-24); } .sp .slide-body { padding: 0 var(--s-8) var(--s-8); } }
@media (max-width: 639px) { .hero { padding: var(--s-48) 0 var(--s-32); } .hero-title { font-size: var(--fs-36); } .hero-desc { font-size: var(--fs-18); } .topic-grid { grid-template-columns: 1fr; gap: var(--s-24); } .sp .slide-link { grid-template-columns: minmax(0, 1fr); gap: var(--s-16); padding: var(--s-12); } .sp .slide-body { padding-right: 0; } .sp .slide-title { font-size: var(--fs-24); } }

/* layout: magazine — intro line, cover carousel, topic tiles, latest per topic */
.mg-intro { padding: var(--s-48) 0 var(--s-32); }
.mg-intro-inner { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-48); }
.mg-title { font-size: var(--fs-display); line-height: 1.15; letter-spacing: -.01em; }
.mg-desc { margin-top: var(--s-16); font-size: var(--fs-18); line-height: 1.75; color: var(--muted); max-width: 38em; }
.mg-intro-side { display: flex; align-items: center; gap: var(--s-32); flex-shrink: 0; }
.mg-stats { display: flex; gap: var(--s-24); }
.mg-stats li { display: flex; flex-direction: column; line-height: 1.2; }
.mg-stats b { font-size: var(--fs-30); font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.mg-stats span { font-size: 13px; color: var(--faint); }
.mg-topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-24); }
.mg-topic { display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--panel); transition: transform .2s, box-shadow .2s; }
.mg-topic:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.mg-topic-media { display: block; aspect-ratio: 4 / 3; overflow: hidden; }
.mg-topic-media img { width: 100%; height: 100%; object-fit: cover; }
.mg-topic-body { display: flex; flex-direction: column; gap: var(--s-8); padding: var(--s-16) var(--s-24) var(--s-24); }
.mg-topic-count { font-size: 13px; font-weight: 700; color: var(--accent); }
.mg-topic-name { font-size: var(--fs-20); font-weight: 800; line-height: 1.4; }
.mg-topic-desc { font-size: var(--fs-14); color: var(--muted); line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 1023px) { .mg-intro-inner { flex-direction: column; align-items: flex-start; gap: var(--s-24); } }
@media (max-width: 639px) { .mg-title { font-size: var(--fs-36); } .mg-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-12); } .mg-topic-desc { display: none; } .mg-topic-body { padding: var(--s-12) var(--s-16) var(--s-16); } .mg-topic-name { font-size: var(--fs-16); } }

/* layout: index — a reference shelf: intro beside a card carousel, then every topic as a card with its list */
.ix-hero { padding: var(--s-48) 0 var(--s-64); background: linear-gradient(180deg, var(--panel) 0, var(--bg) 100%); }
.ix-hero-inner { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--s-64); align-items: center; }
.ix-title { font-size: var(--fs-display); line-height: 1.15; }
.ix-desc { margin-top: var(--s-16); font-size: var(--fs-18); line-height: 1.8; }
.ix-audience { margin-top: var(--s-12); font-size: var(--fs-14); color: var(--muted); line-height: 1.7; }
.ix-hero-foot { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-24); margin-top: var(--s-32); }
.ix-stats { display: flex; gap: var(--s-16); font-size: 13px; color: var(--faint); }
.ix-stats b { font-size: var(--fs-20); color: var(--ink); margin-right: 4px; font-variant-numeric: tabular-nums; }
.ix-hero-carousel { min-width: 0; }
.ix-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-24); }
.ix-card { display: flex; flex-direction: column; gap: var(--s-12); padding: var(--s-24); border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.ix-card-head { display: flex; align-items: center; gap: var(--s-16); }
.ix-card-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-12); flex-shrink: 0; }
.ix-card-name { display: block; font-size: var(--fs-20); font-weight: 800; line-height: 1.4; }
.ix-card-head:hover .ix-card-name { color: var(--accent); }
.ix-card-count { display: block; font-size: 13px; color: var(--faint); }
.ix-card-desc { font-size: var(--fs-14); color: var(--muted); line-height: 1.7; }
.ix-list { counter-reset: ix; border-top: 1px solid var(--line); }
.ix-list li { counter-increment: ix; border-bottom: 1px solid var(--line); }
.ix-list a { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: var(--s-8); padding: var(--s-12) 0; align-items: baseline; }
.ix-list a::before { content: counter(ix); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 800; align-self: center; }
.ix-list-title { font-weight: 700; line-height: 1.5; }
.ix-list a:hover .ix-list-title { color: var(--accent); }
.ix-list-meta { font-size: 12px; color: var(--faint); white-space: nowrap; }
.ix-card-all { margin-top: auto; padding-top: var(--s-4); font-weight: 700; color: var(--accent); font-size: var(--fs-14); }
@media (max-width: 1023px) { .ix-hero-inner { grid-template-columns: minmax(0, 1fr); gap: var(--s-32); } }
@media (max-width: 639px) { .ix-title { font-size: var(--fs-30); } .ix-cards { grid-template-columns: minmax(0, 1fr); } .ix-card { padding: var(--s-16); } }

/* layout: wall — image-led tiles, for topics readers browse by picture */
.wl-head { padding: var(--s-48) 0 var(--s-24); text-align: center; }
.wl-head-inner { display: flex; flex-direction: column; align-items: center; gap: var(--s-12); }
.wl-title { font-size: var(--fs-36); letter-spacing: .02em; }
.wl-desc { font-size: var(--fs-18); color: var(--muted); max-width: 38em; line-height: 1.7; }
.wl-tile { position: relative; display: block; overflow: hidden; border-radius: var(--r-12); background: var(--panel); aspect-ratio: 4 / 3; isolation: isolate; }
.wl-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; z-index: -1; }
.wl-tile:hover img { transform: scale(1.04); }
.wl-tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, color-mix(in srgb, var(--ink) 82%, transparent) 100%); z-index: -1; }
.wl-tile-text { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-16) var(--s-16) var(--s-16); color: #fff; }
.wl-tile-title { font-size: var(--fs-18); font-weight: 800; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wl-tile-kicker { font-size: 12px; font-weight: 700; opacity: .85; letter-spacing: .04em; }
.wl-topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-16); margin-top: var(--s-48); }
.wl-tile--topic { aspect-ratio: 1 / 1; }
.wl-tile--topic .wl-tile-title { font-size: var(--fs-20); }
.wl-featured { margin-top: var(--s-8); }
.wl-wall { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-16); }
.wl-wall .wl-tile:first-child { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
.wl-wall .wl-tile:first-child .wl-tile-title { font-size: var(--fs-24); }
.wl-wall .wl-tile:only-child { grid-column: 1 / -1; grid-row: auto; aspect-ratio: 21 / 9; }
@media (max-width: 1023px) { .wl-wall { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) {
  .wl-wall { grid-template-columns: minmax(0, 1fr); }
  .wl-wall .wl-tile:first-child { grid-column: auto; grid-row: auto; aspect-ratio: 4 / 3; }
  .wl-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* layout: guide — a reading path, numbered steps, for readers new to the subject */
.gd-hero { padding: var(--s-64) 0; background: var(--panel); }
.gd-hero-inner { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: var(--s-48); align-items: center; }
.gd-title { font-size: var(--fs-display); line-height: 1.2; }
.gd-desc { margin-top: var(--s-16); font-size: var(--fs-20); line-height: 1.75; }
.gd-audience { margin-top: var(--s-16); color: var(--muted); }
.gd-cta { margin-top: var(--s-32); width: fit-content; }
.gd-carousel { min-width: 0; padding: var(--s-16); background: var(--bg); border-radius: 16px; box-shadow: 0 10px 30px color-mix(in srgb, var(--ink) 8%, transparent); }
.gd-path { counter-reset: step; display: flex; flex-direction: column; }
.gd-step { counter-increment: step; position: relative; display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: var(--s-48); padding: var(--s-32) 0 var(--s-48) var(--s-64); border-left: 2px solid var(--line-strong); margin-left: var(--s-24); }
.gd-step:last-child { border-left-color: transparent; }
.gd-step::before { content: counter(step, decimal-leading-zero); position: absolute; left: -25px; top: var(--s-24); width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--bg); font-weight: 800; font-variant-numeric: tabular-nums; }
.gd-step-head { display: flex; flex-direction: column; gap: var(--s-12); }
.gd-step-name { font-size: var(--fs-24); }
.gd-step-name a:hover { color: var(--accent); }
.gd-step-desc { color: var(--muted); line-height: 1.75; }
.gd-step-posts { display: flex; flex-direction: column; gap: var(--s-12); }
.gd-step-posts a { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: var(--s-16); align-items: center; padding: var(--s-8); border-radius: var(--r-8); transition: background .15s; }
.gd-step-posts a:hover { background: var(--panel); }
.gd-step-posts img { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; border-radius: var(--r-4); }
.gd-post-title { display: block; font-weight: 700; line-height: 1.5; }
.gd-post-meta { display: block; margin-top: var(--s-4); font-size: var(--fs-14); color: var(--faint); }
@media (max-width: 1023px) {
  .gd-hero-inner, .gd-step { grid-template-columns: minmax(0, 1fr); }
  .gd-step { gap: var(--s-24); }
}
@media (max-width: 639px) {
  .gd-title { font-size: var(--fs-30); }
  .gd-step { padding-left: var(--s-32); margin-left: var(--s-16); } .gd-step::before { left: -17px; width: 32px; height: 32px; font-size: 12px; }
  .gd-step-posts a { grid-template-columns: 88px minmax(0, 1fr); }
}

.author-band { margin-top: var(--s-64); padding: var(--s-48) 0; background: var(--panel); }
.author-band-inner { display: grid; gap: var(--s-32); }
.author-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-24); align-items: start; max-width: 52em; }
.author-card .avatar { width: 72px; height: 72px; background: var(--bg); font-size: var(--fs-24); }
.author-card-name { font-size: var(--fs-24); font-weight: 800; margin-top: var(--s-4); }
.author-card-name a:hover { color: var(--accent); }
.author-card-bio { margin: var(--s-12) 0 var(--s-16); color: var(--muted); line-height: 1.8; }

/* ---------- post ---------- */
.post-layout { width: min(100% - 2 * var(--gutter), var(--page)); display: grid; grid-template-columns: 220px minmax(0, var(--content)) 280px; justify-content: space-between; gap: var(--s-48); padding-top: var(--s-32); }
.post { min-width: 0; }
.rail { position: sticky; top: calc(var(--header-h) + var(--s-32)); max-height: calc(100vh - var(--header-h) - var(--s-64)); overflow: auto; overscroll-behavior: contain; padding-right: var(--s-4); scrollbar-width: thin; }
.rail-title { font-size: var(--fs-14); font-weight: 700; color: var(--ink); margin-bottom: var(--s-12); }

.toc-list { border-left: 1px solid var(--line); }
.toc-item a { display: block; margin-left: -1px; padding: 6px 0 6px var(--s-12); border-left: 2px solid transparent; font-size: var(--fs-14); line-height: 1.5; color: var(--muted); }
.toc-item--sub a { padding-left: var(--s-24); font-size: 13px; color: var(--faint); }
.toc-item a:hover { color: var(--ink); }
.toc-item a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 700; }

.post-head { margin-top: var(--s-24); }
.post-title { font-size: var(--fs-36); line-height: 1.35; letter-spacing: -.005em; }
.byline { display: flex; align-items: center; gap: var(--s-12); margin-top: var(--s-24); }
.byline-text { display: flex; flex-direction: column; min-width: 0; }
.byline-name { font-weight: 700; font-size: var(--fs-16); }
.byline-name:hover { color: var(--accent); }
.byline-meta { display: flex; flex-wrap: wrap; gap: 0 var(--s-8); font-size: var(--fs-14); color: var(--faint); }
.byline-meta a { color: var(--accent); }
.post-cover { margin: var(--s-32) 0 0; aspect-ratio: 16 / 9; border-radius: var(--r-12); overflow: hidden; background: var(--panel); }
.post-cover img { width: 100%; height: 100%; object-fit: cover; }
/* A post with a generated card (Carousel Images): the cover area is a carousel, the card first, then the drawn cover. */
.post-cover-carousel { margin: var(--s-32) 0 0; }
.post-cover-carousel .carousel-track { border-radius: var(--r-12); }
.post-cover-carousel .post-cover { margin: 0; border-radius: 0; }
.post-cover-carousel .carousel-nav { justify-content: center; margin-top: var(--s-12); }

.toc-inline { display: none; margin-top: var(--s-24); border: 1px solid var(--line); border-radius: var(--r-8); }
.toc-inline > summary, .tree-box > summary { list-style: none; cursor: pointer; padding: var(--s-12) var(--s-16); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.toc-inline > summary::-webkit-details-marker, .tree-box > summary::-webkit-details-marker { display: none; }
.toc-inline > summary::after, .tree-box > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.toc-inline[open] > summary::after, .tree-box[open] > summary::after { transform: rotate(-135deg); }
.tree-box > summary { display: none; }  /* the wide right rail shows the tree open, without its toggle */
.toc-inline .toc-list { margin: 0 var(--s-16) var(--s-16); }


/* article body: WordPress block markup (wp-block-image / wp-block-table) */
.entry-content { margin-top: var(--s-32); font-size: var(--fs-18); line-height: var(--lh-body); overflow-wrap: anywhere; }
.entry-content > * + * { margin-top: 1em; }
.entry-content h2 { font-size: var(--fs-30); margin-top: 2.2em; padding-top: 1.1em; border-top: 1px solid var(--line); }
.entry-content h3 { font-size: var(--fs-20); margin-top: 1.8em; }
.entry-content > h2:first-child, .entry-content > .sec-head:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.entry-content h2 + p, .entry-content h3 + p { margin-top: .6em; }
.entry-content a {
  color: var(--accent); font-weight: 700; text-decoration: none;
  background: linear-gradient(var(--accent-soft), var(--accent-soft)) 0 100% / 100% .45em no-repeat;
  transition: background-size .15s;
}
.entry-content a:hover { background-size: 100% 100%; }
.entry-content strong { font-weight: 700; }
.entry-content ul, .entry-content ol { padding-left: 1.4em; }
.entry-content ul { list-style: disc; } .entry-content ol { list-style: decimal; }
.entry-content li + li { margin-top: .4em; }
.entry-content li::marker { color: var(--accent); }
.entry-content blockquote { margin-left: 0; padding: var(--s-16) var(--s-24); border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 var(--r-8) var(--r-8) 0; color: var(--muted); }
.entry-content figure { margin: 2em 0; }
.wp-block-image img { width: 100%; height: auto; border-radius: var(--r-12); border: 1px solid var(--line); }
.wp-block-image figcaption { margin-top: var(--s-8); font-size: var(--fs-14); color: var(--faint); text-align: center; }
/* An H3 image with an infographic (Article Infographics): a carousel, the infographic first, then the drawn image; both
   16:9, so the frame never changes height. */
.figure-carousel { margin: 2em 0; }
.figure-carousel .carousel-track { border-radius: var(--r-12); border: 1px solid var(--line); background: var(--panel); }
.entry-content .figure-carousel .figure-slide { margin: 0; aspect-ratio: 16 / 9; }
.figure-slide img { width: 100%; height: 100%; object-fit: contain; display: block; }
.figure-carousel .carousel-nav { justify-content: center; margin-top: var(--s-12); }
.entry-content .figure-carousel .carousel-dots { list-style: none; padding: 0; margin: 0; }
.entry-content .figure-carousel .carousel-dots li + li { margin-top: 0; }
.wp-block-table { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line-strong); border-radius: var(--r-12); max-width: none; box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent); }
.wp-block-table table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: var(--fs-16); line-height: 1.6; }
.wp-block-table th, .wp-block-table td { padding: var(--s-12) var(--s-16); text-align: left; vertical-align: top; }
.wp-block-table th + th, .wp-block-table td + td { border-left: 1px solid var(--line); }
.wp-block-table thead th { background: var(--accent-soft); font-size: var(--fs-14); font-weight: 700; color: var(--ink); white-space: nowrap; border-bottom: 2px solid var(--accent); }
.wp-block-table tbody tr + tr td { border-top: 1px solid var(--line); }
.wp-block-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--panel) 55%, var(--bg)); }
.wp-block-table tbody td { color: var(--muted); }
.wp-block-table tbody td:first-child { font-weight: 700; color: var(--ink); white-space: nowrap; }
.entry-content--page h2 { font-size: var(--fs-24); border-top: 0; padding-top: 0; margin-top: 1.8em; }
/* Sources: the section's external source, a small card under it */
.source-note { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px var(--s-12); align-items: center; padding: var(--s-12) var(--s-16); border: 1px solid var(--line); border-radius: var(--r-12); background: color-mix(in srgb, var(--panel) 60%, var(--bg)); font-size: var(--fs-14); line-height: 1.55; }
.source-label { grid-row: span 2; align-self: start; margin-top: 1px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; white-space: nowrap; }
.entry-content .source-note a { color: var(--ink); font-weight: 500; background: none; overflow-wrap: anywhere; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-decoration-thickness: 1px; text-underline-offset: 5px; transition: color .15s, text-decoration-color .15s; }
.entry-content .source-note a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.source-publisher { grid-column: 2; color: var(--faint); font-size: 13px; }

/* Head-Term Links: horizontal scroller */
.related { margin-top: var(--s-64); padding-top: var(--s-32); border-top: 1px solid var(--line-strong); }
.related-head { display: flex; align-items: center; gap: var(--s-12); margin-bottom: var(--s-24); }
.related-title { font-size: var(--fs-24); }
.related-hint { font-size: var(--fs-14); color: var(--faint); display: inline-flex; align-items: center; gap: var(--s-8); }
.related-hint::after { content: ""; width: 18px; height: 1px; background: currentColor; box-shadow: 4px 0 0 0 transparent; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(5px); } }
.related-nav { margin-left: auto; display: flex; gap: var(--s-8); }
.scroll-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--bg); cursor: pointer; display: grid; place-items: center; font-size: var(--fs-24); line-height: 1; color: var(--ink); transition: border-color .15s, color .15s, opacity .15s; }
.scroll-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.scroll-btn:disabled { opacity: .35; cursor: default; }
.scroller { position: relative; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; padding-bottom: var(--s-16); cursor: grab;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 64px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 64px), transparent); }
.scroller.is-end { -webkit-mask-image: none; mask-image: none; }
.scroller.is-dragging { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; user-select: none; }
.scroller.is-dragging a { pointer-events: none; }
.scroller-track { display: grid; grid-auto-flow: column; grid-auto-columns: 260px; gap: var(--s-24); }
.scroller-item { scroll-snap-align: start; }
.scroller .card { gap: var(--s-12); }
.scroller .card-title { font-size: var(--fs-16); -webkit-line-clamp: 3; }
.scroller .card-excerpt, .scroller .card-meta { display: none; }
.scroller img { -webkit-user-drag: none; user-select: none; }

.author-box { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-16); margin-top: var(--s-48); padding: var(--s-24) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.author-box-label { font-size: var(--fs-14); color: var(--faint); font-weight: 700; }
.author-box-name { font-size: var(--fs-18); font-weight: 800; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-12); }
.author-box-name a:hover { color: var(--accent); }
.author-box-bio { margin: var(--s-8) 0 var(--s-12); color: var(--muted); font-size: var(--fs-16); line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* category tree: quieter than the TOC */
.tree { font-size: var(--fs-14); }
.tree summary { list-style: none; cursor: pointer; display: grid; align-items: center; gap: var(--s-8); border-radius: var(--r-8); }
.tree summary::-webkit-details-marker { display: none; }
.tree summary:hover { background: var(--panel); }
.tree-parent + .tree-parent { margin-top: var(--s-4); }
.tree-parent > details > summary { grid-template-columns: 40px minmax(0, 1fr) auto; padding: var(--s-8); font-weight: 700; color: var(--ink); }
.tree-parent > details > summary img, .tree-parent > details > summary .tree-thumb { width: 40px; height: 40px; border-radius: var(--r-8); object-fit: cover; background: var(--panel); }
.tree-name { line-height: 1.45; min-width: 0; }
.tree-count { font-size: 12px; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.tree-children { margin: var(--s-4) 0 var(--s-8) 28px; padding-left: var(--s-12); border-left: 1px solid var(--line); }
.tree-children summary { grid-template-columns: minmax(0, 1fr) auto; padding: 6px var(--s-8); color: var(--muted); font-weight: 500; }
.tree-children details[open] > summary { color: var(--ink); font-weight: 700; }
.tree-posts { margin: 2px 0 var(--s-8); }
.tree-posts a { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: var(--s-8); align-items: center; padding: 6px var(--s-8); border-radius: var(--r-8); color: var(--muted); line-height: 1.45; }
.tree-posts a span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; }
.tree-posts img, .tree-posts .tree-thumb { width: 48px; aspect-ratio: 16 / 9; border-radius: var(--r-4); object-fit: cover; background: var(--panel); }
.tree-posts a:hover { background: var(--panel); color: var(--ink); }
.tree-posts a.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.tree-more a { display: block; grid-template-columns: none; padding: 4px var(--s-8); font-size: 13px; color: var(--accent); font-weight: 500; }
.rail--quiet .rail-title { color: var(--faint); }

/* ---------- category ---------- */
.cat-hero { padding: var(--s-32) 0 var(--s-48); background: linear-gradient(180deg, var(--panel) 0, var(--bg) 100%); border-bottom: 1px solid var(--line); }
.cat-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-48); align-items: center; margin-top: var(--s-24); }
.cat-title { font-size: var(--fs-36); }
.cat-desc { margin-top: var(--s-16); font-size: var(--fs-18); color: var(--muted); line-height: 1.8; max-width: 36em; }
.cat-count { margin-top: var(--s-16); font-size: var(--fs-14); font-weight: 700; color: var(--faint); }
.cat-mosaic { position: relative; width: 400px; height: 240px; }
.cat-mosaic img { position: absolute; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-12); border: 4px solid var(--bg); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 12%, transparent); background: var(--panel); }
.cat-mosaic img:nth-child(1) { width: 78%; right: 0; top: 0; z-index: 2; }
.cat-mosaic img:nth-child(2) { width: 52%; left: 0; bottom: 0; z-index: 3; }
.chips--lg { margin-top: var(--s-32); }
.chips--lg .chip { font-size: var(--fs-16); padding: var(--s-8) var(--s-16); }
.subcat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-16); }
.subcat { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s-16); align-items: center; padding: var(--s-12); border: 1px solid var(--line); border-radius: var(--r-12); transition: border-color .15s, box-shadow .15s; }
.subcat:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); }
.subcat img, .subcat .tree-thumb { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-8); background: var(--panel); }
.subcat-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.subcat-name { font-weight: 700; line-height: 1.45; }
.subcat-count { font-size: var(--fs-14); color: var(--faint); }

/* ---------- page ---------- */
.page { padding-top: var(--s-32); }
.page-head { margin: var(--s-32) 0 0; padding-bottom: var(--s-24); border-bottom: 1px solid var(--line); }
.page-title { font-size: var(--fs-36); }
.profile-head { display: flex; align-items: center; gap: var(--s-24); margin-top: var(--s-32); }
.profile-head .avatar { width: 88px; height: 88px; font-size: var(--fs-30); }
.profile-bio { margin-top: var(--s-24); padding: var(--s-24); background: var(--panel); border-radius: var(--r-12); color: var(--ink); line-height: 1.8; font-size: var(--fs-18); }

/* the menu folds behind the toggle when its items do not fit on one line, or below 1024 (theme.js sets .nav-compact) */
.nav-compact .header-inner { gap: var(--s-16); }
.nav-compact .nav-toggle { display: inline-flex; }
.nav-compact .site-nav { position: absolute; left: 0; right: 0; top: 100%; margin: 0; background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px color-mix(in srgb, var(--ink) 8%, transparent); display: none; }
.nav-compact .site-nav.is-open { display: block; }
.nav-compact .site-nav ul { flex-direction: column; gap: 0; width: min(100% - 2 * var(--gutter), var(--wide)); margin: 0 auto; padding: var(--s-8) 0 var(--s-16); }
.nav-compact .site-nav a { white-space: normal; max-width: none; padding: var(--s-12) 0; border-radius: 0; border-bottom: 1px solid var(--line); }
.nav-compact .site-nav li:last-child a { border-bottom: 0; }
.nav-compact .site-nav a:hover { background: none; }
/* ---------- responsive ---------- */
/* 1024–1279: TOC stays as the left rail; the category tree moves to the end */
@media (max-width: 1279px) {
  .post-layout { grid-template-columns: 200px minmax(0, var(--content)); justify-content: center; }
  /* the one category tree follows the article here, collapsed */
  .post-tree { grid-column: 2; }
  .post-layout { row-gap: var(--s-24); }
  .tree-box { border: 1px solid var(--line); border-radius: var(--r-8); }
  .tree-box > summary { display: flex; }
  .post-tree .rail { position: static; max-height: none; overflow: visible; padding: 0 var(--s-16) var(--s-16); }
  .post-tree .rail-title { display: none; }
}
/* < 1024: one column; TOC under the cover, collapsible, not sticky */
@media (max-width: 1023px) {
  .post-layout { grid-template-columns: minmax(0, var(--content)); }
  .post-toc { display: none; }
  .toc-inline { display: block; }
  .post-tree { grid-column: auto; }
  .card-grid--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid--list { grid-template-columns: 1fr; }
  .cat-head { grid-template-columns: 1fr; }
  .cat-mosaic { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 639px) {
  :root { --gutter: 20px; --header-h: 60px; }
  .brand .logo { height: 32px; }
  .nav-toggle-text { display: none; }
  .section { padding-top: var(--s-48); }
  .section-title { font-size: var(--fs-24); }
  .card-grid--grid, .card-grid--list { grid-template-columns: 1fr; gap: var(--s-32); }
  .card-grid--list .card, .card-grid--list .card:only-child { grid-template-columns: 1fr; gap: var(--s-16); }
  .card-grid--list .card-title { font-size: var(--fs-20); }
  .section-head--split .text-link { white-space: nowrap; }
  .section--topic .card-grid .card, .section--topic .card-grid .card:only-child { grid-template-columns: 120px minmax(0, 1fr); gap: var(--s-16); align-items: start; display: grid; }
  .section--topic .card-grid { gap: var(--s-24); }
  .section--topic .card-grid .card .card-title { font-size: var(--fs-16); }
  .section--topic .card-meta span { display: none; }
  .section--topic .card-excerpt { display: none; }
  .section--topic .card-body { gap: var(--s-4); }
  .post-title { font-size: var(--fs-30); }
  .entry-content { font-size: 17px; }
  .entry-content h2 { font-size: var(--fs-24); }
  .entry-content h3 { font-size: var(--fs-18); }
  .post-cover { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; }
  .post-cover-carousel { margin-inline: calc(-1 * var(--gutter)); }
  .post-cover-carousel .carousel-track { border-radius: 0; }
  .post-cover-carousel .post-cover { margin-inline: 0; }
  .related-nav { display: none; }
  .scroller { margin-right: calc(-1 * var(--gutter)); }
  .scroller-track { grid-auto-columns: 72%; padding-right: var(--gutter); gap: var(--s-16); }
  .cat-title, .page-title { font-size: var(--fs-30); }
  .author-card { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: var(--s-32); padding-top: var(--s-48); }
  .footer-bottom { flex-direction: column; }
  .subcat-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- site assistant (assistant.js; optional): the button at the bottom right and its panel; theme tokens only ---------- */
.aca { position: fixed; right: max(20px, env(safe-area-inset-right, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); z-index: 50; font-family: var(--font); color: var(--ink); }
.aca svg { width: 20px; height: 20px; display: block; }

.aca-launcher { display: inline-flex; align-items: center; gap: var(--s-8); height: 52px; padding: 0 var(--s-24) 0 var(--s-16); border: 0; border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-size: var(--fs-16); font-weight: 700; cursor: pointer; box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 22%, transparent); transition: transform .15s, background .15s; }
.aca-launcher svg { width: 22px; height: 22px; }
.aca-launcher:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); transform: translateY(-1px); }
.aca.is-open .aca-launcher { display: none; }

.aca-panel { position: absolute; right: 0; bottom: 0; width: 392px; height: min(620px, calc(100vh - 40px)); display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-12); box-shadow: 0 18px 48px color-mix(in srgb, var(--ink) 20%, transparent); overflow: hidden; }
.aca-panel[hidden] { display: none; }

.aca-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-12); padding: var(--s-16) var(--s-16) var(--s-12) var(--s-24); border-bottom: 1px solid var(--line); }
.aca-title { font-size: var(--fs-18); font-weight: 700; line-height: var(--lh-head); }
.aca-sub { font-size: var(--fs-14); color: var(--muted); }
.aca-close { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.aca-close:hover { background: var(--panel); color: var(--ink); }

.aca-log { flex: 1; overflow-y: auto; padding: var(--s-16) var(--s-16) var(--s-24); display: flex; flex-direction: column; gap: var(--s-12); background: var(--panel); }
.aca-msg { max-width: 100%; font-size: var(--fs-14); line-height: 1.7; }
.aca-msg p { margin: 0 0 var(--s-8); }
.aca-bot { align-self: stretch; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-12); border-top-left-radius: var(--r-4); padding: var(--s-12) var(--s-16); }
.aca-user { align-self: flex-end; max-width: 85%; background: var(--accent); color: #fff; border-radius: var(--r-12); border-bottom-right-radius: var(--r-4); padding: var(--s-8) var(--s-12); }

.aca-chips { display: flex; flex-wrap: wrap; gap: var(--s-8); }
.aca-chip { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: var(--fs-14); padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); color: var(--ink); cursor: pointer; text-align: left; }
.aca-chip:hover { border-color: var(--accent); color: var(--accent); }
.aca-count { font-size: 12px; color: var(--faint); }

.aca-qs { display: flex; flex-direction: column; }
.aca-q { font: inherit; font-size: var(--fs-14); text-align: left; padding: var(--s-8) 0; border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink); cursor: pointer; }
.aca-q:first-child { border-top: 0; }
.aca-q:hover { color: var(--accent); }
.aca-more { margin-top: var(--s-8); font: inherit; font-size: var(--fs-14); font-weight: 700; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }

.aca-cards { display: flex; flex-direction: column; gap: var(--s-8); }
.aca-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s-12); align-items: start; padding: var(--s-12); border: 1px solid var(--line); border-radius: var(--r-8); text-decoration: none; color: var(--ink); background: var(--bg); transition: border-color .15s, box-shadow .15s; }
.aca-card:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); }
.aca-card-img { display: block; width: 96px; height: 54px; object-fit: cover; border-radius: var(--r-4); background: var(--base-light); }
.aca-card-text { display: grid; gap: 2px; min-width: 0; }
.aca-card-cat { font-size: 12px; font-weight: 700; color: var(--accent); }
.aca-card-title { font-weight: 700; line-height: 1.5; }
.aca-card-meta { font-size: 13px; color: var(--muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.aca-form { display: flex; gap: var(--s-8); padding: var(--s-12); border-top: 1px solid var(--line); background: var(--bg); }
.aca-input { flex: 1; min-width: 0; font: inherit; font-size: var(--fs-16); padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); color: var(--ink); }
.aca-input:focus { outline: none; border-color: var(--accent); }
.aca-send { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; }
.aca-send:disabled { opacity: .5; cursor: default; }
.aca button:focus-visible, .aca-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 520px) {
  .aca { right: 12px; bottom: 12px; }
  .aca-panel { position: fixed; inset: auto 8px 8px 8px; width: auto; height: min(78vh, 620px); }
}
@media (prefers-reduced-motion: reduce) { .aca-launcher, .aca-card { transition: none; } }
@media print { .aca { display: none; } }

/* E-E-A-T: the post's sources line and report box, the cite menus theme.js builds, the footer's posts, the
   editorial page's numbers. An H2 sits in a heading row (.sec-head) that keeps room for its cite button, so the
   button arrives without moving anything; the heading's look moves from the H2 to the row. */
.ed-intro { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; column-gap: var(--s-12); row-gap: var(--s-4); margin-top: var(--s-16); padding: var(--s-12) var(--s-16); border: 1px solid var(--line); border-radius: var(--r-12); background: color-mix(in srgb, var(--panel) 60%, var(--bg)); }
.ed-intro-icon { width: 28px; height: 28px; color: var(--accent); }
.ed-intro-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.5; min-width: 0; }
.ed-intro-text strong { font-size: var(--fs-14); color: var(--ink); }
.ed-intro-text span { font-size: 13px; color: var(--muted); }
.ed-intro .text-link { font-size: var(--fs-14); white-space: nowrap; }
.author-box-links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-8) var(--s-24); }
.post-actions { margin-top: var(--s-48); }
.post-actions .chips { margin-top: var(--s-8); }
.footer-pref { margin-top: var(--s-16); }
.footer-col--posts a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-content .sec-head { position: relative; font-size: var(--fs-30); margin-top: 2.2em; padding: 1.1em 72px 0 0; border-top: 1px solid var(--line); }
.entry-content .sec-head h2 { font-size: 1em; margin: 0; padding: 0; border: 0; }
.entry-content .sec-head + * { margin-top: .6em; }
.sec-tool { position: absolute; right: 0; top: 1.1em; height: calc(var(--lh-head) * 1em); display: flex; align-items: center; }
.entry-content > .sec-head:first-child .sec-tool { top: 0; }
.figure-carousel .sec-tool { position: relative; top: auto; height: auto; margin-left: auto; }
.sec-btn { display: inline-flex; align-items: center; padding: 2px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--faint); font: 700 12px/1.7 var(--font); cursor: pointer; white-space: nowrap; }
.sec-btn:hover, .sec-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.sec-menu { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: 240px; max-width: calc(100vw - 32px); padding: 6px; border: 1px solid var(--line); border-radius: var(--r-12); background: var(--bg); box-shadow: var(--shadow-hover); font-size: var(--fs-14); line-height: 1.5; }
.figure-carousel .sec-menu { top: auto; bottom: calc(100% + 6px); }
.sec-menu[hidden] { display: none; }
.sec-menu button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-8); background: none; text-align: left; cursor: pointer; font: 700 var(--fs-14)/1.5 var(--font); color: var(--ink); }
.sec-menu button small { font-weight: 400; font-size: 12px; color: var(--faint); }
.sec-menu button:hover, .sec-menu button:focus-visible { background: var(--panel); }
.sec-toast { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: var(--fs-14); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
.sec-toast.is-on { opacity: 1; }
.entry-content .ep-stats { margin: var(--s-24) 0; }
.entry-content .ep-stats ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-16); list-style: none; padding: 0; margin: 0; }
.entry-content .ep-stats li { margin: 0; padding: 0; }
.data-bar { display: block; min-width: 4px; height: 10px; margin-top: 7px; border-radius: 999px; background: var(--accent); }
@media (max-width: 639px) {
  .entry-content .sec-head { font-size: var(--fs-24); }
  .ed-intro { grid-template-columns: 28px minmax(0, 1fr); align-items: start; }
  .ed-intro .text-link { grid-column: 2; justify-self: start; }
}

/* Home tour (partials/tour.html): four screens of scroll over the static home. The mascot greets, steps aside as the
   topics fly in round it, holds a book as they settle into cards (each with its top posts and children: the home's
   topic map, all real links), then waves; the static home follows. theme.js turns the scroll into --p (0..1); every
   move below is computed from it. Without script, or with reduced motion, the tour is a plain list (html:not(.tour-on)). */
.tour-switch { position: fixed; z-index: 30; top: calc(var(--header-h) + 12px); right: 16px; display: flex; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 88%, transparent); border: 1px solid var(--line); backdrop-filter: blur(8px); box-shadow: var(--shadow-hover); }
.tour-switch a { padding: 6px 14px; border-radius: 999px; font-size: var(--fs-14); font-weight: 700; color: var(--muted); }
.tour-switch a.is-on { background: var(--accent); color: #fff; }
html:not(.tour-on) .tour-switch { display: none; }
.tour { position: relative; height: 400svh; background: radial-gradient(120% 80% at 50% 0%, var(--accent-soft), var(--bg) 70%); }
.tour-stage { position: sticky; top: var(--header-h); height: calc(100svh - var(--header-h)); overflow: hidden; --p: 0; --tour-w: min(100vw - 32px, 1240px); --tour-top: clamp(24px, 14vh, 140px); --tour-reserve: 400px;
  --b: clamp(0, calc(var(--p) * 4 - 1), 1); --c: clamp(0, calc(var(--p) * 4 - 2), 1); --d: clamp(0, calc(var(--p) * 4 - 3), 1); }
.tour-mascot { position: absolute; left: 50%; top: calc((100% - var(--tour-reserve)) / 2 + 8px); aspect-ratio: 1;
  width: max(96px, min(40vmin, 300px, 100svh - var(--header-h) - var(--tour-reserve) - 16px));
  transform: translate(calc(-50% - var(--b) * (var(--tour-w) / 2 - 95px)), calc(-50% + var(--b) * (var(--tour-top) + 28px - (100svh - var(--header-h) - var(--tour-reserve)) / 2 - 8px))) scale(calc(1 - var(--b) * .5 + var(--d) * .25));
  transition: transform .12s linear; will-change: transform; }
.tour-pose { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; animation: tour-bob 3.2s ease-in-out infinite; filter: drop-shadow(0 18px 24px color-mix(in srgb, var(--ink) 16%, transparent)); }
.tour-pose--hello { opacity: clamp(0, calc(1 - var(--b) * 4), 1); }
.tour-pose--point { opacity: clamp(0, calc(min(var(--b) * 4, 1) - var(--c) * 4), 1); }
.tour-pose--book { opacity: clamp(0, calc(min(var(--c) * 4, 1) - var(--d) * 4), 1); }
.tour-pose--bye { opacity: clamp(0, calc(var(--d) * 4), 1); }
@keyframes tour-bob { 50% { transform: translateY(-10px) rotate(-3deg); } }
.tour-bubble { position: absolute; left: 62%; top: -4%; padding: 8px 14px; border-radius: 16px 16px 16px 4px; background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow-hover); font-weight: 700; font-size: var(--fs-16); white-space: nowrap; }
.tour-bubble--hi { opacity: calc(1 - var(--b) * 3); }
.tour-bubble--bye { opacity: var(--d); font-size: var(--fs-20); }
.tour-intro { position: absolute; left: 50%; bottom: 5%; width: min(92vw, 1040px); transform: translate(-50%, calc(var(--b) * -40px)); text-align: center; opacity: calc(1 - var(--b) * 2.5); }
.tour-kicker { font-size: var(--fs-14); letter-spacing: .2em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.tour-title { font-size: clamp(32px, 6vw, 56px); font-weight: 800; line-height: 1.15; margin-top: 6px; }
.tour-desc { max-width: 680px; margin: 10px auto 0; color: var(--muted); font-size: var(--fs-16); line-height: 1.7; }
/* the first screen lists the topics too (the same parents as the cards), so a reader can pick before scrolling */
.tour-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px auto 0; max-width: 1040px; }
.tour-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); box-shadow: 0 2px 8px color-mix(in srgb, var(--ink) 6%, transparent); font-size: var(--fs-14); font-weight: 700; color: var(--ink); }
.tour-chip span { font-size: 12px; font-weight: 600; color: var(--faint); }
.tour-chip:hover { border-color: var(--accent); color: var(--accent); }
.tour-hint { margin-top: 16px; font-size: var(--fs-14); color: var(--faint); }
.tour-hint::after { content: ""; display: block; width: 10px; height: 10px; margin: 8px auto 0; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.tour-topics { position: absolute; inset: 0; padding: var(--tour-top) calc((100vw - var(--tour-w)) / 2) 16px calc((100vw - var(--tour-w)) / 2 + 200px); display: flex; flex-direction: column; justify-content: flex-start; opacity: calc(var(--b) * 3 - var(--d) * 2); pointer-events: none; }
.tour-stage:not([data-phase="a"]) .tour-topics { pointer-events: auto; }  /* clickable whenever shown (b, c and the last phase d) */
.tour-step-title { min-height: 56px; display: flex; align-items: center; font-size: clamp(22px, 3vw, 32px); font-weight: 800; margin: 0 0 12px; opacity: var(--c); }
.tour-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tour-card { --ang: calc(var(--i) / var(--n) * 360deg); border-radius: var(--r-12); background: var(--bg); border: 1px solid var(--line); overflow: hidden; box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 8%, transparent);
  transform: translate(calc(cos(var(--ang)) * (1 - var(--b)) * 60vw), calc(sin(var(--ang)) * (1 - var(--b)) * 60vh)) scale(calc(.4 + var(--b) * .6)); opacity: var(--b); }
.tour-card-head { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; color: var(--ink); }
.tour-card-head img { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; }
.tour-card-name { font-weight: 800; font-size: var(--fs-16); line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tour-card-count { font-size: 12px; color: var(--faint); white-space: nowrap; }
.tour-card-posts { list-style: none; margin: 0; padding: 0 12px 10px; max-height: calc(var(--c) * 16em); opacity: var(--c); overflow: hidden; }
.tour-card-posts li + li { margin-top: 4px; }
.tour-card-posts a { display: block; font-size: var(--fs-14); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tour-card-posts a::before { content: "\203A"; margin-right: 6px; color: var(--accent); font-weight: 700; }
.tour-card a:hover { color: var(--accent); }
.tour-card-posts .tour-card-kids { display: flex; flex-wrap: nowrap; gap: 4px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.tour-card-kids::-webkit-scrollbar { display: none; }
.tour-card-kids a { flex: none; display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--panel); font-size: 12px; }
.tour-card-kids a::before { content: none; }
@media (max-width: 639px) {
  .tour-mascot { top: 38%; width: 34vmin; transform: translate(calc(-50% - var(--b) * (50vw - 40px)), calc(-72% + var(--b) * (22% + 112px - .38 * (100svh - var(--header-h))))) scale(calc(1 - var(--b) * .62 + var(--d) * .2)); }
  .tour-bubble { left: 50%; top: -14%; transform: translateX(-10%); font-size: var(--fs-14); }
  .tour-title { font-size: 34px; }
  .tour-desc { font-size: var(--fs-14); line-height: 1.6; }
  .tour-chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 14px -16px 0; padding: 2px 16px 6px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
  .tour-chips::-webkit-scrollbar { display: none; }
  .tour-chip { flex: none; }
  .tour-topics { justify-content: flex-start; padding: 84px 12px 12px; }
  .tour-step-title { padding-left: 84px; min-height: 56px; display: flex; align-items: center; font-size: var(--fs-20); margin-bottom: 10px; }
  .tour-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tour-card-head { grid-template-columns: 40px minmax(0, 1fr); gap: 8px; padding: 8px; }
  .tour-card-head img { width: 40px; height: 40px; border-radius: 8px; }
  .tour-card-count { display: none; }
  .tour-card-posts { padding: 0 8px 8px; }
  .tour-card-posts li:nth-child(n+3) { display: none; }
  .tour-card-posts a { font-size: 12px; }
}
@media (max-width: 639px) and (max-height: 720px) { .tour-card-posts li:nth-child(n+2) { display: none; } }
html:not(.tour-on) .tour { height: auto; }
html:not(.tour-on) .tour-stage { position: static; height: auto; overflow: visible; --b: 1; --c: 1; --d: 0; padding: 24px 0; }
html:not(.tour-on) .tour-mascot, html:not(.tour-on) .tour-topics { position: static; transform: none; opacity: 1; width: auto; padding: 16px; }
html:not(.tour-on) .tour-mascot { width: 140px; height: 140px; margin: 0 auto; position: relative; }
html:not(.tour-on) .tour-pose:not(.tour-pose--hello), html:not(.tour-on) .tour-bubble, html:not(.tour-on) .tour-intro { display: none; }
html:not(.tour-on) .tour-pose--hello { opacity: 1; animation: none; }
html:not(.tour-on) .tour-card { transform: none; opacity: 1; }

/* The site assistant wears the mascot when the site has one (assistant.js, data-mascot): its face and a bubble. */
.aca-launcher--mascot { position: relative; height: auto; padding: 0; border-radius: 0; background: none; box-shadow: none; color: var(--ink); }
.aca-launcher--mascot:hover { background: none; }
.aca-launcher--mascot img { display: block; width: 76px; height: 88px; object-fit: contain; filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--ink) 22%, transparent)); animation: tour-bob 3.2s ease-in-out infinite; }
.aca-launcher--mascot span { position: absolute; right: 70px; bottom: 58px; padding: 7px 12px; border-radius: 14px 14px 4px 14px; background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow-hover); font-size: var(--fs-14); font-weight: 700; white-space: nowrap; }
.aca.is-open .aca-launcher--mascot span { display: none; }
@media (prefers-reduced-motion: reduce) { .tour-pose, .aca-launcher--mascot img { animation: none; } }

/* The home's shelf of diagrams (partials/diagram_shelf.html): topic tabs, then one row of cards per topic that
   scrolls sideways (the related-posts scroller); without script every topic shows under its own heading. */
.dg-shelf-lead { margin-top: var(--s-8); color: var(--muted); }
.dg-tabs { display: none; }
.dg-shelf.dg-js .dg-tabs { display: flex; gap: 8px; margin-bottom: var(--s-16); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.dg-tabs::-webkit-scrollbar { display: none; }
.dg-tab { flex: none; padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--muted); font: inherit; font-size: var(--fs-14); font-weight: 700; cursor: pointer; }
.dg-tab:hover { border-color: var(--accent); color: var(--accent); }
.dg-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.dg-panel + .dg-panel { margin-top: var(--s-32); }
.dg-shelf.dg-js .dg-panel + .dg-panel { margin-top: 0; }
.dg-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-16); margin-bottom: var(--s-12); }
.dg-topic-name { font-size: var(--fs-20); }
.dg-topic-name a:hover { color: var(--accent); }
.dg-shelf.dg-js .dg-topic-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dg-shelf.dg-js .dg-panel-head { justify-content: flex-end; margin-bottom: var(--s-8); }
.dg-track { grid-auto-columns: 200px; gap: var(--s-16); list-style: none; margin: 0; padding: 0; }
.dg-card a { display: flex; flex-direction: column; height: 100%; border: 1px solid var(--line); border-radius: var(--r-12); background: var(--bg); overflow: hidden; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.dg-card a:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); }
.dg-art { display: block; aspect-ratio: 1; background: var(--panel); padding: 6px; }
.dg-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.dg-see-all { margin-left: 8px; color: var(--accent); font-weight: 700; white-space: nowrap; }

.dg-name { margin: 10px 12px 2px; font-weight: 800; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dg-meta { margin: auto 12px 10px; font-size: var(--fs-14); color: var(--faint); }
@media (max-width: 639px) { .dg-track { grid-auto-columns: 44%; gap: var(--s-12); } .dg-shelf .related-nav { display: none; } }
@media (min-width: 1024px) { .footer-grid:has(> :nth-child(5)) { grid-template-columns: minmax(0, 1.2fr) minmax(0, .9fr) minmax(0, .8fr) minmax(0, 1.1fr) minmax(0, 1.1fr); gap: var(--s-32); } }
.footer-disclaimer { padding-bottom: var(--s-16); font-size: var(--fs-14); line-height: 1.7; color: var(--muted); }

/* Tools overview (templates/tools.html), a map-search screen: two panes fill the window under the header, the left
   (heading, topic filter, tool list) scrolls on its own, the right shows the chosen diagram large. A narrow screen
   stacks heading, filter, diagram, list. */
.tools-layout { display: grid; grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); border-top: 1px solid var(--line); }
.tools-side { overflow-y: auto; padding: var(--s-24) var(--s-16) var(--s-32) var(--s-24); border-right: 1px solid var(--line); background: var(--bg); }
.tools-head { margin-bottom: var(--s-16); }
.tools-title { font-size: var(--fs-24); line-height: 1.3; }
.tools-intro { margin-top: 6px; font-size: var(--fs-14); color: var(--muted); }
.tools-filter { display: grid; gap: 8px; margin-bottom: var(--s-16); }
.tools-topics, .tools-subtopics { display: flex; flex-wrap: wrap; gap: 6px; }
.tools-subtopics { padding: 8px; border-radius: var(--r-8); background: var(--panel); }
.tools-subtopics[hidden] { display: none; }
.tools-topic { flex: none; white-space: nowrap; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink); font: inherit; font-size: var(--fs-14); font-weight: 700; cursor: pointer; }
.tools-topic span { color: var(--faint); font-weight: 600; }
.tools-topic--sub { font-weight: 500; }
.tools-topic:hover { border-color: var(--accent); }
.tools-topic[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tools-topic[aria-pressed="true"] span { color: inherit; opacity: .8; }
.tools-list { display: grid; gap: var(--s-16); }
.tools-group[hidden] { display: none; }
.tools-group-title { margin: 0 0 8px; font-size: var(--fs-14); font-weight: 800; color: var(--muted); }
.tools-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tools-diagram-title { margin: 0 0 4px; font-size: var(--fs-24); font-weight: 800; line-height: 1.3; color: var(--ink); }
.tools-item a { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-12); background: var(--bg); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.tools-item a:hover { border-color: var(--accent); }
.tools-item.is-on a { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tools-art { display: block; width: 72px; height: 72px; border-radius: var(--r-8); background: var(--panel); padding: 4px; }
.tools-lead { font-size: var(--fs-14); color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tools-text { display: grid; gap: 2px; min-width: 0; }
.tools-text .dg-name, .tools-text .dg-meta { margin: 0; }
.tools-viewer { overflow-y: auto; padding: var(--s-24) clamp(16px, 4vw, 64px); background: var(--panel); }
.tools-stage { max-width: 860px; margin: 0 auto; }
.tools-stage > section { margin: 0; }
.tools-stage svg[class$="-svg"] { max-width: min(640px, 100%, calc(100dvh - var(--header-h) - 300px)); }
.tools-read { max-width: 860px; margin: var(--s-12) auto 0; font-weight: 700; }
.tools-read a { color: var(--accent); }
/* A wide screen: the explanation cards beside the diagram instead of under it, so the pane is used. */
@media (min-width: 1600px) {
  .tools-stage, .tools-read { max-width: 1400px; }
  .tools-stage > section { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); column-gap: var(--s-32); align-items: start; }
  .tools-stage > section > * { grid-column: 1 / -1; }
  .tools-stage > section > [class$="-fig"] { grid-column: 1; grid-row: 3; }
  .tools-stage > section > [class$="-foot"] { grid-column: 1; grid-row: 4; }
  .tools-stage > section > [class$="-cards"] { grid-column: 2; grid-row: 3 / span 2; margin-top: 0; }
}
@media (max-width: 1023px) {
  .tools-layout { display: flex; flex-direction: column; height: auto; border-top: 0; }
  .tools-side { display: contents; }
  .tools-head { order: 1; padding: var(--s-24) var(--gutter) 0; margin: 0; }
  .tools-filter { order: 2; margin: 0; padding: var(--s-12) var(--gutter) 0; }
  .tools-topics, .tools-subtopics { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tools-topics::-webkit-scrollbar, .tools-subtopics::-webkit-scrollbar { display: none; }
  .tools-viewer { order: 3; overflow: visible; margin-top: var(--s-12); padding: var(--s-12) var(--gutter); }
  .tools-stage svg[class$="-svg"] { max-width: 100%; }
  .tools-list { order: 4; padding: var(--s-16) var(--gutter) var(--s-32); }
}

/* Entries to the tools page: a card at a post's top left (picture + button, a compact row on narrow screens), a banner
   at the top of the home, a button on the tour's first screen. */
.tools-entry { position: relative; display: block; margin-bottom: var(--s-16); border: 1px solid var(--line); border-radius: var(--r-12); background: var(--panel); overflow: hidden; color: var(--accent); }
.tools-entry-art { display: block; height: 96px; padding: 8px; background: var(--accent-soft); }
.tools-entry-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tools-entry-btn { position: relative; display: block; margin: -18px 12px 12px; padding: 8px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--accent); box-shadow: var(--shadow-hover); font-size: var(--fs-14); font-weight: 800; line-height: 1.35; text-align: center; }
.tools-entry:hover .tools-entry-btn { background: var(--accent); color: #fff; }
.tools-entry--inline { display: none; }
@media (max-width: 1279px) {
  .tools-entry--inline { display: flex; align-items: center; gap: 10px; margin: 4px 0 var(--s-12); padding: 6px 12px 6px 6px; border-color: var(--accent); background: var(--accent-soft); border-radius: 999px; }
  .tools-entry--inline .tools-entry-art { width: 40px; height: 40px; padding: 2px; border-radius: 50%; background: var(--bg); }
  .tools-entry--inline .tools-entry-btn { margin: 0; padding: 0; border: 0; background: none; box-shadow: none; text-align: left; }
}
.tools-banner { margin-top: var(--s-24); }
.tools-banner-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-24); align-items: center; padding: var(--s-16) var(--s-24); border: 1px solid var(--line); border-radius: var(--r-12); background: linear-gradient(120deg, var(--accent-soft), var(--panel)); color: var(--ink); }
.tools-banner-art { display: flex; }
.tools-banner-art img { width: 72px; height: 72px; margin-left: -18px; padding: 4px; border-radius: 50%; background: var(--bg); border: 2px solid var(--bg); box-shadow: 0 2px 8px color-mix(in srgb, var(--ink) 12%, transparent); }
.tools-banner-art img:first-child { margin-left: 0; }
.tools-banner-title { display: block; font-size: var(--fs-20); font-weight: 800; }
.tools-banner-lead { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-14); }
.tools-banner-btn { padding: 10px 18px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 800; white-space: nowrap; }
.tools-banner-link:hover .tools-banner-btn { filter: brightness(1.1); }
@media (max-width: 639px) {
  .tools-banner-link { grid-template-columns: minmax(0, 1fr); gap: var(--s-12); padding: var(--s-16); }
  .tools-banner-art img { width: 56px; height: 56px; }
  .tools-banner-btn { justify-self: start; }
}
.tour-tools { display: inline-block; margin-top: 14px; padding: 9px 18px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 800; box-shadow: var(--shadow-hover); }
.tour-topics .tools-banner { width: auto; margin: var(--s-16) 0 0; }
.tour-topics .tools-banner-link { padding: 12px 16px; gap: var(--s-16); }
.tour-topics .tools-banner-lead { display: none; }
.tour-topics .tools-banner-art img { width: 52px; height: 52px; margin-left: -14px; }
.tour-topics .tools-banner-art img:first-child { margin-left: 0; }
@media (max-width: 639px) {
  .tour-topics .tools-banner { margin-top: var(--s-12); }
  .tour-topics .tools-banner-link { grid-template-columns: auto minmax(0, 1fr); padding: 10px 12px; gap: 10px; }
  .tour-topics .tools-banner-art img { width: 40px; height: 40px; margin-left: -12px; }
  .tour-topics .tools-banner-art img:nth-child(n+4) { display: none; }
  .tour-topics .tools-banner-title { font-size: var(--fs-16); }
  .tour-topics .tools-banner-btn { grid-column: 1 / -1; justify-self: stretch; text-align: center; padding: 8px 14px; }
  .aca-launcher--mascot span { display: none; }
}
