/* ============================================================
 * 中文学习系统 · 前台移动端样式 mobile.css
 * 移动优先；PC 端居中内容列（min-width:640px 最大 720px）
 * 与后台 admin.css 隔离，仅前台页面加载
 * ============================================================ */
:root {
  --primary: #3b5bdb;
  --primary-dark: #2f4bc0;
  --primary-light: #edf2ff;
  --danger: #e03131;
  --success: #2f9e44;
  --warning: #f08c00;
  --text: #1f2937;
  --text-sub: #6b7280;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --gap: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* PC 端居中内容列 */
.page { max-width: 100%; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
@media (min-width: 640px) { body { background: #e9ebf2; } .page { max-width: 720px; box-shadow: 0 0 24px rgba(0,0,0,.06); } }
@media (min-width: 1024px) { .page { max-width: 900px; } }

/* ---------- 顶部栏 ---------- */
.navbar {
  height: 50px; background: var(--card); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--border);
}
.navbar .nav-title { font-size: 17px; font-weight: 600; }
.navbar .nav-left, .navbar .nav-right { display: flex; align-items: center; gap: 12px; }
.navbar i { font-size: 22px; cursor: pointer; color: var(--text); }

/* ---------- 底部页签 ---------- */
.tabbar {
  position: sticky; bottom: 0; left: 0; right: 0; height: 56px; background: var(--card);
  border-top: 1px solid var(--border); display: flex; z-index: 30; margin-top: auto;
}
@media (min-width: 640px) { .tabbar { max-width: 720px; left: 50%; transform: translateX(-50%); } }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-sub); font-size: 11px; }
.tabbar a i { font-size: 22px; }
.tabbar a.active { color: var(--primary); }
.tabbar a.active i { font-weight: 600; }

/* ---------- 内容区 ---------- */
.body { flex: 1; padding: 12px 16px 20px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); }
.section-title { font-size: 16px; font-weight: 600; margin: 6px 0 12px; }
.muted { color: var(--text-sub); font-size: 13px; }

/* ---------- 宫格入口 ---------- */
.grid-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (min-width: 640px) { .grid-nav { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); } }
.grid-nav .cell { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; background: var(--card); border-radius: var(--radius); font-size: 12px; text-align: center; }
.grid-nav .cell i { font-size: 26px; color: var(--primary); }
.grid-nav .cell.soon i { color: #adb5bd; }
.grid-nav .cell.soon { color: var(--text-sub); }

/* ---------- 课程卡片 ---------- */
.course-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.course-item:last-child { border-bottom: none; }
.course-item .thumb { width: 96px; height: 68px; border-radius: 8px; object-fit: cover; background: var(--primary-light); flex: none; }
.course-item .info { flex: 1; min-width: 0; }
.course-item .info h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 视频 ---------- */
.video-box { width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-box video { width: 100%; display: block; max-height: 56vw; }
@media (min-width: 640px) { .video-box video { max-height: 400px; } }

/* ---------- 题目 ---------- */
.q-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.q-item .q-stem { font-weight: 600; margin-bottom: 10px; }
.q-opt { display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.q-opt.sel { border-color: var(--primary); background: var(--primary-light); }
.q-opt .k { font-weight: 600; color: var(--primary); }
.q-item textarea { width: 100%; min-height: 90px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; font-family: inherit; }
.q-correct { color: var(--success); }
.q-wrong { color: var(--danger); }

/* ---------- 考试严肃模式 ---------- */
.exam-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 40; }
.exam-timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.exam-warn-bar { background: #fff3bf; color: #946200; padding: 8px 16px; font-size: 13px; text-align: center; }

/* ---------- 按钮 ---------- */
.btn { height: 44px; padding: 0 20px; border: none; border-radius: 10px; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 14px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; color: var(--text-sub); font-size: 13px; }
.input, .field input, .field select, .field textarea {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; background: #fff; outline: none; color: var(--text);
}
.field textarea { height: auto; min-height: 90px; padding: 10px 12px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.tag-ok { background: #ebfbee; color: var(--success); }
.tag-no { background: #fff5f5; color: var(--danger); }
.tag-warn { background: #fff9db; color: var(--warning); }
.tag-info { background: var(--primary-light); color: var(--primary); }

/* ---------- 录音 ---------- */
.recorder { display: flex; align-items: center; gap: 12px; }
.rec-btn { width: 54px; height: 54px; border-radius: 50%; background: var(--danger); color: #fff; border: none; display: flex; align-items: center; justify-content: center; }
.rec-btn i { font-size: 24px; }
.rec-btn.recording { animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224,49,49,.5); } 100% { box-shadow: 0 0 0 14px rgba(224,49,49,0); } }
audio { width: 100%; margin-top: 8px; }

/* ---------- 登录 ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; background: linear-gradient(160deg, #3b5bdb 0%, #5f3dc4 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 28px 22px; width: 100%; max-width: 400px; margin: 0 auto; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-sub); font-size: 13px; margin-bottom: 22px; }
.role-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.role-tabs button { flex: 1; height: 40px; border: 1px solid var(--border); background: #fff; border-radius: 10px; font-size: 14px; cursor: pointer; color: var(--text-sub); }
.role-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--text-sub); }
.empty i { font-size: 48px; opacity: .4; display: block; margin-bottom: 10px; }

/* ---------- 列表项通用 ---------- */
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-main h4 { font-size: 15px; font-weight: 600; }

#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast-item { padding: 10px 18px; border-radius: 10px; color: #fff; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.15); display: flex; align-items: center; gap: 8px; max-width: 80vw; }
.toast-item.ok { background: var(--success); }
.toast-item.err { background: var(--danger); }
.toast-item.info { background: var(--primary); }
.ri-spin { animation: rispin 1s linear infinite; }
@keyframes rispin { to { transform: rotate(360deg); } }
