:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7788;
  --line: #dfe4ec;
  --accent: #2463d4;
  --accent-soft: #e8f0ff;
  --green: #16803f;
  --green-soft: #e9f8ef;
  --red: #c0362c;
  --red-soft: #fdeeec;
  --amber: #8a5a00;
  --amber-soft: #fff5dc;
  --chip: #eef1f6;
  --shadow: 0 1px 2px rgba(20, 33, 55, .06), 0 6px 18px rgba(20, 33, 55, .05);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --card: #1a202a;
    --text: #e7ecf4;
    --muted: #98a4b6;
    --line: #2b3441;
    --accent: #6c9dff;
    --accent-soft: #1d2b45;
    --green: #4fd18b;
    --green-soft: #14301f;
    --red: #ff8b80;
    --red-soft: #341c1a;
    --amber: #ffcf70;
    --amber-soft: #33280d;
    --chip: #232c38;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 0 10px 0 6px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.appbar-title {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .5px;
}

.appbar-extra { font-size: 12px; color: var(--muted); }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:active { background: var(--chip); }

.view {
  flex: 1;
  padding: 14px 12px 104px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card h2 { margin: 0 0 6px; font-size: 20px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }

.muted { color: var(--muted); }
.fine { margin: 6px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.center { text-align: center; }

/* ---------- 首页 ---------- */

.hero { background: linear-gradient(135deg, #24406b, #1b2c48); color: #f2f6ff; border: 0; }
.hero .hero-kicker { margin: 0 0 6px; font-size: 11.5px; letter-spacing: 1.6px; opacity: .75; }
.hero h2 { font-size: 22px; margin: 0 0 4px; }
.hero .muted { color: #c4d2e8; font-size: 13px; }

.stat-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.stat-row > div {
  flex: 1;
  background: rgba(255, 255, 255, .1);
  border-radius: 11px;
  padding: 8px 6px;
  text-align: center;
}

.stat-row strong { display: block; font-size: 19px; }
.stat-row span { font-size: 11.5px; opacity: .78; }

.hero .fine { color: #c4d2e8; margin-top: 10px; }

.resume-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.resume-card .grow { flex: 1; min-width: 0; }
.resume-card h3 { margin: 0 0 2px; font-size: 15px; }
.resume-card p { margin: 0; font-size: 12.5px; color: var(--muted); }

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--chip);
  margin-bottom: 12px;
}

.seg button {
  flex: 1;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14.5px;
  font-family: inherit;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(20, 33, 55, .14);
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.field > span {
  flex: none;
  width: 42px;
  font-size: 14px;
  color: var(--muted);
}

.field select {
  flex: 1;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary.btn-muted { background: var(--chip); border-color: var(--line); color: var(--muted); }
.btn-ghost { background: var(--chip); border-color: transparent; }
.btn-small { min-height: 38px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-ai { width: 100%; background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.tile {
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.tile span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.5;
}

.ai-card p { margin: 0; font-size: 13.5px; color: var(--muted); }

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

.qmeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.chip-strong { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip-ok { background: var(--green-soft); color: var(--green); }
.chip-bad { background: var(--red-soft); color: var(--red); }
.chip-ghost { background: transparent; border: 1px solid var(--line); }

.counter { margin-left: auto; font-size: 12.5px; color: var(--muted); }

.stem {
  margin: 0 0 16px;
  font-size: 16.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.options { display: flex; flex-direction: column; gap: 10px; }

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.6;
  text-align: left;
  cursor: pointer;
}

.option .key {
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.option .text { flex: 1; white-space: pre-wrap; overflow-wrap: break-word; }

.option.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.option.is-selected .key { background: var(--accent); color: #fff; }
.option.is-correct { border-color: var(--green); background: var(--green-soft); }
.option.is-correct .key { background: var(--green); color: #fff; }
.option.is-wrong { border-color: var(--red); background: var(--red-soft); }
.option.is-wrong .key { background: var(--red); color: #fff; }
.option.is-static { cursor: default; }

.option .mark {
  flex: none;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}

.feedback.ok { border-color: var(--green); background: var(--green-soft); }
.feedback.bad { border-color: var(--red); background: var(--red-soft); }

.fb-head { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.feedback.ok .fb-head { color: var(--green); }
.feedback.bad .fb-head { color: var(--red); }

.fb-row {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  font-size: 14px;
  border-top: 1px dashed rgba(120, 130, 150, .35);
}

.fb-row:first-of-type { border-top: 0; }
.fb-row span { flex: none; width: 72px; color: var(--muted); }
.fb-row strong { flex: 1; font-weight: 600; overflow-wrap: break-word; }
.fb-note { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }

.ai-panel { margin-top: 14px; }
.ai-loading { padding: 14px; border-radius: 12px; background: var(--chip); color: var(--muted); font-size: 14px; }

.ai-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 14px;
}

.ai-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

.ai-body { font-size: 14.5px; line-height: 1.75; overflow-wrap: break-word; }
.ai-body p { margin: 0 0 8px; }
.ai-body p:last-child { margin-bottom: 0; }
.ai-body .md-h { font-weight: 700; }
.ai-body .md-li { padding-left: 14px; position: relative; }
.ai-body .md-li::before { content: "·"; position: absolute; left: 2px; color: var(--muted); }

.ai-error {
  border: 1px solid var(--red);
  border-radius: 12px;
  background: var(--red-soft);
  padding: 12px;
}

.ai-error p { margin: 0 0 10px; font-size: 14px; color: var(--red); }
.ai-error .btn { background: transparent; border-color: var(--red); color: var(--red); }

.hint-box {
  padding: 12px;
  border-radius: 12px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 10px;
}

/* ---------- 底部操作栏 ---------- */

.bottombar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 30;
  width: 100%;
  max-width: 600px;
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
}

.bottombar .btn { flex: 1; }
.bottombar .btn-primary { width: auto; }
.bottombar .btn-narrow { flex: 0 0 92px; }

/* ---------- 考试 ---------- */

.exam-tip {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12.5px;
  line-height: 1.6;
}

.sheet-wrap { margin-top: 16px; }
.sheet-wrap summary { cursor: pointer; font-size: 14px; color: var(--muted); }

.sheet {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.sheet button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.sheet button.is-done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.sheet button.is-current { outline: 2px solid var(--accent); outline-offset: 1px; }
.sheet button.is-right { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 700; }
.sheet button.is-answer-wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); font-weight: 700; }

.score-card { text-align: center; }
.score-card .score { font-size: 56px; font-weight: 800; line-height: 1.1; color: var(--accent); }
.score-card .score span { font-size: 18px; color: var(--muted); font-weight: 600; }
.score-card .score-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.result-list { display: flex; flex-direction: column; gap: 10px; }

.result-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.result-row .grow { flex: 1; min-width: 0; }
.result-row .result-title { font-size: 13.5px; font-weight: 600; }
.result-row .result-detail { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); overflow-wrap: break-word; }

/* ---------- 错题本 ---------- */

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }

.tabs button {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.tabs button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.wrong-item .stem {
  margin: 8px 0;
  font-size: 14.5px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-actions { display: flex; gap: 8px; margin-top: 10px; }
.row-actions .btn { flex: 1; min-height: 40px; font-size: 13.5px; }

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

.conflict-item { border-color: var(--amber); }
.conflict-source {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  background: var(--chip);
  font-size: 13px;
  overflow-wrap: break-word;
}
.conflict-source strong { font-weight: 700; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 40px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(22, 30, 42, .92);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}

@media (max-width: 360px) {
  .view { padding-left: 10px; padding-right: 10px; }
  .stem { font-size: 15.5px; }
  .score-card .score { font-size: 48px; }
  .sheet { grid-template-columns: repeat(5, 1fr); }
}}
/* ---------- 公网版：顶部设置与弹窗 ---------- */

.header-btn {
  flex: none;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.header-btn:active { background: var(--chip); }

.dialog {
  width: min(92vw, 420px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 18px 50px rgba(10, 20, 40, .35);
}

.dialog::backdrop { background: rgba(12, 18, 28, .55); }

.dialog-body { padding: 18px; }

.dialog-body h2 { margin: 0 0 8px; font-size: 18px; }

.field-block { display: block; margin-bottom: 12px; }

.field-block span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field-block input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.dialog-error {
  margin: 0 0 12px;
  padding: 10px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  line-height: 1.6;
}

.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

.dialog-hr { margin: 16px 0 12px; border: 0; border-top: 1px solid var(--line); }

.btn-danger { width: 100%; color: var(--red); border-color: var(--red); }

.about-card p { margin: 0 0 6px; }
.about-card p:last-child { margin-bottom: 0; }

/* ---------- 题库导入 ---------- */

.field-block textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.field-block input[type="file"] {
  width: 100%;
  font-family: inherit;
  font-size: 12px;
  color: var(--muted);
}

.format-help { margin-top: 14px; font-size: 12px; color: var(--muted); }
.format-help summary { cursor: pointer; }
.format-help pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 10px;
  background: var(--chip);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.bank-card .row-actions { margin-top: 4px; }

/* ---------- 在线版：登录、账号、管理 ---------- */

.auth-card { margin-top: 8vh; }
.auth-card h2 { margin-bottom: 4px; }

.account-actions { display: flex; flex-direction: column; gap: 8px; }

.two-cols { display: flex; gap: 10px; }
.two-cols .field-block { flex: 1; }

.q-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.q-option { display: flex; align-items: center; gap: 8px; }
.q-option .key {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--chip); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.q-option input {
  flex: 1; min-height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px;
}

.q-answers { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.q-answers label { display: flex; align-items: center; gap: 5px; font-size: 14px; }

.admin-row {
  display: flex; gap: 10px; padding: 10px;
  border: 1px solid var(--line); border-radius: 11px; margin-bottom: 10px;
}
.admin-row .grow { flex: 1; min-width: 0; }
.admin-row .admin-stem {
  margin: 4px 0; font-size: 13.5px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.admin-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
.admin-actions .btn { min-height: 34px; padding: 0 10px; font-size: 12.5px; }

.admin-search { display: flex; gap: 8px; margin-bottom: 10px; }
.admin-search input {
  flex: 1; min-height: 42px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px;
}

.import-preview { margin: 10px 0; padding: 10px; border-radius: 10px; background: var(--chip); font-size: 12.5px; max-height: 220px; overflow: auto; }
.import-counts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.import-error-list { margin: 6px 0 0; padding-left: 18px; color: var(--red); }
.import-preview-row { color: var(--muted); }

.legacy-confirm { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; font-size: 13px; line-height: 1.5; }

.quota-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; }
.quota-row .grow { flex: 1; min-width: 0; }
.quota-row input { width: 72px; min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; }
