/* ===== CSS Variables ===== */
:root {
  --bg-primary: #faf6f1;
  --bg-secondary: #f0ebe4;
  --bg-card: #ffffff;
  --bg-card-hover: #fffcf7;
  --border-color: #e4ddd4;
  --border-hover: #d97706;
  --text-primary: #3d2e1e;
  --text-secondary: #6b5c4c;
  --text-muted: #9a8d7e;
  --accent: #d97706;
  --accent-light: #f59e0b;
  --accent-dark: #b45309;
  --tag-answer: #059669;
  --tag-article: #d97706;
  --tag-pin: #7c3aed;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(60, 40, 10, 0.08);
  --shadow-hover: 0 8px 28px rgba(217, 119, 6, 0.12);
  --transition: all 0.25s ease;
  --font-main: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  --max-width: 1280px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background:
    radial-gradient(circle at top, #fff7ed 0%, transparent 32%),
    linear-gradient(180deg, #fbf7f2 0%, var(--bg-primary) 100%);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-light), var(--accent));
  transform: scaleX(0);
  transform-origin: left center;
  z-index: 220;
}

mark {
  background: #fde68a;
  color: var(--text-primary);
  padding: 0 0.15em;
  border-radius: 0.2em;
}

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

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

::selection {
  background: var(--accent-light);
  color: white;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #cdc3b6;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Header ===== */
.header {
  background: linear-gradient(180deg, #f5ede3 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 40px 20px 30px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.header .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.header .stats {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.header .stat {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header .stat strong {
  color: var(--accent-light);
  font-weight: 600;
}

/* ===== Toolbar ===== */
.toolbar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 20px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.quick-entry-bar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-entry-btn {
  border: 1px solid var(--border-color);
  background: #fffaf3;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.quick-entry-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #fff7ed;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-main);
  transition: var(--transition);
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-main);
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.sort-select {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-main);
  outline: none;
}

.sort-select:focus {
  border-color: var(--accent);
}

.sort-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.result-info {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Card Grid ===== */
.card-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}

.card:hover {
  text-decoration: none;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
  opacity: 0;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.card-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-tag.answer {
  background: #ecfdf5;
  color: var(--tag-answer);
}

.card-tag.article {
  background: #fffbeb;
  color: var(--tag-article);
}

.card-tag.pin {
  background: #f5f3ff;
  color: var(--tag-pin);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-primary);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  margin-top: auto;
}

.card-likes {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 600;
}

/* ===== Pagination ===== */
.pagination {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-btn {
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-main);
}

.page-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-info {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0 8px;
}

/* ===== Article Detail Page ===== */
.article-page-wrapper {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 28px;
  align-items: start;
}

.article-page {
  min-width: 0;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  margin-bottom: 24px;
  font-family: var(--font-main);
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  text-decoration: none;
}

.source-context {
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.article-action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.action-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.84rem;
  font-family: var(--font-main);
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.action-btn-primary {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: white;
  border-color: transparent;
}

.action-btn-primary:hover {
  color: white;
  filter: brightness(0.98);
}

.article-detail {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.article-detail .article-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.article-detail .article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.article-detail .article-meta .likes {
  color: var(--accent);
  font-weight: 600;
}

.article-detail .article-content {
  font-size: 1rem;
  line-height: 2;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  letter-spacing: 0.01em;
}

.article-detail .article-content p {
  margin-bottom: 1.4em;
}

.article-detail .article-content p:last-child {
  margin-bottom: 0;
}

/* Numbered point titles: "1. ..." "2. ..." */
.article-detail .article-content .article-point-title {
  margin: 1.8em 0 0.5em;
  font-weight: 700;
  color: var(--text-primary);
  border-left: 3px solid var(--accent-light);
  padding-left: 0.7em;
}

.article-detail .article-content .article-subheading {
  margin: 2em 0 0.7em;
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--accent-dark);
}

.article-detail .article-content ul,
.article-detail .article-content ol {
  margin: 0.3em 0 1.4em 1.2em;
  padding-left: 0.6em;
}

.article-detail .article-content li {
  margin-bottom: 0.55em;
  line-height: 1.85;
}

.article-detail .article-content li::marker {
  color: var(--accent);
}

.article-detail .article-content hr {
  border: 0;
  border-top: 1px dashed #ddd0c0;
  margin: 2.2em 0;
}

.article-detail .article-content a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-decoration-color: rgba(180, 83, 9, 0.3);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.article-detail .article-content .article-link-block {
  margin: 0.8em 0 1.4em;
  padding: 8px 12px;
  background: #fef9f3;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  word-break: break-all;
  font-size: 0.88rem;
  line-height: 1.6;
}

.article-detail .article-content .article-link-block a {
  text-decoration: none;
  color: var(--accent-dark);
}

.article-detail .article-content .article-link-block a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.article-detail .article-content a:hover {
  text-decoration-color: var(--accent);
}



/* Article images */
.article-images {
  margin: 1.8em 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.article-figure {
  margin: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  box-shadow: var(--shadow);
}

.article-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: zoom-in;
  transition: opacity 0.3s;
}

.article-figure img:hover {
  opacity: 0.92;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(34, 23, 13, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 300;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox-image {
  max-width: min(1100px, 92vw);
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
  background: white;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 18px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  font-size: 1.6rem;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Lightbox prev/next arrows */
.lb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 301;
  line-height: 1;
}

.lb-arrow:hover {
  background: rgba(255, 255, 255, 0.26);
}

.lb-prev { left: 16px; }
.lb-next { right: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(61, 46, 30, 0.92);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 320;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mobile-bottom-bar {
  display: none;
}



.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.article-nav a {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
  transition: var(--transition);
}

.article-nav a:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  text-decoration: none;
}

/* ===== Related Sidebar ===== */
.related-sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  align-self: start;
}

.related-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--accent-light);
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toc-box {
  margin-bottom: 18px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.toc-header {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toc-item {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.45;
  transition: color 0.2s, padding-left 0.2s;
}

.toc-item:hover {
  color: var(--accent-dark);
}

.toc-item.active {
  color: var(--accent-dark);
  font-weight: 600;
  padding-left: 6px;
  border-left: 2px solid var(--accent);
}

.related-item {
  display: block;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  text-decoration: none;
}

.related-item:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  text-decoration: none;
  transform: translateX(2px);
}

.related-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-excerpt {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.related-meta .card-tag {
  font-size: 0.65rem;
  padding: 1px 5px;
}

/* scrollbar for sidebar */
.related-sidebar::-webkit-scrollbar {
  width: 4px;
}
.related-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 1rem;
}

.clear-search-btn {
  margin-top: 16px;
  padding: 9px 22px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: var(--font-main);
  cursor: pointer;
  transition: var(--transition);
}

.clear-search-btn:hover {
  background: var(--accent-dark);
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading .spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header {
    padding: 24px 16px 20px;
  }

  .header h1 {
    font-size: 1.4rem;
  }

  .toolbar {
    padding: 16px 16px 0;
  }

  .quick-entry-bar {
    padding: 10px 16px 0;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .quick-entry-bar::-webkit-scrollbar {
    display: none;
  }

  .quick-entry-btn {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .card-grid {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 12px;
  }

  .card {
    padding: 16px;
  }

  .article-page-wrapper {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 16px;
  }

  .article-page {
    width: 100%;
  }

  .back-btn {
    width: 100%;
    justify-content: center;
    padding: 11px 14px;
    margin-bottom: 14px;
    font-size: 0.9rem;
  }

  .article-action-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .source-context {
    margin-bottom: 10px;
    padding: 0 2px;
    line-height: 1.5;
  }

  .action-btn {
    min-height: 42px;
    padding: 10px 12px;
  }

  .related-sidebar {
    position: static;
    max-height: none;
  }

  .article-detail {
    padding: 18px 16px;
    border-radius: 10px;
  }

  .article-detail .article-title {
    font-size: 1.3rem;
    line-height: 1.45;
    margin-bottom: 14px;
  }

  .article-detail .article-meta {
    gap: 8px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    font-size: 0.78rem;
  }

  .article-detail .article-meta > span {
    padding: 5px 8px;
    background: #faf2e7;
    border-radius: 999px;
  }

  .article-detail .article-content {
    font-size: 0.96rem;
    line-height: 1.92;
  }

  .article-detail .article-content p {
    margin-bottom: 1.45em;
  }

  .article-detail .article-content .article-subheading {
    font-size: 1rem;
    margin: 1.6em 0 0.6em;
  }

  .article-detail .article-content .article-point-title {
    margin: 1.5em 0 0.45em;
    padding-left: 0.6em;
  }

  .article-nav {
    flex-direction: column;
    gap: 10px;
  }

  .article-nav a {
    width: 100%;
    padding: 13px 14px;
  }

  .toc-box,
  .related-item {
    border-radius: 10px;
  }

  .toc-list {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .toc-list::-webkit-scrollbar {
    display: none;
  }

  .toc-item {
    flex: 0 0 auto;
    max-width: 220px;
    padding: 8px 10px;
    background: #faf2e7;
    border-radius: 8px;
    border: 1px solid var(--border-color);
  }

  .related-header,
  .toc-header {
    margin-bottom: 10px;
  }

  .related-list {
    gap: 8px;
  }

  .related-item {
    padding: 10px;
  }

  .related-title {
    font-size: 0.8rem;
  }

  .related-excerpt {
    font-size: 0.74rem;
  }

  .lightbox {
    padding: 14px;
  }

  .lightbox-image {
    max-width: 96vw;
    max-height: 82vh;
  }

  .lightbox-close {
    top: max(14px, env(safe-area-inset-top));
    right: 14px;
    width: 44px;
    height: 44px;
  }

  .toast {
    width: calc(100% - 28px);
    max-width: 360px;
    text-align: center;
    white-space: normal;
  }

  .mobile-bottom-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 250, 243, 0.94);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 24px rgba(60, 40, 10, 0.12);
    z-index: 210;
  }

  .mobile-bottom-btn {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: white;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
  }

  .mobile-bottom-btn-primary {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: white;
    border-color: transparent;
  }

  .footer {
    padding-bottom: 92px;
  }
}

@media (max-width: 480px) {
  .filter-group {
    width: 100%;
  }

  .filter-btn {
    flex: 1;
    text-align: center;
  }

  .header .stats {
    gap: 12px;
  }

  .article-page-wrapper {
    padding: 12px;
  }

  .article-detail {
    padding: 16px 14px;
  }

  .article-detail .article-title {
    font-size: 1.18rem;
  }

  .article-detail .article-content {
    font-size: 0.93rem;
  }

  .scroll-top {
    bottom: 18px;
    right: 18px;
  }
}

/* ===== Scroll to top ===== */
.scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(180, 83, 9, 0.22);
  z-index: 50;
}

.scroll-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-top:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
}
