/* ===== Duolingo 风格英语模考系统 ===== */
:root {
  --green: #58cc02;
  --green-dark: #58a700;
  --green-hover: #61e002;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --gold: #ffc800;
  --purple: #ce82ff;
  --ink: #3c3c3c;
  --muted: #777;
  --line: #e5e5e5;
  --line-dark: #d0d0d0;
  --bg: #fff;
  --bg-soft: #f7f7f7;
  --good-bg: #d7ffb8;
  --good-ink: #58a700;
  --bad-bg: #ffdfe0;
  --bad-ink: #ea2b2b;
  --radius: 16px;
  --shadow-btn: 0 4px 0;
  --font: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- 屏幕切换 / 入场动画 ---------- */
@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.app.screen-in { animation: screenIn .34s cubic-bezier(.22, .61, .36, 1) both; }
/* 卡片/选项轻微错落入场，营造优雅的层次感 */
.app.screen-in .qcard,
.app.screen-in .focus-card,
.app.screen-in .paper-row,
.app.screen-in .bar-row,
.app.screen-in .hist-card {
  animation: cardIn .42s cubic-bezier(.22, .61, .36, 1) both;
}
.app.screen-in .qcard:nth-child(1),
.app.screen-in .focus-card:nth-child(1) { animation-delay: .04s; }
.app.screen-in .qcard:nth-child(2),
.app.screen-in .focus-card:nth-child(2) { animation-delay: .08s; }
.app.screen-in .qcard:nth-child(3),
.app.screen-in .focus-card:nth-child(3) { animation-delay: .12s; }
.app.screen-in .qcard:nth-child(4),
.app.screen-in .focus-card:nth-child(4) { animation-delay: .16s; }
.app.screen-in .qcard:nth-child(5),
.app.screen-in .focus-card:nth-child(5) { animation-delay: .20s; }
.app.screen-in .qcard:nth-child(6)  { animation-delay: .24s; }
.app.screen-in .qcard:nth-child(7)  { animation-delay: .27s; }
.app.screen-in .qcard:nth-child(8)  { animation-delay: .30s; }
.app.screen-in .qcard:nth-child(n+9) { animation-delay: .33s; }

/* 结果页大分数弹入 */
@keyframes popIn {
  0%   { opacity: 0; transform: scale(.6); }
  60%  { transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}
.app.screen-in .result-emoji { animation: popIn .55s cubic-bezier(.18, .89, .32, 1.28) both; }
.app.screen-in .bigscore { animation: popIn .55s .12s cubic-bezier(.18, .89, .32, 1.28) both; }

/* 全屏彩带画布 */
.confetti-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 9999;
}

/* 尊重系统“减弱动态效果” */
@media (prefers-reduced-motion: reduce) {
  .app.screen-in,
  .app.screen-in * { animation: none !important; }
  .progress-fill, .bar-fill, .focus-card, .fc-go { transition: none !important; }
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 2px solid var(--line);
}
.topbar-inner {
  max-width: 920px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.brand-logo { font-size: 26px; }
.brand-name { font-weight: 800; font-size: 20px; color: var(--green-dark); letter-spacing: .5px; }
.topbar-progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 16px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0; background: var(--green);
  border-radius: 999px; transition: width .35s ease;
  background-image: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 45%);
}
.streak { font-weight: 800; color: var(--gold); white-space: nowrap; font-size: 14px; }
.topbar-actions { margin-left: auto; }
.icon-btn {
  border: none; background: none; font-size: 20px; color: var(--muted);
  cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.ghost-btn {
  border: 2px solid var(--line); background: #fff; color: var(--muted);
  font-weight: 700; padding: 8px 14px; border-radius: 12px; cursor: pointer; font-size: 14px;
}
.ghost-btn:hover { border-color: var(--line-dark); color: var(--ink); }

/* ---------- 主区域 ---------- */
.app { max-width: 760px; margin: 0 auto; padding: 28px 18px 140px; min-height: 60vh; }
.loading { text-align: center; color: var(--muted); padding: 80px 0; font-size: 18px; }

.section-head { margin-bottom: 22px; }
.section-kicker { color: var(--blue); font-weight: 800; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }
.section-title { font-size: 26px; font-weight: 800; margin: 6px 0 4px; }
.section-desc { color: var(--muted); font-size: 15px; line-height: 1.5; }

/* ---------- 题卡 ---------- */
.qcard {
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; background: #fff;
}
.qcard .qno { color: var(--blue); font-weight: 800; font-size: 13px; margin-bottom: 6px; }
.qtext { font-size: 17px; line-height: 1.9; }
.qtext u { text-decoration: none; border-bottom: 3px solid var(--gold); padding-bottom: 1px; font-weight: 700; }
.hint-given { color: var(--purple); font-weight: 800; }

/* 内联填空输入 */
.blank-input {
  display: inline-block; min-width: 90px; max-width: 260px;
  border: none; border-bottom: 3px solid var(--blue);
  background: #f0fbff; font: inherit; font-weight: 700; color: var(--ink);
  text-align: center; padding: 2px 8px; margin: 2px 2px; border-radius: 6px 6px 0 0;
  outline: none; line-height: 1.6;
}
.blank-input:focus { background: #e1f5ff; border-color: var(--blue-dark); }

/* 课文填空：紧凑输入框 + 序号嵌入框内左侧（半透明） */
.cloze-slot { position: relative; display: inline-block; }
.cloze-idx {
  position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 800; line-height: 1;
  color: rgba(28, 176, 246, .55); pointer-events: none; user-select: none;
}
.blank-input.cloze-blank {
  min-width: 56px; width: 120px; max-width: none;
  text-align: left; padding-left: 18px; padding-right: 6px;
}
.blank-input.good { border-color: var(--green); background: var(--good-bg); color: var(--good-ink); }
.blank-input.bad { border-color: var(--red); background: var(--bad-bg); color: var(--bad-ink); text-decoration: line-through; }
.inline-correct { color: var(--good-ink); font-weight: 800; margin-left: 4px; }

/* 词框 */
.wordbank {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 22px;
  padding: 16px; background: var(--bg-soft); border-radius: var(--radius); border: 2px dashed var(--line-dark);
}
.wordbank-title { width: 100%; font-weight: 800; color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.chip {
  border: 2px solid var(--line); border-bottom-width: 4px; background: #fff;
  border-radius: 12px; padding: 8px 14px; font-weight: 700; font-size: 15px;
  cursor: pointer; user-select: none; transition: transform .05s;
}
.chip:hover { background: var(--bg-soft); }
.chip:active { transform: translateY(2px); border-bottom-width: 2px; }
.chip.used { opacity: .35; pointer-events: none; text-decoration: line-through; }

/* 选择题选项 */
.options { display: grid; gap: 10px; margin-top: 12px; }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 2px solid var(--line); border-bottom-width: 4px; background: #fff;
  border-radius: 14px; padding: 12px 14px; cursor: pointer; font-size: 16px; font-weight: 600;
  transition: transform .05s;
}
.option:hover { background: var(--bg-soft); }
.option:active { transform: translateY(2px); border-bottom-width: 2px; }
.option .key {
  flex: 0 0 28px; height: 28px; border: 2px solid var(--line); border-radius: 8px;
  display: grid; place-items: center; font-weight: 800; color: var(--muted); font-size: 14px;
}
.option.selected { border-color: var(--blue); background: #e1f5ff; }
.option.selected .key { border-color: var(--blue); color: var(--blue-dark); }
.option.good { border-color: var(--green); background: var(--good-bg); }
.option.good .key { border-color: var(--green-dark); color: var(--green-dark); }
.option.bad { border-color: var(--red); background: var(--bad-bg); }
.option.bad .key { border-color: var(--red-dark); color: var(--red-dark); }
.option[disabled] { cursor: default; }

/* 造句文本框 */
.maker-input {
  width: 100%; min-height: 70px; border: 2px solid var(--line); border-radius: 12px;
  padding: 12px; font: inherit; font-size: 16px; resize: vertical; outline: none; margin-top: 10px;
}
.maker-input:focus { border-color: var(--blue); }
.maker-word { font-size: 20px; font-weight: 800; color: var(--purple); }

/* ---------- 底栏 ---------- */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff; border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  transition: background .25s ease, border-color .25s ease;
}
/* 判分后反馈文字轻轻浮入 */
.bottom-feedback { transition: color .25s ease; }
.bottombar.good .bottom-feedback, .bottombar.bad .bottom-feedback {
  animation: feedbackIn .3s ease both;
}
@keyframes feedbackIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bottombar.good { background: var(--good-bg); border-top-color: #9ce05a; }
.bottombar.bad { background: var(--bad-bg); border-top-color: #ffafb0; }
.bottombar-inner {
  max-width: 760px; margin: 0 auto; padding: 14px 18px;
  display: flex; align-items: center; gap: 16px;
}
.bottom-feedback { flex: 1; font-weight: 800; font-size: 16px; }
.bottom-feedback.good { color: var(--good-ink); }
.bottom-feedback.bad { color: var(--bad-ink); }

.primary-btn {
  border: none; background: var(--green); color: #fff; font-weight: 800; font-size: 16px;
  letter-spacing: 1px; padding: 14px 28px; border-radius: 14px; cursor: pointer;
  box-shadow: var(--shadow-btn) var(--green-dark); min-width: 130px;
}
.primary-btn:hover { background: var(--green-hover); }
.primary-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.primary-btn.blue { background: var(--blue); box-shadow: var(--shadow-btn) var(--blue-dark); }
.primary-btn.blue:hover { filter: brightness(1.03); }
.primary-btn:disabled { background: var(--line); color: #aaa; box-shadow: var(--shadow-btn) var(--line-dark); cursor: not-allowed; }

/* ---------- 首页 ---------- */
.home { text-align: center; padding-top: 10px; }
.home-hero { font-size: 64px; }
.home h1 { font-size: 30px; margin: 8px 0; }
.home p.sub { color: var(--muted); font-size: 16px; margin: 0 auto 26px; max-width: 460px; line-height: 1.6; }
.home-actions { display: flex; flex-direction: column; gap: 12px; max-width: 360px; margin: 0 auto; }
.btn-xl {
  border: none; font-weight: 800; font-size: 18px; letter-spacing: 1px;
  padding: 16px; border-radius: 16px; cursor: pointer; color: #fff;
}
.btn-xl.green { background: var(--green); box-shadow: 0 5px 0 var(--green-dark); }
.btn-xl.green:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--green-dark); }
.btn-xl.white { background: #fff; color: var(--blue-dark); border: 2px solid var(--line); border-bottom-width: 4px; }
.btn-xl.white:active { transform: translateY(3px); border-bottom-width: 2px; }

/* 专项练习卡片 —— 强化“这是一个按钮”的视觉暗示 */
.home-focus, .home-paper { margin: 30px auto 0; max-width: 520px; text-align: left; }
.home-focus h3, .home-paper h3 { font-size: 17px; margin: 0 0 8px; }
.home-focus h3 small { color: var(--muted); font-weight: 600; font-size: 12px; }
.focus-hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.focus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.focus-card {
  text-align: left; border: 2px solid var(--line); border-bottom-width: 5px;
  background: #fff; border-radius: 16px; padding: 16px 16px 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; font: inherit;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.focus-card:hover {
  border-color: var(--green); transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(88, 204, 2, .15);
}
.focus-card:active { transform: translateY(1px); border-bottom-width: 2px; }
.focus-card .fc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.focus-card .fc-name { font-weight: 800; font-size: 21px; color: var(--ink); letter-spacing: .5px; }
.focus-card .fc-go {
  flex: 0 0 auto; font-size: 12px; font-weight: 800; color: #fff; background: var(--green);
  padding: 4px 10px; border-radius: 999px; box-shadow: 0 2px 0 var(--green-dark);
  transition: transform .12s ease;
}
.focus-card:hover .fc-go { transform: translateX(3px); }
.focus-card .fc-meta { font-size: 12px; color: var(--blue); font-weight: 700; }
.focus-card .fc-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.paper-list { text-align: left; }
.paper-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 14px; margin-bottom: 10px;
}
.paper-row .idx {
  flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--green);
  color: #fff; font-weight: 800; display: grid; place-items: center;
}
.paper-row .meta { flex: 1; }
.paper-row .meta b { display: block; font-size: 16px; }
.paper-row .meta span { color: var(--muted); font-size: 13px; }
.paper-row .pts { font-weight: 800; color: var(--blue); }

/* ---------- 结果页 ---------- */
.result { text-align: center; }
.result-emoji { font-size: 64px; }
.result h2 { font-size: 26px; margin: 6px 0; }
.bigscore {
  display: inline-flex; align-items: baseline; gap: 4px; margin: 8px 0 4px;
  font-weight: 800; color: var(--green-dark);
}
.bigscore .num { font-size: 56px; }
.bigscore .den { font-size: 24px; color: var(--muted); }
.score-sub { color: var(--muted); margin-bottom: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0; }
.stat {
  border: 2px solid var(--line); border-radius: 14px; padding: 14px 8px;
}
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 24px; font-weight: 800; }
.stat .v.green { color: var(--green-dark); }
.stat .v.red { color: var(--red); }

/* 失分分析条 */
.analysis { text-align: left; margin-top: 18px; }
.analysis h3 { font-size: 18px; margin-bottom: 12px; }
.bar-row { margin-bottom: 14px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; margin-bottom: 5px; }
.bar-row .bar-top .rate { color: var(--muted); }
.bar-track { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.bar-fill.lvl-good { background: var(--green); }
.bar-fill.lvl-mid { background: var(--gold); }
.bar-fill.lvl-bad { background: var(--red); }
.ungraded-note {
  background: var(--bg-soft); border-radius: 12px; padding: 12px 14px;
  color: var(--muted); font-size: 14px; margin-top: 6px;
}

/* 答案回顾列表 */
.review-list { text-align: left; margin-top: 22px; }
.review-list h3 { font-size: 18px; margin-bottom: 10px; }
.review-item {
  display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.6;
}
.review-item .mark { flex: 0 0 22px; font-weight: 800; }
.review-item .mark.ok { color: var(--green-dark); }
.review-item .mark.no { color: var(--red); }
.review-item .body { flex: 1; }
.review-item .ua { color: var(--red); text-decoration: line-through; margin-right: 6px; }
.review-item .ca { color: var(--green-dark); font-weight: 800; }

/* ---------- 历史中心 ---------- */
.history h2 { font-size: 24px; margin-bottom: 4px; }
.history .sub { color: var(--muted); margin-bottom: 18px; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.hist-card {
  border: 2px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 14px;
}
.hist-card .when { flex: 1; }
.hist-card .when b { display: block; font-size: 15px; }
.hist-card .when span { color: var(--muted); font-size: 13px; }
.hist-card .hscore { font-size: 22px; font-weight: 800; color: var(--green-dark); }
.hist-card .hscore small { font-size: 13px; color: var(--muted); font-weight: 600; }

.weak-banner {
  background: linear-gradient(135deg, #fff6d6, #ffe7c2); border: 2px solid var(--gold);
  border-radius: 16px; padding: 16px; margin-bottom: 20px;
}
.weak-banner h3 { margin: 0 0 6px; font-size: 17px; }
.weak-banner p { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.6; }
.weak-banner .target { color: var(--red-dark); font-weight: 800; }

.danger-link {
  display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px;
  background: none; border: none; cursor: pointer; text-decoration: underline;
}

/* ---------- 响应式：手机端适配 ---------- */
@media (max-width: 600px) {
  .topbar-inner { padding: 10px 12px; gap: 10px; }
  .brand-name { display: none; }
  .ghost-btn { padding: 7px 10px; font-size: 13px; }
  .app { padding: 20px 14px 150px; }
  .section-title { font-size: 22px; }
  .qtext { font-size: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid .stat:last-child { grid-column: span 2; }
  .bigscore .num { font-size: 46px; }
  .primary-btn { padding: 13px 20px; min-width: 104px; font-size: 15px; }
  .bottombar-inner { padding: 12px 14px; gap: 8px; }
  .blank-input { min-width: 110px; }
  .blank-input.cloze-blank { min-width: 92px; width: 92px; }
  .home-hero { font-size: 52px; }
  .focus-grid { grid-template-columns: 1fr; gap: 10px; }
  .focus-card { padding: 14px 14px 12px; }
  .focus-card .fc-name { font-size: 20px; }
  #secondaryBtn { padding: 10px 12px; }
}

@media (max-width: 380px) {
  .chip, .option { font-size: 14px; }
}
