:root {
  --bg: #f4f3ed;
  --ink: #253e37;
  --muted: #728078;
  --line: #d9dfd5;
  --green: #26614c;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.7 "PingFang SC",
    "Microsoft Yahei",
    sans-serif;
}
header {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf5;
}
.brand {
  font-family: Georgia, serif;
  font-size: 23px;
  letter-spacing: 2px;
}
.brand span {
  font: 13px sans-serif;
  letter-spacing: 0;
  margin-left: 10px;
}
a {
  color: var(--green);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
header nav {
  display: flex;
  gap: 22px;
  margin-left: auto;
}
header nav span {
  border-bottom: 2px solid var(--green);
  padding: 8px 0;
}
small {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 2px;
}
header small {
  letter-spacing: 0;
}
.layout {
  display: grid;
  grid-template-columns: 230px minmax(460px, 1fr) minmax(320px, 360px);
  height: calc(100dvh - 76px);
}
aside,
main {
  overflow: auto;
  min-width: 0;
}
.catalog {
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #eeefe6;
}
h1,
h2 {
  font-family: "Songti SC", serif;
  font-weight: 600;
}
h2 {
  font-size: 20px;
  margin: 0 0 12px;
}
input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcf7;
  color: var(--ink);
  margin-bottom: 18px;
}
details {
  margin: 8px 0;
}
summary {
  cursor: pointer;
  padding: 7px 0;
  font-weight: 600;
}
button {
  font: inherit;
  cursor: pointer;
  color: var(--ink);
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
}
button:hover {
  border-color: #6f9c83;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #d4a85c;
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.directory-node {
  display: block;
  text-align: left;
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 12px;
  padding: 8px 10px;
}
.directory-node.current {
  background: #dce8d8;
  color: #1b543f;
  font-weight: 600;
}
.trail {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
#history {
  display: flex;
  gap: 6px;
  overflow: auto;
  white-space: nowrap;
}
#history button {
  font-size: 11px;
  border: 0;
  background: transparent;
}
#history button.active {
  background: #e1e9d9;
}
.heading {
  padding: 24px 25px 10px;
}
h1 {
  font-size: 28px;
  margin: 5px 0;
}
.heading p,
.footnote {
  font-size: 12px;
  color: var(--muted);
}
.controls {
  display: flex;
  gap: 8px;
  padding: 0 25px 20px;
  flex-wrap: wrap;
}
.controls button {
  font-size: 12px;
}
#relations {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 17px;
  padding: 0 22px 25px;
}
.lane-label {
  color: var(--muted);
  font-size: 11px;
  margin: 4px 0 16px;
  letter-spacing: 1px;
}
.tier {
  margin-bottom: 22px;
}
.tier h3 {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
.card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  margin: 9px 0;
  padding: 13px 11px;
  background: #fffefa;
  box-shadow: 0 3px 12px #354e3710;
  overflow-wrap: anywhere;
}
.card strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
}
.card small {
  font-size: 10px;
  letter-spacing: 0;
  display: block;
  margin-top: 7px;
}
.before .card:after,
.center .card:after {
  content: "→";
  position: absolute;
  right: -15px;
  top: 14px;
  color: #648a72;
}
.card.selected {
  background: #254f40;
  color: #fffaf0;
  border-color: #254f40;
}
.card.selected small {
  color: #c4d7c6;
}
.empty {
  font-size: 12px;
  color: var(--muted);
}
.lane.center {
  padding-top: 0;
}
.center .hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
}
.footnote {
  padding: 0 25px 15px;
}
.reading {
  background: #fffefa;
  border-left: 1px solid var(--line);
}
.reading-head {
  padding: 25px 24px 20px;
  border-bottom: 1px solid var(--line);
}
.reading-head h2 {
  font-size: 23px;
  margin: 12px 0;
}
.reading-head p {
  font-size: 12px;
  color: var(--muted);
}
.primary {
  display: block;
  text-align: center;
  background: #e2eadb;
  border: 1px solid #bdcdb6;
  border-radius: 6px;
  padding: 9px;
  margin-top: 18px;
}
.primary[hidden] {
  display: none;
}
.prose {
  padding: 20px 24px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.prose h1,
.prose h2 {
  font-size: 20px;
}
.prose h3 {
  font-size: 16px;
}
.prose img {
  max-width: 100%;
}
.prose pre {
  overflow: auto;
  background: #f1f2ec;
  padding: 12px;
  font-size: 11px;
}
.prose table {
  display: block;
  overflow: auto;
  border-collapse: collapse;
}
.prose td,
.prose th {
  border: 1px solid var(--line);
  padding: 5px;
}
.prose blockquote {
  margin: 12px 0;
  padding-left: 12px;
  border-left: 3px solid #a8bfa0;
  color: var(--muted);
}
.prose .katex-display {
  overflow: auto;
}
.preview-note {
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 190px minmax(390px, 1fr);
  }
  .reading {
    grid-column: 2;
    border-top: 1px solid var(--line);
    max-height: 60vh;
  }
  .layout {
    height: auto;
  }
  .catalog {
    grid-row: span 2;
    max-height: calc(100dvh - 76px);
    position: sticky;
    top: 0;
  }
  main {
    min-height: 65vh;
  }
}
@media (max-width: 650px) {
  header {
    height: auto;
    min-height: 90px;
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 8px;
  }
  .brand {
    font-size: 19px;
  }
  header nav {
    margin: 0;
    font-size: 12px;
    gap: 16px;
  }
  header small {
    margin-left: auto;
  }
  .layout {
    display: block;
  }
  .catalog {
    position: static;
    max-height: 210px;
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
  }
  .catalog h2 {
    font-size: 16px;
  }
  .catalog input {
    margin-bottom: 4px;
  }
  .heading {
    padding: 16px;
  }
  .heading h1 {
    font-size: 24px;
  }
  .controls {
    padding: 0 16px 12px;
  }
  #relations {
    padding: 0 16px 15px;
    gap: 14px;
  }
  .card {
    padding: 10px 7px;
  }
  .card strong {
    font-size: 11px;
  }
  .card small {
    font-size: 9px;
  }
  .reading {
    max-height: none;
  }
  .trail {
    padding: 12px 16px;
  }
  .footnote {
    padding: 0 16px;
  }
  .reading-head {
    padding: 20px 16px;
  }
  .prose {
    padding: 16px;
  }
}
