:root {
  color-scheme: light;
  --ink: #1c2530;
  --muted: #5b6673;
  --paper: #fffdf7;
  --line: #d7dde5;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --green: #0f766e;
  --green-soft: #e6f7f4;
  --rose: #be123c;
  --rose-soft: #fff1f2;
  --gold: #b7791f;
  --gold-soft: #fff7df;
  --shadow: 0 16px 40px rgba(28, 37, 48, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, #f6f8fb 0%, #fffdf7 42%, #eef7f5 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px clamp(18px, 4vw, 54px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.25rem, 2.2vw, 1.8rem);
}

.eyebrow {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.student-box {
  display: grid;
  gap: 6px;
  min-width: min(280px, 100%);
}

.student-box label,
.summary-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.student-box input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcff;
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 48px;
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr)) auto;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.summary-panel strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 3px;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.primary-btn,
.ghost-btn,
.tab,
.option,
.small-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  min-height: 42px;
}

.primary-btn {
  color: #ffffff;
  background: var(--blue);
  padding: 10px 14px;
  font-weight: 800;
}

.ghost-btn,
.small-btn {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
  padding: 10px 13px;
  font-weight: 750;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 18px 0 10px;
}

.tab {
  white-space: nowrap;
  color: var(--muted);
  background: #ffffff;
  border-color: var(--line);
  padding: 10px 15px;
  font-weight: 800;
}

.tab.active {
  color: #ffffff;
  background: var(--green);
  border-color: var(--green);
}

.lesson-section {
  display: none;
  padding-top: 8px;
}

.active-section {
  display: block;
}

.section-heading {
  margin: 10px 0 16px;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 184px;
  box-shadow: 0 10px 28px rgba(28, 37, 48, 0.07);
}

.card.correct {
  border-color: #35b69f;
  background: var(--green-soft);
}

.card.wrong {
  border-color: #f2a6b8;
  background: var(--rose-soft);
}

.question-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  font-weight: 850;
}

.badge {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--gold);
  flex: 0 0 auto;
}

.prompt {
  color: var(--ink);
  line-height: 1.45;
  margin-bottom: 13px;
}

.visual-number {
  display: inline-flex;
  justify-content: center;
  min-width: 86px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 8px 14px;
  margin: 6px 0 12px;
  background: var(--paper);
  font-size: 1.25rem;
  font-weight: 800;
}

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

.option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #f8fafc;
  border-color: var(--line);
  padding: 10px 11px;
}

.option.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.letter {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--line);
  font-weight: 900;
  flex: 0 0 auto;
}

.answer-input,
.answer-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
  min-height: 44px;
}

.math-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.math-line input {
  width: 84px;
  text-align: center;
}

.feedback {
  min-height: 22px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.correct .feedback {
  color: #087669;
}

.wrong .feedback {
  color: var(--rose);
}

.reference-strip,
.practice-note {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  overflow: auto;
}

.practice-note {
  color: var(--muted);
  font-weight: 700;
}

.reference-strip img {
  display: block;
  width: min(760px, 100%);
  height: auto;
  margin: 0 auto;
}

.blocks-visual {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 7px;
  padding: 12px;
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.hundred-block,
.ten-block,
.one-block {
  display: inline-block;
  border: 1px solid #738096;
  background-color: #e7edf4;
  background-image:
    linear-gradient(#b5becb 1px, transparent 1px),
    linear-gradient(90deg, #b5becb 1px, transparent 1px);
}

.hundred-block {
  width: 42px;
  height: 42px;
  background-size: 8px 8px;
}

.ten-block {
  width: 10px;
  height: 54px;
  background-size: 10px 9px;
}

.one-block {
  width: 13px;
  height: 13px;
  background-size: 13px 13px;
}

.number-line {
  display: grid;
  grid-template-columns: repeat(5, minmax(42px, 1fr));
  gap: 7px;
  align-items: center;
  margin: 10px 0 13px;
  padding-top: 14px;
  border-top: 3px solid var(--ink);
}

.number-line span,
.compare-row span,
.item-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 9px;
  text-align: center;
  font-weight: 850;
}

.compare-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.compare-row strong {
  color: var(--gold);
  font-size: 1.3rem;
}

.group-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 9px 0 12px;
}

.item-group {
  display: inline-flex;
  gap: 5px;
  min-width: 58px;
  min-height: 42px;
  justify-content: center;
  align-items: center;
}

.item-group i {
  color: var(--blue);
  font-style: normal;
}

.mini-note {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(120px);
  background: #111827;
  color: #ffffff;
  border-radius: 8px;
  padding: 12px 16px;
  transition: transform 0.2s ease;
  z-index: 20;
  max-width: min(520px, calc(100% - 28px));
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .topbar,
  .summary-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    position: static;
  }

  .summary-actions {
    justify-content: stretch;
  }

  .summary-actions button {
    flex: 1 1 140px;
  }
}
