:root {
  --bg: #f3f5fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --danger: #e11d48;
  --ok: #10b981;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }

#app { max-width: 720px; margin: 0 auto; padding: 0 12px 90px; }

/* 顶部栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; background: linear-gradient(180deg, var(--bg) 80%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 26px; }
.brand-name { font-weight: 800; font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: #eef2ff; color: var(--primary); font-weight: 600;
}
.chip-streak { background: #fff7ed; color: #ea580c; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer; font-weight: 600; font-size: 15px;
  padding: 11px 18px; border-radius: 12px; transition: 0.15s;
  font-family: inherit;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:not(:disabled):hover { background: #f3f4f6; }
.btn-block { width: 100%; margin-top: 14px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin: 12px 0; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.stat-card { text-align: center; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 34px; font-weight: 800; color: var(--primary); }
.stat-value small { font-size: 14px; color: var(--muted); font-weight: 500; }

.badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 8px;
  background: #eef2ff; color: var(--primary);
}
.badge-soft { background: #f3f4f6; color: var(--muted); }
.passage-meta { display: flex; gap: 6px; }
.passage-text { font-size: 16px; line-height: 1.7; white-space: pre-wrap; }
.passage-text.big { font-size: 19px; }

/* 逐句段落 */
.passage-sentences { display: flex; flex-direction: column; gap: 10px; }
.sentence {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 16px; line-height: 2; padding: 8px 10px;
  background: #f9fafb; border-radius: 10px;
  border-left: 3px solid #e5e7eb; transition: 0.12s;
}
.passage-sentences.big .sentence { font-size: 19px; }
.sentence:hover { background: #eef2ff; border-left-color: var(--primary); }
.s-play {
  flex: none; width: 28px; height: 28px; margin-top: 6px; border-radius: 50%;
  background: #eef2ff; border: none; cursor: pointer; font-size: 12px; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.s-play:hover { background: var(--primary); color: #fff; }
.s-words { flex: 1; }
.s-fav { flex: none; background: none; border: none; cursor: pointer; font-size: 18px; color: #d1d5db; margin-top: 5px; padding: 0 2px; }
.s-fav:hover { color: #f59e0b; }
.s-fav.favd { color: #f59e0b; }
.word { border-radius: 5px; padding: 0 2px; transition: 0.1s; }
.word:hover { background: #e0e7ff; }
.word.selected-word { background: #c7d2fe; font-weight: 700; color: var(--primary); }

.mark-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; flex-wrap: wrap; }
.mark-hint { font-size: 12px; }
.selected-words { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip-word {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef2ff; color: var(--primary); font-weight: 600;
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
}
.dict-actions { margin: 6px 0; }

.dict-results { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.dict-card {
  padding: 12px 14px; background: #f9fafb; border-radius: 12px; border: 1px solid var(--border);
}
.dict-card .d-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dict-card .d-word { font-weight: 800; font-size: 16px; }
.dict-card .d-ipa { color: var(--primary); font-size: 14px; }
.dict-card .d-pos { font-size: 12px; color: var(--muted); font-style: italic; }
.dict-card .d-meaning { font-size: 14px; margin: 3px 0; }
.dict-card .d-example { font-size: 13px; color: var(--muted); }
.dict-card .d-btns { display: flex; gap: 8px; margin-top: 8px; }

.wordbook-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.wordbook-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: #f9fafb; border-radius: 12px;
}
.wordbook-item .w-main { flex: 1; cursor: pointer; }
.wordbook-item .w-word { font-weight: 700; font-size: 15px; }
.wordbook-item .w-ipa { color: var(--primary); font-size: 13px; margin-left: 6px; }
.wordbook-item .w-meaning { font-size: 13px; color: var(--muted); }
.wordbook-item .w-del { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); }
.wordbook-item .w-del:hover { color: var(--danger); }

/* 导入 */
textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 15px; font-family: inherit; line-height: 1.6; resize: vertical; margin: 8px 0;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }

/* 金句收藏 */
.fav-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.fav-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: #f9fafb; border-radius: 12px;
}
.fav-item .f-play { flex: none; width: 30px; height: 30px; border-radius: 50%; background: #eef2ff; border: none; cursor: pointer; color: var(--primary); font-size: 13px; }
.fav-item .f-text { flex: 1; cursor: pointer; font-size: 15px; line-height: 1.6; }
.fav-item .f-src { font-size: 12px; color: var(--muted); }
.fav-item .f-del { flex: none; background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); }
.fav-item .f-del:hover { color: var(--danger); }

/* 复习 */
.review-tabs { margin: 12px 0 4px; }
.review-item {
  padding: 14px; background: #f9fafb; border-radius: 12px; margin: 10px 0;
  border: 1px solid var(--border);
}
.r-type { font-size: 12px; color: var(--primary); font-weight: 700; }
.r-content { margin: 6px 0; cursor: pointer; }
.r-word { font-size: 24px; font-weight: 800; }
.r-text { font-size: 15px; line-height: 1.7; }
.r-answer { margin: 6px 0; padding: 8px 10px; background: #fff; border-radius: 8px; font-size: 14px; color: var(--muted); }
.r-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* 今日页待复习 */
.dash-review-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.dash-review-item:last-child { border-bottom: none; }
.dr-type { flex: none; font-size: 12px; font-weight: 700; color: var(--primary); background: #eef2ff; padding: 2px 8px; border-radius: 6px; }
.dr-content { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.section-title { font-size: 14px; color: var(--muted); text-transform: none; margin: 16px 0 8px; font-weight: 700; }
.translation summary { cursor: pointer; color: var(--primary); font-size: 14px; }
.translation p { color: var(--muted); font-size: 14px; }

/* 单词列表 */
.vocab-list { display: flex; flex-direction: column; gap: 8px; }
.vocab-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: #f9fafb; border-radius: 12px; cursor: pointer; border: 1px solid transparent;
}
.vocab-item:hover { border-color: var(--primary); }
.vocab-word { font-weight: 700; font-size: 15px; }
.vocab-ipa { color: var(--primary); font-size: 13px; }
.vocab-meaning { color: var(--muted); font-size: 13px; flex: 1; }
.vocab-speak { font-size: 18px; }
.v-btn { flex: none; border: none; cursor: pointer; border-radius: 8px; font-size: 12px; font-weight: 600; padding: 5px 9px; font-family: inherit; }
.v-speak { background: #eef2ff; color: var(--primary); }
.v-save { background: #eef2ff; color: var(--primary); }
.v-speak:hover, .v-save:hover { background: var(--primary); color: #fff; }
.vocab-save { margin-top: 10px; font-size: 13px; }

.vocab-cards { display: flex; flex-direction: column; gap: 10px; }
.vocab-card { padding: 14px; background: #f9fafb; border-radius: 12px; cursor: pointer; border: 1px solid var(--border); }
.vocab-card:hover { border-color: var(--primary); }
.vocab-card .top { display: flex; align-items: baseline; gap: 10px; }
.vocab-card .pos { font-size: 12px; color: var(--muted); font-style: italic; }
.vocab-card .example { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* 分级测试 */
.progress { height: 8px; background: #e5e7eb; border-radius: 999px; margin: 12px 0; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.3s; width: 0; }
.option {
  display: block; width: 100%; text-align: left; padding: 13px 16px; margin: 8px 0;
  background: #f9fafb; border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; font-size: 15px; transition: 0.12s; font-family: inherit; color: var(--text);
}
.option:hover { border-color: var(--primary); }
.option.selected { border-color: var(--primary); background: #eef2ff; color: var(--primary); font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }

/* 步进器 */
.stepper { display: flex; gap: 4px; margin: 14px 0; }
.step {
  flex: 1; text-align: center; font-size: 12px; padding: 8px 4px; border-radius: 10px;
  background: #e5e7eb; color: var(--muted); font-weight: 600;
}
.step.active { background: var(--primary); color: #fff; }
.step.done { background: #d1fae5; color: #047857; }

/* 计时 */
.timer-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 20px; color: var(--primary); }

/* 录制 */
.video-wrap {
  position: relative; width: 100%; aspect-ratio: 4/3; background: #0b1020; border-radius: 14px;
  overflow: hidden; margin: 10px 0;
}
#preview { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.record-status {
  position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,0.55); color: #fff;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.record-status.recording { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.rec-actions { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.cam-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.cam-row select {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
.cam-row select:focus { outline: none; border-color: var(--primary); }
.upload-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.upload-label { cursor: pointer; display: inline-flex; }
.upload-label input { display: none; }
#upload-name { font-size: 13px; color: var(--primary); }
.mic-meter { flex: 1; height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.mic-meter-fill { height: 100%; width: 0; background: #e5e7eb; border-radius: 999px; transition: width 0.08s linear; }
#mic-level-text { flex: none; font-size: 12px; min-width: 64px; text-align: right; }
.speech-opt { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin: 10px 0; background: #f9fafb; }
.toggle-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; cursor: pointer; }
.toggle-row input { width: auto; margin: 0; }
.mode-toggle { display: flex; background: #f3f4f6; border-radius: 12px; padding: 4px; margin: 10px 0; }
.mode-btn { flex: 1; padding: 9px; border: none; background: none; border-radius: 9px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--muted); font-size: 14px; }
.mode-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.listen-box { border: 1px dashed var(--border); border-radius: 12px; padding: 16px; margin: 10px 0; text-align: center; background: #f9fafb; }
.listen-status { font-size: 14px; color: var(--muted); margin-bottom: 12px; min-height: 22px; }
.listen-status.listening { color: var(--danger); font-weight: 600; }

/* 打分 */
.score-wrap { display: flex; align-items: center; gap: 20px; }
.score-ring {
  width: 110px; height: 110px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--ok) 0%, #e5e7eb 0);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 10px; background: #fff; border-radius: 50%; }
.score-ring span { position: relative; font-size: 32px; font-weight: 800; }
.bars { margin: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 60px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.bar { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; width: 0; transition: width 0.6s; }
.feedback-block { background: #f9fafb; border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.feedback-block h4 { font-size: 14px; }
.feedback-block ul { margin: 4px 0; padding-left: 18px; }
.feedback-block li { font-size: 14px; margin: 4px 0; }

/* 历史 */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 10px 0; }
.cal-cell {
  aspect-ratio: 1; border-radius: 8px; background: #f3f4f6; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted);
}
.cal-cell.done { background: #d1fae5; color: #047857; font-weight: 700; }
.cal-cell .cal-score { font-size: 10px; }
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item { padding: 14px; background: #f9fafb; border-radius: 12px; border: 1px solid var(--border); }
.history-item .h-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.h-title { font-weight: 700; font-size: 15px; }
.h-date { font-size: 12px; color: var(--muted); }
.h-score-ring {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  background: conic-gradient(var(--ok) 0%, #e5e7eb 0);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.h-score-ring::before { content: ""; position: absolute; inset: 6px; background: #fff; border-radius: 50%; }
.h-score-ring span { position: relative; font-size: 17px; font-weight: 800; }
.h-bars { margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.h-bar-row { display: grid; grid-template-columns: 56px 1fr 32px; align-items: center; gap: 10px; font-size: 13px; }
.h-summary { font-size: 14px; color: var(--text); margin: 6px 0; }
.h-feedback { margin-top: 8px; }
.h-feedback summary { cursor: pointer; color: var(--primary); font-size: 13px; font-weight: 600; }
.h-feedback-body { padding: 8px 0 0; }
.h-fb-title { font-size: 13px; font-weight: 700; margin: 8px 0 2px; }
.h-feedback-body ul { margin: 4px 0; padding-left: 18px; }
.h-feedback-body li { font-size: 13px; margin: 3px 0; }
.h-feedback-body p { font-size: 13px; white-space: pre-wrap; }
.h-score { font-weight: 800; color: var(--primary); font-size: 18px; }

/* 排行榜 */
.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: #f9fafb; border-radius: 12px; }
.lb-rank { font-size: 20px; font-weight: 800; width: 34px; text-align: center; }
.lb-name { font-weight: 600; flex: 1; }
.lb-meta { font-size: 13px; color: var(--muted); }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; padding: 10px 2px; text-align: center; background: none; border: none;
  font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit;
}
.nav-item.active { color: var(--primary); }

/* 登录 */
.view { display: none; }
.view.active { display: block; }
.auth { min-height: 90vh; align-items: center; justify-content: center; }
.view.auth.active { display: flex; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.auth-hero { text-align: center; margin-bottom: 18px; }
.auth-emoji { font-size: 48px; }
.auth-hint { font-size: 13px; color: var(--muted); text-align: center; margin-top: 14px; }
.tabs { display: flex; background: #f3f4f6; border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; padding: 9px; border: none; background: none; border-radius: 9px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--muted); }
.tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 15px; font-family: inherit; margin-top: 4px;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: #1c2333; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: 0.25s; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

@media (max-width: 480px) {
  .passage-text { font-size: 15px; }
  .brand-sub { display: none; }
}

/* 视频弹窗 */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-content { position: relative; width: 100%; max-width: 480px; background: #fff; border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.modal-content video { width: 100%; border-radius: 10px; background: #000; max-height: 62vh; }

/* 用户名 chip */
.chip-user { background: #eef2ff; color: var(--primary); }

/* 宣传语横幅 */
.slogan-banner {
  background: linear-gradient(120deg, #4f46e5, #7c3aed);
  color: #fff; border-radius: 16px; padding: 20px 18px; margin: 12px 0;
  text-align: center; box-shadow: var(--shadow);
}
.slogan-main { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.slogan-sub { font-size: 13px; margin-top: 6px; opacity: 0.92; line-height: 1.6; }

/* 提示词编辑 */
.prompt-block { margin: 12px 0; }
.prompt-label { display: flex; flex-direction: column; font-size: 13px; margin-bottom: 6px; gap: 2px; }
.prompt-label b { font-size: 14px; }
.prompt-ta { width: 100%; font-size: 13px; line-height: 1.6; resize: vertical; }

/* Powered by 标注 */
.slogan-credit { font-size: 11px; margin-top: 8px; opacity: 0.75; letter-spacing: 1px; }
.auth-credit { font-size: 12px; color: var(--muted); margin-top: 10px; letter-spacing: 0.5px; }
