/* ============================================================
   大学英语四六级 · 单词天天记  (PWA / iPhone)
   浅色玻璃主题 —— 与 Windows 版视觉语言保持一致，但按手机竖屏重排
   ============================================================ */

:root {
  --bg-1: #eef4f8;
  --bg-2: #e6f0f7;
  --bg-3: #f6f1ec;

  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --stroke: rgba(255, 255, 255, 0.85);
  --line: rgba(20, 40, 60, 0.08);

  --ink: #17232e;
  --ink-2: #4a5c6b;
  --ink-3: #8899a6;

  --brand: #2f7fd1;
  --brand-2: #16a394;
  --brand-soft: rgba(47, 127, 209, 0.1);

  --ok: #2fa36b;
  --warn: #d98b23;

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 11px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --shadow-card: 0 8px 26px rgba(28, 55, 80, 0.09), 0 1px 2px rgba(28, 55, 80, 0.05);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 620px at 12% -8%, #ffffff 0%, rgba(255,255,255,0) 62%),
    radial-gradient(900px 520px at 92% 4%, #dff0f6 0%, rgba(223,240,246,0) 60%),
    radial-gradient(900px 700px at 50% 108%, #f7ece2 0%, rgba(247,236,226,0) 62%),
    linear-gradient(170deg, var(--bg-1) 0%, var(--bg-2) 52%, var(--bg-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-t) + 8px) 12px 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.86) 0%, rgba(255,255,255,0.55) 78%, rgba(255,255,255,0) 100%);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.tb-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: var(--glass);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.tb-btn:active { transform: scale(0.92); background: var(--glass-strong); }
.tb-btn.off { color: var(--ink-3); opacity: .55; }
.tb-back[hidden] { display: none; }
.tb-btn[hidden] { display: none; }

/* ---------------- 页面容器 ---------------- */

main {
  flex: 1;
  padding: 4px 16px calc(var(--safe-b) + 28px);
  animation: fade-up .3s ease;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 1px;
  margin: 22px 2px 10px;
}

/* ---------------- 首页 ---------------- */

.hero {
  padding: 18px 4px 6px;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.4px;
}
.hero p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}

.grade-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px;
  margin-bottom: 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  background: var(--glass);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  cursor: pointer;
  text-align: left;
  transition: transform .18s ease;
  overflow: hidden;
}
.grade-card:active { transform: scale(0.975); }

.grade-badge {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  box-shadow: 0 6px 16px rgba(47,127,209,0.28);
}
.grade-4 .grade-badge { background: linear-gradient(150deg, #4b96e0, #2f6ec1); }
.grade-6 .grade-badge { background: linear-gradient(150deg, #2bb8a6, #12867c); box-shadow: 0 6px 16px rgba(22,163,148,0.28); }

.grade-meta { flex: 1; min-width: 0; }
.grade-name { font-size: 17px; font-weight: 700; margin-bottom: 3px; }
.grade-sub { font-size: 12.5px; color: var(--ink-3); }

.grade-progress {
  margin-top: 9px;
  height: 5px;
  border-radius: 3px;
  background: rgba(20, 40, 60, 0.08);
  overflow: hidden;
}
.grade-progress i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .4s ease;
}

.grade-arrow { color: var(--ink-3); flex: none; }

/* ---------------- 课次列表 ---------------- */

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (min-width: 430px) {
  .lesson-grid { grid-template-columns: repeat(5, 1fr); }
}

.lesson-cell {
  position: relative;
  padding: 12px 4px 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: var(--glass);
  box-shadow: 0 2px 8px rgba(28,55,80,0.06);
  text-align: center;
  cursor: pointer;
  transition: transform .15s ease;
}
.lesson-cell:active { transform: scale(0.94); }

.lesson-no { font-size: 16px; font-weight: 700; line-height: 1.15; }
.lesson-range {
  font-size: 9.5px;
  color: var(--ink-3);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-cell.done {
  background: linear-gradient(160deg, rgba(47,163,107,0.16), rgba(47,163,107,0.06));
  border-color: rgba(47,163,107,0.34);
}
.lesson-cell.done .lesson-no { color: var(--ok); }
.lesson-cell.done::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 10px;
  color: var(--ok);
  font-weight: 700;
}

/* ---------------- 学习页 ---------------- */

.study-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 12px;
}

/* 学习页整块在可视区垂直居中，避免下方一大片空白 */
.study-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - 150px);
}
.study-bar {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: rgba(20,40,60,0.08);
  overflow: hidden;
}
.study-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .35s ease;
}
.study-count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.word-card {
  position: relative;
  padding: 26px 20px 24px;
  border: 1px solid var(--stroke);
  border-radius: 26px;
  background: var(--glass-strong);
  box-shadow: 0 14px 40px rgba(28,55,80,0.11), 0 1px 2px rgba(28,55,80,0.05);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  text-align: center;
  min-height: clamp(232px, 36vh, 400px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform .2s ease;
}
.word-card.swap { animation: card-in .26s ease; }
@keyframes card-in {
  from { opacity: 0; transform: translateX(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.word-text {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.14;
  word-break: break-word;
}
.word-text.long { font-size: 30px; }
.word-text.xlong { font-size: 24px; }

.word-phonetic {
  margin-top: 8px;
  font-size: 15px;
  color: var(--ink-3);
  font-family: "Times New Roman", Georgia, serif;
}

.word-meaning {
  margin-top: 18px;
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
  text-align: center;
  padding: 0 2px;
}
/* 释义长的时候才左对齐，短释义居中跟着单词走，视觉更稳 */
.word-meaning.mid { font-size: 15px; text-align: left; }
.word-meaning.small { font-size: 13.5px; text-align: left; }

.word-meaning b { color: var(--ink); font-weight: 700; }

.wm-fav {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: transform .16s ease, color .16s ease;
}
.wm-fav:active { transform: scale(0.85); }
.wm-fav.on { color: #e9564f; }

/* 朗读按钮 */
.speak-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn-speak {
  flex: 1;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  font-size: 15.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(150deg, #4b96e0, #2f6ec1);
  box-shadow: 0 8px 20px rgba(47,127,209,0.28);
  cursor: pointer;
  transition: transform .16s ease;
}
.btn-speak:active { transform: scale(0.965); }
.btn-speak.speaking { background: linear-gradient(150deg, #2bb8a6, #12867c); box-shadow: 0 8px 20px rgba(22,163,148,0.28); }

/* 翻页 */
.nav-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.btn-nav {
  flex: 1;
  height: 54px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: var(--glass);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform .16s ease, opacity .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-nav:active { transform: scale(0.96); }
.btn-nav[disabled] { opacity: .38; }
.btn-nav.primary {
  background: linear-gradient(150deg, #4b96e0, #2f6ec1);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(47,127,209,0.26);
}

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 14px;
  line-height: 1.7;
}

/* 完成页 */
.finish {
  margin-top: 28px;
  padding: 30px 22px;
  border-radius: 26px;
  border: 1px solid var(--stroke);
  background: var(--glass-strong);
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: pop .32s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}
.finish .big { font-size: 54px; line-height: 1; }
.finish h2 { margin: 14px 0 8px; font-size: 21px; }
.finish p { margin: 0 0 22px; font-size: 14px; color: var(--ink-2); line-height: 1.7; }

.btn-primary {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(150deg, #4b96e0, #2f6ec1);
  box-shadow: 0 10px 24px rgba(47,127,209,0.3);
  cursor: pointer;
  transition: transform .16s ease;
}
.btn-primary:active { transform: scale(0.97); }
.btn-ghost {
  width: 100%;
  height: 50px;
  margin-top: 10px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--glass);
  cursor: pointer;
}

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 40px);
  transform: translate(-50%, 16px);
  max-width: 78vw;
  padding: 11px 18px;
  border-radius: 14px;
  background: rgba(23, 35, 46, 0.86);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  backdrop-filter: blur(8px);
  z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 音频解锁层 ---------------- */
.unlock {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(238, 244, 248, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.unlock[hidden] { display: none; }
.unlock-card {
  width: 100%;
  max-width: 340px;
  padding: 30px 24px 24px;
  border-radius: 26px;
  border: 1px solid var(--stroke);
  background: var(--glass-strong);
  box-shadow: 0 20px 50px rgba(28,55,80,0.16);
  text-align: center;
}
.unlock-emoji { font-size: 42px; }
.unlock-card h2 { margin: 12px 0 8px; font-size: 19px; }
.unlock-card p { margin: 0 0 22px; font-size: 13.5px; color: var(--ink-2); line-height: 1.65; }

/* 载入中 */
.loading {
  display: grid;
  place-items: center;
  padding: 80px 0;
  color: var(--ink-3);
  font-size: 14px;
}
.spinner {
  width: 26px;
  height: 26px;
  margin-bottom: 12px;
  border: 2.5px solid rgba(47,127,209,0.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty {
  padding: 70px 24px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.8;
}
