:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #687381;
  --line: #dbe2ea;
  --panel: #ffffff;
  --soft: #fff4e6;
  --accent: #e97829;
  --accent-dark: #b64d13;
  --green: #123f37;
  --gold: #f4b94f;
  --bad: #b42318;
  --good: #057a55;
  --shadow: 0 22px 65px rgba(31, 47, 70, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(244, 185, 79, 0.32), transparent 32%),
    linear-gradient(135deg, rgba(255, 248, 238, 0.98), rgba(242, 249, 240, 0.92)),
    #fff8ee;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 48px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: stretch;
}

.test-panel,
.side-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(234, 143, 63, 0.24);
  box-shadow: var(--shadow);
}

.test-panel {
  min-height: 680px;
  padding: clamp(22px, 4vw, 46px);
  border-radius: 8px;
}

.side-panel {
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-row,
.question-topline,
.result-grid,
.progress-header,
.metric-row,
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-row {
  margin-bottom: 28px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  margin-bottom: 28px;
  color: var(--green);
  text-decoration: none;
}

.site-brand span {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(18, 63, 55, 0.18);
  border-radius: 50%;
  background: #fff;
}

.site-brand img {
  width: 88%;
  height: 88%;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.85rem, 4vw, 3rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.2;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.lead {
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.8;
  max-width: 650px;
}

.cefr-badge {
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(233, 120, 41, 0.5);
  color: var(--accent-dark);
  border-radius: 50%;
  font-weight: 800;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(240px, 0.75fr);
  gap: 28px;
  align-items: start;
}

.student-form {
  margin-top: 24px;
  display: grid;
  gap: 14px;
  max-width: 520px;
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 0.95rem;
  font-weight: 700;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.consent-row {
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.6;
}

.consent-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

input,
select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.primary-action,
.ghost-action {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  color: #231904;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  box-shadow: 0 14px 28px rgba(185, 91, 20, 0.16);
}

.primary-action:hover {
  background: linear-gradient(135deg, #f7c45a, var(--accent-dark));
}

.primary-action:disabled {
  cursor: not-allowed;
  background: #9ab8b5;
}

.ghost-action {
  color: var(--green);
  background: #fff4e6;
}

.ghost-action:hover {
  background: #ffe7c9;
}

.level-map {
  display: grid;
  gap: 10px;
}

.level-card {
  display: grid;
  grid-template-columns: 66px 1fr;
  align-items: center;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  overflow: hidden;
}

.level-card span {
  height: 100%;
  display: grid;
  place-items: center;
  background: #ffe4c5;
  color: var(--accent-dark);
  font-size: 1.1rem;
  font-weight: 900;
}

.level-card strong {
  padding: 0 14px;
  font-size: 0.98rem;
}

.question-count {
  min-width: 82px;
  padding: 10px 12px;
  text-align: center;
  border-radius: 6px;
  background: var(--soft);
  font-weight: 900;
}

.question-card {
  margin-top: 20px;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-text {
  margin-bottom: 22px;
  font-size: clamp(1.18rem, 2.3vw, 1.55rem);
  line-height: 1.55;
  font-weight: 800;
}

.options {
  display: grid;
  gap: 12px;
}

.option-button {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.option-button:hover {
  border-color: var(--accent);
  background: #f6fbfa;
}

.option-button.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.option-button.correct {
  border-color: var(--good);
  background: #edfdf7;
}

.option-button.wrong {
  border-color: var(--bad);
  background: #fff1f0;
}

.option-key {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  font-weight: 900;
}

.feedback-bar {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  color: #1f2937;
  background: #fff7e6;
  line-height: 1.6;
}

.controls-row {
  margin-top: 18px;
}

.progress-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.progress-header span,
.metric-row span {
  color: var(--muted);
}

.progress-header strong {
  font-size: 2.1rem;
  color: var(--green);
}

.progress-track {
  position: relative;
  height: 10px;
  margin: 14px 2px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f6c55f, #e97829, #c75b1c, #0e756b, #123f37, #3b2f2a);
}

.level-marker {
  position: absolute;
  top: 50%;
  left: var(--position);
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--green);
  transform: translate(-50%, -50%);
  box-shadow: 0 6px 14px rgba(23, 33, 43, 0.2);
}

.track-labels {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  color: var(--muted);
  font-size: 0.68rem;
}

.track-labels span {
  text-align: center;
}

.metric-row {
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.metric-row:last-child {
  border-bottom: 0;
}

.metric-row strong {
  color: var(--ink);
}

.compact p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.result-heading {
  margin-bottom: 18px;
}

.result-grid {
  align-items: stretch;
}

.result-score {
  flex: 1;
  min-height: 180px;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #fff4e6, #f2fbf9);
}

.result-score span {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: clamp(3.2rem, 8vw, 5.2rem);
  line-height: 0.95;
  font-weight: 900;
}

.result-score strong {
  display: block;
  margin-bottom: 10px;
  font-size: 1.25rem;
}

.result-score p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.sync-status {
  margin: 14px 0 0;
  border: 1px solid rgba(233, 120, 41, 0.24);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--green);
  background: #fff8ee;
  font-size: 0.92rem;
  font-weight: 800;
}

.result-actions {
  width: 170px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.recommendation-panel,
.report-panel,
.history-panel {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.recommendation-panel ul {
  margin: 0;
  padding-left: 20px;
  color: #334155;
  line-height: 1.8;
}

.report-toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}

.report-toolbar h3 {
  margin-bottom: 0;
}

.report-toolbar label {
  font-size: 0.86rem;
}

#result-report {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: #243244;
  background: #fbfdfd;
  line-height: 1.7;
}

.answer-history {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-pill {
  min-width: 52px;
  padding: 7px 9px;
  border-radius: 999px;
  color: #fff;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
}

.history-pill.correct {
  background: var(--good);
}

.history-pill.wrong {
  background: var(--bad);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: -1;
  }

  .intro-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-actions {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .report-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin: 10px auto;
  }

  .test-panel,
  .side-panel {
    padding: 14px;
  }

  .brand-row,
  .question-topline,
  .controls-row {
    align-items: stretch;
    flex-direction: column;
  }

  .cefr-badge {
    width: 56px;
    height: 56px;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .side-panel,
  .controls-row,
  .result-actions,
  #intro-screen,
  #question-screen {
    display: none !important;
  }

  .app-shell {
    display: block;
    width: 100%;
    margin: 0;
  }

  .test-panel {
    min-height: auto;
    box-shadow: none;
    border: 0;
  }
}
