/* ---------- 设计变量 ---------- */
:root {
  --ink: #16202c;
  --ink-soft: #4a5868;
  --ink-faint: #7a8796;
  --line: #e4e8ee;
  --line-strong: #cdd5df;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --brand: #2350d8;
  --brand-dark: #1a3da8;
  --brand-soft: #eaf0ff;
  --ok: #1f8a53;
  --ok-soft: #e8f6ee;
  --warn: #b86a0b;
  --warn-soft: #fff4e2;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(22 32 44 / 4%), 0 6px 24px rgb(22 32 44 / 6%);
  --shadow-hover: 0 2px 4px rgb(22 32 44 / 6%), 0 14px 36px rgb(22 32 44 / 10%);
  --width: 72rem;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; line-height: 1.7; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.3; letter-spacing: .01em; }
h1 { margin: 0 0 .5rem; font-size: clamp(1.6rem, 3.2vw, 2.25rem); }
h2 { margin: 2.5rem 0 1rem; font-size: 1.3rem; }
h3 { margin: 0 0 .4rem; font-size: 1.1rem; }
p { margin: 0 0 1rem; }
:focus-visible { outline: 3px solid rgb(35 80 216 / 45%); outline-offset: 2px; }

/* ---------- 顶栏 ---------- */
.site-header { position: sticky; top: 0; z-index: 10; background: rgb(255 255 255 / 92%); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: min(var(--width), calc(100% - 2rem)); margin: 0 auto; min-height: 4rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.08rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px; background: linear-gradient(135deg, #3a6bff, #1c3fb0); color: #fff; font-size: .95rem; }
.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav a, .site-nav .link-button { padding: .45rem .8rem; border-radius: 999px; color: var(--ink-soft); text-decoration: none; font-size: .95rem; white-space: nowrap; }
.site-nav a:hover, .site-nav .link-button:hover { background: var(--surface-soft); color: var(--ink); }
.site-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.site-nav form { margin: 0; }
.site-nav .nav-cta { background: var(--brand); color: #fff; }
.site-nav .nav-cta:hover { background: var(--brand-dark); color: #fff; }
.link-button { min-height: 0; border: 0; background: none; font: inherit; cursor: pointer; }

/* ---------- 页面主体 ---------- */
main { flex: 1; width: min(var(--width), calc(100% - 2rem)); margin: 2rem auto 3rem; overflow-wrap: anywhere; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(1.25rem, 3vw, 2rem); }
.panel + .panel, .panel + section, section + .panel { margin-top: 1.25rem; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { color: var(--ink-soft); max-width: 44rem; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; margin-bottom: 1rem; color: var(--ink-soft); text-decoration: none; font-size: .95rem; }
.back-link:hover { color: var(--brand); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 1rem; }
.section-title h2 { margin: 0; }
.section-title span { color: var(--ink-faint); font-size: .9rem; }
.muted, small { color: var(--ink-faint); }
.eyebrow { display: inline-block; margin-bottom: .6rem; padding: .15rem .7rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .85rem; font-weight: 600; }

/* ---------- 按钮 ---------- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: .6rem 1.15rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--brand); color: #fff; font: inherit; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s; }
button:hover, .button:hover { background: var(--brand-dark); color: #fff; }
button:disabled { opacity: .55; cursor: not-allowed; }
.button.secondary, button.secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.button.secondary:hover, button.secondary:hover { background: var(--surface-soft); border-color: var(--ink-faint); color: var(--ink); }
.button.ghost, button.ghost { background: transparent; color: var(--ink-soft); }
.button.ghost:hover, button.ghost:hover { background: var(--surface-soft); color: var(--ink); }
.button.small { min-height: 2.2rem; padding: .35rem .85rem; font-size: .9rem; }
.button.block, button.block { width: 100%; }

/* ---------- 表单 ---------- */
.form-page { display: grid; place-items: start center; padding-top: 1rem; }
.form-card { width: min(28rem, 100%); }
.form-card h1 { font-size: 1.6rem; }
.form-card .lead { color: var(--ink-soft); margin-bottom: 1.5rem; }
.form-card form { margin-top: 1rem; }
.form-foot { margin: 1.25rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .92rem; text-align: center; }
.field { display: grid; gap: .35rem; margin: 0 0 1.1rem; }
.field label { font-weight: 600; font-size: .95rem; }
.field small, .field .helptext { font-size: .85rem; line-height: 1.6; }
.field small ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.field:has(> input[type="checkbox"]) { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: .5rem; }
.field:has(> input[type="checkbox"]) label { font-weight: 400; color: var(--ink-soft); }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--brand); }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea { width: 100%; min-width: 0; min-height: 2.75rem; padding: .6rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(35 80 216 / 15%); }
.errorlist { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: .9rem; }
.errorlist.nonfield { margin-bottom: 1rem; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--danger-soft); }

/* ---------- 提示与标签 ---------- */
.notice { display: flex; gap: .6rem; align-items: flex-start; margin: 0 0 1rem; padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: #7a4606; border: 1px solid #f3d9ad; }
.notice::before { content: "!"; flex: none; display: grid; place-items: center; width: 1.3rem; height: 1.3rem; margin-top: .2rem; border-radius: 50%; background: var(--warn); color: #fff; font-size: .8rem; font-weight: 700; }
.notice.success { background: var(--ok-soft); color: #145c37; border-color: #bfe5cf; }
.notice.success::before { content: "✓"; background: var(--ok); }
.notice.info { background: var(--brand-soft); color: #1f3a8f; border-color: #cbd8ff; }
.notice.info::before { content: "i"; background: var(--brand); }
.tag { display: inline-flex; align-items: center; padding: .1rem .6rem; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--ink-soft); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); border-color: #bfe5cf; color: var(--ok); }
.tag.warn { background: var(--warn-soft); border-color: #f3d9ad; color: var(--warn); }
.tag.brand { background: var(--brand-soft); border-color: #cbd8ff; color: var(--brand); }
.username-box { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: 1rem 1.2rem; border-radius: var(--radius-sm); background: var(--surface-soft); border: 1px dashed var(--line-strong); }
.username-box strong { font-size: 1.15rem; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink); }
.username-box span { color: var(--ink-soft); font-size: .92rem; }
.empty-state { padding: 2.5rem 1.5rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); text-align: center; color: var(--ink-soft); }
.empty-state h2, .empty-state h3 { margin: 0 0 .5rem; color: var(--ink); }
.empty-state p { max-width: 34rem; margin-left: auto; margin-right: auto; }
.empty-icon { display: grid; place-items: center; width: 3rem; height: 3rem; margin: 0 auto 1rem; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 1.4rem; }

/* ---------- 首页 ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: center; padding: clamp(1.5rem, 4vw, 3rem); border-radius: 20px; background: radial-gradient(120% 140% at 0% 0%, #f0f4ff 0%, #ffffff 55%), var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.hero .intro-text { color: var(--ink-soft); font-size: 1.05rem; max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: .75rem; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2.2rem 1fr; gap: .8rem; align-items: start; padding: .9rem 1rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft); font-size: .95rem; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; }
.steps-title { margin: 0 0 .75rem; font-size: 1rem; color: var(--ink); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1.25rem; }
.course-card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s; }
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.course-cover { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #e9eef5; }
.cover-placeholder { display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #3a6bff 0%, #1c3fb0 100%); color: rgb(255 255 255 / 92%); font-size: 2.6rem; font-weight: 700; }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 1.1rem 1.25rem 1.25rem; }
.card-body h3 a { color: var(--ink); text-decoration: none; }
.card-body h3 a::after { content: ""; position: absolute; inset: 0; }
.card-body .summary { flex: 1; color: var(--ink-soft); font-size: .93rem; }
.card-body .notice { font-size: .88rem; padding: .5rem .75rem; }
.card-link { margin-top: .5rem; font-weight: 600; font-size: .93rem; color: var(--brand); }

/* ---------- 课程详情 ---------- */
.detail-head { display: grid; grid-template-columns: minmax(0, 22rem) 1fr; gap: clamp(1.25rem, 3vw, 2.25rem); align-items: start; }
.detail-head.no-cover { grid-template-columns: 1fr; }
.detail-cover { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; }
.detail-head h1 { margin-bottom: 1rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.25rem; align-items: start; margin-top: 1.25rem; }
.detail-grid > .panel { margin-top: 0; }
.detail-grid h2 { margin-top: 0; }
.description { color: var(--ink-soft); }
.side-card h2 { font-size: 1.05rem; }
.side-card p { color: var(--ink-soft); font-size: .93rem; }

.lesson-list { margin: 0; padding: 0; list-style: none; counter-reset: lesson; }
.lesson-list li { counter-increment: lesson; display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: .9rem; align-items: center; padding: .85rem .25rem; border-bottom: 1px solid var(--line); }
.lesson-list li:last-child { border-bottom: 0; }
.lesson-list li::before { content: counter(lesson, decimal-leading-zero); color: var(--ink-faint); font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem; }
.lesson-title { font-weight: 500; }
.lesson-action { justify-self: end; }

/* ---------- 我的课程 ---------- */
.course-list { display: grid; gap: 1rem; }
.access-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem 1.5rem; align-items: center; padding: 1.25rem 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.access-card h2 { margin: 0 0 .35rem; font-size: 1.15rem; }
.access-card p { margin: 0 0 .35rem; color: var(--ink-soft); font-size: .93rem; }
.access-card .notice { margin-top: .6rem; }
.access-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; margin-bottom: .5rem; }
.access-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; }
.progress { display: grid; gap: .35rem; max-width: 26rem; margin-top: .5rem; }
.progress-bar { height: .5rem; border-radius: 999px; background: #e7ecf3; overflow: hidden; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3a6bff, #2350d8); }
.progress-text { font-size: .85rem; color: var(--ink-faint); }

/* ---------- 账号 ---------- */
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem; margin-top: 1.25rem; }
.account-grid .panel { margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.account-grid .panel p { flex: 1; color: var(--ink-soft); font-size: .93rem; }

/* ---------- 帮助 ---------- */
.help-list { display: grid; gap: 1rem; }
.help-list .panel { margin: 0; }
.help-list h2 { margin: 0 0 .6rem; font-size: 1.1rem; }
.help-list p { margin: 0; color: var(--ink-soft); }

/* ---------- 错误页 ---------- */
.error-page { max-width: 32rem; margin: 3rem auto; text-align: center; }
.error-code { margin-bottom: .5rem; font-size: 3.5rem; font-weight: 800; line-height: 1; color: var(--brand); opacity: .25; }
.error-page p { color: var(--ink-soft); }

/* ---------- 播放页 ---------- */
.lesson-layout { display: grid; gap: 1.25rem; }
.lesson-head .course-name { color: var(--ink-soft); margin: 0; }
.player-card { padding: 0; overflow: hidden; }
#lesson-video { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 72vh; background: #0b0f15; }
.player-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; padding: 1rem 1.25rem; border-top: 1px solid var(--line); }
.player-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.player-actions button[hidden] { display: none; }
.speed-control { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink-soft); font-size: .92rem; }
.speed-control select { width: auto; min-height: 2.4rem; padding: .35rem .6rem; }
.player-status { padding: 0 1.25rem 1rem; display: grid; gap: .25rem; }
.player-status p { margin: 0; font-size: .92rem; color: var(--ink-soft); }
#player-status { color: var(--ink); font-weight: 500; }
.player-note { font-size: .88rem; }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; width: min(var(--width), calc(100% - 2rem)); margin: 0 auto; padding: 1.25rem 0; color: var(--ink-faint); font-size: .88rem; }
.footer-inner a { color: var(--ink-soft); }

.side-note { margin: .8rem 0 0; }
.side-note.center { text-align: center; }
.card-heading { margin: 0; font-size: 1.05rem; }

/* ---------- 窄屏 ---------- */
@media (max-width: 52rem) {
  .hero, .detail-grid, .detail-head { grid-template-columns: 1fr; }
  .access-card { grid-template-columns: 1fr; }
  .access-actions { justify-content: flex-start; }
}
@media (max-width: 40rem) {
  .header-inner { flex-direction: column; align-items: stretch; gap: .25rem; padding: .6rem 0; }
  .site-nav { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem .2rem; scrollbar-width: none; }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a, .site-nav .link-button { padding: .35rem .55rem; font-size: .9rem; }
  .site-header { position: static; }
  main { margin-top: 1.25rem; }
  .lesson-list li { grid-template-columns: 1.6rem minmax(0, 1fr); }
  .lesson-action { grid-column: 2; justify-self: start; }
  .player-bar { flex-direction: column; align-items: stretch; }
  .player-actions button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
