:root{
  --sidebar-width:240px;
  --sidebar-collapsed-width:60px;
  --primary-color:#4a6cf7;
  --primary-light:#e8f1fd;
  --light-bg:#f8f9fa;
  --dark-text:#16181a;
  --gray-200:#edf2f7;
  --gray-300:#e2e8f0;
  --danger-color:#e53e3e;
  --shadow-sm:0 1px 2px rgba(0,0,0,.03);
  --shadow-lg:0 10px 15px rgba(0,0,0,.1);
}
body{
  margin:0;
  height:100vh;
  display:flex;
  overflow:hidden;
  color:var(--dark-text);
  font-family:'Segoe UI','SF Pro Display',-apple-system,sans-serif;
  background:#f7fafc;
}
/* ===== 侧边栏 ===== */
#sidebar{
  width:var(--sidebar-width);
  background:#f0f3ff;
  border-right:1px solid var(--gray-300);
  height:100%;
  transition:width .3s;
  display:flex;
  flex-direction:column;
  box-shadow:var(--shadow-sm);
  z-index:1000;
}
#sidebar.collapsed{width:var(--sidebar-collapsed-width)}
.sidebar-header{
  padding:.75rem 1rem;
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:1px solid var(--gray-300);
  height:56px;
}
.logo{display:flex;align-items:center;gap:.5rem;font-weight:600;font-size:1.1rem;color:var(--primary-color)}
#sidebar.collapsed .logo{opacity:0}
.collapse-btn{
  background:none;border:none;font-size:1.1rem;color:#718096;cursor:pointer;
  width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;
}
.collapse-btn:hover{background:var(--gray-200)}
.sidebar-body{flex:1;overflow-y:auto;padding:.75rem 0}
.quick-actions{display:flex;flex-direction:column;gap:.25rem;margin-bottom:1rem}
.quick-btn{
  display:flex;align-items:center;gap:.75rem;padding:.5rem 1rem;border-radius:6px;
  color:var(--dark-text);text-decoration:none;font-size:.9rem;
  transition:background .2s;border:1px solid transparent;margin:0 .75rem;
}
.quick-btn.active{background:var(--primary-light);color:var(--primary-color);border-color:var(--primary-color)}
.quick-btn:hover:not(.active){background:var(--gray-200)}
.quick-btn i{font-size:1rem;min-width:20px;text-align:center}
.history-title{
  font-size:.75rem;color:#718096;text-transform:uppercase;letter-spacing:.5px;
  margin:1rem 0 .5rem .75rem;padding-left:.25rem;
}
.history-list{list-style:none;padding:0;margin:0}
.history-item{
  display:flex;justify-content:space-between;align-items:center;
  padding:.4rem .75rem;border-radius:6px;font-size:.85rem;color:var(--dark-text);
  margin:0 .75rem;cursor:pointer;transition:background .2s;
}
.history-item:hover{background:var(--gray-200)}
.history-item-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px;flex:1}
.history-actions{display:none;gap:.25rem}
.history-item:hover .history-actions{display:flex}
.action-btn{background:none;border:none;color:#718096;font-size:.75rem;cursor:pointer;padding:.1rem .2rem;border-radius:4px}
.action-btn:hover{color:var(--danger-color);background:rgba(229,62,62,.1)}
.sidebar-footer{padding:.75rem 1rem;border-top:1px solid var(--gray-300);position:relative}
.user-section{display:flex;align-items:center;gap:.75rem;margin-bottom:.5rem}
.user-avatar{
  width:32px;height:32px;border-radius:50%;background:var(--primary-color);color:#fff;
  display:flex;align-items:center;justify-content:center;font-weight:700;font-size:.85rem;margin-left:1rem;
}
.user-info{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.user-name{font-size:.85rem;font-weight:500;color:var(--dark-text)}
.user-menu-btn{background:none;border:none;color:#718096;cursor:pointer;width:32px;height:32px;border-radius:8px}
.user-menu-btn:hover{background:var(--gray-200)}
.shortcut-icons{display:flex;gap:2rem;justify-content:center}
.shortcut-btn{
  width:32px;height:32px;border-radius:8px;border:1px solid var(--gray-300);
  background:#fff;display:flex;align-items:center;justify-content:center;
  color:#718096;cursor:pointer;transition:all .2s;font-size:.9rem;
}
.shortcut-btn:hover{background:var(--primary-color);color:#fff;border-color:var(--primary-color)}
#userDropdown{
  position:absolute;top:auto;bottom:100%;right:0;width:200px;background:#fff;
  border-radius:8px;box-shadow:var(--shadow-lg);border:1px solid var(--gray-300);
  padding:.5rem 0;z-index:1000;display:none;
}
.dropdown-item{
  display:flex;align-items:center;gap:.75rem;padding:.75rem 1rem;color:var(--dark-text);
  text-decoration:none;font-size:.9rem;transition:background .2s;
}
.dropdown-item:hover{background:var(--primary-light);color:var(--primary-color)}
.dropdown-item i{font-size:1rem;min-width:20px;text-align:center}
/* ===== 主内容占位 ===== */
#main-content{
  flex:1;
  overflow-y: auto;
  background:#f7fafc;
  transition:margin-left .3s;
  padding: 20px;
}
#main-content.sidebar-collapsed{margin-left:calc(var(--sidebar-collapsed-width) - var(--sidebar-width))}
/* ===== 折叠状态隐藏 ===== */
#sidebar.collapsed .logo,
#sidebar.collapsed .user-info,
#sidebar.collapsed .quick-btn span,
#sidebar.collapsed .history-item-title,
#sidebar.collapsed .user-avatar,
#sidebar.collapsed .history-title{display:none}
#sidebar.collapsed .quick-btn,
#sidebar.collapsed .history-item{justify-content:center;padding:.75rem 0}
#sidebar.collapsed .user-section{justify-content:center}
#sidebar.collapsed .shortcut-icons{display:none}
@media(max-width:768px){
  :root{--sidebar-width:60px}
  #sidebar{width:var(--sidebar-width)}
}
/* ===== 主内容样式 ===== */
.section {
  margin-bottom: 40px;
}
.section-header {
  margin-bottom: 20px;
}
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--dark-text);
  position: relative;
  padding-left: 10px;
}
.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  width: 4px;
  height: 24px;
  background: var(--primary-color);
  border-radius: 2px;
}
.forum-content {
  display: flex;
  /* 在小屏幕上优先保持水平排列，必要时才换行 */
  flex-wrap: wrap;
  /* 关键：确保子元素拉伸以填满容器高度 */
  align-items: stretch;
}
.forum-content > .col-md-8,
.forum-content > .col-md-4 {
  /* 确保在小屏幕上也能占据空间，避免被挤下去 */
  flex-shrink: 0;
  width: auto;
  max-width: 100%;
  /* 关键：使子列也拉伸 */
  display: flex;
}
/* 在中等及以上屏幕强制水平排列 */
@media (min-width: 768px) {
  .forum-content {
    flex-wrap: nowrap;
  }
  .forum-content > .col-md-8 {
    flex: 0 0 auto;
    width: calc(66.666% - 10px); /* 减去间距的一半 */
  }
  .forum-content > .col-md-4 {
    flex: 0 0 auto;
    width: calc(33.333% - 10px); /* 减去间距的一半 */
  }
}
.hot-rank-card {
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  background: white;
  /* 移除了 height: fit-content; 以允许卡片拉伸 */
  /* 添加最小宽度以防止过度压缩 */
  min-width: 0;
  width: 100%;
  /* 关键：确保卡片内容垂直排列并填充 */
  display: flex;
  flex-direction: column;
}
/* 移除了 .card-header 的样式，因为它已被删除 */
.card-body {
    padding: 1.25rem;
    /* 关键：使 body 也参与弹性布局 */
    flex: 1;
    display: flex;
    flex-direction: column;
}
.hot-list {
  list-style: none;
  padding: 0;
  margin: 0;
  /* 关键：让列表占据剩余空间 */
  flex-grow: 1;
}
.hot-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
}
.hot-item:last-child {
  border-bottom: none;
}
.rank-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  margin-right: 10px;
  flex-shrink: 0;
}
.rank-1 .rank-badge {
  background: #ff6b6b;
  color: white;
}
.rank-2 .rank-badge {
  background: #4ecdc4;
  color: white;
}
.rank-3 .rank-badge {
  background: #ffd166;
  color: white;
}
.hot-content {
  flex: 1;
}
.hot-content h6 {
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0 0 5px 0;
}
.hot-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #999;
}
.date {
  font-size: 0.75rem;
}
.read-count {
  font-size: 0.75rem;
}
.forum-slider {
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  background: white;
  overflow: hidden; /* 隐藏超出部分 */
  /* 关键：确保轮播卡片也拉伸 */
  flex: 1;
  display: flex;
  flex-direction: column;
}
.forum-slider .card-body {
  /* 关键：确保轮播卡片 body 也拉伸 */
  flex: 1;
  display: flex;
  flex-direction: column;
}
/* 新增的 wrapper 用于隐藏溢出 */
.carousel-wrapper {
  overflow: hidden;
  width: 100%;
  /* 关键：让 wrapper 也拉伸 */
  flex: 1;
  display: flex;
  flex-direction: column;
}
.slider-container {
  display: flex;
  /* 关键：使用 flex 布局 */
  flex-direction: row;
  /* 关键：不允许换行 */
  flex-wrap: nowrap;
  gap: 20px;
  padding: 10px;
  /* 关键：移除 transform 动画，改用 left 定位 */
  position: relative;
  left: 0;
  transition: left 0.5s ease-in-out;
  /* 关键：确保容器拉伸 */
  flex: 1;
}
.slide {
  /* 关键：设置固定宽度 */
  min-width: calc(100% - 20px); /* 减去 gap */
  scroll-snap-align: start;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s;
  background: white;
  display: flex; /* 使用 flex 布局 */
  /* 关键：确保每个 slide 也拉伸 */
  flex: 1;
}
.slide-content {
  display: flex;
  flex-direction: row; /* 改为水平排列 */
  gap: 15px;
  width: 100%;
  padding: 15px;
  /* 关键：确保内容拉伸 */
  flex: 1;
}
.slide-img {
  width: 300px; /* 固定图片宽度 */
  height: 225px; /* 固定图片高度 */
  overflow: hidden;
  border-radius: 8px;
  flex-shrink: 0; /* 防止图片被压缩 */
}
.slide-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.slide-info {
  flex: 1; /* 占据剩余空间 */
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* 内容两端对齐 */
}
.slide-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 10px 0;
}
.slide-desc {
  font-size: 0.9rem;
  color: #666;
  margin: 0 0 10px 0;
  line-height: 1.4;
  flex-grow: 1; /* 描述占据可用空间 */
}
.slide-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #999;
}
.slide-time {
  font-size: 0.8rem;
}
.slide-read {
  font-size: 0.8rem;
}
/* ===== AI资源选项卡样式 ===== */
.tab-nav {
  margin-bottom: 20px;
}
.nav-tabs {
  border-bottom: 1px solid var(--gray-300);
}
.nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  color: var(--dark-text);
  border-radius: 0;
  transition: all 0.3s;
}
.nav-link.active {
  border-bottom: 2px solid var(--primary-color);
  color: var(--primary-color);
  font-weight: 600;
}
.nav-link:hover {
  color: var(--primary-color);
}
.tab-content {
  border: 1px solid var(--gray-300);
  border-top: none;
  border-radius: 8px;
  overflow: hidden;
}
/* ===== AI试卷样式 ===== */
.papers-container {
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.papers-filter {
  margin-bottom: 20px;
}
.filter-row {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap; /* 允许换行 */
}
.subject-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
}
.filter-btn {
  padding: 8px 15px;
  background: #f0f3ff;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.9rem;
}
.filter-btn:hover,
.filter-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}
/* ===== 搜索框样式 (圆角 + 图标) ===== */
.search-box {
  position: relative;
  flex: 1;
  max-width: 300px; /* 保持最大宽度 */
}
.search-box .form-control {
  padding-right: 40px; /* 为图标留出空间 */
  border: 1px solid var(--gray-300); /* 添加边框 */
  border-radius: 50px !important; /* 强制圆角 */
}
.search-box .form-control:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}
.search-icon {
  position: absolute;
  right: 15px; /* 调整图标位置 */
  top: 50%;
  transform: translateY(-50%);
  color: #999; /* 图标颜色 */
  pointer-events: none; /* 防止图标干扰输入 */
}
.papers-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
}
.paper-item {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s;
  background: white;
}
.paper-item:hover {
  transform: translateY(-5px);
}
.paper-img {
  width: 100%;
  height: 180px;
  overflow: hidden;
}
.paper-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.paper-info {
  padding: 15px;
}
.paper-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 10px;
}
.paper-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 15px 0;
}
.paper-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 15px;
}
/* ===== AI图片样式 (瀑布流) ===== */
.images-masonry {
  column-count: 5; /* 一行5列 */
  column-gap: 15px; /* 列间距 */
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.masonry-item {
  break-inside: avoid; /* 防止图片被截断 */
  margin-bottom: 15px; /* 图片间距 */
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.masonry-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s;
}
.masonry-item img:hover {
  transform: scale(1.02); /* 悬停放大效果 */
}
/* ===== AI听力样式 ===== */
.audio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.audio-item {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s;
  background: white;
}
.audio-item:hover {
  transform: translateY(-5px);
}
.audio-content {
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.audio-img {
  width: 100%;
  height: 180px;
  overflow: hidden;
  border-radius: 8px;
  flex-shrink: 0;
}
.audio-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.audio-info {
  margin-top: 10px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.audio-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 5px 0;
}
.audio-desc {
  font-size: 0.9rem;
  color: #666;
  margin: 0 0 15px 0;
  flex-grow: 1;
}
.audio-play-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.3s;
  align-self: flex-end;
  margin-top: auto; /* 将按钮推到底部 */
}
.audio-play-btn:hover {
  color: #3a5af5;
}
/* 响应式设计 */
@media (max-width: 992px) {
  .forum-content {
    flex-direction: column; /* 在小屏幕上论坛内容垂直排列 */
  }
  .papers-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .images-masonry {
    column-count: 3; /* 中等屏幕3列 */
  }
  .audio-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  #main-content {
    padding: 10px;
  }
  .section-title {
    font-size: 1.3rem;
  }
  .papers-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .images-masonry {
    column-count: 2; /* 小屏幕2列 */
  }
  .audio-grid {
    grid-template-columns: 1fr;
  }
  .search-box {
    max-width: 100%; /* 小屏幕上搜索框占满宽度 */
    margin-top: 10px; /* 在小屏幕上与筛选按钮有一些间距 */
  }
  .filter-row {
    flex-direction: column; /* 在小屏幕上垂直排列 */
    align-items: stretch; /* 拉伸子元素以填充容器 */
  }
  .subject-filters {
    justify-content: center; /* 在小屏幕上居中筛选按钮 */
  }
  /* 确保在小屏幕上，论坛内容也能正确换行 */
  .forum-content {
    flex-wrap: wrap;
  }
  .forum-content > .col-md-8,
  .forum-content > .col-md-4 {
    width: 100%;
    flex: 0 0 100%;
  }
}