:root {
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #9f1239;
  --hit: #fef3c7;
  --paper: #fafaf9;
  --header: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font: 16px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
}

.bar {
  max-width: 1120px;
  margin: 0 auto;
  min-height: var(--header);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; }
h1 a { color: inherit; text-decoration: none; }
.review-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.review-link .n {
  display: inline-block;
  min-width: 1.2em;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  text-align: center;
}

#find { flex: 1; display: flex; justify-content: flex-end; }
#q {
  width: min(440px, 100%);
  border: 1px solid #d6d3d1;
  background: var(--paper);
  border-radius: 999px;
  padding: 9px 16px;
  font: inherit;
  font-size: 15px;
}
#q:focus { outline: 2px solid var(--accent); border-color: transparent; background: #fff; }

#toc-btn {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr) 212px;
  gap: 36px;
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--header) + 16px);
  max-height: calc(100vh - var(--header) - 32px);
  overflow: auto;
  padding-right: 4px;
}

.laws { display: flex; gap: 4px; margin-bottom: 16px; position: sticky; top: 0; background: #fff; padding-bottom: 8px; }
.laws button {
  flex: 1;
  border: 0;
  background: transparent;
  border-bottom: 2px solid transparent;
  padding: 6px 0;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.laws button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.ch { margin: 0 0 14px; }
.ch h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.4; }
.nums { display: flex; flex-wrap: wrap; gap: 3px; }
.nums a {
  width: 30px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #57534e;
  text-decoration: none;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.nums a:hover { background: var(--paper); }
.nums a.on { background: #f5f5f4; color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 1px #d6d3d1; }

.crumb { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.reader h2 {
  margin: 0 0 18px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.cite {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0;
}

.prose {
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", PMingLiU, "SimSun", serif;
  font-size: 17.5px;
  line-height: 1.85;
}

.kuan {
  display: grid;
  grid-template-columns: 1.8rem 1fr;
  gap: 2px 12px;
  padding: 6px 0;
  scroll-margin-top: 88px;
}
.kuan.single { grid-template-columns: 1fr; }
.num {
  color: var(--accent);
  font-family: -apple-system, "PingFang SC", sans-serif;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding-top: 0.35em;
}
.txt p { margin: 0; }
.txt .item { padding-left: 1.75em; }
.kuan.hit .txt {
  background: var(--hit);
  border-radius: 6px;
  margin: 0 -8px;
  padding: 2px 8px;
}

a.ref { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(159, 18, 57, 0.35); }
a.ref:hover { border-bottom-color: var(--accent); }
mark { background: var(--hit); color: inherit; padding: 0 1px; }

.mem { margin: -6px 0 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.mem button, .rates button, .reveal {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.mem button { color: var(--accent); border-color: rgba(159, 18, 57, 0.35); }
.mem button[disabled] { color: var(--muted); border-color: var(--line); cursor: default; }
.mem a { color: var(--muted); font-size: 13px; }

.prompt { margin: 0 0 8px; font-size: 26px; font-weight: 600; letter-spacing: 0.02em; }
.recall {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.rates { display: flex; gap: 8px; margin-top: 18px; }
.rates button { flex: 1; }
.rates .again { color: #9f1239; }
.rates .hard { color: #92400e; }
.rates .good { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }

.turn {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.turn a { color: var(--accent); text-decoration: none; }
.turn a:hover { text-decoration: underline; }
.turn .spacer { visibility: hidden; }

.side { position: sticky; top: calc(var(--header) + 16px); }
.panel { background: var(--paper); border-radius: 12px; padding: 16px 14px 12px; }
.panel h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.rel { display: flex; flex-wrap: wrap; gap: 6px; }
.rel a {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  color: var(--accent);
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 6px;
  padding: 3px 7px;
}
.rel a:hover { border-color: var(--accent); }
.rel a.draft { border-style: dashed; color: var(--muted); }
.rel a.draft::after { content: "?"; margin-left: 2px; font-size: 11px; }
.hint, .quiet, .empty { margin: 10px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.panel .empty { margin: 0; }

.status { margin: 0 0 16px; font-size: 14px; color: var(--muted); }
.hitcard {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.hitcard:hover .hit-title { color: var(--accent); }
.hit-title { font-size: 17px; font-weight: 600; }
.hitcard p { margin: 6px 0 0; color: #44403c; font-size: 14px; line-height: 1.6; }

.foot {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 24px 40px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.foot a { color: var(--muted); }

@media (max-width: 900px) {
  .bar { flex-wrap: wrap; padding: 10px 16px 12px; gap: 8px 10px; }
  #toc-btn { display: inline-flex; }
  h1 { font-size: 16px; letter-spacing: 0.02em; }
  #find { flex: 1 0 100%; justify-content: stretch; }
  #q { width: 100%; }
  .shell { display: block; padding: 18px 16px 32px; }
  .toc {
    display: none;
    position: fixed;
    z-index: 30;
    inset: 108px 0 0;
    max-height: none;
    background: #fff;
    padding: 12px 16px 48px;
  }
  body.toc-open .toc { display: block; }
  body.toc-open { overflow: hidden; }
  .side { position: static; margin-top: 28px; }
  .reader h2 { font-size: 24px; }
  .prose { font-size: 17px; }
}
