* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --blue: #5b8def;
  --blue-d: #3f6fd1;
  --bg: #eef2f9;
  --card: #ffffff;
  --text: #25324a;
  --muted: #93a0b5;
  --green: #2ecc71;
  --red: #ff5b6e;
  --gold: #ffb13c;
  --shadow: 0 8px 24px rgba(58, 84, 130, .10);
  --shadow-lg: 0 16px 40px rgba(58, 84, 130, .16);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #eef2f9; background: var(--bg); color: #25324a; color: var(--text);
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  overflow-x: hidden;
}
.view { min-height: 100vh; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- 飘分 / Toast ---------- */
.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.fly-score {
  position: absolute; font-weight: 800; font-size: 26px;
  text-shadow: 0 2px 8px rgba(0,0,0,.18); animation: flyUp 1.1s ease-out forwards;
}
@keyframes flyUp {
  0% { opacity: 0; transform: translateY(0) scale(.6); }
  20% { opacity: 1; transform: translateY(-12px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-90px) scale(1); }
}
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(37,50,74,.92); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 14px; z-index: 70; opacity: 0; transition: all .25s; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 登录 ---------- */
.login-view { display: flex; align-items: center; justify-content: center; padding: 24px; position: relative; }
.login-bg {
  position: absolute; inset: 0;
  background: #5b8def;
  background:
    radial-gradient(900px 500px at 15% -10%, #7aa7ff 0%, transparent 55%),
    radial-gradient(700px 500px at 110% 10%, #9be7d8 0%, transparent 50%),
    linear-gradient(160deg, #5b8def 0%, #6f7bf0 45%, #8a6cf0 100%);
}
.login-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(3px 3px at 20% 30%, rgba(255,255,255,.5), transparent),
              radial-gradient(2px 2px at 70% 20%, rgba(255,255,255,.4), transparent),
              radial-gradient(2.5px 2.5px at 85% 60%, rgba(255,255,255,.35), transparent),
              radial-gradient(2px 2px at 40% 75%, rgba(255,255,255,.4), transparent);
}
.login-card {
  position: relative; z-index: 1; background: #fff; background: rgba(255,255,255,.96);
  border-radius: 28px; padding: 42px 28px 30px; width: 100%; max-width: 360px;
  box-shadow: 0 24px 60px rgba(45, 60, 110, .3); text-align: center;
  animation: pop .5s cubic-bezier(.18,.9,.34,1.2);
}
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
  .login-card { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
}
@keyframes pop { 0% { transform: scale(.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.login-mascot {
  width: 90px; height: 90px; margin: 0 auto 14px; border-radius: 50%;
  background: linear-gradient(135deg, #ffe0a3, #ffc4d6); display: flex; align-items: center; justify-content: center;
  font-size: 50px; box-shadow: 0 10px 24px rgba(255,170,120,.4);
}
.login-title { font-size: 28px; font-weight: 800; letter-spacing: 1px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 6px 0 26px; }
.name-field {
  display: flex; align-items: center; gap: 8px; background: #f3f6fc; border-radius: 16px;
  padding: 0 16px; height: 54px; margin-bottom: 16px; border: 2px solid transparent; transition: border-color .2s;
}
.name-field:focus-within { border-color: var(--blue); background: #fff; }
.name-emoji { font-size: 20px; }
.name-field input { flex: 1; border: none; background: transparent; outline: none; font-size: 16px; color: var(--text); }
.btn-primary {
  width: 100%; height: 54px; border: none; border-radius: 16px; color: #fff; font-size: 17px; font-weight: 700;
  background: linear-gradient(135deg, #5b8def, #7c6cf0); cursor: pointer;
  box-shadow: 0 10px 24px rgba(91,141,239,.45); transition: transform .12s, box-shadow .2s;
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 6px 16px rgba(91,141,239,.4); }
.login-tip { color: var(--muted); font-size: 12px; margin-top: 18px; line-height: 1.6; }
.history-box { margin-top: 20px; text-align: left; }
.history-label { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.history-list { display: flex; flex-wrap: wrap; gap: 10px; }
.history-chip {
  display: flex; align-items: center; gap: 6px; background: #eef3ff; color: var(--blue-d);
  border: none; border-radius: 22px; padding: 8px 14px; font-size: 14px; cursor: pointer; transition: transform .12s;
}
.history-chip:active { transform: scale(.95); }
.history-chip .dot { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 22px 20px 26px; color: #fff; overflow: hidden;
  background: #5b8def;
  background: linear-gradient(160deg, #5b8def 0%, #6a72ef 55%, #8a63e8 100%); }
.hero-glow { position: absolute; top: -60px; right: -40px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.35), transparent 70%); }
.hero-top { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.hero-user { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff; background: rgba(255,255,255,.25); border: 2px solid rgba(255,255,255,.5);
}
.hero-name { font-size: 18px; font-weight: 700; }
.hero-date { font-size: 12px; opacity: .85; margin-top: 2px; }
.ghost-btn { background: rgba(255,255,255,.2); border: none; color: #fff; border-radius: 12px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.hero-stats { display: flex; align-items: center; margin-top: 22px; position: relative; z-index: 1; }
.stat { flex: 1; text-align: center; }
.stat-val { font-size: 24px; font-weight: 800; }
.stat-val small { font-size: 12px; font-weight: 500; opacity: .85; margin-left: 2px; }
.stat-label { font-size: 12px; opacity: .85; margin-top: 2px; }
.stat-div { width: 1px; height: 30px; background: rgba(255,255,255,.25); }

/* ---------- 进度环 ---------- */
.progress-card {
  margin: -18px 16px 0; background: var(--card); border-radius: 22px; padding: 18px;
  display: flex; align-items: center; gap: 18px; box-shadow: var(--shadow); position: relative; z-index: 2;
}
.ring-wrap { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.ring { width: 96px; height: 96px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #eef1f7; stroke-width: 10; }
.ring-fg {
  fill: none; stroke: #5b8def; stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.3,1);
}
@supports (stroke: url(#ringGrad)) {
  .ring-fg { stroke: url(#ringGrad); }
}
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font-size: 22px; font-weight: 800; color: var(--text); }
.ring-txt { font-size: 11px; color: var(--muted); margin-top: 1px; }
.progress-info { flex: 1; }
.pi-title { font-size: 15px; font-weight: 700; }
.pi-tip { font-size: 13px; color: var(--muted); margin: 6px 0 8px; line-height: 1.5; }
.pi-tip b { color: var(--green); }
.pi-coins { font-size: 12px; color: #8a6cf0; background: #f1edff; display: inline-block; padding: 4px 10px; border-radius: 10px; }

/* ---------- 容器 ---------- */
.container { padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.section-title { font-size: 15px; font-weight: 700; margin: 8px 4px 12px; }
.subject-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.subj-card {
  background: var(--card); border-radius: 20px; padding: 16px; cursor: pointer; position: relative; overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
  animation: rise .5s ease both;
}
@keyframes rise { 0% { opacity: 0; transform: translateY(14px); } 100% { opacity: 1; transform: translateY(0); } }
.subj-card:active { transform: scale(.97); }
.subj-top { display: flex; align-items: center; gap: 12px; }
.subj-icon { width: 50px; height: 50px; border-radius: 15px; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.subj-name { font-size: 16px; font-weight: 700; }
.subj-count { font-size: 12px; color: var(--muted); margin-top: 3px; }
.subj-footer { display: flex; align-items: center; justify-content: space-between; }
.subj-status { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 10px; }
.subj-status.pending { color: var(--gold); background: #fff4e2; }
.subj-status.done { color: var(--green); background: #e7faf0; }
.subj-check { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px;
  animation: pop .4s ease; }

.quick-row { display: flex; gap: 14px; margin-top: 16px; }
.quick-btn {
  flex: 1; background: var(--card); border: none; border-radius: 18px; padding: 16px; cursor: pointer;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); transition: transform .12s;
}
.quick-btn:active { transform: scale(.97); }
.q-ico { width: 44px; height: 44px; border-radius: 13px; background: #eef3ff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.q-txt { display: flex; flex-direction: column; text-align: left; }
.q-txt b { font-size: 15px; }
.q-txt small { font-size: 12px; color: var(--muted); margin-top: 2px; }
.footer-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }

/* ---------- 面板 ---------- */
.panel { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; background: var(--card); border-bottom: 1px solid #eef1f6; }
.back-btn { background: none; border: none; font-size: 26px; line-height: 1; color: var(--blue); cursor: pointer; padding: 0 4px; }
.panel-title { font-size: 17px; font-weight: 700; }
.panel-progress { margin-left: auto; font-size: 13px; color: var(--muted); }
.do-progressbar { height: 5px; background: #e9eef7; }
.do-progressbar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #5b8def, #8a63e8); transition: width .3s; }
.panel-body { flex: 1; overflow-y: auto; padding: 18px; padding-bottom: 90px; }

/* ---------- 题目 ---------- */
.q-item { background: var(--card); border-radius: 18px; padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); animation: rise .35s ease both; }
.q-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.q-idx { width: 26px; height: 26px; border-radius: 9px; background: linear-gradient(135deg,#5b8def,#7c6cf0); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.q-stem { font-size: 16px; line-height: 1.65; }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px; border: 2px solid #e6ebf3; border-radius: 14px;
  margin-bottom: 10px; font-size: 15px; cursor: pointer; transition: all .15s; background: #fff;
}
.opt .opt-key { width: 24px; height: 24px; border-radius: 50%; background: #eef2f9; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; transition: all .15s; }
.opt.sel { border-color: var(--blue); background: #eef4ff; }
.opt.sel .opt-key { background: var(--blue); color: #fff; }
.opt.correct { border-color: var(--green); background: #e9faf1; }
.opt.correct .opt-key { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: #ffeef0; }
.opt.wrong .opt-key { background: var(--red); color: #fff; }
.fill-input { width: 100%; height: 50px; border: 2px solid #e6ebf3; border-radius: 14px; padding: 0 16px; font-size: 16px; outline: none; transition: border-color .2s; }
.fill-input:focus { border-color: var(--blue); }
.q-state { font-size: 14px; font-weight: 700; margin: 12px 0 4px; }
.q-state.ok { color: var(--green); }
.q-state.no { color: var(--red); }
.explain { background: linear-gradient(135deg,#fff8e9,#fff3df); border: 1px solid #ffe2a8; border-radius: 14px; padding: 14px; margin-top: 10px; font-size: 14px; line-height: 1.7; color: #6b5a36; }
.explain b { color: #c8841a; }
.explain .ex-q { color: #25324a; font-weight: 600; display: block; margin-bottom: 4px; }

.submit-fixed { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px;
  border-radius: 0; height: calc(56px + env(safe-area-inset-bottom)); font-size: 17px; z-index: 21; padding-bottom: env(safe-area-inset-bottom); }

/* ---------- 结果弹层 ---------- */
.result-overlay { position: fixed; inset: 0; background: rgba(20,28,46,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; animation: fadeIn .25s ease; }
@supports (backdrop-filter: blur(3px)) or (-webkit-backdrop-filter: blur(3px)) {
  .result-overlay { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.result-card { width: 84%; max-width: 340px; background: #fff; border-radius: 26px; padding: 30px 24px 24px; text-align: center;
  box-shadow: var(--shadow-lg); animation: pop .4s cubic-bezier(.18,.9,.34,1.3); }
.res-emoji { font-size: 60px; animation: bounce .6s ease; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }
.res-title { font-size: 24px; font-weight: 800; margin: 8px 0 6px; }
.res-sub { font-size: 14px; color: var(--muted); line-height: 1.7; margin-bottom: 22px; }
.res-sub .up { color: var(--green); font-weight: 700; }
.res-sub .down { color: var(--red); font-weight: 700; }
.res-actions { display: flex; flex-direction: column; gap: 10px; }
.res-actions button { height: 48px; border: none; border-radius: 14px; font-size: 15px; font-weight: 700; cursor: pointer; }
.res-view { background: linear-gradient(135deg,#5b8def,#7c6cf0); color: #fff; box-shadow: 0 8px 18px rgba(91,141,239,.4); }
.res-home { background: #f1f4fa; color: var(--text); }

/* ---------- 错题本 / 积分 ---------- */
.mistake-item, .log-item { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); animation: rise .35s ease both; }
.mistake-subj { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mistake-tag { background: #eef3ff; color: var(--blue-d); border-radius: 9px; padding: 4px 11px; font-size: 12px; font-weight: 600; }
.mistake-stem { font-size: 15px; line-height: 1.65; margin-bottom: 10px; }
.mistake-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.remove-btn { background: #ffeef0; color: var(--red); border: none; border-radius: 11px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.remove-btn:active { transform: scale(.96); }
.log-top { display: flex; align-items: center; justify-content: space-between; }
.log-reason { font-size: 14px; font-weight: 600; }
.log-change { font-size: 16px; font-weight: 800; }
.log-change.up { color: var(--green); }
.log-change.down { color: var(--red); }
.log-date { font-size: 12px; color: var(--muted); margin-top: 5px; }
.empty-tip { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 14px; line-height: 1.8; }
.empty-tip .big { font-size: 46px; display: block; margin-bottom: 12px; }

/* ---------- 单题翻页 ---------- */
.q-card {
  background: #fff; background: var(--card); border-radius: 20px; padding: 22px 18px; margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(58,84,130,.10); box-shadow: var(--shadow);
  animation: rise .3s ease both; border: 1px solid #eef1f6;
}
.q-card .q-stem { font-size: 18px; line-height: 1.7; font-weight: 600; }
.q-card .opt { font-size: 16px; padding: 15px 14px; }
.q-result { border-radius: 16px; padding: 16px; margin-top: 14px; font-size: 15px; line-height: 1.7; }
.q-result.ok { background: #e9faf1; border: 1px solid #bdeed2; color: #1f8a4d; }
.q-result.no { background: #ffeef0; border: 1px solid #ffd0d6; color: #d33a4a; }
.q-result .qr-title { font-weight: 800; font-size: 17px; margin-bottom: 6px; }
.q-result .qr-ans { font-weight: 700; margin-bottom: 6px; }
.next-btn {
  width: 100%; height: 54px; border: none; border-radius: 16px; font-size: 17px; font-weight: 800;
  color: #fff; background: linear-gradient(135deg,#5b8def,#7c6cf0); cursor: pointer; margin-top: 16px;
  box-shadow: 0 10px 22px rgba(91,141,239,.38); transition: transform .12s;
}
.next-btn:active { transform: scale(.97); }
.submit-all-btn { background: linear-gradient(135deg,#ff9d2f,#ff6a3d); box-shadow: 0 10px 22px rgba(255,106,61,.4); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 跟读 / 听写 语音 ---------- */
.audio-row { display: flex; gap: 10px; align-items: center; margin: 12px 0 4px; flex-wrap: wrap; }
.play-btn { background: #eaf0ff; color: #3b6fe0; border: 1px solid #cdd9f5; border-radius: 12px; padding: 10px 14px; font-size: 15px; cursor: pointer; }
.play-btn:active { background: #dce6ff; }
.read-done-btn { background: #27ae60; color: #fff; border: none; border-radius: 12px; padding: 10px 16px; font-size: 15px; cursor: pointer; }
.read-done-btn:disabled { opacity: .6; cursor: default; }
.read-done-btn:active:not(:disabled) { opacity: .85; }
