/* Веб-платформа курсов. Без сборки и без фреймворка: страница одна, и всё её
   оформление — здесь. Цвета — токенами, тёмная тема — по системной. */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #e4e2dd;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --pink: #d9467a;
  --blue: #2f6fde;
  --error: #c62828;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1e1e21;
    --text: #f2f2f4;
    --muted: #9b9ba3;
    --line: #2e2e33;
    --accent: #5b8ef0;
    --pink: #ec6b98;
    --blue: #5b8ef0;
    --error: #ef6b6b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px;
}

.brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
.brand span { color: var(--muted); font-weight: 400; }

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

h1 { font-size: 30px; line-height: 1.2; margin: 16px 0 8px; }
h2 { font-size: 20px; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.course-card {
  display: block;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.course-card p { margin: 0; color: var(--muted); }
.course-card.tone-pink { border-left-color: var(--pink); }
.course-card.is-active { outline: 2px solid var(--accent); outline-offset: 0; }
.course-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
}

.login {
  max-width: 360px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.login label {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}
.login input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.error { color: var(--error); margin: 0 0 12px; }

.button {
  padding: 10px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.button:disabled { opacity: 0.6; cursor: default; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Дерево курса ──────────────────────────────────────────────────────── */

.course-head { margin: 8px 0 16px; }
.course-head p { margin: 0; color: var(--muted); white-space: pre-wrap; }

.folder {
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.folder .folder { margin: 8px 0 0; background: var(--bg); }
.folder > summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary::before {
  content: "▸";
  display: inline-block;
  width: 1.2em;
  color: var(--muted);
  transition: transform 0.15s;
}
.folder[open] > summary::before { transform: rotate(90deg); }
.folder-body { padding: 0 16px 14px; }
.folder-body > p { margin: 0 0 8px; color: var(--muted); white-space: pre-wrap; }

.pill {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 14%, transparent);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  vertical-align: 2px;
}
.tone-pink .pill { background: color-mix(in srgb, var(--pink) 14%, transparent); color: var(--pink); }

.materials { margin: 0; padding: 0; list-style: none; }
.materials a {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}
.materials li:first-child a { border-top: 0; }
.materials a:hover { color: var(--accent); }
.kind { width: 1.4em; flex: none; color: var(--muted); text-align: center; }

.assignment {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.assignment strong { display: block; margin-bottom: 4px; }

/* ─── Урок ──────────────────────────────────────────────────────────────── */

.back { display: inline-block; margin: 8px 0 12px; }

.lesson video,
.lesson img {
  display: block;
  width: 100%;
  max-height: 80vh;
  margin: 0 0 16px;
  border-radius: var(--radius);
  background: #000;
}
.lesson img { background: none; object-fit: contain; }

.text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 16px; }
.text strong { font-weight: 600; }

.files { margin: 0 0 16px; padding: 0; list-style: none; }
.files li { padding: 8px 0; border-top: 1px solid var(--line); }
.files li:first-child { border-top: 0; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.pager a { max-width: 48%; }
.pager .next { margin-left: auto; text-align: right; }
