:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #1e40af;
  --brand-hover: #1d4ed8;
  --brand-soft: #eff6ff;
  --brand-border: #bfdbfe;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, .05), 0 2px 4px -2px rgba(15, 23, 42, .05);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, .08), 0 8px 10px -6px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100dvh;
}
img, video { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, .file { font: inherit; cursor: pointer; touch-action: manipulation; }
.wrap { width: min(1080px, calc(100% - 36px)); margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* 头部通用 Hero Banner */
.hero {
  background: radial-gradient(1200px 480px at 20% -30%, #3b82f6 0%, transparent 70%),
              linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
  color: #fff;
  padding: calc(26px + env(safe-area-inset-top)) 0 32px;
  box-shadow: 0 4px 20px rgba(30, 64, 175, .15);
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  color: #93c5fd;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0;
  font-size: clamp(22px, 3.8vw, 30px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.hero .sub {
  margin: 8px 0 0;
  color: #bfdbfe;
  font-size: 14px;
}
.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.student-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  border: 2px solid rgba(255, 255, 255, .3);
  display: grid;
  place-items: center;
  color: #fff;
}
.profile-avatar svg { width: 24px; height: 24px; }
.profile-last4 {
  font-size: 15px;
  font-weight: 400;
  color: #bfdbfe;
  margin-left: 4px;
}
/* 统一的页面返回按钮：蓝色头图上为半透明胶囊，浅色页面上用 .light。 */
.page-back {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 16px 4px 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.page-back-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .2);
}
.page-back:hover {
  background: rgba(255, 255, 255, .24);
  border-color: rgba(255, 255, 255, .5);
  transform: translateX(-2px);
}
.page-back:active { transform: translateX(-1px) scale(.98); }
.page-back:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.page-back.light {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.page-back.light .page-back-icon {
  background: #fff;
  color: var(--brand);
}
.page-back.light:hover {
  background: #dbeafe;
  border-color: var(--brand);
}
.page-back.light:focus-visible {
  outline: 2px solid rgba(30, 64, 175, .35);
  outline-offset: 2px;
}
/* 首页关闭按钮：只关闭页面/视图，不结束会话。 */
.page-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.page-close:hover {
  background: rgba(255, 255, 255, .24);
  border-color: rgba(255, 255, 255, .5);
}
.page-close:active { transform: scale(.96); }
.page-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.crumb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.hero-crumb { color: #bfdbfe; font-size: 13px; }
.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  font-size: 13px;
  margin-top: 8px;
}

main { padding: 28px 0 calc(48px + env(safe-area-inset-bottom)); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.01em;
}
.section-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* 首页：现代多列自适应科目网格 */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.subject-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: border-color .18s, box-shadow .18s, transform .18s;
}
.subject-card:hover {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}
.chip-icon { display: flex; align-items: center; color: var(--brand); }
.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}
.status-badge.warn { background: var(--warn-soft); color: var(--warn); }
.status-badge.muted { background: #f1f5f9; color: #64748b; }

.card-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.card-progress {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.progress-ratio strong { color: var(--brand); font-size: 14px; font-weight: 700; }
.progress-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #3b82f6);
  border-radius: 999px;
  transition: width .4s ease;
}
.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}
.expiry-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.round-arrow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  transition: background .15s, transform .15s;
}
.subject-card:hover .round-arrow {
  background: var(--brand);
  color: #fff;
  transform: translateX(2px);
}
.subject-card.disabled {
  background: #f8fafc;
  box-shadow: none;
  opacity: .75;
}
.subject-card.disabled .card-title { color: #64748b; }

details.inactive {
  margin-top: 32px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
details.inactive summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}
details.inactive .subject-grid { margin-top: 14px; }

/* 科目详情页 */
.subject-hero-headline {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
}
.subject-days-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  font-size: 13px;
  color: #bfdbfe;
  background: rgba(255, 255, 255, .15);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.subject-days-badge.warn {
  color: #fde68a;
  background: rgba(217, 119, 6, .3);
  border: 1px solid rgba(217, 119, 6, .4);
}

/* 主训练卡片 (突出主行动) */
.primary-action-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px 28px;
  margin-bottom: 16px;
}
.primary-left { flex: 1 1 auto; min-width: 0; }
.primary-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  background: #dbeafe;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.primary-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.primary-sub {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}
.primary-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 440px;
}
.primary-progress-bar {
  flex: 1 1 auto;
  min-width: 0;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.primary-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #059669);
  border-radius: 999px;
}
/* 进度数字只作为进度条右侧的读值：无边框、无「完成度」标签。 */
.primary-pct {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.primary-pct span { font-size: 11.5px; font-weight: 600; }
.primary-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}
.btn-start {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(30, 64, 175, .25);
  transition: all .15s ease;
}
.btn-start:hover {
  background: var(--brand-hover);
  box-shadow: 0 6px 20px rgba(30, 64, 175, .35);
  transform: translateY(-1px);
}
/* 有规范节点时整卡是一个链接：.primary-link 的伪元素铺满卡片，
   「开始学习」按钮 z-index 更高，两个点击区域互不干扰。 */
.primary-action-card.has-outline { cursor: pointer; }
.primary-action-card.has-outline:hover {
  border-color: var(--brand);
  box-shadow: 0 10px 26px rgba(30, 64, 175, .16);
}
.primary-action-card.has-outline:focus-within {
  outline: 3px solid rgba(30, 64, 175, .18);
  outline-offset: 2px;
}
.primary-link { color: inherit; text-decoration: none; }
.primary-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius);
}
.primary-link:focus-visible { outline: none; }
.primary-enter {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
}
.primary-action-card.has-outline:hover .primary-enter {
  background: var(--brand);
  color: #fff;
}

/* 品字布局：右侧题库跨两行，左侧签到/线上上下排列 */
.aux-entries {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.aux-checkin { grid-column: 1; grid-row: 1; }
.aux-online_hours { grid-column: 1; grid-row: 2; }
.aux-question_bank { grid-column: 2; grid-row: 1 / span 2; }
.aux-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 12px;
  min-height: 92px;
  transition: all .15s ease;
}
/* Icon+title and the credential block share one left edge; the block itself is
   centred, so the credential lines stay put and the header aligns to them. */
.aux-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
}
.aux-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  max-width: 100%;
}
.aux-entry:hover {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.aux-entry.disabled {
  background: #f8fafc;
  box-shadow: none;
  opacity: .7;
}
.aux-icon-wrap {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
}
.aux-content { min-width: 0; }
.aux-content h4 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; }
/* 签到打卡只有 4 个字，比下面的「线上视频学时」窄 30px；补两个全角空格让两块
   等宽，图标左缘因此对齐。纯展示，不改数据。 */
.aux-checkin .aux-content h4::after { content: "　　"; }
.aux-desc { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.aux-note { margin: 4px 0 0; font-size: 12px; color: var(--warn); }
.aux-cred { display: flex; flex-direction: column; gap: 2px; margin-top: 0; font-size: 12.5px; color: var(--muted); }
.aux-cred b { color: var(--ink); font-weight: 600; letter-spacing: .02em; }

/* 视频列表页 */
.video-list-container {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.video-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0;
}
.video-list li:not(:last-child) {
  border-bottom: 1px solid var(--line);
}
.video-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: #fff;
  transition: background .15s;
}
.video-row:hover { background: #f8fafc; }
.video-status-icon {
  flex: 0 0 auto;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.video-row.is-completed .video-status-icon { color: var(--success); }
.video-info { flex: 1 1 auto; min-width: 0; }
.video-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.video-index {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 6px;
  border-radius: 4px;
}
.video-name {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
}
.video-desc {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.video-right-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
.video-duration {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.badge-done {
  font-size: 12px;
  color: var(--success);
  background: var(--success-soft);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.badge-todo {
  font-size: 12px;
  color: var(--muted);
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}

/* 播放页：桌面双栏工作台布局 */
.play-main { padding-top: 20px; }
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}
.play-left { min-width: 0; }
.player-shell {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .25);
}
.player { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
/* 外链：站内无法统计的外部页面；直链加载失败时也复用这一出口样式。 */
.external-player {
  aspect-ratio: 16 / 9;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0b1220 70%);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .25);
  color: #cbd5e1;
}
.external-player-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .1);
  color: #fff;
}
.external-player-icon svg { width: 22px; height: 22px; }
.external-player p { margin: 0; max-width: 32em; font-size: 14px; line-height: 1.7; }
.external-player .btn-start { min-height: 44px; padding: 0 20px; }
.player-fallback {
  margin-top: 12px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #f8fafc;
  text-align: center;
}
.player-fallback[hidden] { display: none; }
.player-fallback p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.player-fallback .btn-start { min-height: 42px; padding: 0 20px; }
.detail-card {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.detail-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.detail-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.detail-status.done { color: var(--success); font-weight: 600; }
.detail-body { margin: 0; color: var(--ink-secondary); font-size: 14.5px; line-height: 1.75; }
.detail-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
}
.detail-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

/* 播放页右侧选集抽屉 */
.playlist-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 20px;
}
.playlist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.playlist-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.playlist-count { font-size: 12.5px; color: var(--muted); }
.playlist-items {
  list-style: none;
  padding: 6px 0;
  margin: 0;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}
.playlist-item {
  padding: 0;
  transition: background .12s;
}
.playlist-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  min-height: 52px;
}
.playlist-item:hover { background: #f8fafc; }
.item-num {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}
.item-text { flex: 1 1 auto; min-width: 0; }
.item-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-dur {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.item-icon { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.playlist-item.is-active {
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
}
.playlist-item.is-active .item-num {
  background: var(--brand);
  color: #fff;
}
.playlist-item.is-active .item-title {
  color: var(--brand);
  font-weight: 700;
}
.playing-indicator {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  background: #dbeafe;
  padding: 2px 6px;
  border-radius: 4px;
}
.playlist-item.is-done:not(.is-active) .item-num {
  background: var(--success-soft);
  color: var(--success);
}

/* 登录向导 Card */
.login-page {
  padding: 0;
  min-height: 100dvh;
  background: linear-gradient(180deg, #f0f5ff 0%, #f8fafc 100%);
}
.login-page .login-hero {
  /* Must beat the mobile `.hero { padding: 20px 0 26px }` override, otherwise the
     card's negative margin slides up over the title. */
  padding: calc(44px + env(safe-area-inset-top)) 0 64px;
  text-align: center;
}
.login-hero h1 { font-size: clamp(26px, 4vw, 34px); }
.login-wrap {
  margin-top: -38px;
  max-width: 460px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 28px;
}
.login-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.login-card form { margin: 0; padding: 0; border: 0; }
.login-card label { display: block; margin: 16px 0; font-weight: 600; font-size: 14px; }
.login-card label.consent {
  /* Flex must beat `.login-card label { display:block }` (specificity 0,1,1). */
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0 0;
  padding: 12px 0;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 20px;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
}
.login-card input[type="text"], #id-card {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  background: #fff;
  transition: all .15s ease;
}
.login-card input:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(30, 64, 175, .15);
}
/* 触屏设备：仿系统键盘，从视口底部滑入并盖在页面之上，不用时完全收起。
   键盘本身不占文档流，所以输入框和按钮的位置不会因弹出而跳动。 */
.keypad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  padding: 0 10px calc(8px + env(safe-area-inset-bottom));
  background: #e9eef6;
  border-top: 1px solid var(--line-strong);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -12px 32px rgba(15, 23, 42, .18);
  transform: translateY(105%);
  visibility: hidden;
  transition: transform .24s cubic-bezier(.2, .8, .3, 1), visibility 0s linear .24s;
  will-change: transform;
  /* 键盘整体不可选中：长按不应该出现选择柄、放大镜或「拷贝/翻译」菜单。 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  /* 按键时不允许页面跟着滚动或触发双击缩放。 */
  touch-action: none;
}
.keypad.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform .24s cubic-bezier(.2, .8, .3, 1), visibility 0s;
}
/* 桌面端永远不出现，实体键盘照常使用。 */
@media (pointer: fine) {
  .keypad { display: none; }
}
.keypad-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 42px;
  padding: 0 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.keypad-done {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  background: transparent;
  border: 0;
  border-radius: 8px;
}
.keypad-done:active { background: rgba(30, 64, 175, .1); }
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.keypad-grid button {
  min-height: 50px;
  padding: 0;
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .18);
}
.keypad-grid button:active,
.keypad-grid button.is-pressed {
  background: #dbe6fb;
  box-shadow: none;
  transform: scale(.97);
}
.keypad .key-x { color: var(--brand); font-weight: 600; }
.keypad .key-back { font-size: 18px; color: var(--muted); }
/* 键盘打开时给页面留出等高的底部空间，让登录按钮仍可滚动到键盘上方。 */
body.keypad-open { padding-bottom: var(--keypad-h, 0px); }

/* 科技感摄像头取景框 */
.camera {
  position: relative;
  background: #090d16;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 320px;
  display: grid;
  place-items: center;
  margin: 14px auto;
  border: 2px dashed rgba(59, 130, 246, .4);
}
.camera video, .camera img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera p {
  position: absolute;
  color: #94a3b8;
  padding: 0 16px;
  text-align: center;
  font-size: 13.5px;
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.row > * { flex: 1 1 140px; }
.file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}
.file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.consent[hidden] { display: none; }
.consent input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  /* (20px line box - 18px box) / 2 => tick centred on the first text line */
  margin: 1px 0 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  display: grid;
  place-content: center;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.consent input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  background: #fff;
  transform: scale(0);
  transition: transform .12s ease-in-out;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.consent input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.consent input[type="checkbox"]:checked::before { transform: scale(1); }
.consent input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(30, 64, 175, .18);
  outline-offset: 2px;
}
button.primary {
  width: 100%;
  margin-top: 16px;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 15.5px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(30, 64, 175, .25);
  transition: all .15s ease;
}
button.primary:hover {
  background: var(--brand-hover);
  box-shadow: 0 6px 18px rgba(30, 64, 175, .35);
}
button.primary:disabled { opacity: .6; cursor: not-allowed; box-shadow: none; }
button.secondary {
  background: #f1f5f9;
  color: var(--ink-secondary);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s ease;
}
button.secondary:hover { background: #e2e8f0; }
.step-actions {
  display: grid;
  /* 返回占 1/4，主行动占 3/4 */
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 10px;
  margin-top: 14px;
}
.step-actions .primary, .step-actions .secondary { width: 100%; margin-top: 0; }
.error {
  color: var(--danger);
  min-height: 1.4em;
  font-size: 13.5px;
  margin-top: 10px;
}
/* 错误页 */
.error-page { padding-top: 32px; }
.error-page .page-back { margin-bottom: 20px; }
.error-card {
  max-width: 520px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  text-align: center;
}
.error-card h1 { margin: 8px 0 10px; font-size: 24px; font-weight: 700; }
.error-card p { margin: 0 0 22px; color: var(--muted); font-size: 15px; }

/* 移动端断点适配 (≤768px 与 ≤560px) */
@media (max-width: 900px) {
  .play-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .playlist-card { position: static; }
  .playlist-items { max-height: 320px; }
}

@media (max-width: 680px) {
  .wrap { width: calc(100% - 24px); }
  .hero { padding: calc(20px + env(safe-area-inset-top)) 0 26px; }
  .hero h1 { font-size: 22px; }
  .student-profile { gap: 10px; }
  .profile-avatar { width: 44px; height: 44px; }
  
  .primary-action-card {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
    gap: 16px;
  }
  .primary-right {
    justify-content: flex-end;
  }
  .btn-start { flex: 1 1 auto; justify-content: center; }

  /* 品字布局保持不变，只压缩内边距，让图标与文字尽量同行 */
  .aux-entry { padding: 14px 10px; min-height: 84px; }

  .video-row { padding: 12px 14px; }
  .video-right-meta .round-arrow { display: none; }
  
  .login-card { padding: 20px 16px; }
  .login-page .login-hero { padding: calc(34px + env(safe-area-inset-top)) 0 56px; }
  .camera { max-height: 280px; }
}

@media (max-width: 400px) {
  .subject-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
