/* ================================================================
   四级词汇 · 学习网站样式（移动优先 / 响应式 / 深浅色自适应）
   ================================================================ */
:root {
  --bg: #f4f5fb;
  --bg-soft: #eceefa;
  --card: #ffffff;
  --text: #171a2b;
  --muted: #737a91;
  --line: #e6e8f2;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-soft: rgba(99, 102, 241, .1);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, .12);
  --bad: #ef4444;
  --bad-soft: rgba(239, 68, 68, .1);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, .12);
  --shadow: 0 2px 8px rgba(23, 26, 43, .06), 0 8px 28px rgba(23, 26, 43, .06);
  --radius: 16px;
  --nav-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html[data-theme="dark"] {
  --bg: #0f1117;
  --bg-soft: #171a24;
  --card: #1a1d29;
  --text: #eef0f7;
  --muted: #9aa1b5;
  --line: #282c3a;
  --primary: #818cf8;
  --primary-2: #a78bfa;
  --primary-soft: rgba(129, 140, 248, .16);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .16);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .16);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .16);
  --shadow: 0 2px 8px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Segoe UI, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }
/* 无底部导航的页面（如管理控制台）不需要为 tabbar 留白 */
body.no-tabbar { padding-bottom: 26px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img, svg { vertical-align: middle; }
::selection { background: var(--primary-soft); }

/* ---------------- 布局 ---------------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 0 14px; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-in {
  max-width: 720px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; min-height: 52px;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.2px; flex: 1; }
.topbar .sub { font-size: 12px; color: var(--muted); font-weight: 400; display: block; margin-top: -2px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 17px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(.94); }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
  display: flex;
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; font-size: 10.5px; color: var(--muted);
  padding-top: 6px; transition: color .15s;
}
.tabbar a .ic { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .55; }
.tabbar a.on { color: var(--primary); font-weight: 600; }
.tabbar a.on .ic { filter: none; opacity: 1; transform: translateY(-1px); }
.tabbar a:active .ic { transform: scale(.88); }
.tabbar .dot {
  position: absolute; margin: -34px 0 0 16px; min-width: 16px; height: 16px;
  border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px;
  line-height: 16px; text-align: center; padding: 0 4px; font-weight: 700;
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 16px; margin-bottom: 12px;
}
.card.flat { box-shadow: none; }
.card-t { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-t h2 { font-size: 15px; margin: 0; font-weight: 700; flex: 1; }
.card-t .more { font-size: 12.5px; color: var(--primary); }

/* ---------------- 通用元素 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 600;
  background: var(--bg-soft); color: var(--text); transition: transform .12s, opacity .2s;
  border: 1px solid transparent; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.pri { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 18px var(--primary-soft); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 600; background: var(--primary-soft); color: var(--primary);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.gray { background: var(--bg-soft); color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hide { display: none !important; }

input.field, select.field {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--text);
  outline: none; transition: border-color .15s;
}
input.field:focus, select.field:focus { border-color: var(--primary); }
label.lb { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 6px 2px; font-weight: 600; }

/* ---------------- 登录页 ---------------- */
.auth {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  justify-content: center; padding: 24px 18px 40px;
}
.auth .logo { text-align: center; margin-bottom: 22px; }
.auth .logo .em { font-size: 52px; display: block; line-height: 1; margin-bottom: 8px; }
.auth .logo h1 { font-size: 25px; margin: 0; letter-spacing: -.5px; }
.auth .logo p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.auth-card { max-width: 400px; width: 100%; margin: 0 auto; }
.tabs { display: flex; gap: 6px; background: var(--bg-soft); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tabs button { flex: 1; padding: 9px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--card); color: var(--primary); box-shadow: var(--shadow); }
.demo-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 16px; line-height: 1.8; }
.demo-hint b { color: var(--text); }

/* ---------------- 首页 ---------------- */
.hero {
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #a855f7);
  border-radius: 20px; padding: 18px; color: #fff; margin-bottom: 12px;
  box-shadow: 0 10px 30px rgba(99, 102, 241, .3);
}
html[data-theme="dark"] .hero { box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.hero .hi { font-size: 14px; opacity: .9; }
.hero .nm { font-size: 21px; font-weight: 700; margin: 0 0 12px; letter-spacing: -.3px; }
.hero .stat3 { display: flex; gap: 8px; }
.hero .stat3 > div {
  flex: 1; background: rgba(255, 255, 255, .16); border-radius: 13px; padding: 9px 6px;
  text-align: center; backdrop-filter: blur(4px);
}
.hero .stat3 b { display: block; font-size: 19px; letter-spacing: -.5px; }
.hero .stat3 span { font-size: 10.5px; opacity: .88; }

.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 108px; height: 108px; flex: 0 0 108px; }
.ring svg { transform: rotate(-90deg); }
.ring .pct {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring .pct b { font-size: 24px; letter-spacing: -1px; line-height: 1; }
.ring .pct span { font-size: 10.5px; color: var(--muted); }
.goal-list { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.goal-item .bar-t { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.goal-item .bar-t b { font-weight: 600; }
.bar { height: 7px; border-radius: 4px; background: var(--bg-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .5s ease; }
.bar > i.ok { background: linear-gradient(90deg, #10b981, #34d399); }
.bar > i.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick a {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 6px; text-align: center; box-shadow: var(--shadow); transition: transform .12s;
}
.quick a:active { transform: scale(.95); }
.quick .em { font-size: 23px; display: block; line-height: 1.2; }
.quick span { font-size: 11px; color: var(--muted); display: block; margin-top: 3px; }

.spark { display: flex; align-items: flex-end; gap: 5px; height: 64px; }
.spark > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.spark .b { width: 100%; border-radius: 5px 5px 3px 3px; background: linear-gradient(180deg, var(--primary), var(--primary-2)); min-height: 3px; transition: height .5s; }
.spark .d { font-size: 9.5px; color: var(--muted); }

.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-no { width: 24px; font-weight: 800; font-size: 14px; color: var(--muted); text-align: center; flex: 0 0 24px; }
.rank-no.g1 { color: #f5b301; } .rank-no.g2 { color: #9aa5b1; } .rank-no.g3 { color: #cd7f32; }
.av { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-soft); display: flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 34px; }
.rank-row .nm { flex: 1; font-size: 14px; font-weight: 600; }
.rank-row .sc { font-weight: 700; color: var(--primary); font-size: 14.5px; }
.rank-row.me { background: var(--primary-soft); border-radius: 11px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }

/* ---------------- 词库 ---------------- */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 10px; -ms-overflow-style: none; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; font-size: 13px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); font-weight: 500;
}
.chip.on { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; font-weight: 600; }

.wcard { border-left: 3px solid transparent; }
.wcard.wrong { border-left-color: var(--bad); }
.wcard.mastered { border-left-color: var(--ok); }
.wcard .wl { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.wcard .w { font-size: 20px; font-weight: 700; letter-spacing: -.4px; }
.wcard .ph { color: var(--muted); font-size: 13px; font-family: "Segoe UI", Arial, sans-serif; }
.wcard .mn { font-size: 13.5px; color: var(--text); opacity: .88; margin-top: 4px; }
.wcard .act { display: flex; align-items: center; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.unit-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.unit-row:last-child { border-bottom: none; }
.unit-row .u { width: 46px; font-weight: 700; font-size: 13px; color: var(--primary); flex: 0 0 46px; }

/* ---------------- 背单词卡 ---------------- */
.study-stage { display: flex; flex-direction: column; min-height: calc(100dvh - 190px); }
.flash {
  position: relative; flex: 1; min-height: 300px; perspective: 1200px; margin-bottom: 14px;
}
.flash-inner {
  position: absolute; inset: 0; transition: transform .5s cubic-bezier(.4, .1, .2, 1);
  transform-style: preserve-3d; cursor: pointer;
}
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: 24px 20px; display: flex;
  flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: auto;
}
.flash-face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--card), var(--bg-soft)); }
.flash-face .big { font-size: 38px; font-weight: 800; letter-spacing: -1.2px; word-break: break-word; line-height: 1.15; }
.flash-face .ph2 { font-size: 16px; color: var(--muted); margin-top: 10px; font-family: "Segoe UI", Arial, sans-serif; }
.flash-face .hint { position: absolute; bottom: 14px; font-size: 11.5px; color: var(--muted); }
.flash-face .mn2 { font-size: 17px; line-height: 1.7; margin-top: 4px; }
.flash-face .pos { font-size: 12px; color: var(--primary); font-weight: 700; letter-spacing: .4px; }
.progress-line { height: 4px; border-radius: 3px; background: var(--bg-soft); margin-bottom: 12px; overflow: hidden; }
.progress-line > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .3s; }

/* ---------------- 练习 ---------------- */
.opt {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 14px 15px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); margin-bottom: 9px; font-size: 14.5px; transition: all .18s;
}
.opt .k {
  width: 24px; height: 24px; border-radius: 8px; background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  font-weight: 700; flex: 0 0 24px; color: var(--muted);
}
.opt:active { transform: scale(.985); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opt.dim { opacity: .5; }

.qhead { text-align: center; padding: 14px 0 18px; }
.qhead .qw { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.qhead .qp { color: var(--muted); font-size: 14px; margin-top: 6px; font-family: "Segoe UI", Arial, sans-serif; }
.qhead .qm { font-size: 19px; font-weight: 600; line-height: 1.5; }
.spell-in { text-align: center; font-size: 24px; letter-spacing: 6px; font-weight: 700; padding: 14px; }
.blanks { font-size: 30px; letter-spacing: 8px; font-weight: 800; text-align: center; color: var(--primary); margin-bottom: 6px; }

.feedback {
  border-radius: 14px; padding: 13px 15px; margin-bottom: 12px; font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start;
}
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.no { background: var(--bad-soft); color: var(--bad); }
.feedback .em { font-size: 19px; line-height: 1.2; }

/* ---------------- 播放按钮 ---------------- */
.speak {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px;
  background: var(--primary-soft); color: var(--primary); font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s, background .2s;
}
.speak:active { transform: scale(.9); }
.speak.playing { animation: pulse .9s infinite; background: var(--primary); color: #fff; }
.speak.lg { width: 52px; height: 52px; font-size: 22px; border-radius: 16px; }
/* 带文字的播放按钮（🔈 美音 / 🔊 英音）：横向胶囊排布，图标+文字一行，
   不再塞进 38px 方块里把两个字挤成竖排 */
.speak.txt {
  width: auto; height: 32px; flex: 0 0 auto;
  padding: 0 13px; border-radius: 999px;
  font-size: 13px; font-weight: 600; gap: 5px; white-space: nowrap;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .em { font-size: 46px; display: block; margin-bottom: 10px; opacity: .8; }
.empty p { margin: 0 0 4px; font-size: 14px; }

/* ---------------- 进度条 / 统计页 ---------------- */
.barchart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.barchart > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; justify-content: flex-end; height: 100%; }
.barchart .stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 1px; }
.barchart .s1 { background: linear-gradient(180deg, #818cf8, #6366f1); border-radius: 3px 3px 0 0; }
.barchart .s2 { background: #34d399; }
.barchart .s3 { background: #fbbf24; }
.barchart .lb2 { font-size: 9px; color: var(--muted); }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
  transform: translate(-50%, 20px); z-index: 999;
  background: rgba(20, 22, 34, .94); color: #fff; padding: 11px 20px;
  border-radius: 13px; font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: all .28s; max-width: 84vw; text-align: center; box-shadow: 0 8px 26px rgba(0, 0, 0, .28);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 弹层 ---------------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 200; background: rgba(10, 12, 20, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  background: var(--card); width: 100%; max-width: 720px; border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + var(--safe-b)); transform: translateY(100%);
  transition: transform .3s cubic-bezier(.3, .1, .2, 1); max-height: 88vh; overflow: auto;
}
.sheet-mask.show .sheet { transform: translateY(0); }
.sheet h3 { margin: 0 0 14px; font-size: 16px; }

/* ---------------- 滑块 ---------------- */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 4px;
  background: var(--bg-soft); outline: none; margin: 4px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 2px 8px var(--primary-soft); cursor: pointer; border: 3px solid var(--card);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--card);
  background: var(--primary); cursor: pointer;
}

/* ---------------- 桌面端 ---------------- */
@media (min-width: 760px) {
  body { padding-bottom: 24px; font-size: 15.5px; }
  .wrap { max-width: 860px; }
  .topbar-in { max-width: 860px; }
  .tabbar {
    position: sticky; top: 0; bottom: auto; height: auto; padding: 0;
    border-top: none; border-bottom: 1px solid var(--line);
    max-width: 860px; margin: 0 auto; border-radius: 0 0 16px 16px;
  }
  .tabbar a { flex-direction: row; gap: 7px; font-size: 14px; padding: 13px 4px; }
  .tabbar a .ic { font-size: 18px; }
  .tabbar a.on .ic { transform: none; }
  .tabbar .dot { margin: -26px 0 0 34px; }
  .topbar .desk-hide { display: none; }
  .grid2.desk3 { grid-template-columns: repeat(3, 1fr); }
  .flash-face .big { font-size: 46px; }
}
@media (max-width: 380px) {
  .quick { grid-template-columns: repeat(3, 1fr); }
  .hero .stat3 b { font-size: 17px; }
  .flash-face .big { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------- ICP 备案号页脚（工信部规范：底部展示 + 链接到 beian.miit.gov.cn） ---------------- */
.icp-footer {
  margin: 28px auto 0;
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
  max-width: 720px;
  text-align: center;
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted);
}
.icp-footer a { color: var(--muted); text-decoration: none; }
.icp-footer a:hover { color: var(--primary); text-decoration: underline; }
.icp-footer .icp-sep { margin: 0 7px; opacity: .45; }
/* 登录页：作为 .auth 弹性列的最后一项，视觉贴底 */
.auth .icp-footer { margin: 26px auto 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
