/* =========================================================
   网络安全周答题 - 全局样式（移动端优先）
   ========================================================= */
:root {
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --brand-light: #dbeafe;
  --accent: #06b6d4;
  --navy: #0f172a;
  --navy-2: #1e3a8a;
  --success: #15803d;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { 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;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部品牌栏 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 16px 16px 14px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .25);
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .shield {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .12);
  border-radius: 9px;
}
.app-header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  letter-spacing: .5px;
}
.app-header .subtitle {
  font-size: 12px;
  opacity: .8;
  margin: 2px 0 0;
  font-weight: 400;
}

/* 进度条 */
.progress-wrap {
  margin-top: 12px;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  opacity: .9;
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, .2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #4ade80);
  border-radius: 99px;
  transition: width .3s ease;
}

/* ---------- 主体容器 ---------- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(226, 232, 240, .8);
}

/* 姓名填写 */
.name-field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.name-field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
}
.name-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

/* ---------- 题目 ---------- */
.q-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.q-index {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 2px;
}
.q-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.55;
}

/* 选项 */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all .18s ease;
  background: #fff;
  position: relative;
}
.option:active { transform: scale(.99); }
.option .key {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all .18s ease;
  margin-top: 1px;
}
.option .text { font-size: 15px; line-height: 1.5; }
.option.selected {
  border-color: var(--brand);
  background: var(--brand-light);
}
.option.selected .key {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* 结果页：对错样式 */
.option.correct {
  border-color: var(--success);
  background: var(--success-bg);
}
.option.correct .key { background: var(--success); border-color: var(--success); color: #fff; }
.option.wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.option.wrong .key { background: var(--danger); border-color: var(--danger); color: #fff; }

.opt-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.opt-badge.correct { background: var(--success); color: #fff; }
.opt-badge.wrong { background: var(--danger); color: #fff; }

/* 解析 */
.explanation {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  color: #475569;
}
.explanation b { color: var(--navy-2); }

.q-result-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  margin-left: auto;
}
.q-result-tag.right { background: var(--success-bg); color: var(--success); }
.q-result-tag.wrong { background: var(--danger-bg); color: var(--danger); }

/* ---------- 底部提交栏 ---------- */
.submit-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.submit-bar .inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.submit-hint {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
}

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  padding: 13px 26px;
  cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  background: #cbd5e1;
  box-shadow: none;
  cursor: not-allowed;
  opacity: .8;
}
.btn-block { width: 100%; }
.btn-ghost {
  background: #fff;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn-ghost:active { background: var(--brand-light); }

/* ---------- 加载/空态 ---------- */
.loading, .empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 14px;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 结果页头部得分 ---------- */
.score-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.score-hero .ring {
  width: 132px; height: 132px;
  margin: 0 auto 16px;
  position: relative;
}
.score-hero .ring svg { transform: rotate(-90deg); }
.score-hero .ring .value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  flex-direction: column;
}
.score-hero .ring .value b {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}
.score-hero .ring .value span {
  font-size: 12px;
  opacity: .8;
}
.score-hero .summary {
  font-size: 15px;
  opacity: .95;
}
.score-hero .badge {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 16px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, .18);
}

.result-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.result-actions .btn { flex: 1; }

/* ---------- 通用工具类 ---------- */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* 提示条 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  padding: 11px 20px;
  border-radius: 99px;
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all .3s ease;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 平板/桌面适配 */
@media (min-width: 768px) {
  body { font-size: 16px; }
  .container { padding: 24px 16px 120px; }
  .app-header h1 { font-size: 20px; }
}
