:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #68717c;
  --paper: #f5f3ef;
  --panel: #ffffff;
  --line: #d9d5cc;
  --accent: #2f6f73;
  --accent-dark: #24565a;
  --warn: #d95845;
  --good: #237a52;
  --focus: #d7eee9;
  --shadow: 0 18px 55px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 80px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 2.6vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
  min-width: 300px;
}

.stat-strip div {
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
}

.stat-strip span {
  display: block;
  font-size: 1.24rem;
  font-weight: 850;
  line-height: 1;
}

.stat-strip small {
  display: block;
  margin-top: 7px;
  color: #cbd1d7;
  font-size: 0.75rem;
}

.segment,
.section-tab,
.ghost-btn,
.nav-btn,
.primary-btn,
.choice-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.segment.active,
.section-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.control-panel,
.quiz-card,
.stat-panel,
.review-row,
.home-card,
.setup-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 18px;
}

.control-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.control-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented,
.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment,
.section-tab,
.ghost-btn {
  padding: 0 14px;
}

.home-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 12px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 16px;
}

.page-head div {
  display: grid;
  gap: 4px;
}

.page-head span {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.page-head h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.1rem);
  line-height: 1.16;
  letter-spacing: 0;
}

.back-link {
  order: 2;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.home-card {
  display: grid;
  gap: 8px;
  min-height: 170px;
  padding: 22px;
}

.home-card.primary {
  background: var(--ink);
  color: #fff;
}

.home-card span {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.home-card.primary span {
  color: #9ed1ca;
}

.home-card strong {
  font-size: 1.28rem;
  line-height: 1.28;
}

.home-card small {
  color: var(--muted);
  line-height: 1.5;
}

.home-card.primary small {
  color: #d5dde2;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.stat-panel {
  padding: 18px;
}

.panel-note {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.setup-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.setup-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.setup-step > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.setup-step h3 {
  margin: 3px 0 12px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.setup-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.stat-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.stat-panel-head strong,
.stat-panel-head span {
  font-weight: 850;
}

.master-track,
.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfdbd3;
}

.master-track div,
.progress-track div {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 0;
}

dl div {
  padding: 10px;
  border-radius: 8px;
  background: #f8f7f4;
}

dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 850;
}

.progress-block {
  margin: 16px 0;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.quiz-card {
  position: relative;
  min-height: 390px;
  padding: 26px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf5f3;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 850;
}

.quiz-text {
  margin: 0;
  font-size: 1.08rem;
  line-height: 2.05;
  letter-spacing: 0;
}

.bullet-mark {
  color: var(--accent);
  font-weight: 900;
}

.blank-input {
  width: min(220px, 48vw);
  min-height: 40px;
  margin: 0 5px;
  border: 1.5px solid #b8c1c8;
  border-radius: 8px;
  padding: 6px 10px;
  background: #fbfbfa;
  color: var(--ink);
  text-align: center;
  font-weight: 800;
}

.blank-input:focus {
  outline: 3px solid var(--focus);
  border-color: var(--accent);
}

.blank-input.correct {
  border-color: var(--good);
  background: #edf8f2;
}

.blank-input.wrong {
  border-color: var(--warn);
  background: #fff0ed;
}

.blank-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 38px;
  margin: 0 5px;
  border: 1.5px solid #aeb8c0;
  border-radius: 8px;
  background: #f8f8f6;
  font-weight: 850;
}

.blank-token.target {
  border-color: var(--warn);
  background: #fff0ed;
  color: #9e2f23;
}

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

.choice-btn {
  min-height: 58px;
  padding: 12px 14px;
  text-align: left;
  line-height: 1.35;
}

.choice-btn.selected {
  border-color: var(--accent);
  background: #edf5f3;
}

.choice-btn.correct {
  border-color: var(--good);
  background: #edf8f2;
  color: #0f5b37;
}

.choice-btn.wrong {
  border-color: var(--warn);
  background: #fff0ed;
  color: #9e2f23;
}

.answers-panel {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.answer-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f8f7f4;
  border: 1px solid var(--line);
}

.answer-row strong {
  color: var(--accent-dark);
}

.answer-row.correct strong {
  color: var(--good);
}

.answer-row.wrong strong {
  color: var(--warn);
}

.result-toast {
  margin-top: 18px;
  padding: 13px 14px;
  border-radius: 8px;
  font-weight: 850;
}

.result-toast.good {
  background: #edf8f2;
  color: var(--good);
}

.result-toast.bad {
  background: #fff0ed;
  color: #9e2f23;
}

.success-pop {
  position: absolute;
  top: 18px;
  right: 22px;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 5px solid var(--good);
  border-radius: 50%;
  color: var(--good);
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
  background: rgba(237, 248, 242, 0.9);
  box-shadow: 0 16px 38px rgba(35, 122, 82, 0.22);
  animation: success-pop 520ms ease-out both;
}

@keyframes success-pop {
  0% {
    opacity: 0;
    transform: scale(0.45) rotate(-12deg);
  }
  62% {
    opacity: 1;
    transform: scale(1.08) rotate(3deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.bottom-actions {
  display: grid;
  grid-template-columns: 1fr minmax(170px, 240px) 1fr;
  gap: 10px;
  width: 100%;
  margin: 16px auto 0;
}

.bottom-actions.single-action {
  grid-template-columns: 1fr 1fr;
}

.bottom-actions.single-primary {
  grid-template-columns: minmax(170px, 260px);
  justify-content: center;
}

.nav-btn,
.primary-btn {
  min-height: 52px;
}

.primary-btn {
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

.primary-btn.wide {
  width: 100%;
  margin-top: 12px;
}

.nav-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.nav-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.good-action {
  background: var(--good);
  border-color: var(--good);
}

.danger-action {
  color: #9e2f23;
}

.memory-card {
  display: grid;
  align-content: start;
  gap: 18px;
}

.flash-answer {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f7f4;
  text-align: center;
}

.flash-answer small {
  color: var(--muted);
  font-weight: 800;
}

.flash-answer strong {
  font-size: 1.55rem;
}

.flash-answer.shown {
  border-color: var(--accent);
  background: #edf5f3;
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.review-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 16px;
  padding: 16px;
}

.review-row p {
  margin: 10px 0;
  color: var(--ink);
  line-height: 1.65;
}

.review-row strong {
  color: var(--accent-dark);
}

.review-score {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 5px;
}

.review-score span {
  font-size: 1.3rem;
  font-weight: 900;
}

.review-score small {
  color: var(--muted);
  font-weight: 750;
}

.empty-state {
  display: grid;
  min-height: 230px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 1120px);
    padding-top: 18px;
  }

  .topbar,
  .control-row,
  .page-head {
    display: grid;
    align-items: start;
  }

  .stat-strip {
    min-width: 0;
    width: 100%;
  }

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

  .back-link {
    order: 0;
    width: max-content;
  }

  .home-card {
    min-height: 128px;
  }

  .control-panel,
  .quiz-card {
    padding: 16px;
  }

  .quiz-text {
    font-size: 1rem;
    line-height: 2;
  }

  .success-pop {
    top: 12px;
    right: 12px;
    width: 58px;
    height: 58px;
    font-size: 2.45rem;
    border-width: 4px;
  }

  .blank-input {
    width: min(170px, 62vw);
  }

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

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

  .review-row {
    grid-template-columns: 1fr;
  }

  .review-score {
    justify-items: start;
  }
}
