:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #667085;
  --line: #e3e8ef;
  --blue: #2563eb;
  --blue-soft: #eff4ff;
  --teal: #0f9b8e;
  --teal-soft: #e8f8f5;
  --amber: #b45309;
  --amber-soft: #fff5e6;
  --red: #c0392b;
  --red-soft: #fdeceb;
  --green: #1e7e45;
  --green-soft: #e9f7ef;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overflow-x: hidden;
}

input, textarea { -webkit-user-select: text; user-select: text; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 600; }
.brand p { font-size: 12px; margin: 0; color: var(--muted); }
.lang-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}

.stage-pill {
  display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); margin-bottom: 12px;
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}

.hero h2 { font-size: 22px; margin: 0 0 4px; }
.hero .sub { color: var(--teal); font-weight: 600; margin-bottom: 16px; }

.info-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.info-tag {
  flex: 0 0 64px; font-size: 12px; font-weight: 600; color: var(--blue);
  background: var(--blue-soft); border-radius: 6px; padding: 2px 6px; text-align: center;
}
.info-body { flex: 1; font-size: 14px; }

.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 11px 20px;
  font-size: 15px; font-weight: 600; cursor: pointer; background: var(--blue); color: #fff;
  margin: 4px 6px 4px 0;
}
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.opt-list { display: grid; gap: 10px; margin: 14px 0; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 12px 14px; font-size: 15px; cursor: pointer;
}
.opt:hover { border-color: var(--blue); }
.opt .key {
  flex: 0 0 26px; height: 26px; border-radius: 6px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted);
}
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }

.feedback { border-radius: 8px; padding: 12px 14px; margin: 10px 0; font-size: 14px; }
.feedback.ok { background: var(--green-soft); color: var(--green); }
.feedback.no { background: var(--red-soft); color: var(--red); }
.feedback .why { color: var(--ink); margin-top: 6px; }
.mis-tag {
  display: inline-block; font-size: 12px; background: var(--amber-soft); color: var(--amber);
  border-radius: 6px; padding: 2px 8px; margin-top: 6px;
}

.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.qhead .count { font-size: 12px; color: var(--muted); }
.prompt { font-size: 17px; font-weight: 600; margin: 6px 0 14px; }

.progress-wrap { margin: 10px 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.progress-track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--teal); border-radius: 999px; transition: width .3s; }

.node-list { display: grid; gap: 10px; }
.node-card {
  display: flex; align-items: center; gap: 12px; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; background: var(--card);
}
.node-card.locked { opacity: .55; }
.node-num {
  flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--blue-soft);
  color: var(--blue); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}
.node-card.mastered .node-num { background: var(--green-soft); color: var(--green); }
.node-main { flex: 1; min-width: 0; }
.node-title { font-weight: 600; font-size: 15px; }
.node-meta { font-size: 12px; color: var(--muted); }
.bar-mini { height: 6px; background: var(--bg); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.bar-mini > i { display: block; height: 100%; background: var(--teal); }

.contract-block { margin-bottom: 14px; }
.contract-block h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--blue);
  margin: 0 0 4px; font-weight: 600;
}
.contract-block p { margin: 0; font-size: 14px; }
.steps { margin: 6px 0 0; padding-left: 18px; }
.steps li { font-size: 14px; margin-bottom: 3px; }
.expr { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 16px; font-weight: 600; color: var(--teal); }
.answer-chip { display: inline-block; background: var(--green-soft); color: var(--green); border-radius: 6px; padding: 2px 10px; font-weight: 600; }

.cert { text-align: center; padding: 28px 18px; }
.cert .badge {
  width: 72px; height: 72px; border-radius: 50%; background: var(--amber-soft); color: var(--amber);
  display: flex; align-items: center; justify-content: center; font-size: 34px; margin: 0 auto 14px;
}
.cert h2 { margin: 0 0 8px; }
.cert .rate { font-size: 28px; font-weight: 600; color: var(--teal); margin: 10px 0; }

.notice { font-size: 13px; color: var(--muted); margin-top: 12px; }
.ai-note { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 14px; }

@media (max-width: 480px) {
  .wrap { padding: 12px 12px 32px; }
  .card { padding: 14px; }
  .hero h2 { font-size: 19px; }
  .prompt { font-size: 16px; }
}

@media (max-height: 480px) {
  .wrap { padding-top: 8px; padding-bottom: 16px; }
  .card { padding: 12px; margin-bottom: 10px; }
  .hero h2 { font-size: 17px; }
  .opt { padding: 8px 12px; }
}

/* 密码门 */
body.is-gated #app { display: none; }
.gate {
  position: fixed; inset: 0; z-index: 9999; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #eef2f9 0%, #dde7f6 100%);
}
.gate.hidden { display: none; }
.gate-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 30px 24px; text-align: center;
  box-shadow: 0 18px 50px rgba(30,50,90,.16);
}
.gate-badge { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.gate-card h2 { margin: 0 0 8px; font-size: 19px; }
.gate-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.gate-input {
  width: 100%; padding: 12px 14px; font-size: 15px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 12px; outline: none; text-align: center;
}
.gate-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.gate-btn {
  width: 100%; padding: 12px; font-size: 16px; font-weight: 600; color: #fff;
  background: var(--blue); border: none; border-radius: 10px; cursor: pointer;
}
.gate-btn:disabled { opacity: .6; cursor: wait; }
.gate-error { color: var(--red); font-size: 13px; margin: 12px 0 0; }
.gate-hint { color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.hidden { display: none !important; }
