:root {
  --bg-top: #f4fbf9;
  --bg-bottom: #eaf4fb;
  --card: #ffffff;
  --ink: #27403a;
  --ink-soft: #5f7a73;
  --mint: #4da98f;
  --mint-deep: #2f8a70;
  --mint-soft: #e2f4ee;
  --sky: #79b6d6;
  --sky-soft: #e9f4fb;
  --peach: #f6a8a0;
  --peach-soft: #fdeeee;
  --sun: #f2c069;
  --line: #e4f0ec;
  --shadow: 0 14px 34px rgba(64, 139, 117, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-top) 0%, var(--bg-bottom) 100%) fixed;
  line-height: 1.6;
}

/* ---------- 背景装饰 ---------- */
.bg-decor {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(4px);
  opacity: 0.5;
}

.b1 {
  width: 280px;
  height: 280px;
  top: -70px;
  right: -70px;
  background: radial-gradient(circle, #cdeee3, transparent 70%);
}

.b2 {
  width: 220px;
  height: 220px;
  bottom: -50px;
  left: -60px;
  background: radial-gradient(circle, #d9ebf7, transparent 70%);
}

.b3 {
  width: 120px;
  height: 120px;
  top: 42%;
  left: 8%;
  background: radial-gradient(circle, #fbf0d4, transparent 70%);
}

/* ---------- 布局 ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 26px 18px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  font-size: 26px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 1px;
}

.brand p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.save-state {
  font-size: 12px;
  color: var(--mint-deep);
  background: var(--mint-soft);
  border: 1px solid #cde9df;
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

.save-state.saving {
  color: #946b2b;
  background: #fdf3dc;
  border-color: #f2ddb0;
}

.save-state.error {
  color: #b0524b;
  background: var(--peach-soft);
  border-color: #f5cdc9;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.view {
  display: none;
  animation: rise 0.35s ease both;
}

.view.active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.start-card {
  padding: 34px;
}

.start-title h2 {
  margin: 0 0 6px;
  font-size: 25px;
}

.start-title p {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 14px;
}

.intro-card {
  margin-top: 18px;
  padding: 24px 30px;
  background: rgba(255, 255, 255, 0.78);
}

.intro-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--mint-deep);
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

.step-dot {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--mint-soft);
  color: var(--mint-deep);
  font-size: 13px;
  font-weight: 600;
}

.tiny {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- 表单 ---------- */
.field {
  margin-bottom: 22px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

select,
input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font: inherit;
  color: var(--ink);
  background: #fbfefd;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus,
input[type="number"]:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(77, 169, 143, 0.12);
}

.count-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-row input {
  flex: 1;
}

.count-row span {
  color: var(--ink-soft);
  font-size: 14px;
}

input[type="range"] {
  width: 100%;
  margin-top: 12px;
  accent-color: var(--mint);
  height: 6px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- 按钮 ---------- */
.btn-primary {
  width: 100%;
  border: none;
  cursor: pointer;
  padding: 14px 22px;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--mint), #6bc0a4);
  box-shadow: 0 10px 22px rgba(77, 169, 143, 0.3);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 13px 26px rgba(77, 169, 143, 0.36);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-soft,
.ghost-btn {
  border: 1.5px solid #cfe9e1;
  background: var(--mint-soft);
  color: var(--mint-deep);
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  padding: 9px 18px;
  transition: background 0.2s, transform 0.15s;
}

.btn-soft:hover,
.ghost-btn:hover {
  background: #d2efe6;
  transform: translateY(-1px);
}

.ghost-btn {
  border-color: #dcebe6;
  background: #ffffff;
  color: var(--ink-soft);
}

.btn-next {
  min-width: 150px;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ---------- 学习界面 ---------- */
.learn-card {
  padding: 26px 30px 32px;
}

.learn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.stage-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.stage-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: #f0f7f4;
  color: #8aa69d;
  transition: all 0.25s;
}

.stage-chip.active {
  background: var(--mint-soft);
  color: var(--mint-deep);
  font-weight: 600;
}

.stage-arrow {
  color: #c6dcd5;
}

.progress-area {
  margin-bottom: 20px;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: #e9f3ef;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #8fd4bc, var(--mint), var(--sky));
  transition: width 0.35s ease;
}

/* 学习内容 */
.content-wrap {
  text-align: center;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stage-label {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--mint-deep);
  background: var(--mint-soft);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  margin: 0 auto 14px;
}

.big-word {
  font-size: clamp(34px, 7vw, 52px);
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink);
  margin: 6px 0 2px;
  word-break: break-word;
}

.word-sense {
  font-size: clamp(18px, 4vw, 23px);
  color: var(--mint-deep);
  margin: 8px 0 0;
}

.sense-quiz {
  font-size: clamp(22px, 5vw, 30px);
  color: var(--ink);
  margin: 10px auto 20px;
  max-width: 90%;
}

.answer-box {
  max-width: 420px;
  margin: 0 auto;
}

.answer-box input {
  width: 100%;
  text-align: center;
  padding: 13px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  font: inherit;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--ink);
  background: #fbfefd;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.answer-box input:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(77, 169, 143, 0.12);
}

.feedback {
  margin: 18px auto 0;
  padding: 14px 20px;
  border-radius: 16px;
  max-width: 460px;
  font-size: 15px;
  animation: rise 0.25s ease both;
}

.feedback.correct {
  background: var(--mint-soft);
  color: var(--mint-deep);
  border: 1px solid #cdebe0;
}

.feedback.wrong {
  background: var(--peach-soft);
  color: #a75b55;
  border: 1px solid #f4d2ce;
}

.feedback strong {
  font-size: 17px;
}

.sub-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #a08d8a;
}

/* ---------- 完成页 ---------- */
.done-card {
  text-align: center;
  padding: 38px 30px;
}

.done-emoji {
  font-size: 56px;
}

.done-card h2 {
  margin: 8px 0 4px;
  font-size: 26px;
}

.done-sub {
  color: var(--ink-soft);
  margin: 0 0 24px;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.stat-box {
  background: #f5fbf9;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 10px;
}

.stat-box .num {
  font-size: 26px;
  font-weight: 700;
  color: var(--mint-deep);
}

.stat-box .label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.saved-note {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 20px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 80px);
  background: rgba(39, 64, 58, 0.92);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 小屏 ---------- */
@media (max-width: 560px) {
  .card {
    padding: 22px 18px;
  }

  .start-card {
    padding: 26px 20px;
  }

  .learn-card {
    padding: 20px 16px 26px;
  }

  .learn-head {
    align-items: flex-start;
  }

  .stage-dots {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
