/* ============================================================
   前台样式（清爽博客风）
   约定：颜色/圆角/宽度全部走主题变量，20 套主题靠覆盖这些变量换肤
   ============================================================ */
:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --border: #e8edf4;
  --tag-bg: #eff4ff;
  --radius: 16px;
  --maxw: 1120px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .14);
  --shadow-hover: 0 2px 6px rgba(16, 24, 40, .06), 0 18px 40px -18px rgba(16, 24, 40, .22);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel: #151b26;
    --text: #e6eaf2;
    --muted: #98a2b3;
    --border: #232b3a;
    --tag-bg: #1b2434;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-hover: 0 18px 40px -18px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.72;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; transition: color .18s ease; }
a:hover { color: var(--brand); }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }

/* ---------------- 顶部导航 ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-in { display: flex; align-items: center; gap: 22px; height: 66px; }
.logo {
  font-size: 19px; font-weight: 800; letter-spacing: -.2px;
  display: inline-flex; align-items: center; gap: 9px; flex: none;
}
.logo::before {
  content: ""; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #7c3aed));
  box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--brand) 70%, transparent);
}
.logo b { color: var(--brand); font-weight: 800; }


.nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.nav a, .nav .nav-item > a {
  display: inline-block; padding: 7px 13px; border-radius: 10px;
  font-size: 14.5px; color: var(--muted); white-space: nowrap;
}
.nav a:hover, .nav .nav-item:hover > a { background: var(--tag-bg); color: var(--text); }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 15px;
  transition: box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.searchbox:focus-within { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); box-shadow: var(--ring); background: var(--panel); }
.searchbox input { border: 0; outline: 0; background: transparent; color: var(--text); width: 150px; font-size: 13.5px; font-family: inherit; }
.searchbox input::placeholder { color: var(--muted); }
.searchbox::before { content: "⌕"; color: var(--muted); font-size: 15px; line-height: 1; }

@media (max-width: 820px) {
  .header-in { height: auto; flex-wrap: wrap; padding: 10px 0 0; row-gap: 8px; }
  .logo { order: 1; }
  .searchbox { order: 2; margin-left: auto; }
  .searchbox input { width: 118px; }
  .nav {
    order: 3; flex-basis: 100%; display: flex; gap: 2px;
    overflow-x: auto; padding: 2px 0 10px; margin: 0 -4px;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav .nav-item > a { padding: 6px 11px; font-size: 14px; }
  .nav .nav-drop { display: none !important; }
}

/* ---------------- 页脚 ---------------- */
.site-footer { margin-top: 72px; border-top: 1px solid var(--border); background: var(--panel); }
.footer-in {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center;
  justify-content: space-between; padding: 26px 0; color: var(--muted); font-size: 13px;
}
@media (max-width: 620px) { .footer-in { flex-direction: column; align-items: flex-start; gap: 10px; } }
.footer-in nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-in a:hover { color: var(--brand); }

/* ---------------- 布局 ---------------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 30px; margin-top: 26px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; gap: 22px; } }

/* ---------------- 卡片 ---------------- */
.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 700px) { .post-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .22s cubic-bezier(.2, .8, .3, 1), box-shadow .22s ease, border-color .22s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--brand) 22%, var(--border)); }

.card > a { display: block; overflow: hidden; }
.card .thumb {
  width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block;
  background: var(--tag-bg); transition: transform .5s cubic-bezier(.2, .8, .3, 1);
}
.card:hover .thumb { transform: scale(1.035); }

.card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card h3 { margin: 0; font-size: 16.5px; font-weight: 650; line-height: 1.5; letter-spacing: -.1px; }
.card h3 a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .excerpt {
  margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.68;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1;
}
.card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.card .meta > span + span::before { content: "·"; margin-right: 10px; opacity: .6; }
.badge {
  background: var(--tag-bg); color: var(--brand);
  font-size: 11.5px; font-weight: 500; padding: 2.5px 9px; border-radius: 999px;
}
.badge:hover { background: color-mix(in srgb, var(--brand) 14%, var(--panel)); }

/* 榜单单号 */
.card .rk {
  position: absolute; margin: 10px; z-index: 2;
  width: 26px; height: 26px; border-radius: 9px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  color: var(--brand); font-weight: 700; font-size: 13px;
  backdrop-filter: blur(6px);
}
.card { position: relative; }

/* 精选区 */
.hero { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 26px; }
.hero .card h3 { font-size: 16px; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .hero { grid-template-columns: 1fr; } }

/* ---------------- 区块标题 ---------------- */
.page-title {
  display: flex; align-items: center; gap: 10px;
  margin: 30px 0 16px; font-size: 19px; font-weight: 700; letter-spacing: -.2px;
}
.page-title::before {
  content: ""; width: 4px; height: 17px; border-radius: 3px;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 45%, transparent));
  flex: none;
}

/* ---------------- 侧栏 ---------------- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.panel h4 {
  margin: 0 0 14px; font-size: 14px; font-weight: 650; letter-spacing: .01em;
  display: flex; align-items: center; gap: 8px;
}
.panel h4::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex: none; }

.tagcloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tagcloud a {
  background: var(--tag-bg); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px;
  transition: background .18s ease, color .18s ease;
}
.tagcloud a:hover { background: var(--brand); color: #fff; }

.rank-list { list-style: none; margin: 0; padding: 0; counter-reset: rk; }
.rank-list li {
  counter-increment: rk; display: flex; gap: 10px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; line-height: 1.5;
}
.rank-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.rank-list li::before {
  content: counter(rk); flex: none;
  width: 19px; height: 19px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--tag-bg); color: var(--brand);
  font-size: 11.5px; font-weight: 700;
}
.rank-list li:nth-child(-n+3)::before { background: var(--brand); color: #fff; }

/* ---------------- 文章页 ---------------- */
.crumb { color: var(--muted); font-size: 12.5px; margin-top: 20px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--brand); }

.article {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 40px 46px 46px; box-shadow: var(--shadow);
}
@media (max-width: 760px) { .article { padding: 24px 20px 30px; border-radius: 14px; } }

.article-head { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.article h1 { font-size: clamp(24px, 3.2vw, 31px); line-height: 1.38; letter-spacing: -.4px; margin: 0 0 14px; font-weight: 750; }
.article .meta-line {
  color: var(--muted); font-size: 12.5px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
}
.article .meta-line > span + span::before { content: "·"; margin-right: 14px; opacity: .55; }
.article > img { width: 100%; border-radius: 12px; margin: 4px 0 24px; }
.series-flag {
  display: inline-block; background: var(--tag-bg); color: var(--brand);
  font-size: 12px; font-weight: 600; padding: 3px 12px; border-radius: 999px; margin-bottom: 12px;
}

.prose { font-size: 16.5px; line-height: 1.9; color: var(--text); }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.15em; }
.prose h2 {
  font-size: 21px; line-height: 1.5; font-weight: 700; letter-spacing: -.2px;
  margin: 2em 0 .8em; padding-left: 12px;
  border-left: 3px solid var(--brand);
}
.prose h3 { font-size: 18px; font-weight: 650; margin: 1.7em 0 .6em; }
.prose h4 { font-size: 16.5px; margin: 1.4em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.35em; margin: 0 0 1.15em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--brand); }
.prose a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose img { border-radius: 12px; margin: 1.5em auto; box-shadow: var(--shadow); }
.prose figure { margin: 1.7em 0; }
.prose figcaption { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.prose figure img { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.prose hr { border: 0; border-top: 1px dashed var(--border); margin: 2em 0; }
.prose blockquote {
  margin: 1.4em 0; padding: 14px 18px;
  border-left: 3px solid var(--brand); border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--brand) 6%, var(--panel));
  color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose pre {
  background: #0f172a; color: #dbe4ff; border-radius: 12px;
  padding: 18px 20px; overflow-x: auto; font-size: 13.5px; line-height: 1.7;
  margin: 1.5em 0;
}
.prose pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; }
.prose code { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.prose :not(pre) > code {
  background: var(--tag-bg); color: color-mix(in srgb, var(--brand) 70%, var(--text));
  padding: 2px 6px; border-radius: 6px; font-size: .88em;
}
.prose table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 1.5em 0; font-size: 14.5px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.prose th, .prose td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.prose th { background: color-mix(in srgb, var(--tag-bg) 60%, var(--panel)); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg) 55%, transparent); }

/* 阅读进度 */
.progress-bar { position: fixed; top: 0; left: 0; height: 3px; background: linear-gradient(90deg, var(--brand), #7c3aed); z-index: 100; transition: width .1s linear; }

/* 目录 */
.toc ol { margin: 0; padding-left: 18px; font-size: 13px; }
.toc li { margin: 5px 0; }

/* 操作区 */
.act-row { display: flex; gap: 12px; margin: 30px 0; }
.act-row button {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 8px 18px; cursor: pointer; font: inherit; font-size: 13.5px;
  transition: all .18s ease;
}
.act-row button:hover { border-color: var(--brand); color: var(--brand); background: var(--tag-bg); }

/* FAQ */
.faq { padding: 18px 22px; }
.faq details {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 8px 0;
  background: color-mix(in srgb, var(--bg) 45%, var(--panel));
}
.faq details[open] { border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }
.faq summary { cursor: pointer; font-weight: 600; font-size: 14.5px; }
.faq summary::marker { color: var(--brand); }
.faq p { margin: 10px 0 0; color: var(--muted); font-size: 14.5px; }

/* ---------------- 评论 ---------------- */
.comment-list .panel { margin-bottom: 12px; }
.comment-list .meta-line { color: var(--muted); font-size: 12.5px; }
.cmt { border-top: 1px solid var(--border); padding: 14px 0; }
.cmt .who { font-weight: 600; font-size: 13.5px; }
.cmt .when { color: var(--muted); font-size: 12px; }
.cmt textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font: inherit; background: var(--bg); color: var(--text); resize: vertical;
}

/* ---------------- 表单与按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff !important; border: 1px solid transparent;
  border-radius: 999px; padding: 10px 22px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand) 80%, transparent);
  transition: all .18s ease;
}
.btn:hover { background: var(--brand-2); transform: translateY(-1px); }
.btn.ghost { background: var(--panel); color: var(--text) !important; border-color: var(--border); box-shadow: none; }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand) !important; background: var(--tag-bg); }

input.field, select.field, textarea.field {
  width: 100%; border: 1px solid var(--border); border-radius: 11px;
  padding: 10px 13px; font: inherit; background: var(--panel); color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease;
}
input.field:focus, select.field:focus, textarea.field:focus {
  outline: 0; border-color: color-mix(in srgb, var(--brand) 50%, var(--border)); box-shadow: var(--ring);
}

/* ---------------- 分页 ---------------- */
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 34px 0 8px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 36px; height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
  font-size: 13.5px; color: var(--text);
}
.pager a:hover { border-color: var(--brand); color: var(--brand); background: var(--tag-bg); }
.pager .cur { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* ---------------- 杂项 ---------------- */
.hl { background: #fff3bf; border-radius: 3px; padding: 0 2px; }
@media (prefers-color-scheme: dark) { .hl { background: #5c4d1a; } }
.author-card { display: flex; gap: 14px; align-items: center; }
.author-card img { width: 52px; height: 52px; border-radius: 50%; }
.update-tip {
  font-size: 12.5px; color: var(--muted); background: var(--tag-bg);
  border-radius: 10px; padding: 8px 14px; margin: 16px 0;
}
.top-btn {
  position: fixed; right: 24px; bottom: 24px; width: 42px; height: 42px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--panel);
  cursor: pointer; box-shadow: var(--shadow); font-size: 15px; color: var(--muted);
  transition: all .18s ease;
}
.top-btn:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-2px); }

/* ASCII 图示 */
.ascii-fig { margin: 20px 0; }
.ascii-fig pre.ascii {
  font-family: ui-monospace, "Courier New", monospace; font-size: 12.5px; line-height: 1.55;
  background: color-mix(in srgb, var(--bg) 70%, var(--panel));
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch;
}
.ascii-fig figcaption { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* 导航下拉 */
.nav .nav-item { position: relative; display: inline-flex; align-items: center; }
.nav .nav-drop {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 150px;
  display: none; flex-direction: column; padding: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-hover); z-index: 30;
}
.nav .nav-item:hover .nav-drop { display: flex; }
.nav .nav-drop a { display: block; padding: 7px 11px; border-radius: 8px; white-space: nowrap; font-size: 13.5px; }
.nav .nav-drop a:hover { background: var(--tag-bg); }

/* ---------------- 补充：无封面卡片 / 段落标题 / 评论表单 / 空状态 ---------------- */
.card.no-cover::before {
  content: "✦";
  display: grid; place-items: center;
  height: 104px;
  color: color-mix(in srgb, var(--brand) 60%, transparent);
  font-size: 19px;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 60%),
    linear-gradient(135deg, color-mix(in srgb, var(--brand) 7%, var(--panel)), color-mix(in srgb, var(--panel) 92%, var(--brand)));
  border-bottom: 1px solid var(--border);
}
.card.no-cover .body { padding-top: 16px; }
.card.no-cover h3 { font-size: 17px; }

.prose h1 { font-size: 23px; font-weight: 700; letter-spacing: -.2px; margin: 1.7em 0 .7em; line-height: 1.5; }

/* 评论区表单（前台 article.php 里没有单独类名，用容器限定） */
#comments form.panel { padding: 20px 22px; }
#comments form.panel input:not([type="hidden"]),
#comments form.panel textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 13px; font: inherit; font-size: 14.5px;
  background: var(--bg); color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease;
}
#comments form.panel input:focus,
#comments form.panel textarea:focus {
  outline: 0; border-color: color-mix(in srgb, var(--brand) 50%, var(--border));
  box-shadow: var(--ring); background: var(--panel);
}
#comments form.panel textarea { min-height: 96px; resize: vertical; }
#comments form.panel .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
@media (max-width: 620px) { #comments form.panel .row2 { grid-template-columns: 1fr; } }

/* 空状态 */
.empty-state {
  padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px;
  background: var(--panel); border: 1px dashed var(--border); border-radius: 14px;
}

/* 桌面端侧栏跟随滚动 */
@media (min-width: 981px) {
  .layout > aside { position: sticky; top: 86px; }
}
