/* ── 基础 ───────────────────────────────────────────────── */

:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --ink: #18181b;
  --ink-2: #52525b;
  --ink-3: #a1a1aa;
  --line: #e4e4e7;
  --brand: #f97316;
  --brand-dark: #ea580c;
  --brand-soft: #fff7ed;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --card: #27272a;
    --ink: #fafafa;
    --ink-2: #d4d4d8;
    --ink-3: #8b8b93;
    --line: #3f3f46;
    --brand-soft: #3a2008;
    --warn-bg: #3a2e12;
    --warn: #fbbf24;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 下面给 .btn-block、.progress 等设了 display,会盖掉 HTML 的 hidden 属性。
   这一条把 hidden 的优先级拉回来,否则该藏的元素会一直显示。 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
        "Helvetica Neue", "Microsoft YaHei", sans-serif;
  /* 底部导航约 58px 高,再留点余量,免得最后一张卡片被挡住 */
  padding-bottom: calc(76px + var(--safe-bottom));
  overscroll-behavior-y: contain;
}

h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
}

main { padding: 12px; max-width: 560px; margin: 0 auto; }

/* ── 标签栏 ─────────────────────────────────────────────── */

.tabbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 4px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 1;
  padding: 9px 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.tab.is-active {
  background: var(--card);
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 1px 3px rgb(0 0 0 / .08);
}

/* 顶部切换只属于「首页」,切到其他栏目时整条隐藏 */
.tabbar.is-hidden { display: none; }

/* ── 底部导航 ───────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  /* iPhone 底部有手势条,safe-area 把按钮抬到它上面 */
  padding: 6px 0 calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.bnav-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bnav-item.is-active { color: var(--brand); font-weight: 600; }
.bnav-item.is-active svg { stroke-width: 2.2; }

/* 未登录时登录页盖住全屏,底部导航也要跟着藏起来 */
body.gate-open .bottom-nav { display: none; }

/* ── 空页面(遗忘曲线占位)──────────────────────────────── */

.empty-page {
  padding: 72px 24px;
  text-align: center;
}

.empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty-page h2 { margin-bottom: 8px; }

/* ── 页与卡片 ───────────────────────────────────────────── */

.page { display: none; }
.page.is-active { display: block; animation: fade .18s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .05);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.card-head h2 { margin: 0; }
.card-head-actions { display: flex; gap: 12px; }

.count {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.hint { margin: 4px 0 12px; color: var(--ink-2); font-size: 14px; }
.hint:last-child { margin-bottom: 0; }
.hint-inline { color: var(--ink-3); font-size: 13px; font-weight: 400; }
.hint code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
  font-size: 13px;
}

/* ── 按钮 ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: transform .06s, opacity .15s;
}

.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.btn-ghost { background: var(--brand-soft); border-color: transparent; color: var(--brand-dark); }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; gap: 8px; margin-bottom: 12px; }
.btn-row > * { flex: 1; }
.btn-row:last-child { margin-bottom: 0; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.link-danger { color: var(--danger); }

/* ── 图片预览 ───────────────────────────────────────────── */

.preview { margin-bottom: 12px; }

.preview img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--bg);
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 13px;
}

/* ── 进度 / 提示 ────────────────────────────────────────── */

.progress {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 14px;
  font-weight: 500;
}

.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.alert-warn { background: var(--warn-bg); color: var(--warn); }

@media (prefers-color-scheme: dark) {
  .alert { background: #3f1d1d; color: #fca5a5; }
}

/* ── 折叠区 / 表单 ──────────────────────────────────────── */

.fold { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

.fold summary {
  color: var(--brand);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "＋ "; }
.fold[open] summary::before { content: "－ "; }
.fold > *:not(summary) { margin-top: 10px; }

/* 把所有文本类输入框一起列出来 —— 之前漏掉 password 和 tel,
   导致那两个框是浏览器默认的窄样式,和其他控件对不上。 */
textarea, select,
input[type="text"], input[type="password"], input[type="tel"],
input[type="email"], input[type="number"], input[type="search"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* 低于 16px iOS 会自动放大页面 */
}

textarea { resize: vertical; line-height: 1.6; }

select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a1a1aa' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field > label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}

.field > label strong { color: var(--brand-dark); }
.field .hint { margin: 6px 0 0; font-size: 13px; }

input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 0;
  appearance: none;
  background: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: var(--line);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -11px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 1px 4px rgb(0 0 0 / .25);
}

input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--line); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--brand); }

.switch {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  cursor: pointer;
}

.switch:last-child { border-bottom: 0; padding-bottom: 0; }
.switch input { width: 20px; height: 20px; flex: none; accent-color: var(--brand); }

/* ── 词表 ───────────────────────────────────────────────── */

.wordlist { margin: 0; padding: 0; list-style: none; }

.word {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.word:last-child { border-bottom: 0; }
.word input[type="checkbox"] { width: 21px; height: 21px; margin-top: 3px; flex: none; accent-color: var(--brand); }
.word-body { flex: 1; min-width: 0; }
.word-en { font-size: 16px; font-weight: 600; word-break: break-word; }
.word-phonetic { color: var(--ink-3); font-size: 13px; }
.word-zh { color: var(--ink-2); font-size: 14px; margin-top: 1px; word-break: break-word; }
.word-del {
  flex: none;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.word.is-off { opacity: .4; }

/* ── 听写舞台 ───────────────────────────────────────────── */

.stage { padding-bottom: 12px; }

.stage-top {
  display: flex;
  justify-content: space-between;
  color: var(--ink-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.stage-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  padding: 14px 0 6px;
  text-align: center;
}

.stage-word {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
  word-break: break-word;
}

.stage-word.is-speaking { color: var(--brand); }
.stage-word.is-hidden { color: var(--ink-3); font-size: 24px; font-weight: 500; }

/* 只显示喇叭图标时,别让它大到占满半屏 */
.stage-word.is-icon { font-size: 44px; line-height: 1; }

/* 中文释义可能很长("喂养,饲养,给……食物"),字号大了会折行甚至溢出。
   用 balance 让折行均匀,并且长文本自动缩小一档。 */
.stage-word { text-wrap: balance; }
.stage-word:not(.is-icon) { font-size: clamp(22px, 7.5vw, 34px); }

.stage-sub {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 14px;
  white-space: nowrap;   /* "听写:写下你听到的单词" 不要被拆行 */
}

.stage-answer {
  padding: 13px;
  border-radius: 10px;
  background: var(--bg);
  text-align: center;
  animation: fade .2s ease;
}

.answer-en { font-size: 21px; font-weight: 700; }
.answer-phonetic { color: var(--ink-3); font-size: 14px; }
.answer-zh { margin-top: 3px; color: var(--ink-2); font-size: 15px; }

.countdown {
  height: 4px;
  margin-top: 13px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.countdown-bar {
  height: 100%;
  width: 100%;
  border-radius: 2px;
  background: var(--brand);
  transform-origin: left;
}

/* ── 播放控制 ───────────────────────────────────────────── */

.player-main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.btn-round {
  width: 54px;
  height: 54px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  letter-spacing: -.5px;
}

.btn-play { flex: 1; min-height: 54px; font-size: 17px; }

/* ── 朗读声音状态 ───────────────────────────────────────── */

.voice-dots { display: flex; gap: 8px; }

/* 「英」「中」两个小胶囊,左边一个圆点表示可用与否 */
.voice-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 13px;
}

.voice-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);   /* 检查中:灰点 */
}

.voice-dot.is-ok::before { background: var(--ok); }
.voice-dot.is-bad::before { background: var(--danger); }

/* ── 密码门 ─────────────────────────────────────────────── */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.gate-box {
  width: 100%;
  max-width: 340px;
  padding: 28px 22px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 4px 24px rgb(0 0 0 / .08);
  text-align: center;
}

.gate-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--brand);
  font-size: 32px;
  line-height: 62px;
}

.gate-box h1 { margin: 0 0 4px; font-size: 23px; font-weight: 700; }
.gate-box .hint { margin-bottom: 16px; }
.gate-box input { margin-bottom: 10px; text-align: center; }
.gate-box .alert { text-align: left; }
.gate-foot { margin: 14px 0 0 !important; font-size: 13px; }

/* 验证码一行:输入框占满剩余宽度,获取按钮固定宽度贴右 */
.code-row { display: flex; gap: 8px; margin-bottom: 10px; }
.code-row input { flex: 1; min-width: 0; margin-bottom: 0 !important; }

.btn-code {
  flex: none;
  width: 112px;
  padding: 0 6px;
  font-size: 14px;
  white-space: nowrap;
}

/* 倒计时中变灰,但要能看出剩余秒数 */
.btn-code:disabled { opacity: .5; }

/* 底部:左边说明文字,右下角切换登录方式 */
.gate-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  text-align: left;
}

.gate-bottom .gate-foot {
  margin: 0 !important;
  flex: 1;
  font-size: 12px;
  line-height: 1.4;
}

.gate-bottom .link { flex: none; white-space: nowrap; }

/* ── 我的账号 ───────────────────────────────────────────── */

.account-rows {
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.account-row:last-child { border-bottom: 0; }
.account-label { color: var(--ink-2); }

.invite-code {
  padding: 14px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .18em;
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.invite-list { margin: 10px 0 0; padding: 0; list-style: none; }

.invite-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.invite-list li:last-child { border-bottom: 0; }
.invite-list .invite-when { color: var(--ink-3); font-size: 13px; }

/* ── 微信引导 ───────────────────────────────────────────── */

.wechat-tip {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(0 0 0 / .72);
}

.wechat-tip-box {
  width: 100%;
  max-width: 330px;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--card);
  font-size: 15px;
  line-height: 1.65;
}

.wechat-tip-box p { margin: 0 0 10px; color: var(--ink-2); }
.wechat-tip-title { font-size: 17px; font-weight: 600; color: var(--ink) !important; }

.wechat-tip-step {
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark) !important;
}

/* 指向右上角的箭头,帮用户定位微信的菜单按钮 */
.wechat-tip::before {
  content: "↗";
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: 18px;
  color: #fff;
  font-size: 40px;
  font-weight: 700;
  animation: nudge 1.4s ease-in-out infinite;
}

@keyframes nudge {
  0%, 100% { transform: translate(0, 0); opacity: .95; }
  50% { transform: translate(5px, -5px); opacity: .55; }
}

/* ── 遗忘曲线 ───────────────────────────────────────────── */

.curve-top { text-align: center; }
.curve-date { color: var(--ink-3); font-size: 13px; }

.curve-count {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 2px 0 2px;
}

.curve-count strong {
  color: var(--brand);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.curve-count span { color: var(--ink-2); font-size: 15px; }
.curve-sub { margin-bottom: 14px; color: var(--ink-3); font-size: 13px; }
.curve-top .btn { margin-top: 2px; }

.batch-list { margin: 0; padding: 0; list-style: none; }

.batch-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.batch-item:last-child { border-bottom: 0; }
.batch-body { flex: 1; min-width: 0; }

.batch-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.batch-meta { margin-top: 2px; color: var(--ink-3); font-size: 13px; }

/* 第几轮 / 逾期 的小标签 */
.batch-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 500;
}

.batch-tag.is-overdue { background: #fef2f2; color: #b91c1c; }

@media (prefers-color-scheme: dark) {
  .batch-tag.is-overdue { background: #3f1d1d; color: #fca5a5; }
}

/* 五个小圆点表示这批的复习进度 */
.batch-dots { display: flex; gap: 3px; margin-top: 5px; }

.batch-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
}

.batch-dots i.is-done { background: var(--ok); }
.batch-dots i.is-now { background: var(--brand); }

.batch-item .btn { flex: none; min-height: 38px; padding: 0 14px; font-size: 14px; }

/* ── 离线横幅 ───────────────────────────────────────────── */

.offline-bar {
  margin-bottom: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 14px;
  line-height: 1.5;
}

/* ── 浮层提示 ───────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(72px + var(--safe-bottom));   /* 让开底部导航 */
  z-index: 50;
  max-width: 80vw;
  padding: 11px 17px;
  border-radius: 999px;
  background: rgb(24 24 27 / .93);
  color: #fff;
  font-size: 14px;
  text-align: center;
  transform: translateX(-50%);
  animation: rise .2s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 10px); }
}
