/* ============================================================
   课程学习平台 · 移动优先样式（零依赖，不引外网字体/图标）
   ============================================================ */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --line: #e6e9f0;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --ok: #12b76a;
  --danger: #f04438;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; font-weight: 600; }

.page {
  max-width: 900px; margin: 0 auto;
  padding: 58px 14px calc(var(--tabbar-h) + var(--safe-b) + 84px);
}

/* ---------------------------------------------------------- 顶栏 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff; font-size: 12px; font-weight: 700;
}
.brand-text { font-size: 15px; }
.hamburger {
  width: 40px; height: 40px; border: 0; background: transparent;
  display: grid; gap: 5px; place-content: center; cursor: pointer;
}
.hamburger span { display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: .2s; }
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------------------------------------------------------- 抽屉菜单 */
.drawer {
  position: fixed; top: 0; right: 0; z-index: 60;
  width: min(80vw, 300px); height: 100%;
  background: var(--surface); box-shadow: var(--shadow-lg);
  padding: 18px 14px; transform: translateX(102%);
  transition: transform .25s ease; overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 14px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}
.drawer-name { font-weight: 600; }
.drawer-phone { color: var(--ink-3); font-size: 12px; }
.drawer-item { display: block; padding: 12px 6px; border-radius: var(--radius-sm); font-size: 15px; }
.drawer-item:active { background: var(--bg); }
.drawer-sep { height: 1px; background: var(--line); margin: 8px 0; }
.drawer-primary { color: var(--brand); font-weight: 600; }
.drawer-admin { color: #7c3aed; }
.drawer-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(16,24,40,.4);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.avatar-lg { width: 54px; height: 54px; font-size: 20px; }
.avatar-img { object-fit: cover; }

/* ---------------------------------------------------------- 底部三 tab */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.tab { flex: 1; display: grid; place-items: center; gap: 2px; color: var(--ink-3); font-size: 11px; }
.tab-ico { font-size: 18px; line-height: 1; }
.tab.on { color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------- 通用块 */
.section { margin: 18px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-title { font-size: 17px; }
.section-count { color: var(--ink-3); font-size: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px;
  background: #eef2ff; color: #3538cd;
}
.chip-ok { background: #e7f8ef; color: #087443; }
.chip-price { background: #fff4e6; color: #b54708; font-weight: 600; }
.chip-link { background: #eef2ff; color: #3538cd; }
.badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; background: var(--brand); color: #fff; }
.badge-hot { background: linear-gradient(135deg,#f97316,#ef4444); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--bg); color: var(--ink); font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line); }
.btn-danger { background: #fef3f2; color: var(--danger); border-color: #fee4e2; }
.btn-disabled { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; }
.btn-mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.empty { text-align: center; color: var(--ink-2); padding: 28px 10px; }
.empty .btn { margin-top: 12px; }
.error-code { font-size: 44px; font-weight: 700; color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%); z-index: 70;
  max-width: 90vw; padding: 10px 16px; border-radius: 999px;
  background: rgba(16,24,40,.92); color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toastIn .2s ease;
}
.toast-error { background: rgba(240,68,56,.95); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------------------------------------------------------- 头像裁剪器 */
.crop-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(16,24,40,.72); padding: 16px;
}
.crop-card {
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow-lg); display: grid; gap: 10px; justify-items: center;
}
.crop-head { font-size: 15px; font-weight: 600; }
.crop-stage {
  position: relative; overflow: hidden; border-radius: 50%;
  background: #0b1220; touch-action: none; cursor: grab;
}
.crop-stage canvas { display: block; border-radius: 50%; }
.crop-frame {
  position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.9);
  pointer-events: none;
}
.crop-zoom { width: 100%; max-width: 260px; }
.crop-hint { color: var(--ink-3); font-size: 12px; }
.crop-actions { display: flex; gap: 10px; }

/* 弹窗海报 */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(16,24,40,.6); display: grid; place-items: center; padding: 20px; }
.modal-card { position: relative; max-width: 340px; width: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); }
.modal-close { position: absolute; top: 6px; right: 8px; border: 0; background: rgba(0,0,0,.4); color: #fff; width: 28px; height: 28px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.modal-title { padding: 12px 14px 0; font-size: 15px; }
.modal-img { width: 100%; }

/* ---------------------------------------------------------- 首页 */
.hero {
  display: block; background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.hero-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #eef2ff; }
.hero-placeholder, .card-placeholder {
  display: grid; place-items: center; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.hero-body { padding: 14px; }
.hero-title { font-size: 18px; margin: 8px 0 4px; }
.hero-sub { color: var(--ink-2); font-size: 13px; margin: 0 0 10px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.cards { display: grid; gap: 12px; }
.cards-scroll { grid-auto-flow: column; grid-auto-columns: 76%; overflow-x: auto; padding-bottom: 6px; }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: block; }
.card-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #eef2ff; }
.card-body { padding: 12px; }
.card-title { font-size: 15px; margin-bottom: 4px; }
.card-sub { color: var(--ink-2); font-size: 12px; margin: 0 0 8px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.card-progress { font-size: 12px; color: var(--ok); font-weight: 600; }
.card-last { color: var(--ink-3); font-size: 11px; margin: 6px 0 0; }

.cta { background: var(--surface); border-radius: var(--radius); padding: 18px; text-align: center; box-shadow: var(--shadow); }
.cta-title { font-size: 17px; }
.cta-sub { color: var(--ink-2); font-size: 13px; margin: 6px 0 14px; }
.cta-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------------------------------------------------------- 课程详情 */
.course-hero { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); padding-bottom: 14px; }
.course-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.course-title { font-size: 20px; padding: 14px 14px 0; }
.course-sub { color: var(--ink-2); font-size: 13px; padding: 0 14px; margin: 6px 0 10px; }
.course-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.prose { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); color: var(--ink-2); font-size: 14px; }
.prose img { border-radius: var(--radius-sm); margin: 10px 0; }

.chapter-title { font-size: 14px; color: var(--ink-2); margin: 14px 0 6px; padding-left: 2px; }
.lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lesson {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 11px 12px; box-shadow: var(--shadow);
}
.lesson-no {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
  background: #eef2ff; color: #3538cd;
}
.lesson-body { flex: 1; min-width: 0; }
.lesson-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--ink-3); }
.meta-ok { color: var(--ok); }
.meta-lock { color: var(--warn); }
.meta-doing { color: var(--brand); }
.lesson.is-done .lesson-no { background: #e7f8ef; color: #087443; }
.lesson.is-locked { opacity: .78; }
.lesson.is-current { outline: 2px solid rgba(37,99,235,.35); }
.lessons-compact .lesson { padding: 9px 11px; box-shadow: none; border: 1px solid var(--line); }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b));
  z-index: 30; display: flex; align-items: center; gap: 12px;
  max-width: 900px; margin: 0 auto; padding: 10px 14px;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.price-inline { font-size: 18px; font-weight: 700; color: #b54708; white-space: nowrap; }

/* ---------------------------------------------------------- 学习页 */
.player-wrap { position: relative; margin: -6px -14px 12px; background: #000; }
.player { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; }
.player-status { color: #fff; background: rgba(0,0,0,.65); font-size: 12px; padding: 6px 12px; text-align: center; }
.player-status:empty { display: none; }
.learn-head { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.learn-title { font-size: 17px; margin-bottom: 8px; }
.learn-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.learn-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.lockpanel { background: var(--surface); border-radius: var(--radius); padding: 26px 16px; text-align: center; box-shadow: var(--shadow); }
.lock-ico { font-size: 34px; }
.lock-title { font-size: 17px; margin: 8px 0; }
.lock-text { color: #b54708; font-weight: 600; margin: 0 0 6px; }
.lock-hint { color: var(--ink-2); font-size: 13px; }
.qr { width: 200px; margin: 12px auto; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.qr-empty { display: grid; place-items: center; color: var(--ink-3); font-size: 12px; aspect-ratio: 1; background: var(--bg); }

/* ---------------------------------------------------------- 我的课程 */
.user-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.user-card-body { min-width: 0; }
.user-name { font-size: 18px; }
.user-sub { color: var(--ink-3); font-size: 12px; margin: 2px 0 0; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow); text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--brand); }
.stat-label { color: var(--ink-3); font-size: 12px; }

.chart-block { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-top: 12px; box-shadow: var(--shadow); }
.seg { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; margin-bottom: 12px; }
.seg-btn { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--ink-2); cursor: pointer; font-family: inherit; }
.seg-btn.on { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }
.chart { min-height: 150px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; overflow-x: auto; }
.bar-wrap { flex: 1 0 34px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 70%; background: linear-gradient(180deg,#60a5fa,#2563eb); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-val { font-size: 10px; color: var(--ink-3); }
.bar-label { font-size: 10px; color: var(--ink-3); margin-top: 4px; }
.chart-empty, .chart-hint { color: var(--ink-3); font-size: 12px; text-align: center; }

/* ---------------------------------------------------------- 支付页 */
.pay-title { font-size: 18px; }
.pay-amount { font-size: 30px; font-weight: 700; color: #b54708; margin: 6px 0 14px; }
.pay-order { display: flex; align-items: center; gap: 10px; background: #eef2ff; border-radius: var(--radius-sm); padding: 10px 12px; }
.pay-order-label { font-size: 12px; color: #3538cd; }
.pay-order-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; letter-spacing: 1px; }
.pay-tip { color: var(--ink-2); font-size: 13px; }
.pay-qrs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 14px 0; }
.pay-qr, .pay-contact { background: var(--surface); border-radius: var(--radius-sm); padding: 12px; text-align: center; box-shadow: var(--shadow); }
.pay-qr-title { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.pay-note { font-size: 12px; color: var(--ink-3); }

/* ---------------------------------------------------------- 表单 */
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; color: var(--ink-2); }
.input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 15px; font-family: inherit; color: var(--ink);
}
.input:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--brand); }
.input-file { font-size: 13px; }
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-hint { font-size: 12px; color: var(--ink-3); }
.auth { background: var(--surface); border-radius: var(--radius); padding: 22px 18px; box-shadow: var(--shadow); margin-top: 20px; }
.auth-title { font-size: 20px; }
.auth-sub { color: var(--ink-3); font-size: 13px; margin: 4px 0 16px; }
.auth-foot { text-align: center; font-size: 13px; margin: 14px 0 0; }
.auth-foot a { color: var(--brand); font-weight: 600; }
.auth-note { color: var(--ink-3); font-size: 12px; text-align: center; margin: 10px 0 0; }
.list-row { display: block; padding: 12px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.list-danger { color: var(--danger); }

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards-scroll { grid-auto-columns: 46%; }
  .pay-qrs { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   后台管理
   ============================================================ */
body.admin { background: #f2f4f7; }
.admin-nav {
  position: sticky; top: 0; z-index: 30; background: var(--surface);
  border-bottom: 1px solid var(--line); padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.admin-nav .admin-brand { font-weight: 700; margin-right: 6px; }
.admin-nav a.nav-item {
  padding: 6px 10px; border-radius: 999px; font-size: 13px; color: var(--ink-2);
}
.admin-nav a.nav-item.on { background: #eef2ff; color: #3538cd; font-weight: 600; }
.admin-nav .spacer { flex: 1; }
.admin-main { max-width: 1180px; margin: 0 auto; padding: 16px 14px 60px; }

.admin-title { font-size: 20px; margin-bottom: 4px; }
.admin-sub { color: var(--ink-3); font-size: 13px; margin: 0 0 16px; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-title { font-size: 15px; margin-bottom: 12px; }
.panel-grid { display: grid; gap: 12px; }
.grid-2 { display: grid; gap: 12px; }
.grid-3 { display: grid; gap: 12px; }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .panel-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi { background: var(--surface); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow); }
.kpi-num { font-size: 24px; font-weight: 700; color: var(--brand); }
.kpi-label { color: var(--ink-3); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { color: var(--ink-2); font-weight: 600; background: #fafbfc; white-space: nowrap; }
table.data tr:hover td { background: #fafbff; }
table.data .nowrap { white-space: nowrap; }
table.data .muted { color: var(--ink-3); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: #eef2ff; color: #3538cd; }
.tag-ok { background: #e7f8ef; color: #087443; }
.tag-warn { background: #fff4e6; color: #b54708; }
.tag-off { background: #f2f4f7; color: var(--ink-3); }
.tag-danger { background: #fef3f2; color: var(--danger); }

.inline-form { display: inline; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row .field { min-width: 130px; flex: 1 1 130px; }
.hint { color: var(--ink-3); font-size: 12px; }
.section-block { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; background: #fcfdff; }
.section-block .section-block-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.drag-handle { cursor: grab; color: var(--ink-3); user-select: none; }
.lesson-row { display: grid; gap: 8px; grid-template-columns: auto 1fr auto; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); }
.upload-progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.upload-progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
details.lesson-edit { margin: 6px 0 12px; }
details.lesson-edit > summary { cursor: pointer; font-size: 13px; color: var(--brand); }




