* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4f6ef7;
  --primary-dark: #3b57d6;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #2b2f3a;
  --muted: #8a93a6;
  --border: #e5e9f2;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.view { min-height: 100vh; }

/* ---------- 登录 ---------- */
#view-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #6d4ef7 0%, #7c4ff7 100%);
}
.auth-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.brand {
  text-align: center;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.3;
}
.brand-main {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.brand-sub {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, #4f6ef7 0%, #7c4ff7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 6px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.auth-form label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.auth-form input, .auth-form select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}
.auth-form input:focus, .auth-form select:focus { outline: none; border-color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: all 0.15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-form .btn { width: 100%; margin-top: 20px; padding: 12px; font-size: 16px; }

.msg { margin-top: 12px; font-size: 14px; min-height: 18px; text-align: center; }
.msg.ok { color: var(--green); }
.msg.err { color: var(--red); }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-chip {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 20px;
}
.user-chip .vip { color: var(--amber); font-weight: 600; }

/* ---------- 容器 ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 28px 20px; }
.container.narrow { max-width: 720px; }

/* ---------- 主页 ---------- */
.home-banner {
  background: linear-gradient(135deg, #4f6ef7 0%, #7c4ff7 100%);
  color: #fff;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 24px;
}
.home-banner h2 { font-size: 22px; margin-bottom: 8px; }
.home-banner p { opacity: 0.9; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  cursor: pointer;
  transition: all 0.15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); border-color: var(--primary); }
.card-icon { font-size: 30px; margin-bottom: 12px; }
.card h3 { margin-bottom: 6px; }
.card p { font-size: 13px; color: var(--muted); }

/* ---------- 看题 / 训练 题目 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.jump { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.jump input { width: 64px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; text-align: center; }

.question-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}
.q-head { display: flex; gap: 10px; margin-bottom: 6px; align-items: flex-start; }
.q-no { font-weight: 600; white-space: nowrap; }
.q-type {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  align-self: center;
}
.q-type.single { background: #e8f0fe; color: #3b57d6; }
.q-type.multi { background: #fef3e2; color: #d97706; }
.q-type.judge { background: #e7f8ee; color: #16a34a; }
.q-text { font-size: 16px; line-height: 1.6; margin: 8px 0 16px; }

.option {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  align-items: flex-start;
  transition: all 0.12s;
}
.option:hover { border-color: var(--primary); }
.option .key {
  min-width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--bg);
  font-weight: 600; font-size: 13px;
}
.option .val { line-height: 1.5; font-size: 15px; }
.option.selected { border-color: var(--primary); background: #f0f4ff; }
.option.selected .key { background: var(--primary); color: #fff; }

.answer-panel {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.answer-panel .ans-label { font-weight: 600; color: var(--green); }
.analysis-panel {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  line-height: 1.7;
  font-size: 14px;
}
.analysis-panel .ana-label { font-weight: 600; color: var(--amber); display: block; margin-bottom: 4px; }

.free-tip { text-align: center; color: var(--amber); margin-top: 16px; font-size: 14px; }

/* ---------- 训练 ---------- */
.train-progress { margin-bottom: 16px; }
.train-progress span { font-size: 14px; color: var(--muted); display: block; margin-bottom: 8px; }
.progress-bar { height: 8px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress-bar div { height: 100%; background: var(--primary); transition: width 0.2s; }

.train-actions { display: flex; gap: 12px; margin-top: 18px; justify-content: flex-end; }

.result-card { text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 32px; margin-bottom: 24px; }
.score { font-size: 52px; font-weight: 700; color: var(--primary); margin: 12px 0; }
#train-summary { color: var(--muted); margin-bottom: 20px; }

/* 错题 */
.wrong-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}
.wrong-item .wq { font-weight: 600; margin-bottom: 10px; line-height: 1.5; }
.wrong-line { font-size: 14px; margin-bottom: 4px; }
.wrong-line .right { color: var(--green); font-weight: 600; }
.wrong-line .wrong { color: var(--red); font-weight: 600; }

/* ---------- 开通 ---------- */
.redeem-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  text-align: center;
  max-width: 480px;
  margin: 40px auto;
}
.redeem-card h2 { margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.redeem-card input {
  width: 100%;
  margin: 20px 0;
  padding: 13px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-transform: uppercase;
}
.redeem-card .btn { width: 100%; padding: 13px; font-size: 16px; }
.contact { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 14px; }

/* ---------- 管理 ---------- */
.admin-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}
.admin-section h3 { margin-bottom: 16px; }
.gen-row { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.gen-row input { width: 80px; padding: 9px; border: 1px solid var(--border); border-radius: 8px; text-align: center; }
#gen-result { display: flex; flex-wrap: wrap; gap: 8px; }
.code-chip {
  background: var(--bg);
  border: 1px dashed var(--primary);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: monospace;
  letter-spacing: 1px;
  font-size: 14px;
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; }
.tag { font-size: 12px; padding: 3px 10px; border-radius: 12px; }
.tag.vip { background: #fef3e2; color: #d97706; }
.tag.free { background: #eef1f6; color: var(--muted); }
.tag.used { background: #f0fdf4; color: #16a34a; }
.tag.unused { background: #eef1f6; color: var(--muted); }

@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  #view-auth { padding: 16px; }
  .auth-card { padding: 24px 18px; }
  .brand-main { font-size: 15px; }
  .brand-sub { font-size: 26px; letter-spacing: 3px; }
  .topbar { padding: 12px 14px; }
  .topbar-title { font-size: 14px; line-height: 1.4; }
  .user-chip { display: none; }
  .container { padding: 20px 14px; }
  .home-banner { padding: 20px; }
  .home-banner h2 { font-size: 18px; }
  .card { padding: 16px; }
  .question-box { padding: 16px; }
  .jump { justify-content: center; }
  .train-actions { justify-content: stretch; }
  .train-actions .btn { flex: 1; }
}

/* ---------- 训练布局（左侧答题卡） ---------- */
.train-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: 1080px;
}
.train-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  position: sticky;
  top: 80px;
}
.train-sidebar-title { font-weight: 600; margin-bottom: 12px; }
.train-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}
.train-list::-webkit-scrollbar { width: 6px; }
.train-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.train-list::-webkit-scrollbar-track { background: transparent; }
.train-list-item {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.train-list-item:hover { border-color: var(--primary); }
.train-list-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.train-list-item.answered { background: #e8f0fe; border-color: #bcd0ff; color: var(--primary-dark); }
.train-main { flex: 1; min-width: 0; }

/* ---------- 开通价格与联系方式（醒目） ---------- */
.price-box {
  margin: 20px 0;
  padding: 18px;
  background: linear-gradient(135deg, #fff5f5 0%, #ffe4e6 100%);
  border: 1px solid #fecdd3;
  border-radius: 12px;
}
.price-label { display: block; font-size: 14px; color: #be123c; margin-bottom: 6px; }
.price-num { font-size: 40px; font-weight: 800; color: #e11d48; }
.price-num b { font-size: 48px; }

.contact {
  margin-top: 20px;
  padding: 18px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
}
.contact-title { font-weight: 700; color: #c2410c; margin-bottom: 8px; font-size: 15px; }
.contact-wechat { font-size: 22px; font-weight: 800; color: #ea580c; letter-spacing: 1px; }

/* ---------- 我的练习 ---------- */
.record-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 14px;
  overflow: hidden;
}
.record-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  flex-wrap: wrap;
}
.record-time { color: var(--muted); font-size: 14px; flex: 1; }
.record-score { font-size: 20px; font-weight: 700; color: var(--primary); }
.record-stat { font-size: 14px; color: var(--text); }
.record-detail { border-top: 1px solid var(--border); padding: 16px 18px; background: #fafbfe; }
.empty-box { text-align: center; color: var(--muted); padding: 60px 0; }
.btn.small { padding: 6px 14px; font-size: 13px; }

/* ---------- 错题选项 ---------- */
.wrong-option {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.wrong-option .key {
  min-width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--bg);
  font-weight: 600; font-size: 13px;
}
.wrong-option .val { flex: 1; line-height: 1.5; }
.wrong-option.right-opt { border-color: #86efac; background: #f0fdf4; }
.wrong-option.right-opt .key { background: var(--green); color: #fff; }
.wrong-option.user-wrong-opt { border-color: #fca5a5; background: #fef2f2; }
.wrong-option.user-wrong-opt .key { background: var(--red); color: #fff; }
.mark { font-size: 12px; white-space: nowrap; }
.mark.ok { color: var(--green); font-weight: 600; }
.mark.bad { color: var(--red); font-weight: 600; }

/* ---------- 批量添加账号 ---------- */
#batch-group { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
#batch-rows {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.6;
}
#batch-rows:focus, #batch-group:focus { outline: none; border-color: var(--primary); }

@media (max-width: 800px) {
  .train-layout { flex-direction: column; }
  .train-sidebar { width: 100%; position: static; }
}

/* ---------- 主页题库选择器 ---------- */
.bank-selector {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.bank-btn {
  padding: 8px 20px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 20px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.15s;
}
.bank-btn:hover { background: rgba(255, 255, 255, 0.3); }
.bank-btn.active { background: #fff; color: var(--primary); border-color: #fff; }
@media (max-width: 600px) {
  .bank-btn { padding: 7px 14px; font-size: 14px; }
}

/* ---------- 管理表格横向滚动（手机） ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .table { min-width: 720px; }

/* ---------- 赛事报名 ---------- */
.regi-line {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.regi-line:last-child { border-bottom: none; }
.regi-label {
  min-width: 96px;
  color: var(--muted);
  flex-shrink: 0;
}
