/* 沿用桌面版 Apple Style Theme 的配色与卡片样式 */
:root {
  --font: -apple-system, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI Variable Text",
    "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --fg: #1d1d1f;
  --fg-subtle: #86868b;
  --canvas: #f5f5f7;
  --elevated: #ffffff;
  --border: #d2d2d7;
  --border-subtle: #e8e8ed;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-soft: rgba(120, 120, 128, 0.08);
  --blue: #0071e3;
  --blue-soft: rgba(0, 113, 227, 0.07);
  --new: #007aff;
  --learn: #ff3b30;
  --review: #34c759;
  --hard: #ff9500;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.08);
  --heat-0: rgba(120, 120, 128, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #f5f5f7;
    --fg-subtle: #98989d;
    --canvas: #1c1c1e;
    --elevated: #2c2c2e;
    --border: #3a3a3c;
    --border-subtle: #323236;
    --fill: rgba(120, 120, 128, 0.28);
    --fill-soft: rgba(120, 120, 128, 0.22);
    --blue: #0a84ff;
    --blue-soft: rgba(10, 132, 255, 0.16);
    --new: #0a84ff;
    --learn: #ff453a;
    --review: #30d158;
    --hard: #ff9f0a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);
    --heat-0: rgba(120, 120, 128, 0.24);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--fg);
  background: var(--canvas);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
button:disabled { opacity: 0.5; cursor: default; }

#app {
  min-height: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 16px);
}
.loading { text-align: center; color: var(--fg-subtle); padding-top: 40vh; }

/* ---------- 通用 ---------- */
.panel {
  background: var(--elevated);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border-radius: 980px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 1.02em;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.plain { background: var(--fill); color: var(--fg); }
.link { color: var(--blue); font-weight: 500; }
.muted { color: var(--fg-subtle); }
.error { color: var(--learn); font-size: 0.9em; min-height: 1.4em; margin: 8px 0 0; }

/* ---------- 登录 ---------- */
.auth { padding-top: 9vh; }
.auth .logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 14px; box-shadow: var(--shadow); }
.auth h1 { text-align: center; font-size: 1.7em; margin: 0; letter-spacing: 0.01em; }
.auth .sub { text-align: center; color: var(--fg-subtle); margin: 4px 0 26px; }
.auth form { padding: 22px 20px; }
.field {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--canvas);
  outline: none;
  font-size: 16px; /* 小于 16px 时 iOS 聚焦会放大页面 */
}
.field:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.25); }
.auth .switch { text-align: center; margin-top: 18px; color: var(--fg-subtle); }
.tip {
  margin-top: 22px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--blue-soft);
  font-size: 0.88em;
  color: var(--fg-subtle);
}
.tip b { color: var(--fg); font-weight: 600; }

/* ---------- 首页 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; min-height: 40px; }
.topbar h1 { font-size: 1.75em; margin: 0; letter-spacing: 0.01em; }
.topbar .who { color: var(--fg-subtle); font-size: 0.9em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--fill); font-size: 1.1em;
  display: inline-flex; align-items: center; justify-content: center;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { padding: 12px 8px; text-align: center; border-radius: 16px; }
.stat .num { font-size: 1.5em; font-weight: 700; line-height: 1.2; }
.stat .lbl { font-size: 0.76em; color: var(--fg-subtle); }
.section-title { font-size: 0.8em; font-weight: 600; color: var(--fg-subtle); letter-spacing: 0.08em; margin: 20px 6px 8px; }
.decks { overflow: hidden; }
.deck {
  display: flex; align-items: center; width: 100%; text-align: left;
  padding: 15px 16px; gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.deck:last-child { border-bottom: none; }
.deck:active { background: var(--fill-soft); }
.deck .emoji { font-size: 1.5em; width: 1.4em; text-align: center; }
.deck .name { font-weight: 600; font-size: 1.05em; }
.deck .progress { font-size: 0.78em; color: var(--fg-subtle); }
.deck .grow { flex: 1; min-width: 0; }
.deck .done { color: var(--review); font-size: 0.85em; font-weight: 600; }
.cnt { display: inline-flex; gap: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cnt .n { color: var(--new); }
.cnt .l { color: var(--learn); }
.cnt .r { color: var(--review); }
.cnt .zero { color: var(--border); }
.cnt .cur { text-decoration: underline; text-underline-offset: 3px; }
.legend { font-size: 0.78em; color: var(--fg-subtle); margin: 8px 6px 0; }
.legend i { font-style: normal; font-weight: 600; }
.heat { padding: 14px 16px 12px; }
.heat-grid { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat-grid span { aspect-ratio: 1; border-radius: 3px; background: var(--heat-0); }
.heat-grid .h1 { background: rgba(52, 199, 89, 0.35); }
.heat-grid .h2 { background: rgba(52, 199, 89, 0.6); }
.heat-grid .h3 { background: rgba(52, 199, 89, 0.85); }
.heat-grid .h4 { background: #248a3d; }
.heat-grid .future { background: transparent; }
.heat-grid .today { outline: 1.5px solid var(--fg-subtle); outline-offset: 0; }

/* ---------- 设置 ---------- */
.row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); gap: 12px; }
.row:last-child { border-bottom: none; }
.row small { display: block; color: var(--fg-subtle); font-size: 0.8em; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); font-size: 1.2em; font-weight: 600; }
.stepper output { min-width: 2.6em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 复习 ---------- */
.review-screen { display: flex; flex-direction: column; min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px); min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px); }
.review-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.review-bar .icon-btn { font-size: 1em; }
.card {
  flex: 1;
  background: var(--elevated);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.6em 1.3em;
  text-align: center;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.card hr { border: none; height: 1px; background: var(--border-subtle); margin: 1.3em 0; }
.mode-label { font-size: 0.82em; font-weight: 600; color: var(--fg-subtle); letter-spacing: 0.12em; margin-bottom: 0.9em; }
.word { font-size: 2.1em; font-weight: 700; letter-spacing: 0.01em; margin: 0.35em 0; line-height: 1.25; }
.meaning { font-size: 1.15em; margin: 0.5em auto; max-width: 34em; }
.prompt { color: var(--fg-subtle); font-size: 0.92em; margin-top: 0.9em; }
.img img { max-height: 34vh; max-width: 100%; border-radius: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10); }
.pills { margin-top: 1.1em; }
.pill { display: inline-block; font-size: 0.78em; color: var(--fg-subtle); background: var(--fill); border-radius: 980px; padding: 3px 12px; margin: 0 3px; }
.phonetic { color: var(--fg-subtle); font-size: 1.05em; margin: 0.1em 0 0.4em; }
.example { margin-top: 1.1em; padding: 0.9em 1.3em; background: var(--fill-soft); border-radius: 12px; display: inline-block; max-width: 100%; }
.ex-fr { font-size: 1.02em; }
.ex-zh { color: var(--fg-subtle); font-size: 0.92em; margin-top: 0.3em; }
.hook { margin-top: 1.1em; padding: 0.9em 1.3em; text-align: left; background: var(--blue-soft); border-left: 3px solid var(--blue); border-radius: 12px; display: inline-block; max-width: 100%; font-size: 0.95em; line-height: 1.6; }
.hook-label { font-size: 0.78em; font-weight: 600; color: var(--blue); letter-spacing: 0.08em; margin-bottom: 0.35em; }
.hook b { color: var(--blue); font-weight: 600; }
.hook .arrow { color: var(--fg-subtle); margin: 0 0.25em; }
.play {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: 6px auto 2px; border-radius: 50%;
  background: var(--blue-soft); color: var(--blue);
}
.play svg { width: 20px; height: 20px; fill: currentColor; margin-left: 3px; }
.play.big { width: 72px; height: 72px; margin: 18px auto 6px; }
.play.big svg { width: 30px; height: 30px; margin-left: 4px; }
.play.playing { background: var(--blue); color: #fff; }
.example .play { display: flex; width: 36px; height: 36px; margin: 8px auto 0; }
.example .play svg { width: 16px; height: 16px; }
.typeans {
  display: block; width: 100%; max-width: 22em; margin: 0.9em auto 0;
  font-size: 1.15em; text-align: center;
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
  background: var(--canvas); outline: none;
}
.typeans:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.25); }
.typed { font-size: 1.15em; margin-bottom: 0.2em; }
.typed .good { color: var(--review); font-weight: 600; }
.typed .bad { color: var(--learn); text-decoration: line-through; }
.typed .near { color: var(--hard); font-weight: 600; }
.typed small { display: block; color: var(--fg-subtle); font-size: 0.72em; }

.actions { position: sticky; bottom: 0; padding: 12px 0 2px; background: linear-gradient(transparent, var(--canvas) 22%); }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate { padding: 9px 2px 10px; border-radius: 14px; background: var(--elevated); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); transition: transform 0.1s ease; }
.rate:active { transform: scale(0.95); }
.rate small { display: block; font-size: 0.72em; color: var(--fg-subtle); }
.rate b { font-weight: 600; }
.rate.r1 b { color: var(--learn); }
.rate.r2 b { color: var(--hard); }
.rate.r3 b { color: var(--review); }
.rate.r4 b { color: var(--new); }
.finished { text-align: center; padding: 18vh 12px 0; flex: 1; }
.finished .big { font-size: 3.4em; }
.finished h2 { margin: 6px 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  background: rgba(40, 40, 42, 0.92); color: #fff; padding: 9px 18px; border-radius: 980px; font-size: 0.9em;
  z-index: 10; max-width: 86vw; text-align: center;
}
