:root {
  --navy: #0f2c5c;
  --navy-2: #173d78;
  --blue: #2f6fed;
  --blue-soft: #eaf1ff;
  --sky: #4f9dff;
  --ink: #16233b;
  --ink-2: #5a6b85;
  --line: #e6ebf3;
  --card: #ffffff;
  --bg: #f3f6fb;
  --ok: #12a150;
  --ok-soft: #e8f8ef;
  --warn: #d97706;
  --warn-soft: #fff5e6;
  --bad: #d63b3b;
  --bad-soft: #fdecec;
  --shadow: 0 2px 10px rgba(15, 44, 92, .07), 0 8px 30px rgba(15, 44, 92, .05);
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.app { max-width: 680px; margin: 0 auto; min-height: 100vh; background: var(--bg); }

/* --------------------------------- 顶部 --------------------------------- */

.hero {
  position: relative;
  padding: 26px 20px 60px;
  background: linear-gradient(160deg, #0b2a5b 0%, #17438a 48%, #2f6fed 100%);
  color: #fff;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -50px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.20), rgba(255,255,255,0) 68%);
}
.hero h1 { margin: 0; font-size: 25px; letter-spacing: 1px; font-weight: 700; }
.hero .sub { margin-top: 8px; font-size: 13.5px; opacity: .85; letter-spacing: .5px; }
.hero .badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero .badge {
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(4px);
}

.wrap { padding: 0 14px 28px; margin-top: -40px; position: relative; z-index: 2; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .dot {
  width: 4px; height: 16px; border-radius: 2px;
  background: linear-gradient(180deg, var(--sky), var(--blue));
}

/* ------------------------------ 可折叠规则 ------------------------------ */

.rules-card { padding: 0; overflow: hidden; }
.rules-card > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 17px 18px;
  font-size: 16px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.rules-card > summary::-webkit-details-marker { display: none; }
.rules-card > summary .chev {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  padding: 3px 10px;
}
.rules-card[open] > summary .chev::after { content: ""; }
.rules-card:not([open]) > summary .chev::after { content: ""; }
.rules-card[open] .when-closed { display: none; }
.rules-card:not([open]) .when-open { display: none; }
.rules-body { padding: 0 18px 18px; border-top: 1px solid var(--line); padding-top: 16px; }

/* -------------------------------- 名额进度 -------------------------------- */

.quota-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.quota-label { font-size: 13.5px; color: var(--ink-2); }
.quota-num { font-size: 28px; font-weight: 700; color: var(--blue); line-height: 1; }
.quota-num small { font-size: 13px; color: var(--ink-2); font-weight: 500; margin-left: 3px; }
.bar { height: 10px; border-radius: 999px; background: #eaf0fa; overflow: hidden; }
.bar > i {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sky), var(--blue));
  transition: width .5s ease;
}
.bar.full > i { background: linear-gradient(90deg, #f0a04b, #d97706); }
.quota-foot { margin-top: 9px; font-size: 12.5px; color: var(--ink-2); display: flex; justify-content: space-between; }

/* --------------------------------- 规则 --------------------------------- */

.rules { list-style: none; margin: 0; padding: 0; }
.rules li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 9px;
  font-size: 14px;
  color: var(--ink-2);
}
.rules li:last-child { margin-bottom: 0; }
.rules li::before {
  content: "";
  position: absolute;
  left: 6px; top: 9px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--blue);
  opacity: .55;
}
.rules b { color: var(--ink); font-weight: 600; }

.paper-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.paper-grid div {
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.paper-grid span { display: block; font-size: 12px; color: var(--ink-2); }
.paper-grid strong { display: block; font-size: 17px; color: var(--navy); margin-top: 2px; }

/* --------------------------------- 表单 --------------------------------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
  color: var(--ink);
  background: #f7f9fd;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .2s, background .2s;
}
.field input:focus { border-color: var(--blue); background: #fff; }
.field .hint { font-size: 12px; color: #93a1b8; margin-top: 5px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 13px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b7bf5, #2f6fed);
  box-shadow: 0 6px 18px rgba(47, 111, 237, .28);
  cursor: pointer;
  transition: transform .12s, opacity .2s;
  font-family: inherit;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .55; box-shadow: none; cursor: not-allowed; }
.btn.ghost {
  background: #fff;
  color: var(--blue);
  border: 1.5px solid #cfe0ff;
  box-shadow: none;
}
.btn.small { height: 40px; font-size: 14.5px; border-radius: 11px; width: auto; padding: 0 16px; }

.notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--blue-soft);
  color: #2c5aa8;
  margin-bottom: 14px;
}
.notice.warn { background: var(--warn-soft); color: #a25c05; }
.notice.bad { background: var(--bad-soft); color: #a92626; }
.notice.ok { background: var(--ok-soft); color: #0d7a3d; }

/* --------------------------------- 答题 --------------------------------- */

.exam-head {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 10px 14px calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.exam-head .title { font-size: 14.5px; font-weight: 700; color: var(--navy); flex: none; }
.exam-head .progress-text { font-size: 12.5px; color: var(--ink-2); flex: 1; text-align: right; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--navy);
  background: #eef3fb;
  border-radius: 8px;
  padding: 4px 9px;
}
.timer.low { color: var(--bad); background: var(--bad-soft); }

.q-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 14px 14px 0; scroll-margin-top: 68px; }
.hint { font-size: 12px; color: #93a1b8; margin-top: 8px; line-height: 1.5; }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.q-no {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--navy); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.q-type { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--blue-soft); color: #2c5aa8; }
.q-type.multi { background: #f0ebff; color: #5b3fc4; }
.q-type.judge { background: #e9f7f3; color: #0d7a63; }
.q-score { margin-left: auto; font-size: 12px; color: #93a1b8; }
.q-stem { font-size: 16px; line-height: 1.72; margin-bottom: 14px; word-break: break-word; }

.opts { display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 13px;
  text-align: left;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  background: #f8fafd;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
.opt:active { background: #eff4fd; }
.opt .k {
  flex: none;
  width: 24px; height: 24px; border-radius: 7px;
  border: 1.5px solid #c9d5e8;
  color: var(--ink-2);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  transition: all .15s;
}
.opt .t { flex: 1; padding-top: 1px; }
.opt.on { border-color: var(--blue); background: var(--blue-soft); }
.opt.on .k { background: var(--blue); border-color: var(--blue); color: #fff; }
.opts.judge { flex-direction: row; }
.opts.judge .opt { justify-content: center; padding: 15px 10px; }
.opts.judge .opt .t { flex: none; font-size: 16.5px; }

.exam-foot-space { height: 92px; }

.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
}
.action-bar .count { font-size: 13px; color: var(--ink-2); flex: none; }
.action-bar .count b { color: var(--blue); font-size: 15px; }
.action-bar .btn { flex: 1; height: 46px; font-size: 16px; }

/* --------------------------------- 结果 --------------------------------- */

.result-hero { text-align: center; padding: 26px 18px 22px; }
.ring {
  width: 148px; height: 148px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: conic-gradient(var(--blue) 0deg, var(--blue) var(--deg, 0deg), #e9eef8 var(--deg, 0deg));
}
.ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: #fff;
}
.ring .in { position: relative; text-align: center; }
.ring .score { font-size: 44px; font-weight: 800; line-height: 1; color: var(--navy); font-variant-numeric: tabular-nums; }
.ring .unit { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.ring.pass { background: conic-gradient(var(--ok) 0deg, var(--ok) var(--deg, 0deg), #e9eef8 var(--deg, 0deg)); }
.ring.pass .score { color: #0d7a3d; }

.result-title { font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.result-sub { font-size: 14px; color: var(--ink-2); }

.award {
  margin: 16px 14px 0;
  padding: 20px 18px;
  border-radius: var(--radius);
  text-align: center;
  background: linear-gradient(135deg, #fff6e4, #ffeccd);
  border: 1px solid #ffdca8;
}
.award.got h3 { color: #9a5b00; }
.award h3 { margin: 0 0 8px; font-size: 19px; }
.award p { margin: 0; font-size: 14px; color: #8a6415; line-height: 1.6; }
.award.miss { background: linear-gradient(135deg, #f4f7fd, #eaf0fa); border-color: #dce6f6; }
.award.miss h3 { color: var(--navy); }
.award.miss p { color: var(--ink-2); }

.kv { margin: 14px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 13px 16px; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv-row span { color: var(--ink-2); flex: none; }
.kv-row b { font-weight: 600; text-align: right; word-break: break-all; }
.kv-row b.mono { font-size: 12.5px; font-weight: 500; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--ink-2); }

.foot-note { text-align: center; font-size: 12px; color: #9aa8bd; padding: 6px 20px 24px; line-height: 1.7; }

/* --------------------------------- 后台 --------------------------------- */

.admin-wrap { max-width: 1080px; margin: 0 auto; padding: 18px 14px 40px; }
.admin-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.admin-top h1 { font-size: 20px; margin: 0; flex: 1; color: var(--navy); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

.day-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; margin-bottom: 16px; }
.day-cell { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 11px 12px; }
.day-cell.today { outline: 2px solid var(--blue); }
.day-cell .d { font-size: 12.5px; color: var(--ink-2); }
.day-cell .v { font-size: 18px; font-weight: 700; color: var(--navy); margin: 3px 0 6px; font-variant-numeric: tabular-nums; }
.day-cell .bar { height: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; font-size: 14px; color: var(--ink); font-family: inherit;
}
.toolbar .spacer { flex: 1; }

table.list { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); font-size: 13.5px; }
table.list th, table.list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list th { background: #f6f9fe; color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.name { font-weight: 600; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 5px; }
.tag.ok { background: var(--ok-soft); color: #0d7a3d; }
.tag.no { background: #f1f4f9; color: #7a889c; }
.empty { text-align: center; padding: 26px; color: #9aa8bd; font-size: 14px; }

/* ------------------------------- 底部弹层 ------------------------------- */

.sheet-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(13, 27, 51, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 680px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 72vh; overflow-y: auto;
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 12px; font-size: 16px; }
.numpad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.numpad button {
  height: 42px; border-radius: 10px; border: 1.5px solid var(--line); background: #f8fafd;
  font-size: 14.5px; color: var(--ink); font-family: inherit; cursor: pointer;
}
.numpad button.done { background: var(--blue-soft); border-color: #bcd4ff; color: #2c5aa8; font-weight: 600; }
.sheet-close { margin-top: 14px; }

/* -------------------------------- 轻提示 -------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 12px);
  z-index: 90;
  max-width: 82vw;
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(22, 35, 59, .93);
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: rgba(176, 39, 39, .95); }

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 380px) {
  .hero h1 { font-size: 22px; }
  .q-stem { font-size: 15.5px; }
  .opt { font-size: 15px; }
  .numpad { grid-template-columns: repeat(5, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
