/* ============================================================
 * 墨阅 · 样式
 * 主题通过 <html data-theme="day|sepia|night"> 切换
 * ============================================================ */

:root {
  --font-serif: Georgia, "Charter", "Times New Roman", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --reader-width: 680px;
  --home-width: 1080px;
  --radius: 14px;
  --header-h: 60px;
}

/* ---------- 主题变量 ---------- */
html[data-theme="day"] {
  --bg: #f7f6f3;
  --bg-paper: #ffffff;
  --bg-soft: #efede8;
  --text: #2b2b2b;
  --text-strong: #1a1a1a;
  --text-soft: #8a8577;
  --accent: #b3541e;
  --accent-soft: rgba(179, 84, 30, .1);
  --border: #e6e2d8;
  --shadow: 0 2px 14px rgba(60, 50, 30, .07);
  --card-hover: 0 10px 30px rgba(60, 50, 30, .12);
}
html[data-theme="sepia"] {
  --bg: #f3ead8;
  --bg-paper: #f8f1e3;
  --bg-soft: #ece1cb;
  --text: #4a3f2f;
  --text-strong: #33291c;
  --text-soft: #99886c;
  --accent: #a05a1f;
  --accent-soft: rgba(160, 90, 31, .12);
  --border: #e0d2b8;
  --shadow: 0 2px 14px rgba(100, 80, 40, .08);
  --card-hover: 0 10px 30px rgba(100, 80, 40, .15);
}
html[data-theme="night"] {
  --bg: #14161a;
  --bg-paper: #1c1f24;
  --bg-soft: #23262c;
  --text: #b8bcc4;
  --text-strong: #e2e5ea;
  --text-soft: #6b7078;
  --accent: #d08a4e;
  --accent-soft: rgba(208, 138, 78, .14);
  --border: #2c3036;
  --shadow: 0 2px 14px rgba(0, 0, 0, .3);
  --card-hover: 0 10px 30px rgba(0, 0, 0, .45);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.9;
  transition: background .35s ease, color .35s ease;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font-sans); cursor: pointer; }

::selection { background: var(--accent-soft); }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background .35s ease;
}
.header-inner {
  width: 100%;
  max-width: var(--home-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.logo .logo-mark {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center; justify-content: center;
  background: var(--accent);
  color: var(--bg-paper);
  border-radius: 8px;
  font-size: 16px;
}
.header-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.header-search input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--bg-paper);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.header-search .search-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-paper);
  color: var(--text);
  display: inline-flex;
  align-items: center; justify-content: center;
  transition: all .2s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.active { background: var(--accent); border-color: var(--accent); color: var(--bg-paper); }

.nav-link {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-soft);
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  transition: color .2s, background .2s;
}
.nav-link:hover { color: var(--accent); background: var(--accent-soft); }

/* ---------- 首页 ---------- */
.home-wrap {
  max-width: var(--home-width);
  margin: 0 auto;
  padding: 0 20px 80px;
}

.hero {
  padding: 64px 0 40px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-strong);
  margin-bottom: 14px;
}
.hero p {
  font-family: var(--font-sans);
  color: var(--text-soft);
  font-size: 15px;
  letter-spacing: 1px;
}
.hero .hero-line {
  width: 56px; height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 22px auto 0;
}

/* 分类 */
.cat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 0 36px;
}
.cat-chip {
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-paper);
  color: var(--text-soft);
  transition: all .2s;
}
.cat-chip:hover { border-color: var(--accent); color: var(--accent); }
.cat-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 文章卡片 */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}
.article-card {
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 26px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, background .35s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.article-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .25s;
}
.article-card:hover { transform: translateY(-4px); box-shadow: var(--card-hover); }
.article-card:hover::before { opacity: 1; }
.article-card .card-cat {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.article-card h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.5;
  margin-bottom: 10px;
}
.article-card .card-excerpt {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.8;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card .card-meta {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.article-card .card-shelf {
  border: none;
  background: none;
  font-size: 12px;
  color: var(--text-soft);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all .2s;
}
.article-card .card-shelf:hover { color: var(--accent); background: var(--accent-soft); }
.article-card .card-shelf.in-shelf { color: var(--accent); }

.empty-tip {
  text-align: center;
  color: var(--text-soft);
  font-family: var(--font-sans);
  padding: 80px 0;
  font-size: 15px;
}

/* 页脚 */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 30px 20px;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-soft);
}

/* ============================================================
 * 阅读页
 * ============================================================ */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 100;
  transition: width .1s linear;
}

.reader-wrap {
  max-width: var(--reader-width);
  margin: 0 auto;
  padding: 0 24px 120px;
}

.reader-head {
  padding: 56px 0 32px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}
.reader-head .r-cat {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 3px;
  margin-bottom: 14px;
}
.reader-head h1 {
  font-size: clamp(26px, 4.5vw, 36px);
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.5;
  margin-bottom: 16px;
}
.reader-head .r-meta {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-soft);
}

/* 正文 */
.reader-body { font-size: var(--reader-font-size, 18px); }
.reader-body p {
  margin-bottom: 1.6em;
  text-align: justify;
  text-justify: inter-ideograph;
  letter-spacing: .02em;
  white-space: pre-line;
  word-break: break-word;
}
.reader-body p:first-of-type::first-letter {
  font-size: 2.2em;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  padding-right: .08em;
}

.reader-body.no-dropcap p:first-of-type::first-letter {
  font-size: inherit; font-weight: inherit; color: inherit; padding-right: 0;
}

/* 英文正文：左对齐 + 自动断词 */
.reader-body.en p {
  text-align: left;
  hyphens: auto;
  -webkit-hyphens: auto;
  word-break: normal;
}

/* 章节标题 */
.chapter-heading {
  font-size: 1.35em;
  font-weight: 700;
  color: var(--text-strong);
  text-align: center;
  letter-spacing: .12em;
  margin: 2.2em 0 1.6em;
  position: relative;
}
.chapter-heading::before,
.chapter-heading::after {
  content: "❦";
  display: block;
  color: var(--accent);
  font-size: .7em;
  opacity: .7;
}
.chapter-heading::before { margin-bottom: .4em; }
.chapter-heading::after { content: none; }
.chapter-heading:first-child { margin-top: 0; }

.reader-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 48px 0 8px;
}
.reader-tags span {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-soft);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 14px;
}

/* 上下篇导航 */
.reader-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 48px;
}
.reader-nav a {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  background: var(--bg-paper);
  transition: all .2s;
  min-width: 0;
}
.reader-nav a:hover { border-color: var(--accent); }
.reader-nav .nav-dir {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-soft);
  display: block;
  margin-bottom: 6px;
}
.reader-nav .nav-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.reader-nav a.next { text-align: right; }

/* ---------- 阅读工具栏（底部悬浮） ---------- */
.reader-toolbar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 6px 10px;
  box-shadow: var(--card-hover);
  z-index: 60;
}
.tb-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center; justify-content: center;
  transition: all .2s;
}
.tb-btn:hover { background: var(--accent-soft); color: var(--accent); }
.tb-btn.active { color: var(--accent); }
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.tb-font { font-size: 13px; font-weight: 700; }

/* ---------- 目录抽屉 ---------- */
.toc-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
  z-index: 70;
}
.toc-mask.open { opacity: 1; pointer-events: auto; }
.toc-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(340px, 85vw);
  background: var(--bg-paper);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .3s ease;
  z-index: 80;
  display: flex;
  flex-direction: column;
}
.toc-drawer.open { transform: translateX(0); }
.toc-drawer .toc-head {
  font-family: var(--font-sans);
  padding: 20px 22px 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  border-bottom: 1px solid var(--border);
}
.toc-drawer .toc-list { overflow-y: auto; flex: 1; padding: 8px 0; }
.toc-item {
  display: block;
  padding: 13px 22px;
  border-left: 3px solid transparent;
  transition: all .2s;
}
.toc-item:hover { background: var(--accent-soft); }
.toc-item.current { border-left-color: var(--accent); background: var(--accent-soft); }
.toc-item .toc-title {
  font-size: 15px;
  color: var(--text-strong);
  font-weight: 700;
  line-height: 1.5;
  display: block;
}
.toc-item .toc-sub {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-soft);
  display: block;
  margin-top: 3px;
}

/* ---------- 书架视图 ---------- */
.shelf-banner {
  background: var(--bg-paper);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 26px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.shelf-banner .clear-shelf {
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 13px;
  text-decoration: underline;
}
.shelf-banner .clear-shelf:hover { color: var(--accent); }

/* ---------- 分级读物书卡 ---------- */
.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: 2px;
  text-align: center;
}
.section-sub {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-soft);
  text-align: center;
  margin: 8px 0 26px;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 10px;
}
.book-card {
  display: flex;
  gap: 0;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease;
}
.book-card:hover { transform: translateY(-4px); box-shadow: var(--card-hover); }
.book-badge {
  flex: 0 0 64px;
  background: var(--book-color, var(--accent));
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.book-info { padding: 20px 22px; min-width: 0; }
.book-info .book-level {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--book-color, var(--accent));
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.book-info h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.5;
  margin-bottom: 8px;
}
.book-info p {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.7;
  font-family: var(--font-sans);
}
.book-info .book-meta {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 12px;
}

/* 作品状态标签（已完结 / 连载中） */
.book-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: 1px;
}
.book-status.done {
  background: rgba(90, 160, 100, .15);
  color: #5fa065;
}
.book-status.ongoing {
  background: var(--accent-soft);
  color: var(--accent);
}
.book-card.done { opacity: .92; }

/* 伴读资料卡：与分级读物区分（虚线边、无级别色条） */
.book-card.guide {
  border-style: dashed;
  background: var(--bg);
  box-shadow: none;
}
.book-card.guide .book-badge {
  background: var(--bg-soft);
  color: var(--text-soft);
}
.book-card.guide .book-level { color: var(--text-soft); }

/* ---------- 词汇标注 ---------- */
.vocab { cursor: pointer; border-radius: 3px; padding: 0 1px; transition: background .15s; }
.vocab.vc {
  color: var(--accent);
  font-weight: 700;
  border-bottom: 1.5px solid var(--accent);
}
.vocab.vb {
  border-bottom: 1.5px dashed var(--text-soft);
}
.vocab:hover { background: var(--accent-soft); }

/* 人名标记与人物卡 */
.vchar {
  cursor: pointer;
  border-bottom: 1.5px dotted var(--accent);
  border-radius: 3px;
  padding: 0 1px;
  transition: background .15s;
}
.vchar:hover { background: var(--accent-soft); }
.vchar-demo {
  color: var(--accent);
  border-bottom: 1.5px dotted var(--accent);
  padding: 0 1px;
}
.vocab-tip .vt-tag.char {
  background: var(--accent-soft);
  color: var(--accent);
}
.vocab-tip .vt-tag.term {
  background: var(--bg-soft);
  color: var(--text-soft);
}

.vocab-legend {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 12px;
}
.vocab-legend .vc-demo {
  color: var(--accent);
  font-weight: 700;
  border-bottom: 1.5px solid var(--accent);
  padding: 0 1px;
}
.vocab-legend .vb-demo {
  border-bottom: 1.5px dashed var(--text-soft);
  padding: 0 1px;
}

/* 查词气泡 */
.vocab-tip {
  position: fixed;
  z-index: 200;
  max-width: 260px;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--card-hover);
  padding: 14px 16px;
  font-family: var(--font-sans);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
}
.vocab-tip.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.vocab-tip .vt-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vocab-tip .vt-head b { font-size: 17px; color: var(--text-strong); }
.vocab-tip .vt-say {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 13px;
  display: inline-flex;
  align-items: center; justify-content: center;
  transition: all .2s;
  padding: 0;
}
.vocab-tip .vt-say:hover { border-color: var(--accent); background: var(--accent-soft); }
.vocab-tip .vt-say.speaking {
  border-color: var(--accent);
  background: var(--accent-soft);
  animation: vt-pulse 1s infinite;
}
@keyframes vt-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.vocab-tip .vt-sub {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 6px 0 2px;
  flex-wrap: wrap;
}
.vocab-tip .vt-ipa { font-size: 13px; color: var(--accent); font-family: var(--font-sans); }
.vocab-tip .vt-base { font-size: 12px; color: var(--text-soft); }
.vocab-tip .vt-pos { font-size: 12px; color: var(--text-soft); font-style: italic; margin-left: auto; }
.vocab-tip .vt-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}
.vocab-tip .vt-tag.core { background: var(--accent-soft); color: var(--accent); }
.vocab-tip .vt-tag.beyond { background: var(--bg-soft); color: var(--text-soft); }
.vocab-tip .vt-cn { font-size: 15px; color: var(--text-strong); margin: 4px 0 2px; }
.vocab-tip .vt-en { font-size: 12px; color: var(--text-soft); line-height: 1.6; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  .hero { padding: 40px 0 28px; }
  .article-grid { grid-template-columns: 1fr; }
  .header-search { max-width: none; }
  .nav-link.hide-m { display: none; }
  .reader-head { padding: 36px 0 24px; margin-bottom: 28px; }
  .reader-wrap { padding: 0 20px 140px; }
  .reader-toolbar { bottom: 14px; padding: 4px 8px; }
  .reader-nav { grid-template-columns: 1fr; }
  .reader-nav a.next { text-align: left; }
}
