/* ===== 基础重置 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent-color: #7c6a46;
  --accent-light: #9a8660;
  --accent-dark: #5c4f35;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f6f3;
  --bg-tertiary: #f0ece5;
  --text-primary: #2d2d2d;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #e5e1da;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --max-width: 1200px;
  --header-height: 64px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

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

a:hover {
  color: var(--accent-dark);
}

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

/* ===== 布局容器 ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== 页头 ===== */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}

.nav {
  display: flex;
  gap: 28px;
}

.nav a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

.nav a:hover,
.nav a.active {
  color: var(--accent-color);
}

.search-box {
  position: relative;
}

.search-box input {
  width: 240px;
  padding: 8px 16px 8px 40px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--bg-secondary);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-color);
  width: 280px;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.5;
}

/* ===== Hero 区域 ===== */
.hero {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
  padding: 60px 0;
  text-align: center;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.hero-search {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.hero-search input {
  width: 100%;
  padding: 16px 24px 16px 52px;
  border: 2px solid var(--border-color);
  border-radius: 32px;
  font-size: 1rem;
  background: var(--bg-primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.hero-search input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: var(--shadow-md);
}

.hero-search::before {
  content: "🔍";
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.5;
}

/* ===== 区块标题 ===== */
.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 卡片组件 ===== */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 20px;
  transition: all 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 12px;
  display: flex;
  gap: 16px;
}

/* ===== 网格布局 ===== */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* ===== 分类标签 ===== */
.category-tag {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.2s;
}

.category-tag:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* ===== 列表样式 ===== */
.list-group {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.list-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
}

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

.list-item:hover {
  background: var(--bg-secondary);
}

.list-item-title {
  font-weight: 500;
  color: var(--text-primary);
}

.list-item-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== 面包屑 ===== */
.breadcrumb {
  padding: 16px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.breadcrumb a {
  color: var(--text-secondary);
}

.breadcrumb a:hover {
  color: var(--accent-color);
}

.breadcrumb span {
  margin: 0 8px;
  color: var(--text-muted);
}

/* ===== 页面内容区 ===== */
.page-content {
  padding: 32px 0;
}

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-desc {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ===== 维基文章布局 ===== */
.wiki-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  height: fit-content;
}

.toc {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 20px;
}

.toc-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.toc-list {
  list-style: none;
}

.toc-list li {
  margin-bottom: 8px;
}

.toc-list a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  display: block;
  padding: 6px 0;
  border-left: 2px solid transparent;
  padding-left: 12px;
  margin-left: -12px;
}

.toc-list a:hover,
.toc-list a.active {
  color: var(--accent-color);
  border-left-color: var(--accent-color);
}

.article {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 32px;
}

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

.article-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.article-meta {
  display: flex;
  gap: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.article-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.article-body h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.article-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 24px 0 12px;
}

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

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

.article-body li {
  margin-bottom: 8px;
}

/* ===== 信息框 ===== */
.info-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 20px;
  margin: 24px 0;
}

.info-box-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-box-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.info-box-content p {
  margin-bottom: 8px;
}

.info-box-content p:last-child {
  margin-bottom: 0;
}

/* ===== 标签云 ===== */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.tag:hover {
  background: var(--accent-color);
  color: white;
}

/* ===== 底部推荐区 ===== */
.bottom-section {
  background: var(--bg-tertiary);
  padding: 40px 0;
  margin-top: 40px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.bottom-column h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.bottom-column ul {
  list-style: none;
}

.bottom-column li {
  margin-bottom: 10px;
}

.bottom-column a {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.bottom-column a:hover {
  color: var(--accent-color);
}

/* ===== 页脚 ===== */
.footer {
  background: var(--text-primary);
  color: var(--text-muted);
  padding: 32px 0;
  text-align: center;
  font-size: 0.9rem;
}

.footer a {
  color: var(--text-muted);
}

.footer a:hover {
  color: white;
}

/* ===== 404 页面 ===== */
.error-page {
  min-height: calc(100vh - var(--header-height) - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
}

.error-code {
  font-size: 8rem;
  font-weight: 700;
  color: var(--accent-color);
  line-height: 1;
  margin-bottom: 16px;
  opacity: 0.8;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.error-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 28px;
  background: var(--accent-color);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--accent-dark);
  color: white;
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }

  .wiki-layout {
    grid-template-columns: 220px 1fr;
  }
}

@media (max-width: 768px) {
  .nav {
    display: none;
  }

  .search-box {
    display: none;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .wiki-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    order: 2;
  }

  .article {
    order: 1;
    padding: 20px;
  }

  .article-title {
    font-size: 1.4rem;
  }

  .error-code {
    font-size: 5rem;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 40px 0;
  }

  .page-content {
    padding: 20px 0;
  }

  .card {
    padding: 16px;
  }
}
