:root {
  --bg: #0e0f12;
  --bg-soft: #16181d;
  --bg-card: #1a1c22;
  --line: #262931;
  --text: #e8e9ec;
  --text-dim: #8b8f99;
  --brand: #3b7bfa;
  --brand-dim: #2a5bc4;
  --warn: #d99427;
  --danger: #e05454;
  --ok: #33b074;
  --radius: 10px;
}

* { 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;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 60px; }

/* ---------- 顶栏 ---------- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; border-bottom: 1px solid var(--line); margin-bottom: 24px;
  position: sticky; top: 0; background: rgba(14,15,18,.92);
  backdrop-filter: blur(8px); z-index: 50;
}
.nav .logo { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.nav .logo span { color: var(--brand); }
.nav-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.nav-right .who { color: var(--text-dim); }

/* ---------- 通用 ---------- */
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.sub { color: var(--text-dim); font-size: 13px; margin: 0 0 24px; }
.muted { color: var(--text-dim); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: .15s; font-family: inherit;
}
.btn:hover { background: var(--brand-dim); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--bg-card); }
.btn.danger { background: transparent; border-color: #4a2a2a; color: var(--danger); }
.btn.danger:hover { background: #2a1616; }
.btn.sm { padding: 5px 11px; font-size: 13px; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: 14px; font-family: inherit; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  font-size: 12px; background: #232630; color: var(--text-dim);
}
.tag.ok { background: rgba(51,176,116,.14); color: var(--ok); }
.tag.warn { background: rgba(217,148,39,.14); color: var(--warn); }
.tag.blue { background: rgba(59,123,250,.14); color: var(--brand); }

/* ---------- 课程卡片 ---------- */
.course-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.course-card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: .18s; cursor: pointer; display: block; color: inherit;
}
.course-card:hover { border-color: #374050; transform: translateY(-2px); text-decoration: none; }
.course-cover {
  aspect-ratio: 16/9; background: linear-gradient(135deg, #1f2430, #14171d);
  display: flex; align-items: center; justify-content: center;
  color: #3a4150; font-size: 13px; overflow: hidden;
}
.course-cover img { width: 100%; height: 100%; object-fit: cover; }
.course-body { padding: 14px 16px 16px; }
.course-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.course-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); }
.price { color: #ffa23e; font-weight: 600; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-dim); }

/* ---------- 播放页 ---------- */
.player-box {
  position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16/9; border: 1px solid var(--line);
}
.player-box video { width: 100%; height: 100%; display: block; }

.wm-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.wm-item {
  position: absolute; white-space: nowrap; font-size: 12px; letter-spacing: .5px;
  color: rgba(255,255,255,.17); text-shadow: 0 0 3px rgba(0,0,0,.6);
  user-select: none; transition: top .9s linear, left .9s linear;
}

.lesson-list { margin-top: 22px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lesson-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: .12s;
}
.lesson-item:last-child { border-bottom: none; }
.lesson-item:hover { background: var(--bg-soft); }
.lesson-item.active { background: rgba(59,123,250,.10); border-left: 2px solid var(--brand); }
.lesson-item.locked { cursor: not-allowed; color: var(--text-dim); }
.lesson-item.locked:hover { background: transparent; }
.lesson-idx { width: 26px; color: var(--text-dim); font-size: 13px; flex: none; }
.lesson-name { flex: 1; }
.lesson-dur { font-size: 12px; color: var(--text-dim); flex: none; }

.lock-note {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 40px 20px; color: var(--text-dim); text-align: center; flex-direction: column;
}

/* ---------- 管理后台 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; flex-wrap: wrap; }
.tab {
  padding: 10px 18px; cursor: pointer; font-size: 14px; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:hover { background: var(--bg-soft); }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 32px;
  text-align: center; color: var(--text-dim); cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: rgba(59,123,250,.05); color: var(--text); }

.progress-bar { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress-bar > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: #22252d; border: 1px solid var(--line); color: var(--text);
  padding: 11px 20px; border-radius: 8px; font-size: 14px; opacity: 0;
  transition: .25s; pointer-events: none; z-index: 999; max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: #5a2a2a; }
.toast.ok { border-color: #26513f; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .row { flex-direction: column; gap: 0; }
  .stat .n { font-size: 22px; }
  table { font-size: 13px; }
  th, td { padding: 9px 8px; }
}
