/* —————————————————————————————————————
   托福背词 · 本地版
   Design: Apple-inspired, calm & confident
   ————————————————————————————————————— */

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fbfbfd;
  --bg-elev: #ffffff;
  --bg-soft: #f5f5f7;
  --ink: #1d1d1f;
  --ink-2: #424245;
  --ink-3: #6e6e73;
  --ink-4: #a1a1a6;
  --line: #e5e5e7;
  --line-soft: #f0f0f2;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --gold: #b58900;
  --gold-soft: #fff6dc;
  --green: #1d8e3a;
  --red: #d70015;
  --amber: #b25000;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 2px 6px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.08), 0 24px 60px rgba(0,0,0,.10);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-elev: #1c1c1e;
    --bg-soft: #2c2c2e;
    --ink: #f5f5f7;
    --ink-2: #d2d2d7;
    --ink-3: #a1a1a6;
    --ink-4: #6e6e73;
    --line: #2c2c2e;
    --line-soft: #1c1c1e;
    --accent: #2997ff;
    --accent-hover: #3aa3ff;
    --gold: #ffd60a;
    --gold-soft: #3a2e00;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
  }
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.003em;
  min-height: 100vh;
}

button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* —— Top nav —— */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251, 251, 253, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  .nav { background: rgba(0,0,0,.72); }
}
.nav-inner {
  max-width: 1280px; margin: 0 auto;
  height: 56px; padding: 0 28px;
  display: flex; align-items: center; gap: 32px;
}
.brand {
  font-weight: 600; font-size: 17px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
}
.brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #5ac8fa);
}
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  padding: 7px 14px; border-radius: 8px;
  color: var(--ink-2); font-size: 14px; font-weight: 450;
  transition: all .15s ease;
}
.tab:hover { color: var(--ink); background: var(--bg-soft); }
.tab.active { color: var(--ink); background: var(--bg-soft); font-weight: 550; }

/* —— Layout —— */
.container {
  max-width: 1280px; margin: 0 auto;
  padding: 56px 28px 96px;
}
.view { display: none; }
.view.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* —— Typography —— */
.hed-xl {
  font-size: 56px; line-height: 1.05; font-weight: 600;
  letter-spacing: -0.025em; color: var(--ink);
}
.hed-lg {
  font-size: 32px; line-height: 1.15; font-weight: 600;
  letter-spacing: -0.015em;
}
.hed-md {
  font-size: 21px; font-weight: 600; letter-spacing: -0.01em;
}
.kicker {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
}
.body-lg { font-size: 17px; color: var(--ink-2); line-height: 1.5; }
.body { font-size: 15px; color: var(--ink-2); }
.muted { color: var(--ink-3); }

/* —— Today dashboard —— */
.today-hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px;
  margin-bottom: 32px;
}
@media (max-width: 900px) {
  .today-hero { grid-template-columns: 1fr; }
}

.hero-card {
  background: linear-gradient(135deg, #1d1d1f 0%, #3a3a3c 100%);
  color: #fff;
  border-radius: 24px;
  padding: 44px 40px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.hero-card::after {
  content: "";
  position: absolute; right: -80px; top: -80px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(0,113,227,.35), transparent 70%);
  border-radius: 50%;
}
.hero-card .kicker { color: rgba(255,255,255,.6); }
.hero-card h1 { color: #fff; margin: 12px 0 16px; }
.hero-card .meta { color: rgba(255,255,255,.7); }
.hero-card .actions { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; position: relative; z-index: 1; }

.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-num {
  font-size: 38px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--ink); line-height: 1.1;
}
.stat-num.warn { color: var(--amber); }
.stat-num.amber { color: #ff9f0a; }
.stat-num.ok { color: var(--green); }
.stat-label { color: var(--ink-3); font-size: 13px; margin-top: 6px; }

/* —— Buttons —— */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 22px;
  border-radius: 980px;
  font-size: 15px; font-weight: 500;
  transition: all .15s ease;
  letter-spacing: -0.005em;
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-light {
  background: rgba(255,255,255,.16); color: #fff;
  backdrop-filter: blur(10px);
}
.btn-light:hover { background: rgba(255,255,255,.24); }
.btn-ghost {
  background: var(--bg-soft); color: var(--ink);
}
.btn-ghost:hover { background: var(--line); }
.btn-amber {
  background: #ff9f0a; color: #fff;
}
.btn-amber:hover { background: #ff8800; transform: translateY(-1px); }

/* —— Section blocks —— */
.section { margin-top: 56px; }
.section-hd {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
}

/* —— Word list rows —— */
.wlist {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.wrow {
  display: grid;
  grid-template-columns: 200px 180px 1fr auto;
  gap: 20px; align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  transition: background .12s ease;
  cursor: pointer;
}
.wrow:first-child { border-top: 0; }
.wrow:hover { background: var(--bg-soft); }
.wrow .w-en {
  font-size: 18px; font-weight: 550; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.wrow .w-ipa { color: var(--ink-3); font-family: var(--mono); font-size: 13px; }
.wrow .w-def {
  color: var(--ink-2); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wrow .w-meta { display: flex; gap: 8px; align-items: center; }
@media (max-width: 760px) {
  .wrow { grid-template-columns: 1fr; gap: 6px; }
  .wrow .w-def { white-space: normal; }

  /* 导航：窄屏让标签横向滚动，避免挤出屏幕 */
  .nav-inner { gap: 12px; }
  .tabs {
    margin-left: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    max-width: 100%;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex: 0 0 auto; padding: 7px 11px; }
  .container { padding: 32px 18px 80px; }
}

/* 🔊 朗读按钮 */
.speak-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  font-size: .72em; line-height: 1; padding: 2px 4px;
  border-radius: 6px; vertical-align: middle; opacity: .65;
  transition: opacity .15s ease, background .15s ease;
}
.speak-btn:hover { opacity: 1; background: var(--bg-soft); }

/* 云同步 */
.sync-status { font-size: 12px; color: var(--ink-3); }
.sync-status.bad { color: var(--red); }
.sync-input {
  padding: 0 12px; height: 36px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-elev); color: var(--ink); font-size: 14px;
}
.sync-input:focus { outline: none; border-color: var(--accent, #0071e3); }

.star {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; font-size: 13px;
  color: var(--gold);
}
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 550; letter-spacing: 0;
  color: var(--ink-3); background: var(--bg-soft);
}
.tag.lv-极高频 { color: #b91c1c; background: #fee2e2; }
.tag.lv-高频   { color: #b25000; background: #fff1d6; }
.tag.lv-中频   { color: #166534; background: #dcfce7; }
.tag.lv-常用   { color: #1e40af; background: #dbeafe; }
.tag.due { color: var(--amber); background: #fff1d6; }
.tag.done { color: var(--green); background: #dcfce7; }
.tag.interview { color: var(--gold); background: var(--gold-soft); }
.tag.respell { color: #c2410c; background: #ffedd5; }
.tag.oneshot { color: #6d28d9; background: #ede9fe; }

@media (prefers-color-scheme: dark) {
  .tag.lv-极高频 { color: #ff6b6b; background: rgba(255,107,107,.12); }
  .tag.lv-高频   { color: #ffb86b; background: rgba(255,184,107,.12); }
  .tag.lv-中频   { color: #86efac; background: rgba(134,239,172,.12); }
  .tag.lv-常用   { color: #93c5fd; background: rgba(147,197,253,.12); }
  .tag.due { color: #ffb86b; background: rgba(255,184,107,.12); }
  .tag.done { color: #86efac; background: rgba(134,239,172,.12); }
  .tag.respell { color: #ffb86b; background: rgba(255,159,10,.15); }
  .tag.oneshot { color: #c4b5fd; background: rgba(196,181,253,.12); }
}

/* —— Empty state —— */
.empty {
  text-align: center; padding: 80px 20px;
  color: var(--ink-3);
}
.empty .ico { font-size: 48px; margin-bottom: 16px; opacity: .35; }

/* —— Study card —— */
.study {
  max-width: 720px; margin: 0 auto;
}
.study-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px;
  font-size: 13px; color: var(--ink-3);
}
.progress {
  flex: 1; max-width: 280px;
  height: 4px; background: var(--line);
  border-radius: 999px; overflow: hidden; margin: 0 20px;
}
.progress-bar {
  height: 100%; background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

.card-flip {
  perspective: 1800px;
  min-height: 440px;
  margin-bottom: 32px;
}
.card-flip-inner {
  position: relative; width: 100%; min-height: 440px;
  transition: transform .55s cubic-bezier(.22,.61,.36,1);
  transform-style: preserve-3d;
}
.card-flip.flipped .card-flip-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 56px 48px;
  box-shadow: var(--shadow-lg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column;
}
.card-back { transform: rotateY(180deg); }

.card-face .interview-mark {
  position: absolute; top: 24px; right: 24px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold);
  font-size: 12px; font-weight: 600; letter-spacing: 0;
}

.card-word {
  font-size: 64px; font-weight: 600;
  letter-spacing: -0.025em; line-height: 1.1;
  margin-top: 36px;
}
.card-ipa {
  margin-top: 16px; font-family: var(--mono);
  color: var(--ink-3); font-size: 18px;
}
.card-hint {
  margin-top: auto; text-align: center;
  color: var(--ink-4); font-size: 13px;
  padding-top: 32px;
}
.card-hint kbd {
  display: inline-block; padding: 2px 7px;
  margin: 0 3px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-2);
}

.card-back .def {
  font-size: 22px; line-height: 1.5;
  color: var(--ink); font-weight: 450;
  letter-spacing: -0.005em;
}
.card-back .def-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 600;
  margin-bottom: 10px;
}
.card-back .mnemonic {
  margin-top: 28px; padding: 20px 22px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  font-size: 14px; color: var(--ink-2);
  line-height: 1.6;
}
.card-back .mnemonic-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 600;
  margin-bottom: 6px;
}

.rating {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.rating-btn {
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-align: center;
  transition: all .15s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.rating-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.rating-btn .lbl { font-weight: 550; font-size: 15px; }
.rating-btn .sub { font-size: 12px; color: var(--ink-3); }
.rating-btn .key {
  display: inline-block; margin-top: 4px;
  padding: 1px 7px; border-radius: 4px;
  background: var(--bg-soft); color: var(--ink-3);
  font-family: var(--mono); font-size: 11px;
}
.rating-btn.again { color: var(--red); border-color: rgba(215,0,21,.2); }
.rating-btn.hard  { color: var(--amber); border-color: rgba(178,80,0,.2); }
.rating-btn.good  { color: var(--green); border-color: rgba(29,142,58,.2); }

.study-flip-btn {
  display: block; width: 100%;
  padding: 14px; margin-top: 8px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-md);
  font-weight: 550; font-size: 15px;
  transition: all .15s ease;
}
.study-flip-btn:hover { opacity: .9; }

/* —— Spell card —— */
.spell-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 48px 44px 36px;
  min-height: 440px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  margin-bottom: 32px;
}
.spell-card .def-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 14px;
}
.spell-def {
  font-size: 28px; line-height: 1.5;
  color: var(--ink); font-weight: 500;
  letter-spacing: -0.005em;
}
.spell-ipa {
  margin-top: 14px; font-family: var(--mono);
  color: var(--ink-3); font-size: 16px;
}
.spell-input-row { margin-top: auto; padding-top: 32px; }
.spell-input {
  width: 100%;
  padding: 18px 22px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.005em;
  outline: none;
  transition: all .15s ease;
  text-align: center;
  font-family: var(--font);
}
.spell-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,.12); }
.spell-input.ok { border-color: var(--green); background: rgba(29,142,58,.06); }
.spell-input.bad {
  border-color: var(--red); background: rgba(215,0,21,.05);
  animation: shake .35s ease;
}
.spell-input:disabled { opacity: .65; cursor: not-allowed; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.spell-hint {
  margin-top: 14px; min-height: 22px;
  font-size: 14px; color: var(--ink-2);
  text-align: center;
}
.spell-hint .ok { color: var(--green); font-weight: 600; }
.spell-hint .bad { color: var(--red); font-weight: 600; }
.spell-hint s { color: var(--ink-4); }
.spell-hint b { color: var(--ink); font-weight: 600; }
.spell-actions {
  margin-top: 14px;
  display: flex; justify-content: center;
}
.spell-actions .btn { height: 36px; font-size: 13px; padding: 0 16px; }

/* —— Filters / search bar —— */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 20px;
}
.search {
  flex: 1; min-width: 240px;
  height: 40px; padding: 0 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  transition: all .15s ease;
  outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,.15); }

.chip {
  height: 32px; padding: 0 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .12s ease;
}
.chip:hover { border-color: var(--ink-4); color: var(--ink); }
.chip.on {
  background: var(--ink); color: var(--bg);
  border-color: var(--ink);
}

.count { color: var(--ink-3); font-size: 13px; margin-left: auto; }

/* —— Pagination —— */
.pager {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  margin-top: 28px;
  color: var(--ink-3); font-size: 13px;
}
.pager button {
  padding: 8px 14px; border-radius: 8px;
  background: var(--bg-elev); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 13px;
  transition: all .12s ease;
}
.pager button:hover:not(:disabled) { background: var(--bg-soft); color: var(--ink); }
.pager button:disabled { opacity: .35; cursor: not-allowed; }

/* —— Toast —— */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 22px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: all .25s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* —— Done celebration —— */
.celebrate {
  text-align: center;
  padding: 80px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-md);
}
.celebrate .ring {
  width: 96px; height: 96px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34c759, #30b452);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 44px;
  box-shadow: 0 12px 32px rgba(52,199,89,.35);
}

/* —— Modal for word detail —— */
.modal-bg {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-bg.show { display: flex; animation: fadeIn .2s ease; }
.modal {
  background: var(--bg-elev);
  border-radius: 20px;
  padding: 36px 36px 32px;
  max-width: 560px; width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal .close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%; background: var(--bg-soft);
  color: var(--ink-3); font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.modal .close:hover { background: var(--line); color: var(--ink); }

.modal .m-word {
  font-size: 36px; font-weight: 600; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 10px;
}
.modal .m-ipa { font-family: var(--mono); color: var(--ink-3); margin-top: 6px; }
.modal .m-def { margin-top: 20px; font-size: 16px; color: var(--ink); line-height: 1.6; }
.modal .m-mnem {
  margin-top: 18px; padding: 14px 16px;
  background: var(--bg-soft); border-radius: var(--radius-md);
  font-size: 13px; color: var(--ink-2);
}
.modal .m-status {
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-3);
  display: flex; gap: 16px; flex-wrap: wrap;
}
.modal .m-actions {
  margin-top: 22px; display: flex; gap: 10px;
}

/* —— Settings —— */
.settings-grid {
  display: grid; gap: 16px; max-width: 720px;
}
.setting-row {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex; justify-content: space-between; align-items: center;
}
.setting-row .lbl { font-weight: 500; }
.setting-row .desc { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.setting-row input[type=number] {
  width: 80px; padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; text-align: center;
}
