:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1d2430;
  --muted: #6b7480;
  --line: #e6e9ef;
  --brand: #b8412f;
  --brand-soft: #f7e6e2;
  --accent: #2f6fb8;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.06), 0 8px 24px rgba(20, 30, 50, 0.05);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Шапка */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

/* Шапка шире контента: у модератора семь пунктов меню, в 960 px они не влезают */
.site-header .wrap { max-width: 1120px; }

/* Высота по содержимому: если меню перенеслось на вторую строку, шапка
   становится выше, а не обрезает навигацию (раньше был height: 64px). */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  min-height: 64px;
  height: auto;
  padding-top: 6px;
  padding-bottom: 6px;
}

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-name { font-weight: 700; font-size: 18px; white-space: nowrap; }

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}
.nav-link.active, .nav-link:hover { color: var(--brand); background: var(--brand-soft); }

.banner {
  background: #e23b2e;
  color: #fff;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  letter-spacing: 0.2px;
}

.content { padding-top: 20px; padding-bottom: 40px; }

/* Панель вкладок: отступ от полосы адресов, иначе вкладки липнут к шапке */
.page-toolbar { padding-top: 14px; }

/* Управление */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }

select {
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  min-width: 260px;
}

.course-tabs { display: flex; gap: 8px; }

.tab {
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
}
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Навигация по месяцам */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 18px;
}

.nav-btn {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
}
.nav-btn:hover { background: #eef4fb; }

.month-title { margin: 0; font-size: 20px; }

/* Фильтр расписания: кнопка рядом с месяцем и панель под ним */
.month-center { display: flex; align-items: center; gap: 6px; }
.filter-btn {
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
  font-family: inherit;
  padding: 6px 9px;
  color: inherit;
}
.filter-btn:hover { background: #eef4fb; }
.filter-btn.is-active { background: var(--accent); border-color: var(--accent); }
.filter-reset { color: var(--muted); padding: 6px 8px; }
.filter-reset:hover { background: #fdecea; color: #c0392b; }

.filter-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 14px;
  margin: -8px 0 16px;
}
.filter-form { display: flex; flex-direction: column; gap: 12px; }
.filter-block { display: flex; flex-direction: column; gap: 6px; }
.filter-label,
.filter-row .field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.filter-weekdays,
.filter-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  max-width: 320px;
}
.filter-weekdays span { font-size: 10px; color: var(--muted); text-align: center; }
.filter-day { position: relative; }
.filter-day input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.filter-day > span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
  background: #fff;
  pointer-events: none;
}
.filter-day.has-lessons > span { color: var(--ink); border-color: #cfd8e3; font-weight: 600; }
.filter-day.has-lessons > span::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
}
.filter-day.is-selected > span,
.filter-day:has(input:checked) > span { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-day.is-selected > span::after,
.filter-day:has(input:checked) > span::after { background: #fff; }
.filter-day.is-empty { visibility: hidden; }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; }
.filter-row .field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }

@media (max-width: 720px) {
  .filter-row .field { min-width: 140px; flex: 1 1 140px; }
  .filter-weekdays, .filter-days { max-width: 100%; }
  .filter-day > span { height: 26px; font-size: 12px; }
}

/* Дни и занятия */
.days { display: flex; flex-direction: column; gap: 14px; }

.day-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.day-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  background: #fafbfd;
  border-bottom: 1px solid var(--line);
}
.day-date { font-weight: 700; font-size: 16px; }
.day-weekday { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }

.day-lessons { display: flex; flex-direction: column; }

.lesson {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  align-items: start;
}
.lesson:first-child { border-top: none; }

.lesson-time { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); white-space: nowrap; }

.lesson-subject { font-weight: 600; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.chip {
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef1f5;
  color: #46505d;
}
.chip-soft { background: var(--brand-soft); color: var(--brand); }
.chip-red { background: #fdecea; color: #c0392b; font-weight: 700; }
.chip-amber { background: #fdf3e2; color: #b9770e; font-weight: 700; }

.lesson-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* Комментарий модератора к занятию — серым внизу карточки, виден всем ролям */
.lesson-note {
  grid-column: 1 / -1;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-line;
}
.mod-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  white-space: pre-line;
}
.fmt { font-size: 12px; color: var(--muted); white-space: nowrap; }

.join {
  display: inline-block;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 9px;
  white-space: nowrap;
}
.join:hover { background: #245a96; }

.lesson-cancelled .lesson-subject,
.lesson-cancelled .lesson-time { text-decoration: line-through; color: var(--muted); }
.lesson-cancelled { background: #fffafa; }

/* Прочее */
.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.muted { color: var(--muted); font-size: 14px; }

.site-footer { border-top: 1px solid var(--line); background: var(--card); }
.addresses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 16px 16px;
  color: var(--muted);
  font-size: 13px;
}
.addresses strong { color: var(--ink); }

@media (max-width: 560px) {
  .lesson { grid-template-columns: 100px 1fr; }
  .lesson-side { grid-column: 1 / -1; align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  select { min-width: 0; width: 100%; }
}

/* Навигация: имя пользователя */
.nav { display: flex; align-items: center; column-gap: 4px; row-gap: 2px; flex-wrap: wrap; min-width: 0; }
.nav-user {
  font-weight: 600;
  color: var(--ink);
  padding: 8px 6px;
  font-size: 15px;
  /* Длинное имя («Елена Садовникова») не должно ломать строку меню */
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Алерты */
.alert {
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-ok { background: #e8f6ee; color: #1e7a44; border-color: #c7ebd6; }
.alert-error { background: #fdecea; color: #c0392b; border-color: #f5cdc7; }
.alert-warn { background: #fdf3e2; color: #9a6b0e; border-color: #f3e0bd; }

/* Карточки и формы авторизации */
.auth-wrap { display: flex; justify-content: center; padding: 20px 0 40px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card { width: 100%; max-width: 460px; padding: 28px 24px; }
.auth-title { margin: 0 0 20px; font-size: 22px; }
.auth-hint { color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.auth-hint a { color: var(--accent); font-weight: 600; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field > span { font-size: 13px; font-weight: 600; color: #46505d; }
.form-block { display: flex; flex-direction: column; }

.input {
  font-size: 15px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.input:focus { outline: 2px solid #cfe0f4; border-color: var(--accent); }
select.input[multiple] { height: auto; }

/* Кнопки */
.btn {
  display: inline-block;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f2f4f8; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #a1382a; }
.btn-small { font-size: 13px; padding: 7px 11px; }
.btn-ok { background: #e8f6ee; border-color: #c7ebd6; color: #1e7a44; }
.btn-ok:hover { background: #d5efe0; }
.btn-danger { background: #fdecea; border-color: #f5cdc7; color: #c0392b; }
.btn-danger:hover { background: #f9dcd6; }

/* Раздел модератора */
.page-title { margin: 4px 0 20px; font-size: 24px; }
/* Отметка «Проверено» у папок студентов в «Домашке» */
.hw-check-cell { width: 108px; text-align: center; }
.hw-check-form { margin: 0; display: inline; }
.hw-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1.5px solid #c3cad4;
  border-radius: 4px;
  background: #fff;
  color: #1e9e5a;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.hw-check:hover { border-color: var(--brand); }
.hw-check.is-on { border-color: #1e9e5a; background: #eefaf3; }
span.hw-check { cursor: default; }
span.hw-check:hover { border-color: #c3cad4; }
span.hw-check.is-on:hover { border-color: #1e9e5a; }
.hw-check-legend { margin: 8px 0 0; }

/* Сводка «сколько папок и файлов внутри» под заголовком папки */
.hw-folder-stats { margin: -12px 0 18px; }
.admin-section { margin-bottom: 32px; }
.admin-section h2 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.count {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  font-size: 13px;
  padding: 2px 9px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { background: #fafbfd; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
/* Кнопки в строке держим ВНУТРИ ячейки: flex на самом <td> ломает таблицу
   (ячейка перестаёт быть ячейкой, строки «поезжают»). */
.table td { vertical-align: middle; }
.table .actions { white-space: normal; }
/* Длинные названия программ переносим — иначе таблица растягивается */
.table .cell-program { white-space: normal; min-width: 150px; max-width: 260px; }
.actions-inner {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.actions-inner form { margin: 0; }

/* Просмотр видео «Домашки»: чёрный фон, плеер на всю ширину */
.video-wrap {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 0 14px;
}
.video-player {
  display: block;
  width: 100%;
  max-height: 72vh;
  background: #000;
}
/* Видео с Vimeo: плеер встраивается iframe'ом с соотношением 16:9 */
.video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 72vh;
  background: #000;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* Telegram в таблицах администратора: аккаунт и кнопка «скопировать» */
.tg-cell { display: flex; align-items: center; gap: 6px; }
.tg-copy {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  opacity: 0.75;
}
.tg-copy:hover { border-color: var(--brand); opacity: 1; }
.tg-copy.copied {
  border-color: #1e9e5a;
  color: #1e9e5a;
  opacity: 1;
}

.status { font-weight: 600; font-size: 13px; }
.status-active { color: #1e7a44; }
.status-pending { color: #9a6b0e; }
.status-blocked, .status-rejected { color: #c0392b; }

/* Замок вместо ссылки */
.locked {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  background: #f1f3f7;
  border: 1px dashed #ccd3dd;
  border-radius: 9px;
  padding: 7px 12px;
  white-space: nowrap;
}

/* Баннер на странице расписания */
.banner-page {
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  letter-spacing: 0.2px;
}

/* Логотип в шапке */
.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  background: #000;
  display: block;
}

/* Адреса в шапке */
.addresses-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  padding: 6px 16px 12px;
  color: var(--muted);
  font-size: 13px;
}
.addresses-top strong { color: var(--ink); }

/* Подвал */
.footer-inner { padding: 16px; color: var(--muted); font-size: 13px; }

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
}

.footer-links { display: inline-flex; flex-wrap: wrap; gap: 8px 16px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }

/* Контакты школы в подвале: телефон, почта, соцсети, ссылки на сайт */
.footer-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 13px;
}
.footer-contacts a { color: var(--muted); text-decoration: none; }
.footer-contacts a:hover { color: var(--brand); text-decoration: underline; }

/* Правовые страницы (политика, соглашение) */
.legal { max-width: 760px; }
.legal h2 { margin: 26px 0 8px; font-size: 18px; }
.legal p { margin: 8px 0; }
.legal ul { margin: 8px 0; padding-left: 22px; }
.legal li { margin: 4px 0; }
.legal code {
  background: #eef1f6;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
}
.legal a { color: var(--accent); }

/* «Домашка» */
.crumbs { font-size: 14px; margin: 0 0 8px; }
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.hw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.hw-card { display: block; padding: 16px; text-decoration: none; color: var(--ink); }
.hw-card:hover { border-color: var(--brand); }
.hw-card-title { font-weight: 600; margin-bottom: 4px; }

/* Карточка «Создать папку»: поля не липнут к рамке, кнопка не растягивается
   на всю ширину (остальные формы — вход, регистрация — остаются как были). */
.hw-create { margin-top: 8px; padding: 20px; }
.hw-create h2 { margin: 0 0 12px; font-size: 18px; }
.hw-create > p.muted { margin: 0 0 14px; }
.hw-create .form > .btn-primary,
.hw-upload > .btn-primary { align-self: flex-start; }
.hw-create .empty { margin: 0; }
.hw-upload { margin-bottom: 16px; }
.hw-danger { margin: 0 0 16px; }
.hw-files td:first-child { white-space: normal; word-break: break-word; }

/* Таблица файлов: компактные строки, кнопки в один ряд */
.hw-files th, .hw-files td { padding: 8px 12px; }
.hw-files td { font-size: 13.5px; }
.hw-file-cell { width: 210px; max-width: 210px; }
.hw-file-name {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  outline: none;
  cursor: pointer;
}
/* Клик по имени раскрывает его целиком, второй клик — сворачивает */
.hw-file-name.is-open {
  max-width: 210px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}
.hw-col-meta { width: 1%; }
.hw-files .hw-meta { color: var(--muted); white-space: nowrap; width: 1%; }
.hw-actions { white-space: nowrap; }
.hw-files .actions-inner { flex-wrap: nowrap; gap: 6px; }
.hw-files .btn-small {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12.5px;
}
.hw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #f5cdc7;
  border-radius: 8px;
  background: #fdecea;
  color: #c0392b;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.hw-icon-btn:hover { background: #f9dcd6; }
.hw-files tbody tr:hover { background: #fbfcff; }

@media (max-width: 560px) {
  .hw-file-cell { width: auto; max-width: none; }
  .hw-file-name {
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .hw-files .actions-inner { flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
}
/* Заголовки разделов внутри папки: «Папки» / «Файлы» */
.hw-subtitle { margin: 22px 0 10px; font-size: 18px; }
/* Поле со списком имён при быстром добавлении папок */
.hw-names {
  width: 100%;
  min-height: 96px;
  font-family: inherit;
  resize: vertical;
}

/* Панель действий над папкой (переименовать / удалить) */
.hw-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.hw-rename {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}
.hw-rename .input { max-width: 280px; }

/* Радио и галочки в формах «Домашки» */
.hw-mode { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 12px; }

/* Уведомления */
.notif-list { display: flex; flex-direction: column; gap: 12px; }
.notif-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.notif-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.notif-date { color: var(--muted); font-size: 12px; margin-left: auto; }
.notif-subject { font-weight: 600; }
.notif-to { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.notif-body {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  color: #36404d;
  background: #f8f9fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  overflow-x: auto;
}

/* Настройки уведомлений */
.settings-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.settings-card { padding: 20px; }
/* Карточка «Уведомления» занимает всю ширину */
.settings-card--wide { grid-column: 1 / -1; }
.channel-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.channel-row:first-of-type { border-top: none; padding-top: 2px; }
.channel-toggle { min-width: 220px; }
.channel-ok { color: #1e9e5a; font-weight: 600; font-size: 13px; }
.channel-box {
  margin: 0 0 14px 28px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}
.channel-box p { margin: 0 0 6px; }
.settings-card h2 { margin: 0 0 12px; font-size: 18px; }
.settings-card .muted { margin-top: 0; }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.code-badge {
  display: inline-block;
  font-family: ui-monospace, Menlo, Monaco, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 10px;
  padding: 10px 16px;
}
/* Код привязки бота копируется по клику */
.code-badge[data-copy] { cursor: pointer; user-select: none; transition: background 0.15s, color 0.15s; }
.code-badge[data-copy]:hover { background: #f2d9d3; }
.code-badge[data-copy]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.code-badge.is-copied {
  background: #e8f6ee;
  color: #1e7a44;
}
.small { font-size: 12px; }

/* Форма занятия (модератор) */
.lesson-form { padding: 22px; margin-bottom: 24px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.field-wide { grid-column: 1 / -1; }
.time-row { display: flex; gap: 12px; }
.time-row .form-field { flex: 1; }

/* Управление занятием */
.lesson-admin { display: flex; gap: 6px; margin-top: 8px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lesson-admin form { display: inline; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
}
.icon-btn:hover { background: #f2f4f8; }

/* Офлайн-страница */
.offline-box { padding: 60px 20px; }
.offline-emoji { font-size: 46px; margin-bottom: 6px; }
.offline-title { margin: 0 0 8px; font-size: 22px; }

/* Кнопка установки приложения */
.install-btn {
  background: var(--brand-soft);
  color: var(--brand);
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.install-btn:hover { background: #f2d9d3; }

/* Очередь загрузки «Домашки»: полоса прогресса и карточки заданий */
.hw-progress { margin: 12px 0 4px; }
.hw-progress-text { font-size: 14px; color: #46505d; margin-bottom: 6px; }
.hw-bar {
  height: 10px;
  border-radius: 999px;
  background: #eceff3;
  overflow: hidden;
}
.hw-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.3s ease;
}
.hw-jobs { margin: 10px 0 18px; display: flex; flex-direction: column; gap: 10px; }
.hw-job {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
.hw-job-name { font-weight: 600; margin-bottom: 4px; }
.hw-job-status { font-size: 14px; color: #46505d; margin-bottom: 6px; }
.hw-job-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Значки «Домашки»: папка и Excel — картинками (одинаково на всех
   устройствах), остальные типы файлов — эмодзи */
.icon-inline {
  height: 15px;
  width: auto;
  margin-right: 7px;
  vertical-align: -2px;
}

/* Правка таблицы Excel прямо в приложении */
.sheet-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.sheet-switch { margin: 0; }
.sheet-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
table.sheet { border-collapse: collapse; font-size: 14px; }
table.sheet th {
  position: sticky;
  top: 0;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid var(--line);
  z-index: 1;
}
table.sheet .sheet-corner { left: 0; z-index: 2; }
table.sheet tbody th.sheet-rownum {
  position: sticky;
  left: 0;
  background: #f6f7f9;
  color: #46505d;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--line);
  z-index: 1;
}
table.sheet td { border: 1px solid var(--line); padding: 0; }
input.sheet-cell {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  padding: 6px 10px;
  min-width: 110px;
  width: 100%;
}
input.sheet-cell:focus {
  background: #fff8e1;
  box-shadow: inset 0 0 0 2px var(--brand);
}
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }

/* Пустые строки в конце таблицы — для новой записи */
table.sheet tr.sheet-empty-row td { background: #fcfcfd; }
table.sheet tr.sheet-empty-row th.sheet-rownum { color: #9aa4b0; }

/* Зелёный значок у вкладки «Заявки»: сколько заявок ждёт модератора */
.nav-badge {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #1e9e5a;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* Страница «Пользователи»: смена роли и перевод в выпускники */
.admin-tools { margin-bottom: 18px; }
.role-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  margin-top: 4px;
}
.role-form .input-small { max-width: 160px; }
.role-form[hidden] { display: none; }
.role-cell { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
/* Роль студента/выпускника — кликабельная «таблетка» */
.chip-edit {
  border: 1px solid transparent;
  border-radius: 999px;
  background: #eef1f5;
  color: #46505d;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chip-edit:hover { background: #e2e8f0; border-color: #cfd8e3; }
.chip-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Вторая роль — это статус, а не кнопка действия: обычный шрифт */
.chip-edit--soft { font-weight: 400; }
.input-small { padding: 5px 8px; font-size: 14px; }


/* Липкая шапка на страницах расписания: вкладки + адреса + плашка */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
.site-header--sticky .header-inner { min-height: 52px; height: auto; }
.site-header--sticky .nav-link { padding: 6px 10px; font-size: 14px; }
.site-header--sticky .addresses-top { padding: 4px 16px 8px; }
.site-header--sticky .banner-page { border-radius: 0; margin: 0; font-size: 12px; padding: 6px 12px; }
.site-header--sticky .brand-logo { width: 36px; height: 36px; }

/* Объединённая таблица расписания (вкладка «Модераторам») */
.mod-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mod-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.mcol-date { width: 84px; }
.mcol-link { width: 150px; }
.mod-table th, .mod-table td { border: 1px solid var(--line); vertical-align: middle; }
.mod-table thead th { background: #eef2f8; text-align: center; font-size: 13px; padding: 8px 10px; color: #22303f; }
.mod-table .mod-group { font-weight: 700; }
.mod-date-head { width: 84px; text-align: center; }
.mod-date { background: #f3f5f9; text-align: center; width: 84px; padding: 8px 6px; }
.mod-date .mod-day, .mod-date .mod-weekday { text-align: center; }
.mod-day { display: block; font-weight: 700; }
.mod-weekday { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.mod-cell { padding: 10px; min-width: 0; overflow-wrap: anywhere; text-align: center; }
.mod-cell .mod-lesson { align-items: center; }
.mod-empty { background: #fff; }
.mod-lesson { display: flex; flex-direction: column; gap: 3px; }
.mod-wide .mod-lesson { align-items: center; }
.mod-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.mod-subject { font-weight: 600; }
.mod-teacher { color: var(--accent); font-weight: 600; font-size: 13px; }
.mod-formats { display: flex; gap: 6px; margin-top: 6px; justify-content: center; flex-wrap: nowrap; }
.mod-fmt { flex: 0 0 auto; white-space: nowrap; text-align: center; font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.fmt-msk { background: #fdf3e2; color: #8a5a11; }
.fmt-spb { background: #e8eefb; color: #2b4a80; }
.mod-link { text-align: center; padding: 10px; }
.mod-lesson.is-cancelled .mod-time, .mod-lesson.is-cancelled .mod-subject { text-decoration: line-through; color: var(--muted); }
.mod-table .lesson-admin { justify-content: center; margin-top: 6px; }

/* Предупреждение о накладке в форме занятия */
.lesson-form [hidden] { display: none !important; }
.conflict-list { margin: 6px 0 8px 18px; padding: 0; }
.conflict-list li { margin: 2px 0; }

/* Плашки форматов в карточке занятия (как в таблице модератора) */
.lesson-formats { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 8px 10px 0 0; vertical-align: top; }

/* Компактная липкая шапка на телефоне */
@media (max-width: 720px) {
  .sticky-top { max-height: 64vh; overflow-y: auto; }
  .sticky-top .header-inner { min-height: 46px; height: auto; }
  .sticky-top .addresses-top { padding: 2px 12px 4px; font-size: 11px; gap: 2px 12px; }
  .sticky-top .banner-page { font-size: 11px; padding: 4px 10px; }
  .sticky-top .controls { gap: 8px; margin: 6px 0 4px; align-items: center; }
  .sticky-top select { padding: 6px 8px; font-size: 14px; }
  .sticky-top .field-label { font-size: 10px; }
  .sticky-top .tab { padding: 6px 10px; font-size: 13px; }
  .sticky-top .admin-actions .btn { padding: 6px 10px; font-size: 12px; }
  .sticky-top .month-nav { margin: 4px 0 8px; }
  .sticky-top .month-title { font-size: 16px; }
  .sticky-top .nav-btn { padding: 6px 10px; font-size: 13px; }
}

/* Кнопки «Ссылка» (синяя) и «Запись» (зелёная) */
.join, .rec { min-width: 108px; text-align: center; }
.rec {
  display: inline-block;
  text-decoration: none;
  background: #1f9d55;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 9px;
  white-space: nowrap;
}
.rec:hover { background: #18804a; }
.join.is-off, .rec.is-off { background: #e7eaef; color: #98a2b0; pointer-events: none; }
.link-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

/* Индивидуальные консультации: слоты */
.consult-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.consult-table th, .consult-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.consult-table th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.consult-table .consult-time { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.consult-table tr.slot-taken td { color: var(--muted); }
/* Слот, на который уже отправлена заявка: второй студент его не выберет */
.consult-table tr.slot-reserved td { background: #fdf9ef; }
.inline-form { display: inline; margin-left: 8px; }
.check-row { flex-direction: row !important; align-items: center; gap: 8px; }

/* Бледный список слотов в карточке занятия */
.slots-mini {
  display: inline-block;
  vertical-align: top;
  margin-top: 6px;
  padding: 4px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  font-size: 12px;
  color: var(--muted);
}
.slots-mini-title { font-weight: 600; margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.slots-mini[open] .slots-mini-title { margin-bottom: 6px; }
.slots-mini-row { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; }
.slots-mini-time { font-variant-numeric: tabular-nums; }
.slots-mini-name { color: var(--ink); }
.slots-link { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--accent); }
/* Имя студента + ссылка на его работу в записи на консультацию.
   margin-right: auto прижимает блок к времени — имя идёт сразу после слота. */
.slots-mini-who {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-right: auto;
}
/* Кнопка-ссылка в карточке занятия: «Ссылка на работу», «Перейти в папку» */
.link-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.link-btn:hover { color: var(--brand); }
.hw-folder-link { display: inline-block; margin-top: 8px; }

/* Кнопка записи на консультацию */
.consult-btn { background: #d4eafb; color: #155a8a; }
.consult-btn:hover { background: #c2e0f7; }
.consult-btn-sm { min-width: 0; font-size: 12px; padding: 5px 10px; }

.time-input { width: 104px; display: inline-block; margin: 0 4px 4px 0; }

/* Поле времени «ЧЧ : ММ» (собирается скриптом в base.html).
   Выглядит как обычное поле ввода, но после двух цифр часа курсор сам
   переходит на минуты. */
.time-field {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
}
.time-field:focus-within { outline: 2px solid #cfe0f4; border-color: var(--accent); }
.form-field > .time-field { display: flex; width: 100%; }
.time-field--short { width: 104px; margin: 0 4px 4px 0; }
.time-part {
  width: 2.2ch;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  outline: none;
}
.time-sep { color: var(--ink); }
.time-part::placeholder { color: #a8b0bb; }

/* Свёрнутый список слотов: треугольник и курсор */
.slots-mini > summary { cursor: pointer; list-style: none; padding: 0; }
.slots-mini > summary::-webkit-details-marker { display: none; }
.slots-mini > summary::before { content: "▸"; display: inline-block; margin-right: 6px; color: var(--muted); font-size: 15px; line-height: 1; vertical-align: -1px; }
.slots-mini[open] > summary::before { content: "▾"; }

/* Форма записи на консультацию: отступы внутри карточки */
.consult-form { padding: 16px; }

/* Домашнее задание в карточке занятия */
textarea.input {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  line-height: 1.45;
  min-height: 68px;
}
.hw-text { white-space: pre-line; color: var(--muted); }
/* Блок «Домашнее задание» — тот же вид, что у консультаций, но бледно-зелёный */
.hw-mini {
  background: #f3fbf6;
  border-color: #c7ebd6;
}
.hw-mini .slots-mini-title { color: #1e7a44; }
.hw-mini[open] .slots-mini-title { margin-bottom: 6px; }

/* Вкладка «Разбор фильмов» */
.films-subtitle { margin-top: -6px; margin-bottom: 16px; }
.films-card { padding: 16px; }
.films-wrap { overflow-x: auto; }
.films-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
.films-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.films-table td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.films-table tr:last-child td { border-bottom: none; }
.films-date { width: 96px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.films-tick { width: 40px; text-align: center; }
.films-tick input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.films-input { padding: 6px 8px; font-size: 14px; }
.films-past td { color: var(--muted); background: #fbfcfe; }

/* --- События («События» в расписании) --- */
/* Одно событие — одна строка во всю ширину, как занятия в расписании */
.events-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
.events-grid--past { margin-top: 16px; }

/* Афиша слева (полностью, без обрезки), текст справа */
.event-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow: hidden;
}
.event-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  /* Пол высоты: если афиша очень широкая, текст с кнопками всё равно поместится */
  min-height: 300px;
  background: #0b0b0b;
  /* Без padding: афиша прилегает к краям карточки, текст — к афише */
}
.event-poster {
  display: block;
  width: 100%;
  height: auto;
}
.event-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 24px;
}

/* Афиша задаёт высоту карточки. Правая колонка выведена из потока, поэтому
   длинное описание прокручивается внутри, а не растягивает рамку; кнопки
   остаются на месте. */
.event-card--poster .event-body {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 50%;
  overflow: hidden;
}
.event-card--poster .event-text {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}
/* Подсказка «текст продолжается»: включается скриптом, только если описание
   не влезло (на macOS полоса прокрутки видна лишь во время прокрутки). */
.event-text.is-scrollable {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.event-card--poster .event-text::-webkit-scrollbar { width: 6px; }
.event-card--poster .event-text::-webkit-scrollbar-thumb {
  background: #ccd2dc;
  border-radius: 3px;
}
.event-when {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--brand);
}
.event-title { margin: 0; font-size: 22px; line-height: 1.3; }
.event-place { font-size: 14px; color: var(--muted); }
.event-text {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
}
.event-remove { display: inline-flex; margin: 0; }
.events-past {
  margin: 8px 0 24px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.events-past summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 0;
}
.events-past summary:hover { color: var(--ink); }
.events-past .event-card { opacity: 0.9; }

/* Форма события: воздух между блоками (только эта форма, не форма занятия) */
.event-form { display: flex; flex-direction: column; gap: 20px; }
.event-form .form-grid { margin-bottom: 0; }
.event-form > .admin-actions {
  margin-top: 6px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* Превью текущей афиши в форме — целиком, без обрезки */
.poster-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0;
}
.poster-preview img {
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 220px;
  background: #eef1f6;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.event-delete-form { margin-top: 14px; }

/* На телефоне афиша сверху, текст под ней — обычным потоком, без «скролла в скролле» */
@media (max-width: 720px) {
  .page-toolbar { padding-top: 10px; }
  .sticky-top .page-toolbar { padding-top: 8px; }
  .event-card { grid-template-columns: 1fr; }
  .event-card--poster .event-body { position: static; overflow: visible; }
  .event-media { min-height: 0; }
  .event-card--poster .event-text {
    overflow-y: visible;
    padding-right: 0;
    background: none;
  }
  .event-body { padding: 16px 18px 18px; }
  .event-title { font-size: 19px; }
}


