:root {
  --ink: #17201d;
  --muted: #5a6660;
  --soft: #edf3ef;
  --paper: #fbfcf8;
  --line: rgba(23, 32, 29, 0.12);
  --green: #23835f;
  --green-deep: #126244;
  --blue: #2f6fa8;
  --amber: #b77713;
  --coral: #c6503d;
  --surface: rgba(255, 255, 255, 0.82);
  --shadow: 0 18px 50px rgba(24, 35, 31, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(90deg, rgba(47, 111, 168, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(35, 131, 95, 0.07) 1px, transparent 1px),
    radial-gradient(circle at 12% 16%, rgba(199, 80, 61, 0.1), transparent 26%),
    radial-gradient(circle at 82% 12%, rgba(183, 119, 19, 0.12), transparent 28%),
    #f6f7f0;
  background-size: 36px 36px, 36px 36px, auto, auto, auto;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 22px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: white;
  font-weight: 850;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: 0 12px 26px rgba(18, 98, 68, 0.22);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.38;
  letter-spacing: 0;
}

.student-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(24, 35, 31, 0.06);
  color: var(--muted);
  white-space: nowrap;
}

.student-strip strong {
  color: var(--coral);
  font-size: 21px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(620px, 1.25fr);
  gap: 18px;
  align-items: start;
}

.map-panel,
.trainer-panel,
.course-rail,
.question-card,
.feedback-panel,
.variants-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.map-panel,
.trainer-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head.compact {
  align-items: center;
  margin-bottom: 12px;
}

.source-note,
#mistakeTag {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.grade-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.tab,
.ghost-button,
.secondary-button,
.primary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.tab,
.ghost-button,
.secondary-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.tab:hover,
.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.tab.is-active {
  color: white;
  border-color: transparent;
  background: var(--green-deep);
}

.chapter-grid {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 205px);
  overflow: auto;
  padding-right: 4px;
}

.chapter-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  overflow: hidden;
}

.chapter-button {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  border: 0;
  background: transparent;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.chapter-index {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: white;
  font-weight: 840;
  background: var(--blue);
}

.chapter-card[data-grade="6"] .chapter-index {
  background: var(--green);
}

.chapter-title {
  margin: 0 0 5px;
  font-size: 16px;
  font-weight: 820;
}

.chapter-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.chapter-score {
  color: var(--amber);
  font-weight: 820;
}

.chapter-details {
  display: none;
  padding: 0 12px 12px 68px;
}

.chapter-card.is-open .chapter-details {
  display: block;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  background: var(--soft);
}

.exam-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.exam-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  font-size: 13px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

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

.trainer-panel {
  display: grid;
  gap: 16px;
}

.trainer-visual {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(47, 111, 168, 0.18);
  border-radius: 8px;
  height: 170px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(237, 243, 239, 0.88)),
    linear-gradient(90deg, rgba(47, 111, 168, 0.08) 1px, transparent 1px);
  background-size: auto, 28px 28px;
}

#masteryCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.trainer-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
}

.course-rail,
.question-card,
.feedback-panel,
.variants-panel {
  padding: 14px;
  box-shadow: 0 10px 28px rgba(24, 35, 31, 0.06);
}

.level-meter {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.meter-copy {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.meter-copy strong {
  color: var(--green-deep);
}

.meter-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 32, 29, 0.1);
}

.meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
  transition: width 240ms ease;
}

.streak-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0;
  min-height: 52px;
  padding: 12px;
  border-radius: 8px;
  color: var(--muted);
  background: #17201d;
}

.streak-box strong {
  color: #f8f5e8;
  font-size: 24px;
}

.point-list {
  display: grid;
  gap: 8px;
}

.point-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  font-size: 13px;
}

.point-item.is-current {
  color: var(--ink);
  border-color: rgba(35, 131, 95, 0.42);
  background: rgba(35, 131, 95, 0.1);
}

.point-badge {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 8px;
  color: white;
  font-weight: 820;
  background: var(--green);
}

.point-lock {
  color: var(--muted);
  font-size: 12px;
}

.question-stage {
  display: grid;
  gap: 12px;
}

.question-card {
  min-height: 300px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.question-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green-deep);
  background: rgba(35, 131, 95, 0.12);
  font-size: 13px;
  font-weight: 720;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.option {
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  text-align: left;
  cursor: pointer;
}

.option.is-selected {
  border-color: var(--blue);
  background: rgba(47, 111, 168, 0.12);
}

.option.is-correct {
  border-color: var(--green);
  background: rgba(35, 131, 95, 0.13);
}

.option.is-wrong {
  border-color: var(--coral);
  background: rgba(198, 80, 61, 0.12);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button {
  min-width: 132px;
  color: white;
  border-color: transparent;
  background: var(--green-deep);
}

.secondary-button {
  min-width: 112px;
}

.feedback-panel {
  display: grid;
  gap: 8px;
  min-height: 98px;
}

.feedback-state {
  font-weight: 830;
  font-size: 18px;
}

.feedback-detail {
  color: var(--muted);
  line-height: 1.58;
}

.feedback-panel.good {
  border-color: rgba(35, 131, 95, 0.36);
}

.feedback-panel.need-work {
  border-color: rgba(198, 80, 61, 0.34);
}

.variant-list {
  display: grid;
  gap: 8px;
}

.variant-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  line-height: 1.42;
}

.variant-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  min-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 8px;
  color: #f8f5e8;
  background: rgba(18, 98, 68, 0.94);
  box-shadow: 0 18px 50px rgba(24, 35, 31, 0.24);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  text-align: center;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.pulse {
  animation: pulse 420ms ease;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.018);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 1120px) {
  .workspace,
  .trainer-layout {
    grid-template-columns: 1fr;
  }

  .chapter-grid {
    max-height: none;
  }

  .course-rail {
    order: 2;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .student-strip,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .student-strip {
    white-space: normal;
  }

  .options {
    grid-template-columns: 1fr;
  }

  .chapter-button {
    grid-template-columns: 38px 1fr;
  }

  .chapter-score {
    grid-column: 2;
  }

  .chapter-details {
    padding-left: 12px;
  }
}
