/* ================================================================
   六级词汇 —— 蓝紫主题
   设计约束：每张卡片最多两个颜色；圆角与阴影全站统一；任何元素不得重叠。
   ================================================================ */

:root {
  --pink:        #8b7cf8;   /* 主色：蓝紫（深底上提亮一档，否则发闷） */
  --pink-light:  #a99cff;
  --violet:      #8b7cf8;
  --blue:        #5b9cf8;
  --ink:         #e9e9f5;   /* 主文字：浅色 */
  --muted:       #8f8fb0;
  --card:        #1e1e36;   /* 卡片表面 */
  --track:       #2a2a45;

  --r-card: 16px;
  --r-btn:  16px;
  --r-chip: 11px;

  --sh-card: 0 2px 10px rgba(0,0,0,.38);
  --sh-btn:  0 6px 18px rgba(109,94,240,.45);

  --grad-btn:  linear-gradient(135deg,#8b7cf8,#6d5ef0 55%,#4f8ff7);
  --grad-fill: linear-gradient(90deg,#a99cff,#7c6cf5 55%,#5b9cf8);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0d0d1a;
}

body {
  /* 防止横向溢出把文档撑宽后，margin:auto 把 #app 居中到视口之外。
     注意：排查布局时别用无头浏览器的小窗口截图 ——
     它存在最小窗口宽度，请求 390 会按更宽的视口排版却只截 390，
     看起来像内容右移+右侧被切，其实是测试工具的假象。 */
  overflow-x: hidden;
  font-family: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  background: linear-gradient(172deg,#17172e 0%,#141428 40%,#111126 100%);
  overflow: hidden;
  /* 左右内边距写死。原本整条 shorthand 用了 calc(18px + var(--safe-top))，
     其中 var(--safe-top) 的值是 env(safe-area-inset-top, 0px)；
     一旦浏览器不认 env()，整条 padding 就失效，实测表现为左右边距不等。
     安全区只加在上下，用两条独立声明，坏了也不影响左右。 */
  padding: 18px 16px 20px;
  padding-top: calc(18px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* 两处柔光晕 —— 铺在内容底下，不遮挡任何元素 */
#app::before,
#app::after {
  content: '';
  position: absolute;
  width: 240px; height: 240px;
  pointer-events: none;
  z-index: 0;
}
#app::before {
  right: -80px; top: -90px;
  background: radial-gradient(circle, rgba(139,124,248,.26), transparent 70%);
}
#app::after {
  left: -92px; bottom: -76px;
  background: radial-gradient(circle, rgba(79,143,247,.20), transparent 70%);
}

.view { position: relative; z-index: 1; min-width: 0; }

/* ---------------- 学伴图放大背景 ---------------- */

/* 铺在 #app 底部。放下面而不是顶部的理由：
   首页内容是「标题 → 学伴条 → 数据格 → 按钮」一路往下排的，
   顶部没有留白给背景；底部那一片本来就是空的，
   图放这儿既有存在感，又不跟任何内容抢位置。
   从上方淡入，看起来像从页面里长出来的。 */
.hero {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  /* 高度可调：改这一个数就能让图整体往上长或往下缩 */
  height: var(--hero-h, 430px);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center 42%;   /* 人物多半在中上部，别把脑袋裁掉 */
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease;
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 52%, transparent 100%);
  mask-image: linear-gradient(to top, #000 0%, #000 52%, transparent 100%);
}
#app.has-hero .hero { opacity: 1; }

/* ---------------- 顶栏 ---------------- */

/* 标题栏只放标题。
   原本右上角还挂着一个设置齿轮，但它在这套结构里总被算到内容区之外，
   被 #app 的 overflow:hidden 从右边切掉 —— flex + space-between、
   grid 1fr auto、absolute + right:0 三种写法都试过，全一样。
   设置入口改放底部的按钮行，那里布局是验证过的，三个入口也更好找。 */
.app-header {
  display: flex;
  align-items: center;
  min-height: 34px;
}

.app-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--ink);
}

.icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none; background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 10px;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.07); }
.icon-btn:active { transform: scale(.94); }

.badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 8px;
  background: var(--pink); color: #fff;
  font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center;
}

/* 必须显式写 —— .badge 的 display:grid 会盖掉浏览器默认的 [hidden]{display:none}，
   不写这条的话隐藏不掉，会一直显示一个「0」 */
.badge[hidden] { display: none; }

/* ---------------- 学伴条 ---------------- */

.mate {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
}

.mate-avatar {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--sh-card);
  display: grid; place-items: center;
}
.mate-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 同 .badge 那条：.mate-avatar 的 display:grid 会盖掉浏览器默认的
   [hidden]{display:none}，不显式写一句就藏不掉 */
.mate-avatar[hidden] { display: none; }


.mate-say {
  flex: 1;
  min-width: 0;
  background: var(--card);
  color: #9a9ac0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  padding: 9px 12px;
  border-radius: 13px;
  box-shadow: var(--sh-card);
}

/* ---------------- 数据格 ---------------- */

.stat-grid {
  display: grid;
  /* 必须写 minmax(0, 1fr) 而不是 1fr。
     1fr 等价于 minmax(auto, 1fr)，其中 auto 的最小值取内容的 min-content 宽度 ——
     子项撑不下去时整条轨道会顶宽，把网格撑出容器，右侧内容被切掉。
     minmax(0, 1fr) 去掉这个下限，轨道才能正常收缩。 */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 14px 0;
}

.stat-cell {
  min-width: 0;
  background: var(--card);
  border-radius: var(--r-card);
  padding: 12px 13px;
  box-shadow: var(--sh-card);
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .6px;
  color: var(--muted);
}

.stat-value {
  font-size: 25px;
  font-weight: 800;
  line-height: 1.12;
  margin-top: 3px;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.stat-value.accent { color: var(--pink); }
.stat-value.blue   { color: var(--blue); }
.stat-value .unit  { font-size: 11px; font-weight: 700; }

/* ---------------- 进度条 ---------------- */

.prog-label {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--muted);
  margin-bottom: 6px;
}

.prog-track {
  height: 7px;
  border-radius: 4px;
  background: var(--track);
  overflow: hidden;
}

.prog-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--grad-fill);
  transition: width .35s ease;
}

/* ---------------- 按钮 ---------------- */

.btn-primary {
  width: 100%;
  border: none;
  border-radius: var(--r-btn);
  padding: 14px;
  margin: 16px 0 9px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #fff;
  background: var(--grad-btn);
  box-shadow: var(--sh-btn);
  cursor: pointer;
  transition: transform .12s, opacity .15s;
}
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled {
  background: #2a2a45;
  color: #5a5a78;
  box-shadow: none;
  cursor: default;
  transform: none;
}

.chips { display: flex; gap: 7px; }

.chip {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: var(--r-chip);
  padding: 10px 2px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: #9a9ac0;
  background: var(--card);
  box-shadow: var(--sh-card);
  cursor: pointer;
  transition: transform .12s;
}
.chip:active { transform: scale(.97); }
.chip.hot { color: var(--pink); }

/* ---------------- 提示条 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: 84vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: #3a3a60;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  z-index: 99;
  animation: toast-in .22s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ================================================================
   子页面（学习 / 挖空 / 错题本 / 设置）
   ================================================================ */

.sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 12px;
}

.sub-progress { font-size: 12px; font-weight: 700; color: var(--muted); }
.sub-score    { font-size: 12px; font-weight: 700; color: var(--pink); min-width: 62px; text-align: right; }

.loading, .empty-state {
  text-align: center;
  padding: 56px 16px;
  color: var(--muted);
  font-size: 13px;
}
.empty-state p { margin-bottom: 6px; font-size: 14px; color: var(--ink); }
.empty-state .sub { font-size: 12px; color: var(--muted); }
.done-emoji { font-size: 42px; margin-bottom: 10px; }

.btn-ghost {
  margin-top: 16px;
  border: none;
  border-radius: var(--r-chip);
  padding: 10px 22px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #9a9ac0;
  background: var(--card);
  box-shadow: var(--sh-card);
  cursor: pointer;
}

/* ---------------- 题干 ---------------- */

.q-card {
  background: var(--card);
  border-radius: var(--r-card);
  padding: 20px 16px;
  box-shadow: var(--sh-card);
  text-align: center;
  margin-bottom: 12px;
}

.q-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 10px;
}

.q-stem {
  font-weight: 800;
  color: var(--ink);
  line-height: 1.28;
  word-break: break-word;
}
.q-stem.en { font-size: 30px; letter-spacing: -.4px; }
.q-stem.cn { font-size: 19px; }

.q-phon {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.speak {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: .75;
}
.speak:active { transform: scale(.9); }

/* ---------------- 选项 ---------------- */

.opts { display: flex; flex-direction: column; gap: 8px; }

.opt {
  width: 100%;
  text-align: left;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 13px 15px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  background: var(--card);
  box-shadow: var(--sh-card);
  cursor: pointer;
  transition: transform .12s, border-color .15s, background .15s;
}
.opt:active { transform: scale(.985); }
.opt:disabled { cursor: default; }
.opt.right {
  border-color: #3aa876;
  background: rgba(58,168,118,.15);
  color: #6ee7a8;
  font-weight: 700;
}
.opt.wrong {
  border-color: #e05a72;
  background: rgba(224,90,114,.15);
  color: #ff8fa3;
}

/* ---------------- 翻面 ---------------- */

.fb {
  background: var(--card);
  border-radius: var(--r-card);
  padding: 16px;
  box-shadow: var(--sh-card);
  margin-top: 12px;
  animation: fb-in .24s ease;
}
@keyframes fb-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fb-head { font-size: 13px; font-weight: 800; margin-bottom: 12px; }
.fb.ok .fb-head { color: #5fd39a; }
.fb.no .fb-head { color: #ff7d94; }

.fb-word {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.fb-en   { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.fb-phon { font-size: 12.5px; color: var(--muted); }

.fb-def {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 4px;
}
.fb-def .pos { color: var(--pink); font-weight: 700; margin-right: 5px; font-style: italic; }

.fb-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #32324f;
}
.fb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 5px;
}
.fb-text { font-size: 13px; line-height: 1.55; color: #b6b6d2; }
.fb-text.en { color: var(--ink); }
.fb-text.zh { color: #8f8fb0; margin-top: 3px; }

.fb-meta {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  font-size: 10.5px;
  color: var(--muted);
}

.fb .btn-primary { margin-top: 14px; }

/* ---------------- 设置 ---------------- */

.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: #262642;   /* 比卡片亮一档，不然同色里看不出是输入框 */
  border: 1.5px solid #37375a;
  border-radius: 12px;
  padding: 12px 13px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
}
.field input:focus { outline: none; border-color: var(--pink-light); }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.field .hint.warn { color: #ff7d94; font-weight: 700; }

.card-panel {
  background: var(--card);
  border-radius: var(--r-card);
  padding: 16px;
  box-shadow: var(--sh-card);
  margin-bottom: 14px;
}
.card-panel h3 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
}

.row-btns { display: flex; gap: 8px; }
.row-btns .chip { padding: 12px 2px; font-size: 12px; }

/* ---------------- 例句挖空 ---------------- */

.cloze-sentence {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.75;
  color: var(--ink);
  text-align: left;
}
.cloze-blank {
  display: inline-block;
  height: 1.05em;
  margin: 0 3px;
  vertical-align: -0.16em;
  border-bottom: 2.5px solid var(--pink-light);
  border-radius: 1px;
}

.cloze-hint {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed #32324f;
  font-size: 12.5px;
  line-height: 1.6;
  color: #8f8fb0;
  text-align: left;
}

/* ---------------- 错题本列表 ---------------- */

.wrong-list { margin-top: 14px; }

.wrong-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--sh-card);
  margin-bottom: 8px;
}

.wrong-main { min-width: 0; }
.wrong-en {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.2px;
}
.wrong-def {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wrong-side {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.wrong-count {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--pink);
  background: #2a2a48;
  border-radius: 8px;
  padding: 3px 8px;
}

/* ---------------- 考前冲刺 ---------------- */

.sprint-lead {
  font-size: 12px;
  line-height: 1.65;
  color: var(--muted);
  margin-bottom: 14px;
}
.sprint-lead b { color: var(--pink); font-weight: 700; }

.sprint-unit {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--sh-card);
  padding: 12px;
  margin-bottom: 10px;
}

.sprint-unit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sprint-unit-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
}

.sprint-all {
  flex-shrink: 0;
  border: none;
  border-radius: 9px;
  padding: 6px 11px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: var(--grad-btn);
  box-shadow: 0 2px 8px rgba(255,110,170,.3);
  cursor: pointer;
}
.sprint-all:active { transform: scale(.96); }

.sprint-lesson {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  border-radius: 11px;
  padding: 10px 12px;
  margin-bottom: 5px;
  font-family: inherit;
  background: #262642;
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.sprint-lesson:last-child { margin-bottom: 0; }
.sprint-lesson:active { transform: scale(.985); background: #30305a; }

.sprint-lesson-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}
.sprint-lesson-meta {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}

/* 尊重系统的减少动效设置 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ================================================================
   深色主题的补充规则
   ----------------------------------------------------------------
   浅色主题靠阴影（--sh-card）把卡片从背景里托起来，
   但深色底上黑影几乎看不见 —— 卡片会和背景糊成一片。
   所以凡是有白色/浅色卡面的元素，都加一道细边框来分隔。
   ================================================================ */

.stat-cell,
.chip,
.q-card,
.fb,
.mate-say,
.sprint-unit,
.sprint-lesson,
.wrong-row,
.card-panel,
.btn-ghost {
  border: 1px solid #2e2e4d;
}

/* 选项按钮同理，默认态也要看得见边界 */
.opt {
  border-color: #2e2e4d;
}
