/* ==========================================================================
   candidate.css —— 考生端（移动优先）
   硬指标：375px 宽度下 document.documentElement.scrollWidth === 375（无横向滚动）。
   做法：所有容器 width:100% + max-width:100%，文本 overflow-wrap:anywhere，
        不使用任何固定宽度（除极小的图标/按钮），图片/表格一律包一层 overflow-x:auto。
   ========================================================================== */

body.candidate {
  background: #f5f6f8;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px 32px;
}

/* --------------------------------------------------------------- 顶部栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
  padding: 10px 12px calc(10px + env(safe-area-inset-top, 0));
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .exam-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  white-space: nowrap;
}

.countdown.warn {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

/* --------------------------------------------------------------- 入场页 */
.hero {
  text-align: center;
  padding: 26px 0 18px;
}

.hero h1 {
  font-size: 21px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.hero p {
  color: var(--c-text-2);
  font-size: 14px;
}

.entry-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 16px;
}

.entry-card .input {
  height: 46px;
  font-size: 16px; /* ≥16px 才不会让 iOS 聚焦时自动放大页面 */
}

.code-input {
  letter-spacing: 6px;
  font-size: 20px !important;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- 资料区 */
.material {
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 10px;
  overflow: hidden;
}

.material-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.material-head .arrow {
  color: var(--c-muted);
  font-size: 12px;
  transition: transform 0.15s;
}

.material.open .material-head .arrow {
  transform: rotate(90deg);
}

.material-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid var(--c-border);
}

.material.open .material-body {
  display: block;
}

.material-body p {
  font-size: 14px;
  line-height: 1.85;
  color: var(--c-text-2);
  text-indent: 2em;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- 题目区 */
.question {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px 14px;
  margin-top: 12px;
}

.q-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.q-title {
  font-weight: 600;
  font-size: 15px;
}

.q-stem {
  font-size: 15px;
  line-height: 1.8;
  color: var(--c-text);
  overflow-wrap: anywhere;
}

.q-req {
  margin-top: 8px;
  font-size: 13px;
  color: var(--c-text-2);
  background: #fafbfc;
  border-left: 3px solid var(--c-primary);
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  overflow-wrap: anywhere;
}

.answer-box {
  margin-top: 12px;
}

.answer-input {
  width: 100%;
  min-height: 210px;
  font-size: 15px;
  line-height: 1.85;
  padding: 12px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: #fff;
  outline: none;
  resize: vertical;
}

.answer-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

.counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--c-muted);
}

.counter .over {
  color: var(--c-danger);
  font-weight: 600;
}

/* --------------------------------------------------------------- 底部操作 */
.footer-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  /* ★ 该元素是 body 的直接子元素（与 .app 同级），.app 自带 12px 内边距。
     原先写 margin: 16px -12px 0 想"通栏"，结果在无内边距的父级上反而左右各溢出 12px，
     实测 360px 视口下宽度变成 384px，右侧按钮被 overflow-x:hidden 裁掉。
     这里改为零横向外边距 + width:100%，由 padding 自己撑开通栏效果。 */
  margin: 16px 0 0;
  width: 100%;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--c-border);
  backdrop-filter: blur(8px);
}

.footer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.save-state {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--c-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-state.offline {
  color: var(--c-warn);
}

/* --------------------------------------------------------------- 结果页 */
.result {
  text-align: center;
  padding: 40px 16px 24px;
}

.result .icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--c-ok-soft);
  color: var(--c-ok);
  font-size: 32px;
  line-height: 64px;
}

.result h2 {
  font-size: 19px;
  margin-bottom: 8px;
}

.result .meta {
  color: var(--c-text-2);
  font-size: 14px;
  line-height: 2;
}

/* --------------------------------------------------------------- 成绩页 */
.score-hero {
  text-align: center;
  background: linear-gradient(160deg, #2f6fed 0%, #4a8bff 100%);
  color: #fff;
  border-radius: 14px;
  padding: 24px 16px;
}

.score-hero .total {
  font-size: 46px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.score-hero .total small {
  font-size: 15px;
  font-weight: 400;
  opacity: 0.85;
}

.score-hero .stars {
  margin-top: 6px;
  font-size: 20px;
  letter-spacing: 2px;
  color: #ffd666;
}

.score-hero .sub {
  margin-top: 8px;
  font-size: 13px;
  opacity: 0.9;
}

.q-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--c-border);
  font-size: 14px;
}

.q-score:last-child {
  border-bottom: none;
}

.item-line {
  display: flex;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--c-border);
  font-size: 13px;
}

.item-line:last-child {
  border-bottom: none;
}

.item-line .name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.item-line .val {
  flex: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.evidence {
  margin-top: 4px;
  font-size: 12px;
  color: var(--c-muted);
  background: #fafbfc;
  border-radius: 6px;
  padding: 6px 8px;
  overflow-wrap: anywhere;
}

.cap-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  padding: 5px 0;
  color: var(--c-text-2);
}

/* --------------------------------------------------------------- 排行榜 */
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
}

.rank-row:last-child {
  border-bottom: none;
}

.rank-no {
  width: 30px;
  flex: none;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--c-muted);
}

.rank-row.me {
  background: var(--c-primary-soft);
  border-radius: 8px;
  padding: 10px;
}

.rank-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------- 小屏适配 */
@media (max-width: 480px) {
  .app {
    padding: 10px 10px 28px;
  }
  .card,
  .question {
    padding: 14px 12px;
  }
  .hero h1 {
    font-size: 19px;
  }
  .score-hero .total {
    font-size: 40px;
  }
}
