:root {
  --paper: #f4f0e6;
  --ink: #1a1714;
  --muted: #6d655c;
  --line: #e4d9c8;
  --seal: #9f1d1d;
  --card: #fffdf8;
  --top: #1c1916;
  --shadow: 0 12px 28px rgba(36, 28, 18, .1);
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }
button, input, select { font: inherit; color: inherit; }
::selection { background: #f0c9c4; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
.hide {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(36, 28, 18, .08);
}
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  background: var(--top);
  color: #f6f1e7;
}
.top :focus-visible { outline-color: #fff; }
.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--seal);
  color: #fff;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 20px;
  flex: none;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 4em; }
.brand a { font-family: "Songti SC", "SimSun", serif; font-size: 22px; letter-spacing: 0.08em; }
.brand span { color: #b7aea2; font-size: 12px; }
.search {
  display: flex;
  flex: 1;
  max-width: 440px;
  margin-left: auto;
  background: #322c27;
  border-radius: var(--radius);
  overflow: hidden;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 9px 12px;
}
.search input::placeholder { color: #b7aea2; }
.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  cursor: pointer;
  background:
    linear-gradient(45deg, transparent 42%, #d9d0c4 42%, #d9d0c4 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, #d9d0c4 42%, #d9d0c4 58%, transparent 58%);
}
.search button {
  border: 0;
  background: var(--seal);
  color: #fff;
  padding: 9px 16px;
  cursor: pointer;
}
.search button:hover { background: #861818; }
.cats {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 22px;
  background: #faf7f1;
}
.cats a {
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
}
.cats a:hover { color: var(--ink); background: #efe8dc; }
.cats a.on { color: #fff; background: var(--ink); }
.cats a.doc { margin-left: auto; color: var(--seal); background: transparent; box-shadow: inset 0 0 0 1px #e7c4c0; }
.cats a.doc:hover { background: #fdeceb; }
.cats a.doc.on { color: #fff; background: var(--seal); box-shadow: none; }

.wrap { width: min(1120px, calc(100% - 32px)); margin: 22px auto 56px; }
.bar, .bar-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.bar { justify-content: space-between; margin-bottom: 16px; }
.bar strong { font-size: 18px; }
.muted { color: var(--muted); }
.textlink { color: var(--seal); font-size: 14px; }
.textlink:hover { text-decoration: underline; }

.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 26px 16px;
}
.frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #e7dfd2;
  box-shadow: 0 1px 2px rgba(36, 28, 18, .08);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover .frame, .card:focus-visible .frame {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.card .cover, .card .ph, .detail .cover, .detail .ph {
  aspect-ratio: 3 / 4;
  width: 100%;
  object-fit: cover;
  background: #e7dfd2;
}
.ph {
  display: grid;
  place-items: center;
  color: #8a8174;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 28px;
}
.pin {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--seal);
  color: #fff;
  font-style: normal;
  font-size: 12px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
}
.card h2 {
  font-size: 14px;
  line-height: 1.4;
  margin: 8px 0 2px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
  overflow-wrap: break-word;
}
.card:hover h2 { color: var(--seal); }
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card p.done { color: var(--seal); }

.bone {
  border-radius: var(--radius);
  background: linear-gradient(100deg, #e6dfd2 30%, #f6f1e8 50%, #e6dfd2 70%);
  background-size: 200% 100%;
  animation: sheen 1.15s ease-in-out infinite;
  aspect-ratio: 3 / 4;
}
@keyframes sheen { to { background-position: -200% 0; } }

.pager {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 28px;
}
.pager a, .pager .now, .jump button, .jump input {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 10px;
  min-height: 36px;
}
.pager .num, .pager .now { min-width: 36px; text-align: center; }
.pager .now { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager a:hover, .jump button:hover { border-color: var(--seal); color: var(--seal); }
.pager .gap { color: var(--muted); padding: 0 2px; }
.jump { display: flex; gap: 6px; margin-left: auto; }
.jump input { width: 4.8em; }
.jump button { cursor: pointer; }

.empty {
  padding: 56px 16px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty strong { display: block; font-size: 18px; margin-bottom: 6px; }
.empty a { color: var(--seal); }

.crumb { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.crumb a:hover { color: var(--seal); }
.detail { display: grid; grid-template-columns: 240px 1fr; gap: 32px; align-items: start; }
.detail .frame { box-shadow: var(--shadow); }
.dhead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.detail h1 {
  font-family: "Songti SC", "SimSun", serif;
  font-size: 34px;
  line-height: 1.25;
  margin: 0;
  overflow-wrap: break-word;
}
.badge {
  background: #efe8dc;
  color: var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
}
.badge.done { background: #fdeceb; color: var(--seal); }
.meta { color: var(--muted); margin: 10px 0 0; }
.meta a:hover { color: var(--seal); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.chips span, .chips button {
  border: 1px solid var(--line);
  padding: 3px 8px;
  font-size: 13px;
  background: var(--card);
  border-radius: 999px;
}
.chips button { cursor: pointer; color: var(--seal); }
.blurb { margin: 0; max-width: 46em; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--seal);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 40px;
}
.btn:hover { background: #861818; color: #fff; }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { color: var(--seal); box-shadow: inset 0 0 0 1px var(--seal); }
.btn.small { padding: 7px 12px; min-height: 36px; }
.dir { font-size: 16px; margin: 26px 0 10px; }
.chapters {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.chapters a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  line-height: 1.4;
}
.chapters a:hover { border-color: var(--seal); background: #fff; }
.chapters a.on { border-color: var(--seal); color: var(--seal); }

.read-body .chrome { position: static; box-shadow: none; }
.read-body .cats, .read-body .search, .read-body .brand span { display: none; }
.read-body .top { padding-block: 8px; }
.read-body .wrap { width: min(820px, 100%); margin-top: 0; }
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 40;
  pointer-events: none;
}
.progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--seal);
  transform: scaleX(0);
  transform-origin: left center;
}
.read-bar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: rgba(244, 240, 230, .94);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(36, 28, 18, .08);
  transition: transform .18s ease;
}
.read-bar.away { transform: translateY(calc(-100% - 12px)); }
.read-bar a, .read-bar select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  min-height: 36px;
}
.read-bar .name {
  max-width: 16em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.read-bar select { flex: 1 1 180px; min-width: 0; background: #fff; }
.read-bar .where, .keys { color: var(--muted); font-size: 13px; white-space: nowrap; }
.keys { margin-left: auto; }
.pages {
  width: min(820px, 100%);
  margin: 8px auto 0;
  line-height: 0;
  background: #fff;
}
.pages figure { margin: 0; }
/* 叠 1 像素，避免切片接缝露出底色 */
.pages figure + figure { margin-top: -1px; }
.pages img {
  width: 100%;
  display: block;
  margin: 0;
  background: #fff;
  /* 未出图时占住高度，出图后收回，避免把两张切片撑开 */
  min-height: 120px;
}
.pages img.ready { min-height: 0; }
.pages figcaption {
  margin: 8px 0;
  line-height: 1.55;
  font-size: 16px;
  text-align: center;
  color: var(--muted);
}
.read-end {
  width: min(820px, 100%);
  margin: 8px auto 0;
  padding-inline: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.totop {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 25;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.totop:hover { border-color: var(--seal); color: var(--seal); }

.doc h1 { font-family: "Songti SC", "SimSun", serif; font-size: 36px; margin: 8px 0 12px; }
.doc h2 { font-size: 18px; margin: 28px 0 8px; }
.doc p, .doc li { max-width: 46em; }
.addr { display: flex; gap: 8px; align-items: stretch; max-width: 760px; }
.addr code, .doc pre, .doc table code {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.addr code, .doc pre { display: block; padding: 12px 14px; overflow: auto; }
.addr code { flex: 1; }
.table-scroll { overflow-x: auto; max-width: 760px; }
.doc table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 8px; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.try { padding-left: 1.2em; }
.try a { color: var(--seal); word-break: break-all; }
.try a:hover { text-decoration: underline; }

@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .keys { display: none; }
}
@media (max-width: 720px) {
  .top { flex-wrap: wrap; padding: 12px; }
  .search { order: 5; flex: 1 1 100%; max-width: none; width: 100%; margin-left: 0; }
  .cats { padding: 10px 12px; }
  .cats a.doc { margin-left: 0; }
  .wrap { width: min(100% - 24px, 1120px); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .detail { grid-template-columns: 1fr; gap: 16px; }
  .detail .frame { max-width: 220px; }
  .detail h1 { font-size: 26px; }
  .chapters { grid-template-columns: 1fr; }
  .keys { display: none; }
  .read-bar .name { max-width: 9em; }
  .jump { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .frame, .bone, .read-bar { transition: none; animation: none; }
}
