:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #5e6872;
  --line: #d8dee6;
  --panel: #f7f9fb;
  --blue: #1c78c0;
  --green: #2d9a67;
  --orange: #ef8a24;
  --purple: #7c5ac8;
  --rose: #df5a6d;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
  overflow: hidden;
}

body {
  height: 100%;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: #ffffff;
  overflow: hidden;
}

a {
  color: inherit;
}

main {
  width: 100%;
  height: 100vh;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
}

.site-home,
.blog-page {
  display: grid;
  align-content: start;
  padding: 40px;
}

.site-home {
  gap: 28px;
  justify-items: center;
  overflow: auto;
}

.site-title {
  width: 100%;
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
  text-align: center;
}

.site-links {
  display: grid;
  gap: 22px;
  max-width: 720px;
  font-size: 20px;
  line-height: 1.35;
}

.site-links a {
  width: fit-content;
  color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.site-blog-posts {
  display: grid;
  gap: 8px;
}

.site-blog-posts p {
  margin: 0;
  color: var(--muted);
}

.diagram-shell {
  display: grid;
  grid-template-columns: minmax(260px, 20vw) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.diagram-sidebar {
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
}

.sidebar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.sidebar-head h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.sidebar-head span {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  padding: 3px 7px;
  font-size: 12px;
}

.diagram-tree,
.diagram-list {
  display: grid;
}

.diagram-tree {
  gap: 16px;
}

.diagram-tree-group h2 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: lowercase;
}

.diagram-tree-group .diagram-list {
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.diagram-list button {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  padding: 9px 10px;
  text-align: left;
}

.diagram-list button:hover {
  border-color: #b8c3cf;
  border-left-color: var(--blue);
}

.diagram-list button.selected {
  border-color: #a8cbe6;
  border-left-color: var(--blue);
  background: #edf6fd;
}

.item-title,
.item-meta {
  display: block;
}

.item-title {
  font-size: 14px;
  line-height: 1.25;
}

.item-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.diagram-view {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px 32px 46px;
}

.diagram-card {
  max-width: 1320px;
  padding: 0;
}

.card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 16px;
}

h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0;
}

.about-title {
  display: block;
  width: 100%;
  text-align: center;
}

.crossout-replacement {
  display: inline-grid;
  grid-template-rows: 1fr 1fr;
  justify-items: center;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1;
}

.crossout-replacement span {
  color: var(--ink);
  font-size: 0.76em;
  line-height: 1;
}

.crossout-replacement s {
  color: #888;
  font-size: 0.76em;
  line-height: 1;
  text-decoration-thickness: 2px;
}

.meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.svg-wrap {
  width: fit-content;
  overflow: visible;
  border: 1px solid var(--line);
  background: #fff;
}

.svg-wrap svg {
  display: block;
}

.caption {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.entry-article {
  max-width: 900px;
  margin-top: 24px;
  font-size: 15px;
  line-height: 1.6;
}

.entry-article h3 {
  margin: 28px 0 10px;
  font-size: 19px;
  line-height: 1.25;
}

.entry-article h4 {
  margin: 18px 0 8px;
  font-size: 15px;
  line-height: 1.3;
}

.entry-article p,
.entry-article ul {
  margin: 8px 0;
}

.entry-article pre {
  margin: 12px 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: #f7f9fb;
}

.entry-article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.math-comment {
  display: inline-block;
  margin-left: 0.75rem;
  color: #888;
}

.math-display {
  display: block;
  margin: 12px 0;
  overflow: visible;
  text-align: left;
}

.math-display .katex-display {
  margin: 0;
  text-align: left !important;
}

.math-display .katex {
  text-align: left;
}

.rvq-proof-block {
  margin-left: 28px;
}

.extracted-diagrams {
  max-width: 1220px;
}

.extract-system-note {
  color: var(--muted);
}

.extract-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 4px 14px;
  margin: 12px 0 22px;
}

.extract-count-row,
.extract-row {
  display: grid;
  gap: 10px;
  align-items: baseline;
}

.extract-count-row {
  grid-template-columns: minmax(0, 1fr) 48px;
  font-size: 12px;
}

.extract-count-row span {
  color: var(--muted);
  text-align: right;
}

.extract-table {
  display: grid;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.extract-row {
  grid-template-columns: minmax(190px, 0.9fr) 48px minmax(90px, 0.4fr) minmax(260px, 1.8fr);
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.extract-head {
  position: sticky;
  top: -24px;
  z-index: 1;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.extract-row code {
  white-space: normal;
}

.about-monkey-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-inline: auto;
  width: 50%;
}

.about-monkey-art {
  display: block;
  width: 100%;
  height: auto;
  min-width: 0;
}

.about-desk {
  fill: #4e3c31;
}

.about-keyboard {
  fill: #28333a;
}

.about-key {
  fill: #888;
}

.about-active-key {
  fill: #38b66b;
  transform: translateY(2px);
}

.about-tail,
.about-arm {
  fill: none;
  stroke: #7b4e36;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.about-tail {
  stroke-width: 8;
}

.about-arm {
  stroke-width: 11;
}

.about-hand {
  transform-box: view-box;
  transform-origin: 0 0;
  will-change: transform;
}

.about-ear,
.about-head {
  fill: #815338;
}

.about-muzzle,
.about-left-ear,
.about-right-ear {
  fill: #c98f66;
}

.about-hat-back-crown,
.about-hat-front-crown {
  fill: #d6b56a;
  stroke: #8d6b2d;
  stroke-linejoin: round;
  stroke-width: 3;
}

.about-hat-back-brim {
  fill: #e2c676;
  stroke: #8d6b2d;
  stroke-width: 3;
}

.about-hat-front-crown {
  fill: #dec174;
}

.about-hat-rib {
  fill: none;
  stroke: #9c7a36;
  stroke-linecap: round;
  stroke-width: 2;
  opacity: 0.72;
}

.about-forehead-dot {
  fill: #c71922;
  stroke: #f0b0a4;
  stroke-width: 2;
}

.about-eye,
.about-nose {
  fill: #1e211e;
}

.about-smile {
  fill: none;
  stroke: #1e211e;
  stroke-linecap: round;
  stroke-width: 4;
}

.about-finger {
  fill: #c98f66;
}

.about-token-bursts rect {
  opacity: 0.9;
}

.about-accent-leaf .about-token-bursts rect {
  fill: #397f78;
}

.about-accent-coral .about-token-bursts rect {
  fill: #d06a55;
}

.about-accent-gold .about-token-bursts rect {
  fill: #c59d24;
}

.note {
  max-width: 1320px;
  margin: 22px 0 0;
  padding: 14px 16px;
  border-left: 3px solid var(--rose);
  background: #fff7f8;
  color: #6f3039;
  font-size: 14px;
  line-height: 1.55;
}

@media (max-width: 860px) {
  .diagram-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .diagram-sidebar {
    padding: 14px;
  }

  .diagram-view {
    padding: 16px 18px 34px;
  }

  .card-head {
    grid-template-columns: 1fr;
  }

}
