:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --brand: #0f766e;
  --brand-ink: #064e3b;
  --surface: #f8fafc;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans SC', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.logo {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-ink);
  text-decoration: none;
}
.tagline { color: var(--muted); font-size: 12px; }

.primary-nav { margin-left: auto; }
.nav-toggle { display: none; }
.nav-menu { display: flex; list-style: none; margin: 0; padding: 0; gap: 8px; }
.nav-menu a { display: block; padding: 8px 10px; color: var(--text); text-decoration: none; border-radius: 6px; }
.nav-menu a:hover { background: var(--border); }

.search-container {
  position: relative;
  display: inline-block;
}

.search input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
  width: 100%;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
}

.search-results {
  padding: 8px 0;
}

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: var(--surface);
}

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

.search-result-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.search-result-category {
  font-size: 12px;
  color: var(--muted);
}

.search-history {
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  background-color: var(--surface);
}

.clear-history-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
}

.clear-history-btn:hover {
  background-color: var(--border);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item:hover {
  background-color: var(--surface);
}

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

.history-text {
  color: var(--text);
  font-size: 14px;
}

.history-time {
  color: var(--muted);
  font-size: 12px;
}

.no-results {
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

main.container { padding: 20px 16px 48px; }
.intro h1 { font-family: 'Noto Serif SC', serif; font-size: 28px; margin: 0 0 6px; }
.intro p { margin-top: 0; color: var(--muted); }

/* Showcase: left text, centered image, right toggleable lists */
.showcase { margin-top: 16px; }
.showcase-grid { display: grid; grid-template-columns: 1.2fr 1.4fr 1fr; gap: 16px; align-items: stretch; }
.showcase-left h2 { margin: 0 0 12px; font-family: 'Noto Serif SC', serif; font-size: 24px; }
.showcase-left p { margin: 6px 0; color: var(--muted); }
.showcase-left, .showcase-center, .showcase-right { height: 100%; }
.showcase-left { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.showcase-center { display: flex; align-items: center; justify-content: center; }
.hero-img { width: 100%; height: 100%; max-height: 100%; object-fit: contain; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 4px 24px rgba(0,0,0,0.06); }
.showcase-right { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.list-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.list-btn { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; box-shadow: 0 2px 10px rgba(0,0,0,0.06); cursor: pointer; }
.list-btn.is-active { background: #fff; color: var(--brand-ink); }
.book-list { list-style: none; margin: 0; padding: 0; display: none; flex: 1 1 auto; overflow: auto; }
.book-list.is-active { display: block; }
.book-list li { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.book-list li:last-child { border-bottom: none; }

/* Article page layout */
.article-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; padding-top: 16px; }
.article-content { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.article-content h1 { margin: 0 0 12px; font-family: 'Noto Serif SC', serif; }
.article-body p { margin: 10px 0; }
.category-content > p { text-indent: 2em; }
.article-body img { max-width: 80%; height: auto; border-radius: 8px; border: 1px solid var(--border); display: block; margin: 8px 0; }
.article-body .figure { margin: 12px 0; }
.article-body .figure-caption { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* 视频和图片并排容器 */
.media-container {
  display: flex;
  gap: 16px;
  margin: 1rem 0;
  align-items: flex-start;
}

/* 视频容器样式 */
.video-container {
  position: relative;
  width: 80%;
  max-width: 800px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.video-container video {
  width: 100%;
  height: auto;
  display: block;
}

/* 图片容器样式 */
.image-container {
  width: 80%;
  max-width: 800px;
}

.image-container img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-caption {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* 响应式视频 */
@media (max-width: 768px) {
  .video-container {
    margin: 0.5rem 0;
  }
}
.article-body h3 { margin: 16px 0 8px; font-size: 18px; font-family: 'Noto Serif SC', serif; }
.article-body ul { margin: 8px 0 12px 18px; padding: 0; }
.article-body li { margin: 4px 0; }
.article-sidebar { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; height: max-content; position: sticky; top: 16px; }

/* Category page specifics */
.category-content { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.category-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 16px; }
.category-list li { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.category-list h3 { margin: 0 0 6px; font-size: 18px; }
.category-list p { margin: 0; color: var(--muted); }

.tabs { margin-top: 16px; }
.tab-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tab { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.tab.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tab-panel { padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; }
.subcategory-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; }
.subcategory-list.two-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.subcategory-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

.recommendations, .ranking { margin-top: 24px; }
.recommendations h2, .ranking h2 { font-size: 18px; margin: 0 0 12px; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.book { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; }
.rank-list { list-style: decimal; padding-left: 18px; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); }
.site-footer .container { padding: 16px; display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }

.back-home {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  text-decoration: none;
  color: var(--brand-ink);
}
.back-home:hover { background: var(--surface); }

@media (max-width: 768px) {
  .primary-nav { order: 3; width: 100%; }
  .nav-toggle { display: inline-block; padding: 8px 10px; border: 1px solid var(--border); background: #fff; border-radius: 8px; }
  .nav-menu { display: none; flex-direction: column; padding: 8px 0; }
  .nav-menu.is-open { display: flex; }
  .search input { min-width: 0; width: 100%; }
  .header-inner { flex-wrap: wrap; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-list { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .subcategory-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .showcase-grid { grid-template-columns: 1fr; }
  .showcase-right { padding: 8px; }
  .article-layout { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .book-grid { grid-template-columns: 1fr; }
  .subcategory-list { grid-template-columns: 1fr; }
}
