/* ===========================================================
   VocaWhale · 样式
   配色取自鲸鱼娘角色设计稿色板
   =========================================================== */

:root {
  --bg:            #0F1A2E;
  --bg-deep:       #0A1220;
  --card:          #1B2A45;
  --card-hi:       #22334F;
  --accent:        #7FA8D9;
  --accent-dim:    #4A6FA5;
  --text:          #F0F4FA;
  --text-dim:      #8FA3BF;
  --line:          #2A3D5C;

  --ok:            #5FBF9F;
  --warn:          #D9B36A;
  --bad:           #D9737A;
  --easy:          #6FA8DC;

  --radius:        20px;
  --radius-sm:     14px;
  --shadow:        0 10px 30px rgba(0, 0, 0, .35);

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

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

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

body {
  background: radial-gradient(120% 80% at 50% 0%, #16243D 0%, var(--bg) 45%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
               "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
  user-select: none;
}

#app {
  position: relative;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
}

/* ---------------- 屏幕切换 ---------------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(var(--safe-top) + 8px) 20px calc(76px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* 学习页与结算页不显示底部导航 */
body.study-mode .tabbar { display: none; }
body.study-mode .screen { padding-bottom: calc(var(--safe-bottom) + 12px); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0 14px;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-mark { font-size: 20px; }
.brand-name { letter-spacing: .3px; }

.chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip-fire { font-size: 13px; }

.page-title { margin: 0; font-size: 22px; font-weight: 700; }

/* ---------------- 首页 ---------------- */
.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

.ring-wrap { position: relative; width: 168px; height: 168px; flex-shrink: 0; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .6s cubic-bezier(.22, 1, .36, 1);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-num { font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.mascot-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2px;
  min-height: 0;
}
.mascot {
  width: 190px;
  height: auto;
  display: block;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .45));
  animation: float 3.4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-9px); }
}
.mascot.happy  { animation: bounce .55s cubic-bezier(.28, 1.6, .5, 1) 2; }
.mascot.annoyed{ animation: shake .45s ease-in-out 2; }
.mascot.impatient { animation: tremor .18s linear infinite; }

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40%      { transform: translateY(-22px) scale(1.05); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25%      { transform: translateX(-9px) rotate(-3deg); }
  75%      { transform: translateX(9px) rotate(3deg); }
}
@keyframes tremor {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(-1.5px, 1px); }
  75%      { transform: translate(1.5px, -1px); }
}

/* 对话气泡 */
.bubble {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  max-width: 320px;
  text-align: center;
  margin-top: 12px;
  box-shadow: var(--shadow);
  min-height: 20px;
}
.bubble::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: var(--card);
  border-top: 0;
}
.bubble.pop { animation: bubblePop .32s cubic-bezier(.28, 1.5, .5, 1); }
@keyframes bubblePop {
  0%   { transform: scale(.9); opacity: .4; }
  100% { transform: scale(1);  opacity: 1; }
}

.home-actions { width: 100%; margin-top: auto; padding-top: 16px; }
.home-meta {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ---------------- 按钮 ---------------- */
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 13px 20px;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
  color: var(--text);
}
.btn:active { transform: scale(.975); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #0B1424;
  box-shadow: 0 8px 22px rgba(74, 111, 165, .38);
}
.btn-lg { width: 100%; padding: 16px; font-size: 17px; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--bad);
  color: var(--bad);
  width: 100%;
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 20px;
  padding: 4px 8px;
  cursor: pointer;
  line-height: 1;
}

/* ---------------- 学习页 ---------------- */
.topbar-study { gap: 14px; }
.progress-bar {
  flex: 1;
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-inner {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}
.study-count {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: right;
}

.study-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 卡片翻转 */
.card {
  flex: 1;
  min-height: 240px;
  perspective: 1200px;
  cursor: pointer;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .5s cubic-bezier(.22, 1, .36, 1);
  transform-style: preserve-3d;
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 22px;
  overflow-y: auto;
}
.card-back { transform: rotateY(180deg); justify-content: flex-start; }

.word {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: .5px;
  text-align: center;
  word-break: break-word;
}
.word-sm {
  font-size: 21px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 4px;
}
.phonetic {
  color: var(--text-dim);
  font-size: 15px;
  margin-top: 8px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
}
.hint { position: absolute; bottom: 16px; font-size: 12px; color: var(--text-dim); opacity: .7; }

.speak-btn {
  background: rgba(127, 168, 217, .14);
  border: 0;
  color: var(--accent);
  font-size: 18px;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  margin-top: 18px;
  cursor: pointer;
}
.speak-btn:active { transform: scale(.92); }
.speak-sm { width: 38px; height: 38px; font-size: 15px; margin-top: 12px; }

.defs { width: 100%; margin-top: 10px; }
.def-item {
  display: flex;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42, 61, 92, .55);
  font-size: 15px;
  line-height: 1.55;
}
.def-item:last-child { border-bottom: 0; }
.def-pos {
  flex-shrink: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 12.5px;
  padding-top: 2px;
  min-width: 40px;
  font-style: italic;
}
.def-text { color: var(--text); }

.tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(127, 168, 217, .13);
  color: var(--accent);
  border: 1px solid rgba(127, 168, 217, .25);
}
.tag.oxford { background: rgba(217, 179, 106, .13); color: var(--warn); border-color: rgba(217, 179, 106, .28); }

/* 学习页吉祥物条 */
.mascot-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
  flex-shrink: 0;
}
.mascot-sm { width: 58px; height: auto; flex-shrink: 0; animation: float 3.4s ease-in-out infinite; }
.bubble-sm {
  margin: 0;
  text-align: left;
  font-size: 13.5px;
  padding: 9px 13px;
  max-width: none;
  flex: 1;
}
.bubble-sm::before {
  top: 50%;
  left: -7px;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-right-color: var(--card);
  border-left: 0;
}

/* 评分按钮 */
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; flex-shrink: 0; }
.grade {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s ease, opacity .2s ease;
}
.grade:active { transform: scale(.95); }
.grade span { font-size: 14px; font-weight: 700; }
.grade small { font-size: 10.5px; color: var(--text-dim); }
.grade.g0 { border-color: rgba(217, 115, 122, .5); }
.grade.g0 span { color: var(--bad); }
.grade.g1 { border-color: rgba(217, 179, 106, .5); }
.grade.g1 span { color: var(--warn); }
.grade.g2 { border-color: rgba(95, 191, 159, .5); }
.grade.g2 span { color: var(--ok); }
.grade.g3 { border-color: rgba(111, 168, 220, .5); }
.grade.g3 span { color: var(--easy); }

.grades.hidden { opacity: 0; pointer-events: none; }

/* ---------------- 结算页 ---------------- */
.done-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
.bubble-done { max-width: 340px; margin-top: 4px; }
.done-stats {
  display: flex;
  gap: 22px;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}
.done-stats b { display: block; color: var(--text); font-size: 22px; font-weight: 700; }

/* ---------------- 统计页 ---------------- */
.page-body { flex: 1; }
.section-title {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 600;
  margin: 24px 0 10px;
}

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px;
}
.stat-card .k { font-size: 12px; color: var(--text-dim); }
.stat-card .v { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 110px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  transition: height .4s ease;
}
.chart-lbl { font-size: 9px; color: var(--text-dim); }

.lib-progress { display: flex; flex-direction: column; gap: 13px; }
.lib-row .lib-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.lib-row .lib-head .n { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.lib-track { height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; }
.lib-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s ease; }

/* ---------------- 设置页 ---------------- */
.setting {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px;
  margin-bottom: 11px;
}
.setting > label { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 11px; }
.setting-ctl { display: flex; align-items: center; gap: 14px; }
.setting-toggle { display: flex; align-items: center; justify-content: space-between; }
.setting-toggle > label { margin: 0; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
output { font-size: 14px; font-weight: 700; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: flex; gap: 6px; }
.seg-wrap { flex-wrap: wrap; }
.seg button {
  flex: 1;
  min-width: 68px;
  padding: 9px 6px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: all .15s ease;
}
.seg button.active {
  background: rgba(127, 168, 217, .16);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  width: 50px;
  height: 29px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background .2s ease;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform .2s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(21px); }

.time-input {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 15px;
}
.danger-zone { background: transparent; border-style: dashed; }
.version-note { text-align: center; color: var(--text-dim); font-size: 12px; margin: 18px 0 0; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(15, 26, 46, .93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 7px 0 calc(7px + var(--safe-bottom));
  z-index: 20;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 10.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0;
  cursor: pointer;
}
.tab span { font-size: 19px; }
.tab.active { color: var(--accent); font-weight: 600; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%) translateY(14px);
  background: var(--card-hi);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 深色滚动条 ---------------- */
::-webkit-scrollbar { width: 0; height: 0; }
