:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --warn: #b45309;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-in {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding-top: 12px; padding-bottom: 12px;
}
.top h1 { font-size: 20px; margin: 0; }
.tabs { display: flex; gap: 4px; }
.tab-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 15px;
}
.tab-btn:hover { background: var(--brand-soft); color: var(--brand); }
.tab-btn.active { background: var(--brand); color: #fff; font-weight: 600; }
.stat {
  margin-left: auto; font-size: 13px; color: var(--muted);
  background: var(--bg); padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}

/* ---------- layout ---------- */
main { padding-top: 18px; padding-bottom: 40px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.hidden { display: none !important; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.tip { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ---------- form controls ---------- */
.field { margin-bottom: 16px; }
.field-label { font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.inline-label {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 18px;
  background: var(--bg); padding: 7px 12px; border-radius: 10px; font-size: 14px; cursor: pointer;
}
.inline-label.disabled { opacity: .5; }
input[type="text"], input:not([type]), textarea, select, .search {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); border-color: transparent; }
textarea { resize: vertical; }

.mode-box {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer;
}
.mode-box input { margin-top: 4px; }
.mode-box b { font-size: 15px; }
.mode-box small { display: block; color: var(--muted); }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.add-grid input:nth-child(3) { grid-column: 1 / -1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; cursor: pointer;
  font-family: inherit; transition: filter .12s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; }
.btn-warn { background: #fef3c7; border-color: #fcd34d; color: var(--warn); }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: #fecaca; }
.btn-danger-ghost:hover { background: var(--bad-bg); }
.btn-lg { width: 100%; padding: 13px; font-size: 16px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.row.between { justify-content: space-between; margin-top: 0; }
.file-btn { position: relative; overflow: hidden; }
.hidden-input { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; }

/* ---------- study / quiz ---------- */
.run-top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.progress {
  flex: 1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden;
}
.progress i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .2s; }
#progTxt { font-size: 13px; color: var(--muted); white-space: nowrap; }
.chip {
  font-size: 12px; background: var(--brand-soft); color: var(--brand);
  padding: 3px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.quiz-card { text-align: center; padding: 28px 24px; }
.quiz-meta { display: flex; justify-content: center; align-items: center; gap: 10px; }
.dir-txt { font-size: 13px; color: var(--muted); }
.type-desc { color: var(--muted); margin: 10px 0 4px; font-size: 14px; }
.prompt {
  font-size: 26px; font-weight: 700; margin: 18px 0; min-height: 46px;
  word-break: break-word; line-height: 1.5;
}
.prompt .fill {
  background: var(--brand-soft); color: var(--brand); border-radius: 6px;
  padding: 2px 8px; letter-spacing: 3px;
}
.hint { color: var(--muted); font-size: 15px; margin: 6px 0 14px; }
.ans-zone { margin-top: 10px; }
.type-row { display: flex; gap: 10px; max-width: 520px; margin: 0 auto; }
.type-row input { flex: 1; text-align: center; font-size: 18px; letter-spacing: 1px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 560px; margin: 0 auto; }
.opt {
  border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 14px 10px;
  font-size: 17px; cursor: pointer; font-family: inherit; color: var(--text);
}
.opt:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.opt.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.opt:disabled { cursor: default; opacity: .85; }

.feedback { margin-top: 18px; padding: 14px 16px; border-radius: 12px; font-size: 15px; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.no { background: var(--bad-bg); color: var(--bad); }
.feedback .fb-head { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.feedback .fb-correct { color: var(--text); font-weight: 600; }
.feedback .fb-note { color: var(--muted); font-size: 13px; }
#nextBtn { margin-top: 14px; }

/* ---------- result ---------- */
.result-card { text-align: center; }
#scoreTxt { font-size: 18px; margin: 4px 0 12px; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), #8b5cf6); transition: width .4s; }
.wrong-list { text-align: left; background: var(--bg); border-radius: 12px; padding: 14px 18px; margin-bottom: 16px; }
.wrong-list h3 { margin: 0 0 10px; font-size: 15px; }
.wrong-list ul { margin: 0; padding: 0; list-style: none; }
.wrong-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.wrong-list li:last-child { border-bottom: none; }
.wrong-list .en { font-weight: 700; }
.wrong-list .zh { color: var(--muted); }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- word lists ---------- */
#wordList, #errList { list-style: none; margin: 12px 0 0; padding: 0; }
.w-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 6px;
  border-bottom: 1px solid var(--line);
}
.w-row:last-child { border-bottom: none; }
.w-main { flex: 1; min-width: 0; }
.w-main .en { font-weight: 700; }
.w-main .zh { color: var(--muted); margin-left: 8px; }
.w-main .ex { display: block; color: var(--muted); font-size: 13px; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-count { color: var(--bad); font-weight: 700; font-size: 13px; white-space: nowrap; }
.w-actions { display: flex; gap: 6px; white-space: nowrap; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 6px 0 30px; }

@media (max-width: 600px) {
  .top-in { gap: 10px; }
  .stat { margin-left: 0; }
  .opts { grid-template-columns: 1fr; }
  .add-grid { grid-template-columns: 1fr; }
  .add-grid input:nth-child(3) { grid-column: auto; }
  .prompt { font-size: 22px; }
}
