/* 简洁版阅读页：手机优先的文档版式，无外部字体、无动画依赖。 */

:root {
  --paper: #fcfbf7;
  --ink: #191c19;
  --muted: #565c55;
  --line: #e3dfd3;
  --accent: #2b6355;
  --accent-soft: #edf2ee;
  --flag: #f2eddf;
  --target: #f7f2e2;
  --measure: 43rem;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; overflow-wrap: anywhere; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 22px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  z-index: 20;
}
.skip:focus { left: 12px; }

/* 顶部条：sticky，但高度克制，锚点用 scroll-margin 让开 */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(252, 251, 247, 0.97);
  border-bottom: 1px solid var(--line);
}

.bar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.bar a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.3;
}

.bar .home { font-weight: 600; color: var(--ink); }
.bar .alt { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.bar a:hover { text-decoration: underline; }

main { padding-bottom: 2rem; }

[id] { scroll-margin-top: 78px; }

/* 首页 */
.lead { padding: 2.2rem 0 0.6rem; }
.kicker {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
h1 {
  margin: 0;
  font-size: clamp(1.65rem, 5.4vw, 2.15rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.sub { margin: 0.9rem 0 0; font-size: 1.03rem; color: #33372f; }
.note { margin: 0.9rem 0 0; font-size: 0.9rem; color: var(--muted); }

.search { margin: 1.8rem 0 0; }
.search label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.4rem; }
.search .row { display: flex; gap: 10px; align-items: stretch; }
.search input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfc9b8;
  border-radius: 10px;
}
.search input::placeholder { color: #676d65; }
.search button {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 16px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #c8d5cc;
  border-radius: 10px;
  cursor: pointer;
}
.hint { margin: 0.5rem 0 0; font-size: 0.86rem; color: var(--muted); }
.count { margin: 1.5rem 0 0.2rem; font-size: 0.88rem; color: #4b514a; }
.empty {
  margin: 1rem 0 0;
  padding: 14px 16px;
  border: 1px dashed #cdc7b5;
  border-radius: 10px;
  color: #3b3f38;
  font-size: 0.95rem;
}

.mod { margin-top: 2.4rem; }
.mod h2 {
  margin: 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 1.28rem;
  line-height: 1.4;
}
.mod-desc { margin: 0.35rem 0 0.6rem; font-size: 0.93rem; color: var(--muted); }

.chapters { list-style: none; margin: 0; padding: 0; }
.chapters li { margin: 0; }
.ch {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 2px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  min-height: 64px;
}
.mod .ch { border-top: 1px solid #efebdf; }
.chapters li:first-child .ch { border-top: 1px solid var(--line); }
.ch:hover .t { text-decoration: underline; text-decoration-thickness: 1px; }
.no {
  flex: 0 0 2.9rem;
  padding-top: 2px;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.cbody { display: block; min-width: 0; }
.t { display: block; font-size: 1.06rem; font-weight: 600; line-height: 1.5; }
.s { display: block; margin-top: 2px; font-size: 0.84rem; color: var(--muted); }
.one { display: block; margin-top: 5px; font-size: 0.94rem; color: #3d423b; }

/* 章节页 */
.read { padding-top: 1.8rem; }
.read h1 { font-size: clamp(1.5rem, 5vw, 1.95rem); }
.meta { margin: 0.6rem 0 0; font-size: 0.88rem; color: var(--muted); overflow-wrap: anywhere; }

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 1.1rem 0 0;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.toc a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
}
.toc a:hover { color: var(--accent); text-decoration: underline; }
.toc-label { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.82rem; color: #4b514a; }

article section { margin-top: 2.1rem; }
article h2 {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 0 0 0.55rem;
  font-size: 1.17rem;
  line-height: 1.5;
}
article h2 .n {
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
article p { margin: 0.6rem 0; }
article section:target { background: var(--target); }

.big {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.75;
  padding: 2px 0 2px 16px;
  border-left: 3px solid #cfdcd3;
}

ol.steps { margin: 0.4rem 0 0; padding-left: 1.35rem; }
ol.steps li { margin: 0.6rem 0; padding-left: 2px; }

.flag {
  display: inline-block;
  margin: 0.2rem 0 0.2rem;
  padding: 1px 9px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: #4a4a3c;
  background: var(--flag);
  border-radius: 5px;
}

ul.pitfalls { list-style: none; margin: 0.4rem 0 0; padding: 0; }
ul.pitfalls li { position: relative; margin: 0.6rem 0; padding-left: 1.1rem; }
ul.pitfalls li::before {
  content: "·";
  position: absolute;
  left: 0.15rem;
  color: var(--accent);
  font-weight: 700;
}

.recap {
  margin: 0.4rem 0 0;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 1rem;
}

.tiny { font-size: 0.86rem; color: var(--muted); }

details {
  margin: 0.6rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
details summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 0.98rem;
  line-height: 1.55;
  cursor: pointer;
}
details summary::marker { color: var(--accent); }
details[open] summary { border-bottom: 1px solid var(--line); }
.ans { padding: 10px 14px 14px; font-size: 0.97rem; color: #2f332c; }
.ans p:first-child { margin-top: 0; }
.ans p:last-child { margin-bottom: 0; }

.srclinks { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.srclinks li { margin: 0.35rem 0; }
.srclinks a { font-size: 0.93rem; }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 2.6rem 0 0;
}
.pg {
  display: block;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.5;
}
.pg span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 2px; }
.pg.next { text-align: right; }
.pg:hover { border-color: #b9c8bd; }

.backtop { margin: 1.6rem 0 0; font-size: 0.88rem; }

.foot {
  margin-top: 2.5rem;
  padding: 1.4rem 0 2.6rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

@media (max-width: 380px) {
  .wrap { padding: 0 16px; }
  body { font-size: 17px; }
  .no { flex-basis: 2.7rem; }
  .pager { grid-template-columns: 1fr; }
  .pg.next { text-align: left; }
}

@media (min-width: 900px) {
  .wrap { padding: 0 24px; }
  .lead { padding-top: 2.8rem; }
}

.ch .go {
  flex: 0 0 auto;
  align-self: center;
  margin-left: auto;
  color: #6f756c;
  font-size: 1.15rem;
  line-height: 1;
}
