/* ========================================
   教辅资料 - 前台样式 (v2 - 卡片网格)
   ======================================== */
:root {
  --primary: #1e3a5f;
  --primary-dark: #16304f;
  --accent: #f59e0b;
  --accent-bg: rgba(245, 158, 11, 0.1);
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #334155;
  --text-light: #94a3b8;
  --text-dark: #1e293b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-hover: 0 6px 16px rgba(0,0,0,0.1);
  --transition: all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ===== HEADER ===== */
.top-header {
  position: sticky; top: 0; z-index: 100;
  background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 16px;
}
.site-logo { font-size: 1.2rem; font-weight: 700; color: #111827; white-space: nowrap; flex-shrink: 0; line-height: 1; }
.site-logo a { color: inherit; }
.mobile-nav-toggle { display: none; align-items: center; justify-content: center; cursor: pointer; color: #374151; flex-shrink: 0; padding: 4px; }

/* Site navigation */
.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
  margin-left: 30px;
}
.site-nav a {
  font-size: 0.95rem;
  color: #374151;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s;
  font-weight: 500;
}
.site-nav a:hover {
  background: #f3f4f6;
  color: #111827;
}

/* Site navigation - dropdown */
.nav-item-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}
.nav-link-dropdown {
  font-size: 0.95rem;
  color: #374151;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.nav-link-dropdown:hover {
  background: #f3f4f6;
  color: #111827;
}
.dropdown-caret {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1;
}
.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  padding: 6px 0;
  display: none;
  opacity: 0;
  flex-direction: column;
  z-index: 200;
  transition: opacity 0.15s;
}
.nav-item-dropdown:hover .nav-dropdown-menu,
.nav-item-dropdown.open .nav-dropdown-menu {
  display: flex;
  opacity: 1;
}
.nav-dropdown-menu a {
  font-size: 0.88rem;
  color: #475569;
  text-decoration: none;
  padding: 8px 16px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
  font-weight: 400;
}
.nav-dropdown-menu a:hover {
  background: #f3f4f6;
  color: #111827;
}
/* Sub-menu positioning */
.nav-item-dropdown .nav-item-dropdown .nav-dropdown-menu {
  top: 0;
  left: 100%;
  z-index: 300;
}

/* Search - smaller, aligned right */
.search-box { 
  margin-left: auto;
  flex: 0 0 auto;
}
.search-box form { 
  width: 240px; 
  display: flex; 
  align-items: center;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 0 8px;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.search-box form:focus-within {
  border-color: #2563eb;
  background: #fff;
}
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 7px 4px;
  font-size: 0.85rem;
  color: #374151;
  width: 100%;
}
.search-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #6b7280;
  display: flex;
  align-items: center;
}
.search-btn:hover { color: #2563eb; }

/* User nav right */
.site-user-nav { 
  display: flex; 
  align-items: center; 
  gap: 4px; 
  flex-shrink: 0;
}
.user-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 0.88rem; color: var(--text); white-space: nowrap;
  transition: var(--transition);
}
.user-link:hover { background: var(--accent-bg); color: var(--primary); }

/* ===== BANNER + GRADE BUTTONS GRID ===== */
.grade-banner-section {
  max-width: 1280px;
  width: 100%;
  margin: 8px auto;
  padding: 0 20px;
  box-sizing: border-box;
}
.banner-wrap {
  margin-bottom: 0;
  overflow: hidden;
}
.banner-img {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: cover;
}

/* ===== Banner Carousel ===== */
.banner
.banner-slides {
  display: flex;
  transition: transform 0.5s ease;
}
.banner-slides .banner-img {
  min-width: 100%;
  max-height: 400px;
  object-fit: cover;
  flex-shrink: 0;
}
.banner-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.banner-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: background 0.2s;
}
.banner-dots span.active {
  background: #fff;
}
.banner-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.3);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.banner-wrap:hover .banner-arrow {
  opacity: 1;
}
.banner-arrow-left { left: 10px; }
.banner-arrow-right { right: 10px; }
.banner-arrow:hover {
  background: rgba(0,0,0,0.6);
}

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1; max-width: 1280px; width: 100%;
  margin: 0 auto; padding: 20px;
}
.page-layout {
  display: flex; flex: 1; max-width: 1280px; width: 100%;
  margin: 0 auto; padding: 20px; gap: 20px;
}

/* ===== SIDEBAR (category tree) ===== */
.page-sidebar {
  width: 220px; flex-shrink: 0;
  align-self: flex-start; position: sticky; top: 120px;
  max-height: calc(100vh - 140px); overflow-y: auto;
}
.sidebar-tree {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.tree-grade { border-bottom: 1px solid var(--border); }
.tree-grade:last-child { border-bottom: none; }
.tree-grade-link {
  display: block; padding: 10px 16px;
  font-weight: 600; font-size: 0.9rem; color: var(--text-dark);
  transition: var(--transition);
}
.tree-grade-link:hover { background: var(--accent-bg); color: var(--primary); }
.tree-grade-link.active { color: var(--primary); background: var(--accent-bg); border-left: 3px solid var(--primary); }
.tree-semesters { padding: 0 0 4px 0; }
.tree-semester { }
.tree-semester-toggle {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 6px 16px 6px 24px;
  border: none; background: none; font-size: 0.85rem;
  color: var(--text-light); cursor: pointer; text-align: left;
  transition: var(--transition);
}
.tree-semester-toggle:hover { color: var(--primary); }
.tree-semester-toggle.active { color: var(--primary); font-weight: 500; }
.tree-semester-toggle .arrow {
  transition: transform 0.2s ease; flex-shrink: 0;
}
.tree-semester-toggle.active .arrow { transform: rotate(90deg); }
.tree-subjects {
  list-style: none; padding: 0 0 4px 0;
}
.tree-subject-link {
  display: block; padding: 4px 16px 4px 34px;
  font-size: 0.83rem; color: var(--text-light);
  transition: var(--transition);
  border-left: 2px solid transparent;
}
.tree-subject-link:hover { color: var(--primary); background: var(--accent-bg); border-left-color: var(--accent); }
.tree-subject-link.active { color: var(--primary); font-weight: 500; border-left-color: var(--primary); background: var(--accent-bg); }

/* ===== MAIN CONTENT (right side) ===== */
.page-main {
  flex: 1; min-width: 0;
}

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 1.2rem; font-weight: 700; color: var(--text-dark);
  margin-bottom: 16px;
}
.search-highlight { color: var(--accent); }
.search-count { font-size: 0.85rem; font-weight: 400; color: var(--text-light); margin-left: 8px; }
.card-title mark { background: #fef3c7; color: #92400e; padding: 0 2px; border-radius: 2px; }

/* ===== Profile Table ===== */
.profile-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.profile-table th, .profile-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.profile-table th { font-weight: 600; color: var(--text-dark); background: var(--bg); }
.profile-table td a { color: var(--primary); }
.profile-table td a:hover { text-decoration: underline; }

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  padding: 0 0 12px 0; font-size: 0.85rem; color: var(--text-light);
}
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--primary); }

/* ===== RESOURCE CARD GRID (4 per row) ===== */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 1200px) { .resource-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .resource-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .resource-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

.resource-card {
  display: flex; flex-direction: column;
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: var(--transition);
  border: 1px solid transparent;
}
.resource-card:hover {
  box-shadow: var(--shadow-hover); border-color: var(--border);
  transform: translateY(-3px);
}

/* Card cover image */
.card-cover {
  position: relative; width: 100%; aspect-ratio: 3/4;
  overflow: hidden; background: #ffffff;
}
/* 横版：宽度不变，高度300 */
.resource-card.card-landscape {
  height: 300px;
  overflow: hidden;
}
.resource-card.card-landscape .card-cover {
  flex: none;
  width: 100%;
  height: 200px;
  aspect-ratio: unset;
}
.resource-card.card-landscape .card-cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}
.resource-card.card-landscape .card-body {
  flex: none;
  height: 100px;
  padding: 12px 16px;
  min-width: 0;
  overflow: hidden;
}
.resource-card.card-landscape .card-meta {
  margin-top: auto;
}
.card-cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.3s ease;
}
.resource-card:hover .card-cover img { transform: scale(1.05); }
.card-cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #f8fafc;
  color: #94a3b8; font-size: 1.1rem; font-weight: 600;
}
.card-badge {
  position: absolute; top: 8px; right: 8px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.3px;
}
.card-badge.exclusive { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.card-badge.free { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

/* Card body */
.card-body { padding: 8px 10px 10px; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.card-title {
  font-size: 0.85rem; font-weight: 600; color: var(--text-dark);
  line-height: 1.4; margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  word-break: break-all;
}
.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; font-size: 0.78rem;
}
.card-price { font-weight: 700; color: #dc2626; font-size: 0.9rem; }
.card-price.free { color: #16a34a; }
.card-price.vip { color: #d97706; font-size: 0.9rem; font-weight: 700; }
.card-date { color: var(--text-light); }
.card-filetype { position:absolute; top:8px; right:8px; background:rgba(0,0,0,0.6); color:#fff; font-size:0.72rem; padding:2px 8px; border-radius:4px; }
.ft-pdf { background:#dc2626; }
.ft-word { background:#2563eb; }
.ft-ppt { background:#ea580c; }
.ft-excel { background:#16a34a; }
.ft-other { background:rgba(0,0,0,0.6); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 20px 0;
}
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.85rem; color: var(--text); background: #fff;
  transition: var(--transition);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { border-color: var(--primary); color: #fff; background: var(--primary); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 60px 20px;
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text-light);
  font-size: 1rem;
}

/* ===== DETAIL PAGE ===== */
.detail-layout {
  display: flex; gap: 24px; max-width: 1280px;
  margin: 0 auto; padding: 20px;
}
.detail-main {
  flex: 1; min-width: 0;
}
.detail-title {
  font-size: 1.6rem; font-weight: 700; color: var(--text-dark);
  line-height: 1.4; margin-bottom: 16px;
}
.detail-description {
  background: #fff; border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
  box-shadow: var(--shadow);
  font-size: 0.95rem; line-height: 1.8; color: var(--text);
  overflow-x: auto;
}
.detail-description img {
  max-width: 100%; height: auto; margin: 12px auto;
  display: block;
}
.detail-description p { margin-bottom: 8px; }

/* Right Sidebar */
.detail-sidebar {
  width: 320px; flex-shrink: 0;
}
.sidebar-card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 20px; margin-bottom: 16px;
}
.sidebar-card-title {
  font-size: 0.95rem; font-weight: 600; color: var(--text-dark);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar-download-box {
  text-align: center;
}
.sidebar-download-box .vip-notice p {
  margin-bottom: 0; font-size: 0.9rem; color: var(--text);
}
.btn-download { padding: 14px 40px; font-size: 1.1rem; }

/* File info table */
.detail-file-info {
  width: 100%;
}
.detail-file-info td {
  padding: 6px 0; font-size: 0.88rem;
}
.detail-file-info td:first-child {
  color: var(--text-light); width: 70px;
}
.detail-file-info td:last-child {
  color: var(--text-dark); font-weight: 500;
}

/* Prev / Next */
.detail-prevnext {
  display: flex; gap: 16px; margin-bottom: 20px;
}
.prevnext-item { flex: 1; }
.prevnext-item.right { text-align: right; }
.prevnext-link, .prevnext-disabled {
  display: block; padding: 12px 16px;
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: var(--transition);
}
.prevnext-link:hover { box-shadow: var(--shadow-hover); border-color: var(--primary); }
.prevnext-disabled { opacity: 0.5; }
.prevnext-label { display: block; font-size: 0.8rem; color: var(--text-light); margin-bottom: 4px; }
.prevnext-title { display: block; font-size: 0.9rem; color: var(--text-dark); font-weight: 500; }
.prevnext-link:hover .prevnext-title { color: var(--primary); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 12px; }
.form-label { display: block; font-size: 0.88rem; font-weight: 500; color: var(--text-dark); margin-bottom: 4px; }
.form-input, .form-select {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; font-size: 0.9rem; transition: var(--transition);
  background: #fff;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.1); }
textarea.form-input { height: auto; min-height: 100px; padding: 10px 12px; resize: vertical; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff;
  font-size: 0.9rem; color: var(--text); cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 12px; font-size: 0.82rem; }

/* ===== ALERTS ===== */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 0.88rem; margin-bottom: 12px;
}
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; z-index: 200;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-width: 90vw; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px; }
.modal-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

/* ===== Notice Modal ===== */
.notice-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99999;
  align-items: center;
  justify-content: center;
}
.notice-modal-overlay.active {
  display: flex;
}
.notice-modal-box {
  background: #fff;
  border-radius: 10px;
  width: 320px;
  max-width: 90vw;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: noticeFadeIn 0.25s ease;
  word-break: break-word;
}
@keyframes noticeFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.notice-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}
.notice-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #111827;
}
.notice-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.notice-modal-close:hover {
  color: #374151;
}
.notice-modal-body {
  padding: 16px 18px;
  font-size: 0.9rem;
  color: #374151;
  line-height: 2;
  overflow-y: auto;
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
.notice-modal-footer {
  padding: 10px 18px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
}
.notice-modal-footer .btn {
  min-width: 120px;
}

@media (max-width: 480px) {
  .notice-modal-box {
    width: 85vw;
    max-height: 70vh;
  }
  .notice-modal-header {
    padding: 12px 14px;
  }
  .notice-modal-header h3 {
    font-size: 0.95rem;
  }
  .notice-modal-body {
    padding: 12px 14px;
    font-size: 0.85rem;
  }
  .notice-modal-footer {
    padding: 8px 14px;
  }
  .notice-modal-footer .btn {
    min-width: 100px;
    padding: 7px 16px;
    font-size: 0.85rem;
  }
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: auto; background: #1a1a1a;
  border-top: none; padding: 20px;
  text-align: center; font-size: 0.85rem; color: #fff;
}

/* ===== 右侧浮动工具栏 ===== */
.side-toolbar {
  position: fixed;
  right: 12px;
  bottom: 100px;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-toolbar-item {
  width: 48px;
  height: 48px;
  background: #fff;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #555;
  font-size: 0.6rem;
  text-decoration: none;
  transition: all 0.2s;
  position: relative;
}
.side-toolbar-item:hover {
  color: #555;
  border-color: #e5e7eb;
  text-decoration: none;
}
.side-toolbar-item span {
  margin-top: 1px;
  line-height: 1;
}
.side-vip {
  color: #f59e0b;
  border-color: #e5e7eb;
}
.side-vip:hover {
  color: #f59e0b;
  border-color: #e5e7eb;
}
/* 微信弹出二维码 */
.wechat-popup {
  display: none;
  position: absolute;
  right: 56px;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 10000;
}
.wechat-popup img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  display: block;
}
.side-wechat:hover .wechat-popup {
  display: block;
}

@media (max-width: 768px) {
  .side-toolbar { display: none; }
}

/* ===== AVATAR DROPDOWN ===== */
.user-avatar-dropdown { position: relative; }
.user-avatar-trigger { cursor: pointer; padding: 2px; }
.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; font-weight: 700;
}
.dropdown-menu {
  display: none; position: absolute; right: 0; top: 42px;
  background: #fff; border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 170px; z-index: 300;
  border: 1px solid var(--border);
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: block; padding: 10px 16px; font-size: 0.9rem;
  color: var(--text); white-space: nowrap; transition: background 0.15s;
}
.dropdown-item:hover { background: var(--bg); color: var(--primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== PROFILE 2-COLUMN ===== */
.profile-layout { display: flex; gap: 24px; max-width: 960px; margin: 24px auto; padding: 0 20px; }
.profile-sidebar { width: 200px; flex-shrink: 0; }
.profile-card-mini {
  background: #fff; border-radius: var(--radius); padding: 20px;
  text-align: center; box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.profile-avatar-lg {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; margin: 0 auto 10px;
}
.profile-card-mini h3 { margin: 0 0 6px; font-size: 1rem; }
.profile-nav { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.profile-nav-item {
  display: block; padding: 12px 16px; font-size: 0.9rem;
  color: var(--text); border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.profile-nav-item:last-child { border-bottom: none; }
.profile-nav-item:hover { background: var(--accent-bg); color: var(--primary); }
.profile-nav-item.active { background: var(--accent-bg); color: var(--primary); font-weight: 600; }
.profile-content { flex: 1; min-width: 0; }
.profile-tab { display: none; }
.profile-tab.active { display: block; }
.profile-section {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.profile-section h3 { font-size: 1rem; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.info-grid { display: grid; gap: 12px; }
.info-item { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-item:last-child { border-bottom: none; }
.info-label { width: 100px; font-weight: 600; color: var(--text-dark); font-size: 0.9rem; flex-shrink: 0; }
.info-value { font-size: 0.9rem; color: var(--text); }

/* ===== PROFILE TABLE ===== */
.profile-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.profile-table th, .profile-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.profile-table th { font-weight: 600; color: var(--text-dark); background: var(--bg); }
.profile-table td a { color: var(--primary); }
.profile-table td a:hover { text-decoration: underline; }

/* ===== BADGE ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-info { background: #e2e8f0; color: #64748b; margin-right:4px; }

/* ===== GRADE TREE ARROW ===== */
.grade-arrow { margin-left: 6px; transition: transform 0.2s; vertical-align: middle; }
.tree-grade-link.expanded .grade-arrow { transform: rotate(90deg); }
.tree-grade-link.active { font-weight: 700; }

/* ===== SECTION HEADER (title + search) ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header .section-title { margin-bottom: 0; }
.section-more {
  font-size: 0.85rem;
  color: #9ca3af;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s;
}
.section-more:hover { color: #2563eb; text-decoration: none; }
.section-search {
  width: 400px;
  flex-shrink: 0;
}
.section-search .search-box form,
.section-search form {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
  display: flex;
  align-items: center;
}
.section-search .search-input { padding: 8px 4px; font-size: 0.88rem; flex: 1; }

/* ===== MOBILE BANNER SEARCH (hidden on desktop) ===== */
.mobile-banner-search { display: none; }
.mobile-banner-search .search-box form {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px;
  display: flex;
  align-items: center;
}
.mobile-banner-search .search-input { padding: 9px 4px; font-size: 0.9rem; flex: 1; }

/* ===== MOBILE BOTTOM NAV (mobile only) ===== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  z-index: 100;
  height: 56px;
}
.mobile-bottom-nav-inner {
  display: flex;
  max-width: 600px;
  margin: 0 auto;
  height: 100%;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  font-size: 0.72rem;
  text-decoration: none;
  transition: color 0.15s;
}
.mobile-nav-item .nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}
.mobile-nav-item.active,
.mobile-nav-item:hover { color: var(--primary); }

/* ===== MOBILE DRAWER ===== */
.mobile-drawer-overlay { display:none; position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.45); z-index:2000; }
.mobile-drawer-overlay.open { display:block; }
.mobile-drawer { display:none; position:fixed; top:0; left:0; bottom:0; width:75%; max-width:320px; background:#fff; z-index:2001; transform:translateX(-100%); transition:transform 0.3s ease; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.mobile-drawer.open { display:block; transform:translateX(0); }
.mobile-drawer-top { display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid #f3f4f6; position:sticky; top:0; background:#fff; z-index:1; }
.mobile-drawer-close { background:none; border:none; font-size:1.6rem; color:#374151; cursor:pointer; padding:4px 8px; line-height:1; }
.mobile-drawer-logo { flex:1; text-align:center; }
.mobile-drawer-search { color:#374151; padding:4px 8px; text-decoration:none; }
.mobile-drawer-menu { padding:8px 0; }
.mobile-drawer-item { display:flex; align-items:center; gap:8px; padding:11px 18px; font-size:0.95rem; color:#111827; text-decoration:none; font-weight:500; }
.mobile-drawer-dot { width:8px; height:8px; border-radius:50%; border:2px solid #dc2626; flex-shrink:0; }
.mobile-drawer-tags { display:flex; flex-wrap:wrap; gap:8px; padding:4px 18px 12px 34px; }
.mobile-drawer-tag { display:inline-block; padding:6px 14px; background:#f9fafb; border:1px solid #e5e7eb; border-radius:6px; font-size:0.85rem; color:#374151; text-decoration:none; transition:background 0.15s; }
.mobile-drawer-tag:hover { background:#eff6ff; border-color:#bfdbfe; color:#2563eb; }
.mobile-drawer-user { border-top:1px solid #f3f4f6; padding:14px 18px; display:flex; align-items:center; gap:10px; }
.mobile-drawer-user-avatar { width:40px; height:40px; border-radius:50%; overflow:hidden; flex-shrink:0; }
.mobile-drawer-user-avatar img { width:100%; height:100%; object-fit:cover; }
.mobile-drawer-user-info { flex:1; min-width:0; }
.mobile-drawer-user-name { font-size:0.9rem; font-weight:600; color:#111827; }
.mobile-drawer-vip { font-size:0.75rem; padding:1px 6px; border-radius:4px; }
.mobile-drawer-vip.vip-active { background:#fef3c7; color:#d97706; }
.mobile-drawer-vip.vip-none { background:#f3f4f6; color:#9ca3af; }
.mobile-drawer-user-link { font-size:0.82rem; color:#6b7280; text-decoration:none; white-space:nowrap; }
.mobile-drawer-login-btn { display:block; width:100%; text-align:center; padding:10px; background:#2563eb; color:#fff; border:none; border-radius:8px; font-size:0.9rem; font-weight:600; cursor:pointer; text-decoration:none; margin-top:8px; }

/* ===== RESPONSIVE ===== */

/* Tablet & small desktop */
@media (max-width: 992px) {
  .detail-layout { flex-direction: column; width: 100%; overflow: hidden; }
  .detail-main { width: 100%; max-width: 100%; min-width: 0; overflow: hidden; }
  .detail-sidebar { width: 100%; }
}

/* Mobile */
@media (max-width: 768px) {
  .page-layout { flex-direction: column; padding: 12px; }
  .page-sidebar { width: 100%; position: static; max-height: none; margin-bottom: 16px; }
  .header-inner { padding: 0 12px; height: 52px; gap: 8px; justify-content: space-between; position: relative; }
  .site-logo { font-size: 1.05rem; text-align: center; flex: 1; line-height: 1; }
  /* Hide desktop-only header elements on mobile */
  .mobile-nav-toggle { display: flex !important; order: -1; }
  .top-header .site-nav { display: none !important; }
  .top-header .site-user-nav { display: none !important; }
  .header-right { display: none !important; }
  .grade-banner-section { display: block !important; }
  .search-box { max-width: none; }
  .search-box form { max-width: 100%; }
  .user-link { padding: 4px 10px; font-size: 0.82rem; }
  .grade-nav-inner { padding: 0 12px; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .grade-nav-inner::-webkit-scrollbar { height: 0; }
  .grade-link { display: inline-block; padding: 8px 12px; font-size: 0.85rem; }
  .page-content { padding: 12px; }
  .detail-layout { padding: 12px; overflow: hidden; }
  .detail-main { min-width: 0; overflow: hidden; }
  .detail-main .detail-box { overflow: hidden; }
  .detail-main .detail-cover-img { max-width: 100% !important; width: 100% !important; height: auto !important; display: block !important; }
  .detail-title { font-size: 1.2rem; }
  .detail-prevnext { flex-direction: column; gap: 8px; }
  .detail-description img { max-width: 100% !important; height: auto !important; margin: 12px auto !important; }
  .detail-related-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-box { width: 95vw !important; max-height: 85vh; }
  .card-title { font-size: 0.85rem; }
  .card-meta { font-size: 0.78rem; }
  .pagination { flex-wrap: wrap; gap: 4px; }
  .page-link { padding: 6px 10px; font-size: 0.85rem; }
  .section-title { font-size: 1rem; }
  .breadcrumb { font-size: 0.82rem; white-space: nowrap; overflow-x: auto; }
  .profile-layout { flex-direction: column; }
  .profile-sidebar { width: 100%; }
  .dropdown-menu { right: auto; left: 50%; transform: translateX(-50%); }
  .avatar-circle { width: 30px; height: 30px; font-size: 0.85rem; }
  /* Show mobile bottom navigation */
  .mobile-bottom-nav { display: block; }
  /* Reserve space for fixed bottom nav */
  body { padding-bottom: 56px; }
  /* Compact banner on mobile */
  .grade-banner-section { padding: 0 12px; margin: 8px auto 0; }
  .banner-wrap { margin-bottom: 0; }
  .banner-img,
  .banner-slides .banner-img { max-height: 180px; }
  /* Mobile: show banner search, hide desktop section search */
  .mobile-banner-search { display: block; padding: 0 0 8px 0; }
  .section-search { display: none; }
  .section-header { justify-content: space-between; flex-wrap: nowrap; gap: 0; }
  .section-more { width: auto; }
  .site-footer { padding: 12px 16px; }
}

/* Very small phones */
@media (max-width: 400px) {
  .header-inner { gap: 4px; }
  .site-logo { font-size: 0.9rem; }
  .user-link { padding: 2px 6px; font-size: 0.75rem; }
  .detail-related-grid { grid-template-columns: repeat(1, 1fr); }
}

/* ===== Modal Popup (card activation etc) ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 9999;
  align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-box {
  background: #fff; border-radius: 12px;
  width: 400px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  animation: slideUp 0.25s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; margin: 0; }
.modal-close {
  font-size: 1.5rem; cursor: pointer; color: var(--text-light);
  line-height: 1; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
