:root {
  --bg: #f3eee4;
  --bg-deep: #ebe4d6;
  --paper: #fffdf8;
  --ink: #1c1712;
  --muted: #6a6157;
  --faint: #8a8074;
  --line: #ddd2c2;
  --line-strong: #c9bba8;
  --accent: #b44512;
  --accent-hover: #8f350c;
  --accent-soft: #f6e4d6;
  --accent-wash: #faf0e8;
  --navy: #1e3f63;
  --navy-hover: #142c47;
  --ok: #1f5c38;
  --ok-bg: #e6f3ea;
  --warn: #8a5a10;
  --warn-bg: #f8eed8;
  --chip: #efe6d8;
  --shadow: 0 1px 2px rgba(28, 23, 18, .06), 0 8px 24px rgba(28, 23, 18, .05);
  --header-h: 56px;
  --sans: "Noto Sans TC", "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  --serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "SF Mono", "IBM Plex Mono", "Source Code Pro", ui-monospace, Menlo, Consolas, monospace;
  --measure: 44rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, #f8e8d6 0%, transparent 50%),
    var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100;
}
.skip:focus { left: 8px; top: 8px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 253, 248, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
}
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  color: inherit; text-decoration: none; flex-shrink: 0;
}
.brand .mark {
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  font-size: 15px;
}
.brand .sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}
.nav a:hover { background: var(--accent-soft); color: var(--accent); }
.nav a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
}

/* Layout */
.wrap { max-width: 1200px; margin: 0 auto; padding: 28px 20px 80px; }
.narrow { max-width: var(--measure); }

/* Hero */
.hero { margin: 8px 0 32px; max-width: 46rem; }
.hero .kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -.02em;
}
.hero .lead { font-size: 1.05rem; color: #3a332c; margin: 0 0 14px; }
.meta-line { color: var(--muted); font-size: 13px; margin: 0; }

.notice, .warn-banner, .note-box {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 16px 0 24px;
  font-size: 14px;
}
.notice { background: var(--accent-wash); border: 1px solid #ead3bf; }
.warn-banner { background: var(--warn-bg); border: 1px solid #e6d2a4; color: #5c3d0a; }
.note-box { background: #f7f4ee; border: 1px solid var(--line); color: var(--muted); }

/* Search / chips */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin: 8px 0 28px;
}
.search {
  flex: 1 1 240px;
  position: relative;
}
.search input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: 8px;
  padding: 9px 12px 9px 34px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.search .icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none; font-size: 14px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Groups & cards */
.group { margin: 0 0 40px; }
.group h2 {
  font-family: var(--serif);
  font-size: 1.25rem;
  margin: 0 0 6px;
  display: flex; align-items: baseline; gap: 10px;
}
.group h2 .count { font-family: var(--sans); font-size: 13px; color: var(--muted); font-weight: 500; }
.group .desc { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
a.card:hover { transform: translateY(-2px); border-color: #c99570; color: inherit; }
.card .top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 12px; letter-spacing: 0;
  flex-shrink: 0;
}
.card.main-read .num { background: var(--accent); color: #fff; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: auto;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.partial { background: var(--warn-bg); color: var(--warn); }
.card h3 {
  font-size: 1.02rem;
  line-height: 1.4;
  margin: 0 0 6px;
  font-weight: 700;
}
.card .by { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.card .thesis { font-size: 14px; color: #3a332c; margin: 0 0 12px; flex: 1; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 11px;
  background: var(--chip);
  color: #5a4c3c;
  border-radius: 4px;
  padding: 1px 6px;
}
.hidden { display: none !important; }
.empty-filter { color: var(--muted); padding: 24px 0; }

/* Compare matrix */
.compare-intro { max-width: 46rem; margin-bottom: 20px; }
.matrix-wrap {
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 160px);
}
table.matrix {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  line-height: 1.5;
  min-width: 1400px;
  width: 100%;
}
.matrix th, .matrix td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 9px;
  vertical-align: top;
  background: var(--paper);
}
.matrix thead th {
  position: sticky; top: 0; z-index: 3;
  background: #f7f0e6;
  font-weight: 700;
  text-align: left;
  font-size: 12px;
  box-shadow: 0 1px 0 var(--line);
}
.matrix tbody th {
  position: sticky; left: 0; z-index: 2;
  background: #fbf7f0;
  min-width: 168px;
  max-width: 200px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 1px 0 0 var(--line);
}
.matrix thead th:first-child {
  left: 0; z-index: 4;
  min-width: 168px;
}
.matrix td { min-width: 148px; max-width: 200px; }
.matrix a.cell {
  display: block;
  color: inherit;
  text-decoration: none;
  color: #2b241c;
}
.matrix a.cell:hover { color: var(--accent); text-decoration: underline; }
.matrix .blank { color: #c3b8aa; text-align: center; }
.matrix tr:hover td, .matrix tr:hover th { background: #fff8ef; }
.matrix .art-num { display: block; font-size: 10px; color: var(--accent); font-weight: 700; letter-spacing: .04em; }

/* Schools comparison */
.schools { margin-top: 48px; }
.schools h2, .article-page h2, .group h2, .principles h2 {
  font-family: var(--serif);
}
.schools table, .prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  margin: 12px 0 20px;
  background: var(--paper);
}
.schools th, .schools td, .prose th, .prose td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
}
.schools th, .prose th { background: #f7f0e6; text-align: left; }

.mermaid {
  margin: 16px 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
}
.cap { font-size: 13px; color: var(--muted); margin: -4px 0 20px; }

/* Article page */
.article-page { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 1040px) {
  .article-page { grid-template-columns: minmax(0, var(--measure)) 220px; align-items: start; }
  .toc-side { position: sticky; top: calc(var(--header-h) + 16px); }
}
.crumb { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.crumb a { color: var(--muted); }
.article-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.3;
  margin: 0 0 10px;
}
.dl {
  display: grid;
  grid-template-columns: 6.5em 1fr;
  gap: 4px 12px;
  font-size: 13px;
  margin: 12px 0 16px;
}
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.dl dd a { word-break: break-all; }

.thesis-box {
  background: var(--paper);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  margin: 0 0 18px;
  box-shadow: var(--shadow);
}
.thesis-box strong { color: var(--accent); }

.summary-block {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 22px;
}
.summary-block h2 { font-size: 1rem; margin: 0 0 8px; }
.summary-block p { margin: 0 0 8px; font-size: 15px; }
.summary-block p:last-child { margin-bottom: 0; }

.body-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent);
  margin: 28px 0 10px;
  text-transform: uppercase;
}

.prose {
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.85;
  color: #211c16;
}
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--serif);
  line-height: 1.35;
  margin: 1.6em 0 .5em;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.1rem; }
.prose p { margin: 0 0 0.95em; }
.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}
.prose img + em, .prose img + p em { display: block; text-align: center; color: var(--muted); font-size: 13px; font-family: var(--sans); }
.prose blockquote {
  margin: 1em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
  color: #3e352c;
}
.prose code {
  font-family: var(--mono);
  font-size: .86em;
  background: #f3eee6;
  padding: 0 4px;
  border-radius: 4px;
}
.prose pre {
  background: #211c16;
  color: #f4efe6;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  font-family: var(--mono);
}
.prose pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .25em 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose a.anchor-target { scroll-margin-top: calc(var(--header-h) + 16px); }
span.concept-anchor {
  display: block;
  height: 0;
  scroll-margin-top: calc(var(--header-h) + 18px);
}
span.concept-anchor:target + *,
span.concept-anchor:target {
  /* highlight the following block via adjacent if possible */
}
.flash-target:target,
.prose h2:target, .prose h3:target, .prose h4:target {
  background: #fff3c4;
  outline: 3px solid #f0d36a;
  outline-offset: 4px;
}

/* When jumping to a concept anchor, tint the next paragraph */
span.concept-anchor:target + * {
  background: #fff3c4;
  outline: 3px solid #f0d36a;
  outline-offset: 6px;
  border-radius: 4px;
}

.toc-side {
  font-size: 13px;
  color: var(--muted);
}
.toc-side h2 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; font-family: var(--sans); }
.toc-side ul { list-style: none; padding: 0; margin: 0; }
.toc-side li { margin: 0 0 4px; }
.toc-side a { color: var(--muted); text-decoration: none; }
.toc-side a:hover { color: var(--accent); }
.pager {
  display: flex; justify-content: space-between; gap: 12px;
  margin: 36px 0 0;
  font-size: 14px;
  font-family: var(--sans);
}
.pager a { text-decoration: none; border: 1px solid var(--line); background: var(--paper); padding: 8px 12px; border-radius: 8px; }
.pager a:hover { border-color: var(--accent); }

details.manual {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  margin: 16px 0;
  padding: 0 14px 8px;
}
details.manual > summary {
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 700;
  padding: 12px 0;
  color: var(--navy);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-deep);
  color: var(--muted);
  font-size: 13px;
  padding: 24px 20px 40px;
}
.site-footer .inner { max-width: 1200px; margin: 0 auto; }
.site-footer a { color: var(--navy); }

.principles ol { padding-left: 1.3em; }
.principles li { margin: 8px 0; }

@media (max-width: 700px) {
  .brand .sub { display: none; }
  .nav a { padding: 6px 8px; font-size: 13px; }
  .prose { font-size: 16.5px; }
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl dt { margin-top: 6px; }
  .matrix-wrap { max-height: none; }
}
@media print {
  .site-header, .site-footer, .toolbar, .search, .pager, .toc-side { display: none !important; }
  body { background: #fff; }
  .article-page { display: block; }
  a { color: inherit; text-decoration: none; }
}
