/* ========== 基础 ========== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f8fafc;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ========== 头部 / 导航 ========== */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  min-height: 68px;
  padding: 10px 20px;
  position: relative;
}
.logo {
  display: inline-flex;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  height: 48px;
}
.logo-text span { color: var(--primary); margin-left: 6px; }
.logo:hover { color: var(--text); }
/* 移动端方形图标：桌面端隐藏 */
.logo-icon {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
/* 非首页左上角 Logo 图片 */
.logo-has-img .logo-img {
  display: block;
  height: 40px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

/* 汉堡按钮：默认隐藏，移动端显示 */
.nav-toggle {
  display: none;
  margin-left: auto;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-menu {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
}
.nav-links { display: flex; gap: 22px; align-items: center; }
.nav-links a { color: var(--text); font-size: 15px; }
.nav-links a:hover { color: var(--primary); }

/* 右上角软链接（GitHub 等外链） */
.nav-about {
  color: var(--text); font-size: 15px; white-space: nowrap; flex-shrink: 0;
}
.nav-about:hover, .nav-about.active { color: var(--primary); }
.nav-social { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.social-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 13px; line-height: 1;
}
.social-link:hover { color: var(--primary); }
.social-link svg { display: block; }
.social-name { white-space: nowrap; }

/* 右上角分类导航：分类过多时可横向滑动，隐藏滚动条 */
.nav-cats {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-cats::-webkit-scrollbar { display: none; }
.nav-cats a { white-space: nowrap; padding: 4px 0; }
.nav-cats a.active {
  color: var(--primary);
  font-weight: 600;
  position: relative;
}
.nav-cats a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
}

.main { padding: 32px 20px 60px; min-height: 60vh; }

.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0;
  text-align: center;
}
.site-footer p { margin: 0; }
.footer-line { line-height: 1.8; }
.footer-line a { color: var(--muted); }
.footer-line a:hover { color: var(--primary); }

/* ========== 首页 Hero ========== */
.hero {
  /* 纯白 Hero：不放背景图，文字用深色 */
  border-radius: var(--radius);
  padding: 24px 4px 8px;
  margin-bottom: 32px;
  background: none;
}
.hero-inner { padding: 40px 16px; }
.hero-title {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  color: #0f2a5c;
  letter-spacing: 1px;
  line-height: 1.25;
}
.hero-subtitle {
  margin: 14px 0 0;
  font-size: 17px;
  color: #5b6b82;
}
.hero-actions {
  margin-top: 28px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* 橙色主行动按钮（Hero 内） */
.hero .btn-accent {
  background: #f97316;
  border-color: #f97316;
  color: #fff;
}
.hero .btn-accent:hover { background: #ea6a0a; border-color: #ea6a0a; color: #fff; }
/* 描边按钮（白底上用主题色描边） */
.hero .btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}
.hero .btn-outline:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 关注公众号二维码（紧贴按钮栏下方） */
.hero-wechat {
  margin-top: 24px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.hero-wechat img {
  width: 132px;
  height: 132px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
}
.hero-wechat span { color: var(--muted); font-size: 13px; }

/* ========== 文章卡片 ========== */
.post-list { display: grid; gap: 20px; }
.post-card {
  display: flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s;
}
.post-card:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, .07); }
.post-cover { flex: 0 0 240px; background: #f1f5f9; }
.post-cover img { width: 100%; height: 100%; object-fit: cover; }
.post-card-body { padding: 20px 24px; flex: 1; }
.post-card-body h2 { margin: 8px 0; font-size: 21px; line-height: 1.4; }
.post-card-body h2 a { color: var(--text); }
.post-card-body h2 a:hover { color: var(--primary); }
.post-summary { color: var(--muted); margin: 6px 0 12px; font-size: 15px; }

.post-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.badge {
  background: #eff6ff;
  color: var(--primary);
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 12px;
}
a.badge-link { text-decoration: none; }
a.badge-link:hover { background: var(--primary); color: #fff; }

/* 后台新建类目表单 */
.category-create {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.category-create input { flex: 1; max-width: 360px; }
.post-tags { margin: 8px 0; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { color: var(--muted); font-size: 13px; }
.read-more { font-size: 14px; font-weight: 600; }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 32px;
}

/* ========== 文章详情 ========== */
.article {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
}
.article-header h1 {
  font-size: 30px;
  line-height: 1.35;
  margin: 12px 0;
}
.article-cover {
  border-radius: var(--radius);
  margin: 18px 0 8px;
  width: 100%;
}
.article-content { margin-top: 22px; font-size: 16px; }
.article-content h2 { margin-top: 32px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.article-content h3 { margin-top: 26px; }
.article-content blockquote {
  margin: 16px 0;
  padding: 8px 16px;
  border-left: 4px solid var(--primary);
  background: #f8fafc;
  color: var(--muted);
}
.article-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 14px;
}
.article-content code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .92em;
}
.article-content pre code { background: none; padding: 0; }
.article-content table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.article-content th, .article-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
}
.article-content th { background: #f8fafc; }
.article-actions {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.action-group { display: flex; gap: 12px; }

/* 点赞按钮 */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.like-btn svg { fill: none; stroke: currentColor; stroke-width: 2; }
.like-btn.liked {
  color: #e0245e;
  border-color: #f9a8c9;
  background: #fdf2f7;
}
.like-btn.liked svg { fill: #e0245e; stroke: #e0245e; }
.like-btn.liked:hover { color: #e0245e; }

/* ========== 评论区 ========== */
.comments {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-top: 24px;
}
.comments h2 { font-size: 20px; margin: 0 0 18px; }
.comments-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: normal;
  margin-left: 8px;
}
.comment-fields { display: flex; gap: 12px; }
.comment-fields input { flex: 1; }
.field-tip {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}
.comment-form textarea { margin-top: 10px; resize: vertical; min-height: 88px; }
.comment-form-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.comment-hint { font-size: 13px; color: var(--muted); }
.comment-hint.ok { color: #047857; }
.comment-hint.err { color: #b91c1c; }
.comment-list { list-style: none; margin: 22px 0 0; padding: 0; }
.comment-item { border-top: 1px solid var(--border); padding: 14px 0; }
.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.comment-name { font-weight: 600; font-size: 14px; }
.comment-head time { font-size: 12px; color: var(--muted); }
.comment-content {
  margin: 6px 0 0;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-empty {
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--border);
  padding: 18px 0 0;
}

/* ========== 按钮 / 表单 ========== */
.btn {
  display: inline-block;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-block { width: 100%; }

input[type="text"], input[type="password"], input:not([type]), select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
label { display: block; font-size: 14px; color: #374151; margin-bottom: 14px; }
label input, label select, label textarea { margin-top: 6px; }

.flash-wrap { margin-top: 18px; }
.flash {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 14px;
}
.flash-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.empty { text-align: center; padding: 70px 0; color: var(--muted); }
.empty h1 { font-size: 56px; margin: 0; color: #cbd5e1; }

/* ========== 后台 ========== */
.admin-body { background: #f1f5f9; }
.admin-header { background: #fff; border-bottom: 1px solid var(--border); }
.logo-dark { color: #111827; }
.inline-form { display: inline; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.link-btn:hover { color: var(--primary); }
.link-danger:hover { color: #dc2626; }

.login-card {
  max-width: 380px;
  margin: 70px auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
}
.login-card h1 { font-size: 22px; margin: 0 0 22px; text-align: center; }
.login-hint { font-size: 12px; color: var(--muted); margin-top: 14px; text-align: center; }

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.admin-toolbar h1 { font-size: 22px; margin: 0; }
.toolbar-right { display: flex; gap: 10px; }

.admin-table {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: collapse;
  overflow: hidden;
}
.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.admin-table th { background: #f8fafc; color: var(--muted); font-weight: 600; }
.col-title { font-weight: 600; max-width: 320px; }
.col-actions { display: flex; gap: 14px; align-items: center; white-space: nowrap; }
.col-actions a { font-size: 14px; }
.empty-cell { text-align: center; color: var(--muted); padding: 40px; }
.status { font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.status-published, .status-approved { background: #ecfdf5; color: #047857; }
.status-draft, .status-pending { background: #fef3c7; color: #b45309; }

/* 后台评论内容列 */
.col-content { max-width: 360px; word-break: break-word; font-size: 13px; }
.col-email { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* 后台 Logo 预览（横图，按比例） */
.logo-preview {
  max-width: 240px;
  max-height: 96px;
  width: auto;
}

.post-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}
.form-row { display: flex; gap: 16px; }
.form-row label { flex: 1; }
.form-row .flex-2 { flex: 2; }
.upload-hint { font-size: 13px; color: var(--muted); min-height: 20px; margin: 6px 0 0; }

/* ========== 微信分享弹窗 ========== */
.share-modal { position: fixed; inset: 0; z-index: 100; }
.share-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); }
.share-dialog {
  position: relative;
  max-width: 380px;
  margin: 8vh auto;
  background: #fff;
  border-radius: 14px;
  padding: 28px 26px;
  text-align: center;
}
.share-dialog h3 { margin: 0 0 14px; }
.share-close {
  position: absolute;
  top: 8px;
  right: 14px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
}
.share-tip { font-size: 15px; color: var(--text); line-height: 2; }
.share-qr {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
}
.share-qr img, .share-qr canvas { border: 1px solid var(--border); border-radius: 8px; }
.share-qr-tip { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.share-link-row { display: flex; gap: 8px; }
.share-link-row input { font-size: 13px; }
.share-others {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.share-others-label { color: var(--muted); font-size: 13px; }
.share-system { display: block; width: 100%; margin-top: 12px; }
.post-author::before { content: "· "; }
.post-author:first-child::before { content: ""; }

/* ========== 关于页 ========== */
.page-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 36px;
}
.page-title { margin: 0 0 20px; font-size: 26px; }
.about-empty { color: var(--muted); }
.qrcodes {
  display: flex; gap: 24px; flex-wrap: wrap;
  margin-top: 28px; padding-top: 24px;
  border-top: 1px solid var(--border);
}
.qrcode-card {
  margin: 0; text-align: center;
}
.qrcode-card img {
  width: 180px; height: 180px; object-fit: contain;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px;
  background: #fff;
}
.qrcode-card figcaption { margin-top: 8px; color: var(--text); font-size: 14px; }
/* 免责声明：位于二维码之后、全页最底部，弱化处理 */
.about-disclaimer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}
.about-disclaimer :is(h1, h2, h3, h4) { color: var(--text); font-size: 17px; margin-top: 0; }

/* ========== 响应式 ========== */
@media (max-width: 720px) {
  /* 移动端页头：56px 高，文字标换成 36px 方形图标，导航收进汉堡菜单 */
  .site-header .nav { min-height: 56px; padding: 10px 16px; }
  .logo { height: 36px; }
  .logo-has-img .logo-img { height: 36px; max-width: 140px; }
  .logo-text { display: none; }
  .logo-icon { display: inline-flex; }
  .nav-toggle { display: flex; }
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-left: 0;
    padding: 6px 16px 10px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .06);
  }
  .nav-menu.nav-open { display: flex; }
  .nav-cats {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    overflow: visible;
  }
  .nav-cats a { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .nav-about { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .nav-social { padding: 10px 0 2px; }

  .hero-inner { padding: 40px 10px; }
  .hero-title { font-size: 28px; }
  .hero-subtitle { font-size: 15px; }
  .hero-actions .btn { flex: 1; text-align: center; }

  .post-card { flex-direction: column; }
  .page-card { padding: 24px 18px; }
  .qrcodes { justify-content: center; }
  .post-cover { flex: none; height: 180px; }
  .article { padding: 24px 18px; }
  .article-header h1 { font-size: 24px; }
  .comments { padding: 22px 16px; }
  .comment-fields { flex-direction: column; gap: 0; }
  .col-content { max-width: 180px; }
  .form-row { flex-direction: column; gap: 0; }
  .admin-table.table-posts th:nth-child(2),
  .admin-table.table-posts td:nth-child(2) { display: none; }
  .admin-table.table-comments th:nth-child(3),
  .admin-table.table-comments td:nth-child(3) { display: none; }
}
