:root {
  --primary: #1666d6;
  --primary-dark: #0f4ea8;
  --primary-light: #e8f1ff;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e6eaf0;
  --success: #18a058;
  --success-bg: #e8f7ee;
  --danger: #e03e3e;
  --danger-bg: #fdecec;
  --warning: #d98a00;
  --warning-bg: #fdf3e2;
  --wechat: #07c160;
  --wechat-dark: #06ad56;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(20, 40, 80, .06);
  --shadow-lg: 0 8px 30px rgba(20, 40, 80, .12);
  --maxw: 1080px;
  --nav-h: 64px;
  --tab-h: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.boot { padding: 60px; text-align: center; color: var(--text-2); }

/* ---------- 布局 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; height: var(--nav-h);
  display: flex; align-items: center; padding: 0 18px;
  box-shadow: 0 2px 10px rgba(15, 78, 168, .25);
}
.app-header .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.app-header .logo .ic { font-size: 22px; }
.app-header .spacer { flex: 1; }
.app-header .right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.app-header .code-chip {
  background: rgba(255,255,255,.16); padding: 4px 10px; border-radius: 20px;
  font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-header .link { color: #fff; opacity: .9; cursor: pointer; }
.app-header .link:hover { opacity: 1; }
/* 手机端标题栏右侧的「客服」按钮（桌面端隐藏，≤860px 显示） */
.nav-service-mobile {
  display: none; align-items: center; gap: 4px;
  color: #fff; font-size: 13px; cursor: pointer;
  background: rgba(255,255,255,.16); padding: 5px 11px; border-radius: 16px;
  white-space: nowrap; flex-shrink: 0;
}
.nav-service-mobile .ic { font-size: 15px; }
.nav-service-mobile:active { background: rgba(255,255,255,.28); }

.top-nav { display: none; gap: 4px; }
.top-nav a {
  color: rgba(255,255,255,.82); padding: 8px 14px; border-radius: 8px;
  font-size: 14px; cursor: pointer; transition: .15s;
}
.top-nav a.active, .top-nav a:hover { background: rgba(255,255,255,.16); color: #fff; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 18px; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px); }
.container.no-tab { padding-bottom: 40px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; border: 1px solid var(--border);
}
.card h3 { margin: 0 0 14px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h3 .bar { width: 4px; height: 16px; background: var(--primary); border-radius: 2px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; }
.wrap { flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm); padding: 11px 18px;
  font-size: 15px; font-weight: 600; background: var(--primary); color: #fff;
  transition: .15s; user-select: none;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.ghost:hover { background: var(--primary-light); }
.btn.wechat { background: var(--wechat); }
.btn.wechat:hover { background: var(--wechat-dark); }
.btn.light { background: var(--primary-light); color: var(--primary-dark); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text); transition: .15s;
}
.input:focus, .select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea { min-height: 90px; resize: vertical; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.primary { background: var(--primary-light); color: var(--primary-dark); }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.gray { background: #f0f2f5; color: var(--text-2); }

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

/* ---------- 统计卡片 ---------- */
.stat { text-align: center; padding: 14px 8px; }
.stat .num { font-size: 26px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat .label { font-size: 13px; color: var(--text-2); margin-top: 4px; }

/* ---------- 入口大卡 ---------- */
.entry {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 26px 14px; border-radius: var(--radius); cursor: pointer; text-align: center;
  border: 1px solid var(--border); background: #fff; transition: .18s; position: relative; overflow: hidden;
}
.entry:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.entry .emoji { font-size: 40px; }
.entry .t { font-weight: 700; font-size: 16px; }
.entry .d { font-size: 12px; color: var(--text-2); }
.entry .corner { position: absolute; top: 10px; right: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 20px;
  background: #fff; border: 1px solid var(--border); font-size: 13px; cursor: pointer; user-select: none; transition: .15s;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip .cnt { background: rgba(0,0,0,.08); border-radius: 10px; padding: 0 6px; font-size: 11px; }
.chip.active .cnt { background: rgba(255,255,255,.25); }

/* ---------- 题目 ---------- */
.q-type { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.q-type.single, .q-type.judge { background: var(--primary-light); color: var(--primary-dark); }
.q-type.multiple { background: var(--warning-bg); color: var(--warning); }
.q-text { font-size: 16px; font-weight: 600; margin: 12px 0; line-height: 1.7; }
.q-cat { font-size: 12px; color: var(--text-3); }
.option {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 10px; cursor: pointer; transition: .15s; background: #fff;
}
.option:hover { border-color: var(--primary); }
.option.sel { border-color: var(--primary); background: var(--primary-light); }
.option.correct { border-color: var(--success); background: var(--success-bg); }
.option.wrong { border-color: var(--danger); background: var(--danger-bg); }
.option .mark { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--text-3); flex: none; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--text-2); }
.option.sel .mark { background: var(--primary); border-color: var(--primary); color: #fff; }
.option.multi .mark { border-radius: 6px; }
.option.correct .mark { background: var(--success); border-color: var(--success); color: #fff; }
.option.wrong .mark { background: var(--danger); border-color: var(--danger); color: #fff; }
.option .txt { flex: 1; }

.feedback { border-radius: var(--radius-sm); padding: 14px; margin-top: 8px; }
.feedback.ok { background: var(--success-bg); border: 1px solid #b7e3c8; }
.feedback.no { background: var(--danger-bg); border: 1px solid #f3c2c2; }
.feedback .tag { font-weight: 700; margin-bottom: 6px; }
.feedback.ok .tag { color: var(--success); }
.feedback.no .tag { color: var(--danger); }
.feedback .ans { font-size: 13px; }
.feedback .analysis { font-size: 13.5px; color: #374151; margin-top: 8px; line-height: 1.7; }

.progress { height: 8px; background: #eef1f5; border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #3d8bff); border-radius: 6px; transition: width .3s; }

/* ---------- 模拟考 ---------- */
.exam-bar { position: sticky; top: var(--nav-h); z-index: 30; background: #fff; border-bottom: 1px solid var(--border); padding: 10px 18px; display: flex; align-items: center; gap: 12px; }
.exam-bar .timer { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.exam-bar .timer.warn { color: var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }
.answer-card { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.answer-card .ans-item { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; cursor: pointer; background: #fff; }
.answer-card .ans-item.answered { background: var(--primary); color: #fff; border-color: var(--primary); }
.answer-card .ans-item.cur { outline: 2px solid var(--primary-dark); }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,25,45,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal .modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.modal .modal-body { padding: 18px; }
.modal .modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal .x { cursor: pointer; color: var(--text-3); font-size: 22px; line-height: 1; }

/* ---------- 支付 ---------- */
.pay-plan { border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; position: relative; transition: .15s; }
.pay-plan.active { border-color: var(--wechat); background: #f4fdf8; }
.pay-plan .price { font-size: 26px; font-weight: 800; color: var(--wechat); }
.pay-plan .origin { color: var(--text-3); text-decoration: line-through; font-size: 13px; margin-left: 8px; }
.pay-plan .tag-corner { position: absolute; top: -10px; right: 14px; background: var(--wechat); color: #fff; font-size: 11px; padding: 2px 10px; border-radius: 12px; }
.pay-plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px){ .pay-plans { grid-template-columns: 1fr; } }

.wx-box { text-align: center; padding: 8px 0; }
.wx-box .amount { font-size: 30px; font-weight: 800; color: var(--danger); margin: 6px 0; }
.qr-wrap { display: flex; justify-content: center; margin: 14px 0; }
.qr-canvas { background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--border); }
.wx-tip { color: var(--text-2); font-size: 13px; }
.wx-spin { width: 18px; height: 18px; border: 3px solid #e0e0e0; border-top-color: var(--wechat); border-radius: 50%; display: inline-block; animation: spin 1s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.code-display { font-size: 24px; font-weight: 800; letter-spacing: 2px; color: var(--primary); background: var(--primary-light); padding: 14px; border-radius: var(--radius-sm); text-align: center; word-break: break-all; }

/* ---------- 结果 ---------- */
.score-ring { width: 150px; height: 150px; margin: 0 auto; position: relative; }
.score-ring .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .num b { font-size: 38px; font-weight: 800; }
.score-ring .num span { font-size: 12px; color: var(--text-2); }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.tbl th { background: #f7f9fc; color: var(--text-2); font-weight: 600; position: sticky; top: 0; }
.table-scroll { overflow: auto; }
/* 后台宽表：列多时给最小宽度，手机上横向滚动而不是把每列压成竖排文字 */
table.tbl.tbl-wide { min-width: 880px; }
/* 后台授权码表：设备ID 用等宽字体便于逐位比对；表格不换行时横向滚动 */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; letter-spacing: .2px; }
.row-between { display: flex; justify-content: space-between; }
table.tbl td .badge + .mono { margin-top: 4px; display: inline-block; }
table.tbl td .muted { color: var(--text-2); }

/* ---------- 底部Tab（移动端） ---------- */
/* 注意：height 必须把 safe-area 一起算进去，否则 box-sizing:border-box 会把
   padding-bottom 挤进可视高度，iPhone 手势条会压住图标文字。 */
.bottom-tab {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: #fff; border-top: 1px solid var(--border);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-tab a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-3); font-size: 11px; cursor: pointer; }
.bottom-tab a .ic { font-size: 20px; }
.bottom-tab a.active { color: var(--primary); }
/* 答题/考试进行中：隐藏底部 Tab，避免与题目操作按钮混淆、防止误触切页 */
body.quizzing .bottom-tab { display: none !important; }
body.quizzing .container { padding-bottom: 40px; }

/* ---------- 登录/支付页（独立布局） ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 20px 72px; background: linear-gradient(160deg, #e8f1ff 0%, #f3f6fb 100%); }
/* 备案信息脚注：固定在视口底部，登录页/购买页展示 */
.site-footer { position: fixed; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 12px; color: var(--text-2); line-height: 1.9; padding: 0 16px; z-index: 10; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--primary); text-decoration: underline; }
.site-footer .sep { margin: 0 8px; opacity: .45; }

/* ===== 客服与公众号 ===== */
/* 客服微信号一行（登录页 / 弹窗通用） */
.service-wechat { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.service-wechat.block { display: block; }
.service-wechat.block .sw-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.service-wechat.block .sw-id { display: inline-block; margin-right: 10px; }
.sw-label { font-size: 12px; color: var(--text-2); }
.sw-id { font-size: 15px; color: var(--wechat-dark); letter-spacing: .3px; word-break: break-all; }
/* 登录页客服面板 */
.service-panel { margin-top: 16px; padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.service-cols { display: flex; gap: 16px; align-items: flex-start; }
.service-side { flex: 1; min-width: 0; }
/* 公众号二维码 */
.service-qr { text-align: center; flex-shrink: 0; }
.service-qr .sq-title { font-size: 12px; color: var(--text-2); margin-bottom: 7px; }
.service-qr .sq-img { width: 132px; height: 132px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; display: block; }
.service-qr .sq-cap { font-size: 11.5px; color: var(--text-2); margin-top: 7px; line-height: 1.6; max-width: 150px; }
@media (max-width: 420px) {
  .service-cols { flex-direction: column; align-items: center; }
  .service-side { width: 100%; text-align: center; }
  .service-side .service-wechat.block { text-align: center; }
  .service-qr .sq-img { width: 118px; height: 118px; }
}
.auth-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 30px 26px; }
.auth-card .brand { text-align: center; margin-bottom: 20px; }
.auth-card .brand .logo { font-size: 46px; }
.auth-card .brand h1 { font-size: 19px; margin: 10px 0 4px; }
.auth-card .brand p { color: var(--text-2); font-size: 13px; margin: 0; }
.device-note { background: var(--primary-light); color: var(--primary-dark); font-size: 12.5px; padding: 10px 12px; border-radius: var(--radius-sm); margin: 14px 0; display: flex; gap: 8px; align-items: flex-start; }
.link-btn { background: none; border: none; color: var(--primary); font-size: 14px; padding: 0; cursor: pointer; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty .e-ic { font-size: 54px; margin-bottom: 8px; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast-item { background: rgba(30,40,60,.92); color: #fff; padding: 10px 18px; border-radius: 24px; font-size: 14px; box-shadow: var(--shadow-lg); animation: tin .25s ease; max-width: 90vw; }
.toast-item.err { background: rgba(200,40,40,.95); }
.toast-item.ok { background: rgba(20,140,80,.95); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- 桌面端：顶部导航，隐藏底部Tab ---------- */
@media (min-width: 861px) {
  .top-nav { display: flex; }
  .bottom-tab { display: none !important; }
  .container { padding-bottom: 40px; }
}
/* ---------- 平板 ---------- */
@media (max-width: 860px) and (min-width: 561px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .bottom-tab { display: flex; }
  .nav-service-mobile { display: inline-flex; }
}
/* ---------- 手机 ---------- */
@media (max-width: 560px) {
  /* 注意：这里必须用 padding-top/right/bottom/left 分开写。
     若写成 `padding: 14px` 简写，会把底部 padding-bottom 覆盖成 14px，
     导致固定底栏（bottom-tab）正好压住「提交答案 / 退出」等操作按钮。 */
  .container {
    padding-top: 14px;
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 20px);
  }
  .container.no-tab { padding-bottom: 40px; }
  .top-nav { display: none; }
  .bottom-tab { display: flex; }
  .nav-service-mobile { display: inline-flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .card { padding: 15px; }
  .app-header .code-chip { display: none; }
  .answer-card { grid-template-columns: repeat(6, 1fr); }
  .modal { max-width: 100%; }
  .hide-mobile { display: none; }
}
