:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --blue: #1cb0f6;
  --purple: #b673f8;
  --yellow: #ffc800;
  --ink: #3c3c3c;
  --muted: #696969;
  --line: #e5e5e5;
  --soft: #f7f7f7;
  --paper: #ffffff;
  --answer: #f1ffe8;
  --answer-line: #46a302;
  --prompt: #f3fbff;
  --prompt-line: #d7eefc;
  --coach: #fbf4ff;
  --coach-line: #e7d4f7;
  --tip: #fff8d7;
  --tip-line: #ffe280;
  --shadow: 0 20px 60px rgba(60, 60, 60, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  overflow-y: auto;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Nunito, ui-rounded, "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

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

button,
summary {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 2px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 20px;
  font-weight: 900;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--green);
  border: 2px solid var(--green-dark);
  border-bottom-width: 5px;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  flex: 0 0 auto;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  min-height: 44px;
  border: 2px solid var(--green-dark);
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.button.secondary {
  background: var(--paper);
  color: var(--blue);
  border-color: #d7eefc;
}

.button:focus-visible,
.lesson-tab:focus-visible,
.answer-box summary:focus-visible {
  outline: 3px solid rgba(28, 176, 246, 0.35);
  outline-offset: 3px;
}

.hero {
  padding: 36px 0 28px;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(360px, 0.65fr);
  gap: 24px;
  align-items: center;
}

.hero-copy {
  min-width: 0;
}

h1 {
  margin: 0;
  max-width: 100%;
  font-size: clamp(38px, 5.2vw, 58px);
  line-height: 1.04;
  font-weight: 900;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.lead {
  margin: 18px 0 0;
  max-width: 720px;
  color: #626262;
  font-size: 19px;
  line-height: 1.55;
  font-weight: 750;
}

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

.stat {
  min-height: 104px;
  border: 2px solid var(--line);
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
}

.stat strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.stat span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  font-weight: 800;
}

.lesson-preview {
  min-width: 0;
  width: 100%;
  border: 2px solid #d7d7d7;
  border-bottom-width: 7px;
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.preview-top {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 2px solid var(--line);
  background: #fbfffa;
}

.flag {
  width: 48px;
  height: 34px;
  border: 2px solid #d8d8d8;
  border-radius: 6px;
  overflow: hidden;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  flex: 0 0 auto;
}

.flag span:nth-child(1) {
  background: #ae1c28;
}

.flag span:nth-child(2) {
  background: #fff;
}

.flag span:nth-child(3) {
  background: #21468b;
}

.pill {
  margin-left: auto;
  border: 2px solid var(--tip-line);
  border-bottom-width: 4px;
  border-radius: 8px;
  background: var(--tip);
  color: #9a7000;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
}

.preview-body {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--soft);
}

.path-step {
  border: 2px solid var(--line);
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--paper);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 900;
}

.path-step.active {
  border-color: var(--green-dark);
  background: var(--answer);
}

.dot {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 auto;
}

.section {
  padding: 34px 0 70px;
  border-top: 2px solid var(--line);
}

.lesson-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.lesson-tabs {
  position: sticky;
  top: 94px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 10px;
}

.lesson-tab {
  border: 2px solid var(--line);
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--paper);
  padding: 13px 14px;
  text-align: left;
  color: var(--ink);
}

.lesson-tab.is-active,
.lesson-tab:hover {
  border-color: var(--green-dark);
  background: var(--answer);
}

.lesson-tab span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.lesson-tab strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
}

.lesson-panel {
  min-width: 0;
  border: 2px solid #d7d7d7;
  border-bottom-width: 7px;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: visible;
  touch-action: pan-y;
}

.lesson-head {
  padding: 24px;
  border-bottom: 2px solid var(--line);
  background: #fbfffa;
}

.lesson-head h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.06;
  font-weight: 900;
}

.lesson-head p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 750;
}

.meta-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-row span {
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 8px;
  background: var(--paper);
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.grammar-topic {
  padding: 24px;
  border-bottom: 2px solid var(--line);
  scroll-margin-top: 96px;
}

.grammar-topic:last-child {
  border-bottom: 0;
}

.topic-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topic-number {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  flex: 0 0 auto;
}

.topic-head h3 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
  font-weight: 900;
}

.topic-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 750;
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.rule-box,
.example-box {
  border: 2px solid var(--prompt-line);
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--prompt);
  padding: 18px;
}

.example-box {
  border-color: var(--coach-line);
  background: var(--coach);
}

.rule-box h4,
.example-box h4,
.exercise-card h4 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 900;
}

.rule-box p,
.example-box p,
.exercise-card p,
.answer-box p {
  margin: 10px 0 0;
  color: #4f4f4f;
  line-height: 1.55;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.example-box ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.example-box li {
  margin: 7px 0;
  line-height: 1.45;
  font-weight: 750;
}

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

.exercise-card {
  border: 2px solid var(--line);
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--paper);
  padding: 18px;
}

.answer-box {
  margin-top: 14px;
  border: 2px solid var(--answer-line);
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--answer);
  color: #35542b;
  overflow: hidden;
}

.answer-box summary {
  padding: 12px 14px;
  color: #347a00;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.answer-box p {
  padding: 0 14px 14px;
}

.answer-box p + p {
  margin-top: 0;
}

.answer-box:not([open]) p {
  display: none;
}

.footer {
  padding: 32px 0 48px;
  border-top: 2px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 750;
}

@media (max-width: 1100px) {
  .hero,
  .lesson-layout,
  .theory-grid {
    grid-template-columns: 1fr;
  }

  .lesson-tabs {
    position: static;
    max-height: none;
    overflow: visible;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell {
    width: calc(100% - 24px);
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .nav {
    min-height: 76px;
    gap: 10px;
  }

  .brand span:last-child {
    display: none;
  }

  .nav-actions {
    min-width: 0;
    margin-left: auto;
    gap: 6px;
  }

  .button {
    max-width: 128px;
    padding: 0 11px;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #printLesson {
    display: none;
  }

  h1 {
    max-width: 100%;
    font-size: 31px;
    line-height: 1.08;
    overflow-wrap: anywhere;
    text-wrap: auto;
  }

  .lead {
    max-width: 100%;
    font-size: 16px;
    overflow-wrap: anywhere;
  }

  .hero {
    gap: 22px;
  }

  .hero-grid,
  .lesson-tabs {
    grid-template-columns: 1fr;
  }

  .stat {
    min-height: 88px;
  }

  .preview-top {
    flex-wrap: wrap;
  }

  .lesson-head,
  .grammar-topic {
    padding: 18px 16px;
  }

  .topic-head {
    display: grid;
  }

  .rule-box,
  .example-box,
  .exercise-card {
    padding: 14px;
  }

  .topic-head h3,
  .lesson-head h2,
  .rule-box h4,
  .example-box h4,
  .exercise-card h4,
  .path-step,
  .lesson-tab {
    overflow-wrap: anywhere;
  }
}

@media print {
  .topbar,
  .lesson-tabs,
  .footer,
  .nav-actions {
    display: none;
  }

  .shell {
    width: 100%;
  }

  .hero,
  .lesson-layout {
    display: block;
  }

  .lesson-panel,
  .lesson-preview,
  .stat,
  .exercise-card,
  .rule-box,
  .example-box {
    box-shadow: none;
  }

  .answer-box {
    break-inside: avoid;
  }
}

.nav-link {
  min-height: 44px;
  border: 2px solid #d7eefc;
  border-bottom-width: 5px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--blue);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-link:focus-visible,
.footer-link:focus-visible {
  outline: 3px solid rgba(28, 176, 246, 0.35);
  outline-offset: 3px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-link {
  color: var(--blue);
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .nav-link {
    min-height: 44px;
    padding: 0 10px;
    font-size: 12px;
  }

  .footer-inner {
    align-items: flex-start;
    display: grid;
  }
}
