:root {
  color-scheme: light;
  --bg: #f5f7ff;
  --text: #17213a;
  --muted: #64708a;
  --line: #dce3f5;
  --blue: #2768e8;
  --violet: #7b3ff2;
  --warning: #d9831f;
  --warning-soft: #fff3df;
  --soft: #eef3ff;
  --done: #0f9f6e;
  --done-soft: #e7f8f1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 88px;
}

button, input { font: inherit; }
button {
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, box-shadow .12s ease, background .12s ease;
}
button:active {
  transform: scale(.98);
  opacity: .86;
}
button:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
}
.app {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 16px 34px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0 12px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--violet);
  font-size: 17px;
  font-weight: 800;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 430px;
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}
h2 { font-size: 28px; margin-bottom: 0; }
h3 { font-size: 19px; margin-bottom: 8px; }
.hero-copy {
  max-width: 460px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-top: 12px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  box-shadow: 0 8px 18px rgba(31, 55, 96, .06);
}
.user-chip strong {
  font-size: 14px;
}
.user-chip span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.progress-ring {
  flex: 0 0 82px;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--violet), var(--blue), #dce7ff 0);
  box-shadow: 0 10px 24px rgba(39, 104, 232, .16);
}
.progress-ring span {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: white;
  font-size: 18px;
  font-weight: 900;
}

.summary, .exam, .lesson-copy, .lesson-goal, .profile-card, .review-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(31, 55, 96, .08);
}
.summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px;
  margin-bottom: 22px;
}
.summary-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 150px;
}
.summary span, .lesson-top span, .section-head span, small {
  display: block;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}
.summary strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}
.next-step-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
}

.primary, .ghost, .link-button {
  border: 0;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 850;
}
.primary {
  padding: 0 18px;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 12px 22px rgba(87, 70, 232, .22);
}
.exam-button {
  background: linear-gradient(135deg, #e08425, #7b3ff2);
}
.wide { width: 100%; }
.ghost {
  padding: 0 14px;
  color: var(--blue);
  background: #f8faff;
  border: 1px solid var(--line);
}
.link-button {
  min-height: 38px;
  padding: 0;
  color: var(--violet);
  background: transparent;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
}

.module-list {
  display: grid;
  gap: 16px;
}
.module-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 14px 34px rgba(31, 55, 96, .07);
}
.module-head {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}
.module-head span, .module-meta span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}
.module-head h2 {
  margin-top: 2px;
  line-height: 1.12;
}
.module-head strong {
  flex: 0 0 auto;
  color: var(--violet);
  font-size: 24px;
}
.module-card p {
  margin: 12px 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}
.module-body {
  margin-top: 12px;
}
.module-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.bar {
  height: 9px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edfb;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--blue), var(--violet));
}
.show-more {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: var(--soft);
  font-weight: 850;
}

.lesson-list {
  display: grid;
  gap: 10px;
}
.lesson-card {
  width: 100%;
  display: grid;
  grid-template-columns: 48px 1fr 32px;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 12px;
  text-align: left;
  color: var(--text);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.lesson-card span {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: var(--soft);
  font-weight: 900;
}
.lesson-card strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}
.lesson-card b {
  color: var(--blue);
  font-size: 22px;
  text-align: center;
}
.lesson-card.done span {
  color: white;
  background: var(--done);
}
.lesson-card.done b { color: var(--done); }
.module-meta span:first-child,
.lesson-card.done small {
  color: var(--done);
}

.lesson-screen {
  display: grid;
  gap: 14px;
}
.lesson-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.lesson-top h2 { margin: 4px 0 0; }
.lesson-goal {
  padding: 14px;
}
.lesson-goal span {
  display: block;
  margin-bottom: 5px;
  color: var(--violet);
  font-size: 15px;
  font-weight: 900;
}
.lesson-goal strong {
  display: block;
  font-size: 20px;
  line-height: 1.35;
}
.term-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.term {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--violet);
  background: #f0ecff;
  font-size: 15px;
  font-weight: 850;
}
.page-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: 0 12px 28px rgba(31, 55, 96, .10);
  cursor: zoom-in;
}
.lesson-copy {
  padding: 16px;
  font-size: 19px;
  line-height: 1.62;
}
.lesson-copy p:last-child { margin-bottom: 0; }
.mistake-box {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #f8f5ff;
}
.mistake-box p {
  margin-bottom: 0;
  color: var(--muted);
}
.lesson-check {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.check-options {
  display: grid;
  gap: 8px;
}
.check-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  font-size: 17px;
  line-height: 1.25;
}
.check-options input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}
.lesson-hint {
  min-height: 26px;
  margin: 10px 0 0;
  color: var(--violet);
  font-size: 16px;
  font-weight: 800;
}

.exam {
  padding: 16px;
  margin-bottom: 22px;
  border-color: #f0d4a2;
  background: linear-gradient(180deg, #fffaf1, white 34%);
}
.exam-description {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}
.question {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}
.question legend {
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 850;
}
.question label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}
.question input { width: 20px; height: 20px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 26, 48, .42);
}
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 54px 10px 18px;
  background: rgba(12, 18, 36, .92);
}
.image-viewer img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  background: white;
}
.viewer-actions {
  position: fixed;
  top: 12px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.viewer-nav {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: rgba(255, 255, 255, .16);
  font-weight: 850;
}
.empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: white;
  font-size: 18px;
  line-height: 1.45;
}
.review-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.review-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}
.review-card strong {
  display: block;
  margin-top: 3px;
  font-size: 19px;
}
.review-card p {
  margin: 10px 0 6px;
  color: var(--text);
  line-height: 1.4;
}
.review-card small {
  color: var(--muted);
  line-height: 1.35;
}
.review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.profile-card {
  padding: 16px;
}
.profile-user {
  padding: 14px;
  border-radius: 8px;
  background: var(--soft);
}
.profile-user strong,
.profile-user span {
  display: block;
}
.profile-user strong {
  font-size: 22px;
}
.profile-user span {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 750;
}
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}
.profile-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.profile-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.profile-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 8;
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  transform: translateX(-50%);
  box-shadow: 0 -10px 28px rgba(31, 55, 96, .12);
}
.nav-item {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 850;
}
.nav-item span {
  display: block;
  margin-bottom: 3px;
  font-size: 18px;
  line-height: 1;
}
.nav-item.active {
  color: var(--blue);
  background: var(--soft);
}
.scroll-top {
  position: fixed;
  right: max(14px, calc((100% - 760px) / 2 + 14px));
  bottom: 92px;
  z-index: 9;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 12px 26px rgba(39, 104, 232, .24);
  font-size: 22px;
  font-weight: 900;
}
.modal-box {
  width: min(420px, 100%);
  padding: 22px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .22);
}
.modal-box strong {
  display: block;
  margin-bottom: 8px;
  font-size: 28px;
}
.modal-box p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.hidden { display: none !important; }

@media (max-width: 520px) {
  .app { padding: 10px 12px 24px; }
  .hero { align-items: flex-start; }
  .eyebrow { font-size: 15px; margin-bottom: 5px; }
  h1 { font-size: 28px; }
  .hero-copy { margin-top: 8px; font-size: 15px; }
  .progress-ring {
    flex-basis: 68px;
    width: 68px;
    height: 68px;
  }
  .progress-ring span {
    width: 52px;
    height: 52px;
    font-size: 15px;
  }
  .summary {
    align-items: stretch;
    flex-direction: column;
  }
  .summary-actions { width: 100%; }
  .summary .primary, .summary .ghost { width: 100%; }
  h2 { font-size: 24px; }
  .lesson-actions { grid-template-columns: 1fr; }
  .lesson-card { grid-template-columns: 44px 1fr 28px; }
  .lesson-card span { width: 44px; height: 44px; }
  .lesson-card strong { font-size: 19px; }
  .lesson-copy { font-size: 20px; }
  .review-actions { grid-template-columns: 1fr; }
  .nav-item { min-height: 56px; font-size: 10px; }
  .profile-grid { grid-template-columns: 1fr 1fr; }
}

/* v0.6.0 polish */
body {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.app {
  padding-bottom: calc(42px + env(safe-area-inset-bottom));
}
.hero {
  padding: 12px 0 10px;
  gap: 10px;
}
h1 {
  font-size: clamp(25px, 6.4vw, 34px);
  line-height: .98;
  white-space: nowrap;
}
.hero-copy {
  margin-top: 8px;
  font-size: 15px;
}
.user-chip {
  max-width: min(100%, 360px);
  min-height: 32px;
  margin-top: 10px;
  padding: 4px 9px 4px 5px;
}
.user-chip-text {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.user-chip strong,
.user-chip span,
.profile-user strong,
.profile-user span,
.profile-user small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  font-weight: 900;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-small {
  width: 28px;
  height: 28px;
  font-size: 13px;
}
.avatar-profile {
  width: 58px;
  height: 58px;
  font-size: 24px;
}
.progress-ring {
  flex-basis: 72px;
  width: 72px;
  height: 72px;
}
.progress-ring span {
  width: 54px;
  height: 54px;
  font-size: 16px;
}
.module-list,
.lesson-list,
.exam-list {
  gap: 14px;
}
.summary,
.module-card,
.exam,
.profile-card,
.review-card,
.lesson-copy,
.lesson-goal {
  border-radius: 10px;
}
h2 { font-size: 24px; }
h3 { font-size: 17px; }
.bottom-nav {
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
}
.nav-item {
  min-height: 52px;
  font-size: 10px;
  border-radius: 10px;
}
.nav-item span {
  font-size: 16px;
}
.nav-item.active {
  color: #315adf;
  background: #eef3ff;
  box-shadow: inset 0 0 0 1px #dfe7ff;
}
.scroll-top {
  bottom: calc(104px + env(safe-area-inset-bottom));
  width: 42px;
  height: 42px;
  font-size: 20px;
}
.lesson-microcopy {
  margin: 0 2px 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}
.check-options label,
.question label {
  min-height: 52px;
  padding: 11px 12px;
}
.check-options label:has(input:checked),
.question label:has(input:checked) {
  border-color: #9eb7ff;
  background: #f0f5ff;
  box-shadow: inset 0 0 0 1px #cfe0ff;
}
.check-options label.wrong {
  border-color: #f0c6a5;
  background: #fff6ed;
}
.check-options label.correct {
  border-color: #a9dfc8;
  background: var(--done-soft);
}
.exam-list {
  display: grid;
  margin-bottom: 16px;
}
.exam-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: 0 12px 30px rgba(31, 55, 96, .06);
  cursor: pointer;
}
.exam-card span,
.exam-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.exam-card strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
  line-height: 1.2;
}
.exam-card-side {
  display: grid;
  gap: 6px;
  justify-items: center;
}
.exam-card-side b,
#examCountBadge {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--violet);
  background: #f1edff;
  font-size: 13px;
  font-style: normal;
  white-space: nowrap;
}
.exam-card-side em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  text-align: center;
}
.exam-card.available { border-color: #cdd9ff; }
.exam-card.passed { border-color: #b9e8d2; background: #fbfffd; }
.exam-card.failed { border-color: #f2d2a4; background: #fffaf2; }
.exam-card.locked { opacity: .78; }
.exam-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}
.exam-head h2 {
  margin: 3px 0 0;
  font-size: 22px;
  line-height: 1.15;
}
.exam-access {
  margin: -4px 0 14px;
  color: var(--warning);
  font-size: 14px;
  font-weight: 850;
}
.profile-user {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 12px;
}
.profile-user small {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}
#resetButton {
  color: #8a4f18;
  background: #fff8ef;
  border-color: #f0d4a2;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-actions .hidden + .primary,
.modal-actions .primary:only-child {
  grid-column: 1 / -1;
}
@media (max-width: 520px) {
  .app { padding-bottom: calc(34px + env(safe-area-inset-bottom)); }
  h1 { font-size: clamp(23px, 6.2vw, 28px); }
  .hero { align-items: center; }
  .hero-copy { font-size: 14px; line-height: 1.35; }
  .progress-ring { flex-basis: 62px; width: 62px; height: 62px; }
  .progress-ring span { width: 48px; height: 48px; font-size: 14px; }
  .exam-card { grid-template-columns: 1fr; }
  .exam-card-side { grid-template-columns: auto auto; justify-content: start; justify-items: start; }
  .modal-actions { grid-template-columns: 1fr; }
}
.continue-lessons {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}
