/* ============ 英语打卡 全局样式（iPhone 移动优先） ============ */
:root {
  --bg: #0f1222;
  --bg-soft: #171b31;
  --card: #1d2238;
  --card-2: #262c48;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef1ff;
  --muted: #9aa3c0;
  --primary: #4F6EF7;
  --primary-2: #9B6BFF;
  --green: #2ec27e;
  --red: #f25c5c;
  --gold: #ffb020;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f4fb;
    --bg-soft: #e9edf9;
    --card: #ffffff;
    --card-2: #f0f3fd;
    --border: rgba(20, 30, 80, 0.10);
    --text: #202642;
    --muted: #6b7292;
  }
}

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

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: var(--safe-t);
}

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
}
.brand { font-size: 19px; font-weight: 800; letter-spacing: 0.5px; }
.streak-badge {
  background: linear-gradient(135deg, #ff8a3c, #ffb020);
  color: #4a2400;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255, 140, 60, 0.35);
}

/* ---------- 视图容器 ---------- */
#views { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 16px 20px; }
.view { display: none; animation: fadeIn 0.22s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 底部导航 ---------- */
#tabbar {
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 0 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.tab .emoji { font-size: 20px; }
.tab.active { color: var(--primary); }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  cursor: pointer;
  width: 100%;
  box-shadow: 0 6px 18px rgba(79, 110, 247, 0.35);
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; box-shadow: none; }
.btn.ghost { background: var(--card-2); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn.green { background: linear-gradient(135deg, #22b573, #2ec27e); box-shadow: 0 6px 18px rgba(46, 194, 126, 0.3); }
.btn.red { background: linear-gradient(135deg, #e5484d, #f25c5c); box-shadow: 0 6px 18px rgba(242, 92, 92, 0.3); }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 11px; }

.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* ---------- 首页 ---------- */
.hero {
  text-align: center;
  padding: 22px 10px 8px;
}
.hero h1 { font-size: 22px; font-weight: 800; }
.hero p { color: var(--muted); font-size: 13px; margin-top: 6px; }

.progress-ring-wrap { position: relative; width: 132px; height: 132px; margin: 16px auto 4px; }
.progress-ring-wrap svg { transform: rotate(-90deg); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-center .pct { font-size: 26px; font-weight: 800; }
.ring-center .lbl { font-size: 11px; color: var(--muted); }

.task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.task:last-child { border-bottom: none; }
.task .t-icon { font-size: 26px; }
.task .t-info { flex: 1; }
.task .t-name { font-size: 15px; font-weight: 700; }
.task .t-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task .t-state { font-size: 12px; font-weight: 700; }
.task .t-state.done { color: var(--green); }
.task .t-state.todo { color: var(--gold); }

.checkin-banner {
  text-align: center;
  padding: 22px 16px;
  background: linear-gradient(135deg, rgba(46,194,126,0.16), rgba(79,110,247,0.16));
  border: 1px solid rgba(46,194,126,0.35);
  border-radius: var(--radius);
  margin-bottom: 14px;
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
.checkin-banner .big { font-size: 40px; }
.checkin-banner .t1 { font-size: 18px; font-weight: 800; margin-top: 6px; }
.checkin-banner .t2 { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- 学习（翻卡） ---------- */
.study-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.study-top .mode-tag { font-size: 13px; font-weight: 700; color: var(--primary); }
.progress-track { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width 0.25s ease; }

.flip-wrap { perspective: 1200px; margin: 20px 0; }
.flip-card {
  position: relative;
  width: 100%;
  height: 300px;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0.2, 0.2, 1);
  cursor: pointer;
}
.flip-card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
}
.face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--card), var(--card-2)); }
.face .word { font-size: 40px; font-weight: 800; letter-spacing: 0.5px; }
.face .phon { color: var(--muted); font-size: 16px; margin-top: 8px; }
.face .speak-btn { margin-top: 14px; font-size: 26px; background: var(--card-2); border: 1px solid var(--border); border-radius: 50%; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.face .mean { font-size: 20px; font-weight: 700; }
.face .example { margin-top: 14px; font-size: 15px; color: var(--text); line-height: 1.5; }
.face .example-cn { margin-top: 4px; font-size: 13px; color: var(--muted); }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 14px; }

/* ---------- 每日一句 ---------- */
.sentence-en { font-size: 22px; font-weight: 800; line-height: 1.55; }
.sentence-cn { margin-top: 12px; font-size: 15px; color: var(--muted); line-height: 1.6; }
.sentence-cn.hidden { display: none; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-box .v { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-box .k { font-size: 12px; color: var(--muted); margin-top: 4px; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell { aspect-ratio: 1; border-radius: 9px; background: var(--card-2); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.cal-cell.checked { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 700; }
.cal-cell.today { outline: 2px solid var(--gold); outline-offset: -2px; }
.cal-cell.blank { background: transparent; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.bar { width: 100%; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--primary), var(--primary-2)); min-height: 3px; }
.bar-col .day { font-size: 10px; color: var(--muted); }
.bar-col .n { font-size: 10px; font-weight: 700; }

/* ---------- 设置 ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-row .lbl { font-size: 14px; font-weight: 600; }
.set-row .val { font-size: 13px; color: var(--muted); }
input[type="range"] { width: 130px; accent-color: var(--primary); }
.toggle { position: relative; width: 48px; height: 28px; border-radius: 99px; background: var(--card-2); border: 1px solid var(--border); cursor: pointer; transition: background 0.2s; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left 0.2s; }
.toggle.on { background: var(--primary); }
.toggle.on::after { left: 22px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-2);
  color: var(--text);
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }

.custom-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.custom-item:last-child { border-bottom: none; }
.custom-item .ci-word { font-weight: 800; font-size: 15px; }
.custom-item .ci-mean { font-size: 12px; color: var(--muted); flex: 1; }
.custom-item .del { border: none; background: none; font-size: 17px; cursor: pointer; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(90px + var(--safe-b));
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 24, 48, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 99;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; line-height: 1.7; }
