/* ============ 科技爱好者周刊 归档站 ============ */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --topbar-bg: #ffffff;
  --sidebar-w: 290px;
  --toc-w: 250px;
  --topbar-h: 58px;
  --code-bg: #0f172a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 顶部栏 ============ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 100;
  box-shadow: var(--shadow);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-logo { font-size: 20px; }
.brand-text { letter-spacing: .5px; }

.search-box {
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: #fff;
}

.search-results {
  position: absolute;
  top: 46px; left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  max-height: 480px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-results.show { display: block; }
.search-result-item {
  display: block;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-soft); text-decoration: none; }
.search-result-title { font-weight: 600; font-size: 15px; }
.search-result-title mark { background: #fde68a; border-radius: 3px; padding: 0 2px; }
.search-result-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.search-result-snippet { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.search-result-snippet mark { background: #fde68a; border-radius: 3px; padding: 0 2px; }
.search-empty { padding: 20px; text-align: center; color: var(--text-faint); }

.menu-toggle {
  display: none;
  background: none; border: none;
  font-size: 22px; cursor: pointer; color: var(--text);
  padding: 4px 8px;
}

/* ============ 布局 ============ */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  align-items: flex-start;
}


/* ============ 左侧目录树 ============ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0 40px;
}
.sidebar-title {
  font-weight: 700; font-size: 13px;
  color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .8px;
  padding: 0 16px 10px;
}
.tree { font-size: 14px; }

.group-toggle {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 7px 16px;
  background: none; border: none;
  font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: left;
  transition: background .12s;
}
.group-toggle:hover { background: var(--bg); }
.toggle-arrow { font-size: 11px; color: var(--text-muted); transition: transform .15s; width: 12px; display: inline-block; }
.year-group.open > .group-toggle .toggle-arrow,
.month-group.open > .group-toggle .toggle-arrow { transform: rotate(90deg); }
.count { color: var(--text-faint); font-weight: 400; font-size: 12px; }

.year-toggle { font-size: 15px; color: var(--text); }
.month-toggle { padding-left: 30px; font-weight: 500; }

.group-body { display: none; }
.year-group.open > .group-body { display: block; }
.month-body { display: none; list-style: none; margin: 0; padding: 0 0 6px; }
.month-group.open > .month-body { display: block; }

.month-body li a {
  display: block;
  padding: 5px 16px 5px 48px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  border-left: 2px solid transparent;
}
.month-body li a:hover { color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.month-body li a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}
.issue-no { color: var(--text-faint); font-weight: 500; margin-right: 4px; }

/* ============ 中间内容 ============ */
.content {
  flex: 1;
  min-width: 0;
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}
.article { max-width: 100%; }

.article-header { margin-bottom: 28px; border-bottom: 1px solid var(--border); padding-bottom: 20px; }
.article-title {
  margin: 0 0 14px;
  font-size: 28px;
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: .3px;
}
.article-meta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 13px; color: var(--text-muted); }
.meta-issue { background: var(--primary-soft); color: var(--primary); padding: 2px 10px; border-radius: 12px; font-weight: 600; }



/* ============ Markdown 正文 ============ */
.markdown { font-size: 16.5px; line-height: 1.85; color: #24292f; word-wrap: break-word; }
.markdown h2 {
  font-size: 22px; font-weight: 700;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 70px;
}
.markdown h3 {
  font-size: 19px; font-weight: 700;
  margin: 32px 0 12px;
  scroll-margin-top: 70px;
}
.markdown h4 { font-size: 17px; font-weight: 600; margin: 26px 0 10px; scroll-margin-top: 70px; }
.markdown p { margin: 0 0 18px; }
.markdown img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 8px 0;
  display: block;
}
.markdown a { color: var(--primary); }
.markdown blockquote {
  margin: 20px 0;
  padding: 10px 18px;
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  color: #334155;
  border-radius: 0 6px 6px 0;
}
.markdown blockquote p { margin: 0; }
.markdown code {
  font-family: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  color: #be185d;
}
.markdown pre {
  background: var(--code-bg);
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 18px 0;
  line-height: 1.6;
  font-size: 14px;
}
.markdown pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.markdown table {
  border-collapse: collapse;
  margin: 18px 0;
  width: 100%;
  font-size: 14.5px;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.markdown th { background: var(--bg); font-weight: 600; }
.markdown ul, .markdown ol { padding-left: 26px; margin: 0 0 18px; }
.markdown li { margin: 4px 0; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 30px 0; }

/* 上一/下一篇 */
.pager {
  display: flex; gap: 12px; margin-top: 40px;
  border-top: 1px solid var(--border); padding-top: 20px;
  flex-wrap: wrap;
}
.pager-link {
  flex: 1; min-width: 220px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  transition: box-shadow .15s, border-color .15s;
}
.pager-link:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
.pager-link.next { text-align: right; }



/* ============ 右侧目录 ============ */
.toc {
  width: var(--toc-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: transparent;
  padding: 24px 14px 40px;
  font-size: 13px;
}
.toc-title {
  font-weight: 700; font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 10px;
}
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  padding: 5px 10px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
  line-height: 1.45;
}
.toc-list a:hover { color: var(--primary); text-decoration: none; }
.toc-list a.active { color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.toc-l2 a { padding-left: 12px; }
.toc-l3 a { padding-left: 26px; font-size: 12px; color: var(--text-faint); }
.toc-l4 a { padding-left: 38px; font-size: 12px; color: var(--text-faint); }
.toc-empty { color: var(--text-faint); }
.toc-about { color: var(--text-muted); font-size: 13px; line-height: 1.7; }

/* ============ 首页 ============ */
.home-title { font-size: 30px; margin: 0 0 6px; font-weight: 800; }
.home-subtitle { color: var(--text-muted); margin: 0 0 28px; }
.home-year { font-size: 20px; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.home-month { font-size: 16px; margin: 18px 0 8px; color: var(--text-muted); }
.home-articles { list-style: none; margin: 0 0 12px; padding: 0; }
.home-articles li a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 8px 10px; border-radius: 6px;
  color: var(--text); font-size: 15px;
}
.home-articles li a:hover { background: var(--primary-soft); text-decoration: none; }
.home-art-title { flex: 1; }
.home-art-date { color: var(--text-faint); font-size: 12px; white-space: nowrap; }

/* ============ 页脚 ============ */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-faint);
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* 遮罩 */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 90;
}
.overlay.show { display: block; }

/* ============ 响应式 ============ */
@media (max-width: 1100px) {
  .toc { display: none; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0; top: var(--topbar-h);
    bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 95;
    box-shadow: 2px 0 12px rgba(0,0,0,.12);
  }
  .sidebar.show { transform: translateX(0); }
  .menu-toggle { display: block; }
  .content { padding: 24px 18px 60px; }
  .brand-text { display: none; }
}

