/* ==========================================================================
   app.css — 材料科学基础 - 云端同步网页版
   由原 index.html 内联 <style> 原样外置（规则、选择器、数值完全未改动）。
   外置后浏览器可缓存本文件，二次访问不再重复解析样式，首屏更快。
   ========================================================================== */

:root {
  --primary-color: #1a237e;
  --primary-gradient: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
  --bg-color: #f0f2f5;
  --text-color: #333;
  --card-bg: #ffffff;
  --nav-height-top: 70px;
  --nav-height-bottom: 50px;
  --nav-bg-color: #0d47a1;
  /* 新增：授课教师子模块内五段信息（姓名/联系方式/头衔/简介/研究方向标签）的统一间距 */
  --teacher-info-gap: 16px;
}

[data-theme="eye-care"] {
  --primary-color: #2e7d32;
  --primary-gradient: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
  --bg-color: #f1f8e9;
  --text-color: #333;
  --card-bg: #ffffff;
  --nav-bg-color: #1b5e20;
}

[data-theme="gray"] {
  --primary-color: #424242;
  --primary-gradient: linear-gradient(135deg, #424242 0%, #212121 100%);
  --bg-color: #eeeeee;
  --text-color: #212121;
  --card-bg: #fafafa;
  --nav-bg-color: #212121;
}

/* 新增：建大红色主题 */
[data-theme="red"] {
  --primary-color: #a3202b;
  --primary-gradient: linear-gradient(135deg, #a3202b 0%, #701219 100%);
  --bg-color: #fdf4f4;
  --text-color: #333;
  --card-bg: #ffffff;
  --nav-bg-color: #7d1720;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif; background: var(--bg-color); color: var(--text-color); line-height: 1.6; transition: background 0.3s; }

#loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255,255,255,0.9); z-index: 10000;
  display: none; flex-direction: column; justify-content: center; align-items: center;
  transition: opacity 0.3s;
}
#loading-overlay.show { display: flex; }
.spinner {
  width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--primary-color);
  border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.sync-status {
  position: fixed; top: 0; left: 0; width: 100%;
  background: #4caf50; color: white; text-align: center;
  padding: 5px; font-size: 12px; z-index: 10001;
  transform: translateY(-100%); transition: transform 0.3s;
}
.sync-status.visible { transform: translateY(0); }
.sync-status.error { background: #f44336; }
.sync-status.saving { background: #ff9800; }

#auth-view { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #1a237e; display: flex; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.5s; }
.auth-container {
  background: white; padding: 40px; border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  width: 100%; max-width: 550px;
  text-align: center; position: relative; overflow: hidden;
}
.auth-header h2 {
  color: var(--primary-color); margin-bottom: 10px; font-size: 22px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auth-header p { color: #666; margin-bottom: 30px; font-size: 14px; }

.auth-tabs { display: flex; margin-bottom: 25px; border-bottom: 2px solid #eee; }
.auth-tab { flex: 1; padding: 10px; cursor: pointer; font-weight: bold; color: #999; transition: all 0.3s; }
.auth-tab.active { color: var(--primary-color); border-bottom: 2px solid var(--primary-color); margin-bottom: -2px; }

.input-group { margin-bottom: 15px; text-align: left; }
.input-group label { display: block; margin-bottom: 6px; color: #555; font-size: 13px; font-weight: 500; }
.input-group input, .input-group select { width: 100%; padding: 10px 15px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.3s; }
.input-group input:focus, .input-group select:focus { border-color: var(--primary-color); }

.auth-btn { width: 100%; padding: 12px; background: var(--primary-gradient); color: white; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; margin-top: 10px; }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.error-msg { color: #e91e63; font-size: 13px; margin-top: 10px; display: none; }

.demo-hint { margin-top: 20px; font-size: 12px; color: #666; background: #f5f5f5; padding: 10px; border-radius: 6px; text-align: left; line-height: 1.8;}

/* 新增：登录表单的“记住信息 / 同意协议”勾选项 */
.auth-options { margin-top: 4px; text-align: left; }
.checkbox-line { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; color: #555; cursor: pointer; margin-bottom: 8px; }
.checkbox-line input { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--primary-color); cursor: pointer; flex: none; }
.checkbox-line a { color: var(--primary-color); text-decoration: underline; }

/* 新增：用户协议与隐私政策正文 */
.terms-body { max-height: 50vh; overflow-y: auto; font-size: 13px; color: #555; line-height: 1.9; text-align: left; border: 1px solid #eee; border-radius: 8px; padding: 15px; background: #fafafa; }
.terms-body h4 { color: var(--primary-color); font-size: 14px; margin: 12px 0 4px; }
.terms-body h4:first-child { margin-top: 0; }

#course-view { display: none; }

.navbar {
  background: var(--nav-bg-color);
  padding: 0 40px; position: fixed; width: 100%; top: 0; z-index: 1000; box-shadow: 0 2px 10px rgba(0,0,0,0.3); transition: background 0.3s;
}
.nav-top {
  max-width: 1200px; margin: 0 auto; display: flex;
  justify-content: space-between; align-items: center; height: var(--nav-height-top);
}
.nav-bottom {
  max-width: 1200px; margin: 0 auto; display: flex;
  justify-content: center; align-items: center; height: var(--nav-height-bottom);
  border-top: 1px solid rgba(255,255,255,0.1);
}

.nav-logo { color: white; font-size: 28px; font-weight: bold; white-space: nowrap; flex-shrink: 0; }
.nav-logo span { color: #64b5f6; font-size: 24px; }
.nav-links { display: flex; gap: 30px; list-style: none; }
.nav-links a { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 18px; padding: 6px 16px; border-radius: 20px; transition: all 0.3s; white-space: nowrap; }
.nav-links a:hover { color: white; background: rgba(255,255,255,0.15); }
.user-info { color: white; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; white-space: nowrap; }
.role-badge { background: rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 12px; font-size: 12px; }
.logout-btn, .settings-btn { background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3); color: white; padding: 4px 12px; border-radius: 15px; cursor: pointer; font-size: 12px; margin-left: 5px; }
.logout-btn:hover, .settings-btn:hover { background: rgba(255,255,255,0.3); }

.export-btn, .sync-btn, .stats-btn {
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3); color: white;
  padding: 4px 12px; border-radius: 15px; cursor: pointer; font-size: 12px;
  display: none; margin-left: 5px;
}
.export-btn:hover, .sync-btn:hover, .stats-btn:hover { background: rgba(255,255,255,0.3); }
.sync-btn { background: rgba(33, 150, 243, 0.8); }
.stats-btn { background: rgba(156, 39, 176, 0.8); }
.export-btn { background: rgba(76, 175, 80, 0.8); }

.hero {
  margin-top: calc(var(--nav-height-top) + var(--nav-height-bottom));
  background: var(--nav-bg-color);
  padding: 80px 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
  /* paint 隔离：把光晕和背景图的失效范围关在 hero 内，不再波及整页重绘 */
  contain: paint;
  isolation: isolate;
  transition: background 0.3s;
}
.hero::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background:
    radial-gradient(circle at 30% 40%, rgba(0, 150, 255, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(0, 220, 255, 0.15) 0%, transparent 40%);
  animation: pulseGlow 8s ease-in-out infinite;
  /* 动画本身只用 transform/opacity，显式提升为合成层后不再逐帧重绘 */
  will-change: transform, opacity;
  z-index: 0;
}
/* Hero 滚出视口时由 JS 挂上：无限动画停摆，滚动与输入不再被逐帧拖累 */
.hero.glow-paused::after { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .hero::after { animation: none; }
}
@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* 新增：Hero内容包装器，用于添加羽化背景框 */
.hero-content-wrapper {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 40px 60px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.85); /* 半透明白色填充 */
  box-shadow: 0 0 60px 20px rgba(255, 255, 255, 0.6); /* 宽大的羽化过渡效果 */
  backdrop-filter: blur(5px); /* 轻微模糊背景，增强文字对比度 */
  max-width: 90%;
}

.hero h1 { color: var(--primary-color); font-size: 42px; margin-bottom: 15px; text-shadow: none; }
.hero p { color: #333; font-size: 18px; max-width: 600px; margin: 0 auto; }
.hero-tags { margin-top: 25px; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
.hero-tag {
  background: rgba(26, 35, 126, 0.1); color: var(--primary-color); padding: 6px 18px; border-radius: 20px; font-size: 14px;
  border: 1px solid rgba(26, 35, 126, 0.2); cursor: default; transition: all 0.3s;
}
.teacher-mode .hero-tag.editable { cursor: pointer; background: rgba(26, 35, 126, 0.15); border-color: #ff9800; }
.teacher-mode .hero-tag.editable:hover { background: rgba(26, 35, 126, 0.25); }
.add-hero-tag-btn {
  background: transparent; border: 1px dashed var(--primary-color); color: var(--primary-color);
  padding: 6px 18px; border-radius: 20px; font-size: 14px; cursor: pointer; transition: all 0.3s;
}
.add-hero-tag-btn:hover { background: rgba(26, 35, 126, 0.1); }

/* 新增：更换背景按钮样式 - 调整为深色背景以适应白色框内或保持独立 */
.change-hero-bg-btn {
  margin-top: 20px;
  background: var(--primary-color);
  border: none;
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.change-hero-bg-btn:hover {
  background: #0d47a1;
  transform: translateY(-2px);
}

/* 新增：顶部背景多图轮播。图层只盖在 .hero 底色之上、内容层(.hero-content-wrapper, z-index 1)之下，
   并且不吃指针事件，标题/标签/按钮的可点区域与改造前一致。
   切换只用 opacity（合成层属性，交给 GPU），不产生重排；.hero 已有的 contain:paint 把失效范围关在这层里。 */
.hero-bg-stack {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.hero-bg-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
  will-change: opacity;
}
.hero-bg-slide.active { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .hero-bg-slide { transition: none; }
}

/* 新增：首页背景图管理窗口（「更换背景图片」按钮打开）里的缩略图列表 */
.hero-bg-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.hero-bg-empty { font-size: 13px; color: #999; }
.hero-bg-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #e0e0e0; border-radius: 8px; padding: 8px;
}
.hero-bg-thumb {
  width: 96px; height: 54px; flex: none; display: block; object-fit: cover;
  border-radius: 6px; background: #f0f2f5;
}
.hero-bg-item-text { flex: 1; min-width: 0; }
.hero-bg-item-name { font-size: 13px; color: #333; }
.hero-bg-item-tip { font-size: 12px; color: #999; margin-top: 2px; }
.hero-bg-item-ops { display: flex; gap: 6px; flex: none; }
.hero-bg-op-btn {
  padding: 6px 10px; border: 1px solid var(--primary-color); background: white;
  color: var(--primary-color); border-radius: 6px; cursor: pointer; font-size: 12px;
}
.hero-bg-op-btn:hover { background: #e8eaf6; }
.hero-bg-op-btn.danger { border-color: #f44336; color: #c62828; }
.hero-bg-op-btn.danger:hover { background: #ffebee; }

.view-count {
  margin-top: 15px; color: #666; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}

.main-content { max-width: 1200px; margin: 0 auto; padding: 40px 20px; }
.section { margin-bottom: 50px; }
.section-title { font-size: 28px; color: var(--primary-color); margin-bottom: 30px; padding-left: 15px; border-left: 4px solid var(--primary-color); display: flex; align-items: baseline; gap: 10px; }
/* 模块浏览点击量：.section-title 本来就是 flex，margin-left:auto 把它推到同一行的最右侧。
   字号按需求再收 0.9 倍：0.7em → 0.63em，仍是相对标题的 em，换断点跟着名称一起缩放；
   数字 .module-count b 1em → 1.3em（相对小字自身），即数字比「本模块的浏览点击量」这几个字大 1.3 倍，
   两者都是标题的固定比例（小字 0.63 倍、数字 0.63×1.3=0.819 倍），实测标题 10px 时小字 6.3px、数字 8.19px，
   小字相对上一版正好 0.9 倍。
   对齐方式跟着改成基线对齐：小字一旦比名称小，flex-end 贴的就不是基线而是行盒底边，
   实测（无头浏览器量两个行盒各自的基线标记）小字会往下掉 0.81~3.52px（名称 28px 那档掉 3.45px），
   看上去是「小字沉底」。改成 .section-title: align-items:center→baseline + 小字 align-self:baseline 后，
   两个字号不同、甚至字重不同的文本段按同一条基线排，且不再依赖具体字体的 ascent/descent 比例，加字换字体都不走形。
   本轮把数字单独放大到 1.3 倍后重新量过：16 档视口（300~1440）× 五个模块 × 计数 1/3/5/6/7 位，
   名称基线 vs 小字基线、名称基线 vs 数字基线的差全部 0.00px（放大后的数字仍与名称同一条基线）；
   标题行盒高度逐档与改动前一字相同（300/375/480/768/1024/1440 是 16/19.92/26.97/38.39/44.8/44.8px，
   始终等于名称那一行的 1.6 倍），因为数字那一行的行盒只有 1.6×0.819=1.31 倍标题字号，撑不过名称。
   「授课教师」那条 .section-title 只有一个文本 flex item，center→baseline 对它的几何完全无影响
   （标题行盒高度实测不变）。纯显示层，不进 appData、不进 /content，同步包体的字节数与请求数一字不变。 */
.module-count {
  margin-left: auto; flex: none; align-self: baseline;
  font-size: 0.63em; font-weight: normal; line-height: inherit;
  color: #666; white-space: nowrap;
}
.module-count b { color: var(--primary-color); font-size: 1.3em; }

.teacher-card { background: var(--card-bg); border-radius: 16px; padding: 40px; display: flex; gap: 40px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); position: relative; margin-bottom: 20px; transition: background 0.3s; }
.teacher-avatar-wrapper {
  width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; position: relative;
  background: var(--primary-gradient); display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: default;
}
.teacher-avatar-img { width: 100%; height: 100%; object-fit: cover; display: none; }
.teacher-avatar-text { color: white; font-size: 50px; font-weight: bold; }

.teacher-mode .teacher-avatar-wrapper.uploadable { cursor: pointer; border: 3px dashed transparent; transition: all 0.3s; }
.teacher-mode .teacher-avatar-wrapper.uploadable:hover { border-color: #ff9800; opacity: 0.9; }
.teacher-mode .teacher-avatar-wrapper.uploadable::after {
  content: '📷 更换'; position: absolute; bottom: 0; left: 0; width: 100%;
  background: rgba(0,0,0,0.6); color: white; font-size: 12px; text-align: center;
  padding: 4px 0; opacity: 0; transition: opacity 0.3s;
}
.teacher-mode .teacher-avatar-wrapper.uploadable:hover::after { opacity: 1; }

/* 修改：姓名/邮箱联系方式/头衔/简介/研究方向标签五段统一间距。
   原来各段靠自己的 margin-bottom（5/12/15/20px）撑开，字段缺一个还会留空档。
   改成 flex column + 单一 row-gap：相邻两块之间的间距恒等于 --teacher-info-gap，
   与每段字号、是否换行无关；纯表现层，渲染逻辑与云端数据结构未动。 */
.teacher-info { flex: 1; display: flex; flex-direction: column; row-gap: var(--teacher-info-gap); }
/* 某段没填（如简介留空、没有研究方向标签）时不占位，避免多出一段空白把间距拉开 */
.teacher-info > :empty { display: none; }
.teacher-info h3 { font-size: 24px; color: var(--primary-color); }
.teacher-info .title { color: #666; font-size: 15px; }
.teacher-info .bio { color: #555; font-size: 15px; line-height: 1.8; }
/* 新增：每个教师子模块的「邮箱/联系方式」（t.contact，纯文字；未填时 app.js 不渲染这一行） */
.teacher-info .contact { color: #555; font-size: 14px; line-height: 1.6; word-break: break-all; }
.teacher-tags { display: flex; gap: 10px; flex-wrap: wrap; }
.teacher-tag { background: #e8eaf6; color: var(--primary-color); padding: 5px 14px; border-radius: 15px; font-size: 13px; }

.add-teacher-btn {
  background: var(--card-bg); border: 2px dashed var(--primary-color); border-radius: 16px; padding: 40px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--primary-color); font-size: 18px; cursor: pointer; transition: all 0.3s; margin-bottom: 20px;
}
.add-teacher-btn:hover { background: #e8eaf6; }

.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); z-index: 5000; display: none;
  justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: white; border-radius: 16px; padding: 35px; width: 100%; max-width: 520px;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-box h3 { color: var(--primary-color); margin-bottom: 20px; font-size: 20px; }
.modal-box label { display: block; font-size: 13px; color: #666; margin-bottom: 5px; margin-top: 12px; }
.modal-box input, .modal-box textarea, .modal-box select {
  width: 100%; padding: 10px; border: 2px solid #e0e0e0; border-radius: 8px;
  font-family: inherit; font-size: 14px; outline: none; transition: border-color 0.3s;
}
.modal-box input:focus, .modal-box textarea:focus { border-color: var(--primary-color); }
.modal-box textarea { min-height: 80px; resize: vertical; }
.modal-actions { display: flex; gap: 10px; margin-top: 25px; justify-content: flex-end; }
.modal-actions button { padding: 10px 24px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; }

/* 新增：系统设置窗口按住标题栏可拖动（.draggable-modal 由 app.js 挂在可拖动的那个弹窗上）。
   位移走 transform，不改布局尺寸；touch-action:none 让手指拖动不被页面滚动吃掉 */
.draggable-modal > h3 { cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
.draggable-modal > h3.dragging { cursor: grabbing; }

/* 新增：身份白名单（站点根目录 xls/xlsx/csv/txt 文件）的状态、识别与预览 */
.whitelist-status {
  font-size: 13px; color: var(--primary-color); background: #f5f6fa; border: 1px solid #e0e0e0;
  border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; word-break: break-all; text-align: left;
}
.whitelist-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.whitelist-actions button {
  flex: 1; min-width: 120px; padding: 9px 10px; border: 1px solid var(--primary-color); background: white;
  color: var(--primary-color); border-radius: 8px; cursor: pointer; font-size: 13px;
}
.whitelist-actions button:hover { background: #f8f9ff; }
.whitelist-hint { font-size: 12px; color: #999; line-height: 1.7; margin: 8px 0 0; text-align: left; }
.whitelist-preview { margin-top: 12px; max-height: 260px; overflow-y: auto; border: 1px solid #eee; border-radius: 8px; }
.whitelist-preview:empty { display: none; }
.whitelist-summary { font-size: 12px; color: #555; padding: 8px 10px; text-align: left; }
.whitelist-issues { font-size: 12px; color: #c62828; background: #fff3f3; padding: 8px 10px; line-height: 1.6; text-align: left; }
.whitelist-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.whitelist-table th {
  position: sticky; top: 0; background: #f5f5f5; color: #666; text-align: left;
  padding: 6px 10px; border-bottom: 1px solid #ddd;
}
.whitelist-table td { padding: 5px 10px; border-bottom: 1px solid #f2f2f2; color: #444; text-align: left; }

.edit-btn {
  position: absolute; top: 20px; right: 20px;
  background: #ff9800; color: white; border: none;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12px; display: flex; align-items: center; gap: 5px; z-index: 2;
}
.edit-btn:hover { background: #f57c00; }

.del-teacher-btn {
  position: absolute; top: 20px; right: 110px;
  background: #f44336; color: white; border: none;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 12px; z-index: 2;
}
.del-teacher-btn:hover { background: #d32f2f; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; }
.course-item {
  background: var(--card-bg); border-radius: 12px; padding: 25px; box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-left: 4px solid var(--primary-color); position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  padding-right: 25px;
  padding-bottom: 80px;
}
.course-item.dragging { opacity: 0.5; border: 2px dashed var(--primary-color); }
.course-item.drag-over { transform: scale(1.02); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }

.drag-handle {
  position: absolute; top: 15px; right: 15px; left: auto; cursor: grab; color: #999; font-size: 18px;
  padding: 5px; display: none; z-index: 10;
}
.drag-handle:active { cursor: grabbing; }
.teacher-mode .drag-handle { display: block; }

/* 教师卡片拖拽按钮 */
.drag-handle-teacher {
  position: absolute; bottom: 20px; right: 20px; cursor: grab; color: #999; font-size: 16px;
  padding: 5px; display: none; z-index: 10; background: rgba(255,255,255,0.8); border-radius: 4px;
}
.drag-handle-teacher:active { cursor: grabbing; }
.teacher-mode .drag-handle-teacher { display: block; }

.course-item-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.course-number { width: 36px; height: 36px; background: var(--primary-color); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: bold; flex-shrink: 0; }
.course-item h4 { font-size: 17px; color: var(--primary-color); line-height: 1.4; word-break: break-word; text-align: left; }
.course-item p { color: #666; font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
.course-meta { font-size: 13px; color: #999; margin-bottom: 15px; }

.add-course-btn {
  background: var(--card-bg); border: 2px dashed var(--primary-color); border-radius: 12px; padding: 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--primary-color); font-size: 16px; cursor: pointer; transition: all 0.3s; min-height: 200px;
}
.add-course-btn:hover { background: #e8eaf6; }
.add-course-btn .plus-icon { font-size: 36px; }

.course-actions-group {
  position: absolute; bottom: 20px; left: 25px; right: 25px;
  display: flex; flex-direction: row; gap: 15px; z-index: 5;
}
.course-edit-btn {
  flex: 1; background: #ff9800; color: white; border: none;
  padding: 10px 0; border-radius: 6px; cursor: pointer; font-size: 14px;
  white-space: nowrap; transition: background 0.2s;
}
.course-edit-btn:hover { background: #f57c00; }

.course-del-btn {
  flex: 1; background: #f44336; color: white; border: none;
  padding: 10px 0; border-radius: 6px; cursor: pointer; font-size: 14px;
  white-space: nowrap; transition: background 0.2s;
}
.course-del-btn:hover { background: #d32f2f; }

.resource-section { border-top: 1px dashed #e0e0e0; padding-top: 15px; margin-top: 15px; }
.resource-title { font-size: 14px; font-weight: bold; color: #333; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.add-res-btn { font-size: 12px; background: #e3f2fd; color: #1976d2; border: 1px solid #90caf9; padding: 4px 10px; border-radius: 12px; cursor: pointer; }
.resource-list { display: flex; flex-direction: column; gap: 8px; }
.res-item { display: flex; align-items: center; gap: 10px; background: #f8f9fa; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.res-icon { font-size: 18px; }
.res-link { color: #1976d2; text-decoration: none; flex: 1; word-break: break-all; cursor: pointer; }
.res-link:hover { text-decoration: underline; }
.del-res-btn { color: #f44336; cursor: pointer; font-size: 12px; display: none; margin-left: 10px; }
.rename-res-btn { color: #1976d2; cursor: pointer; font-size: 12px; display: none; margin-left: 10px; font-weight: bold; }
.teacher-mode .del-res-btn, .teacher-mode .rename-res-btn { display: block; }

.inline-form { display: none; background: #fffde7; padding: 15px; border-radius: 8px; margin-top: 10px; border: 1px solid #fff59d; }
.inline-form.active { display: block; }
.inline-form input, .inline-form select { padding: 8px; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 8px; width: 100%; font-size: 13px; }
.inline-form .form-actions { display: flex; gap: 10px; }

.res-tab-bar { display: flex; gap: 0; margin-bottom: 12px; }
.res-tab { flex: 1; padding: 8px; text-align: center; font-size: 13px; cursor: pointer; border: 1px solid #ccc; background: #f5f5f5; color: #666; transition: all 0.2s; }
.res-tab:first-child { border-radius: 6px 0 0 6px; }
.res-tab:last-child { border-radius: 0 6px 6px 0; }
.res-tab.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.res-tab-panel { display: none; }
.res-tab-panel.active { display: block; }
.file-upload-area {
  border: 2px dashed #ccc; border-radius: 8px; padding: 20px; text-align: center;
  cursor: pointer; transition: all 0.3s; margin-bottom: 8px; position: relative;
  color: #999; font-size: 13px;
}
.file-upload-area:hover { border-color: var(--primary-color); background: #f8f9ff; }
.file-upload-area input[type="file"] { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-upload-area.has-file { border-color: #4caf50; background: #e8f5e9; color: #2e7d32; }

.qa-container { background: var(--card-bg); border-radius: 16px; padding: 30px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.qa-input-area { display: flex; gap: 10px; margin-bottom: 20px; }
.qa-input-area input { flex: 1; padding: 12px 18px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 14px; outline: none; }
.qa-input-area button { padding: 12px 24px; background: var(--primary-color); color: white; border: none; border-radius: 10px; cursor: pointer; }
.qa-list { display: flex; flex-direction: column; gap: 15px; }
.qa-item { padding: 20px; background: #f8f9ff; border-radius: 10px; border-left: 3px solid var(--primary-color); position: relative; }

.qa-question {
  font-size: 15px; color: #333; font-weight: 500; margin-bottom: 10px;
  max-height: 150px; overflow-y: auto; word-break: break-word;
}
.qa-meta { font-size: 12px; color: #999; margin-bottom: 10px; }
.qa-answer {
  background: #e8eaf6; padding: 12px; border-radius: 8px; font-size: 14px; color: #333; margin-top: 10px; border-left: 3px solid #3f51b5;
  max-height: 200px; overflow-y: auto; word-break: break-word;
}
.qa-answer-label { font-weight: bold; color: var(--primary-color); margin-right: 5px; }
.reply-area { margin-top: 10px; display: none; }
.reply-area.active { display: block; }
.reply-textarea { width: 100%; min-height: 60px; padding: 10px; border: 1px solid #c5cae9; border-radius: 6px; font-family: inherit; font-size: 13px; margin-bottom: 8px; }
.reply-btns { display: flex; gap: 10px; }
.reply-btns button { padding: 6px 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }

.del-qa-btn {
  position: absolute; top: 10px; right: 10px;
  background: #ffebee; color: #c62828; border: 1px solid #ffcdd2;
  padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px;
  display: none; transition: all 0.2s;
}
.del-qa-btn:hover { background: #ef9a9a; color: white; }
.teacher-mode .del-qa-btn { display: block; }

/* 问答置顶按钮 */
.pin-qa-btn {
  position: absolute; top: 10px; right: 100px;
  background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9;
  padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px;
  display: none; transition: all 0.2s;
}
.pin-qa-btn:hover { background: #bbdefb; }
.teacher-mode .pin-qa-btn { display: block; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.book-card {
  background: var(--card-bg); border-radius: 12px; padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  padding-bottom: 70px;
  border: 2px solid transparent;
}
.book-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }

.book-card.dragging { opacity: 0.5; border: 2px dashed var(--primary-color); }
.book-card.drag-over { transform: scale(1.02); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }

.drag-handle-book {
  position: absolute; top: 10px; right: 10px; left: auto; cursor: grab; color: #999; font-size: 16px;
  padding: 5px; display: none; z-index: 10; background: rgba(255,255,255,0.8); border-radius: 4px;
}
.drag-handle-book:active { cursor: grabbing; }
.teacher-mode .drag-handle-book { display: block; }

.book-cover {
  width: auto; height: 200px; aspect-ratio: 210 / 297;
  background: #f0f2f5; border-radius: 8px; margin: 26px auto 15px auto;
  display: flex; align-items: center; justify-content: center;
  color: #999; font-size: 40px; overflow: hidden; position: relative;
}
.book-cover img { width: 100%; height: 100%; object-fit: contain; }
.book-info h4 { font-size: 16px; color: var(--primary-color); margin-bottom: 5px; line-height: 1.4; }
.book-author { font-size: 13px; color: #666; margin-bottom: 8px; }
.book-desc { font-size: 13px; color: #888; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.book-actions-bottom {
  position: absolute; bottom: 15px; left: 20px; right: 20px;
  display: flex; gap: 10px; z-index: 5;
}
.book-action-btn-bottom {
  flex: 1; padding: 8px 0; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: white;
  transition: background 0.2s; display: none;
  align-items: center; justify-content: center;
}
.teacher-mode .book-action-btn-bottom { display: flex; }

.btn-edit-book-bottom { background: #ff9800; }
.btn-edit-book-bottom:hover { background: #f57c00; }

.btn-del-book-bottom { background: #f44336; }
.btn-del-book-bottom:hover { background: #d32f2f; }

.add-book-btn {
  background: var(--card-bg); border: 2px dashed var(--primary-color); border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--primary-color); font-size: 16px; cursor: pointer; transition: all 0.3s; min-height: 280px;
}
.add-book-btn:hover { background: #e8eaf6; }

/* 推荐书目子模块的本地资料清单（三端可查看，教师/管理员可上传、重命名、删除） */
.book-cover.clickable { cursor: pointer; }
.book-cover.clickable:hover { box-shadow: 0 0 0 2px var(--primary-color) inset; }
/* 「N 份资料」角标：从封面内部（会压住上传的封面）移到卡片右上角，
   落点在 .book-cover 上方让出的那条 26px 空档里，三端位置一致。 */
.book-material-badge {
  position: absolute; right: 16px; top: 14px; z-index: 4;
  background: rgba(26, 35, 126, 0.85); color: #fff;
  font-size: 11px; line-height: 1; padding: 5px 8px; border-radius: 999px;
  cursor: pointer;
}
.book-material-badge:hover { background: rgba(26, 35, 126, 1); }
/* 教师端/管理员端右上角有拖动手柄（top:10 right:10），角标让开它，两者并排不重叠 */
.teacher-mode .book-material-badge { right: 44px; }
/* 新增：编辑里填了网址后，封面上给一枚链接角标，卡片信息区再给一个可点的「访问链接」 */
.book-link-badge {
  position: absolute; left: 6px; top: 6px; z-index: 3;
  background: rgba(255, 152, 0, 0.9); color: #fff;
  font-size: 11px; line-height: 1; padding: 5px 8px; border-radius: 999px;
  pointer-events: none;
}
.book-site-link {
  display: inline-block; margin-top: 8px; font-size: 12px; color: #1565c0;
  background: #e3f2fd; border: 1px solid #90caf9; border-radius: 999px;
  padding: 4px 12px; cursor: pointer; transition: all 0.2s;
}
.book-site-link:hover { background: #bbdefb; }
.book-files { margin: 0 0 10px; }
.book-files-title { font-size: 13px; color: #666; font-weight: 600; margin-bottom: 6px; }
.book-file-empty { font-size: 12px; color: #999; }
.book-file-chip {
  display: flex; align-items: center; gap: 6px;
  background: #f8f9fa; border: 1px solid #eef0f5; border-radius: 8px;
  padding: 6px 8px; font-size: 12px; margin-bottom: 6px;
}
.book-file-icon { font-size: 16px; flex: none; }
.book-file-name { flex: 1; color: #1976d2; cursor: pointer; word-break: break-all; }
.book-file-name:hover { text-decoration: underline; }
.book-file-name.static { color: #333; cursor: default; }
.book-file-name.static:hover { text-decoration: none; }
.book-file-size { color: #999; white-space: nowrap; flex: none; }
.book-file-btn {
  flex: none; font-size: 11px; padding: 3px 7px; border-radius: 4px; cursor: pointer;
  transition: all 0.2s;
}
.rename-book-file-btn { background: #e3f2fd; color: #1565c0; }
.rename-book-file-btn:hover { background: #bbdefb; }
.del-book-file-btn { background: #ffebee; color: #c62828; }
.del-book-file-btn:hover { background: #ffcdd2; }
.add-book-file-btn {
  width: 100%; margin-top: 2px; padding: 7px 0; font-size: 12px;
  background: #f5f6fa; color: var(--primary-color);
  border: 1px dashed var(--primary-color); border-radius: 6px; cursor: pointer;
  transition: background 0.2s;
}
.add-book-file-btn:hover { background: #e8eaf6; }
.book-file-input { display: none; }

/* 编辑弹窗里的多选上传暂存区 */
.book-files-hint { font-size: 12px; color: #999; line-height: 1.7; margin: 6px 0 0; text-align: left; }
.book-files-staged { margin-top: 8px; }
.book-file-chip.staged { background: #fffde7; border-color: #fff59d; }
.book-file-drop {
  flex: none; width: 20px; height: 20px; line-height: 1; padding: 0;
  border: none; border-radius: 4px; background: #ffebee; color: #c62828; cursor: pointer; font-size: 12px;
}
.book-file-drop:hover { background: #ffcdd2; }

/* 点封面后弹出的资料清单（多个文件时选一条打开） */
.book-files-list { max-height: 320px; overflow-y: auto; }
.book-file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  background: #fafbff; border: 1px solid #e0e0e0; border-radius: 8px; cursor: pointer;
  transition: all 0.2s;
}
.book-file-row:hover { border-color: var(--primary-color); background: #e8eaf6; }
.book-file-row .book-file-icon { font-size: 20px; }
.book-file-row .book-file-name { font-size: 14px; }
.book-file-open-tag { flex: none; font-size: 12px; color: var(--primary-color); }

/* 生活中的材科基 / 视野拓展 模块 */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.media-card {
  background: var(--card-bg); border-radius: 12px; padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06); position: relative;
  transition: transform 0.2s, box-shadow 0.2s; padding-bottom: 70px;
  border: 2px solid transparent;
}
.media-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.media-card.dragging { opacity: 0.5; border: 2px dashed var(--primary-color); }
.media-card.drag-over { transform: scale(1.02); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }

.drag-handle-media {
  position: absolute; top: 10px; right: 10px; left: auto; cursor: grab; color: #999; font-size: 16px;
  padding: 5px; display: none; z-index: 10; background: rgba(255,255,255,0.8); border-radius: 4px;
}
.drag-handle-media:active { cursor: grabbing; }
.teacher-mode .drag-handle-media { display: block; }

.media-preview {
  width: 100%; height: 180px; background: #f0f2f5; border-radius: 8px;
  margin-bottom: 15px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: contain; }
.media-link-box {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--primary-color); text-decoration: none; font-size: 15px;
  padding: 20px; text-align: center; word-break: break-all;
}
.media-link-box:hover { text-decoration: underline; }
.media-link-icon { font-size: 40px; }

.media-info h4 { font-size: 16px; color: var(--primary-color); margin-bottom: 5px; line-height: 1.4; word-break: break-word; }
.media-desc { font-size: 13px; color: #888; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }

.media-actions-bottom {
  position: absolute; bottom: 15px; left: 20px; right: 20px;
  display: flex; gap: 10px; z-index: 5;
}
.media-action-btn-bottom {
  flex: 1; padding: 8px 0; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: white;
  transition: background 0.2s; display: none;
  align-items: center; justify-content: center;
}
.teacher-mode .media-action-btn-bottom { display: flex; }
.btn-edit-media-bottom { background: #ff9800; }
.btn-edit-media-bottom:hover { background: #f57c00; }
.btn-del-media-bottom { background: #f44336; }
.btn-del-media-bottom:hover { background: #d32f2f; }

.add-media-btn {
  background: var(--card-bg); border: 2px dashed var(--primary-color); border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--primary-color); font-size: 16px; cursor: pointer; transition: all 0.3s; min-height: 200px;
}
.add-media-btn:hover { background: #e8eaf6; }

/* 新增：视野拓展子模块的封面（管理员端/教师端在「编辑」里设置，三端点击封面打开链接或资料） */
.media-preview.media-cover { cursor: pointer; background: #eef1f6; }
.media-preview.media-cover:hover { box-shadow: 0 0 0 2px var(--primary-color) inset; }
.media-preview.media-cover img { width: 100%; height: 100%; object-fit: cover; }
.media-cover-badge {
  position: absolute; left: 8px; bottom: 8px; z-index: 3;
  background: rgba(26, 35, 126, 0.85); color: #fff;
  font-size: 11px; line-height: 1; padding: 5px 9px; border-radius: 999px;
  pointer-events: none;
}
/* 编辑弹窗里的封面选择区：左侧缩略图，右侧上传与 URL */
.media-cover-picker { display: flex; gap: 12px; align-items: flex-start; }
.media-cover-thumb {
  width: 110px; height: 154px; flex: none; border-radius: 8px; overflow: hidden;
  background: #f0f2f5; border: 1px dashed #c5cae9;
  display: flex; align-items: center; justify-content: center; color: #999; font-size: 12px;
}
.media-cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-cover-thumb-empty { padding: 0 6px; text-align: center; }
.media-cover-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.media-cover-side .file-upload-area { margin-bottom: 0; }
.media-cover-side input[type="text"] { padding: 9px 10px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 13px; outline: none; width: 100%; }
.media-cover-side input[type="text"]:focus { border-color: var(--primary-color); }
/* 「移除封面」这一行：.modal-box label{display:block} 与 .modal-box input{width:100%}
   比 .checkbox-line 更具体，会把选框撑成整行、文字掉到下一行。
   这里用同级双类选择器盖回去，让选框回到文字前面、两者同一行。 */
.modal-box .checkbox-line { display: flex; align-items: center; gap: 6px; }
.modal-box .checkbox-line input[type="checkbox"] {
  width: 15px; height: 15px; flex: none; margin: 0; padding: 0; border: none;
  border-radius: 0; accent-color: var(--primary-color); cursor: pointer;
}
.cover-clear-line { margin-top: 8px; font-size: 13px; color: #555; }

.more-card {
  background: #f8f9fa; border: 2px dashed #ccc; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 280px; cursor: pointer; transition: all 0.3s; color: #666;
}
.more-card:hover { background: #e8eaf6; border-color: var(--primary-color); color: var(--primary-color); }
.more-icon { font-size: 40px; margin-bottom: 10px; }
.more-text { font-size: 16px; font-weight: bold; }

/* 「生活中的材科基」「视野拓展」「推荐书目及资料」手动展开后，网格最后一行的整行「收起」按钮：
   点一下把该模块恢复成显示前 5 个子模块的折叠态。「查看更多」卡片、内容卡片与教师端
   添加按钮的样式规则一字未改；按钮只读本地渲染状态，不参与数据与云端同步。 */
.fold-bar { grid-column: 1 / -1; display: flex; justify-content: center; }
.fold-btn {
  background: #f8f9fa; border: 2px dashed #ccc; border-radius: 12px; padding: 10px 26px;
  color: #666; cursor: pointer; transition: all 0.3s; text-align: center;
  font-family: inherit; font-size: 15px; font-weight: bold; line-height: 1.5;
}
.fold-btn:hover { background: #e8eaf6; border-color: var(--primary-color); color: var(--primary-color); }
.fold-hint { font-weight: normal; font-size: 13px; }

.status-bar {
  background: #e8f5e9; color: #2e7d32; padding: 8px; text-align: center; font-size: 13px;
  border-bottom: 1px solid #c8e6c9; display: none; position: fixed; top: calc(var(--nav-height-top) + var(--nav-height-bottom)); width: 100%; z-index: 999;
}
.status-bar.error { background: #ffebee; color: #c62828; border-color: #ffcdd2; }

.footer { background: var(--primary-color); color: rgba(255,255,255,0.7); text-align: center; padding: 30px; font-size: 14px; margin-top: 50px; }

/* 新增：页面右侧的「回到顶部」。按钮在 #course-view 里，未登录时整块 display:none，天然不出现。
   隐藏态用 opacity:0 + visibility:hidden + pointer-events:none：既不占视线也点不到，
   出现/收起只由 app.js 切一个 .show 类，不改布局、不发请求。
   bottom 抬到 80px 是给右下角那条「文件预览」最小化条让位（right:20px + bottom:20px，高约 44px），
   两者同在右侧上下错开、互不遮挡；z-index 1200 高于固定导航(1000)，低于任何弹窗遮罩(5000+)，
   弹窗打开时按钮自然被压在遮罩下面，不会浮在弹窗上。 */
.back-to-top {
  position: fixed; right: 20px; bottom: 80px; z-index: 1200;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 48px; height: 48px; padding: 0 14px;
  border: none; border-radius: 24px; cursor: pointer;
  background: var(--primary-gradient); color: #fff;
  font-family: inherit; font-size: 14px; line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  opacity: 0; visibility: hidden; transform: translateY(10px); pointer-events: none;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s, box-shadow 0.3s;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.back-to-top:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.3); }
.back-to-top .btt-arrow { font-size: 18px; }
@media (max-width: 768px) {
  /* 窄屏只留箭头，收成见方按钮并贴右边，避免压住卡片内容 */
  .back-to-top { right: 12px; bottom: 76px; min-width: 42px; height: 42px; padding: 0; border-radius: 50%; }
  .back-to-top .btt-label { display: none; }
}
@media print {
  .back-to-top { display: none !important; }
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-success { background: #4caf50; color: white; }
.btn-cancel { background: #9e9e9e; color: white; }

.preview-modal-content {
  position: fixed; top: 15%; left: 50%; transform: translateX(-50%);
  width: 80%; max-width: 900px; height: 70vh;
  background: white; border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3); z-index: 6000;
  transition: all 0.2s ease;
}
.preview-modal-content.maximized {
  top: 0; left: 0; width: 100%; height: 100%; max-width: 100%; border-radius: 0; transform: none;
}
.preview-header {
  padding: 12px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center;
  background: #f8f9fa; user-select: none;
}
.preview-header h3 { margin: 0; font-size: 16px; color: var(--primary-color); }
.preview-controls { display: flex; gap: 8px; }
.preview-ctrl-btn {
  background: transparent; border: none; color: #666; font-size: 16px; cursor: pointer;
  width: 30px; height: 30px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.preview-ctrl-btn:hover { background: #e0e0e0; }
.preview-ctrl-btn.close-btn:hover { background: #f44336; color: white; }

.preview-body {
  flex: 1; overflow: auto; padding: 20px; display: flex; justify-content: center; align-items: center; background: #333;
  position: relative;
}
.preview-footer {
  padding: 15px 20px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 10px; background: white;
}

.preview-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-pdf { width: 100%; height: 100%; border: none; }
.preview-video { max-width: 100%; max-height: 100%; }
.preview-fallback { text-align: center; color: white; padding: 40px; }
.preview-fallback p { margin-bottom: 20px; font-size: 16px; }

.close-preview-btn {
  background: var(--primary-color); color: white; border: none; padding: 8px 20px;
  border-radius: 20px; cursor: pointer;
}
.download-btn {
  background: #4caf50; color: white; border: none; padding: 8px 20px;
  border-radius: 20px; cursor: pointer; text-decoration: none; display: inline-block;
}
/* 学生端保留下载按钮但不给文件：置灰 + 禁用态外观，点击只提示 */
.download-btn.locked {
  background: #b0bec5; color: #eceff1; cursor: not-allowed; box-shadow: none;
}
/* 学生端（take-restricted）打印时收起预览窗，避免正在预览的资料被整页打印出去。
   教师端与管理员端没有这个类，打印行为完全不变。 */
@media print {
  body.take-restricted #previewModal,
  body.take-restricted #previewMinimizedBar { display: none !important; }
}

@media (max-width: 768px) {
  .teacher-card { flex-direction: column; align-items: center; text-align: center; }
  .course-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 28px; }
  .hero { margin-top: calc(var(--nav-height-top) + var(--nav-height-bottom)); }
  .modal-box { margin: 20px; }
  .preview-modal-content { width: 95%; height: 80vh; top: 10%; }
  .preview-modal-content.maximized { width: 100%; height: 100%; top: 0; }
  .course-item { padding-right: 25px; padding-bottom: 80px; }
  .course-actions-group { bottom: 15px; left: 15px; right: 15px; gap: 10px; }
  .book-card { padding-bottom: 70px; }

  .navbar { padding: 0 15px; }
  .nav-top { height: 50px; }
  .nav-bottom { height: 36px; }
  .nav-logo { font-size: 20px; }
  .nav-logo span { font-size: 18px; }
  .nav-links { gap: 10px; }
  .nav-links a { font-size: 14px; padding: 4px 10px; }
  .user-info { font-size: 11px; gap: 5px; }
  .role-badge, .logout-btn, .export-btn, .sync-btn, .stats-btn, .settings-btn { font-size: 10px; padding: 2px 6px; }

  /* 移动端适配 Hero 内容框 */
  .hero-content-wrapper {
    padding: 20px 30px;
    width: 95%;
  }

  /* 模块浏览点击量在手机/平板上也与模块名称同一行、下对齐。计数与名称同字号那一版，
     这一行最长的一条是「📚 推荐书目及资料」+「本模块的浏览点击量：99999次」——原位实测 22.65em
     （模块名称是 h2 的粗体，比常规字重的同串文字宽 0.15em，所以不能用普通文本量）。
     一行放不下就只能让名称与计数按屏宽一起缩放，4.2vw-3.3px 由 22.65em 反解：flex 行活在小标题里，
     可用宽度 = 视口 - 40(main-content 内边距) - 4(左边框) - 15(左内边距) = 视口-59，
     于是字号 ≤ (视口-59-行间距)/22.65，取 4.2vw-3.3px；640px 以上封顶 24px，375px 收到 12.5px，320px 收到 10.1px。
     第十二轮把小字收成 0.7em 之后，这条 clamp 一个数字没改，是刻意的：
     小字是相对标题的 em，收标题等于连小字一起收，「缩小为现在的 0.7 倍」才在每个断点上都正好成立
     （若顺手放宽 clamp 去补回腾出来的宽度，名称会变大、小字就不再是 0.7 倍了）。
     放宽之后这一行的实测需求只剩 19.43em（五位）~20.29em（七位），比原来的 22.65em 更宽松，
     单行更有保证；实测见 app.js 末尾「第十二轮」。
     第十三轮（小字再收 0.9 倍、数字放大到小字的 1.3 倍）这条 clamp 还是一个数字没改：小字仍是标题的
     固定 em 比例，0.9 倍在每个断点上都正好成立。同一探针复量：整行最紧的一档是 300px 视口 + 七位计数，
     实测需 194.3px、可用 241px，余量 46.7px（上一版 44.1px，数字放大后反而更宽松）；
     16 档视口（300/317/320/360/375/390/414/480/600/640/768/769/900/1024/1200/1440）× 五个模块
     × 1/3/5/6/7 位计数，名称一律没被压成两行、整行无横向溢出。 */
  .section-title { font-size: clamp(10px, calc(4.2vw - 3.3px), 24px); }
}

@media (max-width: 480px) {
  .section-title { gap: 6px; }
}

/* 380px 以下再让出 2px 行间距：字号继续按 4.2vw-3.3px 缩放（360px 时 11.8px、320px 时 10.1px），
   保证这两条最长的模块名连六位计数也不把名称压成两行。 */
@media (max-width: 380px) {
  .section-title { gap: 4px; }
}
