:root {
  --orange: #f58220;
  --orange-d: #e55100;
  --orange-l: #fff1e2;
  --ink: #1a1a1a;
  --ink-2: #4b423a;
  --muted: #8a7f72;
  --bg: #fff8ee;
  --card: #ffffff;
  --line: #f0e4d4;
  --green: #1f9d55;
  --red: #d93a3a;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(180, 130, 70, 0.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--orange-d); text-decoration: none; }

/* ---------- 通用 ---------- */
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px 48px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 248, 238, 0.94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 780px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), var(--orange-d));
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 800;
}
.brand small { color: var(--muted); font-weight: 500; font-size: 12px; }
.spacer { flex: 1; }
.ghost-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 6px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.ghost-btn:hover { border-color: var(--orange); color: var(--orange-d); }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid rgba(240, 228, 212, 0.9);
  padding: 18px;
}
.page-title { font-size: 22px; margin: 22px 0 6px; }
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.hw-list { display: grid; gap: 12px; }
.hw-item {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; transition: 0.15s; cursor: pointer;
}
.hw-item:hover { border-color: var(--orange); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(245, 130, 32, 0.12); }
.hw-item h3 { font-size: 17px; margin-bottom: 4px; }
.hw-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); }
.hw-desc { font-size: 14px; color: var(--ink-2); margin: 6px 0 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--orange-l); color: var(--orange-d);
}
.pill.gray { background: #f2efeb; color: var(--muted); }
.pill.green { background: #e8f7ee; color: var(--green); }
.pill.red { background: #fdecec; color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 14px; }

/* ---------- 答题 ---------- */
.stu-bar {
  display: flex; gap: 10px; align-items: center; margin: 18px 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.stu-bar label { font-size: 14px; color: var(--ink-2); white-space: nowrap; font-weight: 600; }
.stu-bar input, .stu-bar select {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; background: #fdfaf6; outline: none;
}
.stu-bar input:focus, .stu-bar select:focus { border-color: var(--orange); background: #fff; }

.q-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.q-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 12px; }
.q-no {
  flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--orange-l);
  color: var(--orange-d); font-weight: 800; font-size: 13px; display: grid; place-items: center;
}
.q-stem { font-size: 16px; font-weight: 600; flex: 1; word-break: break-word; }
.stem-text { white-space: pre-wrap; font-family: inherit; }
.q-text { white-space: pre-wrap; }
.q-score { flex: none; font-size: 12px; color: var(--muted); }
.q-type { font-size: 11px; color: var(--orange-d); background: var(--orange-l); padding: 1px 7px; border-radius: 6px; font-weight: 700; }

.opts { display: grid; gap: 9px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer;
  background: #fdfcfb; transition: 0.12s; font-size: 15px;
}
.opt:hover { border-color: #f3c99b; }
.opt.on { border-color: var(--orange); background: var(--orange-l); }
.opt .mk {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #d8cbbbd0;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: transparent; background: #fff;
}
.opt.sq .mk { border-radius: 7px; }
.opt.on .mk { background: var(--orange); border-color: var(--orange); color: #fff; }
.opt span.txt { padding-top: 1px; word-break: break-word; }

textarea, input.txt {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 14px; background: #fdfcfb; outline: none; resize: vertical; font-size: 15px;
}
textarea:focus, input.txt:focus { border-color: var(--orange); background: #fff; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.submit-bar {
  position: sticky; bottom: 0; z-index: 15; margin-top: 22px;
  background: rgba(255, 248, 238, 0.96); backdrop-filter: blur(8px);
  padding: 12px 0 16px; border-top: 1px solid var(--line);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--orange); color: #fff; border: 0; border-radius: 12px;
  padding: 13px 22px; font-size: 16px; font-weight: 700; cursor: pointer; width: 100%;
  box-shadow: 0 4px 14px rgba(245, 130, 32, 0.28); transition: 0.15s;
}
.btn:hover { background: var(--orange-d); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn.sm { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 9px; box-shadow: none; }
.btn.line { background: #fff; color: var(--ink-2); border: 1px solid var(--line); box-shadow: none; }
.btn.line:hover { color: var(--orange-d); border-color: var(--orange); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #f3caca; box-shadow: none; }

/* ---------- 结果 ---------- */
.result-hero { text-align: center; padding: 26px 18px; }
.result-hero .score { font-size: 46px; font-weight: 800; color: var(--orange-d); line-height: 1.1; }
.result-hero .score small { font-size: 16px; color: var(--muted); font-weight: 600; }
.result-hero .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.rev { border-top: 1px dashed var(--line); padding: 14px 0; }
.rev:first-child { border-top: 0; }
.rev-top { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; font-size: 15px; }
.tag-ok, .tag-no, .tag-wait {
  flex: none; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 6px;
}
.tag-ok { background: #e8f7ee; color: var(--green); }
.tag-no { background: #fdecec; color: var(--red); }
.tag-wait { background: #fff5e0; color: #b7791f; }
.rev-body { font-size: 14px; color: var(--ink-2); margin-top: 6px; padding-left: 2px; }
.rev-body b { font-weight: 600; color: var(--ink); }
.rev-ans { white-space: pre-wrap; word-break: break-word; }

/* ---------- 后台 ---------- */
.admin-body { background: #f7f4ef; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; margin-bottom: 5px; }

.admin-shell { display: flex; min-height: 100vh; }
.side {
  width: 210px; flex: none; background: #fff; border-right: 1px solid var(--line);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 2px;
}
.side .brand { padding: 4px 8px 16px; }
.nav-btn {
  text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; color: var(--ink-2); cursor: pointer; font-weight: 600;
}
.nav-btn:hover { background: #faf6f0; }
.nav-btn.on { background: var(--orange-l); color: var(--orange-d); }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.main h2 { font-size: 19px; margin-bottom: 4px; }
.main .lead { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 11px 12px; background: #fbf8f4; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid #f6f1ea; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fffdfa; }
.tbl .num { font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; }

.ov { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ov-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.ov-card .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.ov-card .v { font-size: 24px; font-weight: 800; margin-top: 2px; }
.ov-card .v small { font-size: 13px; color: var(--muted); font-weight: 600; }

.editor-q { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.editor-q .row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.editor-q .row select, .editor-q .row input[type="number"] {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fdfcfb; font-size: 13px;
}
.opt-edit { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.opt-edit input[type="text"] { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; background: #fdfcfb; font-size: 14px; }
.opt-edit .mark { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(30, 20, 10, 0.42); z-index: 60;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 720px; max-height: 88vh;
  overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h3 { font-size: 17px; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; position: sticky; bottom: 0; background: #fff; padding-top: 12px; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  background: #2b2118; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.err { background: #b3261e; }

.ans-view { background: #faf7f2; border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-top: 8px; }
.ans-view .lbl { color: var(--muted); font-size: 12px; font-weight: 700; }

@media (max-width: 720px) {
  .admin-shell { flex-direction: column; }
  .side { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; gap: 4px; }
  .side .brand { display: none; }
  .nav-btn { white-space: nowrap; padding: 8px 12px; }
  .main { padding: 16px 14px 60px; }
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 9px 8px; }
  .stu-bar { flex-direction: column; align-items: stretch; }
}
