:root {
  --bg: #f6f2ec;
  --card: #fffaf3;
  --ink: #1a1a1a;
  --muted: #6f6a63;
  --line: #e3d9cc;
  --accent: #d24b3c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Times New Roman", "Noto Serif SC", "Songti SC", "SimSun", serif;
  background: var(--bg);
  color: var(--ink);
}

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

.topbar {
  border-bottom: 1px solid var(--line);
  background: #f8f3ec;
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.brand { font-weight: 700; font-size: 18px; }

.nav { display: flex; gap: 12px; }
.nav a { padding: 6px 8px; border-radius: 6px; }
.nav a:hover { background: #fff4e5; }
.nav-user { padding: 6px 8px; color: var(--muted); }

.nav-dropdown { position: relative; display: flex; align-items: center; }
.nav-dropdown::after {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: 100%;
  height: 8px;
}
.nav-trigger {
  padding: 6px 8px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.nav-trigger:hover,
.nav-dropdown.open .nav-trigger,
.nav-dropdown:focus-within .nav-trigger { background: #fff4e5; }

.nav-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  min-width: 140px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 20px rgba(26, 26, 26, 0.08);
  z-index: 10;
}
.nav-menu a { display: block; padding: 8px 10px; border-radius: 8px; }
.nav-menu a:hover { background: #fff4e5; }

.nav-dropdown:hover .nav-menu,
.nav-dropdown.open .nav-menu,
.nav-dropdown:focus-within .nav-menu { display: block; }

.modal-card .muted#topic-start-subtitle { margin: 2px 0 10px; }

.lang-switch {
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 6px;
}
.lang-pill {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
}
.lang-pill.is-active {
  background: #e8f4ff;
  color: #0f3b7b;
  font-weight: 700;
}
.lang-pill.is-active[data-lang="zh"] {
  background: #fff3d6;
  color: #8b5a00;
}
.lang-divider { color: var(--line); }

.container { max-width: 980px; margin: 30px auto; padding: 0 16px; }

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.schedule-strip {
  margin: 18px 0 0;
  display: grid;
  gap: 12px;
  justify-items: stretch;
}

.schedule-title {
  font-weight: 700;
  font-size: 18px;
  width: 100%;
  text-align: left;
}

.schedule-row {
  width: 100%;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.schedule-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
  display: grid;
  gap: 6px;
}

@media (min-width: 940px) {
  .schedule-row {
    grid-template-columns: repeat(5, 1fr);
  }
}

.schedule-head { display: flex; align-items: center; gap: 8px; }
.schedule-icon { width: 18px; height: 18px; color: var(--accent); display: inline-flex; }
.schedule-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.schedule-exam { font-weight: 700; }

.quick-start { margin-top: 24px; }

.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.level-card { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px; display: block; }
.level-title { font-weight: 700; }

.cta-row { display: flex; gap: 12px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.cta-row .muted { margin: 0; line-height: 1.2; }

.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  line-height: 1.2;
}

.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: #fff; }

.text-link { color: var(--accent); }
.link-button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  position: relative;
}

.form { display: grid; gap: 10px; max-width: 420px; }
.inline-form { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

label { font-weight: 600; }
input, select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.muted { color: var(--muted); }

.site-footer { padding-bottom: 24px; }

.site-footer .container { margin: 0 auto; }

.site-footer-inner {
  width: 100%;
  padding: 18px 16px 26px 16px;
  border-top: 1px solid var(--line);
  background: #fffaf2;
  border-radius: 12px;
  display: grid;
  gap: 10px;
}

.footer-links {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.footer-dot { color: var(--muted); }

.footer-disclaimer {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.footer-disclaimer p { margin: 0 0 6px 0; }
.footer-disclaimer p:last-child { margin-bottom: 0; }

.footer-copy {
  color: var(--muted);
  font-size: 12px;
}

.legal {
  color: var(--ink);
  line-height: 1.65;
  max-width: 860px;
}

.legal p { margin: 0 0 12px 0; }
.legal ul { margin: 0 0 12px 18px; padding: 0; }
.legal li { margin: 0 0 6px 0; }

.info-center { margin-top: 26px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.info-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.topic-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.topic-tag {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffaf3;
  font-size: 13px;
}
.topic-code { font-weight: 700; color: var(--accent); }
.topic-name { color: var(--text); }
.amc-score-number { color: #c62828; font-size: 1.5em; font-weight: 700; }
.amc-highlight {
  background: #fff1a8;
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 700;
}
.tips-article p { margin: 0 0 12px; line-height: 1.6; }
.tips-article p:last-child { margin-bottom: 0; }

.account-header { margin-top: 6px; }
.account-grid { display: grid; gap: 16px; margin-top: 16px; }
.account-form { display: grid; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.form-field { display: grid; gap: 6px; }
.verify-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.plan-card .text-link { margin-top: 6px; }
.account-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.activity-list { display: grid; gap: 12px; margin-top: 10px; }
.activity-row { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.activity-row.type-paper { border-left: 6px solid #60a5fa; background: #f5faff; }
.activity-row.type-topic { border-left: 6px solid #a78bfa; background: #faf5ff; }
.activity-row.type-diagnostic { border-left: 6px solid #fbbf24; background: #fffbeb; }
.activity-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.activity-title { font-weight: 700; }
.activity-meta { color: var(--muted); font-size: 14px; }
.activity-wrong { display: flex; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.activity-actions { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.activity-badge { flex: 0 0 auto; }
.activity-badge-paper { background: #2563eb; border-color: #2563eb; color: #fff; }
.activity-badge-topic { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.activity-badge-diagnostic { background: #f59e0b; border-color: #f59e0b; color: #1f2937; }
.divider-dot { color: var(--muted); }
.notice-box { padding: 10px 12px; border-radius: 8px; background: #e9f3ff; border: 1px solid #b9d7ff; color: #17427a; margin-top: 12px; }
.inline-check { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.subscription-list { display: grid; gap: 10px; margin-top: 10px; }
.subscription-row { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.subscription-main { min-width: 0; }
.subscription-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.subscription-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn.small { padding: 6px 10px; font-size: 15px; }
.btn.is-loading { opacity: 0.65; cursor: wait; }
.subscription-title { font-weight: 700; }
.subscription-meta { color: var(--muted); font-size: 14px; }

.amc-info-header { margin-top: 6px; }
.amc-info-header h1 { margin-bottom: 6px; }
.latest-updates { margin-top: 20px; }

.date-list { display: grid; gap: 8px; }
.date-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 8px; align-items: center; }
.date-label { font-weight: 700; }
.date-countdown { color: var(--accent); font-weight: 700; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.feature { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; position: relative; }
.feature-links { display: flex; gap: 12px; flex-wrap: wrap; }
.mock-section { margin-top: 16px; }

.home-page .schedule-strip { margin: 10px 0 0; gap: 8px; }
.home-page .schedule-title { font-size: 28px; }
.home-page .schedule-row { gap: 18px; }
.home-page .schedule-item { padding: 10px 12px; min-width: 0; gap: 4px; }
.home-page .hero { gap: 16px; }
.home-page .hero h1 { margin: 8px 0 6px; font-size: 26px; }
.home-page .hero p { margin: 0 0 10px; }
.home-page .quick-start { margin-top: 16px; }
.home-page .hero-card { padding: 12px; }
.home-page .feature-grid { margin-top: 16px; gap: 12px; }
.home-page .feature { padding: 12px; }
.home-page .mock-section { margin-top: 12px; }
.home-page .purchase-grid { gap: 12px; }
.purchase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.purchase-block { position: relative; }
.purchase-badge {
  background: #fff3d6;
  color: #8b5a00;
  border: 1px solid #f1d39a;
}
.free-badge {
  background: #fff1ef;
  color: #a12a1d;
  border: 1px solid #f3c0b8;
  animation: freeBadgePulse 4s ease-in-out infinite;
}
.coming-soon-badge {
  background: #f5f1ff;
  color: #50328a;
  border: 1px solid #d8cdf2;
}

@keyframes freeBadgePulse {
  0%,
  88%,
  100% {
    box-shadow: none;
    filter: none;
    transform: none;
  }
  92% {
    box-shadow: 0 0 0 0 rgba(210, 75, 60, 0.22);
    filter: saturate(1.05) brightness(1.03);
    transform: translateY(-1px);
  }
  96% {
    box-shadow: 0 0 0 10px rgba(210, 75, 60, 0);
    filter: saturate(1.12) brightness(1.05);
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .free-badge { animation: none; }
}

@media print {
  .free-badge { animation: none !important; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: min(860px, 95vw);
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 18px 60px rgba(26, 26, 26, 0.2);
}
.confirm-card { width: min(520px, 92vw); }
.ad-card { width: min(560px, 92vw); }
.leave-card { width: min(640px, 92vw); }
.leave-body { white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.confirm-card p { margin-top: 12px; color: var(--muted); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
}
.ad-body { padding: 10px 12px; }
.ad-countdown { font-weight: 700; color: var(--accent); }
.ad-placeholder {
  min-height: 250px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fffaf3;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.ad-bar .ad-placeholder { min-height: 140px; }
.ad-bar {
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.ad-side {
  position: fixed;
  top: 140px;
  width: clamp(120px, calc((100vw - 980px) / 2 - 32px), 260px);
  min-width: 120px;
  max-width: 260px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ad-slot {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.ad-side-left { left: 16px; }
.ad-side-right { right: 16px; }
@media (max-width: 1280px) {
  .ad-side { display: none; }
  /* Timed practice should still show side ads. */
  .paper-practice[data-timer="timed"] ~ .ad-side { display: block; }
}
.flow-diagram {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  align-items: center;
}
.flow-step {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}
.flow-title { font-weight: 700; margin-bottom: 4px; }
.flow-text { font-size: 14px; color: var(--muted); }
.flow-arrow { text-align: center; font-weight: 700; color: var(--accent); }
.modal-points { margin-top: 14px; display: grid; gap: 6px; }
.point-item { font-size: 14px; color: var(--muted); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.plan-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-card .btn { align-self: flex-start; margin-top: auto; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.plan-title { font-weight: 700; margin-bottom: 6px; }
.plan-price { font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 14px;
}
.mock-links { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.placeholder { padding: 16px; border: 1px dashed var(--line); border-radius: 12px; background: #fff; }

.paper-list { display: grid; gap: 10px; }
.paper-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.paper-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.paper-card { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.paper-card .paper-meta { text-align: right; color: var(--muted); font-size: 14px; }
.paper-card.is-locked { opacity: 0.6; }
.paper-card.is-locked .paper-title { text-decoration: line-through; }
.section-title { margin: 16px 0 10px; font-size: 18px; }
.count-accent { color: var(--accent); font-weight: 700; }
.mock-papers.is-collapsed .paper-card:nth-child(n+13) { display: none; }
.mock-toggle-row { margin-top: 10px; display: flex; justify-content: center; }
@media (max-width: 1100px) {
  .paper-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .paper-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .paper-grid { grid-template-columns: 1fr; }
}
.paper-title { font-weight: 700; }
.paper-season {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.link-button { background: none; border: 0; padding: 0; cursor: pointer; }

.paper-nav {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 10px;
}

.paper-progress {
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.qnav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

@media (min-width: 980px) {
  .qnav-grid { grid-template-columns: repeat(var(--qnav-cols, 13), minmax(0, 1fr)); }
}

.qnav-pill {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}

.qnav-pill.is-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.qnav-pill.is-answered {
  background: #e8f4e6;
  border-color: #cde7d3;
  color: #1c6b37;
}

.qnav-step { display: none; }
.qnav-step.is-active { display: block; }

.question-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; margin: 14px 0; font-size: 16px; position: relative; }
.q-title { font-weight: 700; }
.q-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.q-source { font-size: 12px; color: var(--muted); background: #fffdf7; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.result-header { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.q-body { margin-bottom: 10px; font-size: 20px; line-height: 1.45; }
.q-body .lang-en, .q-body .lang-zh { font-size: 20px; }
.multiline-text {
  /* Keep authored \n newlines while avoiding huge gaps from blank lines. */
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}
.q-body .lang-en, .q-body .lang-zh,
.solution-box .lang-en, .solution-box .lang-zh {
  /* Preserve authored newlines without creating huge blank blocks (pre-wrap does). */
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.q-body .text-par,
.solution-box .text-par { margin: 0; }
.q-body .text-par-gap,
.solution-box .text-par-gap { height: 4px; }
.question-card .q-body { font-size: 20px !important; line-height: 1.45 !important; }
.choice-bars .q-body { font-size: 18px !important; }
.choice-bars .q-body .lang-en, .choice-bars .q-body .lang-zh { font-size: 18px; }
.question-card img { max-width: 100%; height: auto; }

.paper-practice-all .question-card,
.diagnostic-practice .question-card {
  position: relative;
  overflow: hidden;
}

.paper-practice-all .question-card::after,
.diagnostic-practice .question-card::after {
  content: "amcdrill";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 12px 14px;
  font-size: 48px;
  letter-spacing: 4px;
  color: #cbbba4;
  opacity: 0.1;
  transform: rotate(-8deg);
  pointer-events: none;
  z-index: 0;
}

.paper-practice-all .question-card > *,
.diagnostic-practice .question-card > * {
  position: relative;
  z-index: 1;
}

.stem-images { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; align-items: flex-start; }
.stem-images img { width: auto; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.choices-block { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex; gap: 8px; align-items: center; }
.choice-text { font-size: 16px; line-height: 1.5; white-space: nowrap; overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.choice-key { font-size: 16px; font-weight: 700; flex: 0 0 auto; }
.choice-text { flex: 1 1 auto; min-width: 0; }

.paper-practice .choices-block { gap: 10px; }
.choice-bars .choices-block { gap: 10px; }

.paper-practice .choice,
.choice-bars .choice {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: #fffaf3;
  border-radius: 999px;
  align-items: center;
  max-width: 100%;
}

.choice-bars .choice:hover { background: #fffdf7; border-color: #d9cfc2; }
.choice-bars .choice input { margin-top: 0; }
.choice-bars .choice.is-long,
.choices-block .choice.is-long {
  flex: 0 0 100%;
  white-space: normal;
  border-radius: 12px;
  align-items: flex-start;
}
.choices-block .choice.is-long .choice-text { white-space: normal; }
.choice-bars .choice.is-selected {
  border-color: #f3c0b8;
  background: #fff1ef;
  box-shadow: 0 0 0 2px rgba(210, 75, 60, 0.12);
  color: #9c2a1f;
}
.choice-bars .choice.is-correct { border-color: #2e7d32; color: #1c6b37; }
.choice-bars .choice.is-selected.is-correct {
  border-color: #2e7d32;
  background: #e8f4e6;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.12);
  color: #1c6b37;
}

.paper-practice .choice {
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  transition: background 120ms ease, border-color 120ms ease;
  cursor: pointer;
  user-select: none;
  min-width: 0;
}

/* Ensure MathJax in choices can wrap instead of overflowing into neighbors. */
.choice-text mjx-container[jax="CHTML"] {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}
.choice-text mjx-container[jax="CHTML"] > span {
  white-space: normal;
}
.q-body mjx-container[jax="CHTML"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.paper-practice .choice:hover { background: #fffdf7; border-color: #d9cfc2; }
.paper-practice .choice input { margin-top: 4px; }
.paper-practice .choice.is-long { grid-column: 1 / -1; }
.paper-practice .choice.is-selected { background: #fff1ef; border-color: #f3c0b8; }
.choice-img { width: auto; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: inline-block; }
.choice-list { display: grid; gap: 8px; margin-top: 8px; }
.choice-row { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start; }

.report-issue-btn {
  border: 1px solid var(--line);
  background: #fffaf3;
  color: #8b6f4f;
  border-radius: 999px;
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1.2;
}
.report-issue-btn:hover { background: #fff3e6; }
.report-issue-options { display: grid; gap: 8px; margin-top: 10px; }
.report-issue-option { display: flex; align-items: center; gap: 8px; }
.report-issue-status { margin-top: 10px; min-height: 18px; }
.report-issue-other { display: grid; gap: 6px; margin-top: 10px; }
.report-issue-other textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  resize: vertical;
}
.result-list { display: grid; gap: 16px; }
.result-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.result-header { font-weight: 700; margin-bottom: 6px; }
.centered-images { align-items: center; justify-content: center; }

.paper-practice .reveal-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.paper-practice .answer-box,
.paper-practice .solution-box { display: none; }
.paper-practice .answer-box.is-open,
.paper-practice .solution-box.is-open { display: block; }

.paper-practice .answer-box {
  margin-top: 10px;
  padding: 10px;
  background: #fff6e8;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1.5;
  font-weight: 700;
}

.youtube-card { width: min(980px, 95vw); }
.youtube-modal-frame { margin-top: 12px; }
.youtube-modal-frame iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 12px;
  background: #000;
}
.youtube-modal-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.youtube-modal-links .youtube-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.youtube-links { margin-top: 10px; }
.youtube-open-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  color: var(--accent);
}
.youtube-open-link:hover { text-decoration: underline; }

.solution-box {
  margin-top: 10px;
  padding: 10px;
  background: #fff6e8;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 20px;
  line-height: 1.45;
  overflow-x: auto;
}
.solution-box .lang-en,
.solution-box .lang-zh { font-size: 20px; }

/* Allow long MathJax equations in solutions to scroll horizontally instead of overflowing. */
.solution-box mjx-container[jax="CHTML"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.report-summary { margin-bottom: 16px; }
.summary-title { font-weight: 700; margin: 6px 0 8px; }
.summary-table-wrap { overflow-x: auto; }
.report-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
}
.report-table th,
.report-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.report-table th { background: #fff6e8; font-weight: 700; }
.summary-row { cursor: pointer; }
.summary-row:hover { background: #faf4e9; }
.summary-total td { font-weight: 700; background: #fffaf2; }

.result-item .choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
}
.result-item .choice-row {
  display: flex;
  gap: 8px;
  align-items: start;
}
.report-email-form { margin: 8px 0 12px; }
.pdf-hidden { display: none !important; }

.score-box { padding: 10px 12px; border-radius: 8px; background: #fff6e8; border: 1px solid var(--line); margin-bottom: 10px; font-weight: 700; }
.honor-box { background: #f6fbff; border: 1px solid #cfe2f3; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; }
.honor-title { font-weight: 700; margin-bottom: 4px; }
.honor-score { font-weight: 700; }
.honor-range { color: var(--muted); margin-top: 2px; font-size: 13px; }
.honor-message { margin-top: 6px; }
.timer-box {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  margin-bottom: 10px;
}
.timer-floating {
  position: fixed;
  right: 16px;
  top: 24px;
  transform: none;
  width: auto;
  max-width: none;
  white-space: nowrap;
  text-align: center;
  z-index: 70;
  box-shadow: 0 10px 22px rgba(0,0,0,0.12);
  padding: 10px 14px;
}
.timer-floating .timer-label {
  font-size: 13px;
}
.timer-floating .timer-value {
  font-size: 18px;
  letter-spacing: 0.3px;
}
.timer-compact { gap: 0; }
.timer-label { color: var(--muted); font-weight: 600; }
.timer-value { color: var(--accent); font-weight: 700; }
@media (max-width: 980px) {
  .timer-floating {
    right: 12px;
    top: 16px;
    width: auto;
  }
}
.diag-lang-toggle { position: absolute; top: 16px; right: 16px; }
.error-box { padding: 10px 12px; border-radius: 8px; background: #fff1f0; border: 1px solid #f2c7c2; color: #9c2a1f; margin-bottom: 10px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.result-line { margin-top: 8px; font-weight: 700; color: var(--ink); }
.result-status.good { color: #1c6b37; }
.result-status.bad { color: #9c2a1f; }
.result-status.unanswered { color: var(--muted); }

/* Anti-copy: disable text selection in protected content (stems/solutions). */
.protect-copy,
.protect-copy * {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}

/* Ensure the HTML `hidden` attribute always hides elements even if component CSS sets display rules. */
[hidden] { display: none !important; }
.answer-selected,
.answer-correct { color: #1c6b37; }
.answer-unanswered { color: var(--muted); }

.image-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.image-row img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.form-actions { margin-top: 12px; }

.question-stack [data-step] { display: none; }
.question-stack [data-step].active { display: block; }
.stepper { display: flex; gap: 8px; margin-top: 12px; justify-content: space-between; }
.stepper .btn { min-width: 72px; }
.floating-nav {
  position: absolute;
  top: 58%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
}
.floating-nav.left { left: -44px; }
.floating-nav.right { right: -44px; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffaf2;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}
.submit-right { display: flex; justify-content: flex-end; }
.jump-nav { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.jump-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); background: #fff; font-weight: 600; font-size: 14px; text-decoration: none; }
.jump-pill:hover { border-color: var(--accent); color: var(--accent); }
.jump-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 6px 12px rgba(0,0,0,0.12); }

.topic-nav-top { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.topic-nav-top .jump-nav { margin-top: 0; justify-content: center; flex: 1 1 auto; }
.topic-nav-top .btn { min-width: 110px; justify-content: center; }

.sideq-layout {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  gap: 14px;
  align-items: start;
}
.sideq-main { min-width: 0; }
.side-qnav {
  position: sticky;
  top: 110px;
  align-self: start;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow: visible;
  padding: 6px 8px;
}
.qjump-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.qjump-pill:hover { border-color: var(--accent); color: var(--accent); }
.qjump-pill.status-bad {
  background: #fff1ef;
  border-color: #f3c0b8;
  color: #9c2a1f;
}
.qjump-pill.status-good {
  background: #e8f4e6;
  border-color: #cde7d3;
  color: #1c6b37;
}
.qjump-pill.is-current {
  box-shadow: 0 0 0 4px rgba(245, 200, 30, 0.72), 0 6px 14px rgba(0, 0, 0, 0.08);
  border-color: #f5c81e;
  color: #6b5200;
}
.qjump-pill.is-current.status-bad {
  box-shadow: 0 0 0 4px rgba(245, 200, 30, 0.72), 0 6px 14px rgba(0, 0, 0, 0.08);
  border-color: #f5c81e;
}
.qjump-pill.is-current.status-good {
  box-shadow: 0 0 0 4px rgba(245, 200, 30, 0.72), 0 6px 14px rgba(0, 0, 0, 0.08);
  border-color: #f5c81e;
}

@media (max-width: 980px) {
  .sideq-layout { grid-template-columns: 1fr; }
  .side-qnav { display: none; }
}

.topic-list { display: grid; gap: 10px; }
.topic-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.topic-row.is-disabled { opacity: 0.55; cursor: not-allowed; }
.topic-row[role="button"] { cursor: pointer; }
.topic-row[role="button"]:hover { border-color: #e5c3be; box-shadow: 0 8px 18px rgba(0,0,0,0.06); }
.topic-code { font-weight: 700; }
.topic-meta { color: var(--muted); }
.topic-count-bars {
  display: grid;
  grid-template-columns: repeat(3, 104px);
  gap: 10px;
  justify-content: end;
  align-items: center;
}
.topic-count-bar {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 104px;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: #1f2a37;
  font-weight: 700;
  line-height: 1;
}
button.topic-count-bar { cursor: pointer; }
button.topic-count-bar:hover { border-color: var(--accent); color: var(--accent); }
.topic-count-bar.is-zero { opacity: 0.45; }
.topic-count-num { color: var(--accent); font-weight: 800; }

@media (max-width: 860px) {
  .topic-count-bars {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topic-count-bar { width: auto; justify-content: flex-start; gap: 6px; }
}
.topic-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.topic-head-actions { display: inline-flex; align-items: center; gap: 10px; }
.topic-title { margin: 0 0 6px; }
.topic-subtitle { margin: 0; color: var(--muted); }
.q-meta { margin-top: 6px; }
.mini-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.mini-badge-good { background: #e8f4e6; border-color: #cde7d3; color: #1c6b37; }
.topic-steps { margin-top: 16px; }
.topic-practice .question-card { margin-top: 16px; }
.topic-nav-row { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }
.topic-reveal-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.answer-box { margin-top: 10px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.solution-images { margin-top: 10px; display: grid; gap: 10px; justify-items: center; }
.solution-images img { max-width: 520px; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.youtube-box { margin-top: 12px; display: grid; gap: 12px; }
.youtube-box iframe { width: 100%; max-width: 720px; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: #000; justify-self: center; }
.level-note { margin: 6px 0 12px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); background: #fff; border-radius: 999px; cursor: pointer; }
.radio-pill.is-disabled { opacity: 0.45; cursor: not-allowed; }
.radio-pill.is-disabled input { pointer-events: none; }
.radio-pill input { margin: 0; }
.radio-pill.checked { border-color: var(--accent); box-shadow: 0 6px 12px rgba(0,0,0,0.08); }

[data-content-lang="en"] .lang-zh { display: none; }
[data-content-lang="zh"] .lang-en { display: none; }

/* Practice review: hide solutions by default, reveal via JS toggle */
[data-show-solutions="0"] .solution-box { display: none; }

@media (max-width: 860px) {
  .flow-diagram { grid-template-columns: 1fr; }
  .flow-arrow { display: none; }
  .flow-step { text-align: left; }
}

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .nav { display: none; }
}

@media (max-width: 900px) {
  .floating-nav {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: space-between;
    margin: 12px 0;
  }
  .floating-nav.left,
  .floating-nav.right {
    left: auto;
    right: auto;
  }
}
