:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --bg-color: #f4f6f9;
  --card-bg: #ffffff;
  --text-color: #2c3e50;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --header-bg: rgba(255, 255, 255, 0.85);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.1);
  --code-bg: #282c34;
  --code-text: #abb2bf;
  --tag-bg: #eff6ff;
  --tag-text: #3b82f6;
  --banner-overlay: linear-gradient(135deg, rgba(30, 41, 59, 0.75), rgba(15, 23, 42, 0.85));
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "Fira Code", Consolas, Monaco, "Courier New", Courier, monospace;
}

[data-theme="dark"] {
  --primary-color: #60a5fa;
  --primary-hover: #3b82f6;
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-color: #e2e8f0;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --header-bg: rgba(30, 41, 59, 0.85);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.45);
  --code-bg: #0b0f19;
  --code-text: #cbd5e1;
  --tag-bg: #1e3a8a;
  --tag-text: #93c5fd;
  --banner-overlay: linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(2, 6, 23, 0.95));
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.75;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-color);
}

/* 顶部导航栏 */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.navbar-container {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.5px;
}

.site-title .dot {
  color: var(--primary-color);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  list-style: none;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-color);
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-item a:hover,
.nav-item.active a {
  color: var(--primary-color);
  background: rgba(59, 130, 246, 0.08);
}

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

.icon-btn {
  background: none;
  border: none;
  color: var(--text-color);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-color);
}

/* 顶部横幅 Banner */
.hero-banner {
  height: 380px;
  background: var(--banner-overlay), url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80"><g fill="%23ffffff" fill-opacity="0.05"><path fill-rule="evenodd" d="M0 0h40v40H0V0zm40 40h40v40H40V40zm0-40h2v40h-2V0zm0 40h2v40h-2V40zm-40 0h40v2H0v-2zm40 0h40v2H40v-2z"/></g></svg>');
  background-size: cover;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #ffffff;
  padding: 80px 20px 20px;
  position: relative;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 650px;
  font-family: var(--font-mono);
  min-height: 28px;
}

.hero-subtitle .cursor {
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 主体内容布局 */
.main-wrapper {
  max-width: 1200px;
  margin: -40px auto 40px;
  padding: 0 20px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
  position: relative;
  z-index: 10;
  flex: 1;
}

.main-single {
  grid-template-columns: 1fr;
  max-width: 900px;
}

/* 文章卡片流 */
.post-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.post-card-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
}

.post-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.post-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 16px;
}

.post-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--border-color);
  padding-top: 14px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-badge {
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-weight: 500;
}

.read-more {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 侧边栏 Widget */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.widget {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 22px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.widget-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-color);
  display: inline-block;
}

/* 作者卡片 */
.author-card {
  text-align: center;
}

.avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.author-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.author-bio {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.author-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 0;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 8px;
}

.stat-item .num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.social-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.2s;
}

.social-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* 分类/标签列表侧边栏 */
.category-list, .archive-list {
  list-style: none;
}

.category-list-item, .archive-list-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.9rem;
  border-bottom: 1px dashed var(--border-color);
}

.category-list-item:last-child {
  border-bottom: none;
}

.badge-count {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 10px;
}

/* 文章详情页布局 */
.article-container {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 36px 40px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.article-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.article-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 14px;
}

.article-content {
  font-size: 1.05rem;
  line-height: 1.85;
}

.article-content h2 {
  font-size: 1.55rem;
  margin: 36px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.article-content h3 {
  font-size: 1.25rem;
  margin: 24px 0 12px;
}

.article-content p {
  margin-bottom: 16px;
}

.article-content ul, .article-content ol {
  padding-left: 24px;
  margin-bottom: 18px;
}

.article-content li {
  margin-bottom: 6px;
}

.article-content blockquote {
  border-left: 4px solid var(--primary-color);
  padding: 12px 18px;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 0 8px 8px 0;
  margin: 20px 0;
  color: var(--text-muted);
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.95rem;
}

.article-content th, .article-content td {
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  text-align: left;
}

.article-content th {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 600;
}

/* 目录 TOC 浮动栏 */
.toc-sidebar {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.toc-list {
  list-style: none;
  font-size: 0.88rem;
  padding-left: 6px;
}

.toc-link {
  display: block;
  padding: 4px 8px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: all 0.2s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-link:hover, .toc-link.active {
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
}

.toc-sublist {
  list-style: none;
  padding-left: 14px;
}

/* 页脚 */
.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding: 30px 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}

.footer-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.footer-badges {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.footer-badge {
  display: inline-flex;
  font-size: 0.75rem;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.footer-badge span:first-child {
  background: #475569;
  color: #fff;
  padding: 2px 6px;
}

.footer-badge span:last-child {
  background: var(--primary-color);
  color: #fff;
  padding: 2px 6px;
}

/* 搜索模态框 */
.search-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
}

.search-modal.active {
  display: flex;
}

.search-box {
  background: var(--card-bg);
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  overflow: hidden;
  animation: modalSlide 0.2s ease-out;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  color: var(--text-color);
  outline: none;
}

.search-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 12px 20px;
}

.search-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-color);
}

.search-item a {
  font-weight: 600;
  font-size: 1rem;
  display: block;
  margin-bottom: 4px;
}

.search-item-snippet {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* 返回顶部按钮 */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 50%;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  z-index: 90;
}

.back-to-top.show {
  display: flex;
}

.back-to-top:hover {
  transform: translateY(-3px);
  background: var(--primary-hover);
}

/* 响应式适配 */
@media (max-width: 860px) {
  .main-wrapper {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .nav-links span {
    display: none;
  }
  .hero-title {
    font-size: 1.8rem;
  }
  .article-container {
    padding: 24px 18px;
  }
}
