/* Учебник по запросу */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1c2333;
  --muted: #66708a;
  --accent: #3457d5;
  --accent-soft: #e8edff;
  --ok: #1f9d55;
  --bad: #d64545;
  --border: #dfe4f2;
  --radius: 14px;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}
#app { max-width: 760px; margin: 0 auto; padding: 18px 14px 60px; }
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.hero h1 { font-size: 30px; margin: 14px 0 6px; }
.subtitle { color: var(--muted); margin-bottom: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 14px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfcff;
}
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chk { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13px; margin: 8px 0; }
.chk input { width: auto; margin-top: 3px; }
.hp { position: absolute; left: -9999px; height: 0; width: 0; opacity: 0; }

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; margin-top: 14px; }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 6px 10px; }

.role-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.role-btn {
  padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; font-weight: 600; cursor: pointer; font-size: 14px;
}
.role-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.hint { color: var(--muted); font-size: 12.5px; }
.center { text-align: center; margin-top: 8px; }

/* загрузка */
.loading { text-align: center; padding: 80px 0; color: var(--muted); }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 18px;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* курс */
.course-header { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0 14px; }
.course-header h2 { font-size: 22px; }
.plan-box ol { margin-left: 20px; }
.plan-box li { margin: 6px 0; color: var(--muted); font-size: 14px; }
.plan-box li.current { color: var(--accent); font-weight: 700; }
.plan-box li.done { color: var(--ok); }
.plan-box li.done::after { content: " ✓"; }

.lesson-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 10px; }
.lesson-num {
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; border-radius: 8px; padding: 2px 10px; font-size: 13px;
  white-space: nowrap;
}
.lesson-body p { margin: 0 0 12px; }
.lesson-body strong { background: #fff3bf; }

.example {
  background: #f6f9ff; border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0; padding: 10px 14px; margin: 0 0 12px;
}
.example .ex-q { font-weight: 700; margin-bottom: 4px; }

#quiz-box h4, .materials h4 { margin: 18px 0 10px; }
.quiz-q { margin-bottom: 14px; }
.quiz-q .qq { font-weight: 600; margin-bottom: 6px; }
.quiz-opt {
  display: flex; gap: 8px; align-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; margin: 6px 0; cursor: pointer; background: #fff;
  font-size: 14px;
}
.quiz-opt input { width: auto; }
.quiz-opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.quiz-opt.correct { border-color: var(--ok); background: #e9f9ef; }
.quiz-opt.wrong { border-color: var(--bad); background: #fdecec; }
.q-explain { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

#result-summary { font-weight: 700; margin: 14px 0 8px; }
.result-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.result-actions .btn { width: auto; margin-top: 0; }
#btn-next { flex: 1; }

.materials ul { margin-left: 20px; font-size: 14px; }
.materials li { margin: 6px 0; }
.materials a { color: var(--accent); }

.lesson-footer { display: flex; justify-content: space-between; margin-top: 18px; }
.done h3 { margin-bottom: 8px; }

/* мои курсы */
.my-courses { margin-top: 18px; }
.my-courses h3 { font-size: 16px; margin-bottom: 8px; }
.my-course {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer;
  font-size: 14px;
}
.my-course:hover { border-color: var(--accent); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; z-index: 99; max-width: 90%;
}
#err-box { background: #fdecec; border: 1px solid var(--bad); color: var(--bad);
  border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 14px; }

@media (max-width: 520px) {
  .row2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
}

/* печать урока */
@media print {
  body { background: #fff; }
  #screen-start, #screen-loading, .course-header, #quiz-box,
  #result-box, .lesson-footer, .plan-box, #toast, #err-box, .materials { display: none !important; }
  #screen-course, #screen-course.active { display: block !important; }
  .card { border: none; box-shadow: none; }
  #lesson-box { display: block !important; }
}
