/* ===== 变量与基础 ===== */
:root {
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-secondary: #5f6b7a;
  --border: #e9edf2;
  --accent: #4a90e2;
  --accent-hover: #3a7bc8;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.04);
  --gap: 24px;
  --btn-bg: #f1f4f8;
  --btn-hover-bg: #e1e6ed;
  --btn-text: #2c3e50;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; vertical-align: middle; }

/* ===== 头部 ===== */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: relative;
}
.header-brand a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
}
.logo { height: 32px; }

/* 菜单按钮 */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  position: relative;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.menu-toggle .bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  margin: 4px 0;
  transition: 0.3s;
  border-radius: 2px;
  pointer-events: none;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
}
.nav-list li a {
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 500;
  display: block;
  white-space: nowrap;
}
.nav-list li a:hover {
  background: var(--border);
  color: var(--text);
}
.nav-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  background: var(--btn-bg);
  color: var(--btn-text);
}
.btn:hover {
  background: var(--btn-hover-bg);
  border-color: #d0d5dd;
  color: var(--text);
}

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
}
.btn-text {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-text:hover {
  background: var(--border);
  border-color: var(--border);
}

/* ===== 主内容布局 ===== */
.site-main { min-height: 80vh; }

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--gap);
  display: flex;
  gap: var(--gap);
}
.main-area {
  flex: 1 1 65%;
  min-width: 0;
}
.sidebar {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ===== 通用卡片 ===== */
.box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: var(--gap);
}
.box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.box-header h2, .box-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* ===== 首页文章列表 ===== */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.post-item {
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 18px 20px;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.post-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.post-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: left 0.5s;
  pointer-events: none;
}
.post-item:hover::after { left: 100%; }

.post-item.top {
  border-left: 4px solid var(--accent);
  background: #f0f5ff;
}
.post-item.private {
  border-color: #f9e79f;
  background: #fefdf5;
}

.post-title {
  font-size: 1.1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.post-title a {
  color: var(--text);
  font-weight: 600;
}
.post-title a:hover { color: var(--accent); }

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.badge-top { background: var(--accent); color: white; }
.badge-private { background: #f1c40f; color: #000; }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.post-meta span, .post-meta time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.meta-icon { color: var(--text-secondary); opacity: 0.7; }

/* ===== 文章详情页 ===== */
.article .headline {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--text);
}
.article-info {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.article-info a {
  color: var(--accent);
}

/* 正文排版（基础） */
.article-content {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
  word-wrap: break-word;
}

/* 强制覆盖 fk.css 的所有标题和样式 */
.article-content .fk {}
.article-content .fk h1,
.article-content .fk .fk-h1 { font-size: 2em !important; font-weight: 700 !important; margin: 1.2em 0 0.6em !important; }
.article-content .fk h2,
.article-content .fk .fk-h2 { font-size: 1.75em !important; font-weight: 700 !important; margin: 1.4em 0 0.6em !important; border-bottom: 2px solid var(--border) !important; padding-bottom: 0.3em !important; }
.article-content .fk h3,
.article-content .fk .fk-h3 { font-size: 1.5em !important; font-weight: 700 !important; margin: 1.2em 0 0.4em !important; }
.article-content .fk h4,
.article-content .fk .fk-h4 { font-size: 1.2em !important; font-weight: 700 !important; margin: 1em 0 0.4em !important; }
.article-content .fk h5,
.article-content .fk .fk-h5 { font-size: 1.1em !important; font-weight: 700 !important; }
.article-content .fk h6,
.article-content .fk .fk-h6 { font-size: 1em !important; font-weight: 700 !important; }

/* 段落 */
.article-content p {
  margin-bottom: 1.3em;
}

/* 列表 */
.article-content ul,
.article-content ol {
  margin: 1.2em 0;
  padding-left: 2em;
}
.article-content li {
  margin-bottom: 0.4em;
}

/* 图片 */
.article-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5em auto;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* 引用块 */
.article-content blockquote {
  margin: 1.8em 0;
  padding: 16px 24px;
  background: #f8f9fb;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
}

/* 行内代码 */
.article-content code {
  background: #f1f4f8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.9em;
}

/* 代码块 */
.article-content pre {
  background: #2c3e50;
  color: #e0e0e0;
  padding: 20px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: 0.9em;
  line-height: 1.5;
}
.article-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* 表格 */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}
.article-content th,
.article-content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.article-content th {
  background: #f1f4f8;
  font-weight: 600;
}

/* 链接 */
.article-content a {
  color: var(--accent);
  text-decoration: underline;
}
.article-content a:hover {
  opacity: 0.8;
}

/* 文章前后导航 */
.article-menu {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.article-menu-item {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.article-menu-item a {
  color: var(--accent);
  margin-left: 4px;
}

/* ===== 评论区域 ===== */
.comment {
  margin-top: 0;
}
.comment .title {
  font-weight: 700;
  font-size: 1.15rem;
  margin: 24px 0 16px;
}
.comment-form {
  margin-bottom: 16px;
}
.comment-info {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.comment-info-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.comment-info-item label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.comment-info-item input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.9rem;
  color: var(--text);
}
.comment-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.9rem;
  color: var(--text);
  resize: vertical;
}
.comment-submit {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.comment-submit .vcode-img {
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
}
.comment-submit .vcode-input {
  width: 100px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.9rem;
}
.comment-submit .btn {
  margin-left: auto;
}
.comment form {
  background: #f9fafb;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* 侧边栏 */
.user-profile { text-align: center; }
.user-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  margin-bottom: 12px;
}
.user-name {
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 16px;
}
.user-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 20px 0;
}
.stat-item {
  display: flex;
  flex-direction: column;
}
.stat-number {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.search-form {
  display: flex;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.search-form input {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: var(--bg);
  outline: none;
  font-size: 0.9rem;
}
.search-form button {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}
.search-form button:hover {
  background: var(--btn-hover-bg);
}

.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
}
.tag-list li a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f4f8;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: 0.2s;
}
.tag-list li a:hover {
  background: #d9e6ff;
  color: var(--accent);
}
.tag-list .count {
  font-size: 0.7rem;
  color: #999;
}

/* 友情链接列表 */
.link-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.link-list li {
  margin: 0;
}
.link-list a {
  display: inline-block;
  padding: 6px 14px;
  background: #f1f4f8;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: 0.2s;
}
.link-list a:hover {
  background: #d9e6ff;
  color: var(--accent);
}

/* ===== 雨滴背景 ===== */
.banner {
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  overflow: hidden;
  position: relative;
}
#rain {
  display: block;
  width: 100%;
  height: 180px;
  opacity: 0.7;
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.pagination .current {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== 回到顶部按钮 ===== */
#back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--border);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  z-index: 99;
  pointer-events: none;
}
#back-to-top:hover {
  background: var(--btn-hover-bg);
}
#back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ===== 页脚 ===== */
.site-footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ===== 暗黑模式 ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --card-bg: #1e1e1e;
    --text: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border: #2a2a2a;
    --shadow: 0 4px 20px rgba(0,0,0,0.2);
    --btn-bg: #2a2a2a;
    --btn-hover-bg: #3a3a3a;
    --btn-text: #e0e0e0;
  }
  .post-item.top { background: #1a2634; border-left-color: #5a9cf8; }
  .post-item.private { background: #332e1a; }
  .tag-list li a { background: #2a2a2a; color: #ccc; }
  .search-form input { background: #2a2a2a; color: #fff; }
  .article-content blockquote { background: #262626; }
  .article-content code { background: #2a2a2a; }
  .article-content pre { background: #121212; }
  .article-content th { background: #1e1e1e; }
  .comment form { background: #1a1a1a; }
  .comment-info-item input,
  .comment-form textarea,
  .comment-submit .vcode-input {
    background: #2a2a2a;
    color: #fff;
    border-color: #3a3a3a;
  }
  #back-to-top {
    border-color: var(--border);
  }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex !important;
  }
  .header-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--card-bg);
    flex-direction: column;
    padding: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border-bottom: 1px solid var(--border);
    gap: 12px;
    z-index: 9998;
    align-items: center;
  }
  .header-nav.active {
    display: flex;
  }
  .nav-list {
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 4px;
  }
  .nav-list li a {
    padding: 12px 4px;
    width: 100%;
    text-align: center;
    border-bottom: 1px solid var(--border);
  }
  .nav-sep { display: none; }
  .nav-actions {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-left: 0;
    justify-content: center;
  }

  .content {
    flex-direction: column;
    padding: 16px;
    gap: 20px;
  }
  .sidebar { flex: 1 0 auto; width: 100%; }

  .article .headline {
    font-size: 1.5rem;
  }
  .article-content {
    font-size: 1rem;
  }
  .comment-info {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .user-stats { gap: 20px; }
}