/* ============================================================
   国源学习平台 · Aurora Glass 设计系统
   暗色为默认主题，亮色通过 [data-theme="light"] 覆盖
   ============================================================ */

:root {
  /* 底色 */
  --bg: #05070d;
  --bg-2: #0a0e1a;

  /* 文字 */
  --text: #eaeefb;
  --text-2: #b6c0d6;
  --muted: #8b96ad;
  --faint: #707b93;

  /* 玻璃 */
  --glass: rgba(255, 255, 255, .045);
  --glass-2: rgba(255, 255, 255, .07);
  --glass-3: rgba(255, 255, 255, .10);
  --stroke: rgba(255, 255, 255, .09);
  --stroke-2: rgba(255, 255, 255, .16);
  --line: rgba(255, 255, 255, .09);
  --line-soft: rgba(255, 255, 255, .055);
  --surface: rgba(255, 255, 255, .045);

  /* 品牌色 */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: rgba(99, 102, 241, .16);
  --accent-2: #22d3ee;
  --teal: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;

  --grad: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
  --grad-soft: linear-gradient(135deg, rgba(99, 102, 241, .22), rgba(34, 211, 238, .12));
  --grad-text: linear-gradient(120deg, #c7d2fe 0%, #67e8f9 100%);

  --radius: 18px;
  --radius-sm: 11px;
  --radius-xs: 8px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 18px 50px -22px rgba(0, 0, 0, .85);
  --blur: blur(22px) saturate(160%);

  --cert-bg: #fffdf7;
  --cert-text: #2a2118;
  --cert-line: #d9d2bd;
}

[data-theme="light"] {
  --bg: #eef2f9;
  --bg-2: #f6f8fc;

  --text: #0f172a;
  --text-2: #334155;
  --muted: #5b6577;
  --faint: #8593a8;

  --glass: rgba(255, 255, 255, .66);
  --glass-2: rgba(255, 255, 255, .85);
  --glass-3: rgba(255, 255, 255, .95);
  --stroke: rgba(15, 23, 42, .08);
  --stroke-2: rgba(15, 23, 42, .16);
  --line: rgba(15, 23, 42, .08);
  --line-soft: rgba(15, 23, 42, .05);
  --surface: rgba(255, 255, 255, .66);

  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: rgba(99, 102, 241, .12);
  --teal: #059669;
  --warn: #b45309;
  --danger: #be123c;

  --grad-text: linear-gradient(120deg, #4338ca 0%, #0891b2 100%);
  --shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 18px 40px -24px rgba(15, 23, 42, .35);
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  transition: background .35s ease;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: color .35s ease;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
[data-theme="light"] a { color: #0891b2; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 8px; }
ul, ol { margin: 0; padding-left: 20px; }

/* ---------- 背景层 ---------- */
.aurora {
  position: fixed; inset: 0; z-index: -3;
  overflow: hidden; pointer-events: none;
}
.aurora i {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .5; will-change: transform;
}
.aurora .b1 {
  width: 820px; height: 820px; left: -220px; top: -280px;
  background: radial-gradient(circle, #4338ca 0%, rgba(67, 56, 202, 0) 70%);
  animation: drift1 26s ease-in-out infinite;
}
.aurora .b2 {
  width: 760px; height: 760px; right: -200px; top: 8%;
  background: radial-gradient(circle, #0891b2 0%, rgba(8, 145, 178, 0) 70%);
  animation: drift2 32s ease-in-out infinite;
}
.aurora .b3 {
  width: 700px; height: 700px; left: 32%; bottom: -320px;
  background: radial-gradient(circle, #a855f7 0%, rgba(168, 85, 247, 0) 70%);
  animation: drift3 38s ease-in-out infinite;
}
@keyframes drift1 { 50% { transform: translate3d(80px, 60px, 0) scale(1.1); } }
@keyframes drift2 { 50% { transform: translate3d(-70px, 90px, 0) scale(1.08); } }
@keyframes drift3 { 50% { transform: translate3d(60px, -70px, 0) scale(1.12); } }

[data-theme="light"] .aurora i { opacity: .38; filter: blur(100px); }
[data-theme="light"] .aurora .b1 { background: radial-gradient(circle, #818cf8 0%, rgba(129, 140, 248, 0) 70%); }
[data-theme="light"] .aurora .b2 { background: radial-gradient(circle, #22d3ee 0%, rgba(34, 211, 238, 0) 70%); }
[data-theme="light"] .aurora .b3 { background: radial-gradient(circle, #c084fc 0%, rgba(192, 132, 252, 0) 70%); }

#particles {
  position: fixed; inset: 0; z-index: -1;
  width: 100%; height: 100%;
  pointer-events: none; display: block;
}

.grid-overlay {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(var(--stroke) 1px, transparent 1px),
    linear-gradient(90deg, var(--stroke) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .55;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 0%, transparent 78%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 0%, transparent 78%);
}

@media (prefers-reduced-motion: reduce) {
  .aurora i { animation: none !important; }
}

/* ---------- 玻璃基类 ---------- */
.glass, .card, .stat, .sidebar, .auth-card {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card::before, .stat::before, .sidebar::before, .auth-card::before {
  content: "";
  position: absolute; left: 14%; right: 14%; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .4), transparent);
  pointer-events: none;
}
[data-theme="light"] .card::before,
[data-theme="light"] .stat::before,
[data-theme="light"] .sidebar::before,
[data-theme="light"] .auth-card::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .95), transparent);
}

@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .card, .stat, .sidebar, .auth-card { background: rgba(18, 22, 34, .92); }
  [data-theme="light"] .card,
  [data-theme="light"] .stat,
  [data-theme="light"] .sidebar,
  [data-theme="light"] .auth-card { background: #ffffff; }
}

/* ---------- 移动端顶栏（桌面隐藏） ---------- */
.mobile-bar { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  color: var(--muted);
  cursor: pointer;
  transition: .2s;
  flex: 0 0 auto;
}
.icon-btn:hover { color: var(--text); border-color: var(--stroke-2); text-decoration: none; }
.icon-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 应用外壳 ---------- */
.shell {
  display: flex; gap: 16px;
  padding: 16px;
  min-height: 100vh;
  align-items: flex-start;
}

.sidebar {
  width: 212px; flex: 0 0 212px;
  position: sticky; top: 16px;
  height: calc(100vh - 32px);
  padding: 16px 13px;
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; color: inherit; padding: 2px 4px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  filter: drop-shadow(0 0 12px rgba(212, 168, 68, .35));
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong {
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text small {
  font-size: 10px; color: var(--faint);
  letter-spacing: .12em; text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--muted);
  border: 1px solid transparent;
  transition: .2s;
  white-space: nowrap;
}
.nav-item:hover {
  color: var(--text); background: var(--glass-2);
  text-decoration: none;
}
.nav-item svg {
  width: 15px; height: 15px;
  flex: 0 0 15px;
  opacity: .9;
}
.nav-item.active {
  color: #dfe4ff;
  background: var(--grad-soft);
  border-color: rgba(99, 102, 241, .34);
  box-shadow: 0 0 22px -8px rgba(99, 102, 241, .9) inset;
  font-weight: 500;
}
[data-theme="light"] .nav-item.active { color: #3730a3; }
.nav-sep { height: 1px; background: var(--stroke); margin: 8px 4px; }

.user-card {
  display: flex; align-items: center; gap: 8px;
  padding-top: 12px; border-top: 1px solid var(--stroke);
}
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; flex: 1; }
.user-meta strong { font-size: 12px; font-weight: 500; }
.user-meta small {
  font-size: 10.5px; color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout { font-size: 11px; color: var(--faint); }
.logout:hover { color: var(--danger); text-decoration: none; }

.side-tools {
  display: flex; gap: 6px;
  padding-top: 10px; border-top: 1px solid var(--stroke);
}
.tool-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 4px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  color: var(--muted);
  font-size: 10.5px; font-family: inherit;
  cursor: pointer; transition: .2s;
}
.tool-btn:hover { color: var(--text); border-color: var(--stroke-2); }
.tool-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.main {
  flex: 1; min-width: 0;
  max-width: 1180px;
  padding: 4px 6px 40px;
}

.footer {
  margin-top: 34px; padding-top: 14px;
  border-top: 1px solid var(--stroke);
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--faint);
}

/* ---------- 登录 / 认证 ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 56px; align-items: center;
  max-width: 1180px; margin: 0 auto;
  padding: 40px 32px;
}
.auth-hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--stroke); background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: 11px; color: var(--muted); letter-spacing: .06em;
}
.auth-hero .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal); box-shadow: 0 0 10px var(--teal);
  animation: pulse 2.4s infinite;
}
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

.auth-hero h1 {
  font-size: clamp(26px, 3.4vw, 44px); line-height: 1.18;
  letter-spacing: -.025em;
  margin: 20px 0 14px;
}
.auth-hero h1 em {
  font-style: normal;
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.auth-hero .lead { color: var(--muted); font-size: 14px; max-width: 430px; line-height: 1.8; }
.auth-stats { display: flex; gap: 32px; margin-top: 34px; flex-wrap: wrap; }
.auth-stats div span {
  display: block; font-size: 10.5px; color: var(--faint);
  letter-spacing: .1em; text-transform: uppercase; margin-bottom: 2px;
}
.auth-stats div strong {
  font-size: 24px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.auth-card { padding: 32px 28px; max-width: 400px; width: 100%; min-width: 0; box-sizing: border-box; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark { margin: 0 auto 12px; width: 84px; height: 84px; flex-basis: 84px; }
.auth-brand h1 { font-size: 17px; }
.auth-brand p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

/* ---------- 页头 ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-title {
  font-size: 22px; letter-spacing: -.02em;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.page-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 卡片 ---------- */
.card { overflow: hidden; }
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--stroke);
}
.card-head h2 { font-size: 13px; font-weight: 600; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }

/* ---------- 指标卡 ---------- */
.stat {
  padding: 15px 16px;
  overflow: hidden;
  min-height: 96px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.stat::after {
  content: "";
  position: absolute; right: -30px; top: -30px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, .22), transparent 70%);
  pointer-events: none;
}
.stat-label {
  font-size: 10.5px; color: var(--faint);
  letter-spacing: .1em; text-transform: uppercase;
}
.stat-value {
  font-size: 28px; font-weight: 600; line-height: 1.25;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.stat-value small { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  color: var(--text);
  font-size: 12.5px; font-family: inherit; line-height: 1.4;
  cursor: pointer;
  transition: .22s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--glass-3);
  border-color: var(--stroke-2);
  text-decoration: none;
}
.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff; font-weight: 500;
  box-shadow: 0 8px 24px -8px rgba(99, 102, 241, .85);
}
.btn-primary:hover {
  background: var(--grad);
  transform: translateY(-1px);
  box-shadow: 0 12px 30px -8px rgba(99, 102, 241, .95);
}
.btn-danger {
  color: var(--danger);
  border-color: rgba(251, 113, 133, .32);
  background: rgba(251, 113, 133, .12);
}
.btn-danger:hover { background: rgba(251, 113, 133, .2); border-color: rgba(251, 113, 133, .5); }
.btn-sm { padding: 5px 11px; font-size: 11.5px; border-radius: var(--radius-xs); }
.btn-block { width: 100%; padding: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 10.5px; line-height: 1.7;
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge-ok { color: #6ee7b7; background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .3); }
.badge-warn { color: #fcd34d; background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .3); }
.badge-danger { color: #fda4af; background: rgba(244, 63, 94, .12); border-color: rgba(244, 63, 94, .32); }
.badge-primary { color: #a5b4fc; background: rgba(99, 102, 241, .14); border-color: rgba(99, 102, 241, .34); }
[data-theme="light"] .badge-ok { color: #047857; }
[data-theme="light"] .badge-warn { color: #b45309; }
[data-theme="light"] .badge-danger { color: #be123c; }
[data-theme="light"] .badge-primary { color: #4338ca; }

/* ---------- 进度 ---------- */
.progress {
  height: 5px; border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}
[data-theme="light"] .progress { background: rgba(15, 23, 42, .08); }
.progress-bar {
  height: 100%; border-radius: 6px;
  background: var(--grad);
  box-shadow: 0 0 12px rgba(99, 102, 241, .7);
  transition: width .3s;
}
.progress-bar.done {
  background: linear-gradient(135deg, #10b981, #34d399);
  box-shadow: 0 0 12px rgba(52, 211, 153, .6);
}

/* ---------- 提示 ---------- */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.flash {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  border: 1px solid transparent;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.flash-success { color: #6ee7b7; background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .3); }
.flash-error { color: #fda4af; background: rgba(244, 63, 94, .12); border-color: rgba(244, 63, 94, .32); }
[data-theme="light"] .flash-success { color: #047857; }
[data-theme="light"] .flash-error { color: #be123c; }

.empty { padding: 38px 16px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------- 课程卡 ---------- */
.course-card {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .28s, border-color .28s, box-shadow .28s;
}
.course-card:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, .42);
  box-shadow: 0 24px 48px -24px rgba(99, 102, 241, .6), var(--shadow);
  text-decoration: none;
}
.course-cover {
  height: 84px;
  display: flex; align-items: flex-end;
  padding: 10px 14px;
  color: rgba(255, 255, 255, .92);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  position: relative;
  background: var(--grad);
}
.course-cover.has-img { background-size: cover; background-position: center; }
.course-cover::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0, 0, 0, .38));
}
.course-cover span { position: relative; z-index: 1; font-weight: 500; }
.course-body {
  padding: 13px 15px 15px;
  display: flex; flex-direction: column; gap: 9px; flex: 1;
}
.course-title { font-size: 13.5px; font-weight: 500; line-height: 1.45; color: var(--text); }
.course-desc {
  font-size: 11.5px; color: var(--faint); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 37px;
}
.course-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 11px; color: var(--faint);
  margin-top: auto;
}

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; gap: 4px;
  padding: 4px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  margin-bottom: 16px;
  overflow-x: auto;
  width: fit-content;
  max-width: 100%;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.tab {
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: .2s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active {
  background: var(--grad);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 4px 16px -4px rgba(99, 102, 241, .8);
}

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table th, .table td { white-space: nowrap; }
table.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 11px 16px;
  border-bottom: 1px solid var(--stroke);
  white-space: nowrap;
}
.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .18s; }
.table tbody tr:hover { background: rgba(255, 255, 255, .035); }
[data-theme="light"] .table tbody tr:hover { background: rgba(99, 102, 241, .05); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > label {
  font-size: 11px; color: var(--faint);
  letter-spacing: .06em; text-transform: uppercase;
}
input:not([type]), input[type=text], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: .2s;
}
[data-theme="light"] input:not([type]),
[data-theme="light"] input[type=text], [data-theme="light"] input[type=password],
[data-theme="light"] input[type=number], [data-theme="light"] input[type=date],
[data-theme="light"] input[type=datetime-local], [data-theme="light"] select,
[data-theme="light"] textarea { background: rgba(255, 255, 255, .92); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(99, 102, 241, .7);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .16);
  background: var(--glass-3);
}
select option { background: #10141f; color: #eaeefb; }
[data-theme="light"] select option { background: #fff; color: #0f172a; }
textarea { resize: vertical; min-height: 72px; }
input[type=file] { padding: 8px 10px; font-size: 12px; }

/* 去掉原生控件外观，统一成玻璃风格 */
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b96ad' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
  cursor: pointer;
}
input[type=file]::-webkit-file-upload-button,
input[type=file]::file-selector-button {
  margin-right: 10px;
  padding: 5px 11px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--stroke-2);
  background: var(--glass-3);
  color: var(--text);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
}

.hint { font-size: 11px; color: var(--faint); }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline > .field { margin-bottom: 0; flex: 1 1 160px; }
.checkline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.checkline input { width: auto; accent-color: var(--primary); }

details summary { color: var(--accent-2); font-size: 11.5px; cursor: pointer; }
[data-theme="light"] details summary { color: #0891b2; }

/* ---------- 学习页 ---------- */
.learn-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}
.player {
  background: #0b0f19;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
  color: var(--faint);
  font-size: 12.5px;
  box-shadow: var(--shadow);
}
.player video { width: 100%; height: 100%; display: block; background: #000; }
.lesson-doc { aspect-ratio: auto; min-height: 320px; background: var(--glass); }
.lesson-text { padding: 20px 22px; font-size: 13.5px; line-height: 1.85; color: var(--text-2); }

/* 文档分页阅读器 */
.doc-viewer {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 74vh; overflow-y: auto;
  padding: 10px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
.doc-page {
  margin: 0;
  flex: 0 0 auto;      /* 关键：否则 flex 容器会把每页压扁 */
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .8);
}
.doc-page img { display: block; width: 100%; height: auto; }
.doc-end {
  text-align: center;
  padding: 14px 10px 6px;
  border-top: 1px dashed var(--stroke);
}

.lesson-list { max-height: 470px; overflow-y: auto; }
.lesson-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text-2);
  border-bottom: 1px solid var(--line-soft);
  transition: .18s;
}
.lesson-item:last-child { border-bottom: none; }
.lesson-item:hover { background: var(--glass-2); text-decoration: none; color: var(--text); }
.lesson-item.active {
  background: var(--grad-soft);
  color: #dfe4ff;
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--primary);
}
[data-theme="light"] .lesson-item.active { color: #3730a3; }
.lesson-item .idx { color: var(--faint); font-size: 10.5px; min-width: 20px; }
.lesson-item .tick { margin-left: auto; color: var(--teal); font-size: 10.5px; white-space: nowrap; }
.chapter-label {
  padding: 10px 14px 4px;
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--glass);
  position: sticky; top: 0;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}

/* ---------- 考试 ---------- */
.exam-q { padding: 16px; border-bottom: 1px solid var(--stroke); }
.exam-q:last-child { border-bottom: none; }
.exam-stem { font-size: 13.5px; margin-bottom: 11px; line-height: 1.7; }
.exam-stem .no { color: var(--faint); margin-right: 5px; }
.option {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  margin-bottom: 7px;
  cursor: pointer;
  font-size: 12.5px;
  background: var(--glass);
  transition: .15s;
}
.option:hover { border-color: var(--stroke-2); background: var(--glass-2); }
.option input { margin-top: 3px; width: auto; accent-color: var(--primary); }
.option.correct {
  border-color: rgba(16, 185, 129, .45);
  background: rgba(16, 185, 129, .12);
  color: #a7f3d0;
}
.option.wrong {
  border-color: rgba(244, 63, 94, .45);
  background: rgba(244, 63, 94, .12);
  color: #fecdd3;
}
[data-theme="light"] .option.correct { color: #065f46; }
[data-theme="light"] .option.wrong { color: #9f1239; }

.exam-timer {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 15px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font-size: 12.5px;
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}
.exam-timer.urgent {
  color: var(--danger);
  border-color: rgba(244, 63, 94, .45);
  background: rgba(244, 63, 94, .14);
}

.score-hero { text-align: center; padding: 28px 16px; }
.score-num {
  font-size: 46px; font-weight: 600; line-height: 1.1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.score-num.pass { background: linear-gradient(135deg, #10b981, #34d399); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-num.fail { background: linear-gradient(135deg, #e11d48, #fb7185); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- 证书（保持纸张质感） ---------- */
.cert-frame {
  border: 2px solid #c8b273;
  border-radius: 8px;
  padding: 36px 32px;
  background: var(--cert-bg);
  color: var(--cert-text);
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
}
.cert-frame h1 { font-size: 22px; letter-spacing: 5px; margin-bottom: 6px; }
.cert-frame .sub { color: #8a7f63; font-size: 11px; letter-spacing: 2px; }
.cert-name {
  font-size: 20px; margin: 22px 0 6px;
  border-bottom: 1px solid var(--cert-line);
  display: inline-block; padding: 0 26px 6px;
}
.cert-course { font-size: 14px; margin: 12px 0; }
.cert-meta {
  display: flex; justify-content: space-between;
  font-size: 11px; color: #8a7f63; margin-top: 30px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
  .auth-shell { gap: 32px; padding: 32px 24px; }
}

@media (max-width: 1000px) {
  .learn-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-shell { grid-template-columns: 1fr; gap: 32px; padding: 28px 20px; }
  .auth-hero h1 { font-size: 32px; }
  .auth-card { max-width: none; }
}

@media (max-width: 780px) {
  /* 顶部固定栏 */
  .mobile-bar {
    display: flex; align-items: center; gap: 8px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 45;
    height: 54px; padding: 0 12px;
    background: rgba(10, 14, 26, .74);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid var(--stroke);
  }
  [data-theme="light"] .mobile-bar { background: rgba(255, 255, 255, .78); }
  .mb-brand { display: flex; align-items: center; gap: 8px; color: var(--text); min-width: 0; }
  .mb-brand:hover { text-decoration: none; }
  .mb-brand .brand-mark { width: 28px; height: 28px; flex-basis: 28px; }
  .mb-brand strong {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mb-spacer { flex: 1; }

  /* 外壳：上下留出固定栏空间 */
  .shell {
    display: block;
    padding: 0;
    padding-top: 54px;
    padding-bottom: calc(var(--tabbar-h, 68px) + 14px + env(safe-area-inset-bottom));
    min-height: 100vh;
  }

  /* 侧栏变底部标签栏 */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto; max-height: 46vh;
    z-index: 45;
    flex-direction: row; align-items: stretch; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    border: 1px solid var(--stroke);
    border-bottom: none;
    background: rgba(10, 14, 26, .82);
    -webkit-backdrop-filter: blur(22px) saturate(170%);
    backdrop-filter: blur(22px) saturate(170%);
    overflow: visible;
  }
  [data-theme="light"] .sidebar { background: rgba(255, 255, 255, .88); }
  .sidebar::before { display: none; }
  .sidebar .brand,
  .sidebar .user-card,
  .sidebar .side-tools,
  .sidebar .nav-sep { display: none; }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px;
    flex: 1;
    overflow: visible;
  }
  .nav-item {
    flex: 1 0 19%;
    min-width: 56px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 7px 2px;
    font-size: 10px;
    line-height: 1.2;
    border-radius: 11px;
    text-align: center;
    min-height: 50px;
  }
  .nav-item svg { width: 19px; height: 19px; flex-basis: 19px; }
  .nav-item.active { box-shadow: none; }

  /* 主内容区 */
  .main { padding: 14px 12px 0; max-width: none; }
  .page-head { gap: 10px; margin-bottom: 14px; align-items: flex-start; }
  .page-title { font-size: 18px; line-height: 1.35; }
  .page-sub { font-size: 11.5px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  /* 网格：统计两列，其余单列 */
  .grid { gap: 10px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .stat { min-height: 78px; padding: 12px 13px; }
  .stat-value { font-size: 21px; }
  .stat-value small { font-size: 10.5px; }
  .stat-label { font-size: 9.5px; letter-spacing: .08em; }

  .card { border-radius: 15px; }
  .card + .card { margin-top: 10px; }
  .card-head { padding: 11px 13px; }
  .card-body { padding: 13px; }

  /* 触控友好 */
  .btn { min-height: 42px; padding: 10px 15px; font-size: 13px; }
  .btn-sm { min-height: 34px; padding: 7px 12px; font-size: 12px; }
  .tab { padding: 8px 15px; font-size: 12.5px; }
  .tabs { width: 100%; }
  input:not([type]), input[type=text], input[type=password], input[type=number],
  input[type=date], input[type=datetime-local], select, textarea {
    font-size: 16px;   /* 防止 iOS 聚焦时页面缩放 */
    padding: 11px 12px;
  }
  .field > label { font-size: 11px; }

  /* 表格：横向滚动 + 触感滚动 */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 2px;
  }
  .table-wrap::before {
    content: "表格可左右滑动查看";
    display: block;
    padding: 8px 13px 4px;
    font-size: 10px;
    color: var(--faint);
    letter-spacing: .04em;
  }
  .table { min-width: 560px; }
  .table th, .table td { padding: 9px 11px; }

  /* 课程卡 */
  .course-cover { height: 66px; }
  .course-body { padding: 11px 12px 12px; gap: 7px; }
  .course-title { font-size: 13px; }
  .course-desc { min-height: auto; -webkit-line-clamp: 2; font-size: 11px; }

  /* 学习页 */
  .learn-layout { gap: 10px; }
  .lesson-list { max-height: 260px; }
  .lesson-item { padding: 11px 13px; font-size: 12.5px; }
  .chapter-label { padding: 9px 13px 4px; }
  .player { border-radius: 15px; }
  .lesson-text { padding: 15px 16px; font-size: 13.5px; }
  .learn-nav {
    position: sticky;
    bottom: calc(var(--tabbar-h, 68px) + 10px);
    z-index: 20;
    background: rgba(10, 14, 26, .82);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 1px solid var(--stroke);
    border-radius: 14px;
    padding: 9px 11px;
  }
  [data-theme="light"] .learn-nav { background: rgba(255, 255, 255, .88); }

  /* 考试 */
  .exam-q { padding: 13px; }
  .option { padding: 12px; font-size: 13px; }
  .exam-submit {
    position: sticky;
    bottom: calc(var(--tabbar-h, 68px) + 10px);
    z-index: 20;
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin-top: 12px;
    padding: 10px 11px;
    border-radius: 14px;
    background: rgba(10, 14, 26, .82);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 1px solid var(--stroke);
  }
  [data-theme="light"] .exam-submit { background: rgba(255, 255, 255, .88); }
  .exam-submit .btn { flex: 1; }
  .exam-timer { padding: 6px 13px; font-size: 12px; }
  .score-num { font-size: 40px; }

  /* 证书 */
  .cert-frame { padding: 22px 15px; }
  .cert-frame h1 { font-size: 17px; letter-spacing: 3px; }
  .cert-name { font-size: 17px; padding: 0 16px 5px; }
  .cert-course { font-size: 12.5px; }
  .cert-meta { flex-direction: column; gap: 4px; align-items: center; margin-top: 20px; }

  .auth-shell { padding: 24px 16px; gap: 26px; }
  .auth-hero h1 { font-size: 30px; margin: 14px 0 10px; }
  .auth-hero .lead { font-size: 13px; }
  .auth-stats { gap: 22px; margin-top: 22px; }
  .auth-stats div strong { font-size: 20px; }
  .auth-card { padding: 24px 18px; }

  .footer { margin-top: 22px; font-size: 10.5px; gap: 10px; }
  .flashes { margin-bottom: 10px; }
  .empty { padding: 30px 12px; }

  /* 防止任何元素撑破视口导致横向晃动 */
  html, body { overflow-x: hidden; }
}

@media (max-width: 400px) {
  .nav-item { flex: 1 0 24%; min-width: 52px; font-size: 9.5px; }
  .stat-value { font-size: 19px; }
  .mb-brand strong { font-size: 12px; }
}

@media print {
  .sidebar, .footer, .page-actions, .flashes, .aurora, #particles, .grid-overlay { display: none !important; }
  .shell { padding: 0; display: block; }
  .main { padding: 0; max-width: none; }
  html, body { background: #fff !important; color: #000 !important; }
  .card, .stat, .cert-frame {
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
    background: #fff !important; border-color: #ddd !important;
  }
  .cert-frame { border-color: #c8b273 !important; }
}
