:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --border: #e4e4df;
  --text: #1d1f23;
  --muted: #6b6f76;
  --accent: #ad1457;
  --accent-hover: #880e4f;
  --accent-soft: #fcebf2;
  --danger: #c92a2a;
  --danger-soft: #fdeeee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.04);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.boot { padding: 48px; text-align: center; color: var(--muted); }

/* --- Кнопки ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #f3c7c7; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #a61e1e; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn-icon { min-height: 30px; width: 30px; padding: 0; font-size: 14px; }
.btn-block { width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Вход -------------------------------------------------------------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px 28px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; }
.brand-mark {
  display: block; width: 64px; height: 64px; border-radius: 16px; margin-bottom: 20px; object-fit: cover;
}

/* --- Формы ------------------------------------------------------------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: 13px; margin-top: 6px; }
.input {
  width: 100%; padding: 10px 12px; min-height: 42px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 96px; }
.form-error {
  background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; margin-bottom: 16px;
}

/* --- Шапка ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 24px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .logo { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.topbar .logo .brand-mark { width: 36px; height: 36px; border-radius: 9px; margin: 0; }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px; font-size: 14px; color: inherit; text-decoration: none;
  padding: 4px 10px 4px 4px; border-radius: 999px; transition: background .15s;
}
.user-chip:hover, .user-chip.active { background: var(--surface-2); }
.user-chip .name { font-weight: 500; }

/* --- Язык -------------------------------------------------------------- */
.lang-switch { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.lang-opt {
  border: 0; background: transparent; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; letter-spacing: .02em;
}
.lang-opt:hover { color: var(--text); }
.lang-opt.active { background: var(--accent); color: #fff; cursor: default; }
.login { position: relative; }
.login-lang { position: absolute; top: 16px; right: 16px; }

/* --- Меню разделов ---------------------------------------------------- */
.nav { display: flex; gap: 4px; margin-left: 16px; }
.nav a {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px; white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.nav-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; line-height: 1;
}
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* --- Раскладка --------------------------------------------------------- */
.layout {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px;
  max-width: 1280px; margin: 0 auto; padding: 24px;
}
.sidebar { align-self: start; position: sticky; top: 84px; max-height: calc(100vh - 108px); overflow: auto; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 12px; }
.sidebar-head h2 { font-size: 20px; }

/* --- Модули ------------------------------------------------------------ */
.modules { display: flex; flex-direction: column; gap: 8px; }
.module { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.module-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px 16px; border: 0; background: none; text-align: left; cursor: pointer;
}
.module-head:hover { background: var(--surface-2); }
.module-head .title { flex: 1; font-weight: 600; }
.module-head .count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.chevron {
  width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .2s; flex: none; margin-right: 2px;
}
.module.open .chevron { transform: rotate(45deg); }
.module-body { border-top: 1px solid var(--border); padding: 6px; }
.module-tools {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 6px 8px; margin-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.module-tools .btn-danger { margin-left: auto; }
.add-lesson { margin: 4px 4px 2px; color: var(--accent); }
.lessons { list-style: none; margin: 0; padding: 0; }
.lesson-item { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm); }
.lesson-item a {
  flex: 1; display: flex; align-items: baseline; gap: 10px; min-width: 0;
  padding: 9px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text); font-size: 15px;
}
.lesson-item a:hover { background: var(--surface-2); }
.lesson-item.active a { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.lesson-item .num { color: var(--muted); font-size: 13px; min-width: 18px; font-variant-numeric: tabular-nums; }
.lesson-item.active .num { color: var(--accent); }
.lesson-item .ltitle { flex: 1; overflow-wrap: anywhere; }
.lesson-item .ccount { color: var(--muted); font-size: 12px; white-space: nowrap; }
.lesson-item .reorder { display: flex; gap: 2px; }
.empty-inline { color: var(--muted); font-size: 14px; padding: 10px; }

/* --- Урок -------------------------------------------------------------- */
.content { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.lesson-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.lesson-head h1 { flex: 1; font-size: 26px; }
.lesson-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: none; margin-bottom: 12px; }

.player {
  position: relative; aspect-ratio: 16 / 9; background: #111; border-radius: var(--radius-sm); overflow: hidden;
  margin-bottom: 24px;
}
.player iframe, .player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #bbb; padding: 16px; text-align: center; font-size: 15px; }

.description { overflow-wrap: anywhere; margin-bottom: 24px; }

/* --- Форматированный текст -------------------------------------------- */
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 12px; }
.rich h2 { font-size: 21px; margin: 24px 0 10px; }
.rich h3 { font-size: 17px; margin: 20px 0 8px; }
.rich ul, .rich ol { margin: 0 0 12px; padding-left: 24px; }
.rich li { margin-bottom: 4px; }
.rich blockquote {
  margin: 0 0 12px; padding: 8px 16px; border-left: 3px solid var(--accent);
  background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: #3d4047;
}
.rich a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* --- Редактор ---------------------------------------------------------- */
.rte { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rte-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.rte-btn {
  display: inline-grid; place-items: center; min-width: 30px; height: 32px; padding: 0 5px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; font-size: 15px;
}
.rte-btn:hover { background: var(--border); }
.rte-btn.active { background: var(--accent-soft); color: var(--accent); }
.rte-icon { display: grid; }
.rte-select {
  height: 32px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: 13px; cursor: pointer;
}
.rte-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.rte-content { min-height: 160px; max-height: 50vh; overflow: auto; padding: 12px 14px; outline: none; overflow-wrap: anywhere; }
.rte-content:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.homework {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: var(--radius-sm); background: var(--accent-soft); margin-bottom: 8px;
}
.homework strong { display: block; }
.homework span { color: var(--muted); font-size: 14px; }

/* --- Комментарии ------------------------------------------------------- */
.comments { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.comments h2 { font-size: 19px; margin-bottom: 16px; }
.comments h2 .muted { color: var(--muted); font-weight: 400; }
.comment-list { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.comment { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius-sm); }
.comment.staff { background: var(--accent-soft); }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
  background: var(--surface-2); color: var(--muted);
}
.comment.staff .avatar { background: var(--accent); color: #fff; }
.avatar-sm { width: 30px; height: 30px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.avatar-lg { width: 72px; height: 72px; font-size: 26px; background: var(--accent-soft); color: var(--accent); }
.comment-main { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.comment-meta .author { font-weight: 600; }
.comment-meta time { color: var(--muted); font-size: 13px; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.comment-tools { display: flex; gap: 4px; margin-top: 4px; margin-left: -8px; }
.comment-form .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.comment-form .hint { color: var(--muted); font-size: 13px; }

/* --- Состояния --------------------------------------------------------- */
.state { text-align: center; color: var(--muted); padding: 48px 16px; }
.state h3 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
.state p { margin: 0 0 16px; }
.state .icon { font-size: 32px; margin-bottom: 8px; opacity: .6; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, #e9e9e5 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius-sm); }
@keyframes sk { to { background-position: -200% 0; } }
.sk-module { height: 52px; border-radius: var(--radius); }
.sk-line { height: 18px; margin-bottom: 12px; }
.sk-line.w30 { width: 30%; }
.sk-line.w80 { width: 80%; }
.sk-title { width: 60%; height: 28px; margin-bottom: 24px; }
.sk-video { aspect-ratio: 16 / 9; margin-bottom: 24px; }
.sk-comment { height: 56px; margin-bottom: 16px; }
.empty-comments { padding: 0 0 16px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Диалоги и уведомления --------------------------------------------- */
dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  border: 0; border-radius: var(--radius); padding: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
dialog::backdrop { background: rgba(20, 22, 28, .4); }
.dialog-inner { padding: 24px; }
.dialog-inner h2 { font-size: 20px; margin-bottom: 16px; }
.dialog-inner > p { margin: 0 0 20px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { background: #1d1f23; color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; box-shadow: var(--shadow); animation: up .2s ease-out; }
.toast.error { background: var(--danger); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* --- Страницы кабинета ------------------------------------------------- */
.page { max-width: 1080px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.page-narrow { max-width: 760px; }
.page-wide { max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head h1 .muted { font-weight: 400; }
.page-sub { margin: 4px 0 0; }
.muted { color: var(--muted); }
.back { align-self: flex-start; }
.section-title { font-size: 19px; margin-bottom: 16px; }

.profile-head { display: flex; gap: 20px; align-items: flex-start; }
.profile-info { flex: 1; min-width: 0; }
.profile-info h1 { font-size: 24px; margin-bottom: 2px; overflow-wrap: anywhere; }
.profile-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0 0; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 500; }

.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.quick-link { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; transition: border-color .15s; }
.quick-link:hover { border-color: var(--accent); }
.quick-link span, .cta span { color: var(--muted); font-size: 14px; }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--accent-soft); border-color: transparent; }
.cta strong { display: block; }

.form-section h2 { font-size: 19px; margin-bottom: 16px; }
.form-section .field { max-width: 420px; }
.form-actions { display: flex; justify-content: flex-start; }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; font-family: ui-monospace, Menlo, monospace; }
.search { max-width: 420px; }
.credentials {
  margin: 0 0 20px; padding: 14px 16px; background: var(--surface-2); border-radius: var(--radius-sm);
  font: 14px/1.6 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all;
}

.people { list-style: none; margin: 0; padding: 6px; }
.person {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius-sm);
  text-decoration: none; color: inherit;
}
.person:hover { background: var(--surface-2); }
.person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }

.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.activity-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; font-size: 14px; margin-bottom: 2px; }
.activity-meta a { font-weight: 600; }
.activity-meta time { color: var(--muted); font-size: 13px; }

/* --- Видео в форме урока --------------------------------------------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 10px; }
.seg-btn { border: 0; background: transparent; padding: 6px 14px; border-radius: 6px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%;
  padding: 22px 16px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { color: var(--accent); }
.dropzone span { color: var(--muted); font-size: 14px; }
.dropzone small { margin-top: 6px; }
.upload-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.upload-box.done { background: var(--surface-2); }
.upload-name { font-weight: 500; overflow-wrap: anywhere; }
.upload-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.upload-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.upload-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* --- Защита материалов (ученик) -------------------------------------- */
.lesson { position: relative; }
.lesson.protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lesson.protected .comment-form, .lesson.protected textarea { -webkit-user-select: text; user-select: text; }
.wm-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; background-repeat: repeat; border-radius: inherit; }
.wm-float {
  position: absolute; left: 8%; top: 10%; z-index: 3; pointer-events: none; white-space: nowrap;
  color: rgba(255, 255, 255, .75); font-size: 14px; font-weight: 600; text-shadow: 0 0 3px rgba(0, 0, 0, .9), 0 1px 2px rgba(0, 0, 0, .8);
  transition: left 2.5s ease, top 2.5s ease;
}
.player-wrap { margin-bottom: 24px; }
.player-wrap .player { margin-bottom: 6px; }
.player-bar { display: flex; justify-content: flex-end; }
.player:fullscreen { aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; margin: 0; }
.player:fullscreen .wm-float { font-size: 18px; }
.player-exit { display: none; }
.player:fullscreen .player-exit {
  display: block; position: absolute; top: 12px; right: 12px; z-index: 4;
  border: 0; border-radius: 999px; padding: 6px 12px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; cursor: pointer;
}
@media print {
  body.protect .main { display: none; }
  body.protect::after { content: attr(data-print-msg); display: block; padding: 48px; font: 18px/1.5 sans-serif; }
}

/* --- Доступ к урокам ------------------------------------------------- */
.access-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.access-head .section-title { margin-bottom: 2px; }
.access-head .muted { font-size: 14px; }
.access-actions { display: flex; gap: 8px; }
.access-hint { color: var(--muted); font-size: 14px; margin: 12px 0 16px; }
.access-list { display: flex; flex-direction: column; gap: 10px; }
.access.busy .access-list { opacity: .6; }
.access-module { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 6px; }
.access-module.full { border-color: var(--accent); background: var(--accent-soft); }
.access-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 6px; cursor: pointer; }
.access-row:hover { background: rgba(0, 0, 0, .03); }
.access-row input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; cursor: pointer; }
.access-title { display: flex; flex-direction: column; }
.access-title small { color: var(--muted); font-size: 13px; }
.access-lessons { list-style: none; margin: 0 0 4px; padding: 0 0 0 28px; }
.access-lessons .access-row { padding: 5px 6px; font-size: 15px; }
.person-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.access-pill { font-size: 12px; font-weight: 500; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; }
.access-pill.none { color: var(--muted); background: var(--surface-2); }

/* --- Ветки вопросов к уроку ------------------------------------------- */
.thread-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.thread-toolbar h2 { margin-bottom: 0; }
.thread-toolbar .seg { margin-bottom: 0; }
.thread-hint { font-size: 14px; margin: 4px 0 16px; }
.thread { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.thread.waiting { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.thread.general { background: var(--surface-2); }
.thread-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; font-size: 14px; }
.thread-name { font-weight: 600; color: var(--text); text-decoration: none; }
.thread-name:hover { color: var(--accent); }
.thread-head time { margin-left: auto; font-size: 13px; }
.thread .comment-list { margin-bottom: 8px; }
.thread .comment-form textarea { min-height: 64px; }
.ccount.waiting { color: var(--accent); font-weight: 600; }
.chat-item-lesson { font-size: 13px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.thread-lesson { font-size: 13px; font-weight: 400; color: var(--muted); }
.thread-panel .chat-messages { list-style: none; margin: 0; }
.thread-reply { border-top: 1px solid var(--border); padding: 12px; }

/* --- Чат --------------------------------------------------------------- */
.chat-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; }
.chat-list { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 108px); min-height: 420px; overflow: hidden; }
.chat-list-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.chat-list-head h1 { font-size: 20px; }
.chat-items { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.chat-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); text-decoration: none; color: inherit; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-item-top time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.chat-item-preview { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.unread .chat-item-preview { color: var(--text); font-weight: 500; }
.chat-placeholder { height: calc(100vh - 108px); min-height: 420px; display: flex; flex-direction: column; justify-content: center; }

.chat-panel { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 108px); min-height: 420px; overflow: hidden; }
.page-narrow .chat-panel { height: calc(100vh - 200px); }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.chat-title { flex: 1; font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-back { display: none; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.chat-empty { margin: auto; text-align: center; max-width: 360px; }
.day-sep { display: flex; justify-content: center; margin: 12px 0 8px; }
.day-sep span { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 999px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 78%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-author { font-size: 12px; color: var(--muted); margin: 8px 0 2px 12px; font-weight: 500; }
.bubble {
  background: var(--surface-2); padding: 8px 12px 6px; border-radius: 16px 16px 16px 4px;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45;
}
.msg.staff:not(.mine) .bubble { background: var(--accent-soft); }
.msg.mine .bubble { background: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg.mine .bubble a { color: #fff; }
.bubble time { display: block; text-align: right; font-size: 11px; opacity: .65; margin-top: 2px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); }
.composer textarea { min-height: 42px; max-height: 160px; resize: none; }

/* --- Мобильные --------------------------------------------------------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .sidebar { position: static; max-height: none; overflow: visible; }
  .topbar { padding: 8px 16px 0; height: auto; flex-wrap: wrap; row-gap: 4px; }
  .topbar .logo-text { font-size: 16px; }
  .nav { order: 10; width: 100%; margin: 0 -12px; padding: 0 0 4px; overflow-x: auto; }
  .user-chip .name, .user-chip .role-badge { display: none; }
  .user-chip { padding: 2px; }
  .page { padding: 16px; }
  .page-head h1 { font-size: 22px; }
  .quick-links { grid-template-columns: 1fr; }
  .profile-head { gap: 14px; }
  .avatar-lg { width: 56px; height: 56px; font-size: 20px; }
  .person-meta > span:last-child { display: none; }
  .panel.chat-panel, .panel.chat-list { padding: 0; }
  .panel.people { padding: 6px; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list, .chat-panel, .chat-placeholder { height: calc(100dvh - 140px); }
  .page-narrow .chat-panel { height: calc(100dvh - 210px); }
  body.viewing-chat .chat-list { display: none; }
  body:not(.viewing-chat) .chat-side { display: none; }
  .chat-back { display: inline-flex; }
  .chat-messages { padding: 12px; }
  .msg { max-width: 88%; }
  .panel { padding: 20px 16px; }
  .lesson-head { flex-direction: column; gap: 12px; }
  .lesson-head h1 { font-size: 22px; }
  .player { margin-left: -16px; margin-right: -16px; border-radius: 0; }
  .back-link { display: inline-flex; }
  body.viewing-lesson .sidebar { display: none; }
  body:not(.viewing-lesson) .content { display: none; }
}
