:root {
  --ink: #18231f;
  --muted: #66736d;
  --line: #dce4df;
  --surface: #ffffff;
  --canvas: #f5f7f3;
  --green: #157f5b;
  --green-dark: #0d6546;
  --green-soft: #e7f5ee;
  --blue: #2d6cdf;
  --blue-soft: #eaf1ff;
  --yellow: #f5b942;
  --yellow-dark: #b97a08;
  --yellow-soft: #fff7db;
  --red: #d94b47;
  --red-soft: #fff0ee;
  --shadow: 0 2px 0 rgba(24, 35, 31, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(45, 108, 223, 0.32);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  min-height: 72px;
  padding: 10px clamp(18px, 4vw, 64px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 0 var(--green-dark);
  font-size: 20px;
  font-weight: 900;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font-size: 16px;
}

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

.desktop-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.desktop-nav button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.desktop-nav button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.site-link {
  justify-self: end;
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.app-main {
  width: min(1180px, calc(100% - 36px));
  min-height: calc(100vh - 170px);
  margin: 0 auto;
  padding: 34px 0 64px;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}

.home-main,
.home-aside,
.page-stack {
  min-width: 0;
}

.home-aside {
  position: sticky;
  top: 100px;
  display: grid;
  gap: 16px;
}

.welcome-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 28px;
  border: 1px solid #d7e1db;
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(231, 245, 238, 0.88), rgba(255, 255, 255, 0.94)),
    var(--surface);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.welcome-band h1,
.page-heading h1,
.result-panel h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.12;
}

.welcome-band p:not(.eyebrow),
.page-heading p,
.result-panel > p {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.continue-button,
.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 46px;
  padding: 0 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}

.continue-button,
.primary-button {
  border: 1px solid var(--green-dark);
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 0 var(--green-dark);
}

.continue-button:hover,
.primary-button:hover {
  background: #198b64;
}

.continue-button:active,
.primary-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--green-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.danger-button {
  border: 1px solid #efc0bd;
  background: var(--red-soft);
  color: #a92d2a;
}

.text-button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--blue);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0 24px;
}

.stat-tile {
  min-height: 90px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat-tile strong {
  display: block;
  font-size: 25px;
}

.stat-tile span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.unit-banner {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) 94px;
  gap: 16px;
  align-items: center;
  padding: 20px 22px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.unit-banner button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.unit-banner button:disabled {
  cursor: default;
  opacity: 0.34;
}

.unit-copy {
  min-width: 0;
  text-align: center;
}

.unit-copy small {
  color: #b8c7c0;
  font-weight: 800;
}

.unit-copy h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.unit-copy p {
  margin: 5px 0 0;
  color: #dbe5df;
  font-size: 13px;
}

.learning-path {
  position: relative;
  width: min(720px, 100%);
  margin: 14px auto 0;
  padding: 14px 0 26px;
}

.learning-path::before {
  position: absolute;
  top: 30px;
  bottom: 50px;
  left: 50%;
  width: 5px;
  border-radius: 99px;
  background: #d7dfda;
  content: "";
  transform: translateX(-50%);
}

.level-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px minmax(0, 1fr);
  align-items: center;
  min-height: 112px;
}

.level-row:nth-child(odd) .level-detail {
  grid-column: 1;
  text-align: right;
}

.level-row:nth-child(even) .level-detail {
  grid-column: 3;
}

.level-row:nth-child(odd) .level-node,
.level-row:nth-child(even) .level-node {
  grid-column: 2;
}

.level-detail {
  grid-row: 1;
  min-width: 0;
  padding: 12px 16px;
}

.level-detail strong,
.level-detail span {
  display: block;
}

.level-detail strong {
  font-size: 16px;
}

.level-detail span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.level-node {
  position: relative;
  z-index: 2;
  grid-row: 1;
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  justify-self: center;
  border: 2px solid #9daaa3;
  border-radius: 50%;
  background: #c6cfca;
  color: #fff;
  cursor: not-allowed;
  box-shadow: 0 5px 0 #9daaa3;
  font-size: 16px;
  font-weight: 900;
}

.level-node.unlocked {
  border-color: var(--green-dark);
  background: var(--green);
  box-shadow: 0 5px 0 var(--green-dark);
  cursor: pointer;
}

.level-node.completed {
  border-color: var(--yellow-dark);
  background: var(--yellow);
  color: #3c2a00;
  box-shadow: 0 5px 0 var(--yellow-dark);
  cursor: pointer;
}

.level-node.current::after {
  position: absolute;
  inset: -9px;
  border: 3px solid rgba(45, 108, 223, 0.38);
  border-radius: 50%;
  content: "";
}

.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel h2,
.panel h3 {
  margin: 0;
}

.panel h2 {
  font-size: 20px;
}

.panel h3 {
  font-size: 16px;
}

.panel p {
  color: var(--muted);
  line-height: 1.6;
}

.overall-meter,
.thin-meter,
.quiz-progress {
  overflow: hidden;
  border-radius: 99px;
  background: #e8eeea;
}

.overall-meter {
  height: 14px;
  margin: 16px 0 8px;
}

.thin-meter {
  height: 9px;
}

.overall-meter > span,
.thin-meter > span,
.quiz-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.meter-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.aside-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.aside-actions button {
  width: 100%;
}

.bank-breakdown {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.bank-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.bank-row span {
  color: var(--muted);
}

.page-stack {
  display: grid;
  gap: 22px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

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

.search-field {
  width: min(420px, 100%);
  height: 46px;
  padding: 0 15px;
  border: 1px solid #bfcac4;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.mistake-list {
  display: grid;
  gap: 12px;
}

.mistake-item {
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  background: var(--surface);
}

.item-meta,
.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag {
  padding: 4px 8px;
  border-radius: 99px;
  background: var(--blue-soft);
  color: var(--blue);
}

.mistake-item h3 {
  margin: 12px 0 10px;
  font-size: 17px;
  line-height: 1.55;
}

.answer-review {
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.6;
}

.empty-state {
  padding: 56px 24px;
  border: 1px dashed #b9c6bf;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
}

.empty-state strong {
  display: block;
  font-size: 22px;
}

.empty-state p {
  color: var(--muted);
}

.quiz-shell {
  width: min(840px, 100%);
  margin: 0 auto;
  animation: quiz-enter 180ms ease-out;
  position: relative;
  overflow: hidden;
}

.quiz-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.close-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  font-size: 22px;
}

.quiz-progress {
  height: 15px;
}

.heart-bar {
  display: flex;
  gap: 5px;
}

.heart-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d6deda;
}

.heart-dot.active {
  background: var(--red);
}

.question-panel {
  margin-top: 28px;
}

.question-panel h1 {
  margin: 16px 0 0;
  font-size: clamp(23px, 3vw, 33px);
  line-height: 1.52;
}

.multi-hint {
  margin: 14px 0 0;
  color: #815a00;
  font-size: 14px;
  font-weight: 700;
}

.answer-options {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.answer-option {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 74px;
  padding: 12px 16px;
  border: 2px solid #d4ddd8;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 #c4cec8;
  text-align: left;
}

.answer-option:hover {
  border-color: #9fb1a8;
}

.option-key {
  display: grid;
  min-width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 7px;
  background: #edf1ef;
  font-weight: 900;
}

.option-text {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.55;
}

.answer-option.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 3px 0 #a9c5f4;
}

.answer-option.selected .option-key {
  background: var(--blue);
  color: #fff;
}

.answer-option.correct {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 3px 0 #9acfb9;
}

.answer-option.correct .option-key {
  background: var(--green);
  color: #fff;
}

.answer-option.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  box-shadow: 0 3px 0 #efb0ac;
}

.answer-option.wrong .option-key {
  background: var(--red);
  color: #fff;
}

.quiz-feedback {
  margin-top: 20px;
  padding: 18px 20px;
  border-radius: 8px;
}

.quiz-feedback.correct {
  border: 1px solid #9fcdb9;
  background: var(--green-soft);
}

.quiz-feedback.wrong {
  border: 1px solid #efb7b3;
  background: var(--red-soft);
}

.quiz-feedback strong,
.quiz-feedback span {
  display: block;
}

.quiz-feedback strong {
  font-size: 18px;
}

.quiz-feedback span {
  margin-top: 8px;
  line-height: 1.6;
}

.feedback-extra {
  color: #1a5d47;
  font-weight: 800;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.confetti-piece {
  position: absolute;
  opacity: 0;
  animation-fill-mode: forwards;
  --drift: 0px;
  --travel: 100vh;
  --spin: 360deg;
}

@keyframes confetti-fall {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translate(var(--drift), var(--travel)) rotate(var(--spin));
    opacity: 0;
  }
}

.quiz-actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.keyboard-note {
  color: var(--muted);
  font-size: 13px;
}

.auto-next {
  color: #5a665f;
  font-size: 13px;
  font-weight: 800;
}

.quiz-actionbar .primary-button {
  min-width: 180px;
}

.answer-option {
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

.quiz-feedback {
  animation: feedback-pop 180ms ease-out;
}

@keyframes quiz-enter {
  from {
    transform: translateY(8px);
    opacity: 0.82;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes feedback-pop {
  from {
    transform: translateY(6px);
    opacity: 0.7;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.result-panel {
  width: min(760px, 100%);
  margin: 28px auto 0;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.result-score {
  display: grid;
  width: 152px;
  height: 152px;
  margin: 0 auto 26px;
  place-items: center;
  border: 10px solid var(--green-soft);
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  box-shadow: 0 7px 0 var(--green-dark);
}

.result-score.failed {
  border-color: var(--red-soft);
  background: var(--red);
  box-shadow: 0 7px 0 #a9322f;
}

.result-score strong {
  font-size: 45px;
}

.result-score span {
  margin-top: -26px;
  font-size: 13px;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 28px 0;
}

.result-summary div {
  padding: 18px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-summary strong,
.result-summary span {
  display: block;
}

.result-summary strong {
  font-size: 24px;
}

.result-summary span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.domain-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.domain-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.domain-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 800;
}

.domain-label span:last-child {
  color: var(--muted);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.history-table th,
.history-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

.history-table th {
  color: var(--muted);
  font-size: 12px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.mobile-nav {
  display: none;
}

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 28px;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 7px;
  background: rgba(24, 35, 31, 0.94);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

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

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

  .desktop-nav {
    display: none;
  }

  .home-layout {
    grid-template-columns: 1fr;
  }

  .home-aside {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-link {
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 62px;
    padding: 8px 16px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-copy small,
  .site-link {
    display: none;
  }

  .app-main {
    width: min(100% - 24px, 1180px);
    padding: 20px 0 88px;
  }

  .welcome-band {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .continue-button {
    width: 100%;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-tile {
    min-height: 82px;
  }

  .unit-banner {
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    gap: 8px;
    padding: 17px 12px;
  }

  .unit-banner button {
    padding: 0 6px;
    font-size: 11px;
  }

  .unit-copy h2 {
    font-size: 19px;
  }

  .unit-copy p {
    display: none;
  }

  .level-row {
    grid-template-columns: minmax(0, 1fr) 70px minmax(0, 1fr);
    min-height: 105px;
  }

  .level-detail {
    padding: 8px 10px;
  }

  .level-detail strong {
    font-size: 14px;
  }

  .level-detail span {
    font-size: 11px;
  }

  .level-node {
    width: 60px;
    height: 60px;
  }

  .home-aside {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .heading-actions button {
    padding: 0 10px;
  }

  .question-panel {
    padding: 20px;
  }

  .quiz-top {
    gap: 10px;
  }

  .heart-dot {
    width: 10px;
    height: 10px;
  }

  .answer-option {
    grid-template-columns: 42px minmax(0, 1fr);
    min-height: 70px;
    padding: 10px 12px;
  }

  .option-text {
    font-size: 15px;
  }

  .quiz-actionbar {
    align-items: stretch;
    flex-direction: column;
  }

  .quiz-actionbar .primary-button {
    width: 100%;
  }

  .keyboard-note {
    display: none;
  }

  .result-panel {
    padding: 28px 18px;
  }

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

  .result-summary strong {
    font-size: 19px;
  }

  .result-actions {
    display: grid;
  }

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

  .history-table th:nth-child(1),
  .history-table td:nth-child(1) {
    display: none;
  }

  .site-footer {
    display: block;
    width: min(100% - 24px, 1180px);
    padding-bottom: 92px;
  }

  .site-footer span {
    display: block;
    margin-top: 5px;
  }

  .mobile-nav {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 7px 12px max(7px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
  }

  .mobile-nav button {
    min-height: 45px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-nav button.active {
    background: var(--green-soft);
    color: var(--green-dark);
  }

  .toast {
    bottom: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
