:root {
  --ink: #241b16;
  --muted: #625e58;
  --paper: #fffdf9;
  --cream: #f6f2e9;
  --line: #e5ded2;
  --accent: #a06b37;
  --focus: #d6a66c;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 48px, 1040px); margin-inline: auto; }
.skip-link { position: absolute; z-index: 20; top: -60px; left: 16px; padding: 10px 16px; background: #fff; }
.skip-link:focus { top: 12px; }
.topbar { border-bottom: 1px solid var(--line); background: #fff; }
.topbar-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; font-size: 14px; font-weight: 650; }
.topbar nav a:hover, .crumbs a:hover, .site-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }
.topbar nav a[aria-current] { color: var(--accent); }
.page { min-height: calc(100vh - 155px); padding-bottom: 92px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; padding-top: 27px; color: var(--muted); font-size: 14px; }
.crumbs span:last-child { color: var(--ink); font-weight: 650; }
.page-heading { padding: 54px 0 49px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 13px; color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: .02em; }
h1 { margin: 0; font-size: clamp(43px, 6vw, 70px); line-height: 1.07; letter-spacing: -.055em; }
.page-heading > p:last-child { margin: 18px 0 0; color: var(--muted); font-size: 18px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin: 42px 0 21px; }
.section-heading h2 { margin: 0; font-size: clamp(26px, 3vw, 34px); line-height: 1.2; letter-spacing: -.035em; }
.section-heading > span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.grades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grade-card { display: flex; align-items: center; gap: 20px; min-height: 112px; padding: 20px 24px; border: 1px solid var(--line); border-radius: 12px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.grade-card:hover { border-color: #b89b7d; box-shadow: 0 8px 22px #241b1610; }
.grade-number { display: grid; place-items: center; flex: 0 0 56px; width: 56px; height: 56px; border-radius: 10px; background: var(--cream); font-size: 28px; font-weight: 800; line-height: 1; }
.grade-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.grade-name strong { font-size: 19px; line-height: 1.2; }
.grade-name small { color: var(--muted); font-size: 14px; }
.card-action { margin-left: auto; color: var(--accent); font-size: 14px; font-weight: 700; white-space: nowrap; }
.class-nav { display: flex; align-items: center; gap: 26px; padding: 26px 0; border-bottom: 1px solid var(--line); }
.class-nav > span { flex: 0 0 auto; color: var(--muted); font-size: 14px; font-weight: 650; }
.class-links { display: flex; flex-wrap: wrap; gap: 8px; }
.class-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; font-weight: 700; white-space: nowrap; }
.class-links a:hover { border-color: #b89b7d; }
.class-links a[aria-current] { border-color: var(--ink); background: var(--ink); color: #fff; }
.catalog .section-heading { margin-top: 37px; }
.search-label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 700; }
.search { display: block; width: 100%; height: 52px; padding: 0 17px; border: 1px solid #b9afa4; border-radius: 9px; background: #fff; color: var(--ink); font: inherit; }
.search::placeholder { color: #756d64; }
.lesson-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 25px 0 0; padding: 0; list-style: none; }
.lesson { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; height: 100%; min-height: 166px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.lesson:hover { border-color: #b89b7d; box-shadow: 0 5px 18px #241b160c; }
.lesson-number { color: var(--accent); font-size: 16px; font-weight: 800; white-space: nowrap; }
.lesson-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.lesson-open { color: var(--accent); font-size: 14px; font-weight: 700; }
.empty { margin: 26px 0; padding: 24px; border-radius: 10px; background: var(--cream); color: var(--muted); }
.site-footer { background: #211b17; color: #fff; }
.footer-inner { min-height: 79px; display: flex; align-items: center; justify-content: space-between; gap: 20px; font-size: 14px; }
.footer-inner span { font-weight: 750; }
.footer-inner a { color: #e7c498; font-weight: 650; }
@media (max-width: 1049px) {
  .lesson-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .wrap { width: min(100% - 32px, 1040px); }
  .topbar-inner { min-height: 70px; }
  .brand { max-width: 172px; font-size: 14px; line-height: 1.2; }
  .topbar nav { display: none; }
  .topbar nav a[aria-current] { display: none; }
  .crumbs { padding-top: 19px; font-size: 13px; }
  .page { padding-bottom: 62px; }
  .page-heading { padding: 35px 0 34px; }
  .page-heading > p:last-child { font-size: 16px; }
  .section-heading { margin: 30px 0 16px; }
  .grades { grid-template-columns: 1fr; }
  .grade-card { min-height: 92px; padding: 15px; gap: 15px; }
  .grade-number { flex-basis: 48px; width: 48px; height: 48px; font-size: 24px; }
  .grade-name strong { font-size: 18px; }
  .card-action { font-size: 13px; }
  .class-nav { display: block; padding: 22px 0; }
  .class-nav > span { display: block; margin-bottom: 12px; }
  .class-links { gap: 7px; }
  .class-links a { min-height: 38px; padding: 6px 11px; }
  .catalog .section-heading { margin-top: 29px; }
}
@media (max-width: 640px) {
  .lesson-list { grid-template-columns: 1fr; gap: 8px; }
  .lesson { flex-direction: row; align-items: center; gap: 14px; min-height: 72px; padding: 14px; }
  .lesson-number { flex: 0 0 48px; font-size: 14px; }
  .lesson-title { font-size: 16px; }
  .lesson-open { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .grade-card, .lesson { transition: none; }
}

/* Разделы внутри класса: части, главы, алгебра и геометрия */
.lesson-section + .lesson-section { margin-top: 34px; }
.lesson-section-title {
  margin: 28px 0 12px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -.02em;
  scroll-margin-top: 20px;
}
.course-progress { margin: -6px 0 22px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.course-progress:empty { display: none; }
.course-progress-hint { margin: 0; color: var(--muted); font-size: 15px; }
.course-progress-hint + .course-progress-label { margin-top: 14px; }
.course-progress-label { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.course-progress progress { display: block; width: 100%; height: 8px; margin-top: 8px; accent-color: #4f8a5b; }
.course-progress-done { margin: 12px 0 0; font-weight: 700; color: #2f6b3b; }
.progress-link { font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
.progress-continue { display: inline-block; margin-top: 14px; font-size: 16px; }
.lesson-mark { padding: 2px 9px; border-radius: 30px; background: #f6f2e9; color: #6b5a3f; font-size: 12px; font-weight: 700; white-space: nowrap; }
.lesson-item.is-done .lesson { border-color: #b7d3bd; background: #f6fbf7; }
.lesson-item.is-done .lesson-mark { background: #e1f0e4; color: #2f6b3b; }
@media (max-width: 640px) {
  .lesson-item .lesson-mark { order: 3; }
}
details.lesson-section > summary.lesson-section-title { font-weight: 750; display: flex; align-items: baseline; gap: 10px 16px; flex-wrap: wrap; padding: 6px 0; cursor: pointer; list-style: none; }
details.lesson-section > summary::-webkit-details-marker { display: none; }
details.lesson-section > summary.lesson-section-title::before { content: '−'; flex: 0 0 22px; color: var(--muted); font-weight: 400; text-align: center; }
details.lesson-section:not([open]) > summary.lesson-section-title::before { content: '+'; }
details.lesson-section > summary.lesson-section-title span { flex: 1 1 300px; }
details.lesson-section > summary small { color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: 0; white-space: nowrap; }
details.lesson-section > summary:hover span { text-decoration: underline; text-underline-offset: 4px; }
details.lesson-section > summary:focus-visible { outline: 3px solid #d6a66c; outline-offset: 4px; border-radius: 6px; }
details.lesson-section .lesson-list { margin-top: 14px; }
details.lesson-subsection { margin: 14px 0 0 22px; }
details.lesson-subsection > summary.lesson-section-title { font-size: 18px; }
@media (max-width: 640px) { details.lesson-subsection { margin-left: 0; } }
