/* ============================================================
   170.html · 第 170 期阅读器（纯文本 / PDF 双模式）
   ============================================================ */
:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --text: #1a1d24;
  --text-soft: #5b6472;
  --accent: #c51a4a;
  --accent-strong: #a3143d;
  --border: #e6e8ec;
  --card: #ffffff;
  --shadow: 0 8px 28px rgba(20, 20, 40, 0.08);
  --radius: 14px;
  --maxw: 1120px;
}
[data-theme="dark"] {
  --bg: #0e1014;
  --bg-soft: #15181f;
  --text: #e8eaed;
  --text-soft: #9aa3b2;
  --accent: #ff4d6d;
  --accent-strong: #ff6b85;
  --border: #262b35;
  --card: #161a22;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
/* 让 hidden 属性真正生效：下方 .pdf-spread / .pdf-single 的 display:flex 会覆盖
   [hidden]，导致未激活的容器（如单页视图）始终显示成右侧空白白块。 */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui,
    -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sr-only {
  position: absolute; left: -999px; top: 0;
}

/* ---------- Header ---------- */
.reader-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.reader-bar {
  display: flex; align-items: center; gap: 14px;
  height: 60px; flex-wrap: wrap;
}
.reader-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; white-space: nowrap;
}
.reader-logo { width: 30px; height: 30px; border-radius: 7px; }
.reader-jump { flex: 1 1 240px; min-width: 200px; }
.reader-jump select {
  width: 100%; max-width: 460px;
  padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 0.95rem; cursor: pointer;
}
.reader-toggles { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: var(--card);
}
.seg-btn {
  border: none; background: transparent; color: var(--text-soft);
  padding: 8px 14px; font-weight: 700; font-size: 0.9rem; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--accent); color: #fff; }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer; font-size: 1rem;
}
.theme-toggle:hover { transform: rotate(20deg); }

/* ---------- Text view ---------- */
.reader-main { min-height: calc(100vh - 60px - 120px); }
.text-view { padding: 36px 0 64px; }
.article-body {
  max-width: 820px; margin: 0 auto; padding: 0 20px;
}
.article-body h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.25; margin: 0 0 18px; }
.article-body .article-title {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 10px;
  margin-bottom: 22px;
}
.article-body h2 { font-size: 1.4rem; margin: 28px 0 12px; }
.article-body h3 { font-size: 1.15rem; margin: 22px 0 10px; }
.article-body h4 { font-size: 1.02rem; margin: 18px 0 8px; }
.article-body p { margin: 0 0 16px; }
.article-body ul { margin: 0 0 16px; padding-left: 22px; }
.article-body li { margin: 4px 0; }
.article-body pre {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; overflow-x: auto;
  font-size: 0.9rem; line-height: 1.5;
}
.article-body code { font-family: "SFMono-Regular", Consolas, monospace; }
.article-body .err { color: var(--accent); }
.zh-text-note {
  max-width: 820px; margin: 0 auto; padding: 12px 16px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 10px; color: var(--text); font-size: 0.9rem;
}

/* ---------- PDF view ---------- */
.pdf-view { padding: 18px 0 48px; }
.pdf-toolbar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 16px;
}
.pdf-nav {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.pdf-nav:hover { border-color: var(--accent); color: var(--accent); }
.pdf-nav:disabled { opacity: 0.35; cursor: default; }
.pdf-indicator { font-weight: 700; min-width: 140px; text-align: center; }
.pdf-loading { color: var(--text-soft); font-size: 0.9rem; }

.pdf-stage {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; justify-content: center; align-items: flex-start;
}
.pdf-spread { display: flex; gap: 14px; justify-content: center; }
.pdf-single { display: flex; justify-content: center; }
.pdf-page-wrap {
  background: #fff; border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}
.pdf-page-wrap.blank {
  display: none;
}
.pdf-page-wrap canvas { display: block; max-width: 100%; }

.pdf-fallback {
  max-width: 720px; margin: 24px auto; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 10px; text-align: center; color: var(--text-soft);
}
.pdf-fallback a { font-weight: 700; }

/* ---------- Footer ---------- */
.reader-footer {
  border-top: 1px solid var(--border); background: var(--bg-soft);
  padding: 22px 0 28px; text-align: center;
}
.reader-footer p { margin: 4px 0; font-size: 0.85rem; color: var(--text-soft); }
.reader-disclaimer { color: var(--accent); }

@media (max-width: 720px) {
  .reader-bar { height: auto; padding: 10px 0; }
  .reader-toggles { margin-left: 0; width: 100%; justify-content: space-between; }
  .reader-jump { flex-basis: 100%; }
}
