:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2a3d;
  --muted: #6b7688;
  --line: #e4e8f0;
  --brand: #1d4ed8;
  --brand-2: #2563eb;
  --ok: #16a34a;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(20, 35, 70, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font-family: inherit; }

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.topbar {
  background: linear-gradient(120deg, #12307a, #2563eb 70%, #3b82f6);
  color: #fff;
  padding: 18px 16px 22px;
  border-radius: 0 0 22px 22px;
}
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: .5px; line-height: 1.45; }

.steps {
  display: flex;
  gap: 4px;
  margin: 14px 2px 4px;
}
.steps .step {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding-top: 22px;
  position: relative;
}
.steps .step::before {
  content: attr(data-n);
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px; height: 20px;
  line-height: 20px;
  border-radius: 50%;
  background: #d7ddea;
  color: #fff;
  font-size: 12px;
}
.steps .step.on { color: var(--brand); font-weight: 700; }
.steps .step.on::before { background: var(--brand); }
.steps .step.done::before { background: var(--ok); content: "✓"; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-top: 14px;
}
.card h2 { margin: 0 0 14px; font-size: 17px; line-height: 1.5; }

.opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  text-align: center;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.opt:active { transform: scale(.99); }
.opt .dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(0,0,0,.05) inset;
}
.opt .t { font-size: 20px; font-weight: 700; }
.opt.sel {
  border-color: var(--brand);
  background: #eff5ff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .16);
}
.opt.sel-con {
  border-color: #dc2626;
  background: #fef2f2;
  box-shadow: 0 6px 18px rgba(220, 38, 38, .14);
}

textarea, input[type=text] {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
textarea:focus, input[type=text]:focus { border-color: var(--brand); }
textarea { min-height: 148px; resize: vertical; line-height: 1.7; }
.boxes textarea { min-height: 96px; margin-bottom: 10px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  cursor: pointer;
  margin-top: 14px;
}
.btn[disabled] { background: #b9c4d8; cursor: not-allowed; }
.btn.ghost {
  background: #fff;
  color: var(--brand);
  border: 2px solid var(--brand);
}
.btn.add {
  width: auto;
  display: inline-block;
  margin-top: 0;
  padding: 8px 16px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--line);
}

.banner {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  margin-top: 12px;
  display: none;
}
.banner.err { display: block; background: #fee2e2; color: #b91c1c; }

.hidden { display: none !important; }

.tally {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tally .cell {
  border: 2px solid var(--line);
  border-radius: 14px;
  text-align: center;
  padding: 22px 8px 16px;
  background: #fff;
}
.tally .num { font-size: 46px; font-weight: 800; line-height: 1; }
.tally .lab { margin-top: 10px; font-size: 16px; font-weight: 700; }
.tally .pro .num, .tally .pro .lab { color: #2563eb; }
.tally .con .num, .tally .con .lab { color: #dc2626; }

.stu-board { display: grid; gap: 12px; }
.stu-board .cloud { cursor: default; }
.stu-board .cloud:hover { transform: none; border-color: #24345a; }
.stu-board .cloud .wc,
.stu-board .cloud .empty { height: 220px; }

.success { text-align: center; padding: 8px 0 4px; }
.success .mark {
  width: 66px; height: 66px; line-height: 66px;
  border-radius: 50%; background: #dcfce7; color: var(--ok);
  font-size: 34px; margin: 6px auto 12px;
}
.success h2 { font-size: 20px; }
.summary {
  background: #f7f9fc;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 14px 0 4px;
  text-align: left;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
}
.summary b.v { color: var(--brand); }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 22px;
  line-height: 1.8;
}

/* ------------------------------------------------ qr / 扫码页 */
body.qrpage {
  background: radial-gradient(1200px 700px at 50% 20%, #1b3163, #0d1526 70%);
  color: #e8eefc;
  min-height: 100vh;
}
.qr-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 5vh 20px 40px;
  text-align: center;
}
.qr-wrap h1 {
  font-size: clamp(26px, 4.2vw, 48px);
  margin: 0 0 10px;
  letter-spacing: 1px;
  line-height: 1.35;
}
.qr-wrap .lead {
  font-size: clamp(16px, 2vw, 24px);
  color: #a8bce8;
  margin: 0 0 4vh;
}
.qr-big {
  background: #fff;
  border-radius: 24px;
  display: inline-block;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
  line-height: 0;
}
.qr-big img {
  width: min(56vh, 56vw, 520px);
  height: min(56vh, 56vw, 520px);
  image-rendering: pixelated;
}
.qr-big .loading {
  display: inline-block;
  line-height: 1.6;
  color: #6b7688;
  font-size: 18px;
  padding: 40px;
}
.qr-url {
  margin-top: 3vh;
  font-size: clamp(15px, 2vw, 22px);
  color: #7dd3fc;
  word-break: break-all;
}
.qr-steps {
  margin-top: 3vh;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.qr-steps span {
  background: #1d2c52;
  border: 1px solid #33477a;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: clamp(14px, 1.8vw, 20px);
}

/* ------------------------------------------------ admin / 投屏 */
body.admin {
  background: #0d1526;
  color: #e8eefc;
}
.admin-shell { max-width: 1680px; margin: 0 auto; padding: 14px 18px 30px; }

.abar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  background: linear-gradient(120deg, #132042, #1b3163);
  border: 1px solid #26365e;
  border-radius: 16px;
  padding: 12px 16px;
}
.abar h1 { margin: 0; font-size: 20px; line-height: 1.4; }
.abar .meta { font-size: 13px; color: #9fb1d6; }
.abar .spacer { flex: 1; }
.pill {
  background: #1d2c52;
  border: 1px solid #33477a;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
}
.pill b { font-size: 22px; color: #7dd3fc; }
.abtn {
  background: #1d2c52;
  border: 1px solid #3b5291;
  color: #dce7ff;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.abtn:hover { background: #27396a; }
.abtn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.abtn.danger { background: #7f1d1d; border-color: #991b1b; color: #fecaca; }

.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 14px;
  margin-top: 14px;
}
.panel {
  background: #111a30;
  border: 1px solid #24345a;
  border-radius: 16px;
  padding: 12px 14px 14px;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #a8bce8;
  letter-spacing: .5px;
}
.panel .hint { font-size: 12px; color: #7e8fb5; margin: -4px 0 8px; }

#barChart { width: 100%; height: 300px; }

.qrbox { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.qr {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  color: #1f2a3d;
}
.qr img {
  display: block;
  width: clamp(176px, 17.6vw, 304px);
  height: clamp(176px, 17.6vw, 304px);
  image-rendering: pixelated;
}

.cloud-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.cloud {
  background: #111a30;
  border: 1px solid #24345a;
  border-radius: 16px;
  padding: 10px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.cloud:hover { transform: translateY(-2px); border-color: #3b5291; }
.cloud .head {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 700; padding: 2px 4px 6px;
}
.cloud .head .dot { width: 12px; height: 12px; border-radius: 50%; }
.cloud .head .n {
  margin-left: auto;
  font-size: 13px;
  background: #1d2c52;
  border-radius: 999px;
  padding: 2px 9px;
  color: #9fc2ff;
}
.cloud .wc { width: 100%; height: 340px; }
.cloud .empty {
  height: 340px;
  display: flex; align-items: center; justify-content: center;
  color: #6d7ea3; font-size: 13px; text-align: center; padding: 0 8px;
}

.log {
  margin-top: 14px;
  background: #111a30;
  border: 1px solid #24345a;
  border-radius: 16px;
  padding: 10px 14px;
  max-height: 260px;
  overflow: auto;
  font-size: 13px;
}
.log .row {
  display: flex; gap: 10px; padding: 6px 2px;
  border-bottom: 1px dashed #1f2c4d;
  align-items: baseline;
}
.log .row:last-child { border-bottom: 0; }
.log .tag { padding: 1px 8px; border-radius: 6px; color: #0d1526; font-size: 12px; font-weight: 700; white-space: nowrap; }
.log .who { color: #cbd7f5; min-width: 92px; white-space: nowrap; }
.log .txt { color: #93a4c9; flex: 1; }
.log .tm { color: #64749a; font-size: 11.5px; white-space: nowrap; }

.modal {
  position: fixed; inset: 0;
  background: rgba(4, 8, 18, .82);
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal.on { display: flex; }
.modal .box {
  background: #111a30;
  border: 1px solid #33477a;
  border-radius: 18px;
  padding: 16px;
  width: min(980px, 96vw);
}
.modal .box .head { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.modal .box .head .dot { width: 14px; height: 14px; border-radius: 50%; }
.modal .box .head .close { margin-left: auto; }
.modal .wc { width: 100%; height: 60vh; }

@media (max-width: 1100px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .cloud-grid { grid-template-columns: 1fr; }
}
