:root {
  --bg: #f7f6f2;
  --panel: #ffffff;
  --ink: #1d252c;
  --muted: #63717c;
  --line: #d9ded8;
  --accent: #225c58;
  --accent-2: #7d5330;
  --code-bg: #eef2f0;
  --sidebar: #edf1ee;
  --shadow: 0 14px 34px rgba(24, 35, 45, 0.08);
  font-family: "Segoe UI", "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.72;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(34, 92, 88, 0.26);
}

a:hover { border-bottom-color: var(--accent); }

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand {
  margin-bottom: 20px;
  color: #142027;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.3;
}

.nav-section { margin: 22px 0; }

.nav-section h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-section a {
  display: block;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  color: #26343d;
  font-size: 14px;
  line-height: 1.35;
}

.nav-section a:hover,
.nav-section a.active {
  background: rgba(34, 92, 88, 0.11);
  color: var(--accent);
}

.content-shell {
  min-width: 0;
  padding: 36px 44px 80px;
}

.content-shell.has-page-toc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 24px;
  align-items: start;
}

.content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.content-shell.has-page-toc .content {
  max-width: none;
  margin: 0;
}

.page-title {
  margin: 0 0 18px;
  color: #142027;
  font-size: 30px;
  line-height: 1.25;
  font-weight: 760;
}

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px 18px;
  margin: 0 0 26px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  color: var(--muted);
  font-size: 14px;
}

.meta b { color: #33414a; }

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -6px 0 22px;
}

.page-action-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(34, 92, 88, 0.24);
  border-radius: 6px;
  background: #eef4f1;
  color: var(--accent);
  font-size: 14px;
  font-weight: 720;
}

.page-action-button:hover {
  border-color: rgba(34, 92, 88, 0.52);
  background: #e4efeb;
}

.proof-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  margin-top: 8px;
  padding: 5px 10px;
  border: 1px solid rgba(34, 92, 88, 0.24);
  border-radius: 6px;
  background: #eef4f1;
  color: var(--accent);
  font-size: 13px;
  font-weight: 720;
}

.proof-link:hover {
  border-color: rgba(34, 92, 88, 0.5);
  background: #e3eeea;
}

.proof-target-flash {
  animation: proofTargetFlash 1.4s ease;
}

@keyframes proofTargetFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(194, 116, 48, 0.42);
  }
  35% {
    box-shadow: 0 0 0 5px rgba(194, 116, 48, 0.16);
  }
  100% {
    box-shadow: none;
  }
}

.toc-sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.page-toc {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf8;
}

.page-toc-title {
  margin: 0 0 8px;
  color: #33414a;
  font-size: 14px;
  font-weight: 700;
}

.page-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-toc li { margin: 0; }

.page-toc a {
  border-bottom: 0;
  color: var(--accent);
  font-size: 14px;
}

.page-toc .toc-level-2 { padding-left: 14px; }
.page-toc .toc-level-2 a {
  color: var(--muted);
  font-size: 13px;
}

h1, h2, h3, h4 {
  color: #142027;
  line-height: 1.34;
}

h1 {
  margin-top: 34px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 28px;
}

h2 {
  margin-top: 30px;
  font-size: 22px;
}

h3 {
  margin-top: 24px;
  font-size: 18px;
}

p, ul, ol, table, pre, blockquote { margin: 12px 0; }

table {
  width: 100%;
  border-collapse: collapse;
  overflow-wrap: anywhere;
  font-size: 14px;
}

th, td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: #eef3f1;
  font-weight: 680;
}

code {
  padding: 0.12em 0.3em;
  border-radius: 4px;
  background: var(--code-bg);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  padding: 14px 16px;
  border: 1px solid #d8ded8;
  border-left: 4px solid rgba(34, 92, 88, 0.55);
  border-radius: 8px;
  background: #f7faf8;
  color: #24313a;
  line-height: 1.62;
}

pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 0.94em;
}

blockquote {
  margin-left: 0;
  padding: 10px 16px;
  border-left: 4px solid var(--accent-2);
  background: #fbf8f4;
  color: #384852;
}

.concept-map {
  margin: 18px 0 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfbf8 0%, #f3f6f4 100%);
}

.concept-root {
  padding: 18px 20px;
  border: 1px solid rgba(34, 92, 88, 0.18);
  border-radius: 8px;
  background: #ffffff;
}

.concept-root-title {
  color: #142027;
  font-size: 24px;
  font-weight: 780;
  line-height: 1.25;
}

.concept-root-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

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

.concept-card {
  position: relative;
  min-height: 210px;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.concept-card.wide {
  grid-column: 1 / -1;
  min-height: 0;
}

.concept-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 26px;
  border-radius: 999px;
  background: rgba(34, 92, 88, 0.10);
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
}

.concept-card h2 {
  margin: 12px 0 8px;
  border: 0;
  padding: 0;
  font-size: 19px;
}

.concept-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.concept-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.concept-card li {
  margin: 4px 0;
}

.concept-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.concept-tags span {
  padding: 5px 9px;
  border: 1px solid rgba(34, 92, 88, 0.18);
  border-radius: 999px;
  background: #f8faf8;
  color: #2d4549;
  font-size: 13px;
}

.matrix-concept-map {
  margin: 18px 0 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.matrix-map-core {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.matrix-map-question {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 150px;
  padding: 18px;
  border: 1px solid rgba(34, 92, 88, 0.22);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
}

.matrix-map-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

.matrix-map-question strong {
  display: block;
  margin-top: 8px;
  color: #142027;
  font-size: 22px;
  line-height: 1.28;
}

.matrix-map-question span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.matrix-map-thesis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.matrix-map-thesis-item {
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.matrix-map-thesis-item b {
  display: block;
  color: #142027;
  font-size: 15px;
}

.matrix-map-thesis-item span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.52;
}

.matrix-map-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.matrix-map-stage {
  position: relative;
  min-height: 270px;
  padding: 14px 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.matrix-map-stage::after {
  content: "";
  position: absolute;
  top: 42px;
  right: -10px;
  width: 18px;
  height: 18px;
  border-top: 2px solid rgba(34, 92, 88, 0.32);
  border-right: 2px solid rgba(34, 92, 88, 0.32);
  transform: rotate(45deg);
  background: #fbfbf8;
}

.matrix-map-stage:last-child::after {
  display: none;
}

.matrix-map-stage[data-tone="linear"] { border-top: 4px solid #2f5f8f; }
.matrix-map-stage[data-tone="geometry"] { border-top: 4px solid #2f755a; }
.matrix-map-stage[data-tone="probability"] { border-top: 4px solid #8a3d5c; }
.matrix-map-stage[data-tone="application"] { border-top: 4px solid #9b6b23; }

.matrix-map-stage-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.matrix-map-stage h2 {
  margin: 7px 0 10px;
  border: 0;
  padding: 0;
  color: #142027;
  font-size: 18px;
}

.matrix-map-stage ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.matrix-map-stage li {
  margin: 8px 0;
  padding: 9px 10px;
  border: 1px solid rgba(217, 222, 216, 0.9);
  border-radius: 6px;
  background: #f8faf8;
  color: #26343d;
  font-size: 14px;
  line-height: 1.45;
}

.matrix-map-stage li b {
  color: #142027;
}

.matrix-map-apps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.matrix-map-app {
  padding: 12px 14px;
  border: 1px solid rgba(34, 92, 88, 0.16);
  border-radius: 8px;
  background: #f7faf8;
}

.matrix-map-app b {
  display: block;
  color: #142027;
  font-size: 14px;
}

.matrix-map-app span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.beginner-map {
  margin: 18px 0 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.beginner-map-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.76fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.beginner-map-main {
  padding: 18px 20px;
  border: 1px solid rgba(34, 92, 88, 0.22);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
}

.beginner-map-main .eyebrow,
.beginner-map-side .eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

.beginner-map-main strong {
  display: block;
  margin-top: 8px;
  color: #142027;
  font-size: 24px;
  line-height: 1.25;
}

.beginner-map-main p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.62;
}

.beginner-map-side {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.beginner-map-side ol {
  margin: 10px 0 0;
  padding-left: 20px;
}

.beginner-map-side li {
  margin: 7px 0;
  color: #26343d;
  font-size: 14px;
  line-height: 1.45;
}

.beginner-map-route {
  display: grid;
  gap: 12px;
}

.beginner-step {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) minmax(210px, 0.56fr);
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.beginner-step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #eef4f1;
  color: var(--accent);
  font-size: 24px;
  font-weight: 780;
}

.beginner-step-body h2 {
  margin: 0 0 7px;
  border: 0;
  padding: 0;
  color: #142027;
  font-size: 19px;
}

.beginner-step-body p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.56;
}

.beginner-step-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.beginner-step-tags span {
  padding: 4px 8px;
  border: 1px solid rgba(34, 92, 88, 0.16);
  border-radius: 999px;
  background: #f8faf8;
  color: #2d4549;
  font-size: 13px;
}

.beginner-step-focus {
  padding: 12px 14px;
  border-radius: 8px;
  background: #f7faf8;
  color: #26343d;
  font-size: 14px;
  line-height: 1.52;
}

.beginner-step-focus b {
  display: block;
  margin-bottom: 4px;
  color: #142027;
}

.beginner-map-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed rgba(34, 92, 88, 0.26);
  border-radius: 8px;
  background: #ffffff;
}

.beginner-map-chain span {
  padding: 5px 9px;
  border-radius: 6px;
  background: #eef4f1;
  color: #26343d;
  font-size: 13px;
}

.beginner-map-chain .arrow {
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.theorem-box,
.semantic-card {
  --card-accent: #225c58;
  --card-border: rgba(34, 92, 88, 0.24);
  --card-bg: #fbfdfb;
  --card-head-bg: rgba(34, 92, 88, 0.08);
  --card-head-border: rgba(34, 92, 88, 0.16);
  --card-uses-border: rgba(34, 92, 88, 0.22);
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-left: 5px solid var(--card-accent);
  border-radius: 8px;
  background: var(--card-bg);
}

.theorem-box.definition,
.semantic-card.definition {
  --card-accent: #2f5f8f;
  --card-border: rgba(47, 95, 143, 0.24);
  --card-bg: #f5f9ff;
  --card-head-bg: rgba(47, 95, 143, 0.08);
  --card-head-border: rgba(47, 95, 143, 0.16);
  --card-uses-border: rgba(47, 95, 143, 0.22);
}

.theorem-box.theorem,
.semantic-card.theorem {
  --card-accent: #8a3d5c;
  --card-border: rgba(138, 61, 92, 0.24);
  --card-bg: #fff7fa;
  --card-head-bg: rgba(138, 61, 92, 0.08);
  --card-head-border: rgba(138, 61, 92, 0.16);
  --card-uses-border: rgba(138, 61, 92, 0.22);
}

.theorem-box.proposition,
.semantic-card.proposition {
  --card-accent: #6f4f91;
  --card-border: rgba(111, 79, 145, 0.24);
  --card-bg: #faf7ff;
  --card-head-bg: rgba(111, 79, 145, 0.08);
  --card-head-border: rgba(111, 79, 145, 0.16);
  --card-uses-border: rgba(111, 79, 145, 0.22);
}

.theorem-box.lemma,
.semantic-card.lemma {
  --card-accent: #9b6b23;
  --card-border: rgba(155, 107, 35, 0.26);
  --card-bg: #fffaf0;
  --card-head-bg: rgba(155, 107, 35, 0.09);
  --card-head-border: rgba(155, 107, 35, 0.17);
  --card-uses-border: rgba(155, 107, 35, 0.24);
}

.theorem-box.corollary,
.semantic-card.corollary {
  --card-accent: #2f755a;
  --card-border: rgba(47, 117, 90, 0.24);
  --card-bg: #f5fbf7;
  --card-head-bg: rgba(47, 117, 90, 0.08);
  --card-head-border: rgba(47, 117, 90, 0.16);
  --card-uses-border: rgba(47, 117, 90, 0.22);
}

.theorem-box.example,
.semantic-card.example {
  --card-accent: #2f6f8a;
  --card-border: rgba(47, 111, 138, 0.24);
  --card-bg: #f4fbfd;
  --card-head-bg: rgba(47, 111, 138, 0.08);
  --card-head-border: rgba(47, 111, 138, 0.16);
  --card-uses-border: rgba(47, 111, 138, 0.22);
}

.theorem-box.proof,
.semantic-card.proof {
  --card-accent: #68737d;
  --card-border: rgba(104, 115, 125, 0.26);
  --card-bg: #f8faf9;
  --card-head-bg: rgba(104, 115, 125, 0.09);
  --card-head-border: rgba(104, 115, 125, 0.18);
  --card-uses-border: rgba(104, 115, 125, 0.24);
}

.theorem-box.exercise,
.semantic-card.exercise {
  --card-accent: #7a5d21;
  --card-border: rgba(122, 93, 33, 0.25);
  --card-bg: #fffaf1;
  --card-head-bg: rgba(122, 93, 33, 0.09);
  --card-head-border: rgba(122, 93, 33, 0.18);
  --card-uses-border: rgba(122, 93, 33, 0.24);
}

.theorem-box.remark,
.semantic-card.remark {
  --card-accent: #5f6872;
  --card-border: rgba(95, 104, 114, 0.25);
  --card-bg: #f8faf9;
  --card-head-bg: rgba(95, 104, 114, 0.08);
  --card-head-border: rgba(95, 104, 114, 0.17);
  --card-uses-border: rgba(95, 104, 114, 0.22);
}

.theorem-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  padding: 11px 14px;
  border-bottom: 1px solid var(--card-head-border);
  background: var(--card-head-bg);
}

.proof-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--card-head-border);
  background: rgba(255, 255, 255, 0.58);
  color: #52616a;
  font-size: 12.5px;
  line-height: 1.45;
}

.proof-status-label {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid rgba(104, 115, 125, 0.28);
  border-radius: 999px;
  background: #ffffff;
  color: #26343d;
  font-weight: 760;
}

.proof-status.complete .proof-status-label {
  border-color: rgba(47, 117, 90, 0.28);
  color: #2f755a;
}

.proof-status.skeleton .proof-status-label {
  border-color: rgba(125, 83, 48, 0.30);
  color: #7d5330;
}

.proof-status.dependent .proof-status-label {
  border-color: rgba(47, 111, 138, 0.30);
  color: #2f6f8a;
}

.proof-status.review .proof-status-label {
  border-color: rgba(133, 61, 68, 0.30);
  color: #853d44;
}

.theorem-kind {
  color: var(--card-accent);
  font-size: 13px;
  font-weight: 780;
}

.theorem-title {
  color: #142027;
  font-size: 16px;
  font-weight: 720;
}

.theorem-body {
  padding: 13px 16px 15px;
}

.theorem-body p:first-child {
  margin-top: 0;
}

.theorem-body p:last-child {
  margin-bottom: 0;
}

.content mjx-container[display="true"],
.paired-pane-scroll mjx-container[display="true"],
.formula-container {
  display: block;
  width: 100%;
  overflow: visible;
  margin: 14px 0;
  padding: 13px 18px;
  border: 1px solid var(--card-head-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.64);
  text-align: center;
}

.content mjx-container[jax="SVG"][display="true"] > svg,
.paired-pane-scroll mjx-container[jax="SVG"][display="true"] > svg,
.formula-container mjx-container[jax="SVG"] > svg {
  max-width: 100%;
  height: auto;
  overflow: visible;
}

.theorem-body mjx-container[display="true"] {
  width: calc(100% + 12px);
  margin-left: -6px;
  margin-right: -6px;
}

.formula-container {
  text-align: center;
}

.theorem-uses {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--card-uses-border);
  color: var(--muted);
  font-size: 14px;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.book-figure {
  margin: 20px 0 24px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.book-figure img {
  display: block;
  max-height: 520px;
  margin: 0 auto;
  object-fit: contain;
}

.book-figure figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.book-figure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.book-figure-grid img {
  max-height: 360px;
}

.math.display {
  overflow: visible;
  padding: 0;
}

.footer {
  margin-top: 42px;
  color: var(--muted);
  font-size: 13px;
}

.paired-reading-shell {
  min-width: 0;
  padding: 24px 28px 42px;
}

.paired-reader-header {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.paired-reader-title {
  color: #142027;
  font-size: 20px;
  font-weight: 760;
  line-height: 1.3;
}

.paired-reader-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.paired-reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.paired-toc-menu {
  position: relative;
}

.paired-toc-summary {
  cursor: pointer;
  list-style: none;
}

.paired-toc-summary::-webkit-details-marker {
  display: none;
}

.paired-toc-summary::after {
  content: "▾";
  margin-left: 8px;
  color: rgba(34, 92, 88, 0.78);
  font-size: 12px;
}

.paired-toc-menu[open] .paired-toc-summary {
  border-color: rgba(34, 92, 88, 0.52);
  background: #e4efeb;
}

.paired-toc-menu[open] .paired-toc-summary::after {
  content: "▴";
}

.paired-toc-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(380px, calc(100vw - 42px));
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(28, 38, 45, 0.16);
}

.paired-toc-title {
  padding: 4px 7px 8px;
  color: #142027;
  font-size: 13px;
  font-weight: 760;
}

.paired-toc-list {
  display: grid;
  gap: 2px;
}

.paired-toc-link {
  display: block;
  padding: 7px 8px;
  border-radius: 6px;
  color: #283940;
  font-size: 13px;
  line-height: 1.35;
}

.paired-toc-link:hover {
  background: #eef4f1;
  color: var(--accent);
}

.paired-toc-level-2 {
  padding-left: 22px;
  color: #52636a;
  font-size: 12.5px;
}

.paired-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.paired-pane {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.paired-pane-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: #f9faf8;
}

.paired-pane-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

.paired-pane-title {
  color: #142027;
  font-size: 15px;
  font-weight: 720;
}

.paired-pane-scroll {
  height: calc(100vh - 168px);
  overflow: auto;
  padding: 26px 30px 40px;
}

.paired-pane-scroll .page-title {
  font-size: 24px;
}

.paired-pane-scroll h1 {
  font-size: 24px;
}

.paired-pane-scroll h2 {
  font-size: 20px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .content-shell,
  .content-shell.has-page-toc {
    display: block;
    padding: 22px 16px 56px;
  }
  .content {
    padding: 24px 20px;
  }
  .content,
  .paired-pane-scroll {
    max-width: 100%;
    overflow-x: hidden;
  }
  .content table,
  .paired-pane-scroll table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
  .content mjx-container[display="true"],
  .paired-pane-scroll mjx-container[display="true"],
  .formula-container {
    padding: 11px 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .theorem-body mjx-container[display="true"] {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  .concept-grid {
    grid-template-columns: 1fr;
  }
  .concept-card {
    min-height: 0;
  }
  .matrix-map-core,
  .matrix-map-thesis,
  .matrix-map-flow,
  .matrix-map-apps {
    grid-template-columns: 1fr;
  }
  .matrix-map-stage {
    min-height: 0;
  }
  .matrix-map-stage::after {
    display: none;
  }
  .beginner-map-hero,
  .beginner-step {
    grid-template-columns: 1fr;
  }
  .beginner-step-number {
    width: 52px;
    height: 42px;
  }
  .book-figure-grid {
    grid-template-columns: 1fr;
  }
  .toc-sidebar { display: none; }
  .page-title { font-size: 25px; }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .paired-reading-shell {
    padding: 18px 14px 42px;
  }
  .layout.paired-layout {
    display: block;
  }
  .paired-layout .sidebar {
    display: none;
  }
  .paired-toc-panel {
    position: fixed;
    top: 146px;
    left: 14px;
    right: 14px;
    width: auto;
    max-height: calc(100vh - 168px);
  }
  .paired-grid {
    grid-template-columns: 1fr;
  }
  .paired-pane-scroll {
    height: auto;
    max-height: none;
  }
}
