/* 墨匣：暖纸、墨色、朱砂点缀。无渐变，无重阴影。 */
:root {
  --paper: #F3EEE4;
  --paper-inset: #EBE6DA;
  --ink: #1C1814;
  --ink-soft: #5C564E;
  --ink-faint: #8A8378;
  --rule: #C9C0B2;
  --rule-strong: #1C1814;
  --seal: #B23A2A;
  --highlight: #E8D4C4;
  --max: 980px;
  --read-width: 38em;
  --font: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "Songti TC", "PMingLiU", serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--seal);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.visually-hidden,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: absolute;
  z-index: 20;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: var(--paper);
  border: 1px solid var(--ink);
}

/* —— 页眉 —— */
.site-header {
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}

.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.55rem;
  height: 2.55rem;
  background: var(--seal);
  color: var(--paper);
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
  text-orientation: upright;
  line-height: 1.05;
  flex: 0 0 auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-name {
  font-size: 1.35rem;
  letter-spacing: 0.4em;
  line-height: 1.2;
  margin-right: -0.4em;
}

.brand-sub {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
}

.search-form {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--ink);
  min-width: 0;
  flex: 1 1 16rem;
  max-width: 22rem;
  margin-left: auto;
}

.search-form input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.35rem 0.15rem;
  outline: none;
}

.search-form input::placeholder {
  color: var(--ink-faint);
}

.search-submit {
  padding: 0.25rem 0 0.25rem 0.8rem;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

.search-submit:hover {
  color: var(--seal);
}

/* —— 主体 —— */
.site-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
  min-height: 60vh;
}

.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  color: var(--ink-faint);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.site-footer p {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.kicker {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  color: var(--ink-soft);
}

.page-title {
  margin: 0 0 0.4rem;
  font-size: 1.65rem;
  font-weight: 500;
  letter-spacing: 0.18em;
}

.lede,
.empty,
.meta-line,
.hint {
  color: var(--ink-soft);
}

.lede {
  max-width: 38em;
  margin: 0.4rem 0 1.5rem;
}

/* —— 分类与续读 —— */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.6rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.15rem;
}

.filter-btn {
  padding: 0.15rem 0.85rem;
  letter-spacing: 0.28em;
  color: var(--ink-soft);
  border-bottom: 1px solid transparent;
}

.filter-btn:hover {
  color: var(--ink);
}

.filter-btn.is-active {
  color: var(--seal);
  border-bottom-color: var(--seal);
}

.continue-link {
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: 0.06em;
}

.continue-link:hover {
  color: var(--seal);
}

/* —— 书架 —— */
.shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.75rem 1.25rem;
}

.shelf-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.cover-inner {
  height: 100%;
  border: 1px solid var(--rule);
  padding: 0.7rem 0.45rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.cover-cat {
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  color: var(--ink-soft);
  writing-mode: horizontal-tb;
}

.cover-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 1.45rem;
  letter-spacing: 0.35em;
  line-height: 1.15;
  margin: 0.4rem auto;
  max-height: 70%;
}

.cover-foot {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  writing-mode: horizontal-tb;
}

.shelf-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  line-height: 1.55;
}

.shelf-meta strong {
  display: block;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.16em;
  margin-bottom: 0.1rem;
}

/* —— 书籍详情 —— */
.detail-head {
  display: grid;
  grid-template-columns: 8.2rem 1fr;
  gap: 1.75rem;
  align-items: start;
  margin-bottom: 1.8rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.detail-cover {
  width: 8.2rem;
}

.detail-cover .cover {
  cursor: default;
}

.crumb {
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.crumb a {
  color: var(--ink-soft);
  text-decoration: none;
}

.crumb a:hover {
  color: var(--seal);
}

.detail-title {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  line-height: 1.2;
}

.meta-list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.meta-list li + li {
  margin-top: 0.15rem;
}

.meta-list span {
  display: inline-block;
  min-width: 3.2em;
  color: var(--ink-faint);
  letter-spacing: 0.16em;
}

.intro {
  margin: 0 0 1.1rem;
  max-width: 38em;
  text-align: justify;
}

.source-link {
  font-size: 0.88rem;
}

.chapter-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.chapter-list li {
  border-bottom: 1px solid var(--rule);
}

.chapter-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.1rem;
  text-decoration: none;
  letter-spacing: 0.12em;
}

.chapter-list a:hover .chap-title,
.chapter-list a:hover .chap-go {
  color: var(--seal);
}

.chap-go {
  color: var(--ink-faint);
  letter-spacing: 0.2em;
  font-size: 0.85rem;
}

/* —— 阅读 —— */
body.is-reading .site-footer {
  display: none;
}

body.is-reading .site-main {
  max-width: none;
  padding: 0 0 3rem;
}

.reader {
  --reader-size: 18px;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.reader-bar-inner {
  max-width: 52rem;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.reader-nav-left,
.reader-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.reader-loc {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.tool-btn {
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--rule);
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  color: var(--ink-soft);
  min-width: 2rem;
}

.tool-btn:hover,
.tool-btn.is-active {
  border-color: var(--seal);
  color: var(--seal);
}

.reader-body {
  font-size: var(--reader-size);
  line-height: 2;
  max-width: var(--read-width);
  margin: 2rem auto 0;
  padding: 0 1.5rem;
}

.reader-body h1 {
  margin: 0 0 1.4rem;
  font-size: 1.25em;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-align: center;
}

.reader-body p {
  margin: 0 0 1em;
  text-align: justify;
}

.verse-label {
  display: block;
  margin: 1.15em 0 0.35em;
  font-size: 0.72em;
  letter-spacing: 0.2em;
  color: var(--seal);
  text-align: left;
}

.reader-body p:first-of-type .verse-label,
.reader-body .verse-label:first-child {
  margin-top: 0;
}

.reader-foot {
  max-width: var(--read-width);
  margin: 2.5rem auto 0;
  padding: 1.1rem 1.5rem 0;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.reader-foot a,
.reader-foot span {
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  text-decoration: none;
}

.reader-foot a:hover {
  color: var(--seal);
}

.reader-foot .is-disabled {
  color: var(--rule);
}

/* 竖排 */
.reader.is-vertical .reader-body {
  max-width: none;
  height: calc(100vh - 7.5rem);
  margin: 1.2rem 0 0;
  padding: 1.5rem 3.5rem 2rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  overflow-x: auto;
  overflow-y: hidden;
  line-height: 1.95;
}

.reader.is-vertical .reader-body h1 {
  text-align: start;
  margin: 0 1.2em 0 0;
}

.reader.is-vertical .reader-body p {
  text-align: start;
  margin: 0 1em 0 0;
}

.reader.is-vertical .verse-label {
  margin: 0 0.15em 0 0.8em;
}

.reader.is-vertical .reader-foot {
  max-width: none;
  margin: 1rem 1.5rem 0;
}

/* —— 检索结果 —— */
.search-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-hit {
  padding: 1rem 0 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.search-hit a {
  text-decoration: none;
}

.search-hit h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.16em;
}

.search-hit .hit-where {
  font-size: 0.82rem;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.search-hit p {
  margin: 0;
  color: var(--ink-soft);
}

mark {
  background: var(--highlight);
  color: var(--ink);
  padding: 0 0.1em;
}

.empty {
  margin: 2rem 0;
}

/* —— 响应 —— */
@media (max-width: 860px) {
  .shelf {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  html {
    font-size: 16px;
  }

  .header-inner {
    flex-wrap: wrap;
    padding: 1rem 1rem 0.9rem;
  }

  .search-form {
    flex: 1 1 100%;
    max-width: none;
    margin-left: 0;
  }

  .site-main,
  .site-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .shelf {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem 0.85rem;
  }

  .cover-title {
    font-size: 1.2rem;
  }

  .detail-head {
    grid-template-columns: 6.4rem 1fr;
    gap: 1rem;
  }

  .detail-cover {
    width: 6.4rem;
  }

  .detail-title {
    font-size: 1.55rem;
    letter-spacing: 0.16em;
  }

  .reader-bar-inner {
    padding: 0.6rem 0.85rem;
  }

  .reader.is-vertical .reader-body {
    padding: 1rem 1.6rem 1.4rem;
    height: calc(100vh - 8.5rem);
  }
}
