:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --line: #e5e5ea;
  --fill: #f2f2f7;
  --blue: #007aff;
  --blue-soft: #eaf3ff;
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, .12);
  --red: #ff3b30;
  --orange: #ff9500;
  --purple: #af52de;
  --shadow: 0 2px 16px rgba(0,0,0,.06);
  --sidebar: 232px;
  --header: #ffffff;
  --input-bg: #ffffff;
  --boot-bg: #f7f8fc;
}

/* 仅浅色主题：系统深色偏好也强制用浅色，避免跟随系统变黑 */
@media (prefers-color-scheme: dark) {
  :root { color-scheme: light; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--boot-bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--card); border-radius: 24px; padding: 44px 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.1);
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, #0a84ff, #0056d6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; margin-bottom: 22px;
}
.login-title { font-size: 26px; font-weight: 700; margin: 0 0 8px; }
.login-sub { color: var(--text-3); font-size: 13px; margin: 0 0 30px; line-height: 1.6; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-2); }
.field input {
  width: 100%; height: 48px; border: 1px solid var(--line);
  border-radius: 12px; padding: 0 16px; outline: none; background: var(--input-bg);
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,.12); }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 46px; padding: 0 20px; border: none; border-radius: 12px;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 14px;
  transition: opacity .2s, transform .1s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--fill); color: var(--text); }
.btn-danger { background: var(--red); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 9px; }
.login-error { color: var(--red); font-size: 13px; margin-bottom: 14px; min-height: 18px; }
.login-foot { margin-top: 22px; text-align: center; font-size: 12px; color: var(--text-3); line-height: 1.7; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--header);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  height: 72px; padding: 0 22px; border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, #0a84ff, #0056d6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-weight: 500; margin-bottom: 3px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--fill); }
.nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.nav-badge { margin-left: auto; font-size: 11px; color: var(--text-3); }
.sidebar-foot { padding: 16px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.user-chip:hover { background: var(--fill); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft);
  color: var(--blue); display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex: none;
}
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 11px; color: var(--text-3); }

.main { flex: 1; min-width: 0; }
.topbar {
  height: 72px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 34px; border-bottom: 1px solid var(--line); background: var(--header);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 19px; font-weight: 700; }
.topbar-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.content { padding: 28px 34px 60px; max-width: 1280px; margin: 0 auto; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card); border-radius: 16px; padding: 22px;
  box-shadow: var(--shadow); border: 1px solid rgba(0,0,0,.02);
}
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; margin: 30px 0 14px;
}
.section-title::before {
  content: ''; width: 4px; height: 18px; border-radius: 2px; background: var(--blue);
}
.section-title .action { margin-left: auto; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; gap: 16px; }
.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)); }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* 概览卡 */
.overview {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
}
.stat {
  background: var(--card); border-radius: 16px; padding: 22px 24px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 13px; color: var(--text-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.blue { background: var(--blue); } .dot.green { background: var(--green); }
.dot.orange { background: var(--orange); } .dot.purple { background: var(--purple); }
.stat-value { font-size: 34px; font-weight: 700; line-height: 1.1; margin: 14px 0 6px; }
.stat-foot { font-size: 12px; color: var(--text-3); }

/* 状态标签 */
.tag {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; background: var(--fill); color: var(--text-2);
}
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: rgba(255,59,48,.12); color: var(--red); }
.tag.orange { background: rgba(255,149,0,.14); color: var(--orange); }
.tag.purple { background: rgba(175,82,222,.12); color: var(--purple); }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; background: var(--card); border-radius: 13px;
  box-shadow: var(--shadow);
}
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .desc { font-size: 12px; color: var(--text-3); margin-top: 5px; }

/* 表格 */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); }
th { color: var(--text-3); font-weight: 600; font-size: 12px; background: var(--fill); }
tr:last-child td { border-bottom: none; }
td .actions { display: flex; gap: 12px; }
.link { color: var(--blue); cursor: pointer; }
.link.danger { color: var(--red); }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.input {
  height: 40px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 13px; outline: none; background: var(--input-bg); min-width: 200px;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,.1); }
.pills { display: flex; gap: 6px; }
.pill {
  padding: 8px 15px; border-radius: 9px; background: var(--fill);
  color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500;
}
.pill.active { background: var(--blue); color: #fff; }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-mark {
  width: 64px; height: 64px; border-radius: 50%; background: var(--fill);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 16px;
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* 模态 */
.mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.42);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
  background: var(--card); border-radius: 20px; padding: 26px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; line-height: 1.5; word-break: break-word; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* 已提交题：只读查看 */
.answer-panel {
  margin-top: 16px; padding: 16px; border-radius: 12px;
  background: var(--green-soft); border: 1px solid rgba(52,199,89,.18);
}
.answer-panel-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.answer-panel-value {
  font-size: 15px; font-weight: 600; line-height: 1.6;
  color: var(--text); word-break: break-word; white-space: pre-wrap;
}
.answer-panel-note { margin-top: 12px; font-size: 12px; color: var(--text-3); }
.ro-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ro-opt {
  display: flex; align-items: center; gap: 12px; min-height: 44px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--input-bg);
}
.ro-opt.mine { border-color: var(--green); background: var(--green-soft); }
.ro-opt-key {
  width: 26px; height: 26px; flex: none; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--fill); color: var(--text-2); font-weight: 700; font-size: 13px;
}
.ro-opt.mine .ro-opt-key { background: var(--green); color: #fff; }
.ro-opt-label { flex: 1; min-width: 0; word-break: break-word; line-height: 1.5; }
.ro-opt-mine { flex: none; font-size: 11px; font-weight: 600; color: var(--green); }

/* 多堂课切换器 */
.lesson-switch { margin-bottom: 16px; padding: 16px 18px; }
.lesson-switch-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-bottom: 12px;
}
.lesson-switch-head b { color: var(--blue); font-size: 15px; }
.lesson-pills {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.lesson-pill {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 8px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--input-bg);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  max-width: 260px; transition: border-color .15s, background .15s, color .15s;
}
.lesson-pill:hover { border-color: var(--blue); color: var(--blue); }
.lesson-pill.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.lesson-pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.lesson-pill-dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.lesson-pill-cur { font-size: 10px; padding: 2px 6px; border-radius: 5px; background: var(--blue); color: #fff; flex: none; }

/* 提示 */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; padding: 11px 20px;
  border-radius: 10px; font-size: 13px; z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}

/* 课件 */
.slide-stage {
  background: #000; border-radius: 14px; overflow: hidden;
  aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center;
}
.slide-stage img { width: 100%; height: 100%; object-fit: contain; }
.slide-placeholder { color: #8e8e93; font-size: 14px; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; }
.thumb {
  width: 92px; height: 54px; border-radius: 7px; overflow: hidden;
  border: 2px solid transparent; cursor: pointer; flex: none; background: var(--fill);
}
.thumb.active { border-color: var(--blue); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* 答题助手 */
.assistant-box { border-left: 3px solid var(--blue); background: var(--blue-soft); padding: 14px 16px; border-radius: 10px; }
.answer-text { line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

/* 移动端：只用一条顶部导航（.mobile-nav），紧跟 topbar 吸顶；桌面侧边栏彻底隐藏。
   导航在上方，不再占据底部，内容不需要为底栏留白。 */
.mobile-nav { display: none; }
@media (max-width: 900px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .shell { display: block; }
  .topbar { padding: 0 18px; height: 60px; }
  .content { padding: 18px 16px 30px; }
  .overview, .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .mobile-nav {
    position: sticky; top: 60px;
    height: 54px;
    background: var(--header); border-bottom: 1px solid var(--line);
    display: flex; z-index: 9;
  }
  .mobile-nav .nav-item {
    flex: 1; flex-direction: row; gap: 6px; padding: 6px 2px;
    margin: 0; border-radius: 0; font-size: 12px; justify-content: center;
    min-height: 48px;
  }
  .mobile-nav .nav-item.active { background: transparent; color: var(--blue); }
  .mobile-nav .nav-icon { font-size: 17px; }
}

/* ---------- 首页：当前课程 + 到期倒计时 ---------- */
.hero-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 28px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0a84ff 0%, #0056d6 100%);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 8px 26px rgba(10, 132, 255, .24);
}
.hero-card::after {
  content: '';
  position: absolute;
  right: -40px; top: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  pointer-events: none;
}
.hero-label { font-size: 12px; opacity: .8; margin-bottom: 8px; }
.hero-title { font-size: 21px; font-weight: 700; line-height: 1.35; }
.hero-sub { font-size: 13px; opacity: .85; margin-top: 6px; }
.hero-icon { font-size: 44px; opacity: .85; flex: none; z-index: 1; }

.expiry-card {
  display: flex;
  align-items: center;
  gap: 16px;
}
.expiry-ring {
  width: 62px; height: 62px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  background: var(--blue-soft); color: var(--blue);
}
.expiry-ring.warn { background: rgba(255,149,0,.14); color: var(--orange); }
.expiry-ring.danger { background: rgba(255,59,48,.14); color: var(--red); }
.expiry-main { flex: 1; min-width: 0; }
.expiry-title { font-size: 15px; font-weight: 700; }
.expiry-desc { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.expiry-days { font-size: 26px; font-weight: 700; color: var(--blue); white-space: nowrap; }
.expiry-days.warn { color: var(--orange); }
.expiry-days.danger { color: var(--red); }

@media (max-width: 900px) {
  .hero-card { padding: 20px; gap: 12px; }
  .hero-title { font-size: 18px; }
  .hero-icon { font-size: 34px; }
  .expiry-card { gap: 12px; }
  .expiry-ring { width: 52px; height: 52px; font-size: 18px; }
  .expiry-days { font-size: 21px; }
}

/* 随堂题网格：默认每行 5 个方形卡片 */
.prob-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.prob-grid .prob-card { min-width: 0; }
/* PPT 封面：保持 16:9 完整显示，绝不裁掉幻灯片两侧（题干会被切字） */
.cover-box {
  width: 100%; aspect-ratio: 16/9; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--fill); border-radius: 8px 8px 0 0;
}
.cover-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cover-ph { display: none; color: var(--text-3); font-size: 26px; }
.cover-box.cover-failed img { display: none; }
.cover-box.cover-failed .cover-ph { display: block; }
@media (max-width: 1180px) { .prob-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 960px)  { .prob-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .prob-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ================= 手机端适配 ================= */
@media (max-width: 720px) {
  html, body {
    font-size: 15px; -webkit-text-size-adjust: 100%;
    max-width: 100%; overflow-x: clip;
  }
  .shell { display: block; }

  /* 唯一一条顶部导航：桌面侧边栏保持隐藏，不再复制出第二条 */
  .sidebar, .brand, .sidebar-foot, .nav-badge { display: none; }
  .mobile-nav { top: 56px; height: 52px; }
  .mobile-nav .nav-item { min-height: 48px; font-size: 12px; }
  .mobile-nav .nav-icon { font-size: 18px; }

  /* 顶部栏与内容：不横向溢出 */
  .topbar { height: 56px; padding: 0 16px; }
  .topbar-title { font-size: 17px; }
  .topbar-sub { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding: 16px 14px 24px; max-width: 100%; }
  .card { padding: 16px; border-radius: 14px; overflow-wrap: anywhere; }
  .section-title { font-size: 15px; margin: 22px 0 10px; }
  .spread { flex-wrap: wrap; }
  .row { flex-wrap: wrap; gap: 8px; }
  .list { min-width: 0; }
  .empty { padding: 40px 16px; }
  .empty p, .answer-text, .log-text, .modal-title { overflow-wrap: anywhere; word-break: break-word; }
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* 触控目标不小于 44px；输入 16px 防 iOS 聚焦自动放大 */
  .btn { min-height: 46px; }
  .btn-sm { min-height: 42px; padding: 0 14px; }
  input, textarea, select, .input, .field input { font-size: 16px; }
  .input { min-width: 0; width: 100%; }
  .field input { height: 48px; }
  .ro-opt { min-height: 48px; }
  .pills { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pill { flex: none; white-space: nowrap; min-height: 42px; display: inline-flex; align-items: center; }

  /* 登录卡片 */
  .login-page { padding: 16px; align-items: flex-start; padding-top: max(32px, env(safe-area-inset-top, 0px)); }
  .login-card { padding: 30px 22px 26px; border-radius: 20px; }
  .login-logo { width: 56px; height: 56px; font-size: 26px; margin-bottom: 18px; }
  .login-title { font-size: 23px; }

  /* 多堂课切换器：横向滑动，胶囊够大好点 */
  .lesson-switch { padding: 14px; }
  .lesson-switch-head { font-size: 12px; }
  .lesson-pills { margin: 0 -14px; padding: 0 14px 4px; }
  .lesson-pill { min-height: 44px; max-width: 70vw; font-size: 13px; }

  /* 随堂题：手机 2 列，超小屏 1 列 */
  .prob-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .prob-grid .card { border-radius: 12px; }
  .prob-card .small, .prob-card div { overflow-wrap: anywhere; }

  /* 弹窗：贴底全宽 sheet，安全区留白，底部按钮常驻 */
  .mask { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important; width: 100% !important;
    max-height: 92vh !important; max-height: 92dvh !important;
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .modal img { max-width: 100%; }
  .modal-title { font-size: 16px; }
  .modal-foot {
    position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom, 0px));
    background: var(--card);
    margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
  }
  .modal-foot .btn { flex: 1; min-height: 46px; }
  .modal-foot .btn-ghost { flex: 0 0 34%; }

  .toast {
    top: calc(12px + env(safe-area-inset-top, 0px));
    max-width: calc(100% - 32px); text-align: center;
  }
}

@media (max-width: 420px) {
  .prob-grid { grid-template-columns: 1fr; }
  .overview, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .cfg-grid { grid-template-columns: 1fr; }
}

/* ===== 穿山甲：AI / 日志 / 配置 ===== */
.ai-box {
  border-left: 3px solid var(--purple);
  background: var(--blue-soft);
  padding: 12px 14px;
  border-radius: 10px;
}
.ai-box.err { border-left-color: var(--red); background: rgba(255,59,48,.08); }
.ai-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.ai-answer { margin-top: 8px; font-size: 14px; line-height: 1.6; word-break: break-word; }

.divider { height: 1px; background: var(--fill, var(--border)); margin: 10px 0; opacity: .6; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 14px; }
.btn-xs { padding: 5px 10px; font-size: 12px; }

.log-list { display: flex; flex-direction: column; }
.log-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--fill, var(--border));
  font-size: 13px; line-height: 1.5;
}
.log-row:last-child { border-bottom: none; }
.log-time { color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; font-size: 12px; }
.log-text { word-break: break-word; flex: 1; min-width: 0; }
.log-row .tag { flex: none; text-transform: uppercase; font-size: 10px; }

@media (max-width: 600px) {
  .cfg-grid { grid-template-columns: 1fr 1fr; }
  .log-row { flex-wrap: wrap; gap: 6px; }
  .log-text { width: 100%; }
}

/* ================= 手机端视觉增强 v2 ================= */
@media (max-width: 720px) {
  :root { --m-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 22px rgba(0,0,0,.05); }

  /* 禁止整页橡皮筋回弹与横向抖动；弹窗/列表内部仍可正常滚动 */
  html, body { overscroll-behavior-y: contain; overflow-x: hidden; }
  .content, .list, .modal { overscroll-behavior: contain; }

  /* 顶栏 / 顶部导航：毛玻璃 + 细分隔线，滚动时内容从下方透出。
     吸顶位置叠加安全区，刘海屏下顶栏不会被状态栏压住。 */
  .topbar {
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(56px + env(safe-area-inset-top, 0px));
  }
  .mobile-nav {
    border-bottom: 1px solid var(--line);
    box-shadow: 0 6px 22px rgba(0,0,0,.06);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    top: calc(56px + env(safe-area-inset-top, 0px));
  }
  @supports (background: color-mix(in srgb, red 50%, transparent)) {
    .topbar { background: color-mix(in srgb, var(--header) 86%, transparent); }
    .mobile-nav { background: color-mix(in srgb, var(--header) 90%, transparent); }
  }

  /* 卡片：统一圆角、细边框、更柔和的双层阴影 */
  .card, .stat, .list-item, .table-wrap {
    border-radius: 18px;
    border: 1px solid var(--line);
    box-shadow: var(--m-shadow);
  }
  .content > .card + .card { margin-top: 14px; }

  /* 主按钮：渐变 + 轻投影 + 明确的按压反馈 */
  .btn {
    border-radius: 13px;
    background: linear-gradient(135deg, #0a84ff, #0060df);
    box-shadow: 0 5px 14px rgba(0,122,255,.20);
    transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
  }
  .btn:active { transform: scale(.97); box-shadow: 0 2px 7px rgba(0,122,255,.16); }
  .btn-ghost, .btn-danger { box-shadow: none; }
  .btn-ghost { background: var(--fill); }
  .btn-danger { background: linear-gradient(135deg, #ff453a, #d92b20); }

  /* 顶部导航：选中项顶部指示条 + 图标胶囊 */
  .mobile-nav .nav-item {
    position: relative; margin: 0 2px; border-radius: 12px;
    transition: color .18s ease, background .18s ease;
  }
  .mobile-nav .nav-item.active { background: transparent; color: var(--blue); }
  .mobile-nav .nav-item.active::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--blue);
  }
  .mobile-nav .nav-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 28px; border-radius: 9px; transition: background .18s ease;
  }
  .mobile-nav .nav-item.active .nav-icon { background: var(--blue-soft); }

  /* 分区标题：渐变色条 */
  .section-title::before {
    width: 4px; height: 16px; border-radius: 3px;
    background: linear-gradient(180deg, var(--blue), var(--purple));
  }

  /* 状态标签：全圆角胶囊 */
  .tag { border-radius: 999px; padding: 4px 10px; letter-spacing: .2px; }
  .pill { border-radius: 11px; }
  .pill.active { box-shadow: 0 4px 12px rgba(0,122,255,.22); }

  /* 课程切换器：淡蓝底 + 实心选中胶囊 */
  .lesson-switch {
    border-radius: 18px;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, var(--blue-soft), var(--card) 72%);
    box-shadow: var(--m-shadow);
  }
  .lesson-pill { border-radius: 12px; }
  .lesson-pill.active {
    background: var(--blue); border-color: var(--blue); color: #fff;
    box-shadow: 0 5px 14px rgba(0,122,255,.26);
  }
  .lesson-pill.active .lesson-pill-cur { background: rgba(255,255,255,.24); }
  .lesson-pill.active .lesson-pill-dot.live { box-shadow: 0 0 0 3px rgba(255,255,255,.28); }

  /* 随堂题卡片：封面下沿细线 + 轻微按压反馈 */
  .prob-grid .card, .prob-card {
    border: 1px solid var(--line);
    transition: transform .16s ease, box-shadow .16s ease;
  }
  .prob-grid .card:active, .prob-card:active { transform: scale(.985); }
  .cover-box { border-bottom: 1px solid var(--line); }

  /* 弹窗：上滑 sheet + 顶部把手 + 更柔的投影 */
  .mask { background: rgba(0,0,0,.52); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
  .modal {
    position: relative;
    border-radius: 22px 22px 0 0;
    padding-top: 28px;
    box-shadow: 0 -12px 42px rgba(0,0,0,.2);
    animation: cx-sheet-in .26s cubic-bezier(.22,.8,.3,1);
  }
  .modal::before {
    content: ''; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 4px;
    background: var(--text-3); opacity: .4;
  }
  .modal-foot .btn { border-radius: 13px; }

  /* 输入框聚焦态更清晰 */
  .input, .field input {
    border-radius: 12px;
    transition: border-color .18s ease, box-shadow .18s ease;
  }
  .input:focus, .field input:focus, textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-soft);
  }
}

@keyframes cx-sheet-in {
  from { transform: translateY(26px); opacity: .55; }
  to   { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .modal, .btn, .prob-grid .card, .prob-card, .mobile-nav .nav-item {
    animation: none !important; transition: none !important;
  }
}
