/* 六级备考站 — Apple Liquid Glass 设计语言
   规范来源: apple-design-skill (naplesblue, MIT)
   原则: 统一白色面板 > 碎卡片 · 玻璃只在导航/悬浮层 · 全局灰阶 + 单一蓝色强调 */
:root {
  /* 中性骨架 */
  --bg: #f5f5f7;
  --card: #ffffff;
  --hover: #fbfbfd;
  --text: #1d1d1f;
  --text-body: #424245;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --text-4: #aeaeb2;
  --faint: #d2d2d7;
  --line: rgba(0, 0, 0, 0.07);
  --hairline: rgba(0, 0, 0, 0.07);
  /* 强调色（仅用于动作/激活/关键数字） */
  --accent: #0071e3;
  --accent-deep: #0066cc;
  --accent-weak: rgba(0, 113, 227, 0.09);
  --danger: #ff3b30;
  --danger-weak: rgba(255, 59, 48, 0.1);
  --warn: #ff9500;
  --live: #30d158;
  --live-weak: rgba(48, 209, 88, 0.14);
  --track: #e8e8ed;
  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  /* 圆角分层 */
  --r-pill: 999px;
  --r-thumb: 12px;
  --r-card: 18px;
  --r-hero: 26px;
  /* 阴影（双层） */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --sh-panel: 0 1px 3px rgba(0, 0, 0, 0.05), 0 14px 40px rgba(0, 0, 0, 0.05);
  --sh-cta: 0 20px 54px rgba(0, 113, 227, 0.24);
  --radius: var(--r-card);
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}
.loading { text-align: center; color: var(--text-3); padding: 60px 0; }

/* ---------- 顶栏 ---------- */
.page-head { margin: 6px 0 18px; }
.page-head h1 { font-size: clamp(24px, 5vw, 30px); font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }

/* ---------- 面板（统一白色表面） ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 14px; }
.card .hint { color: var(--text-2); font-size: 13px; }

/* ---------- 倒计时（英雄卡：唯一彩色渐变） ---------- */
.countdown {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #0071e3 0%, #5e5ce6 100%);
  color: #fff; border-radius: var(--r-hero);
  box-shadow: var(--sh-cta);
}
.countdown .days { font-size: 46px; font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.countdown .days small { font-size: 15px; font-weight: 500; margin-left: 4px; }
.countdown .label { font-size: 14px; opacity: .92; }
.countdown .date-chip {
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--r-thumb); padding: 6px 10px; font-size: 13px; text-align: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.countdown .date-chip input {
  margin-top: 4px; border: none; border-radius: 6px; padding: 3px 6px;
  font-size: 12px; color: var(--text); background: #fff;
}

/* ---------- 进度条 ---------- */
.bar { height: 8px; background: var(--track); border-radius: var(--r-pill); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .4s; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .bar { flex: 1; }

/* ---------- 统计格子 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-box { background: var(--bg); border-radius: var(--r-thumb); padding: 12px 8px; text-align: center; }
.stat-box .num { font-size: 22px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-box .lbl { font-size: 12px; color: var(--text-2); }

/* ---------- 打卡日历 ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .wd { text-align: center; font-size: 11px; color: var(--text-3); padding: 2px 0; }
.cal .day {
  aspect-ratio: 1; border-radius: 9px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-2); position: relative; font-variant-numeric: tabular-nums;
}
.cal .day.active { background: var(--accent); color: #fff; font-weight: 600; }
.cal .day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal .day.empty { background: transparent; }

/* ---------- 按钮（胶囊形） ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  border-radius: var(--r-pill); padding: 11px 22px; font-size: 15px; font-weight: 600;
  transition: transform .15s var(--ease-out), opacity .2s, box-shadow .2s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: var(--accent-weak); color: var(--accent-deep); }
.btn.danger { background: var(--danger-weak); color: var(--danger); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.btn.sm { padding: 7px 15px; font-size: 13px; border-radius: var(--r-pill); }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* ---------- 背词卡片 ---------- */
.word-card { text-align: center; padding: 34px 18px; }
.word-card .word { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; }
.word-card .phon { color: var(--accent-deep); font-size: 15px; margin: 6px 0 2px; }
.word-card .pos { color: var(--text-3); font-size: 14px; }
.word-card .meaning { font-size: 20px; font-weight: 600; margin: 14px 0 8px; letter-spacing: -0.01em; }
.word-card .example {
  margin-top: 10px; padding: 12px; background: var(--bg); border-radius: var(--r-thumb);
  font-size: 14px; color: var(--text-body); text-align: left;
}
.word-card .example .ex-label { font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.star-btn {
  position: absolute; top: 14px; right: 14px; border: none; background: none;
  font-size: 22px; cursor: pointer; opacity: .3; transition: opacity .2s;
}
.star-btn.on { opacity: 1; }
.word-card { position: relative; }
.speak-btn {
  border: none; background: var(--accent-weak); color: var(--accent-deep);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 4px 0; transition: transform .15s var(--ease-out);
}
.speak-btn:active { transform: scale(.9); }

/* ---------- 题目 ---------- */
.passage {
  background: var(--bg); border-radius: var(--r-thumb); padding: 14px;
  font-size: 15px; line-height: 1.9; white-space: pre-wrap; max-height: 340px; overflow-y: auto;
  color: var(--text-body);
}
.passage.reading { max-height: none; }
.q-item { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hairline); }
.q-item .q-text { font-size: 15px; font-weight: 600; margin-bottom: 10px; letter-spacing: -0.01em; }
.q-item .q-num {
  display: inline-block; background: var(--accent-weak); color: var(--accent-deep);
  font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 8px; margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
.opt {
  display: block; width: 100%; text-align: left; margin-top: 8px;
  border: 1px solid var(--hairline); background: #fff; border-radius: var(--r-thumb);
  padding: 11px 14px; font-size: 14px; cursor: pointer; transition: all .15s var(--ease-out);
  color: var(--text); font-family: inherit;
}
.opt:hover { border-color: var(--faint); background: var(--hover); }
.opt .opt-key { font-weight: 700; color: var(--text-3); margin-right: 8px; }
.opt.correct { border-color: var(--live); background: var(--live-weak); }
.opt.correct .opt-key { color: var(--live); }
.opt.wrong { border-color: var(--danger); background: var(--danger-weak); }
.opt.wrong .opt-key { color: var(--danger); }
.opt.locked { cursor: default; pointer-events: none; }
.explain {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--r-thumb);
  background: var(--bg); font-size: 13px; color: var(--text-2);
}
.explain b { color: var(--accent-deep); }
.explain.bad b { color: var(--danger); }

/* 词库（选词填空） */
.bank {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px;
  padding: 12px; background: var(--bg); border-radius: var(--r-thumb);
}
.bank .chip {
  background: #fff; border: 1px solid var(--hairline); border-radius: var(--r-pill);
  padding: 4px 12px; font-size: 13px; color: var(--text);
}
.bank .chip b { color: var(--accent-deep); margin-right: 4px; }
.blank-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.blank-row select {
  flex: 1; border: 1px solid var(--hairline); border-radius: var(--r-thumb);
  padding: 9px 12px; font-size: 14px; background: #fff; color: var(--text);
}
.blank-row select:disabled { opacity: .85; }
.blank-row select.correct { border-color: var(--live); background: var(--live-weak); }
.blank-row select.wrong { border-color: var(--danger); background: var(--danger-weak); }

/* 段落匹配字母 chips */
.letter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.letter-row .lbtn {
  width: 42px; height: 40px; border-radius: 10px; border: 1px solid var(--hairline);
  background: #fff; font-weight: 600; font-size: 15px; cursor: pointer; color: var(--text);
}
.letter-row .lbtn:hover { border-color: var(--faint); background: var(--hover); }
.letter-row .lbtn.correct { background: var(--live-weak); border-color: var(--live); color: #1a9c48; }
.letter-row .lbtn.wrong { background: var(--danger-weak); border-color: var(--danger); color: var(--danger); }

/* ---------- 听力播放器 ---------- */
.audio-panel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.audio-panel select {
  border: 1px solid var(--hairline); border-radius: var(--r-thumb); padding: 8px 10px;
  font-size: 13px; background: #fff; color: var(--text);
}
.script-toggle { margin-top: 10px; }
.script-box {
  margin-top: 10px; background: var(--bg); border-radius: var(--r-thumb); padding: 12px;
  font-size: 14px; line-height: 1.9; white-space: pre-wrap;
}
.script-box.hidden { display: none; }

/* ---------- 写译 ---------- */
.task-text {
  background: var(--bg); border-radius: var(--r-thumb); padding: 14px;
  font-size: 15px; line-height: 1.9; text-align: justify; color: var(--text-body);
}
.task-text.en { font-family: Georgia, "Times New Roman", serif; line-height: 1.8; }
textarea.answer {
  width: 100%; min-height: 130px; border: 1px solid var(--hairline); border-radius: var(--r-thumb);
  padding: 12px; font-size: 14px; font-family: inherit; resize: vertical;
  background: #fff; color: var(--text); margin-top: 12px;
}
textarea.answer:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.ref-box {
  margin-top: 12px; padding: 14px; border-radius: var(--r-thumb);
  border: 1px solid var(--hairline); background: var(--bg);
  font-size: 14px; line-height: 1.85;
}
.ref-box .ref-label { font-size: 12px; color: var(--accent-deep); font-weight: 700; margin-bottom: 6px; }
.ref-box.hidden { display: none; }
.rate-row { display: flex; gap: 10px; margin-top: 14px; }

/* ---------- 列表 ---------- */
.set-list .set-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 0; border-bottom: 1px solid var(--hairline); cursor: pointer;
}
.set-list .set-item:last-child { border-bottom: none; }
.set-item .t { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.set-item .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.set-item .score {
  flex-shrink: 0; font-size: 13px; font-weight: 700;
  color: var(--accent-deep); background: var(--accent-weak);
  border-radius: var(--r-pill); padding: 4px 10px; font-variant-numeric: tabular-nums;
}
.group-label {
  font-size: 13px; font-weight: 600; color: var(--text-3);
  margin: 16px 0 6px; letter-spacing: .02em;
}

/* ---------- 结果横幅 ---------- */
.result-banner {
  border-radius: var(--r-thumb); padding: 14px; text-align: center; margin-bottom: 14px;
  background: var(--live-weak); color: #1a9c48; font-weight: 600;
}
.result-banner.good { background: var(--live-weak); color: #1a9c48; }
.result-banner.bad { background: var(--danger-weak); color: var(--danger); }

/* ---------- 空状态 / 完成 ---------- */
.done-state { text-align: center; padding: 40px 10px; }
.done-state .emoji { font-size: 52px; }
.done-state .msg { font-size: 17px; font-weight: 700; margin: 12px 0 4px; letter-spacing: -0.01em; }
.done-state .sub { color: var(--text-2); font-size: 13px; }

/* ---------- 趋势图 ---------- */
.chart-wrap { width: 100%; }
.trend-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 14px 0; }

/* ---------- 生词本 ---------- */
.starred-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--hairline); cursor: pointer;
}
.starred-item:last-child { border-bottom: none; }
.starred-item .w { font-weight: 600; font-size: 15px; }
.starred-item .m { font-size: 13px; color: var(--text-2); }
.detail-pop {
  margin-top: 8px; padding: 12px; background: var(--bg); border-radius: var(--r-thumb); font-size: 13px;
}
.detail-pop.hidden { display: none; }

/* ---------- 底部导航（玻璃材质 — 仅此一处用玻璃） ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px; z-index: 100;
  display: flex; background: rgba(245, 245, 247, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar button {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; font-size: 11px; color: var(--text-3); font-family: inherit;
}
#tabbar button .tab-ic { color: var(--text-3); transition: color .2s, transform .2s var(--ease-out); }
#tabbar button.active { color: var(--accent); font-weight: 600; }
#tabbar button.active .tab-ic { color: var(--accent); }

/* 返回按钮 */
.back-link {
  display: inline-flex; align-items: center; gap: 4px; border: none; background: none;
  color: var(--accent-deep); font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 4px 0; margin-bottom: 8px; font-family: inherit;
}

/* ---------- 快捷入口 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-grid .qbtn {
  background: var(--bg); border: none; border-radius: var(--r-thumb);
  padding: 14px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text); font-weight: 500; cursor: pointer;
  font-family: inherit; transition: transform .15s var(--ease-out), box-shadow .15s;
}
.quick-grid .qbtn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-grid .qbtn:active { transform: scale(.95); }
.quick-grid .qbtn .tab-ic { color: var(--text-2); }

/* 倒计时临近变暖色渐变 */
.countdown.urgent { background: linear-gradient(135deg, #ff375f 0%, #ff9f0a 100%); box-shadow: 0 20px 54px rgba(255, 55, 95, 0.22); }

/* 背词卡片类型标签 */
.chip-tag {
  position: absolute; top: 16px; left: 16px; font-size: 11px;
  padding: 2px 10px; border-radius: var(--r-pill); font-weight: 600;
  background: var(--accent-weak); color: var(--accent-deep);
}
.chip-tag.review { background: rgba(255, 107, 0, 0.1); color: #ff6b00; }

/* 子标签页（iOS 分段控件） */
.subtabs {
  display: flex; gap: 2px; margin-bottom: 14px;
  background: var(--track); border-radius: var(--r-pill); padding: 3px;
}
.subtabs .stab {
  flex: 1; border: none; background: transparent; border-radius: var(--r-pill);
  padding: 9px; font-size: 14px; font-weight: 500; color: var(--text-2);
  cursor: pointer; box-shadow: none; font-family: inherit; transition: all .2s var(--ease-out);
}
.subtabs .stab.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }

/* 听力逐句 */
.script-line { padding: 2px 8px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.script-line:hover { background: var(--accent-weak); color: var(--accent-deep); }

/* 错题本 */
.wrong-item { padding: 14px 0; border-bottom: 1px solid var(--hairline); }
.wrong-item:last-child { border-bottom: none; }
.wrong-meta { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }

/* 设置行 */
.set-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.set-row label { white-space: nowrap; color: var(--text-2); font-size: 13px; width: 62px; }
.set-row select, .set-row input[type="date"] {
  flex: 1; border: 1px solid var(--hairline); border-radius: var(--r-thumb);
  padding: 9px 10px; font-size: 14px; background: #fff; color: var(--text); font-family: inherit;
}
.set-row select:focus, .set-row input[type="date"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

/* 生词本移除按钮 */
.star-mini { border: none; background: none; font-size: 18px; cursor: pointer; padding: 6px; }
.star-mini.on { color: var(--warn); }

/* 完成态补充 */
.done-state .stats-line { color: var(--text-2); font-size: 13px; margin-top: 4px; }

/* ---------- 桌面端网页布局（≥900px） ---------- */
.brand { display: none; }

@media (min-width: 900px) {
  .brand {
    display: block; padding: 22px 14px 16px;
    font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.02em;
    white-space: nowrap;
  }
  #tabbar {
    top: 0; bottom: 0; left: 0; transform: none;
    width: 208px; max-width: none;
    flex-direction: column; align-items: stretch;
    border-top: none; border-right: 1px solid var(--hairline);
    padding: 0 10px; padding-bottom: 0;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
  }
  #tabbar button {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 12px 14px; font-size: 15px; border-radius: var(--r-thumb); margin: 2px 0;
  }
  #tabbar button .tab-ic { width: 20px; height: 20px; }
  #tabbar button:hover { background: var(--hover); }
  #tabbar button.active { background: var(--accent-weak); color: var(--accent-deep); font-weight: 600; }

  #app {
    max-width: 1040px;
    margin: 0 0 0 208px;
    padding: 30px 36px 48px;
  }

  .home-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 16px; align-items: start;
  }
  .home-grid .card { margin-bottom: 0; }
  .span-2 { grid-column: span 2; }

  .quiz-cols {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px; align-items: start;
  }
  .quiz-left { position: sticky; top: 20px; }
  .quiz-cols .card { margin-bottom: 0; }

  .passage.reading { max-height: 60vh; overflow-y: auto; }

  #app > .card.word-card, #app .word-wrap { max-width: 620px; margin-left: auto; margin-right: auto; }

  textarea.answer { min-height: 180px; }
}

@media (min-width: 640px) and (max-width: 899.9px) {
  #app { max-width: 760px; }
}

.account-link { position: fixed; top: 10px; right: 16px; z-index: 105; color: var(--accent); background: var(--bg); padding: 7px 12px; border-radius: 20px; font-size: 13px; text-decoration: none; }
.signed-out #tabbar, .signed-out .account-link { display: none; }
.signed-out #app { margin: 0 auto; max-width: 500px; padding: 60px 20px; }
.login-card h1 { font-size: 26px; margin-bottom: 12px; }
.login-card form, .account-form { display: grid; gap: 12px; }
.login-card label, .account-form label { font-size: 14px; }
.login-card input, .account-form input { width: 100%; padding: 12px; border: 1px solid var(--hairline); border-radius: 10px; background: white; font: inherit; }
.login-card input:focus, .account-form input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-message { color: var(--text-2); font-size: 14px; min-height: 20px; overflow-wrap: anywhere; }
.draft-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 18px; }
.draft-toolbar #save-state { flex: 1; min-width: 130px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.history-item { border-bottom: 1px solid var(--hairline); padding: 14px 0; }
.history-item summary { cursor: pointer; font-size: 14px; }
.history-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 14px; line-height: 1.8; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.hidden { display: none !important; }
button:disabled { opacity: .6; cursor: wait; }
@media (max-width: 899px) { #app { padding-top: 45px; } }
