:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-soft: #f4ede4;
  --border: #e7ddd0;
  --text: #2c221e;
  --text-muted: #786960;
  --accent: #b85d2d;
  --accent-hover: #9d4c21;
  --accent-soft: #f9ebe2;
  --shadow-sm: 0 2px 8px rgba(44, 34, 30, 0.05);
  --shadow-md: 0 8px 24px rgba(44, 34, 30, 0.08);
  --radius: 12px;
  --sidebar-w: 290px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* 移动端顶部栏 */
.mobile-header {
  display: none;
}

.mobile-only {
  display: none;
}

/* 左侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 30;
}

.sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.search-box {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.search-box input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
  background: #fff;
}

.course-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.nav-overview-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 9px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

.nav-overview-btn:hover {
  background: var(--surface-soft);
}

.nav-overview-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(184, 93, 45, 0.25);
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 9px;
  padding: 9px 11px;
  margin-bottom: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  transition: background-color 0.12s;
}

.nav-item:hover {
  background: var(--surface-soft);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-color: rgba(184, 93, 45, 0.25);
}

.nav-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-counts {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.nav-item.active .nav-item-counts {
  color: var(--accent);
  border-color: rgba(184, 93, 45, 0.25);
  background: #fff;
}

/* 主内容区 */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 64px;
  max-width: 1220px;
  margin: 0 auto;
}

.loading-state,
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 64px 20px;
  font-size: 15px;
}

/* 总览页面 */
.overview-header {
  margin-bottom: 22px;
}

.overview-header h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.overview-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.course-card-cover {
  aspect-ratio: 4 / 3;
  background: var(--surface-soft);
  overflow: hidden;
  position: relative;
}

.course-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.course-card-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 32px;
  color: var(--text-muted);
}

.course-card-body {
  padding: 12px 14px 14px;
}

.course-card-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.course-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

/* 课程详情页 */
.detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.detail-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.back-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
}

.back-btn:hover {
  background: var(--surface-soft);
}

.detail-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
}

.detail-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn-outline {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-outline:hover {
  background: var(--surface-soft);
}

.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.section-block {
  margin-bottom: 34px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h3 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-tip {
  font-size: 13px;
  color: var(--text-muted);
}

.view-mode-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* 图片区：网格模式 */
.image-gallery.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.image-gallery.mode-stream {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
}

.photo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  position: relative;
}

.photo-card img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--surface-soft);
}

.mode-grid .photo-card img {
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.photo-caption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
}

/* 视频按需加载区 */
.bandwidth-notice {
  background: var(--accent-soft);
  border: 1px solid rgba(184, 93, 45, 0.22);
  color: #7c3b19;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.video-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.video-info-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 3px;
}

.video-info-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.video-player-wrap {
  margin-top: 14px;
  background: #141110;
  border-radius: 10px;
  overflow: hidden;
}

.video-player-wrap video {
  width: 100%;
  max-height: 75vh;
  display: block;
}

/* 全屏灯箱 */
.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(18, 14, 12, 0.94);
  display: flex;
  flex-direction: column;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.lightbox-counter {
  font-size: 14px;
  color: #e7ddd0;
}

.lightbox-actions {
  display: flex;
  gap: 8px;
}

.lb-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}

.lb-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-stage {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: calc(100vh - 88px);
  object-fit: contain;
  border-radius: 4px;
  cursor: zoom-in;
  transition: transform 0.15s ease;
}

.lightbox-stage.zoomed {
  align-items: flex-start;
  justify-content: flex-start;
}

.lightbox-stage.zoomed img {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  margin: 0 auto;
  cursor: zoom-out;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 60px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  z-index: 3;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-nav.prev {
  left: 14px;
}

.lightbox-nav.next {
  right: 14px;
}

/* 移动端适配 */
@media (max-width: 860px) {
  .app-shell {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 25;
  }

  .mobile-title {
    font-weight: 700;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-btn {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .text-btn {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-only {
    display: grid;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(84vw, 310px);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 50;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 40;
  }

  .main-content {
    padding: 16px 14px 48px;
  }

  .course-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .image-gallery.mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

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

  .detail-title {
    font-size: 20px;
  }

  .lightbox-nav {
    width: 36px;
    height: 48px;
    font-size: 24px;
  }
}
