/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  color: #2c2c2c;
  background: #f8f6f1;
  background-image: 
    radial-gradient(ellipse at 20% 50%, rgba(180,140,100,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(120,90,60,0.03) 0%, transparent 50%);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.site-header {
  background: linear-gradient(135deg, #1c1c30 0%, #1a2640 40%, #162d52 70%, #0f3460 100%);
  color: #e8d5b7;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 24px rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(200,170,120,0.15);
}
.site-header::after {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, transparent, #c4975a, #dbb87a, #c4975a, transparent);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.header-title {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #e8d5b7;
  text-decoration: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  position: relative;
}
.header-title:hover { color: #f0e2cc; }

/* ── Breadcrumb ── */
.breadcrumb {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 28px;
  font-size: 0.85rem;
  color: #999;
  background: rgba(255,255,255,0.5);
  border-bottom: 1px solid #e8e4dc;
}
.breadcrumb a { color: #6b5b4e; text-decoration: none; transition: color 0.15s; }
.breadcrumb a:hover { color: #8b4513; }
.bc-sep { margin: 0 6px; color: #c8bfb0; }
.bc-current { color: #5a4a3e; font-weight: 500; }

/* ── Search Bar ── */
.search-bar {
  background: linear-gradient(180deg, #fff 0%, #faf8f4 100%);
  border-bottom: 1px solid #e0dcd5;
  padding: 20px 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.search-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
}
#searchInput {
  width: 100%;
  max-width: 640px;
  padding: 12px 22px 12px 42px;
  font-size: 1rem;
  border: 2px solid #d4c9b8;
  border-radius: 28px;
  outline: none;
  font-family: inherit;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23997' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") 16px center no-repeat;
  transition: all 0.25s;
}
#searchInput:focus { 
  border-color: #8b6f47; 
  box-shadow: 0 0 0 3px rgba(139,111,71,0.12);
}

/* ── Category Sections ── */
.category-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 28px 8px;
}
.category-title {
  font-size: 1.4rem;
  color: #3a2a1e;
  border-bottom: 2px solid #c4975a;
  padding-bottom: 8px;
  margin-bottom: 20px;
  font-weight: 700;
  position: relative;
}
.category-title::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: #8b4513;
}

/* ── Card Grid ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  padding-bottom: 18px;
}

/* ── Book Card ── */
.book-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
  border: 1px solid #e8e4dc;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.book-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #c4975a, #dbb87a, #c4975a);
  opacity: 0;
  transition: opacity 0.25s;
}
.book-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.1);
  transform: translateY(-3px);
  border-color: #d4c0a0;
}
.book-card:hover::before { opacity: 1; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #2c1e12;
  line-height: 1.5;
}

.card-tabs {
  display: flex;
  gap: 6px;
}
.card-tab {
  flex: 1;
  display: inline-block;
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  background: #f5f0e8;
  color: #6b5b4e;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  border: 1px solid #e8e4dc;
}
.card-tab:hover { 
  background: linear-gradient(135deg, #1a2640, #0f3460);
  color: #fff; 
  border-color: #0f3460;
}
.card-tab.disabled {
  background: #f8f8f8;
  color: #ccc;
  cursor: default;
  pointer-events: none;
  border-color: #eee;
}

/* ── Content Page ── */
.content-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px;
  flex: 1;
}

/* ── Tabs on Content Page ── */
.book-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 2px solid #e0dcd5;
  background: #fff;
  border-radius: 12px 12px 0 0;
  padding: 0 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.tab-btn {
  display: inline-block;
  padding: 12px 32px;
  color: #888;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-btn:hover { color: #3a2a1e; }
.tab-btn.active {
  color: #1a2640;
  font-weight: 700;
  border-bottom-color: #c4975a;
}
.tab-btn.disabled {
  color: #ccc;
  cursor: default;
  pointer-events: none;
}

/* ── MD Content ── */
.md-content {
  background: #fff;
  padding: 36px 44px;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
  border: 1px solid #e8e4dc;
  border-top: none;
}
.md-content h1 {
  font-size: 1.65rem;
  color: #1a1a2e;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #c4975a;
  position: relative;
}
.md-content h2 {
  font-size: 1.35rem;
  color: #2c1e12;
  margin: 32px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e8e4dc;
  position: relative;
}
.md-content h2::before {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 40px;
  height: 1px;
  background: #c4975a;
}
.md-content h3 {
  font-size: 1.15rem;
  color: #3a2a1e;
  margin: 22px 0 10px;
  padding-left: 12px;
  border-left: 3px solid #c4975a;
}
.md-content h4 {
  font-size: 1.05rem;
  color: #4a3a2e;
  margin: 18px 0 8px;
}
.md-content p { margin: 12px 0; text-align: justify; }
.md-content ul, .md-content ol {
  margin: 12px 0 12px 28px;
}
.md-content li { margin: 5px 0; }
.md-content blockquote {
  border-left: 4px solid #c4975a;
  margin: 16px 0;
  padding: 12px 24px;
  background: linear-gradient(135deg, #faf8f4, #f5f0e8);
  color: #5a4a3e;
  border-radius: 0 8px 8px 0;
}
.md-content code {
  background: #f5f0e8;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "Sarasa Mono SC", "Noto Sans SC", monospace;
  color: #6b4f3a;
}
.md-content pre {
  background: #1c1c30;
  color: #e8d5b7;
  padding: 18px 24px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid #2a2a44;
}
.md-content pre code {
  background: none;
  color: inherit;
  padding: 0;
}
.md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.92rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.md-content thead { 
  background: linear-gradient(135deg, #f5f0e8, #eae5dc); 
}
.md-content th {
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  color: #2c1e12;
  border-bottom: 2px solid #c4975a;
}
.md-content td {
  padding: 10px 16px;
  border-bottom: 1px solid #eae5dc;
}
.md-content tbody tr:hover { background: #faf8f4; }
.md-content tbody tr:last-child td { border-bottom: none; }
.md-content strong { color: #6b4f3a; }
.md-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d4c0a0, transparent);
  margin: 28px 0;
}
.md-content a { color: #6b4f3a; text-decoration: underline; text-underline-offset: 2px; }
.md-content a:hover { color: #8b4513; }

/* ── Footer ── */
.site-footer {
  background: linear-gradient(135deg, #1c1c30 0%, #1a2640 40%, #0f3460 100%);
  color: #e8d5b7;
  text-align: center;
  padding: 24px;
  margin-top: auto;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  position: relative;
}
.site-footer::before {
  content: "";
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c4975a, #dbb87a, #c4975a, transparent);
}
.footer-inner {
  padding-top: 8px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f5f0e8; }
::-webkit-scrollbar-thumb { background: #c8bfb0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a89880; }

/* ── Selection ── */
::selection { background: #c4975a; color: #fff; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
  .md-content { padding: 20px; }
  .header-title { font-size: 1.2rem; letter-spacing: 0.12em; }
  .tab-btn { padding: 10px 18px; font-size: 0.85rem; }
  .content-page { padding: 16px; }
}
@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .category-nav { gap: 4px; padding: 8px 16px; }
  .cat-link { padding: 3px 10px; font-size: 0.8rem; }
  .search-inner { padding: 0 16px; }
  #searchInput { font-size: 0.9rem; }
}
