/* ============ 全局 ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #222;
  background: #f4f6f5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
img, video, input, select, textarea { max-width: 100%; }
a { color: #1f9d55; text-decoration: none; }
.btn {
  display: inline-block; border: 1px solid #d0d6d3; background: #fff; color: #333;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1.2;
}
.btn-primary { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-primary:hover { background: #178045; }
.btn-danger { color: #c0392b; border-color: #e6b3ac; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ============ 前台（移动端优先）============ */
.front-body { background: #f4f6f5; padding-bottom: 40px; }
.front-header {
  background: linear-gradient(135deg, #1f9d55, #2bbf6e);
  color: #fff; padding: 26px 18px 22px; border-radius: 0 0 18px 18px;
}
.front-title { margin: 0; font-size: 22px; }
.front-sub { margin: 6px 0 0; font-size: 13px; opacity: .9; }

.chapter-list { padding: 14px 12px; display: flex; flex-direction: column; gap: 12px; }
.chapter-card {
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.chapter-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 16px 14px; background: none; border: 0; cursor: pointer; text-align: left;
}
.chapter-name { font-size: 16px; font-weight: 600; color: #1f2d27; }
.chapter-meta { display: flex; align-items: center; gap: 10px; }
.lesson-count { font-size: 13px; color: #1f9d55; background: #e7f6ec; padding: 3px 10px; border-radius: 20px; }
.arrow { color: #9aa5a0; transition: transform .2s; }
.chapter-card.open .arrow { transform: rotate(180deg); }

.chapter-body { display: none; border-top: 1px solid #eef2f0; }
.chapter-card.open .chapter-body { display: block; }

.lesson-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border-bottom: 1px solid #f2f5f3;
}
.lesson-row:last-child { border-bottom: 0; }
.lesson-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; padding-right: 10px; }
.lesson-no { font-size: 12px; color: #1f9d55; }
.lesson-title { font-size: 15px; color: #222; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-dur { font-size: 12px; color: #8a948f; }
.btn-watch {
  background: #1f9d55; color: #fff; border: 0; border-radius: 20px;
  padding: 7px 18px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn-watch:hover { background: #178045; }
.empty-tip { padding: 18px 14px; color: #9aa5a0; font-size: 14px; text-align: center; }

/* 课程头图 */
.course-hero {
  position: relative; color: #fff; overflow: hidden;
  border-radius: 0 0 18px 18px; min-height: 150px;
  display: flex; align-items: flex-end;
}
.course-hero.hero-plain {
  background: linear-gradient(135deg, #1f9d55, #2bbf6e);
}
.hero-bg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
}
.course-hero .hero-inner {
  position: relative; z-index: 1; padding: 22px 18px; width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0));
}
.hero-title { margin: 0 0 6px; font-size: 22px; }
.hero-desc { margin: 0 0 8px; font-size: 13px; opacity: .92; line-height: 1.5; }
.hero-stat { margin: 0; font-size: 13px; opacity: .9; }

/* 工具栏 / 搜索 */
.front-toolbar { padding: 12px 12px 0; }
.search-box { display: flex; gap: 8px; align-items: center; }
.search-box input {
  flex: 1; border: 1px solid #d8e2dc; border-radius: 20px; padding: 10px 16px; background: #fff;
}
.search-box button {
  border: 0; background: #1f9d55; color: #fff; border-radius: 18px; padding: 8px 14px; cursor: pointer;
}

/* 最近观看 */
.recent-card {
  margin: 12px; background: #fff; border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  border-left: 4px solid #1f9d55;
}
.recent-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-label { font-size: 12px; color: #1f9d55; }
.recent-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-pos { font-size: 12px; color: #8a948f; }

/* 封面缩略图 */
.lesson-thumb {
  width: 60px; height: 42px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: #e7f0ea;
}

/* 搜索结果 */
.search-results { margin: 0 12px; }
.search-count { font-size: 13px; color: #7a8580; padding: 6px 2px; }

/* 页脚 */
.front-footer { text-align: center; color: #9aa5a0; font-size: 12px; padding: 24px 12px 30px; }

/* 课时行操作区 + 已学标签 */
.lesson-ops { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.btn-share {
  background: #fff; color: #1f9d55; border: 1px solid #bfe3cd; border-radius: 16px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.btn-done {
  background: #f1f5f2; color: #5a6b62; border: 1px solid #dde5e0; border-radius: 16px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.done-tag {
  display: inline-block; background: #1f9d55; color: #fff; font-size: 11px;
  border-radius: 10px; padding: 1px 7px; margin-left: 6px; vertical-align: middle;
}
@media (max-width: 380px) {
  .btn-share, .btn-done { padding: 5px 8px; font-size: 12px; }
}

/* 控制栏（深色） */
.player-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #161616;
}
.pbtn {
  background: #222; color: #fff; border: 1px solid #333; border-radius: 16px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.pbtn:active { background: #1f9d55; }
.pselect {
  background: #222; color: #fff; border: 1px solid #333; border-radius: 8px;
  padding: 6px 8px; font-size: 13px; width: auto;
}
.ptime { margin-left: auto; color: #bbb; font-size: 13px; }

.modal-desc {
  background: #1d1d1d; color: #d8e0db; font-size: 13px; line-height: 1.6;
  padding: 12px 14px; max-height: 30vh; overflow-y: auto; white-space: pre-wrap;
}
.modal-tip { background: #161616; color: #8a948f; font-size: 12px; padding: 10px 14px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; z-index: 200;
}

/* 上传进度条 */
.upload-progress { margin-bottom: 12px; }
.up-bar-track { background: #e6ece9; border-radius: 8px; height: 10px; overflow: hidden; }
.up-bar { background: #1f9d55; height: 100%; width: 0; transition: width .2s; }
.up-text { font-size: 13px; color: #55605a; margin-top: 6px; }

/* 拖拽排序 */
tr.dragging { opacity: .5; background: #e7f6ec; }
.data-table tbody tr { cursor: grab; }
.data-table tbody tr:active { cursor: grabbing; }

/* 分页 */
.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; }

/* ============ 模态框 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
/* 关键：让 hidden 属性真正隐藏（author 的 display:flex 会覆盖 UA 的 [hidden] 规则） */
.modal-mask[hidden] { display: none !important; }
.modal-box {
  background: #111; width: 100%; max-width: 560px; border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column; max-height: 92vh;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: #161616;
}
.modal-title { color: #fff; font-size: 15px; flex: 1; padding-right: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close {
  background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.modal-video-wrap { background: #000; padding: 0; }
.modal-video-wrap video { width: 100%; max-height: 70vh; display: block; background: #000; }

/* ============ 后台 ============ */
.admin-body { background: #f4f6f5; min-height: 100vh; }
.admin-top {
  background: #1f9d55; color: #fff; padding: 12px 16px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
}
.admin-brand { font-weight: 700; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 14px; }
.admin-nav a { color: #eafff3; font-size: 14px; }
.admin-main { max-width: 960px; margin: 0 auto; padding: 18px 14px 50px; }
.page-title { font-size: 20px; margin: 6px 0 16px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash-ok { background: #e7f6ec; color: #176b3a; border: 1px solid #b6e2c6; }
.flash-err { background: #fdeceb; color: #b23a30; border: 1px solid #f3bcb6; }

.stat-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-card {
  flex: 1; min-width: 140px; background: #fff; border-radius: 12px; padding: 18px;
  text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.stat-num { font-size: 28px; font-weight: 700; color: #1f9d55; }
.stat-label { font-size: 13px; color: #7a8580; margin-top: 4px; }
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; }

.panel { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.panel-title { font-size: 16px; margin: 0 0 12px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-row input[type=text], .form-row input[type=number] { flex: 1; min-width: 140px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
.form-stack label, .form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #55605a; }
input, select, textarea {
  padding: 9px 10px; border: 1px solid #d4dbd7; border-radius: 8px; font-size: 14px; width: 100%;
  background: #fff;
}
textarea { font-family: inherit; }
.hint { color: #8a948f; font-size: 12px; }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.data-table th, .data-table td { padding: 11px 12px; border-bottom: 1px solid #eef2f0; text-align: left; font-size: 14px; }
.data-table th { background: #f7faf8; color: #55605a; font-weight: 600; }
.data-table .ops { display: flex; gap: 8px; align-items: center; }
.data-table .ops form { margin: 0; }
.empty { text-align: center; color: #9aa5a0; padding: 20px; }

.filter-bar { background: #fff; padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; display: inline-block; }
.filter-bar select { width: auto; }

/* ============ 登录页 ============ */
.login-body {
  background: linear-gradient(135deg, #1f9d55, #2bbf6e); min-height: 100vh;
  display: block; padding: 16px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 28px 24px; width: auto; max-width: 360px;
  margin: 40px auto 0; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.login-title { margin: 0 0 4px; font-size: 20px; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #55605a; }
