/* 信标Beacon 设计系统 — 参照 CSDN 的信息密度与红白主题
   手写 CSS，零构建依赖，gzip < 30KB */

:root {
  --ink: #1f2933;
  --ink-soft: #52606d;
  --ink-faint: #9aa5b1;
  --paper: #ffffff;
  --subtle: #f5f6f7;
  --line: #e8eaed;
  --accent: #fc5531;          /* 信标红 */
  --accent-hover: #e0441f;
  --accent-soft: #fff3f0;
  --code-bg: #f6f8fa;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink);
  background: var(--subtle);
}
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; border-radius: 6px; }

.container { max-width: 76rem; margin: 0 auto; padding: 0 1rem; }
.reading { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }
.hidden { display: none !important; }
.muted { color: var(--ink-faint); }

/* ---------- 顶部导航（白色 sticky，信标红点缀） ---------- */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.site-header .container {
  display: flex; align-items: center; gap: 1.25rem; height: 3.5rem;
}
.site-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.site-title:hover { color: var(--ink); }
.site-title .beacon-dot {
  width: 0.75rem; height: 0.75rem; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.site-title .beacon-en { color: var(--accent); }
.site-nav { display: flex; gap: 1.1rem; margin-left: 1rem; }
.site-nav a { color: var(--ink-soft); font-size: 0.9375rem; padding: 0.2rem 0; }
.site-nav a.active, .site-nav a:hover { color: var(--accent); }
.search-form { margin-left: auto; }
.search-input {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.35rem 1rem; font-size: 0.875rem; width: 13rem;
  background: var(--subtle);
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }

/* ---------- 用户区 ---------- */
.user-area { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; margin-left: 0.5rem; }
.user-area .user-name { color: var(--ink); font-weight: 600; }
.logout-form { display: inline; margin: 0; }
.link-btn { background: none; border: none; padding: 0; color: var(--ink-soft); font-size: 0.875rem; cursor: pointer; }
.link-btn:hover { color: var(--accent); }

/* ---------- 首页三栏布局 ---------- */
.home-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 300px;
  gap: 1.25rem;
  padding: 1.25rem 0 2rem;
  align-items: start;
}
@media (max-width: 1024px) { .home-layout { grid-template-columns: minmax(0,1fr) 280px; } .home-left { display: none; } }
@media (max-width: 768px)  { .home-layout { grid-template-columns: 1fr; } .home-right { display: none; } }

.home-left, .home-right { position: sticky; top: 4.75rem; }
.side-card {
  background: var(--paper); border-radius: 8px; border: 1px solid var(--line);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.side-card h3 {
  margin: 0 0 0.6rem; font-size: 0.9375rem; font-weight: 600;
}
.side-card h3::after { content: ""; display: block; margin-top: 0.35rem; width: 1.8rem; border-bottom: 2px solid var(--accent); }

/* 左侧分类导航 */
.cat-nav { list-style: none; margin: 0; padding: 0; }
.cat-nav li { margin: 0.15rem 0; }
.cat-nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 0.6rem; border-radius: 6px; font-size: 0.9rem; color: var(--ink-soft);
}
.cat-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.cat-nav .count { font-size: 0.75rem; color: var(--ink-faint); }

/* 右侧：标签云 / 最新文章 */
.side-tags { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.side-tags a {
  font-size: 0.8125rem; color: var(--ink-soft);
  background: var(--subtle); border-radius: 4px; padding: 0.15rem 0.6rem;
}
.side-tags a:hover { background: var(--accent-soft); color: var(--accent); }
.side-latest { list-style: none; margin: 0; padding: 0; }
.side-latest li { padding: 0.35rem 0; font-size: 0.875rem; line-height: 1.5; }
.side-latest a { color: var(--ink-soft); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-latest a:hover { color: var(--accent); }

/* ---------- 文章卡片（CSDN 信息流风格） ---------- */
.post-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 1.1rem 1.25rem; margin-bottom: 0.9rem;
  display: flex; gap: 1rem; transition: box-shadow .15s;
}
.post-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.post-card-main { flex: 1; min-width: 0; }
.post-card h2 { margin: 0 0 0.3rem; font-size: 1.125rem; line-height: 1.5; font-weight: 600; }
.post-card h2 a:hover { color: var(--accent); }
.post-card .excerpt {
  color: var(--ink-soft); font-size: 0.875rem; margin: 0 0 0.6rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card .cover-thumb {
  width: 8.5rem; height: 6rem; object-fit: cover; border-radius: 6px; flex-shrink: 0;
}
.post-meta { font-size: 0.8125rem; color: var(--ink-faint); display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: center; }
.post-meta .author { color: var(--ink-soft); font-weight: 500; }
.pinned-badge {
  display: inline-block; font-size: 0.72rem; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 4px; padding: 0 0.35rem; margin-right: 0.4rem;
  vertical-align: middle;
}
.stat { display: inline-flex; align-items: center; gap: 0.25rem; }

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 0.5rem; justify-content: center; padding: 1.5rem 0 2.5rem; }
.pagination a, .pagination span {
  padding: 0.35rem 0.85rem; border: 1px solid var(--line); border-radius: 6px;
  font-size: 0.875rem; color: var(--ink-soft); background: var(--paper);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- 文章详情页（左作者卡 + 中正文 + 右目录） ---------- */
.post-header { padding: 2rem 0 1rem; }
.post-header h1 { font-size: 1.75rem; line-height: 1.35; margin: 0 0 0.75rem; }
.post-layout { display: flex; gap: 1.5rem; align-items: flex-start; }
.post-body { flex: 1; min-width: 0; }
.post-body-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 1.75rem 2rem;
}
.post-leftbar { width: 13rem; flex-shrink: 0; display: none; }
.post-sidebar { width: 15rem; flex-shrink: 0; display: none; }
@media (min-width: 900px)  { .post-leftbar { display: block; } }
@media (min-width: 1200px) { .post-sidebar { display: block; } }

/* 作者卡片 */
.author-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 1.25rem 1rem; text-align: center;
  position: sticky; top: 4.75rem;
}
.author-avatar {
  width: 3.5rem; height: 3.5rem; border-radius: 50%; margin: 0 auto 0.6rem;
  background: var(--accent); color: #fff; font-size: 1.5rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.author-card .name { font-weight: 600; margin-bottom: 0.75rem; }
.author-stats { display: flex; border-top: 1px solid var(--line); padding-top: 0.75rem; }
.author-stats > div { flex: 1; }
.author-stats .num { font-weight: 700; font-size: 1.05rem; }
.author-stats .lbl { font-size: 0.75rem; color: var(--ink-faint); }

/* TOC */
.toc {
  position: sticky; top: 4.75rem; font-size: 0.875rem; line-height: 1.7;
  max-height: 70vh; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 1rem 1.1rem;
}
.toc .toc-title { font-weight: 600; margin-bottom: 0.5rem; }
.toc .toc-title::after { content: ""; display: block; margin-top: 0.35rem; width: 1.8rem; border-bottom: 2px solid var(--accent); }
.toc ul { list-style: none; margin: 0; padding-left: 0; }
.toc ul ul { padding-left: 1rem; }
.toc a { color: var(--ink-soft); display: block; padding: 0.15rem 0; }
.toc a.active { color: var(--accent); font-weight: 600; }
.toc a:hover { color: var(--accent); }

/* 移动端 TOC 抽屉 */
#toc-toggle {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50;
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 0.6rem 1.1rem; font-size: 0.875rem; box-shadow: 0 4px 14px rgba(252,85,49,.35);
  display: none; cursor: pointer;
}
@media (max-width: 1199px) { #toc-toggle { display: block; } }
#toc-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }
#toc-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-radius: 12px 12px 0 0;
  max-height: 60vh; overflow-y: auto; padding: 1.25rem 1.5rem;
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
}

/* ---------- 正文排版 ---------- */
.post-content { font-size: 1rem; line-height: 1.8; }
.post-content h1 { font-size: 1.5rem; line-height: 1.4; font-weight: 600; margin: 2.25rem 0 1rem; scroll-margin-top: 4.5rem; }
.post-content h2 { font-size: 1.5rem; line-height: 1.4; font-weight: 600; margin: 2.25rem 0 1rem; padding-left: 0.7rem; border-left: 4px solid var(--accent); scroll-margin-top: 4.5rem; }
.post-content h3 { font-size: 1.25rem; line-height: 1.5; font-weight: 600; margin: 1.75rem 0 0.75rem; scroll-margin-top: 4.5rem; }
.post-content h4 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; scroll-margin-top: 4.5rem; }
.post-content p { margin: 1rem 0; }
.post-content a { color: var(--accent); text-underline-offset: 2px; }
.post-content a:hover { text-decoration: underline; }
.post-content ul, .post-content ol { padding-left: 1.5rem; margin: 1rem 0; }
.post-content li { margin: 0.25rem 0; }
.post-content blockquote {
  margin: 1.25rem 0; padding: 0.5rem 1rem;
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  color: var(--ink-soft); border-radius: 0 6px 6px 0;
}
.post-content blockquote p { margin: 0.25rem 0; }
.post-content hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }
.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em; background: var(--subtle);
  padding: 0.1rem 0.4rem; border-radius: 4px; color: #c7254e;
}
.post-content pre {
  background: var(--code-bg); border-radius: 8px;
  padding: 1rem; overflow-x: auto;
  font-size: 0.875rem; line-height: 1.6; margin: 1.25rem 0;
}
.post-content pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.post-content table { display: block; overflow-x: auto; border-collapse: collapse; margin: 1.25rem 0; max-width: 100%; }
.post-content th, .post-content td { border: 1px solid var(--line); padding: 0.45rem 0.9rem; font-size: 0.9375rem; white-space: nowrap; }
.post-content th { background: var(--subtle); font-weight: 600; }
.post-content tr:nth-child(even) td { background: #fafbfc; }
.code-copy {
  position: absolute; top: 0.5rem; right: 0.5rem;
  font-size: 0.75rem; color: var(--ink-faint);
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  padding: 0.15rem 0.5rem; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.post-content pre:hover .code-copy { opacity: 1; }

/* ---------- 文章操作区（收藏） ---------- */
.post-actions {
  margin-top: 2rem; padding: 1rem 0 0; border-top: 1px solid var(--line);
  display: flex; justify-content: center;
}

/* ---------- 上下篇 / 页脚 ---------- */
.post-nav { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem 0; font-size: 0.9375rem; }
.post-nav a { max-width: 48%; color: var(--ink-soft); }
.post-nav a:hover { color: var(--accent); }
.site-footer {
  margin-top: 2rem; background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 2rem 0; color: var(--ink-faint); font-size: 0.8125rem; text-align: center;
}
.site-footer a { color: var(--ink-faint); }
.site-footer a:hover { color: var(--accent); }
.psb-link { display: inline-flex; align-items: center; gap: 0.3rem; }
.psb-badge { width: 16px; height: 16px; border-radius: 0; }

/* ---------- AI 助手浮窗（仅站长） ---------- */
#ai-toggle {
  position: fixed; right: 1.25rem; bottom: 4.5rem; z-index: 50;
  width: 3rem; height: 3rem; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  box-shadow: 0 4px 14px rgba(252,85,49,.35);
}
#ai-panel {
  position: fixed; right: 1.25rem; bottom: 8rem; z-index: 60;
  width: 22rem; max-width: calc(100vw - 2.5rem);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  display: flex; flex-direction: column; overflow: hidden;
}
.ai-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0.9rem; background: var(--accent); color: #fff;
  font-size: 0.875rem; font-weight: 600;
}
.ai-close { background: none; border: none; color: #fff; font-size: 1.25rem; cursor: pointer; line-height: 1; }
.ai-toolbar { padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line); }
.ai-toolbar select {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.3rem 0.5rem; font-size: 0.8125rem;
}
.ai-messages {
  flex: 1; min-height: 12rem; max-height: 20rem; overflow-y: auto;
  padding: 0.75rem 0.9rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.ai-msg {
  padding: 0.5rem 0.75rem; border-radius: 8px; font-size: 0.875rem;
  line-height: 1.6; max-width: 88%; white-space: pre-wrap; word-break: break-word;
}
.ai-msg-bot { background: var(--subtle); align-self: flex-start; }
.ai-msg-user { background: var(--accent); color: #fff; align-self: flex-end; }
.ai-form {
  display: flex; gap: 0.5rem; padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--line);
}
.ai-form input {
  flex: 1; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.4rem 0.7rem; font-size: 0.875rem;
}
.ai-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- 分类 / 标签 / 归档页 ---------- */
.term-list { list-style: none; padding: 0; margin: 1.5rem 0; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.term-list li {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--line);
}
.term-list li:last-child { border-bottom: none; }
.term-list .count { color: var(--ink-faint); font-size: 0.8125rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.5rem 0; }
.tag-cloud a {
  border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 1rem;
  color: var(--ink-soft); font-size: 0.875rem; background: var(--paper);
}
.tag-cloud a:hover { border-color: var(--accent); color: var(--accent); }
.archive-group h2 { font-size: 1.125rem; margin: 1.75rem 0 0.5rem; color: var(--accent); }
.archive-group ul { list-style: none; padding: 0; margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.archive-group li { padding: 0.55rem 1.25rem; display: flex; gap: 1rem; border-bottom: 1px solid var(--line); }
.archive-group li:last-child { border-bottom: none; }
.archive-group time { color: var(--ink-faint); font-size: 0.8125rem; flex-shrink: 0; width: 6.5rem; }

/* ---------- 搜索 ---------- */
mark { background: #ffe58f; padding: 0 0.1em; border-radius: 2px; }
.search-summary { color: var(--ink-soft); margin: 1.5rem 0 0.5rem; }

/* ---------- 空态 / 404 ---------- */
.empty-state { text-align: center; padding: 5rem 1rem; color: var(--ink-faint); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 1rem; }

/* ---------- 认证卡片（登录/注册） ---------- */
.auth-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 2rem; max-width: 26rem; margin: 2.5rem auto;
  box-shadow: 0 4px 20px rgba(0,0,0,.05);
}
.auth-card h1 { font-size: 1.375rem; margin: 0 0 1rem; }

/* ---------- 后台 ---------- */
.admin-layout { display: flex; min-height: 100vh; background: var(--subtle); }
.admin-sidebar {
  width: 12rem; flex-shrink: 0; background: #fff;
  border-right: 1px solid var(--line); padding: 1.5rem 0;
}
.admin-sidebar .brand { font-weight: 700; padding: 0 1.25rem 1.25rem; border-bottom: 1px solid var(--line); }
.admin-sidebar nav a { display: block; padding: 0.6rem 1.25rem; color: var(--ink-soft); font-size: 0.9375rem; }
.admin-sidebar nav a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); border-right: 3px solid var(--accent); }
.admin-sidebar nav a:hover { color: var(--accent); }
.admin-main { flex: 1; padding: 1.75rem 2rem; min-width: 0; }
.admin-main h1 { font-size: 1.375rem; margin: 0 0 1.25rem; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--subtle); }
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 2.25rem; width: 22rem; box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.login-card h1 { font-size: 1.25rem; margin: 0 0 0.25rem; text-align: center; }
.login-card .sub { color: var(--ink-faint); font-size: 0.8125rem; text-align: center; margin-bottom: 1.5rem; }
.login-error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; text-align: center; }

.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: 0.875rem; color: var(--ink-soft); margin-bottom: 0.3rem; }
.form-row input[type=text], .form-row input[type=password], .form-row select, .form-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.5rem 0.75rem; font-size: 0.9375rem; font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}

.btn {
  display: inline-block; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.45rem 1.1rem; font-size: 0.875rem; cursor: pointer;
  background: #fff; color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { color: #dc2626; }
.btn-danger:hover { border-color: #dc2626; color: #dc2626; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.25rem 0.8rem; font-size: 0.8125rem; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; background: #fff; border-radius: 8px; overflow: hidden; }
.admin-table th, .admin-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--ink-soft); font-weight: 600; background: var(--subtle); }
.badge { display: inline-block; font-size: 0.75rem; border-radius: 4px; padding: 0 0.45rem; }
.badge-published { background: #dcfce7; color: #166534; }
.badge-draft { background: #fef9c3; color: #854d0e; }

.editor-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.editor-tabs button {
  border: none; background: none; padding: 0.5rem 1.1rem; font-size: 0.875rem;
  color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent;
}
.editor-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
#md-editor {
  width: 100%; min-height: 26rem; border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 8px 8px; padding: 1rem; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.875rem; line-height: 1.7; resize: vertical; background: #fff;
}
#md-preview {
  border: 1px solid var(--line); border-top: none; border-radius: 0 0 8px 8px;
  padding: 1rem 1.25rem; min-height: 26rem; background: #fff;
}
.editor-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.editor-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }

.import-drop {
  border: 2px dashed var(--line); border-radius: 10px; padding: 3rem 1.5rem;
  text-align: center; color: var(--ink-faint); margin-bottom: 1rem; background: #fff;
}
.import-result { margin-top: 1.5rem; }
.import-result .ok { color: #166534; }
.import-result .fail { color: #dc2626; }
.import-result .skip { color: var(--ink-faint); }

@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); padding: 0.75rem 0; }
  .admin-sidebar nav { display: flex; flex-wrap: wrap; }
  .admin-main { padding: 1rem; }
  .editor-meta { grid-template-columns: 1fr; }
  .post-layout { display: block; }
  .post-card .cover-thumb { display: none; }
  .site-nav { display: none; }
}
