/* =========================================================
 * WordMate 样式
 * 移动优先，桌面端自动居中为手机尺寸
 * ========================================================= */
:root {
  --brand: #5b5bd6;
  --brand-2: #7c6cf6;
  --brand-soft: #eeedff;
  --ok: #21a67a;
  --warn: #e8912d;
  --danger: #e05b62;
  --text: #1b1b21;
  --muted: #7a7a8c;
  --line: #e8e8f0;
  --bg: #f6f6fa;
  --card: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 22px rgba(38, 38, 70, 0.07);
  --shadow-lg: 0 18px 44px rgba(38, 38, 70, 0.16);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: #e9e9f2;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pad { padding: 8px 2px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 外壳 ---------------- */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100%;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(30, 30, 60, 0.04), 0 20px 60px rgba(30, 30, 60, 0.12);
}

@media (min-width: 760px) {
  body { display: grid; place-items: center; padding: 18px; }
  .app-shell {
    height: min(900px, calc(100vh - 36px));
    border-radius: 28px;
  }
}

#app {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  scroll-behavior: smooth;
}

.view {
  display: none;
  padding: 16px 16px 8px;
  animation: fadeUp .28s ease both;
}
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 通用顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand h1 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.brand p { margin-top: 2px; }

.logo {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  background: linear-gradient(140deg, var(--brand-2), var(--brand));
  box-shadow: 0 6px 16px rgba(91, 91, 214, .28);
  flex: none;
}
.logo.alt {
  font-size: 18px;
  background: linear-gradient(140deg, #ffd7a8, #f2a25c);
  box-shadow: 0 6px 16px rgba(242, 162, 92, .3);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: .18s;
  flex: none;
}
.icon-btn:hover { color: var(--brand); border-color: #d9d6ff; }
.icon-btn:active { transform: scale(.95); }
.icon-btn.subtle { border: none; background: transparent; font-size: 18px; color: var(--muted); }
.icon-btn.tiny {
  width: 30px; height: 30px; border-radius: 9px; font-size: 14px; border-color: transparent;
  background: #f3f3f9;
}

/* ---------------- 按钮 ---------------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform .12s, background .18s, box-shadow .18s, opacity .18s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff;
  box-shadow: 0 8px 20px rgba(91, 91, 214, .28);
}
.btn.primary:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }
.btn.ghost {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn.ghost:hover { border-color: #d9d6ff; color: var(--brand); }
.btn.danger { background: #fdecec; color: var(--danger); }
.btn.small { padding: 9px 14px; font-size: 13px; border-radius: 10px; }
.btn.tiny { padding: 7px 10px; font-size: 12px; border-radius: 9px; }

.link-btn {
  background: none; border: none; color: var(--brand); font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 4px 2px;
}

/* ---------------- 学习页 ---------------- */
.progress-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.progress-head { display: flex; align-items: center; justify-content: space-between; }
.big { font-size: 26px; font-weight: 800; letter-spacing: -.4px; }
.big .muted { font-weight: 600; font-size: 16px; }

.ring {
  width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; color: var(--brand);
  background:
    radial-gradient(closest-side, #fff 76%, transparent 77% 100%),
    conic-gradient(var(--brand) calc(var(--p) * 1%), #ecebf7 0);
}

.progress-bar {
  height: 7px;
  border-radius: 99px;
  background: #eeedf6;
  overflow: hidden;
  margin: 12px 0 12px;
}
.progress-bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}
.progress-bar.thin { height: 4px; margin: 10px 0 0; }

.stat-row { display: flex; gap: 8px; }
.stat {
  flex: 1;
  background: #f8f8fc;
  border-radius: 12px;
  padding: 9px 6px;
  text-align: center;
}
.stat b { display: block; font-size: 16px; }
.stat span { font-size: 11.5px; color: var(--muted); }

.card-deck { min-height: 320px; }

.word-card {
  background: var(--card);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
  animation: cardIn .34s cubic-bezier(.2,.8,.2,1) both;
  position: relative;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.chip {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 99px;
}
.chip.sm { padding: 3px 8px; font-size: 11px; }

.card-face { padding: 14px 6px 6px; cursor: pointer; min-height: 176px; }
.word-line { display: flex; align-items: center; gap: 10px; justify-content: center; }
.word-line h2 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.6px;
  text-align: center;
  word-break: break-word;
  line-height: 1.15;
}
.phonetic { text-align: center; color: var(--muted); margin-top: 6px; font-size: 14px; min-height: 18px; }
.pos-inline {
  font-size: 12.5px; font-weight: 600; color: var(--brand);
  background: var(--brand-soft); border-radius: 8px; padding: 2px 8px;
  white-space: nowrap;
}
.pos-inline:empty { display: none; }
.hint-tap { text-align: center; margin-top: 22px; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: .45; } 50% { opacity: 1; } }

.card-back {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .32s ease, opacity .28s ease, margin .3s;
  text-align: center;
}
.card-back.show { max-height: 460px; opacity: 1; margin-top: 14px; }
.card-back .pos { color: var(--brand); font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.card-back .meaning { font-size: 19px; font-weight: 700; line-height: 1.45; }
.card-back .example {
  margin-top: 10px;
  padding: 0 4px;
  color: #55556b;
  font-size: 13.5px;
  line-height: 1.6;
  font-style: italic;
}
/* 英文释义：弱化在中文释义下面，帮助建立英英思维 */
.card-back .endef {
  margin: 6px 0 0;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  font-style: italic;
  text-align: center;
}
/* 常用搭配：翻到背面后出现在释义下方 */
.phrase-block {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--brand-soft);
  text-align: left;
}
.phrase-title {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--brand);
}
.phrase-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.phrase-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 13px;
  line-height: 1.45;
}
.phrase-en {
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
/* 搭配里把本词单独标出来：drug abuse → drug 后加粗 abuse */
.phrase-en b {
  font-weight: 800;
  color: var(--brand);
  background: rgba(109, 91, 240, .12);
  border-radius: 5px;
  padding: 0 2px;
}
.phrase-zh { color: #55556b; }
/* 例句：英文为主，中文对照在下面 */
.example-block {
  margin-top: 12px;
  padding: 0 6px;
  text-align: left;
}
.example-en {
  margin: 0;
  color: #3d3d55;
  font-size: 13.5px;
  line-height: 1.6;
  font-style: italic;
}
.example-zh {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}
/* 同族词：派生形式，最弱的一层 */
.family-block {
  margin-top: 12px;
  padding: 0 6px;
  text-align: left;
}
.family-title {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
}
.family-list { display: flex; flex-wrap: wrap; gap: 6px; }
.family-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9px;
  background: rgba(120, 120, 160, .09);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}
.family-chip b { color: #4a4a63; font-weight: 600; }
/* 词根助记：一行小提示 */
.root-line {
  margin: 10px 0 0;
  padding: 0 6px;
  color: #8a7b4a;
  font-size: 12px;
  line-height: 1.55;
  text-align: left;
}
.card-back .note {
  margin-top: 8px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.faq-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  text-align: left;
}
.faq-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: #55556b;
}
.faq-line span { flex: 1; }
.tag {
  font-size: 11.5px;
  color: #63637a;
  background: #f2f2f8;
  border-radius: 99px;
  padding: 3px 9px;
}
.tag.sm { font-size: 10.5px; padding: 2px 7px; }

.card-image {
  margin: 14px auto 0;
  max-height: 130px;
  border-radius: 12px;
  object-fit: cover;
}

.rating-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
  animation: fadeUp .26s ease both;
}
.rate {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px 4px;
  background: #fff;
  cursor: pointer;
  display: grid;
  gap: 2px;
  transition: .16s;
}
.rate b { font-size: 14px; }
.rate small { font-size: 10.5px; color: var(--muted); }
.rate.again { border-color: #f6d0d2; background: #fef7f7; color: #c9454c; }
.rate.hard { border-color: #f7e2c8; background: #fffaf4; color: #c07517; }
.rate.good { border-color: #cdebdf; background: #f4fdf9; color: #178a62; }
.rate:active { transform: scale(.96); }

.card-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: center; }
.card-actions .btn { flex: 1; }

.empty-state {
  background: var(--card);
  border-radius: 22px;
  padding: 40px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.empty-state .emoji { font-size: 40px; margin-bottom: 8px; }
.empty-state h3 { font-size: 17px; margin-bottom: 6px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

.today-list { margin-top: 20px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-head h3 { font-size: 15px; font-weight: 700; }
.head-tools { display: flex; gap: 12px; }

.mini-list { display: grid; gap: 8px; }
.mini-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 2px 10px rgba(30, 30, 60, .04);
  cursor: pointer;
}
.mini-main { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.mini-main b { font-size: 14.5px; }
.mini-item .ellipsis { max-width: 150px; }

/* ---------------- 拍照页 ---------------- */
.upload-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.upload-inner {
  border: 2px dashed #dedcf0;
  border-radius: 14px;
  padding: 30px 16px;
  text-align: center;
  cursor: pointer;
  transition: .2s;
  background: linear-gradient(180deg, #fbfbff, #f7f7fd);
}
.upload-inner:hover { border-color: #c9c5f7; }
.upload-icon {
  width: 52px; height: 52px; margin: 0 auto 10px;
  display: grid; place-items: center;
  font-size: 26px; color: var(--brand);
  border-radius: 50%;
  background: var(--brand-soft);
}
.upload-title { font-weight: 700; margin-bottom: 4px; }
.upload-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.preview-wrap { padding: 4px; }
.preview-wrap img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 12px;
  background: #f1f1f7;
}
.preview-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }

.ocr-status {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px;
  border: 3px solid #e7e5fb;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ocr-result {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.raw-text {
  background: #f7f7fb;
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  color: #55556b;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 8px 0 4px;
}
.muted[role="button"] { cursor: pointer; user-select: none; display: inline-block; margin: 2px 0 10px; }

.word-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  transition: .16s;
  max-width: 100%;
}
.pill .pill-word { font-weight: 600; font-size: 14px; }
.pill .pill-mean { font-size: 11.5px; color: var(--muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.on {
  background: var(--brand-soft);
  border-color: #c3bdf9;
  color: var(--brand);
}
.pill.on .pill-word { color: var(--brand); }
.pill.dup { opacity: .55; cursor: default; }
.pill .pill-flag { font-style: normal; font-size: 10.5px; color: var(--ok); }
.pill .pill-flag.prof { color: var(--brand); font-weight: 600; }

.batch-form { border-top: 1px dashed var(--line); padding-top: 12px; }
.batch-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }

.card-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13px; font-weight: 600; color: #4a4a5e; }
.field > span em { color: var(--danger); font-style: normal; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 14.5px;
  font-family: inherit;
  background: #fcfcfe;
  outline: none;
  transition: .16s;
  resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: #b9b4f5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(91, 91, 214, .1);
}
.field-hint { font-size: 11.5px; color: var(--muted); min-height: 15px; }
.field-hint[data-state="warn"] { color: var(--warn); }
.field-hint[data-state="ok"] { color: var(--ok); }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-row .field.narrow { flex: 0 0 92px; }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.form-actions .btn { flex: 0 1 auto; min-width: 0; }

/* 两个并排的长文案按钮（如「开始认词测试」+「按记忆曲线开始学习」）：
   窄屏改为上下各占满一行，避免文字撑出卡片 */
.form-actions .btn.wide { flex: 1 1 190px; }
@media (max-width: 400px) {
  .form-actions .btn.wide { flex-basis: 100%; }
}

.photo-preview { position: relative; margin: -4px 0 14px; }
.photo-preview img { max-height: 130px; border-radius: 12px; }
.chip-x {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(20,20,40,.6); color: #fff;
  font-size: 12px; cursor: pointer;
}

.tip-card {
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.tip-card h4 { font-size: 13.5px; margin-bottom: 6px; }
.tip-card ul { margin: 0; padding-left: 18px; line-height: 1.75; }
.tip-card li { margin-bottom: 2px; }
.tip-card code { background: #eeedf8; padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }

/* ---------------- 计划页 ---------------- */
.test-card {
  background: linear-gradient(160deg, #fbfbff, #f3f2fd);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 16px;
  text-align: center;
  margin: 14px 0 10px;
}
.test-card h2 {
  font-size: 32px;
  letter-spacing: -.5px;
  font-weight: 800;
  word-break: break-word;
}
.plan-batch { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.plan-batch-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.plan-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.plan-group-name { font-size: 12px; color: var(--brand); font-weight: 600; margin-right: 2px; }

/* 联想词表（计划页展开区） */
.plan-topics { margin-top: 8px; }
.plan-topics:empty { display: none; }
.topic-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.topic-block:last-child { border-bottom: 0; }
.topic-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-bottom: 2px;
}

/* 词卡里的同类词联想 */
.card-topic {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  text-align: left;
}
.topic-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.topic-head b { color: var(--brand); margin-right: 6px; }
.topic-chip { cursor: pointer; border: 1px solid var(--line); background: #fff; }
.topic-chip:active { background: var(--brand-soft); }

/* ---------------- 联网导入 ---------------- */
.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #55556b;
  margin: 2px 0 10px;
  cursor: pointer;
  user-select: none;
}
.switch-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.switch-row { display: flex; flex-wrap: wrap; gap: 16px; }

.online-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.online-head h3 { font-size: 20px; letter-spacing: -.3px; }
.online-zh {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
}
.online-defs { margin-top: 10px; display: grid; gap: 10px; }
.online-def { display: grid; gap: 4px; }
.online-def .pos-tag { color: var(--brand); font-size: 12px; font-weight: 700; }
.online-def p { font-size: 13.5px; line-height: 1.6; color: #44445a; }
.online-def em { display: block; color: var(--muted); font-size: 12.5px; }

.bulk-progress { margin-top: 10px; }

/* 识别结果里的补全状态 */
.pill.merged { border-color: #cdebdf; }
.pill.pending { opacity: .72; }
.pill .pill-flag.ok { color: var(--ok); }
.pill .pill-flag.bad { color: var(--warn); }

/* ---------------- 分段控件 ---------------- */
.segmented {
  display: flex;
  background: #ecebf5;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.seg {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 9px;
  padding: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: .18s;
}
.seg.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(30,30,60,.1); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .24s ease both; }

/* ---------------- 词库 ---------------- */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border-radius: 13px;
  padding: 0 12px;
  box-shadow: 0 2px 10px rgba(30,30,60,.05);
  margin-bottom: 12px;
  color: var(--muted);
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  padding: 13px 0;
  font-size: 14.5px;
  background: transparent;
}
.search-box .chip-x { position: static; background: #efeff6; color: var(--muted); }

.filter-row, .tag-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar, .tag-row::-webkit-scrollbar { display: none; }
.filter {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 13px;
  color: #55556b;
  cursor: pointer;
  white-space: nowrap;
  transition: .16s;
}
.filter.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tag-filter {
  border: none;
  background: #eeedf6;
  border-radius: 99px;
  padding: 5px 11px;
  font-size: 11.5px;
  color: #63637a;
  cursor: pointer;
  white-space: nowrap;
}
.tag-filter.active { background: #dcd8ff; color: var(--brand); font-weight: 600; }

.lib-list { display: grid; gap: 10px; margin-top: 6px; }
.lib-item {
  background: var(--card);
  border-radius: 15px;
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(30,30,60,.045);
  animation: fadeUp .22s ease both;
}
.lib-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.lib-word { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lib-word b { font-size: 17px; letter-spacing: -.2px; }
.lib-word .phonetic { text-align: left; margin: 0; }
.lib-actions { display: flex; gap: 4px; }
.lib-meaning { margin-top: 5px; font-size: 13.5px; color: #3d3d4d; line-height: 1.5; }
.lib-example { margin-top: 4px; font-style: italic; line-height: 1.5; }
.lib-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; }
.due-tag { margin-left: auto; }
.level-meter { height: 3px; background: #f0f0f7; border-radius: 99px; margin-top: 9px; overflow: hidden; }
.level-meter i { display: block; height: 100%; background: linear-gradient(90deg, #a9a1fb, var(--brand)); border-radius: 99px; }
mark { background: #fff0b8; color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------------- 统计 ---------------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--card);
  border-radius: 15px;
  padding: 13px 14px;
  box-shadow: 0 2px 10px rgba(30,30,60,.045);
  display: grid;
  gap: 4px;
}
.kpi b { font-size: 23px; letter-spacing: -.5px; }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding: 10px 2px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; }
.bar-track {
  flex: 1;
  width: 100%;
  max-width: 34px;
  background: #f2f2f9;
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.bar-track i {
  display: block; width: 100%;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  border-radius: 8px;
  min-height: 2px;
  transition: height .5s cubic-bezier(.2,.8,.2,1);
}
.bar-val { color: var(--muted); font-size: 10.5px; height: 14px; }
.bar-label { color: var(--muted); }

.level-list { display: grid; gap: 10px; }
.level-row { display: grid; grid-template-columns: 78px 1fr 34px; align-items: center; gap: 10px; }
.level-name { font-size: 12.5px; color: #55556b; }
.level-bar { height: 8px; background: #f2f2f9; border-radius: 99px; overflow: hidden; }
.level-bar i { display: block; height: 100%; background: linear-gradient(90deg, #b7b0fb, var(--brand)); border-radius: 99px; }
.level-count { text-align: right; color: var(--muted); }

.settings-list { display: grid; gap: 4px; margin-bottom: 8px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f3f3f9;
}
.setting-row:last-child { border-bottom: none; }
.setting-info { display: grid; gap: 2px; }
.setting-info > span { font-size: 14px; font-weight: 600; }
.setting-row select, .num-input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fcfcfe;
  outline: none;
  font-family: inherit;
}
.num-input { width: 84px; text-align: center; }
.setting-row input[type="range"] { width: 110px; accent-color: var(--brand); }

.switch {
  appearance: none;
  width: 44px; height: 26px; border-radius: 99px;
  background: #e2e1ee; position: relative; cursor: pointer; outline: none;
  transition: background .2s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }

.danger-zone {
  display: flex; gap: 10px; justify-content: flex-end;
  margin: 14px 0 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tab {
  flex: 1;
  border: none;
  background: none;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: #9a9aae;
  cursor: pointer;
  position: relative;
  transition: color .18s;
}
.tab span { font-size: 10.5px; font-weight: 600; }
.tab.active { color: var(--brand); }
.tab.active svg { transform: translateY(-1px); }
.nav-badge {
  position: absolute;
  top: 5px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  line-height: 16px;
  text-align: center;
}

/* ---------------- 弹层 / Toast ---------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 38, .42);
  opacity: 0;
  transition: opacity .22s;
  z-index: 40;
  backdrop-filter: blur(2px);
}
.sheet-backdrop.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 16px 18px calc(18px + var(--safe-b));
  z-index: 50;
  transition: transform .28s cubic-bezier(.2,.85,.25,1);
  box-shadow: 0 -10px 40px rgba(20, 20, 40, .18);
}
.sheet.show { transform: translate(-50%, 0); }
@media (min-width: 760px) {
  .sheet { bottom: 4vh; border-radius: 22px; }
  .sheet.show { transform: translate(-50%, 0); }
}
.sheet-sm { max-width: 380px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font-size: 16.5px; }
.sheet-body { max-height: 60vh; overflow-y: auto; padding-right: 2px; }
.sheet-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.sheet-actions .left { display: flex; gap: 6px; flex-wrap: wrap; }
.sheet-photo { max-height: 120px; border-radius: 10px; margin-bottom: 12px; }

.confirm { text-align: left; }
.confirm h3 { font-size: 16.5px; margin-bottom: 8px; }
.confirm p { font-size: 14px; color: #55556b; line-height: 1.6; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.menu-list { display: grid; gap: 4px; }
.menu-list button {
  border: none;
  background: #f8f8fc;
  border-radius: 12px;
  padding: 13px 14px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: .16s;
}
.menu-list button:hover { background: #f0effa; }
.menu-list button.danger { color: var(--danger); }
.menu-list button.warn { color: var(--warn); }

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 30px);
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
  width: max-content;
  max-width: 86vw;
}
.toast {
  background: rgba(28, 28, 42, .92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 11px;
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(8px);
  transition: .22s;
  box-shadow: 0 8px 24px rgba(20, 20, 40, .22);
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: rgba(24, 140, 100, .95); }
.toast.warn { background: rgba(190, 116, 22, .95); }
.toast.error { background: rgba(200, 60, 68, .95); }

/* ---------------- 深色模式 ---------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #edecf5;
    --muted: #9c9cb2;
    --line: #2c2c3c;
    --bg: #131320;
    --card: #1c1c2b;
    --brand-soft: #2a2950;
    --shadow: 0 6px 22px rgba(0, 0, 0, .3);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .45);
  }
  body { background: #0c0c14; }
  .app-shell { background: var(--bg); }
  .tabbar { background: rgba(20, 20, 32, .92); }
  .progress-bar, .level-meter, .level-bar, .bar-track, .segmented { background: #262637; }
  .stat, .menu-list button, .raw-text, .field input, .field textarea, .field select,
  .setting-row select, .num-input { background: #232334; border-color: var(--line); }
  .rate { background: #202030; }
  .rate.again { background: #2a1d21; }
  .rate.hard { background: #2a2419; }
  .rate.good { background: #17271f; }
  .tag { background: #262637; color: #b3b3c8; }
  .upload-inner { background: linear-gradient(180deg, #1e1e2e, #191926); border-color: #33334a; }
  .preview-wrap img { background: #232334; }
  .tip-card { background: #191926; }
  .search-box { background: var(--card); }
  .filter { background: var(--card); color: #b0b0c4; }
  .tag-filter { background: #2a2a3d; color: #b0b0c4; }
  .tag-filter.active { background: #35325e; color: #c9c4ff; }
  .seg.active { background: #2e2e44; }
  .lib-meaning { color: #d4d4e2; }
  .card-back .example { color: #b0b0c4; }
  .sheet { background: #1b1b29; }
  .icon-btn.tiny { background: #262637; }
  .pill { background: #202030; }
  .pill.on { background: #2b2952; }
  mark { background: #6b5b18; color: #fff; }
  .confirm p { color: #b0b0c4; }
  .switch-label { color: #b0b0c4; }
  .online-def p { color: #d4d4e2; }
  .online-zh { background: #2b2952; color: #c9c4ff; }
}

/* 底部联网状态提示 */
.net-banner {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translate(-50%, -140%);
  background: rgba(200, 60, 68, .95);
  color: #fff;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 99px;
  z-index: 90;
  transition: transform .25s ease;
  box-shadow: 0 6px 18px rgba(20, 20, 40, .22);
  pointer-events: none;
}
.net-banner.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ---------- 电工专业词库 ---------- */
.prof-card { display: flex; flex-direction: column; gap: 12px; }
.prof-card .form-actions { margin-top: 2px; }
.prof-card .form-actions .btn { flex: 1 1 0; }
.prof-title { font-size: 16px; font-weight: 700; margin: 0 0 2px; }
.prof-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.prof-num {
  flex: 1 1 88px; text-align: center; padding: 8px 6px;
  background: var(--bg); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--muted);
}
.prof-num b { display: block; font-size: 17px; color: var(--text); margin-bottom: 2px; }
.prof-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.prof-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--line);
}
.prof-item:last-child { border-bottom: none; }
.prof-item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.prof-word { font-weight: 600; font-size: 14.5px; }
.prof-ph { font-size: 12px; color: var(--muted); }
.prof-mean { font-size: 13px; color: var(--muted); flex: 1 1 100%; }
.prof-say {
  flex: 0 0 auto; border: 1px solid var(--brand); background: transparent;
  color: var(--brand); border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.prof-say.added { border-color: var(--line); color: var(--muted); cursor: default; }
.prof-say:active { transform: scale(0.97); }

/* ================= 检测 ================= */
.quiz-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.quiz-kpi {
  background: var(--brand-soft); border-radius: var(--radius-sm);
  padding: 10px 8px; text-align: center;
}
.quiz-kpi b { display: block; font-size: 19px; line-height: 1.2; }
.quiz-kpi span { font-size: 11.5px; color: var(--muted); }
.quiz-kpi.dim b { color: var(--muted); }

.quiz-scope {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 4px; margin-bottom: 14px; border-radius: 14px;
  background: var(--brand-soft);
}
.quiz-scope-btn {
  border: 0; background: transparent; color: var(--muted);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 6px; border-radius: 11px; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.quiz-scope-btn.active {
  background: var(--card); color: var(--brand);
  box-shadow: 0 1px 3px rgba(84, 79, 214, .18);
}

.quiz-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.quiz-mode {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 10px; cursor: pointer;
  font-family: inherit; text-align: left; transition: border-color .15s, background .15s;
}
.quiz-mode b { font-size: 13.5px; }
.quiz-mode small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.quiz-mode.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.quiz-mode.active b { color: var(--brand); }
.quiz-mode:active { transform: scale(0.985); }

.quiz-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.quiz-bar { height: 6px; border-radius: 999px; background: var(--brand-soft); overflow: hidden; margin-bottom: 16px; }
.quiz-bar i { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .25s; }

.quiz-prompt { text-align: center; padding: 6px 0 14px; }
.quiz-q-label { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.quiz-word { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; word-break: break-word; }
.quiz-phon { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.quiz-zh { font-size: 20px; font-weight: 600; line-height: 1.45; word-break: break-word; }

.quiz-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.quiz-choice {
  width: 100%; text-align: left; font-family: inherit; font-size: 14px; line-height: 1.4;
  padding: 12px 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  transition: border-color .15s, background .15s;
}
.quiz-choice:active:not(:disabled) { transform: scale(0.99); }
.quiz-choice.right { border-color: var(--ok); background: rgba(33, 166, 122, .12); font-weight: 600; }
.quiz-choice.wrong { border-color: var(--danger); background: rgba(224, 91, 98, .1); }
.quiz-choice:disabled { cursor: default; }

.quiz-input-wrap { display: flex; gap: 8px; margin-bottom: 12px; }
.quiz-input-wrap input {
  flex: 1 1 auto; min-width: 0; font-family: inherit; font-size: 16px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.quiz-input-wrap input:focus { outline: none; border-color: var(--brand); }
.quiz-input-wrap .btn { flex: 0 0 auto; }

.quiz-feedback {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px;
}
.quiz-feedback b { font-size: 14px; }
.quiz-feedback span { font-size: 13px; color: var(--muted); word-break: break-word; }
.quiz-feedback.ok { background: rgba(33, 166, 122, .12); }
.quiz-feedback.ok b { color: var(--ok); }
.quiz-feedback.bad { background: rgba(224, 91, 98, .1); }
.quiz-feedback.bad b { color: var(--danger); }

.quiz-result-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.quiz-score-ring {
  --pct: 0%;
  flex: 0 0 auto; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--brand) var(--pct), var(--brand-soft) 0);
}
.quiz-score-ring b {
  width: 60px; height: 60px; border-radius: 50%; background: var(--card);
  display: grid; place-items: center; font-size: 16px;
}
.quiz-result-head h3 { font-size: 16px; margin-bottom: 4px; }
.quiz-result-head p { margin: 0; }

.quiz-wrong-list { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 12px; }
.quiz-wrong-list:empty { display: none; margin: 0; }
.quiz-wrong-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--line);
}
.quiz-wrong-item:last-child { border-bottom: none; }
.qwi-main { flex: 1 1 auto; min-width: 0; }
.qwi-main b { font-size: 14.5px; }
.qwi-phon { font-size: 12px; color: var(--muted); margin-left: 6px; }
.qwi-meaning { font-size: 12.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.qwi-speak { flex: 0 0 auto; }

@media (max-width: 400px) {
  .quiz-modes { grid-template-columns: 1fr; }
  .quiz-mode { flex-direction: row; align-items: baseline; gap: 8px; }
}

/* ---------- iOS「添加到主屏幕」引导条 ---------- */
.ios-hint {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px);
  z-index: 60;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(30, 27, 58, .93);
  color: #fff;
  font-size: 13px; line-height: 1.5;
  box-shadow: 0 10px 30px rgba(24, 20, 60, .28);
  transform: translateY(120%);
  opacity: 0;
  transition: transform .28s ease, opacity .28s ease;
  pointer-events: none;
}
.ios-hint.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.ios-hint-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin: 0 2px;
  border-radius: 5px; background: rgba(255, 255, 255, .18);
  font-size: 12px;
}
.ios-hint-x {
  margin-left: auto;
  border: 0; border-radius: 9px;
  padding: 5px 11px;
  background: rgba(255, 255, 255, .16); color: #fff;
  font-family: inherit; font-size: 12.5px; cursor: pointer;
}
.ios-hint-x:active { background: rgba(255, 255, 255, .28); }
