:root {
  --brand: #3f5bd9;
  --brand-dark: #1d2b6b;
  --brand-soft: #ecf0ff;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --text: #17181c;
  --muted: #5b6172;
  --hint: #9aa0b0;
  --divider: #e6e8f0;
  --correct: #1e8e5a;
  --correct-bg: #e4f6ec;
  --wrong: #d14343;
  --wrong-bg: #fdeBeb;
  --star: #f0a028;
  --shadow: 0 10px 30px rgba(28, 39, 76, 0.06);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--brand); }

/* ---------- 基础布局 ---------- */

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 28px calc(72px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topbar .sub {
  margin-left: 10px;
  color: var(--hint);
  font-size: 12px;
  font-weight: 400;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 18px;
  padding: 20px;
}

.section-label {
  margin: 26px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 76px;
}

.page-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.page-head .grow { flex: 1; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease;
}

.btn:hover { background: #3550c8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.block { width: 100%; height: 52px; font-size: 16px; border-radius: 14px; }

.btn.ghost {
  background: transparent;
  border-color: var(--divider);
  color: var(--text);
}
.btn.ghost:hover { background: #f7f8fd; border-color: #d6daea; }

.btn.text {
  background: transparent;
  color: var(--brand);
  padding: 0 10px;
  height: 40px;
}
.btn.text:hover { background: var(--brand-soft); }

.btn.danger { background: var(--wrong); }
.btn.danger:hover { background: #b93a3a; }

.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--hint);
  cursor: pointer;
}
.icon-btn:hover { background: #f2f4fb; color: var(--brand); }
.icon-btn.star-on { color: var(--star); }

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

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(135deg, #4a63e4 0%, #3348c4 55%, #2a3a96 100%);
  color: #fff;
  padding: 24px 26px;
  box-shadow: 0 16px 36px rgba(45, 60, 140, 0.22);
}

.hero .tag {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #b9c4ff;
}

.hero .big {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.hero .sub { margin-top: 10px; color: #b9c4ff; font-size: 12.5px; }

.bar {
  height: 7px;
  margin-top: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #fff;
  transition: width 0.35s ease;
}

.bar.on-light { background: var(--divider); }
.bar.on-light > i { background: var(--brand); }

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: start;
}

.stack { display: flex; flex-direction: column; gap: 20px; }

.book-card .row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.book-card .meta {
  flex: 1;
  min-width: 180px;
  color: var(--muted);
  font-size: 12.5px;
}

select.field {
  width: 100%;
  height: 50px;
  padding: 0 40px 0 14px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%235b6172' stroke-width='1.8' stroke-linecap='round'/></svg>") no-repeat right 14px center;
  appearance: none;
  cursor: pointer;
  font-size: 15px;
}
select.field:focus { outline: 2px solid rgba(63, 91, 217, 0.25); border-color: var(--brand); }

.mode-list { display: grid; gap: 10px; }

.mode {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  border: 1px solid var(--divider);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.mode:hover { border-color: #c9d1ef; box-shadow: var(--shadow); }

.mode.on {
  border-color: var(--brand);
  border-width: 2px;
  background: var(--brand-soft);
  padding: 14px 15px;
}

.mode .check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 2px solid #cfd4e4;
  color: #fff;
  font-size: 12px;
}
.mode.on .check { border-color: var(--brand); background: var(--brand); }

.mode b { display: block; font-size: 16px; }
.mode small { color: var(--muted); font-size: 12.5px; }

.settings .line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 14px;
}

.settings .line .title { font-weight: 600; }
.settings .line small { color: var(--muted); font-size: 12.5px; }

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--divider);
  border-radius: 11px;
  background: #fff;
  font-size: 15px;
}
.input:focus { outline: 2px solid rgba(63, 91, 217, 0.25); border-color: var(--brand); }
.input.narrow { width: 110px; text-align: center; }

.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  cursor: pointer;
  user-select: none;
}
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand); }

.divider { height: 1px; margin: 16px 0; background: var(--divider); }

.hint { color: var(--hint); font-size: 12px; }

.footer-actions { display: flex; gap: 10px; margin-top: 18px; }
.footer-actions .btn { flex: 1; }

/* ---------- 练习 ---------- */

.center-col { max-width: 780px; margin: 0 auto; }
.center-col.wide { max-width: 880px; }

.practice-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.practice-top .progress-text { color: var(--muted); font-size: 13px; white-space: nowrap; }

.prompt-card {
  margin-top: 18px;
  padding: 30px 28px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--divider);
  text-align: center;
}

.prompt-label {
  color: var(--hint);
  font-size: 11px;
  letter-spacing: 0.32em;
  font-weight: 700;
}

.prompt {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--divider);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font-size: 16px;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.opt:hover { border-color: #c9d1ef; box-shadow: var(--shadow); }
.opt:disabled { cursor: default; }

.opt .badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
}

.opt.correct { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); }
.opt.correct .badge { background: var(--correct); color: #fff; }
.opt.wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }
.opt.wrong .badge { background: var(--wrong); color: #fff; }

.spell-box { margin-top: 18px; }
.spell-hint {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  letter-spacing: 0.08em;
  text-align: center;
  font-size: 15px;
}

.feedback {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 14px;
  white-space: pre-line;
  font-size: 14px;
  line-height: 1.7;
}
.feedback.ok { background: var(--correct-bg); color: var(--correct); }
.feedback.no { background: var(--wrong-bg); color: var(--wrong); }

.practice-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.practice-actions .btn { flex: 1; }

.kbd-tip {
  margin-top: 14px;
  text-align: center;
  color: var(--hint);
  font-size: 12px;
}
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--divider);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
}

/* ---------- 结果 ---------- */

.result-card { padding: 26px 28px; }

.score {
  font-size: 54px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.result-detail { margin-top: 8px; color: var(--muted); font-size: 14px; }

.wrong-label {
  margin: 26px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.wrong-item {
  padding: 15px 18px;
  margin-bottom: 8px;
  border: 1px solid var(--divider);
  border-radius: 14px;
  background: var(--surface);
}
.wrong-item b { font-size: 17px; }
.wrong-item .m { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.wrong-item .a { margin-top: 4px; color: var(--wrong); font-size: 13px; }

/* ---------- 词表 ---------- */

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

.search {
  flex: 1;
  height: 46px;
  padding: 0 42px 0 14px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: #fff;
}
.search:focus { outline: 2px solid rgba(63, 91, 217, 0.25); border-color: var(--brand); }

.list-meta { color: var(--hint); font-size: 12.5px; margin: 6px 2px 10px; }

.word-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  margin-bottom: 7px;
  border: 1px solid var(--divider);
  border-radius: 13px;
  background: var(--surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.word-row:hover { border-color: #ccd4f2; box-shadow: var(--shadow); }

.word-row .idx {
  width: 34px;
  flex: none;
  color: var(--hint);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  text-align: right;
}

.word-row .body { flex: 1; min-width: 0; }
.word-row .w { font-size: 16.5px; font-weight: 700; }
.word-row .m { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.word-row .extra { color: var(--wrong); font-size: 12px; }

.word-row .acts { display: flex; gap: 2px; opacity: 0.55; transition: opacity 0.12s ease; }
.word-row:hover .acts { opacity: 1; }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 600;
}

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--hint);
  border: 1px dashed var(--divider);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

/* ---------- 导入 ---------- */

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  border: 1.5px dashed #c6cee8;
  border-radius: 16px;
  background: #fafbff;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-align: center;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop b { color: var(--text); }

textarea.input {
  height: 190px;
  padding: 12px 14px;
  resize: vertical;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

.preview {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12.5px;
  white-space: pre-line;
}

/* ---------- 关于弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(23, 24, 28, 0.42);
  backdrop-filter: blur(2px);
  z-index: 50;
}

.about-card {
  width: 380px;
  max-width: 100%;
  max-height: 88vh;
  overflow: auto;
  padding: 30px 26px 22px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(20, 28, 60, 0.3);
  text-align: center;
}

.about-card img.logo { width: 76px; height: 76px; border-radius: 18px; }

.about-card h3 { margin: 14px 0 2px; font-size: 20px; }
.about-card .ver { color: var(--muted); font-size: 13px; }
.about-card .sum { margin-top: 12px; color: var(--muted); font-size: 13px; white-space: pre-line; }

.about-rows {
  margin-top: 18px;
  padding-top: 6px;
  border-top: 1px solid var(--divider);
  text-align: left;
}

.about-row { display: flex; gap: 12px; padding: 6px 0; font-size: 13px; }
.about-row .k { width: 66px; flex: none; color: var(--hint); }
.about-row .v { flex: 1; }

.about-note {
  margin-top: 14px;
  color: var(--hint);
  font-size: 11.5px;
  text-align: left;
  white-space: pre-line;
}

.about-close { margin-top: 18px; }

.about-card a {
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1px solid rgba(63, 91, 217, 0.35);
}

.about-card a:hover { border-bottom-color: var(--brand); }
.about-card a:active { opacity: 0.7; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(8px);
  padding: 11px 20px;
  border-radius: 12px;
  background: rgba(23, 24, 28, 0.88);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 载入中 / 安装提示 ---------- */

.boot {
  padding: 120px 0;
  text-align: center;
  color: var(--hint);
  font-size: 14px;
}

.install-tip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 8px 10px 14px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12.5px;
  line-height: 1.5;
}

.install-tip span { flex: 1; }
.install-tip .icon-btn { flex: none; color: var(--brand); }

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  .app { padding: 0 16px 48px; }
  .home-grid { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .prompt { font-size: 27px; }
  .score { font-size: 44px; }
}

@media (max-width: 560px) {
  .app { padding: 0 14px calc(56px + env(safe-area-inset-bottom)); }
  .topbar, .page-head { min-height: 58px; height: auto; padding: 10px 0; }
  .topbar h1 { font-size: 19px; }
  .page-head h2 { font-size: 18px; }

  .hero { padding: 20px 18px; border-radius: 18px; }
  .hero .big { font-size: 25px; }

  .card { padding: 16px; border-radius: 16px; }
  .home-grid, .stack { gap: 14px; }

  .prompt-card { margin-top: 14px; padding: 22px 16px; }
  .prompt { font-size: 25px; }
  .opt { padding: 14px; font-size: 15.5px; }
  .spell-hint { font-size: 13.5px; overflow-x: auto; }

  .word-row { padding: 11px 12px; gap: 10px; }
  .word-row .w { font-size: 16px; }
  .word-row .acts { opacity: 1; }
  .book-card .meta { min-width: 0; }

  .modal { padding: 14px; }
  .about-card { padding: 24px 18px 18px; border-radius: 18px; }
  .score { font-size: 44px; }

  .toast {
    bottom: calc(28px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 28px);
    text-align: center;
  }

  /* iOS 上输入框字体小于 16px 会自动放大页面 */
  .input, .search, select.field, .opt, .btn { font-size: 16px; }
  .btn.small { font-size: 13px; }
}

/* ---------- 触屏 ---------- */

@media (hover: none) {
  .btn:hover { background: var(--brand); }
  .btn.ghost:hover { background: transparent; border-color: var(--divider); }
  .btn.text:hover { background: transparent; }
  .btn.danger:hover { background: var(--wrong); }
  .icon-btn:hover { background: transparent; color: var(--hint); }
  .mode:hover { border-color: var(--divider); box-shadow: none; }
  .opt:hover { border-color: var(--divider); box-shadow: none; }
  .word-row:hover { border-color: var(--divider); box-shadow: none; }
  .kbd-tip { display: none; }
}

button, .mode, .opt, .word-row, .drop { -webkit-tap-highlight-color: transparent; }

