:root {
  --orange: #e8722c;
  --orange-light: #fde8d8;
  --ink: #24292f;
  --muted: #6b7280;
  --border: #e2e5e9;
  --bg: #f5f6f8;
  --card: #ffffff;
  --green: #2f9e57;
  --blue: #2f6fed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar .brand {
  font-weight: 700;
  color: var(--orange);
  font-size: 18px;
}

.topbar .who {
  color: var(--muted);
  font-size: 14px;
  margin-right: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: #f0f1f3; }

.btn-primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover { background: #d5641f; }

.btn-danger {
  background: #fff;
  border-color: #e3a2a2;
  color: #b3312c;
}

.btn-danger:hover { background: #fdeeee; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}

/* flex-wrap + gap — коли не вистачає ширини (вузький екран/планшет), блок
   з ім'ям і кнопки більше не тиснуться й не наїжджають одне на одне: текст
   зліва отримує право стискатись/переноситись (min-width:0), а кнопки
   справа при нестачі місця акуратно опускаються на свій рядок (замість
   безладного накладання). */
.roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.roster-row:last-child { border-bottom: none; }
.roster-row > div:first-child {
  min-width: 0;
  flex: 1 1 200px;
}

.roster-name { font-weight: 600; overflow-wrap: break-word; }
.roster-meta { color: var(--muted); font-size: 13px; overflow-wrap: break-word; }

.tag {
  display: inline-block;
  font-size: 12px;
  background: var(--orange-light);
  color: var(--orange);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}
.tag[hidden] { display: none; }

/* ---- Сторінка входу — дизайн під старшу школу (13-18 років) ---- */
body.login-page {
  min-height: 100vh;
  background: linear-gradient(160deg, #ffe9d6 0%, #ffd9e6 35%, #e6ddff 68%, #d8e6ff 100%);
  position: relative;
}

/* Декоративний фон: м'які кольорові "аури" (як у сучасних застосунків для
   підлітків) + мінімалістичні лінійні іконки (навушники, чат, ноутбук,
   музика, кава/бабл-ті) замість дитячих хмаринок і зірочок. Плавно
   "дихають" — суто CSS, без зовнішніх зображень і без впливу на клік по формі. */
.login-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.login-bg .aura {
  position: absolute;
  border-radius: 50%;
  filter: blur(6px);
}
.login-bg .aura-orange { top: -14%; left: -10%; width: 420px; height: 420px; background: radial-gradient(circle, rgba(232,114,44,.38), transparent 70%); }
.login-bg .aura-blue { bottom: -16%; right: -12%; width: 460px; height: 460px; background: radial-gradient(circle, rgba(111,180,242,.36), transparent 70%); }
.login-bg .aura-pink { top: 30%; right: 2%; width: 260px; height: 260px; background: radial-gradient(circle, rgba(185,138,242,.3), transparent 70%); }

.login-bg .shape {
  position: absolute;
  animation: login-float 7s ease-in-out infinite;
}
.login-bg .shape svg { display: block; width: 100%; height: auto; }

.login-bg .shape-chat { top: 10%; left: 8%; width: 62px; color: #e8722c; animation-duration: 7s; }
.login-bg .shape-headphones { top: 60%; left: 9%; width: 50px; color: #6fb4f2; animation-duration: 8s; animation-delay: .6s; }
.login-bg .shape-note { top: 20%; right: 11%; width: 34px; color: #b98af2; animation-duration: 6.5s; animation-delay: .3s; }
.login-bg .shape-laptop { bottom: 12%; right: 15%; width: 58px; color: #6fb4f2; animation-duration: 9s; animation-delay: .9s; }
.login-bg .shape-cup { bottom: 9%; left: 17%; width: 38px; color: #f2934f; animation-duration: 7.5s; animation-delay: .4s; }
.login-bg .shape-ring1 { top: 8%; right: 27%; width: 42px; color: #f28fb0; animation-duration: 10s; }
.login-bg .shape-ring2 { bottom: 30%; left: 4%; width: 26px; color: #8bd3b0; animation-duration: 8.5s; animation-delay: 1.1s; }
.login-bg .shape-plus1 { top: 46%; left: 45%; width: 16px; color: #f4a24f; animation-duration: 5.5s; }
.login-bg .shape-plus2 { top: 80%; right: 30%; width: 14px; color: #6fb4f2; animation-duration: 6s; animation-delay: .7s; }
.login-bg .shape-sparkle1 { top: 15%; left: 40%; width: 18px; color: #f4a24f; animation-duration: 6s; }
.login-bg .shape-sparkle2 { bottom: 22%; right: 22%; width: 14px; color: #b98af2; animation-duration: 7s; animation-delay: 1s; }

.login-bg .shape-dot { border-radius: 50%; width: 8px; height: 8px; opacity: .55; }
.login-bg .shape-dot1 { top: 32%; left: 27%; background: #f4a24f; animation-duration: 5s; }
.login-bg .shape-dot2 { top: 56%; right: 34%; background: #6fb4f2; animation-duration: 6.5s; animation-delay: .5s; }
.login-bg .shape-dot3 { top: 76%; right: 12%; background: #b98af2; animation-duration: 6s; animation-delay: 1.4s; }

@keyframes login-float {
  0%, 100% { transform: translateY(0); opacity: .5; }
  50% { transform: translateY(-12px); opacity: .8; }
}

@media (max-width: 640px) {
  /* На вузькому екрані прибираємо частину декору, щоб не тіснило форму */
  .login-bg .shape-laptop, .login-bg .shape-note, .login-bg .shape-ring1, .login-bg .aura-pink { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .login-bg .shape, .login-card { animation: none !important; }
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding: 24px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px 30px 26px;
  box-shadow: 0 24px 50px rgba(232, 114, 44, 0.16), 0 2px 10px rgba(20, 22, 26, 0.05);
  animation: login-card-in .5s cubic-bezier(.22, .9, .3, 1.2);
}
@keyframes login-card-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--orange) 0%, #f4a24f 100%);
  border-radius: 18px;
  box-shadow: 0 10px 22px rgba(232, 114, 44, 0.35);
}
.login-logo svg { width: 30px; height: 30px; }

.login-card h1 {
  text-align: center;
  color: var(--ink);
  font-size: 23px;
  margin: 0 0 6px;
}
.login-card h1 span { color: var(--orange); }
.login-card .subtitle { text-align: center; margin-bottom: 26px; }

/* Базові стилі .field спільні для всього сайту (форми в кабінеті вчителя/
   адміна теж це використовують) — тут лишаємо як було, нічого не ламаємо. */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.field input:disabled,
.field select:disabled {
  background: var(--bg);
  color: var(--muted);
  cursor: not-allowed;
}

/* Іконка всередині поля (лого людини/замка) та більш "дружній" вигляд
   інпутів — лише на сторінці входу, щоб не зачепити інші форми сайту. */
.login-card .field { margin-bottom: 16px; }
.login-card .field-control { position: relative; }
.login-card .field-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  pointer-events: none;
}
.login-card .field-icon svg { width: 17px; height: 17px; }
.login-card .field input {
  padding: 11px 12px 11px 38px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-size: 15px;
  background: #fbfbfc;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-card .field input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 4px var(--orange-light);
  background: #fff;
}

.login-card .btn-primary {
  margin-top: 4px;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  background: linear-gradient(135deg, var(--orange), #f2934f);
  border: none;
  box-shadow: 0 10px 20px rgba(232, 114, 44, 0.3);
  transition: transform .15s ease, box-shadow .15s ease;
}
.login-card .btn-primary:hover {
  background: linear-gradient(135deg, var(--orange), #f2934f);
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 12px 24px rgba(232, 114, 44, 0.38);
}
.login-card .btn-primary:active { transform: translateY(0) scale(0.99); }

.error-msg { color: #b3312c; font-size: 13px; margin-top: 10px; min-height: 18px; text-align: center; }

/* ---- Student waiting / lesson status ---- */
.status-card {
  text-align: center;
  padding: 40px 20px;
}
.status-card .big { font-size: 18px; margin-bottom: 14px; }
.pulse-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 8px;
}
.pulse-dot.live { background: var(--green); box-shadow: 0 0 0 4px rgba(47,158,87,0.15); }

/* ---- Lesson room ---- */
/* Швидке письмо стилусом (повторні дотики поруч) браузер часто трактує як
   подвійний клік і виділяє найближчий текст — будь-де в шапці чи тілі
   уроку ("підключено", ім'я учня, підписи кнопок тощо), що заважає й
   відволікає. Виділення тексту тут ніде не потрібне (це не текст для
   копіювання), тож вимикаємо його на всій сторінці уроку одразу, а не
   для окремих елементів по черзі. Це НЕ чіпає текстове поле інструмента
   "текст" на PDF-сторінці — user-select не діє на вміст справжніх
   <input>/<textarea>, там виділення й курсор працюють як завжди. ---- */
.lesson-header,
.lesson-header *,
.lesson-body,
.lesson-body * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.lesson-header-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lesson-header-actions { display: flex; align-items: center; gap: 10px; }
.lesson-controls { display: flex; align-items: center; gap: 10px; }
.lesson-controls select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

/* ---- Учасники уроку в шапці: ім'я + індикатор онлайн/офлайн (пункт 5) ---- */
.participants-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.participant-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.participant-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.participant-chip.online {
  background: #eafaf0;
  border-color: #bfe8cc;
}
.participant-chip.online .participant-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(47,158,87,0.18);
}
.participant-chip.offline { color: var(--muted); }

/* ---- Lesson body: book/page picker + content ---- */
.lesson-body {
  display: flex;
  align-items: flex-start;
  padding: 20px 24px;
  gap: 20px;
}

/* ---- Панель вибору книги — можна сховати, коли не потрібна (пункт 4).
   Закладка сидить праворуч від панелі (як і має бути — стирчить із краю
   відкритої книги), а не ліворуч.

   Згортання зроблене у ДВА кроки, а не простим стисканням ширини — інакше
   через overflow:hidden завжди "з'їдається" саме правий край панелі (він
   лишається приклеєним до вікна, що зникає), і це виглядає як "стискання
   на місці", а не як від'їзд геть. Тому спочатку (поки ширина ще повна)
   панель рухається цілком, як єдиний блок, через transform:translateX —
   і це справді виглядає, ніби вона їде за екран ліворуч. Лише ПІСЛЯ цього
   звільнене місце швидко "стуляється" (ширина 454px → 0), підтягуючи вміст
   уроку. Розгортання йде у зворотному порядку: спершу відкривається місце,
   потім панель заїжджає назад. ---- */
.book-picker-rail {
  --picker-w: 454px;
  position: relative;
  flex-shrink: 0;
}

.book-picker-wrap {
  width: var(--picker-w);
  max-width: calc(100vw - 120px);
  overflow: hidden;
  transform: translateX(0);
  /* Розгортання (базовий стан): спершу ширина (0.16s), потім рух панелі
     назад (0.2s), зі зсувом на тривалість ширини — щоб місце вже було
     звільнене до того, як панель в’їде в нього. */
  transition: width 0.16s ease 0s, transform 0.2s ease 0.16s;
}
.book-picker-rail.collapsed .book-picker-wrap {
  width: 0;
  /* ВАЖЛИВО: тут навмисно -454px (фіксоване число з тієї ж змінної), а НЕ
     -100%. Відсоток у transform рахується від ПОТОЧНОЇ ширини самого
     елемента — а вона в цей самий момент теж анімується (width: 454px→0px)
     нижче. Через це -100% на другому кроці (коли стуляється місце) сама
     собою зменшувалась услід за шириною, що тягнуло вже сховану панель
     НАЗАД, і вона встигала на мить знову "виглянути" з-під лівого краю,
     перш ніж остаточно зникнути — звідси й ривок/недомальовка. Фіксоване
     значення в пікселях від ширини руху не залежить, тож панель, раз
     виїхавши, більше нікуди не зсувається. */
  transform: translateX(calc(-1 * var(--picker-w)));
  /* Згортання: спершу панель від'їжджає ліворуч (0.2s), і лише потім (з
     тією ж затримкою) стуляється звільнене місце (0.16s). */
  transition: transform 0.2s ease 0s, width 0.16s ease 0.2s;
}

.picker-bookmark {
  position: absolute;
  top: 18px;
  left: var(--picker-w);
  transition: left 0.36s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 34px;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 12px 12px 0;
  background: var(--card);
  color: var(--orange);
  cursor: pointer;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.05);
  z-index: 5;
  writing-mode: vertical-rl;
  /* Пункт 2 (нове прохання): швидкі повторні дотики стилусом по закладці
     інакше трактуються браузером як подвійний клік і виділяють текст
     "КНИГИ" — це заважає користуватись закладкою. Виділення й системні
     жести довгого натискання тут вимкнені зовсім. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
/* -24px = мінус лівий відступ .lesson-body (padding: 20px 24px) — рівно
   стільки, щоб закладка своїм лівим краєм торкнулась справжнього краю
   вікна браузера, а не лише краю самої панелі (яка сидить із відступом
   24px через padding контейнера уроку). Якщо цей відступ .lesson-body
   зміниться — поправити й тут те саме число. */
.book-picker-rail.collapsed .picker-bookmark { left: -24px; }
.picker-bookmark:hover { background: var(--orange-light); }
.picker-bookmark-icon { display: flex; justify-content: center; transform: rotate(180deg); }
.picker-bookmark-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transform: rotate(180deg);
}

.book-picker {
  display: flex;
  width: 454px;
  max-width: 454px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  overflow: hidden;
  height: 100%;
  min-height: calc(100vh - 130px);
}

.picker-col {
  width: 190px;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
}
.picker-col:last-child { border-right: none; }

.picker-col-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 4px 6px 8px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 8px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 2px;
  user-select: none;
}
.picker-item:hover { background: #f5f6f8; }
.picker-item.active-book { background: var(--orange-light); color: var(--orange); font-weight: 600; }
.picker-item.previewing { background: #eaf1ff; box-shadow: inset 0 0 0 1px var(--blue); }
.picker-item.live { background: #eafaf0; box-shadow: inset 0 0 0 1px var(--green); }
.picker-item .picker-item-meta { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* ---- Сторінки з прогресом (вже є відповіді/малюнки) підсвічуємо, щоб
   вчитель бачив, який матеріал вже пройдений (пункт 3). ---- */
.page-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-check-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); flex-shrink: 0; }

/* Прев'ю сторінки в списку (раунд V, збільшено в раунді X — реальна
   роздільність картинки суттєво вища за попередній розмір показу, тож просто
   виводимо її більшою) — сіра плашка-заглушка, поки зображення ще не
   завантажилось або ще не згенероване на сервері (404). */
.page-thumb-wrap {
  width: 64px;
  height: 84px;
  flex-shrink: 0;
  border-radius: 6px;
  background: #e3e5ea;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
  cursor: zoom-in;
}
.page-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-thumb:not([src]), .page-thumb[src=""] { display: none; }

/* Велике спливаюче прев'ю зліва від курсора при наведенні (раунд X) — один
   спільний елемент на весь список, керується з lesson.js. */
.page-thumb-hover-preview {
  display: none;
  position: fixed;
  z-index: 500;
  width: 220px;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0,0,0,0.28), 0 0 0 1px rgba(0,0,0,0.08);
  pointer-events: none;
}
.picker-item.page-item.touched:not(.live):not(.previewing) {
  background: #fff4e6;
}

.lesson-content { flex: 1; min-width: 0; }

.previewing input, .previewing select, .previewing button.choice-btn {
  pointer-events: none;
  opacity: 0.8;
}

.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #eaf1ff;
  border-bottom: 1px solid #c7d9fb;
  padding: 10px 24px;
  font-size: 14px;
  color: #1c3f8f;
}

/* ---- Приємний "порожній" екран до вибору сторінки / після завершення
   уроку — замінює колишню суху "дошку" (пункт 6). ---- */
.lesson-empty {
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  padding: 40px 20px;
}
.lesson-empty-icon {
  width: 92px;
  height: 92px;
  border-radius: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
  background: linear-gradient(135deg, #ffdcb0, #ffc2dd);
  box-shadow: 0 12px 28px rgba(232,114,44,0.18);
}
.lesson-empty h2 { margin: 0; color: var(--ink); font-size: 19px; }
.lesson-empty p { margin: 0; color: var(--muted); font-size: 14px; max-width: 380px; line-height: 1.5; }

/* ---- Індикатор завантаження (раунд R): спільний спінер для двох випадків —
   поки вантажаться дані нової сторінки (.lesson-loading, замінює весь вміст)
   і поки вантажиться сама картинка PDF-сторінки (.pdf-page-loading, шар
   поверх уже готової "рамки" сторінки) — без цього перехід на нову сторінку
   виглядав як зависання порожнього екрана. ---- */
.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(232,114,44,0.18);
  border-top-color: var(--orange);
  animation: pdf-spin 0.8s linear infinite;
}
@keyframes pdf-spin { to { transform: rotate(360deg); } }

.lesson-loading {
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.pdf-page-frame.is-loading { min-height: 420px; }
.pdf-page-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ---- Page content ---- */
.page-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.unit-badge {
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 16px;
}
.page-head .titles h1 { color: var(--orange); }

.page-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
@media (max-width: 800px) {
  .page-columns { grid-template-columns: 1fr; }
}

.section-title { color: #444; font-size: 15px; margin: 0 0 2px; font-weight: 700; }
.section-subtitle { color: var(--orange); font-weight: 700; font-size: 16px; margin: 0 0 14px; }

.exercise { margin-bottom: 24px; }
.exercise-instruction {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}
.exercise-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  background: var(--orange);
  color: #fff;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
}

.word-bank {
  background: var(--orange-light);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  background: #fff;
  border: 1px solid #f0c9a4;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 13px;
  cursor: pointer;
  color: #8a4a12;
}
.chip:hover { background: var(--orange); color: #fff; }

.fill-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 14px;
  flex-wrap: wrap;
}
.fill-item .num { color: var(--muted); width: 16px; }
.fill-item input[type=text] {
  flex: 1;
  min-width: 90px;
  padding: 6px 8px;
  border: none;
  border-bottom: 2px solid #c9c9cf;
  background: transparent;
  font-size: 14px;
}
.fill-item input[type=text]:focus { outline: none; border-color: var(--orange); }
.fill-item input.saved-remote { background: #fff7ec; }

.choice-item { margin-bottom: 10px; font-size: 14px; }
.choice-item .options { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.choice-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  font-style: italic;
}
.choice-btn.selected {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.dialogue-line { margin-bottom: 10px; font-size: 14px; line-height: 1.6; }
.dialogue-line .speaker { font-weight: 700; margin-right: 6px; }
.dialogue-line input[type=text] {
  border: none;
  border-bottom: 2px solid #c9c9cf;
  background: transparent;
  font-size: 14px;
  padding: 2px 4px;
  width: 130px;
}
.dialogue-line input[type=text]:focus { outline: none; border-color: var(--orange); }
.dialogue-bubble {
  background: #fbeee0;
  border-radius: 10px;
  padding: 8px 12px;
  display: inline-block;
  max-width: 90%;
}

.match-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.match-item select {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  max-width: 220px;
}

.letter-prefix {
  font-weight: 700;
  border-bottom: 2px solid #c9c9cf;
  padding: 2px 0 2px 4px;
}
.letter-input {
  border: none;
  border-bottom: 2px solid #c9c9cf;
  background: transparent;
  font-size: 14px;
  padding: 2px 2px;
  width: 90px;
}
.letter-input:focus { outline: none; border-color: var(--orange); }
.letter-group { display: inline-flex; align-items: baseline; }

.transform-item { margin-bottom: 14px; font-size: 14px; }
.transform-item .given { color: var(--muted); margin-bottom: 2px; }
.transform-item .row2 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.transform-item input[type=text] {
  border: none;
  border-bottom: 2px solid #c9c9cf;
  background: transparent;
  font-size: 14px;
  padding: 2px 4px;
  min-width: 140px;
  flex: 1;
}
.transform-item input[type=text]:focus { outline: none; border-color: var(--orange); }
.transform-item .hint { color: var(--orange); font-weight: 600; }

/* ---- 'flow' exercise type (Книга 2: связный текст/диалог с разными пропусками) ---- */
.flow-heading-block {
  background: #fbeee0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.flow-heading { font-weight: 700; color: #8a4a12; margin-bottom: 6px; }
.flow-para { font-size: 14px; line-height: 1.7; margin-bottom: 12px; }
.flow-numbered { font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
.flow-numbered .num { color: var(--muted); margin-right: 4px; }
.flow-para input[type=text], .flow-numbered input[type=text], .dialogue-bubble input[type=text] {
  border: none;
  border-bottom: 2px solid #c9c9cf;
  background: transparent;
  font-size: 14px;
  padding: 2px 4px;
  min-width: 110px;
}
.flow-para input[type=text]:focus, .flow-numbered input[type=text]:focus { outline: none; border-color: var(--orange); }
select.inline-select {
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  max-width: 220px;
}

/* ---- 'clue-fill' exercise type (упрощённый кроссворд) ---- */
.clue-group-title {
  font-weight: 700;
  color: var(--orange);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 14px 0 8px;
}
.clue-item { margin-bottom: 10px; }
.clue-text { font-size: 14px; margin-bottom: 4px; }
.clue-item input[type=text] {
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-bottom: 2px solid #c9c9cf;
  background: transparent;
  font-size: 14px;
}
.clue-item input[type=text]:focus { outline: none; border-color: var(--orange); }

.presence-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  min-height: 14px;
}

/* ---- Teacher layout: sidebar with checkboxes + fixed start button ---- */
.teacher-layout {
  display: flex;
  align-items: flex-start;
  max-width: 1180px;
  margin: 0 auto;
  gap: 24px;
  padding: 24px 20px 60px;
}

/* Шапка (.topbar) закріплена завжди зверху (position: sticky) — бічна
   панель прилипає ПІД нею, а не під самим верхом viewport, і займає решту
   висоти екрана фіксовано (height, а не max-height), щоб групи й учні
   могли ділити цю висоту на дві НЕЗАЛЕЖНІ прокручувані області нижче. */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 88px;
  height: calc(100vh - 88px - 24px);
  overflow: hidden;
}

/* Кнопка "Почати урок" — над вкладками груп/учнів, завжди на виду. */
.sidebar-start {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Вкладки "Групи" / "Учні" — показуємо тільки один список одразу, за
   замовчуванням групи (їх обираємо в першу чергу). Підказка про те, що
   галочка групи виділяє всіх її учнів, тепер живе в title (hover) на самій
   вкладці "Групи", а не окремим текстом під заголовком. */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 11px 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.sidebar-tab:hover { color: var(--ink); }
.sidebar-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

.sidebar-section {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-section[hidden] { display: none; }

.sidebar-list {
  overflow-y: auto;
  padding: 10px;
  flex: 1 1 auto;
  min-height: 0;
}

.main-area { flex: 1; min-width: 0; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.check-row:hover { background: #f5f6f8; }
.check-row input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; flex-shrink: 0; }
.check-row .label { font-size: 14px; }
.check-row .label .meta { color: var(--muted); font-size: 12px; display: block; }
/* Компактний рядок учня в одну лінію: "Ім'я (Група)" — група вписана
   прямо в текст, без окремого рядка метаданих. */
.check-row .label .meta-inline { color: var(--muted); font-weight: 400; }

.group-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px 8px;
  margin-bottom: 10px;
}
.group-block .group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  cursor: pointer;
  font-weight: 600;
}
.group-block .group-members {
  margin-left: 27px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.group-block .group-members .check-row { padding: 4px 6px; }

/* ---- Live answer feedback ---- */
/* "Последний ответ" — рамка вокруг поля, которое только что изменили (любая сторона). */
.answer-recent {
  outline: 3px solid var(--blue) !important;
  outline-offset: 2px;
  border-radius: 4px;
  transition: outline-color 0.2s ease;
}

/* Подсветка правильно/неправильно — виден только учителю. */
.answer-correct {
  background: #eafaf0 !important;
  box-shadow: inset 0 0 0 2px var(--green);
  border-radius: 4px;
}
.answer-incorrect {
  background: #fdecec !important;
  box-shadow: inset 0 0 0 2px #d64545;
  border-radius: 4px;
}
select.answer-correct, select.answer-incorrect { padding: 4px 6px; }
.choice-item.answer-correct, .choice-item.answer-incorrect {
  padding: 4px 6px;
  margin: -4px -6px 6px;
}

/* ---- Дерево PDF-книг (Издательство → Серия → Книга) в левой колонке ---- */
#booksCol { width: 260px; }

.picker-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 700;
  margin: 14px 6px 6px;
}
.picker-section-title:first-child { margin-top: 4px; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.tree-row:hover { background: #f5f6f8; }
.tree-toggle-icon {
  display: inline-block;
  width: 10px;
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.tree-node.collapsed > .tree-children { display: none; }
.tree-node.collapsed > .tree-row .tree-toggle-icon { transform: rotate(-90deg); }
.tree-children {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px dashed var(--border);
}
.tree-empty-note { font-size: 12px; color: var(--muted); padding: 6px 8px; }

/* ---- Пункт книги в дереві PDF: більша іконка на 2 рядки (назва + к-сть
   сторінок), назва обрізається трьома крапками й не з'їжджає під іконку,
   повна назва — у підказці при наведенні (пункт 2). ---- */
.picker-item.tree-book {
  position: relative;
  align-items: flex-start;
  font-size: 13px;
  padding: 7px 8px;
}
.tree-book-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--orange-light);
  color: var(--orange);
}
.picker-item.tree-book.active-book .tree-book-icon { background: #fff; }
.tree-book-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 1px;
}
.tree-book-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-book-text .picker-item-meta { margin-top: 0; }
.tree-book-tooltip {
  position: absolute;
  left: 8px;
  top: 100%;
  margin-top: 4px;
  background: var(--ink);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  max-width: 260px;
  z-index: 50;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
}
.tree-book:hover .tree-book-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---- PDF-страница: картинка + холст для рисования поверх ---- */
.pdf-page-wrap { max-width: 980px; margin: 0 auto; padding: 20px 20px 80px; }

/* ---- Раунд O: панель інструментів зліва від сторінки (наполовину "заходить"
   на її ліве поле — .pdf-toolbar нижче), шапка з назвою книги накладена
   поверх верхньої кромки самої сторінки (.pdf-page-head нижче) — разом це
   звільняє під сторінку PDF ще два рядки висоти порівняно з попереднім
   компонуванням, де і шапка, і панель займали власні рядки згори. ---- */
.pdf-page-area {
  display: flex;
  align-items: flex-start;
  min-width: 0;
}
.pdf-page-frame {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

/* Видавництво/серія + назва книги й сторінки — в один компактний рядок,
   накладений напівпрозорою підложкою поверх самого верхнього краю сторінки
   (а не в окремому рядку над нею), щоб віддати максимум місця самій сторінці.
   pointer-events:none — це суто інформаційний напис, він не повинен
   заважати малювати навіть у верхньому краю сторінки. */
.pdf-page-head {
  /* Раунд P: напис тепер "осідлав" саму верхню кромку сторінки — рівно
     половина висоти напису над сторінкою, половина — на ній (translateY(-50%)
     від top:0, тобто від верхнього краю .pdf-page-frame, який співпадає з
     верхнім краєм зображення сторінки), а не повністю всередині, як раніше. */
  position: absolute;
  top: 0;
  left: 8px;
  right: 8px;
  transform: translateY(-50%);
  z-index: 3;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: rgba(255,255,255,0.88);
  border-radius: 8px;
  padding: 5px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.pdf-page-head .unit-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 8px;
}
.pdf-page-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--orange);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pdf-zoom-reset[hidden] { display: none; }

/* ---- Рамка, що обрізає масштабовану сторінку (пункт 10): сам .pdf-canvas-stage
   всередині масштабується жестами, а ця рамка лишається фіксованого розміру
   й ховає все, що виходить за межі — так масштабується лише сторінка PDF,
   а не вся веб-форма. ---- */
.pdf-canvas-viewport {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  touch-action: none;
}
.pdf-canvas-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  transform-origin: 0 0;
  will-change: transform;
}
/* ---- Сторінка PDF: заборона виділення/збереження картинки й контекстного
   меню (пункти "прибрати можливість зберігати" та "вимкнути виділення").
   pointer-events:none на <img> — усі жести й так обробляє canvas зверху,
   а сам <img> перестає бути "ціллю" для довгого натискання/правої кнопки. ---- */
.pdf-page-wrap {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.pdf-page-img {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
.pdf-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-touch-callout: none;
}
.previewing .pdf-canvas { cursor: default; }

/* ---- Плавающее поле ввода для инструмента "Текст" ---- */
.pdf-text-input {
  position: absolute;
  transform: translate(-2px, -2px);
  min-width: 120px;
  padding: 3px 6px;
  border: 1px dashed var(--blue);
  border-radius: 4px;
  background: rgba(255,255,255,0.92);
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  z-index: 5;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ---- Закреплённая панель инструментов рисования (шапка урока закреплена
   через .lesson-header выше) — при масштабировании PDF-страницы жестами
   (пункт 10) шапка и панель инструментов остаются на месте и рабочими.
   Раунд O: панель тепер вертикальна колонка ЗЛІВА від сторінки, зсунута
   так, щоб лівий край сторінки проходив рівно по середині кнопок (наполовину
   "лежить" на порожньому полі сторінки, наполовину — у порожньому місці
   зліва від неї, де раніше й так нічого не було).
   Раунд P: власної "підложки" (фон+рамка+тінь навколо ВСІЄЇ панелі) більше
   немає — кожна кнопка тепер висить окремим "стікером" (свій фон і тінь —
   див. .pdf-tool-btn нижче), без єдиної рамки навколо групи. Також панель
   зсунута вниз на висоту однієї кнопки, щоб дати відступ від верхньої
   кромки сторінки. Явний z-index гарантує, що кнопки завжди клікабельні
   (малюються НАД холстом). ---- */
.pdf-toolbar {
  position: sticky;
  top: 72px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  margin: 40px -22px 0 0;
}

/* ---- Компактные кнопки-иконки для инструментов рисования (пункт 8) ----
   Раунд P: кожна кнопка сама по собі — власна тінь замість спільної
   підложки на всю панель, щоб вони виглядали як окремі "стікери",
   що лежать на краю сторінки. ---- */
.pdf-tool-btn {
  padding: 8px 10px;
  line-height: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.16);
}
.pdf-tool-btn svg { display: block; }
/* Раунд R: підсвітка обраного інструменту (олівець/гумка/текст) — загубилась
   при переробці панелі в раунді O, повертаємо. Явно видно, що зараз обрано:
   малювання, стирання чи текст. */
.pdf-tool-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 2px 10px rgba(46,110,235,0.45);
}

.pdf-toolbar-sep {
  height: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 2px 0;
}

@media (max-width: 640px) {
  /* На вузькому екрані менше зайвого поля зліва від сторінки — трохи менше
     "заходимо" на саму сторінку, щоб не перекривати забагато. */
  .pdf-toolbar { margin-right: -16px; }
}

/* ---- Прокрутка колонок "Книги" / "Страницы" (пункт 5) ---- */
.picker-col {
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}
#booksList, #pagesList {
  max-height: calc(100vh - 210px);
  overflow-y: auto;
}

/* ---- Дерево книг: отступ между иконкой и текстом (папки/серии) ---- */
.tree-icon {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  margin-right: 2px;
}
.tree-row .tree-icon { color: var(--muted); }

/* ---- Модальное окно "Управление" (ученики/группы + PDF-учебники) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 48px);
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 6px 10px 6px 6px;
  flex-shrink: 0;
}

.modal-tabs { display: flex; gap: 4px; }
.modal-tab {
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.modal-tab:hover { color: var(--ink); }
.modal-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

.modal-close {
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
}
.modal-close:hover { background: #f0f1f3; color: var(--ink); }

.modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
}
.modal-pane[hidden] { display: none; }

/* Стилізоване вікно підтвердження (заміна window.confirm) — по центру
   екрана, з бекдропом, у тому ж стилі, що й решта сайту. */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  padding: 24px;
}
.confirm-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 22px 24px 20px;
  text-align: center;
}
.confirm-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.confirm-message {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.confirm-actions .btn { flex: 1; justify-content: center; }

/* Підвкладки всередині вкладки модального вікна (наприклад "Учні"/"Групи"
   всередині "Учні та групи") — той самий принцип, що й .modal-tabs, трохи
   скромніший за розміром, бо це вже другий рівень. */
.subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.subtab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--orange); border-bottom-color: var(--orange); }
.subtab-pane[hidden] { display: none; }

/* Спливаюча форма (додати/редагувати учня, додати групу) — по центру екрана,
   поверх основного модального вікна "Керування"; можна відкрити вкладено
   (наприклад форма нової групи поверх форми учня). */
.form-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  padding: 24px;
}
.form-popup-card {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 24px;
}
.form-popup-card h2 { margin: 0 0 16px; font-size: 17px; }
.form-popup-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Рядки прогресу завантаження PDF-файлів (попап "Додати підручники") —
   з'являються під полями форми, по одному рядку на кожен обраний файл. */
.upload-rows { margin: 4px 0 14px; display: flex; flex-direction: column; gap: 10px; }
.upload-row { display: flex; align-items: center; gap: 10px; }
.upload-row-name {
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink);
}
.upload-row-bar {
  flex: 1 1 auto;
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
}
.upload-row-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--orange);
  transition: width 0.15s ease;
}
.upload-row-status {
  flex: 0 0 auto;
  min-width: 34px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.upload-row-ok .upload-row-bar-fill { background: var(--green); }
.upload-row-ok .upload-row-status { color: var(--green); font-weight: 700; }
.upload-row-error .upload-row-bar-fill { background: #d64545; }
.upload-row-error .upload-row-status { color: #d64545; }

/* ---- Общие формы внутри модального окна (создание ученика/группы/книги) ---- */
.inline-form {
  background: #f7f7f9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
}
.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.field-row .field { flex: 1; min-width: 140px; margin-bottom: 0; }

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row-actions .btn { padding: 6px 12px; font-size: 13px; }

.tag-muted {
  background: #eceef1;
  color: var(--muted);
}
.tag-green {
  background: #e3f5e9;
  color: var(--green);
}

/* ---- Прокрутка списків учнів/груп у вікні "Керування" (пункт 2, раунд 6) ---- */
#manageStudentsList, #manageGroupsList {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

/* ---- Групування списку PDF-підручників за папками видавництво → серія
   у вікні керування (пункт 5, раунд 6) ---- */
.book-group-publisher {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: #f7f7f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 14px 0 4px;
}
.book-group-publisher:first-child { margin-top: 0; }

.book-group-series {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 700;
  margin: 8px 0 2px 14px;
}

.book-group-row {
  margin-left: 14px;
  padding-left: 6px;
}

.book-group-empty {
  margin-left: 14px;
  padding: 4px 8px 10px;
}
