/* 语法模考 — Duolingo-flavored styling. Desktop-first with mobile overrides. */

:root {
  --green:      #58cc02;
  --green-dark: #45a002;
  --green-shadow:#3f8c00;
  --blue:       #1cb0f6;
  --blue-dark:  #1899d6;
  --purple:     #ce82ff;
  --gold:       #ffc800;
  --red:        #ff4b4b;
  --red-soft:   #ffe5e5;
  --green-soft: #d7ffb8;
  --ink:        #3c3c3c;
  --muted:      #777;
  --line:       #e5e5e5;
  --bg:         #fff;
  --bg-soft:    #f7f7f7;
  --radius:     16px;
  --maxw:       820px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg-soft);
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--green); color: #fff; font-weight: 800; font-size: 20px;
}
.brand-name { font-weight: 800; font-size: 20px; color: var(--green-dark); }
.topnav a {
  margin-left: 18px; font-weight: 700; color: var(--muted);
}
.topnav a:hover { color: var(--green-dark); }

/* ---------------- Layout ---------------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 96px; }
.block { margin: 36px 0; }
.block.center { text-align: center; }
.block-title { font-size: 24px; font-weight: 800; margin: 0 0 6px; }
.block-title.sm { font-size: 19px; margin-top: 30px; }
.block-sub { color: var(--muted); margin: 0 0 18px; }

/* ---------------- Hero ---------------- */
.hero { text-align: center; padding: 40px 16px 10px; }
.hero-mascot { font-size: 64px; }
.hero-title { font-size: 40px; font-weight: 900; color: var(--green-dark); margin: 8px 0; }
.hero-sub { color: var(--muted); max-width: 540px; margin: 0 auto 26px; line-height: 1.6; }
.hero-meta { color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-block; cursor: pointer; border: none;
  font-weight: 800; font-size: 15px; letter-spacing: .03em;
  padding: 14px 26px; border-radius: 14px;
  text-transform: uppercase;
  transition: transform .05s ease, filter .15s ease;
  user-select: none;
}
.btn:active { transform: translateY(2px); }
.btn-lg { font-size: 18px; padding: 16px 38px; }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-shadow); }
.btn-primary:hover { filter: brightness(1.03); }
.btn-blue { background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-dark); }
.btn-ghost { background: #fff; color: var(--green-dark); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); border-radius: 14px; padding: 14px 26px; font-weight: 800; }
.btn-secondary { background: #e5e5e5; color: #555; box-shadow: 0 4px 0 #cfcfcf; }
.btn[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }

/* ---------------- Cards grid ---------------- */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.practice-card {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 4px 0 var(--line);
  transition: transform .1s ease, border-color .1s ease;
}
.practice-card:hover { transform: translateY(-3px); border-color: var(--green); }
.pc-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; background: var(--bg-soft); margin-bottom: 12px;
}
.c-term  .pc-icon { background: #e7f7ff; }
.c-cloze .pc-icon { background: #fff3d6; }
.c-cont  .pc-icon { background: #f3e6ff; }
.c-rewrite .pc-icon { background: var(--green-soft); color: var(--green-dark); }
.pc-name { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.pc-desc { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ---------------- Progress ---------------- */
.exam-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.progress-bar { flex: 1; height: 16px; background: #e5e5e5; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--green); border-radius: 10px; transition: width .4s ease; }
.progress-label { font-weight: 800; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------------- Stage / cards ---------------- */
.stage { min-height: 200px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; font-weight: 700; }
.panel {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 24px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 6px; font-size: 22px; }
.panel .sec-instr { color: var(--muted); margin: 0 0 18px; line-height: 1.6; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); margin-left: 8px; }
.badge.ai { background: #f3e6ff; color: #8a2be2; }
.badge.offline { background: #ffe9c7; color: #b26a00; }
.badge.orig { background: var(--gold); color: #7a5b00; }

/* question rows */
.q { padding: 16px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: none; }
.q-prompt { font-weight: 700; margin-bottom: 10px; line-height: 1.6; }
.q-num { color: var(--muted); font-weight: 800; margin-right: 6px; }
.q-tag { font-size: 12px; color: var(--blue); font-weight: 800; margin-left: 6px; }

input.answer, textarea.answer {
  width: 100%; font-size: 16px; font-family: inherit; color: var(--ink);
  padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
}
input.answer:focus, textarea.answer:focus { outline: none; border-color: var(--blue); }
textarea.answer { min-height: 220px; resize: vertical; line-height: 1.7; }

/* terminology two-col on desktop */
.term-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.term-grid .q { border-bottom: none; padding: 6px 0; }
.dir-tag { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 8px; margin-right: 8px; }
.dir-en2cn { background: #e7f7ff; color: var(--blue-dark); }
.dir-cn2en { background: var(--green-soft); color: var(--green-dark); }

/* cloze passage */
.cloze-text { line-height: 2.4; font-size: 16px; }
.cloze-text input.blank {
  width: 120px; display: inline-block; padding: 4px 8px; margin: 0 2px;
  border: none; border-bottom: 2px solid var(--blue); border-radius: 6px 6px 0 0;
  background: #f0faff; font-size: 15px; text-align: center;
}
.cloze-cue { color: var(--muted); font-size: 13px; }

/* cloze review — correctness shown on the passage inputs in place */
.cloze-slot { white-space: nowrap; }
.cloze-review input.blank[disabled] { opacity: 1; cursor: default; font-weight: 700; }
.cloze-review input.blank.correct {
  border-bottom-color: var(--green); background: #effbe4;
  color: var(--green-dark); -webkit-text-fill-color: var(--green-dark);
}
.cloze-review input.blank.wrong {
  border-bottom-color: var(--red); background: var(--red-soft);
  color: var(--red); -webkit-text-fill-color: var(--red); text-decoration: line-through;
}
.cloze-fix { color: var(--green-dark); font-weight: 800; font-size: 13px; margin: 0 4px; white-space: nowrap; }

/* cloze recitation — the fully correct passage, blanks bold + red */
.cloze-recite { background: var(--bg-soft); border-radius: 12px; padding: 16px 18px; margin-top: 6px; line-height: 2.2; }
.cloze-recite-blank { color: var(--red); font-weight: 800; }

/* ---------------- Results ---------------- */
.result-head { text-align: center; padding: 10px 0 18px; }
.result-score { font-size: 44px; font-weight: 900; color: var(--green-dark); }
.result-score .out { font-size: 22px; color: var(--muted); }
.result-sub { color: var(--muted); font-weight: 700; }
.r-item { padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; border: 2px solid var(--line); }
.r-item.ok { background: #f3fde9; border-color: var(--green-soft); }
.r-item.bad { background: var(--red-soft); border-color: #ffc9c9; }
.r-line { margin: 3px 0; }
.r-label { font-weight: 800; color: var(--muted); margin-right: 6px; font-size: 13px; }
.r-your.wrong { color: var(--red); text-decoration: line-through; }
.r-answer { color: var(--green-dark); font-weight: 800; }
.r-comment { margin-top: 8px; color: #444; line-height: 1.6; background: #fff; border-radius: 10px; padding: 10px 12px; border: 1px dashed var(--line); white-space: pre-wrap; }
.r-score-pill { float: right; font-weight: 900; color: var(--green-dark); }

/* ---------------- Guide ---------------- */
.guide .guide-kicker { color: var(--purple); font-weight: 800; letter-spacing: .08em; }
.guide h2 { font-size: 26px; margin: 6px 0; }
.guide .guide-sub { color: var(--muted); margin-bottom: 20px; }
.guide-section { margin: 18px 0; }
.guide-section h3 { font-size: 17px; margin: 0 0 8px; color: var(--green-dark); }
.guide-concept { white-space: pre-wrap; line-height: 1.8; color: #444; }
.guide ol, .guide ul { line-height: 1.8; padding-left: 22px; margin: 0; }
.guide-eg { background: var(--bg-soft); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.guide-eg .before { color: var(--red); }
.guide-eg .arrow { color: var(--muted); margin: 0 6px; }
.guide-eg .after { color: var(--green-dark); font-weight: 700; }
.guide-eg .eg-note { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------------- Continuation feedback ---------------- */
.story-box { background: var(--bg-soft); border-radius: 12px; padding: 16px 18px; line-height: 1.8; margin-bottom: 16px; }
.story-box h3 { margin: 0 0 8px; }
.corr-list .corr { border-left: 4px solid var(--red); padding: 8px 12px; margin: 8px 0; background: #fff7f7; border-radius: 0 10px 10px 0; }
.corr .err { color: var(--red); text-decoration: line-through; }
.corr .fix { color: var(--green-dark); font-weight: 700; }
.up-list .up { border-left: 4px solid var(--purple); padding: 8px 12px; margin: 8px 0; background: #faf5ff; border-radius: 0 10px 10px 0; }
.overall-note { background: var(--green-soft); border-radius: 12px; padding: 14px 16px; margin-top: 14px; font-weight: 700; color: var(--green-dark); }

/* ---------------- Final analysis ---------------- */
.final-celebrate { text-align: center; font-size: 56px; }
.analysis-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.analysis-table th, .analysis-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.analysis-table th { color: var(--muted); font-size: 13px; }
.lossbar { height: 10px; border-radius: 6px; background: #eee; overflow: hidden; min-width: 80px; }
.lossbar > span { display: block; height: 100%; background: var(--red); }

.actionbar { display: flex; justify-content: flex-end; gap: 12px; margin-top: 18px; }

.note-line { color: var(--muted); font-size: 13px; margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* ---------------- 学习 / flashcards ---------------- */
.hero-secondary { margin-top: 14px; }
.btn-sm { font-size: 13px; padding: 10px 16px; }
.study-modes { max-width: 560px; margin: 10px auto 0; }
.study-back { text-align: center; margin-top: 20px; }

.study-wrap { max-width: 640px; margin: 0 auto; }
.study-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.study-counter { font-weight: 800; color: var(--muted); font-size: 14px; }
.study-progress { height: 12px; background: #e5e5e5; border-radius: 8px; overflow: hidden; margin-bottom: 22px; }
.study-progress-fill { height: 100%; background: var(--green); border-radius: 8px; transition: width .35s ease; }

/* the card itself */
.flashcard { perspective: 1200px; cursor: pointer; user-select: none; }
.fc-inner {
  background: #fff; border: 2px solid var(--line); border-radius: 20px;
  box-shadow: 0 6px 0 var(--line);
  min-height: 280px; padding: 30px 26px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  transform-style: preserve-3d;
  animation: fc-flip .28s ease;
}
.flashcard.flipped .fc-inner { border-color: var(--green-soft); box-shadow: 0 6px 0 var(--green-soft); }
.flashcard:hover .fc-inner { filter: brightness(1.01); }
@keyframes fc-flip {
  from { transform: rotateY(-90deg); opacity: .25; }
  to   { transform: rotateY(0deg);   opacity: 1; }
}
.fc-face { display: none; width: 100%; }
.flashcard:not(.flipped) .fc-front { display: block; }
.flashcard.flipped .fc-back { display: block; }

.fc-content { width: 100%; }
.fc-content-rw { text-align: left; }
.fc-tagrow { margin-bottom: 14px; }
.fc-word { font-size: 30px; font-weight: 900; color: var(--ink); line-height: 1.4; word-break: break-word; }
.fc-word.fc-answer { color: var(--green-dark); }
.fc-sub { color: var(--muted); margin-top: 14px; font-size: 14px; }
.fc-answer-label { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); }
.fc-pair { color: var(--muted); margin-top: 16px; font-size: 14px; }

/* rewrite card faces */
.fc-part-tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); }
.fc-label { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .05em; margin: 14px 0 6px; }
.fc-sentence { font-size: 19px; font-weight: 700; line-height: 1.6; color: var(--ink); }
.fc-sentence.dim { font-size: 15px; font-weight: 600; color: var(--muted); }
.fc-refs { display: flex; flex-direction: column; gap: 8px; }
.fc-ref { font-size: 18px; font-weight: 800; color: var(--green-dark); line-height: 1.6; background: #f3fde9; border: 2px solid var(--green-soft); border-radius: 12px; padding: 10px 14px; }
.fc-ref-n { color: var(--muted); font-weight: 800; }
.fc-explain { margin-top: 16px; background: #faf5ff; border-left: 4px solid var(--purple); border-radius: 0 12px 12px 0; padding: 12px 14px; }
.fc-explain-label { font-weight: 800; color: var(--purple); font-size: 14px; margin-bottom: 6px; }
.fc-explain-body { color: #444; line-height: 1.7; white-space: pre-wrap; }

.fc-hint { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 18px; font-weight: 700; }
.study-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------------- Mobile ---------------- */
@media (max-width: 640px) {
  .container { padding: 16px 14px 120px; }
  .hero-title { font-size: 32px; }
  .topnav a { margin-left: 12px; font-size: 14px; }
  .card-grid { grid-template-columns: 1fr; }
  .term-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px 16px; }
  .cloze-text input.blank { width: 96px; }
  /* sticky action bar on mobile for the primary button */
  .actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--bg); border-top: 2px solid var(--line);
    padding: 12px 14px; margin: 0; justify-content: stretch;
  }
  .actionbar .btn { flex: 1; }
  .actionbar .btn-secondary { flex: 0 0 auto; }
  /* flashcards */
  .study-modes { grid-template-columns: 1fr; }
  .fc-inner { min-height: 240px; padding: 24px 18px; }
  .fc-word { font-size: 26px; }
  .fc-sentence { font-size: 17px; }
  .study-controls { gap: 8px; }
  .study-controls .btn { padding: 12px 12px; font-size: 13px; }
}
