:root {
  --ink: #17332a;
  --muted: #65766f;
  --line: #dce8e0;
  --green: #2e7d5b;
  --green-dark: #1e5c43;
  --green-soft: #eaf5ee;
  --cream: #fbf8ef;
  --gold: #d8a536;
  --white: #ffffff;
  --red: #c94d4d;
  --shadow: 0 22px 70px rgba(26, 72, 54, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: #f6f7f2;
  color: var(--ink);
  font-family: "Times New Roman", Times, serif;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

button, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.data-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .8);
  color: var(--green-dark);
  font-weight: 800;
  cursor: pointer;
}

dialog {
  width: min(520px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  box-shadow: 0 24px 90px rgba(15, 52, 38, .28);
}

dialog::backdrop {
  background: rgba(15, 39, 29, .45);
  backdrop-filter: blur(4px);
}

.dialog-card {
  position: relative;
  padding: 34px;
  background: white;
}

.dialog-card h2 {
  margin: 9px 0 12px;
  font-family: "Times New Roman", Times, serif;
  font-size: 28px;
  font-weight: 500;
}

.dialog-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.65;
}

.dialog-card small {
  display: block;
  margin-top: 20px;
  color: #84918b;
  line-height: 1.5;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #eef4ef;
  color: var(--green-dark);
  font-size: 22px;
  cursor: pointer;
}

.upload-button {
  min-height: 52px;
  margin-bottom: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--green);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.upload-button input { display: none; }
.wide { width: 100%; }

.danger-link {
  width: 100%;
  margin-top: 15px;
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 800;
  cursor: pointer;
}

.site-shell, .quiz-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 84% 12%, rgba(201, 228, 210, .72), transparent 28%),
    linear-gradient(135deg, #f8f9f4 0%, #f2f7f2 100%);
}

.topbar, .quiz-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand > div { display: flex; flex-direction: column; gap: 2px; }
.brand strong { font-size: 18px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--green);
  color: white;
  font-family: "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Arial, sans-serif;
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(46, 125, 91, .22);
}
.brand.compact .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; }

.online-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}
.online-badge i { width: 8px; height: 8px; border-radius: 50%; background: #43a56f; box-shadow: 0 0 0 4px #dcf0e3; }

.hero {
  width: min(1180px, calc(100% - 40px));
  margin: 28px auto 0;
  min-height: calc(100vh - 170px);
  display: grid;
  grid-template-columns: .95fr 1.05fr;
  align-items: center;
  gap: 80px;
  padding: 42px 0 72px;
}

.eyebrow, .step-label {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
}

.hero-copy h1 {
  margin: 18px 0 22px;
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(52px, 6vw, 82px);
  line-height: .98;
  letter-spacing: normal;
  font-weight: 700;
}
.hero-copy h1 em { color: var(--green); font-style: italic; }
.hero-copy > p { max-width: 500px; color: var(--muted); font-size: 18px; line-height: 1.7; }

.hero-stats { display: flex; gap: 42px; margin-top: 40px; }
.hero-stats div { display: flex; flex-direction: column; gap: 4px; }
.hero-stats strong { font-family: "Times New Roman", Times, serif; font-size: 26px; }
.hero-stats span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .09em; }

.setup-card {
  position: relative;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(206, 224, 212, .9);
  border-radius: 28px;
  padding: 36px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.card-heading h2 { margin: 8px 0 0; font-family: "Times New Roman", Times, serif; font-size: 27px; font-weight: 600; }
.card-number { color: #dae6dd; font-family: "Times New Roman", Times, serif; font-size: 54px; line-height: 1; }

.field { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.field label { font-size: 13px; font-weight: 800; color: #344b42; }
.two-column { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  background: #f5f8f5;
  border-radius: 14px;
}
.segmented button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.segmented button.selected {
  color: white;
  background: var(--green);
  box-shadow: 0 5px 14px rgba(46, 125, 91, .22);
}

.select-wrap { position: relative; }
.select-wrap::after {
  content: "⌄";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-54%);
  color: var(--green);
  pointer-events: none;
  font-weight: 800;
}
select, input {
  width: 100%;
  min-height: 54px;
  appearance: none;
  padding: 0 44px 0 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  outline: none;
}
input { padding: 0 16px; font-weight: 500; }
select:focus, input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(46, 125, 91, .1); outline: none; }

.set-note {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin: 0 0 22px;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--green-soft);
  color: #3b6251;
}
.set-note > span { display: grid; place-items: center; flex: 0 0 22px; height: 22px; border-radius: 50%; background: var(--green); color: white; font-size: 12px; }
.set-note p { margin: 0; font-size: 12px; line-height: 1.55; }

.primary-button, .secondary-button {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 13px;
  font-weight: 800;
  border: 0;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.primary-button { color: white; background: var(--green); box-shadow: 0 10px 24px rgba(46, 125, 91, .2); }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.secondary-button { color: var(--green-dark); background: white; border: 1px solid var(--line); }
.secondary-button:hover { border-color: var(--green); }
.secondary-button:disabled { opacity: .4; cursor: not-allowed; }
.start-button { width: 100%; display: flex; justify-content: center; align-items: center; gap: 16px; }
.start-button span { font-size: 21px; }

.home-footer {
  width: min(1180px, calc(100% - 40px));
  margin: -30px auto 0;
  padding-bottom: 24px;
  display: flex;
  justify-content: center;
  gap: 10px;
  color: #85938d;
  font-size: 12px;
}

.center-screen { min-height: 100vh; display: grid; place-content: center; text-align: center; background: #f5f8f4; }
.loader { width: 46px; height: 46px; margin: auto; border-radius: 50%; border: 4px solid #dceadf; border-top-color: var(--green); animation: spin .8s linear infinite; }
.loading-text { color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { width: min(420px, calc(100vw - 32px)); padding: 36px; border-radius: 24px; background: white; box-shadow: var(--shadow); }
.error-card .brand-mark { margin: auto; }
.error-card h1 { font-family: "Times New Roman", Times, serif; font-size: 25px; }
.error-card p { color: var(--muted); margin-bottom: 24px; }

.quiz-page { padding-bottom: 70px; }
.quiz-header { min-height: 74px; border-bottom: 1px solid rgba(217, 229, 220, .8); }
.text-button { border: 0; background: transparent; color: var(--green); font-weight: 800; cursor: pointer; }
.quiz-title { text-align: center; display: flex; flex-direction: column; gap: 3px; }
.quiz-title small { color: var(--muted); }
.question-count { min-width: 54px; text-align: center; padding: 8px 10px; border-radius: 11px; background: var(--green-soft); color: var(--green-dark); font-weight: 800; }
.header-spacer { width: 74px; }
.progress-track { height: 4px; background: #dce8df; }
.progress-track div { height: 100%; background: linear-gradient(90deg, var(--green), #65aa76); transition: width .25s ease; }

.question-stage { width: min(760px, calc(100% - 32px)); margin: 48px auto 0; }
.question-topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.type-chip { padding: 8px 11px; border-radius: 99px; letter-spacing: normal; }
.type-chip.vocab { color: #37614e; background: #e2f0e7; }
.type-chip.grammar { color: #7d5b13; background: #fff2ca; }

.question-card {
  padding: clamp(25px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: white;
  box-shadow: var(--shadow);
}
.topic-label { color: var(--muted); font-size: 12px; }
.question-card h1 {
  min-height: 86px;
  margin: 22px 0 40px;
  display: flex;
  align-items: center;
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(30px, 7vw, 46px);
  line-height: 1.25;
  font-weight: 500;
  letter-spacing: normal;
}
.question-card label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 800; }
.question-card textarea {
  width: 100%;
  resize: vertical;
  min-height: 112px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #fbfdfb;
  font-size: 18px;
  outline: none;
}
.answer-help { margin: 10px 0 0; color: #8a9791; font-size: 11px; }

.question-dots { display: flex; gap: 7px; overflow-x: auto; padding: 18px 2px 10px; scrollbar-width: thin; }
.question-dots button {
  flex: 0 0 35px;
  height: 35px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.question-dots button.answered { background: var(--green-soft); color: var(--green-dark); border-color: #b8d6c1; }
.question-dots button.active { background: var(--green); color: white; border-color: var(--green); }

.navigation-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.submit-button { background: #b48423; box-shadow: 0 10px 24px rgba(180, 132, 35, .22); }
.submit-button:hover { background: #936a17; }

.result-hero {
  width: min(900px, calc(100% - 40px));
  margin: 45px auto 32px;
  padding: 34px 40px;
  display: flex;
  align-items: center;
  gap: 32px;
  border-radius: 26px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.result-hero h1 { margin: 8px 0; font-family: "Times New Roman", Times, serif; font-size: clamp(28px, 5vw, 40px); font-weight: 600; }
.result-hero p { margin: 0; color: var(--muted); }
.score-ring {
  flex: 0 0 126px;
  height: 126px;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 75%, #e5eee8 75%);
  box-shadow: inset 0 0 0 12px white;
}
.score-ring strong { font-family: "Times New Roman", Times, serif; font-size: 38px; line-height: 1; }
.score-ring span { font-size: 11px; color: var(--muted); }
.score-ring.great { background: conic-gradient(#2e7d5b 0 88%, #e5eee8 88%); }
.score-ring.okay { background: conic-gradient(#d39a2b 0 62%, #eee9dc 62%); }
.score-ring.needs-work { background: conic-gradient(#c95e51 0 35%, #f0e5e2 35%); }

.review-list { width: min(900px, calc(100% - 40px)); margin: 0 auto; }
.review-heading { display: flex; justify-content: space-between; align-items: end; margin: 36px 2px 18px; }
.review-heading h2 { margin: 7px 0 0; font-family: "Times New Roman", Times, serif; font-size: 28px; font-weight: 600; }
.result-legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.correct-dot, .wrong-dot { width: 9px; height: 9px; border-radius: 50%; margin-left: 8px; }
.correct-dot { background: var(--green); }
.wrong-dot { background: var(--red); }
.review-card {
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr 34px;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
  padding: 22px;
  border-radius: 18px;
  background: white;
  border: 1px solid var(--line);
}
.review-card.wrong { border-left: 4px solid var(--red); }
.review-card.correct { border-left: 4px solid var(--green); }
.review-index { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #eff4f0; font-weight: 800; }
.question-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.question-meta span { color: var(--green); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.question-meta small { color: var(--muted); }
.review-content h3 { margin: 10px 0 15px; font-family: "Times New Roman", Times, serif; font-size: 22px; font-weight: 500; letter-spacing: normal; }

.han-text {
  font-family: "Microsoft YaHei", "Noto Sans SC", "PingFang SC", "SimSun", sans-serif !important;
}
.answer-lines { display: grid; gap: 8px; }
.answer-lines p { margin: 0; display: grid; grid-template-columns: 105px 1fr; gap: 12px; font-size: 13px; }
.answer-lines p span { color: var(--muted); }
.answer-lines p strong { word-break: break-word; }
.result-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-size: 18px; font-weight: 800; }
.correct .result-icon { color: var(--green); background: var(--green-soft); }
.wrong .result-icon { color: var(--red); background: #f9eaea; }
.result-actions { width: min(900px, calc(100% - 40px)); margin: 26px auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding-top: 18px; }
  .hero-copy { text-align: center; }
  .hero-copy > p { margin-left: auto; margin-right: auto; }
  .hero-stats { justify-content: center; }
  .home-footer { margin-top: 0; }
}

@media (max-width: 600px) {
  .topbar, .quiz-header { width: calc(100% - 28px); min-height: 66px; }
  .brand small, .online-badge { display: none; }
  .data-button { min-height: 38px; padding: 0 12px; font-size: 12px; }
  .dialog-card { padding: 28px 20px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 19px; }
  .hero { width: calc(100% - 24px); margin-top: 0; padding: 26px 0 54px; gap: 30px; }
  .hero-copy h1 { margin-top: 12px; font-size: 47px; }
  .hero-copy > p { font-size: 15px; line-height: 1.6; }
  .hero-stats { gap: 26px; margin-top: 26px; }
  .hero-stats strong { font-size: 23px; }
  .setup-card { border-radius: 22px; padding: 23px 18px; }
  .card-heading { margin-bottom: 23px; }
  .card-heading h2 { font-size: 23px; }
  .card-number { display: none; }
  .level-options { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
  .two-column { grid-template-columns: 1fr; gap: 0; }
  .field { margin-bottom: 18px; }
  .home-footer { display: none; }
  .quiz-title strong { font-size: 13px; }
  .quiz-title small { font-size: 10px; }
  .text-button { font-size: 12px; }
  .question-count { font-size: 12px; min-width: 47px; }
  .question-stage { margin-top: 25px; }
  .question-card { padding: 25px 19px; border-radius: 21px; }
  .question-card h1 { min-height: 72px; margin: 18px 0 30px; font-size: 32px; }
  .question-card textarea { font-size: 17px; }
  .navigation-buttons { position: sticky; bottom: 8px; z-index: 10; padding: 8px; margin-left: -8px; margin-right: -8px; border-radius: 16px; background: rgba(246, 247, 242, .92); backdrop-filter: blur(10px); }
  .navigation-buttons button { padding: 0 10px; font-size: 13px; }
  .result-hero { width: calc(100% - 24px); margin-top: 26px; padding: 25px 20px; flex-direction: column; text-align: center; gap: 18px; }
  .score-ring { flex-basis: 108px; width: 108px; height: 108px; }
  .review-list, .result-actions { width: calc(100% - 24px); }
  .review-heading { align-items: start; }
  .result-legend { display: none; }
  .review-card { grid-template-columns: 33px 1fr 28px; padding: 17px 13px; gap: 10px; }
  .review-index { width: 31px; height: 31px; }
  .review-content h3 { font-size: 20px; }
  .answer-lines p { grid-template-columns: 1fr; gap: 3px; }
  .result-actions { position: sticky; bottom: 8px; z-index: 10; padding: 8px; border-radius: 16px; background: rgba(246, 247, 242, .94); backdrop-filter: blur(10px); }
  .result-actions button { padding: 0 10px; font-size: 13px; }
}
