:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1b2430;
  --ink-2: #3c4757;
  --muted: #788392;
  --line: #e6eaf0;
  --brand: #0d47a1;
  --brand-2: #1a63c8;
  --brand-soft: #e9f1fd;
  --accent: #d7622c;
  --ok: #2c7a5b;
  --shadow: 0 2px 12px rgba(22, 43, 78, 0.06);
  --shadow-lg: 0 10px 34px rgba(22, 43, 78, 0.12);
  --r: 14px;
  --wrap: 1200px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

.wrap { width: min(100% - 40px, var(--wrap)); margin-inline: auto; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 68px;
}

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

.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, #0d47a1, #4a90d9);
  color: #fff;
  font-size: 20px; font-weight: 700;
  letter-spacing: 0;
  box-shadow: 0 3px 10px rgba(13, 71, 161, 0.24);
}
.brand-mark.small { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }

.brand-copy { display: flex; flex-direction: column; line-height: 1.25; }
.brand-copy strong { font-size: 17px; letter-spacing: .5px; }
.brand-copy small { color: var(--muted); font-size: 11px; }

.nav { display: flex; gap: 4px; flex: none; }
.nav a {
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--brand-soft); color: var(--brand); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(340px, 34vw);
  padding: 0 6px 0 12px;
  height: 38px;
  background: #f2f5f9;
  border: 1px solid transparent;
  border-radius: 20px;
  transition: border-color .15s, background .15s;
}
.search:focus-within { background: #fff; border-color: var(--brand-2); }
.search-icon { color: var(--muted); display: flex; }
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  color: var(--ink); font-size: 13px;
}
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-btn {
  border: 0; border-radius: 16px;
  padding: 5px 14px;
  background: var(--brand); color: #fff;
  font-size: 12px;
}
.search-btn:hover { background: var(--brand-2); }

.user-btn {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  color: var(--ink-2);
  flex: none;
}
.user-btn:hover { border-color: var(--brand-2); color: var(--brand); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  font-size: 13px; font-weight: 600;
}
.user-name { font-size: 13px; max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.demo-badge {
  flex: none;
  font-size: 11px;
  color: var(--accent);
  background: #fff2e9;
  border: 1px solid #f7d9c4;
  padding: 3px 9px;
  border-radius: 12px;
}

/* ---------- 通用 ---------- */
main { min-height: 62vh; padding: 28px 0 56px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 30px 0 16px; }
.section-head h2 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.section-head .sub { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  background: var(--brand); color: #fff;
  transition: transform .12s, background .15s, box-shadow .15s;
}
.btn:hover { background: var(--brand-2); box-shadow: 0 4px 14px rgba(13, 71, 161, .22); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #fff; color: var(--brand); border-color: #cddcf3; }
.btn.ghost:hover { background: var(--brand-soft); box-shadow: none; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.tag {
  display: inline-block;
  font-size: 11px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 6px;
  padding: 2px 8px;
}
.tag.free { color: var(--ok); background: #e8f5ef; }

.empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r);
}
.empty h3 { margin: 0 0 8px; color: var(--ink-2); font-size: 16px; }
.empty p { margin: 0 0 20px; font-size: 13px; }
.empty-mark { font-size: 34px; color: #c9d3e2; margin-bottom: 10px; }

/* ---------- 首页 Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 44px 46px;
  background: linear-gradient(120deg, #0d47a1 0%, #1c63bd 55%, #4a91d6 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: "";
  position: absolute;
  right: -80px; top: -120px;
  width: 360px; height: 360px;
  border-radius: 50%;
  background: rgba(255,255,255,.09);
}
.hero::before {
  content: "";
  position: absolute;
  right: 120px; bottom: -180px;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.hero-inner { position: relative; z-index: 1; max-width: 620px; }
.hero .kicker { font-size: 12px; letter-spacing: 2px; opacity: .8; }
.hero h1 { margin: 10px 0 12px; font-size: clamp(26px, 3.6vw, 40px); line-height: 1.3; letter-spacing: 1px; }
.hero p { margin: 0 0 24px; font-size: 14px; opacity: .9; max-width: 500px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn { background: #fff; color: var(--brand); }
.hero .btn:hover { background: #eef4fd; }
.hero .btn.line { background: transparent; color: #fff; border-color: rgba(255,255,255,.65); }
.hero .btn.line:hover { background: rgba(255,255,255,.14); }
.hero-stats { display: flex; gap: 30px; margin-top: 30px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.22); }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats b { font-size: 20px; font-weight: 650; }
.hero-stats span { font-size: 11px; opacity: .8; }

/* ---------- 分类 / 排序 ---------- */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 26px 0 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  transition: all .15s;
}
.chip:hover { border-color: var(--brand-2); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.sort-box { margin-left: auto; display: flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 3px; }
.sort-box button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 4px 12px; border-radius: 16px; }
.sort-box button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ---------- 课程卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 18px; margin-top: 18px; }

.card {
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #cfdcf0; }

.cover {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  overflow: hidden;
}
.cover::before {
  content: ""; position: absolute;
  width: 190px; height: 190px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  right: -50px; top: -70px;
}
.cover::after {
  content: ""; position: absolute;
  width: 110px; height: 110px;
  background: rgba(255,255,255,.08);
  border-radius: 50%;
  left: -30px; bottom: -50px;
}
.cover .glyph {
  position: relative; z-index: 1;
  font-size: 58px; font-weight: 700;
  color: rgba(255,255,255,.92);
  text-shadow: 0 3px 16px rgba(0,0,0,.12);
  letter-spacing: 4px;
}
.cover .cat-label {
  position: absolute; z-index: 2;
  left: 12px; top: 12px;
  background: rgba(255,255,255,.9);
  color: #26415f;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
}
.cover .free-label {
  position: absolute; z-index: 2;
  right: 12px; bottom: 12px;
  background: rgba(0,0,0,.35);
  color: #fff; font-size: 11px;
  padding: 3px 9px; border-radius: 10px;
}
.cover.sm { aspect-ratio: 16 / 9; }
.cover.lg { aspect-ratio: 21 / 9; }
.cover.lg .glyph { font-size: 84px; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card-body h3 { margin: 0 0 5px; font-size: 15px; line-height: 1.45; font-weight: 650; }
.card-body .sub { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.5; flex: 1; }
.card-meta { display: flex; gap: 12px; color: var(--muted); font-size: 11px; margin-bottom: 10px; }
.card-foot { display: flex; align-items: baseline; gap: 8px; }
.price { color: var(--accent); font-weight: 700; font-size: 17px; }
.price small { font-size: 11px; font-weight: 500; }
.origin { color: #aab2bd; font-size: 12px; text-decoration: line-through; }
.card-foot .go { margin-left: auto; color: var(--brand); font-size: 12px; }

/* ---------- 详情 ---------- */
.crumb { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.crumb a:hover { color: var(--brand); }

.detail-top { display: grid; grid-template-columns: 1.05fr .95fr; gap: 26px; }
.detail-cover { border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.detail-info h1 { margin: 6px 0 10px; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.4; }
.detail-info .sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.detail-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.detail-meta b { color: var(--ink-2); font-weight: 600; }

.buy-box {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.buy-box .price-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.buy-box .price { font-size: 26px; }
.buy-box .hint { color: var(--muted); font-size: 11px; margin: 10px 0 0; text-align: center; }

.intro { white-space: pre-line; color: var(--ink-2); font-size: 14px; line-height: 1.9; }

.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .15s, background .15s;
}
.lesson:hover { border-color: #cfdcf0; background: #fbfdff; }
.lesson .idx { width: 24px; color: #a7b1bf; font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.lesson .lt { flex: 1; font-size: 13px; }
.lesson .dur { color: var(--muted); font-size: 11px; flex: none; }
.lesson .play-ico { color: var(--brand); display: flex; flex: none; }
.lesson.locked .lt { color: var(--muted); }

/* ---------- 播放页 ---------- */
.player-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; }
.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r);
  background: linear-gradient(150deg, #14243b, #24456e);
  display: grid; place-items: center;
  color: #fff;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.screen::before {
  content: ""; position: absolute;
  width: 340px; height: 340px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.12);
  right: -90px; top: -120px;
}
.screen-inner { position: relative; z-index: 1; text-align: center; padding: 20px; }
.screen .circle {
  width: 62px; height: 62px; margin: 0 auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.3);
}
.screen h3 { margin: 0 0 8px; font-size: 17px; }
.screen p { margin: 0; font-size: 12px; opacity: .82; max-width: 420px; }
.screen .screen-note { margin-top: 14px; font-size: 11px; opacity: .6; }

.player-title { margin: 18px 0 4px; font-size: 19px; }
.player-sub { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.player-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.side-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); align-self: start; }
.side-panel h3 { margin: 0 0 12px; font-size: 14px; }
.side-lesson {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 10px; border-radius: 8px;
  font-size: 12px;
  transition: background .15s;
}
.side-lesson:hover { background: var(--brand-soft); }
.side-lesson.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-lesson .n { color: #a7b1bf; flex: none; width: 18px; }
.side-lesson .txt { flex: 1; line-height: 1.5; }
.side-lesson .done { color: var(--ok); flex: none; font-size: 11px; }

/* ---------- 我的 / 订单 ---------- */
.profile {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(120deg, #0d47a1, #3d7fc9);
  color: #fff;
  border-radius: var(--r);
  padding: 24px 26px;
  box-shadow: var(--shadow);
}
.profile .avatar-lg {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.2);
  font-size: 22px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.35);
}
.profile h2 { margin: 0; font-size: 19px; }
.profile p { margin: 2px 0 0; font-size: 12px; opacity: .85; }
.profile .stat { margin-left: auto; text-align: right; }
.profile .stat b { display: block; font-size: 24px; }
.profile .stat span { font-size: 11px; opacity: .85; }

.order-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.order-row .ot { flex: 1; font-size: 13px; }
.order-row .od { color: var(--muted); font-size: 11px; }
.order-row .oa { color: var(--accent); font-weight: 650; }
.status-pill { font-size: 11px; padding: 3px 10px; border-radius: 12px; background: #e8f5ef; color: var(--ok); }

/* ---------- 底部 ---------- */
.footer { background: #fff; border-top: 1px solid var(--line); padding: 26px 0 34px; }
.footer-inner { display: flex; gap: 26px; align-items: flex-start; flex-wrap: wrap; }
.footer-brand { display: flex; gap: 12px; align-items: center; flex: none; }
.footer-brand strong { font-size: 15px; }
.footer-brand p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.footer-note { flex: 1; min-width: 280px; }
.footer-note p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.8; }
.footer-note b { color: var(--ink-2); }
.footer-legal { margin-top: 4px !important; color: #a3acb8 !important; }

.tabbar { display: none; }

/* ---------- 弹窗 / Toast ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16, 28, 45, .42);
  display: grid; place-items: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-mask.hidden { display: none; }
.modal {
  width: min(100%, 400px);
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(10, 24, 45, .28);
}
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.modal .modal-price { font-size: 22px; color: var(--accent); font-weight: 700; margin: 0 0 12px; }
.modal input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  outline: 0; margin-bottom: 16px;
}
.modal input:focus { border-color: var(--brand-2); }
.modal .notice { background: #fff7f0; border: 1px solid #f6ddc7; color: #9c5726; padding: 10px 12px; border-radius: 9px; font-size: 11px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast {
  position: fixed; z-index: 80;
  left: 50%; bottom: 40px;
  transform: translate(-50%, 14px);
  background: #1b2b40; color: #fff;
  padding: 10px 20px; border-radius: 22px;
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .nav { display: none; }
  .search { width: min(300px, 38vw); }
  .player-layout { grid-template-columns: 1fr; }
  .side-panel { order: -1; }
  .detail-top { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .wrap { width: min(100% - 28px, var(--wrap)); }
  .topbar-inner { height: 58px; gap: 10px; }
  .brand-copy small, .demo-badge, .user-name { display: none; }
  .brand-copy strong { font-size: 15px; }
  .brand-mark { width: 32px; height: 32px; font-size: 17px; border-radius: 9px; }
  .search { width: auto; flex: 1; }
  .search-btn { display: none; }
  .user-btn { padding: 3px; border: 0; }
  main { padding: 18px 0 90px; }
  .hero { padding: 30px 24px; border-radius: 16px; }
  .hero h1 { font-size: 26px; }
  .hero-stats { gap: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .cover .glyph { font-size: 40px; }
  .card-body { padding: 11px 12px 13px; }
  .card-body h3 { font-size: 13px; }
  .card-body .sub { font-size: 11px; }
  .card-meta { gap: 8px; font-size: 10px; }
  .price { font-size: 15px; }
  .sort-box { margin-left: 0; }
  .footer { padding: 22px 0 96px; }
  .footer-inner { flex-direction: column; gap: 14px; }

  .tabbar {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--muted); font-size: 10px;
  }
  .tabbar a.active { color: var(--brand); }
}

@media (max-width: 400px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .cover .glyph { font-size: 34px; }
}
