:root {
  color-scheme: light;
  --font-main: "Nunito", Arial, sans-serif;
  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --surface-soft: #EAF3FC;
  --surface-inset: #DCEAF7;
  --text: #173F7A;
  --text-soft: #355B8E;
  --muted: #5E789E;
  --line: #D5E1EF;
  --line-strong: #B6C9DF;
  --blue: #2D9BF0;
  --blue-dark: #176EB8;
  --blue-soft: #E5F3FF;
  --blue-border: #A9CBEA;
  --code-bg: #14243A;
  --code-text: #F5F8FC;
  --green: #20734C;
  --green-soft: #E7F4EC;
  --red: #A42D32;
  --red-soft: #F9E9EA;
  --shadow: 0 1px 4px rgba(29, 70, 120, 0.035);
  --shadow-hover: 0 2px 7px rgba(29, 70, 120, 0.055);
  --radius: 12px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0D1726;
  --surface: #142238;
  --surface-soft: #1B2D46;
  --surface-inset: #253C58;
  --text: #F0F5FC;
  --text-soft: #CDD9E9;
  --muted: #AFC1D8;
  --line: #405773;
  --line-strong: #5A7694;
  --blue: #68B9FF;
  --blue-dark: #91CCFF;
  --blue-soft: #193B5D;
  --blue-border: #527FA8;
  --code-bg: #081321;
  --code-text: #F3F7FC;
  --green: #8DD5AC;
  --green-soft: #183B2D;
  --red: #FFAFB4;
  --red-soft: #49272E;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 2px 7px rgba(0, 0, 0, 0.10);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 106px; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.65;
  transition: background-color .2s ease, color .2s ease;
}

button, select, input { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { color: inherit; }
img { max-width: 100%; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  z-index: 30;
  top: 10px;
  width: min(1516px, calc(100% - 36px));
  margin: 10px auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow);
}
.header-inner {
  width: 100%;
  min-height: 70px;
  padding: 0 17px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
}
.brand { display: inline-flex; align-items: center; flex: 0 0 auto; text-decoration: none; }
.brand-logo { display: block; width: 210px; max-width: 100%; height: auto; object-fit: contain; }
.header-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex: 0 0 auto; }
.header-lesson-nav-slot { display: flex; align-items: center; justify-content: center; flex: 1 1 auto; min-width: 0; }
.header-lesson-nav-slot:empty { display: none; }
.control-select,
.theme-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
}
.control-select {
  padding: 0 34px 0 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%238290a4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}
.course-select { min-width: 98px; }
.language-select { min-width: 112px; }
.theme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: border-color .18s ease, background-color .18s ease;
}
.theme-button:hover, .control-select:hover { border-color: var(--blue); }
.theme-icon { font-size: 18px; line-height: 1; color: var(--blue); }

.page-shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }
.home-shell { padding-top: 58px; }
.home-intro { max-width: 790px; margin-bottom: 46px; }
.eyebrow {
  margin: 0 0 9px;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .105em;
  line-height: 1.45;
}
h1, h2, h3, h4, p { margin-top: 0; }
.home-intro h1 {
  margin: 0 0 10px;
  font-size: clamp(34px, 4.2vw, 48px);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.15;
}
.intro-copy { max-width: 690px; margin: 0; color: var(--text-soft); font-size: 17px; line-height: 1.7; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 19px; }
.section-heading .eyebrow { margin-bottom: 4px; }
.section-heading h2 { margin: 0; font-size: 25px; line-height: 1.25; font-weight: 800; letter-spacing: -.02em; }
.topics-count { padding-bottom: 3px; color: var(--muted); font-size: 13px; font-weight: 700; }
.topics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.topic-card {
  min-height: 196px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 15px;
  padding: 22px 21px 19px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  text-decoration: none;
  text-align: left;
  box-shadow: none;
  transition: border-color .18s ease, background-color .18s ease;
}
a.topic-card:hover { border-color: var(--blue-border); background: var(--surface-soft); }
.topic-card:focus-visible, .control-select:focus-visible, .theme-button:focus-visible,
.primary-button:focus-visible, .secondary-button:focus-visible, .back-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent);
  outline-offset: 3px;
}
.topic-card-active .topic-number {
  color: var(--blue-dark);
  background: var(--blue-soft);
}
.topic-number {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #8995a5;
  background: #f0f3f7;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
body[data-theme="dark"] .topic-number { background: #263A53; color: #E1EAF6; }
.topic-content { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.topic-title { margin: 1px 0 7px; color: var(--text); font-size: 16px; line-height: 1.35; font-weight: 800; }
.topic-description { color: var(--text-soft); font-size: 13px; line-height: 1.5; }
.topic-action { margin-top: auto; padding-top: 15px; color: var(--muted); font-size: 12px; line-height: 1.2; font-weight: 800; }
.topic-card-active .topic-action { color: var(--blue-dark); }
.topic-card-disabled { cursor: pointer; background: var(--surface-soft); box-shadow: none; }
.topic-card-disabled .topic-title, .topic-card-disabled .topic-description, .topic-card-disabled .topic-action { color: var(--muted); }
.topic-card-disabled:hover { border-color: var(--line); background: var(--surface-soft); }
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 48px;
  padding: 18px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(13, 25, 43, .52);
  backdrop-filter: blur(4px);
}
.modal-backdrop[hidden] { display: none; }
.modal-open { overflow: hidden; }
.notice-modal {
  position: relative;
  width: min(100%, 430px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(20, 50, 90, .10);
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}
.modal-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin: 0 auto 15px;
  border-radius: 14px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 22px;
  font-weight: 800;
}
.notice-modal h2 { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.notice-modal p { margin: 0 0 22px; color: var(--text-soft); font-size: 14px; }
.primary-button, .secondary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 19px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.primary-button { background: var(--blue); color: #fff; }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { border-color: var(--line); background: var(--surface); color: var(--text); }
.secondary-button:hover { border-color: var(--blue); }
.toast {
  position: fixed;
  z-index: 120;
  right: 22px;
  bottom: 22px;
  max-width: min(430px, calc(100% - 44px));
  padding: 13px 17px;
  border: 1px solid var(--blue-border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  font-size: 13px;
  font-weight: 700;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 920px) {
  .topics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-inner { flex-wrap: wrap; padding: 10px 16px; gap: 9px 14px; }
  .header-lesson-nav-slot { order: 3; flex: 1 0 100%; justify-content: flex-start; }
  .header-controls { margin-left: auto; }
}
@media (max-width: 640px) {
  html { scroll-padding-top: 118px; }
  .site-header { width: calc(100% - 20px); top: 6px; margin-top: 6px; border-radius: 14px; }
  .header-inner { min-height: 58px; padding: 8px 10px; gap: 8px; }
  .brand-logo { width: 174px; max-width: 45vw; }
  .header-controls { gap: 6px; }
  .control-select, .theme-button { min-height: 36px; font-size: 11px; }
  .course-select { min-width: 69px; padding-left: 9px; padding-right: 24px; }
  .theme-button { padding: 0 8px; }
  .theme-button-text { display: none; }
  .page-shell { width: min(100% - 28px, 560px); }
  .home-shell { padding-top: 34px; }
  .home-intro { margin-bottom: 29px; }
  .intro-copy { font-size: 15px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .section-heading h2 { font-size: 22px; }
  .topics-grid { grid-template-columns: 1fr; gap: 11px; }
  .topic-card { min-height: 0; padding: 18px; }
  .topic-action { padding-top: 12px; }
  .site-footer { margin-top: 34px; flex-direction: column; gap: 4px; }
  .notice-modal { padding: 28px 22px 23px; }
  .prep-lesson-card { align-items: flex-start; padding: 14px; gap: 11px; }
  .prep-action { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Подготовительный урок перед CSS */
.prep-lesson-card {
  display: flex; align-items: center; gap: 16px; margin: 0 0 34px; padding: 18px 20px;
  border: 1px solid var(--blue-border); border-radius: 16px; background: var(--blue-soft);
  color: inherit; text-decoration: none; transition: border-color .18s ease, transform .18s ease;
}
.prep-lesson-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.prep-lesson-card[hidden] { display: none; }
.prep-number { flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--surface); color: var(--blue-dark); font-weight: 900; }
.prep-copy { display: grid; gap: 3px; min-width: 0; }
.prep-copy strong { font-size: 15px; font-weight: 900; }
.prep-copy span { color: var(--text-soft); font-size: 13px; line-height: 1.5; }
.prep-action { margin-left: auto; color: var(--blue-dark); font-size: 12px; font-weight: 900; white-space: nowrap; }
@media (max-width: 640px) {
  .prep-lesson-card { align-items: flex-start; padding: 14px; gap: 11px; }
  .prep-action { display: none; }
}

.header-main-links { display:flex; align-items:center; gap:12px; }
.header-main-link { display:inline-flex; align-items:center; min-height:38px; padding:0 12px; border:1px solid transparent; border-radius:9px; color:var(--blue-dark); font-size:14px; font-weight:800; text-decoration:none; white-space:nowrap; }
.header-main-link:hover, .header-main-link.is-active { border-color:var(--line); background:var(--surface-soft); }
@media (max-width: 640px) {
  .header-main-link { min-height:34px; padding:0 8px; font-size:12px; }
  .header-controls { gap:6px; }
  .brand-logo { width: min(172px, 40vw); }
}
