:root {
  /* Тёмная «слива»: матовые панели без стекла, один фиолетовый акцент.
     Красный ТОП — только логотип, выход и то, что горит. */
  --brand: #ec1b2e;             /* IT-Top красный */
  --brand-2: #ec1b2e;
  --hot: #ff5468;               /* просрочки, выход, ошибки на тёмном */
  --violet: #7c3aed;            /* главный акцент: кнопки, активный раздел */
  --violet-hi: #a78bfa;         /* акцент для текста и иконок */

  /* старые имена — на них завязаны правила по всему файлу */
  --purple-glow: rgba(124, 58, 237, 0.35);
  --purple-brand: var(--violet);
  --purple-light: var(--violet-hi);

  --bg: #140f1e;
  --panel: #1d1530;
  --card: #1d1530;
  --raised: #281e3e;
  --card-2: #281e3e;
  --card-hover: #30244a;
  --stroke: #352950;
  --stroke-2: #46376a;
  --txt: #f3effa;
  --muted: #a99bc0;

  --good: #10b981;              /* 5 — изумрудный */
  --info: #3b82f6;              /* 4 — лазурный */
  --warn: #f59e0b;              /* 3 — янтарный */
  --bad: #ef4444;               /* 2/1 — коралловый */

  /* значки форматов документов агента — цвета самих программ */
  --doc-docx: #2b579a;
  --doc-pdf: #d93025;
  --doc-pptx: #c43e1c;
  --doc-xlsx: #217346;

  /* скругления по иерархии: панель > плитка > мелочь */
  --radius: 20px;
  --r-mid: 14px;
  --r-sm: 9px;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Rubik", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--txt);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-weight: 500; }

/* Фон — ровный тёмный: без пятен свечения, их место заняли панели */
.aurora { position: fixed; inset: 0; z-index: -1; background: var(--bg); }

.glass {
  background: var(--card);
  border: 1px solid transparent;
}

/* ===== Логотип IT-Top ===== */
.logo-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.logo-mark .box {
  background: var(--brand);
  color: #fff;
  padding: 4px 8px;
  border-radius: 9px;
  font-size: 18px;
  line-height: 1;
  box-shadow: none;
}
.logo-mark .word { font-size: 20px; }
.logo-mark .word b { color: var(--brand); }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 390px;
  border-radius: 22px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.brand { display: flex; align-items: center; gap: 15px; margin-bottom: 8px; }
.brand .brand-logo {
  width: 92px;
  height: auto;
  flex: 0 0 auto;
  
}
.brand .brand-text {
  padding-left: 15px;
  border-left: 1px solid var(--stroke-2);
}
.brand h1 { margin: 0; font-size: 25px; letter-spacing: -0.5px; }
.brand h1 b { color: var(--brand); }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"], textarea, input:not([type]) {
  background: rgba(18, 7, 38, 0.65);
  border: 1px solid var(--stroke-2);
  color: var(--txt);
  padding: 12px 14px;
  border-radius: 11px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
input:focus, textarea:focus {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25);
}
.remember { flex-direction: row; align-items: center; gap: 8px; }
.remember input { width: 16px; height: 16px; accent-color: var(--violet); }

.btn-primary {
  margin-top: 6px;
  border: none;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 18px;
  border-radius: 11px;
  background: var(--violet);
  box-shadow: none;
  transition: transform 0.15s, filter 0.2s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:active, .btn-sec:active, .fr-btn:active { transform: scale(0.98); }
/* Выключенная кнопка и кнопка «в работе» — это разные вещи. Без .is-busy
   курсор говорит «нажать нельзя», с ней — «жду ответа». */
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary:disabled.is-busy { cursor: progress; }

.btn-sec {
  background: var(--card-2);
  border: 1px solid var(--stroke);
  color: var(--txt);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sec:hover {
  background: var(--card-hover);
  border-color: var(--stroke-2);
}

.err { color: var(--bad); font-size: 13px; min-height: 16px; margin: 0; text-align: center; }

/* ===== App layout ===== */
.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 22px 16px 16px;
  min-height: 100vh;
  max-width: 1900px;
  margin: 0 auto;
}
@media (min-width: 1700px) {
  .app { gap: 20px; padding: 20px 30px 20px 20px; }
}
.sidebar {
  border-radius: var(--radius);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  background: var(--panel);
  padding: 20px 12px 14px;
}
.brand.small { gap: 10px; margin: 4px 6px 12px; }
.brand.small .brand-logo { width: 38px; filter: drop-shadow(0 4px 12px rgba(192, 132, 252, 0.45)); }
.brand.small .brand-text { padding-left: 10px; }
.brand.small h1 { font-size: 20px; }
/* Сайдбар высотой в экран, а пунктов тринадцать: на ноутбуке с низким
   экраном они не помещались и выталкивали «Выйти» за рамку карточки.
   Теперь лишнее прокручивается внутри меню, а выход всегда стоит внизу
   сайдбара. Поля внутри — чтобы тень активного пункта не обрезалась. */
#nav { display: flex; flex-direction: column; gap: 4px; margin: 6px -6px 0;
  padding: 0 6px 10px; flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
/* Кнопка-«гамбургер» — часть только мобильной вёрстки; на десктопе меню
   висит колонкой в сайдбаре, и переключатель не нужен. */
.nav-toggle { display: none; }
#nav button, .logout {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  font-size: 14.5px;
  padding: 10px 12px;
  border-radius: var(--r-mid);
  cursor: pointer;
  transition: background-color .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 12px;
}
#nav button:hover { color: var(--txt); background: rgba(255, 255, 255, 0.035); }
/* Активный раздел — приглушённая фиолетовая плашка и яркая иконка, без
   заливки на весь пункт: так он заметен, но не спорит с кнопками. */
#nav button.active { color: var(--txt); background: color-mix(in srgb, var(--violet) 24%, var(--raised)); }
#nav button.active .nav-ic { color: var(--violet-hi); }
#nav button:active, .logout:active { transform: scale(0.98); }
/* Выход — красный: действие сбрасывает сессию, его не должно быть легко
   перепутать с разделом. */
.logout { margin-top: auto; flex: none; color: var(--hot); }
/* Иконки меню — одноцветные SVG из public/icons. Рисуем их маской, а цвет
   берём из текста пункта: так иконка сама становится белой на наведении и
   в активном пункте, а цвет внутри файла (обычно чёрный) не важен.
   ИИ-помощник — цветной логотип, он идёт обычной картинкой. */
.nav-ic { width: 19px; height: 19px; flex: none; display: inline-block;
  background-color: currentColor;
  -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
.nav-ic-img { background: none; -webkit-mask: none; mask: none; object-fit: contain; }
.prof-exit { display: inline-flex; align-items: center; gap: 7px; }
.prof-exit .nav-ic { width: 14px; height: 14px; }
/* Невысокий экран ноутбука (768–900 px): поджимаем пункты, чтобы меню
   влезало целиком и прокрутка оставалась запасным вариантом. */
@media (min-width: 961px) and (max-height: 860px) {
  .sidebar { padding: 14px 10px; gap: 4px; }
  .brand.small { margin: 2px 6px 6px; }
  #nav { gap: 2px; }
  #nav button, .logout { padding: 8px 14px; font-size: 13.5px; }
}
.logout:hover { background: rgba(255, 84, 104, 0.14); color: #ff7a8a; }

.content { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar h2 { margin: 0; font-size: 26px; letter-spacing: -0.5px; }
.topbar p { margin: 3px 0 0; font-size: 13.5px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: 100px;
  background: var(--card);
  border: 1px solid var(--stroke);
}
.user-chip img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--purple-light);
}
.user-chip .u-name { font-weight: 600; font-size: 14px; }
.user-chip .u-grp { font-size: 12px; color: var(--purple-light); }

/* ===== Cards & grid ===== */
.view { display: flex; flex-direction: column; gap: 18px; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.grid { display: grid; gap: 16px; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.card { border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ===== Rows & lists ===== */
.rowlist { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--stroke);
}
.row:last-child { border-bottom: none; }
.row .lead {
  min-width: 38px;
  height: 28px;
  padding: 0 6px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
  flex: none;
  background: var(--card-2);
  color: var(--muted);
}
.row .lead.mono {
  font-size: 11.5px;
  letter-spacing: -0.2px;
}
.row .main { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.row .t2 { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.row .side { text-align: right; font-size: 12px; color: var(--muted); flex: none; }

/* Оценки 5, 4, 3, 2 */
.mark {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  font-size: 13.5px;
}
.m5 { background: rgba(16, 185, 129, 0.22); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.m4 { background: rgba(59, 130, 246, 0.22); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.m3 { background: rgba(245, 158, 11, 0.22); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.m2 { background: rgba(239, 68, 68, 0.22); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }

.pill { font-size: 11.5px; font-weight: 600; padding: 4px 11px; border-radius: 100px; white-space: nowrap; }
.pill.on { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
.pill.off { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }
.pill.wait { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }

/* Статусы в toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar input[type="search"] { width: 100%; padding: 10px 14px; border-radius: 11px; font-size: 14px; }

.mini-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.chipstat {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 8px 14px;
  font-size: 13px;
}
.chipstat b { font-size: 15px; }
.chipstat .cs-purple { color: var(--purple-light); }

/* ===== ГЕЙМИФИКАЦИЯ ===== */
.user-chip .wallet { display: flex; gap: 8px; margin-right: 6px; }
.cur {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cur img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.cur-gold { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.cur-gem { background: rgba(6, 182, 212, 0.2); color: #67e8f9; border: 1px solid rgba(6, 182, 212, 0.35); }

/* ===== ЛЕГЕНДА ОЦЕНОК (ПОКАЗЫВАЕТСЯ ПЕРВОЙ) ===== */
/* Легенда свёрнута на телефоне (см. phone() в app.js): три ряда чипов —
   это 570 px, после которых только начинались сами пары. */
.leg-sum { cursor: pointer; font-weight: 700; font-size: 14px; list-style: none; }
.leg-sum::-webkit-details-marker { display: none; }
.leg-sum::before { content: "▸ "; color: var(--purple-light); }
.legend-card[open] .leg-sum::before { content: "▾ "; }
.legend-card[open] .leg-sum { margin-bottom: 12px; }
.legend-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--card);
}
.leg-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--purple-light); }
.leg-row { display: flex; flex-wrap: wrap; gap: 8px; }
.leg-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
  color: var(--txt);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.leg-chip:hover { border-color: var(--purple-light); }
.leg-chip.sel {
  border-color: var(--purple-light);
  background: rgba(124, 58, 237, 0.28);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.35);
}
.leg-badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  font-weight: 700;
  font-size: 13px;
}
.leg-cnt {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255,255,255,0.08);
  padding: 1px 7px;
  border-radius: 6px;
}
.leg-chip.work b { color: var(--purple-light); }
.leg-chip.hw-tag { border-color: rgba(124, 58, 237, 0.4); background: rgba(124, 58, 237, 0.18); }
.leg-chip.hw-tag b { color: #f472b6; }
.leg-active { font-size: 13.5px; color: var(--muted); min-height: 4px; }
.leg-reset {
  background: transparent;
  border: none;
  color: var(--purple-light);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  margin-left: 8px;
  text-decoration: underline;
}

/* ===== СЕТКА КАРТОЧЕК ОЦЕНОК (КАРТОЧКИ ТАБЛИЦЕЙ) ===== */
.cards-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
/* Карточка пары в «Оценках» — как карточка домашки: полоса цвета предмета
   сверху, без рамки и подложки «с домашкой» — ДЗ и так видно по блоку. */
.mark-card {
  background: var(--card);
  border-top: 4px solid var(--c, var(--stroke-2));
  border-radius: var(--r-mid);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  position: relative;
  overflow: hidden;
}
.mark-card:hover { background: color-mix(in srgb, var(--card) 88%, var(--violet)); }
.mc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 6px;
}
.mc-date { display: flex; align-items: baseline; gap: 5px; }
.mc-wd { font-weight: 700; font-size: 12px; color: var(--purple-light); }
.mc-num { font-size: 11.5px; color: var(--muted); }
.mc-lesson {
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(255,255,255,0.07);
  padding: 1px 6px;
  border-radius: 5px;
}
.mc-body { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.mc-subj { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.mc-theme { font-size: 12px; color: var(--txt); opacity: 0.85; line-height: 1.35; }
.mc-teacher { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Выделенный блок ДЗ внутри карточки */
.hw-highlight-box {
  background: rgba(124, 58, 237, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 8px;
  padding: 6px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}
.hw-highlight-title {
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #f5d0fe;
}
.mc-marks-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.gmark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 25px;
  padding: 0 8px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 13px;
}
.gmark .gm-t {
  font-size: 9.5px;
  font-weight: 600;
  opacity: 0.8;
}
.gmark.hw-mark {
  box-shadow: none;
}

.att-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 100px; white-space: nowrap; }
.att-badge.on { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.att-badge.off { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* ===== ДОМАШКА: КАРТОЧКИ И СДАЧА ===== */
.hw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
  align-items: stretch;
}
/* Заголовок секции во вкладке «Все»: категория + её настоящее число. */
.hw-section { display: flex; align-items: center; gap: 9px; margin: 20px 2px 10px;
  font-size: 14px; font-weight: 700; color: var(--txt); }
.hw-section:first-child { margin-top: 4px; }
.hw-section-n { font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--stroke-2); border-radius: 999px; padding: 1px 9px; }
/* Выбор предмета во вкладке ДЗ — в тон сегментам рядом. */
/* Шапка вкладки ДЗ: статусы слева, предмет/вид/загрузка справа — в одну строку.
   Правая группа не переносится, вместо этого ужимается выбор предмета
   (название уходит в многоточие); переносом строки жертвуем только на узком экране. */
.hw-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.hw-tools { display: flex; gap: 8px; align-items: center; flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
.hw-tools > .seg, .hw-tools > .btn-primary { flex: none; }
.spec-dd { position: relative; min-width: 130px; flex: 0 1 230px; }
.spec-dd-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--stroke); border-radius: 12px;
  padding: 11px 14px; cursor: pointer; transition: border-color .15s, color .15s;
}
.spec-dd-btn:hover, .spec-dd.open .spec-dd-btn { border-color: var(--stroke-2); color: var(--txt); }
.spec-dd.set .spec-dd-btn { color: var(--txt); border-color: var(--purple-light); }
.spec-dd-label { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spec-dd-caret { font-size: 11px; transition: transform .15s; }
.spec-dd.open .spec-dd-caret { transform: rotate(180deg); }
.spec-dd-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 340px; max-width: 90vw;
  background: var(--panel); border: 1px solid var(--stroke-2); border-radius: 14px;
  box-shadow: var(--shadow); padding: 8px;
}
.spec-dd-search {
  width: 100%; box-sizing: border-box; margin-bottom: 6px;
  font: inherit; font-size: 13.5px; color: var(--txt);
  background: var(--card-2); border: 1px solid var(--stroke); border-radius: 10px; padding: 9px 12px;
}
.spec-dd-search:focus { outline: none; border-color: var(--purple-light); }
.spec-dd-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.spec-dd-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  font: inherit; font-size: 13.5px; color: var(--txt); background: transparent;
  border: none; border-radius: 9px; padding: 8px 10px; cursor: pointer;
}
.spec-dd-item:hover { background: var(--card-hover); }
.spec-dd-item.on { background: var(--violet); color: #fff; }
.spec-dd-empty { padding: 14px 10px; font-size: 13px; color: var(--muted); text-align: center; }
/* Статусы с числами + правая группа влезают в строку примерно с 1880px окна. */
@media (max-width: 1880px) { .hw-toolbar, .hw-tools { flex-wrap: wrap; } .hw-tools { justify-content: flex-start; } }
@media (max-width: 720px) {
  .spec-dd { flex: 1 1 100%; }
  .spec-dd-pop { width: 100%; }
  /* «Домашние задания / Лабораторные работы» на 390px шире экрана:
     растягиваем на всю строку и делим её пополам. */
  #hwtype { flex: 1 1 100%; flex-wrap: nowrap; }
  #hwtype button { flex: 1 1 0; min-width: 0; padding: 8px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* Кнопка догрузки заданий: заданий бывают сотни, тянем их порциями. */
.hw-more-wrap { display: flex; justify-content: center; margin: 18px 0 4px; }
.hw-more {
  padding: 10px 22px; border-radius: 10px; border: 1px solid var(--stroke-2);
  background: var(--card-2); color: var(--txt); font: inherit; font-weight: 600;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.hw-more:hover { border-color: var(--violet-hi); color: var(--violet-hi); }
.hw-more:disabled { opacity: .6; cursor: default; }
.hw-card {
  border-radius: var(--r-mid);
  padding: 14px 16px 14px;
  border-top: 4px solid var(--c, var(--stroke-2));
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: transform 0.18s, box-shadow 0.18s;
  height: 100%;
  box-sizing: border-box;
}
.hw-card:hover { background: color-mix(in srgb, var(--card) 88%, var(--violet)); }
.hw-cover-wrap {
  width: 100%;
  height: 115px;
  border-radius: 9px;
  overflow: hidden;
  position: relative;
  background: var(--raised);
  flex: none;
}
.hw-cover-link, .hw-cover-default {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  text-decoration: none;
}
.hw-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.hw-cover-link:hover .hw-cover-img {
  transform: scale(1.04);
}
.hw-cover-tag {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(10, 4, 24, 0.78);
  color: #e9d5ff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.hw-cover-tag.default {
  color: var(--violet-hi);
  background: rgba(20, 8, 44, 0.78);
  border-color: rgba(124, 58, 237, 0.3);
}

.hw-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: none;
  position: relative;
}
/* Предмет и оценка — одной строкой: длинное название обрезается, а не
   уезжает под оценку. */
.hw-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.hw-top .gmark { flex: none; }
.hw-spec {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c, var(--violet-hi));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hw-theme {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  min-height: 38px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hw-teach {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hw-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--stroke);
  flex-wrap: wrap;
  gap: 6px;
  flex: none;
}
.hw-due { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.hw-due.overdue { color: var(--bad); font-weight: 600; }
.hw-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.btn-submit-hw {
  background: var(--violet);
  color: #fff;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: none;
}
.btn-submit-hw:hover { filter: brightness(1.1); }
.btn-del-hw {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font: inherit;
  font-weight: 600;
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-del-hw:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #f87171;
  color: #fff;
}
.hw-file {
  font-size: 11.5px;
  color: var(--purple-light);
  text-decoration: none;
  font-weight: 600;
  padding: 5px 9px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.hw-file:hover {
  background: var(--card-hover);
  border-color: var(--purple-light);
}

.submission-box {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 9px;
  padding: 8px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.sb-top .btn-del-hw {
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1;
}
.sb-title { font-size: 11.5px; font-weight: 700; color: #34d399; display: flex; align-items: center; gap: 5px; }
.sb-file { font-size: 11.5px; word-break: break-all; }
.sb-comment { font-size: 11.5px; color: var(--txt); opacity: 0.9; font-style: italic; }

/* ===== МОДАЛКА СДАЧИ ДЗ ===== */
/* Подложка сама прокручивается: карточка сдачи ДЗ выше экрана ноутбука, и
   раньше её низ с кнопкой «Сдать» был недостижим, а колесо крутило
   страницу под модалкой. margin: auto у карточки центрирует её, пока она
   помещается, и прижимает к верху, когда нет — без обрезки сверху, как было
   бы с place-items: center. Страницу под модалкой держит .modal-open. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 3, 20, 0.75);
  display: flex;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-backdrop > .modal-card { margin: auto; flex: none; }
html.modal-open { overflow: hidden; scrollbar-gutter: stable; }
html.modal-open body { overflow: hidden; }
.modal-card {
  width: 100%;
  max-width: 520px;
  border-radius: 20px;
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--stroke-2);
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
  animation: pop 0.2s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.modal-header h3 { margin: 0; font-size: 19px; letter-spacing: -0.3px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
}
.modal-close:hover { color: #fff; background: rgba(255,255,255,0.08); }
.modal-body { display: flex; flex-direction: column; gap: 16px; }

.hw-dropzone {
  border: 2px dashed rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.08);
  border-radius: 14px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
}
.hw-dropzone:hover, .hw-dropzone.dragover {
  border-color: var(--purple-light);
  background: rgba(124, 58, 237, 0.16);
}
.dz-icon { width: 34px; height: 34px; display: block; margin: 0 auto 8px; color: var(--violet-hi); }
.dz-prompt { margin: 0; font-size: 14.5px; }
.dz-hint { font-size: 12px; color: var(--muted); margin-top: 4px; display: block; }
.dz-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card-2);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
}
.dz-file-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.btn-remove-file {
  background: transparent;
  border: none;
  color: var(--bad);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

/* --- Затраченное время --- */
.hw-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hw-field-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.hw-field-label .req {
  color: var(--bad);
}
.hw-time-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.hw-time-inputs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
  padding: 6px 10px;
  border-radius: 10px;
}
.hw-time-col {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hw-time-col input[type="number"] {
  width: 48px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  padding: 4px 2px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--stroke);
  border-radius: 6px;
  color: #fff;
  -moz-appearance: textfield;
}
.hw-time-col input[type="number"]::-webkit-outer-spin-button,
.hw-time-col input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.hw-time-sub {
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
.hw-time-sep {
  font-weight: 600;
  color: var(--muted);
  font-size: 16px;
}
.hw-time-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.hw-time-chip {
  background: var(--card-2);
  border: 1px solid var(--stroke);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.hw-time-chip:hover {
  color: #fff;
  border-color: rgba(124, 58, 237, 0.5);
}
.hw-time-chip.active {
  background: rgba(124, 58, 237, 0.22);
  color: #fff;
  border-color: var(--purple-light);
}

/* --- Оценка задания для академии --- */
.hw-eval-block {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hw-eval-toggle {
  display: inline-flex;
  /* Глобальное правило label выставляет column — без этой строки галочка
     уезжает над подписью и встаёт по центру блока. */
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
  font-weight: 600;
}
.hw-eval-toggle input[type="checkbox"] {
  accent-color: var(--purple-light);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.hw-rate-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 2px;
}
.hw-rate-fields.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.hw-rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.hw-rating-stars {
  display: inline-flex;
  gap: 4px;
}
.hw-star-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #4b5563;
  cursor: pointer;
  padding: 0 2px;
  transition: transform 0.1s ease, color 0.15s ease;
}
.hw-star-btn:hover {
  transform: scale(1.15);
}
.hw-star-btn.active,
.hw-star-btn.hover {
  color: #f59e0b;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.45);
}
.hw-rating-label {
  font-size: 13px;
  font-weight: 600;
}
.hw-tags-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hw-tags-hint {
  font-size: 11.5px;
}
.hw-rating-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hw-tag {
  background: var(--card-2);
  border: 1px solid var(--stroke);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.hw-tag:hover {
  color: #fff;
  border-color: rgba(124, 58, 237, 0.4);
}
.hw-tag.sel {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--purple-light);
  color: #fff;
  font-weight: 600;
  box-shadow: none;
}
.hw-rate-comment {
  width: 100%;
  font-size: 13px;
  padding: 8px 12px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: #fff;
}
.hw-rate-comment:focus {
  outline: none;
  border-color: var(--purple-light);
}

.hw-answer-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
}
.hw-answer-label textarea {
  font-size: 13.5px;
  font-family: inherit;
}

#hw-submit-msg {
  font-size: 13.5px;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  display: none;
}
#hw-submit-msg:not(:empty) {
  display: block;
}
#hw-submit-msg.err {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
#hw-submit-msg.ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}
#hw-submit-msg.warn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde047;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

/* ===== СЕГМЕНТЫ / ПЕРЕКЛЮЧАТЕЛИ ===== */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
}
.seg button:hover { color: #fff; }
.seg button.active {
  background: var(--violet);
  color: #fff;
  box-shadow: none;
}

/* Расписание: день — строка, пары — плитки (.ltile из «Обзора») */
.sch-days { display: flex; flex-direction: column; gap: 10px; }
.sday { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 18px; align-items: start;
  padding: 16px 18px; border-radius: var(--radius); background: var(--card); }
.sday.is-today { background: color-mix(in srgb, var(--violet) 9%, var(--card)); box-shadow: inset 3px 0 0 var(--violet-hi); }
/* Пустой день — тонкая строка: дата слева, «нет занятий» справа */
.sday.is-empty { display: flex; justify-content: space-between; gap: 16px; padding: 10px 18px; align-items: center;
  background: transparent; border: 1px dashed var(--stroke); }
.sd-date { display: flex; flex-direction: column; line-height: 1.2; padding-top: 2px; }
.sd-date b { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.sd-date span { font-size: 13.5px; }
.sd-date small { font-size: 12.5px; color: var(--muted); }
.sday.is-today .sd-date small { color: var(--violet-hi); font-weight: 500; }
.sday.is-empty .sd-date { flex-direction: row; align-items: baseline; gap: 8px; padding: 0; }
.sday.is-empty .sd-date b { font-size: 17px; }
.sd-empty { color: var(--muted); font-size: 13.5px; }

/* Неделя — семь колонок: день сверху, пары стопкой (компактные .ltile) */
.sch-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: start; }
.wday { background: var(--card); border-radius: var(--radius); padding: 12px 10px; min-width: 0; }
.wday.is-today { background: color-mix(in srgb, var(--violet) 9%, var(--card)); box-shadow: inset 0 3px 0 var(--violet-hi); }
.wday.is-empty { background: transparent; border: 1px dashed var(--stroke); }
.wd-head { display: flex; align-items: baseline; gap: 6px; padding: 0 4px 10px; }
.wd-head b { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.wd-head span { font-size: 13.5px; color: var(--muted); }
.wd-head small { margin-left: auto; font-size: 12px; color: var(--violet-hi); font-weight: 500; }
.wd-list { display: flex; flex-direction: column; gap: 8px; }
.wday .ltile { padding: 10px 11px 11px; border-top-width: 3px; border-radius: 11px; }
.wday .lt-time { font-size: 17px; }
.wday .lt-time small { display: block; margin: 0; font-size: 11.5px; }
.wday .lt-subj { font-size: 13.5px; margin-top: 4px; }
.wday .lt-meta { font-size: 12px; white-space: normal; }
.wday .lt-live { font-size: 11.5px; padding: 2px 8px; margin-top: 8px; }
.wday .sd-empty { padding: 0 4px; font-size: 13px; }
/* Семь колонок уже 130px перестают читаться — переходим на четыре,
   на телефоне дни идут один под другим. */
@media (max-width: 1280px) { .sch-week { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 720px) { .sch-week { grid-template-columns: minmax(0, 1fr); } }

/* Рейтинг */
.mat-trail { margin-top: 10px; font-size: 12px; }
.mat-trail summary { cursor: pointer; color: var(--purple-light); font-weight: 600; }
.mat-trail .mono { margin-top: 6px; line-height: 1.6; word-break: break-all; }

/* ===== Обзор: плотная раскладка ===== */
/* Обзор — витрина, а не рабочий экран: карточки тут уже и суше, чем в
   разделах, где с содержимым действительно работают. */
.view-dash { gap: 12px; }
.view-dash .card { padding: 14px 16px; }
.view-dash .grid { gap: 12px; }
.dash-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
}
.dash-head h3 { margin: 0; }

/* Приветствие «Обзора»: фото, имя и фраза о дне */
.dash-hello { display: flex; align-items: center; gap: 18px; padding: 20px 22px; }
.dh-ava { width: 56px; height: 56px; border-radius: 18px; object-fit: cover; flex: none; background: var(--raised); }
.dh-ini { display: grid; place-items: center; font-size: 19px; font-weight: 600;
  background: color-mix(in srgb, var(--violet) 35%, var(--raised)); }
.dh-text h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.dh-text p { margin: 3px 0 0; color: var(--muted); font-size: 14.5px; }

/* Пары — плитки с полосой цвета предмета */
.ltiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.ltile { border-radius: var(--r-mid); background: var(--raised); padding: 13px 16px 15px; border-top: 4px solid var(--c); min-width: 0; }
.lt-time { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.lt-time small { font-size: 12.5px; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-left: 6px; }
.lt-subj { margin-top: 6px; font-weight: 500; line-height: 1.3; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lt-meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltile.is-done { opacity: .5; }
.ltile.is-cur { background: color-mix(in srgb, var(--c) 15%, var(--raised)); }
.lt-live { display: inline-block; margin-top: 10px; padding: 3px 10px; border-radius: 999px; background: var(--c);
  color: #1a1424; font-size: 12.5px; font-weight: 600; }

/* ===== Рейтинг на дашборде ===== */
.ld-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.ld-head h3 { margin: 0 0 4px; }
.ld-head .sub { margin: 0; }
.ld-segs { display: flex; flex-wrap: wrap; gap: 8px; }
.ld-me {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--stroke-2);
  border-radius: 12px;
  background: rgba(124, 58, 237, 0.14);
  font-size: 13px;
}
.ld-me b { font-size: 26px; font-weight: 700; color: var(--purple-light); }

.leaders-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.pod {
  border-radius: var(--r-mid);
  padding: 12px 10px 14px;
  text-align: center;
  background: var(--raised);
}
.pod img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 8px;
}
.pod .rk { font-size: 17px; }
.pod .nm { font-size: 13px; font-weight: 600; line-height: 1.3; }
.pod .pt {
  color: #fbbf24;
  font-size: 14px;
  font-weight: 700;
  margin-top: 6px;
}
/* Первое место — приподнято и с золотой полосой, без свечения */
.pod.p1 { transform: translateY(-6px); box-shadow: inset 0 3px 0 #f5c451; }
.ld-list { display: flex; flex-direction: column; }
.ld-row {
  display: grid;
  grid-template-columns: 28px 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 4px 6px;
  border-top: 1px solid rgba(167, 139, 250, 0.09);
  font-size: 13px;
}
.ld-row img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.ld-pos { font-size: 11.5px; color: var(--muted); text-align: center; }
.ld-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ld-amt { color: #fbbf24; font-weight: 600; font-size: 12.5px; }
.ld-more {
  align-self: flex-start;
  margin-top: 8px;
  background: transparent;
  border: none;
  color: var(--purple-light);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 2px 4px;
}

.me-row {
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.22), transparent);
  border-radius: 11px;
}

.loading, .empty { text-align: center; color: var(--muted); padding: 42px; font-size: 14.5px; }
.skel { display: grid; gap: 12px; padding: 22px 4px; }
.skel i { display: block; height: 14px; border-radius: 7px;
  background: linear-gradient(90deg, var(--raised) 0%, var(--card-hover) 50%, var(--raised) 100%) 0 0 / 200% 100%;
  animation: skel 1.4s ease-in-out infinite; }
@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel i { animation: none; } }
/* Фокус с клавиатуры виден везде одинаково; мышью кольцо не появляется. */
:focus-visible { outline: 2px solid var(--violet-hi); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: none; }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--stroke-2);
  border-top-color: var(--purple-light);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bar {
  height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  min-width: 70px;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--violet-hi);
}
/* Полоска, окрашенная по баллу */
.bar i.b5 { background: #34d399; }
.bar i.b4 { background: #60a5fa; }
.bar i.b3 { background: #fbbf24; }
.bar i.b2 { background: #f87171; }

/* Точка присутствия (легенда и компактный список) */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.dot.on { background: #34d399; box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.dot.off { background: #f87171; box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }

/* ===== КОМПАКТНЫЙ СПИСОК ПАР (режим «Компактно») ===== */
.seg.seg-sm button { font-size: 12.5px; padding: 6px 11px; }
.mk-lines { margin-top: 10px; border-top: 1px solid var(--stroke); }
.mk-mon {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple-light);
  padding: 10px 6px 4px;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.mk-line {
  display: grid;
  grid-template-columns: 8px 44px 24px minmax(120px, 250px) minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.09);
  font-size: 12.5px;
  min-height: 29px;
}
.mk-line:hover { background: rgba(255,255,255,0.04); }
.mk-line.miss .ml-subj, .mk-line.miss .ml-date { opacity: 0.55; }
.ml-date { font-size: 11.5px; color: var(--muted); }
.ml-wd { font-size: 11px; font-weight: 700; color: var(--purple-light); }
.ml-subj, .ml-theme {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ml-subj { font-weight: 600; }
.ml-theme { color: var(--muted); }
.ml-marks { display: flex; gap: 4px; justify-content: flex-end; }
.gmark.gm-sm {
  height: 19px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11.5px;
  gap: 3px;
}
.gmark.gm-sm .gm-t { font-size: 8.5px; }

/* ===== ПРЕДМЕТЫ: СРЕДНЯЯ И РАСШИРЕННЫЙ РАЗБОР ===== */
.sc-sort { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; margin: 2px 0 12px; }
.sc-sort button {
  background: var(--card-2);
  border: 1px solid var(--stroke);
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 9px;
  cursor: pointer;
}
.sc-sort button:hover { color: #fff; border-color: var(--purple-light); }
.sc-sort button.active { background: rgba(124, 58, 237, 0.3); border-color: var(--purple-light); color: #fff; }

.subj-cards { display: flex; flex-direction: column; gap: 7px; }
.subj-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
}
.subj-card.top { border-color: rgba(16, 185, 129, 0.35); }
.sc-head {
  width: 100%;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto 128px 18px;
  gap: 12px;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--txt);
  font: inherit;
  text-align: left;
  padding: 9px 12px;
  cursor: pointer;
}
.sc-head:hover { background: rgba(255,255,255,0.04); }
.sc-avg {
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 15px;
}
.sc-avg.none { background: rgba(255,255,255,0.06); border: 1px solid var(--stroke); color: var(--muted); }
.sc-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sc-name { font-weight: 600; font-size: 13.5px; }
.sc-sub { font-size: 11.5px; }
.sc-dist { display: flex; gap: 4px; }
.sc-d {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}
.sc-d b { font-size: 10px; opacity: 0.75; }
.sc-att { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.sc-chev { color: var(--purple-light); font-size: 14px; justify-self: center; transition: transform 0.18s; }
.subj-card.open .sc-chev { transform: rotate(180deg); }
.sc-body { display: none; padding: 4px 12px 14px; border-top: 1px solid var(--stroke); }
.subj-card.open .sc-body { display: block; }
.sc-sec {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple-light);
  margin: 12px 0 8px;
}
.sc-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.st-tile {
  background: var(--card-2);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.st-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.st-t { font-size: 12px; font-weight: 700; color: var(--purple-light); }
.st-avg {
  font-size: 14px;
  padding: 1px 7px;
  border-radius: 6px;
}
.st-tile .bar { min-width: 0; }
.st-sub { font-size: 11px; line-height: 1.35; }
.sc-time { display: flex; flex-wrap: wrap; gap: 4px; }
.sc-teach { font-size: 11.5px; margin-top: 12px; }

/* Планшет и телефон: боковое меню превращается в одну липкую строку.
   Вертикальный список из тринадцати пунктов при переносе занимал 408 px из
   844 — полэкрана уходило на меню ещё до первой карточки. Пункты теперь не
   переносятся, а прокручиваются вбок; активный подкручивается сам (show()). */
@media (max-width: 960px) {
  .app { display: block; padding: 0; max-width: none; }
  /* Меню на телефоне — не лента из 13 пунктов (в неё не попасть пальцем, а
     активный раздел вечно за краем), а одна кнопка-«гамбургер»: жмёшь —
     выпадает сетка всех разделов поверх контента. */
  .sidebar { position: sticky; top: 0; z-index: 60; height: auto; border-radius: 0;
    flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px;
    border-bottom: 1px solid var(--stroke); }
  /* Логотип в строке меню — это ещё 60 px по горизонтали ради украшения. */
  .sidebar .brand.small { display: none; }

  .nav-toggle { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0;
    background: var(--card-2); border: 1px solid var(--stroke-2); color: var(--txt);
    font: inherit; font-weight: 600; font-size: 15px; padding: 10px 14px;
    border-radius: 12px; cursor: pointer; text-align: left; }
  .nt-burger { display: flex; flex-direction: column; justify-content: center; gap: 3px;
    width: 18px; flex: none; }
  .nt-burger i { display: block; height: 2px; border-radius: 2px; background: var(--txt);
    transition: transform .2s, opacity .2s; }
  .nt-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  .nt-chev { flex: none; color: var(--muted); transition: transform .2s; }
  .sidebar.nav-open .nt-chev { transform: rotate(180deg); }
  /* Три полоски складываются в крестик, когда меню раскрыто. */
  .sidebar.nav-open .nt-burger i:nth-child(1) { transform: translateY(5px) rotate(45deg); }
  .sidebar.nav-open .nt-burger i:nth-child(2) { opacity: 0; }
  .sidebar.nav-open .nt-burger i:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

  /* Выпадающая панель: сетка в две колонки под строкой меню. По умолчанию
     свёрнута (прозрачна и не ловит нажатия), .nav-open её раскрывает. */
  #nav { position: absolute; left: 0; right: 0; top: 100%; z-index: 70;
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0;
    padding: 10px; background: var(--panel); border-bottom: 1px solid var(--stroke);
    box-shadow: 0 18px 40px rgba(0,0,0,0.45);
    max-height: calc(100vh - 58px); overflow-y: auto;
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: transform .18s ease, opacity .18s ease; }
  .sidebar.nav-open #nav { transform: translateY(0); opacity: 1; pointer-events: auto; }
  #nav button { justify-content: flex-start; padding: 12px 14px; font-size: 14px;
    border: 1px solid var(--stroke); background: var(--card-2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  #nav button.active { border-color: transparent; }

  /* Тап по затемнению закрывает меню. */
  .nav-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,0.45); }

  /* Выход из ленты разделов убран: мимо него промахиваются, а цена промаха —
     разлогин. Он переехал в «Профиль» (кнопка .prof-exit). */
  .logout { display: none; }
  .content { padding: 14px 14px 28px; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .leaders-podium { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .user-chip .wallet { display: none; }
  /* Шапка раздела: заголовок и плашка человека в одну строку без переносов —
     полное ФИО в три строки распирало её на треть экрана. */
  .topbar { gap: 10px; margin-bottom: 14px; }
  .topbar h2 { font-size: 21px; }
  .user-chip { padding: 5px 10px 5px 5px; gap: 8px; }
  .user-chip img { width: 30px; height: 30px; border-width: 1px; }
  .u-name { font-size: 12px; max-width: 38vw; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  .u-grp { display: none; }
  .cards-matrix { grid-template-columns: 1fr; }
  /* На телефоне тема пары и посещаемость уходят — остаётся дата, предмет, оценки */
  .mk-line { grid-template-columns: 8px 40px 22px minmax(0, 1fr) auto; gap: 7px; }
  .ml-theme { display: none; }
  .sc-head { grid-template-columns: 48px minmax(0, 1fr) 18px; row-gap: 8px; }
  .sc-dist, .sc-att { grid-column: 2 / -1; }
  /* шеврон держим в первой строке, иначе автопоток уносит его под полоску */
  .sc-chev { grid-row: 1; grid-column: 3; }
  .sc-att { justify-content: flex-start; }
  .dash-hello { padding: 16px; gap: 14px; }
  .dh-ava { width: 46px; height: 46px; border-radius: 14px; }
  .dh-text h2 { font-size: 19px; }
}

/* ===== Расписание: день / неделя / месяц ===== */
.sch-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.sch-nav { display: flex; gap: 6px; }
.nav-btn { border: 1px solid var(--stroke-2); background: var(--card-2); color: var(--txt);
  font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  transition: all .15s; }
.nav-btn:hover { border-color: var(--violet-hi); color: var(--violet-hi); }
.sch-title { font-weight: 700; font-size: 16px; margin-left: auto; }
@media (max-width: 720px) {
  .sday { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px; }
  .sd-date { flex-direction: row; align-items: baseline; gap: 8px; }
  .sd-date b { font-size: 20px; }
}

/* ===== Домашки: комментарии, скриншоты, сдача ===== */
.hw-note { margin: 6px 0; padding: 7px 10px; border-radius: 8px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke); font-size: 12px; line-height: 1.35; }
.hw-note .nt { font-weight: 500; font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 2px; }
.hw-note.teacher { border-color: rgba(124, 58, 237,0.3); background: rgba(124, 58, 237,0.08); }
.hw-cover { margin: 6px 0; }
.hw-cover img { width: 100%; max-height: 130px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--stroke); cursor: zoom-in; display: block; }
.hw-cover .cap { font-size: 10.5px; color: var(--muted); margin-top: 3px; }

.seg { flex-wrap: wrap; }
/* Просрочку видно по сроку в подвале и красной плашке — рамка вокруг
   карточки спорила бы с цветной полосой предмета. */
.hw-card.hw-overdue .hw-due b { color: var(--hot); }

/* ===== Счётчики на вкладках домашки ===== */
.seg button .cnt { font-style: normal; font-size: 11px; font-weight: 700; margin-left: 7px;
  padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--muted);
  display: none; }
.seg button .cnt.on { display: inline-block; }
.seg button.active .cnt.on { background: rgba(255,255,255,0.22); color: #fff; }

/* ===== Новости: раскрытие текста ===== */
.news-row { cursor: pointer; }
.news-row:hover { background: rgba(255,255,255,0.04); }
.news-row:focus-visible { outline: 2px solid var(--violet-hi); outline-offset: 2px; }
.news-chev { color: var(--muted); font-size: 13px; }
.news-text { margin-top: 10px; font-size: 13.5px; line-height: 1.55; }
.news-html img { max-width: 100%; height: auto; border-radius: 10px; }
.news-html a { color: var(--violet-hi); }
.news-html p { margin: 0 0 8px; }

/* ===== Профиль ===== */
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-photo { width: 92px; height: 92px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--stroke-2); flex: none; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.ach { text-align: center; padding: 10px 8px; border-radius: 12px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke); }
.ach img { width: 52px; height: 52px; object-fit: contain; margin-bottom: 6px; }
.ach-ph { font-size: 34px; line-height: 1; margin-bottom: 6px; color: #fbbf24; }
.ach-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.ach-desc { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.prof-exit { margin-left: auto; align-self: flex-start; color: var(--bad);
  border-color: rgba(239,68,68,.35); }
/* Выход красный и здесь: .fr-btn.ghost перекрашивал его в цвет текста */
.fr-btn.ghost.prof-exit { color: var(--hot); border-color: rgba(255, 84, 104, 0.35); }
.fr-btn.ghost.prof-exit:hover { background: rgba(255, 84, 104, 0.14); color: #ff7a8a; }

/* Карточка API-ключа в профиле */
.ak-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.ak-row input { flex: 1 1 0; min-width: 0; }
/* input сбрасывает шрифт на inherit сильнее, чем класс .mono */
.ak-key { font-size: 13px; font-family: "JetBrains Mono", monospace; }
.ak-note { font-size: 12.5px; margin-top: 8px; line-height: 1.45; }
.ak-warn { margin-top: 10px; padding: 9px 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
  color: var(--warn); background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); }
.ak-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ak-err { color: var(--bad); font-size: 12.5px; margin-top: 8px; min-height: 1em; }
.ak-err:empty { display: none; }
.ak-help { margin: 12px 0; font-size: 13px; color: var(--muted); }
.ak-help summary { cursor: pointer; color: var(--txt); font-weight: 600; }
.ak-help p { margin: 8px 0; line-height: 1.5; }
.ak-help code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; color: var(--txt);
  word-break: break-all; }
.ak-routes { background: var(--card-2); border: 1px solid var(--stroke); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; color: var(--txt); overflow-x: auto; }
.ak-routes div { white-space: nowrap; line-height: 1.7; }
#ak-done { margin-top: 4px; }

@media (max-width: 720px) {
  .profile-head { flex-direction: column; align-items: flex-start; }
  .profile-photo { width: 72px; height: 72px; }
  .prof-exit { margin-left: 0; }
  .ak-creds { flex-direction: column; align-items: stretch; }
}

/* ===== ЧАТ: общие элементы ленты ===== */
.chat-day { text-align: center; font-size: 11px; color: var(--muted); margin: 12px 0 8px;
  text-transform: lowercase; }
/* Сообщение: аватарка слева, тело справа; свои — зеркально */
.msg { margin-bottom: 10px; display: flex; align-items: flex-end; gap: 9px; }
.msg.own { flex-direction: row-reverse; }
.msg.grouped { margin-bottom: 4px; }
.msg-ava, .msg-ava-sp { width: 42px; height: 42px; flex: none; }
.msg-ava { border-radius: 50%; object-fit: cover; display: grid; place-items: center;
  font-size: 14.5px; font-weight: 700; color: #fff;
  border: 1px solid var(--stroke-2); }
.msg-ava.ava-sys { background: var(--card-2); color: var(--purple-light); font-size: 18px; }
.msg-body { min-width: 0; max-width: 78%; display: flex; flex-direction: column; align-items: flex-start; }
.msg.own .msg-body { align-items: flex-end; }
.msg-author { font-size: 11.5px; font-weight: 600; color: var(--purple-light); margin-bottom: 3px; }
.msg-bubble { padding: 8px 12px 6px; border-radius: 14px 14px 14px 4px;
  background: var(--card-2); border: 1px solid var(--stroke); font-size: 13.5px; line-height: 1.45;
  word-break: break-word; display: flex; align-items: flex-end; gap: 8px; }
.msg.own .msg-bubble { border-radius: 14px 14px 4px 14px;
  background: var(--card-2);
  border-color: var(--stroke-2); }
.msg.sys .msg-bubble { background: rgba(255,255,255,0.05); font-style: italic; color: var(--muted); }
.msg-time { font-size: 10px; color: var(--muted); flex: none; }
/* Кнопка подгрузки истории вверх ленты и ошибки чата */
.chat-more-wrap { text-align: center; padding: 4px 0 10px; }
.chat-more { font: inherit; font-size: 11.5px; color: var(--muted); cursor: pointer;
  padding: 5px 14px; border-radius: 999px; background: var(--card-2);
  border: 1px solid var(--stroke); transition: all .15s; }
.chat-more:hover:not(:disabled) { color: var(--txt); border-color: var(--stroke-2); }
.chat-more:disabled { cursor: default; opacity: .6; }
.chat-err { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; font-size: 12px;
  color: #fecaca; background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.3); }
.chat-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 12px; line-height: 1.6; }

/* ===== ЧАТ: полноэкранный раздел ===== */
.chat-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.chat-side h3 { margin-top: 0; }
.chat-chans { display: flex; flex-direction: column; gap: 6px; }
.chat-chan { display: flex; align-items: center; gap: 9px; text-align: left;
  padding: 8px 10px; border-radius: 11px; border: 1px solid transparent; background: transparent;
  color: var(--txt); font: inherit; cursor: pointer; transition: all .15s; }
.chat-chan:hover { background: var(--card-2); }
.chat-chan.active { background: var(--card-2); border-color: var(--stroke-2); }
/* Ростом с аватарку друга ниже: иначе строки каналов и личных чатов стоят
   в списке на разной высоте и он выглядит рваным. */
.cc-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; border-radius: 10px; background: var(--card-2); flex: none; }
.chat-chan .fr-ava { width: 36px; height: 36px; font-size: 12.5px; flex: none; }
.cc-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.cc-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.cc-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; flex: none; }
.cc-desc { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Шаблоны ИИ переиспользуют .chat-chan, но устроены иначе: у канала чата имя
   и подпись завёрнуты в .cc-body (столбик), а здесь оба span лежат прямыми
   детьми flex-строки — то есть стоят бок о бок. Плюс подпись у канала короткая
   («одногруппники»), а у шаблона это фраза на 40+ символов. В колонке 260px
   многоточие съедало ровно то, чем шаблоны отличаются друг от друга, поэтому
   здесь кладём их в столбик и разрешаем переносы. Правила скоупим по
   #ai-templates: у чата обрезка в одну строку осмысленна, её не трогаем. */
#ai-templates .chat-chan { flex-direction: column; align-items: stretch; gap: 3px; padding: 10px 12px; }
#ai-templates .cc-name { white-space: normal; overflow: visible; text-overflow: clip; }
#ai-templates .cc-desc { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.4; }
.cc-count { font-size: 11px; color: var(--muted); font-weight: 600; flex: none; }
.cc-count.cc-unread { color: #fff; background: var(--brand); border-radius: 999px;
  min-width: 18px; padding: 1px 5px; text-align: center; }
.cc-pin { flex: none; background: none; border: none; cursor: pointer; font-size: 14px; color: var(--muted);
  opacity: .45; transition: opacity .15s, color .15s; padding: 2px; line-height: 1; }
.cc-pin:hover { opacity: .9; }
.cc-pin.on { opacity: 1; color: var(--violet-hi); }
.cc-pin.fixed { cursor: default; opacity: .6; }
.cc-sep { font-size: 10.5px; color: var(--muted);
  margin: 10px 4px 4px; }
.chat-status { display: block; margin-top: 3px; font-size: 11.5px; }
/* Точка состояния связи: зелёная — поток, жёлтая — запасной режим или
   подключение, красная — связи нет. Раньше это были эмодзи-кружки. */
.chat-status[data-state]::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: 1px; background: var(--good); }
.chat-status[data-state="slow"]::before { background: var(--warn); }
.chat-status[data-state="off"]::before { background: var(--hot); }
.chat-online-h { margin: 16px 0 8px; font-size: 13px; }
.chat-online { display: flex; flex-direction: column; gap: 6px; max-height: 210px; overflow-y: auto; }
.chat-online-u { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-online-u img, .chat-online-u i { width: 28px; height: 28px; border-radius: 50%; flex: none;
  object-fit: cover; display: grid; place-items: center; font-style: normal; font-size: 9px;
  font-weight: 700; color: #fff; border: 1px solid var(--stroke-2); }
.chat-online-u b { font-size: 12px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.chat-online-none { font-size: 12px; color: var(--muted); }
.chat-note { margin-top: 14px; font-size: 11.5px; line-height: 1.5; color: var(--muted);
  border-top: 1px solid var(--stroke); padding-top: 12px; }
.chat-main { display: flex; flex-direction: column; min-height: 62vh; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  border-bottom: 1px solid var(--stroke); padding-bottom: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.chat-me { font-size: 12px; }
.chat-msgs { flex: 1; overflow-y: auto; max-height: 52vh; padding-right: 6px; }
.chat-form { display: flex; gap: 10px; margin-top: 12px; }
.chat-form input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--stroke-2);
  background: var(--card-2); color: var(--txt); font: inherit; font-size: 14px; }
.chat-form input:focus { outline: none; border-color: var(--violet-hi); }
.chat-send { margin: 0; flex: none; padding: 0 22px; }
@media (max-width: 960px) {
  /* minmax(0, 1fr), а не 1fr: иначе колонка растягивается по самому широкому
     неразрывному содержимому (строка отправки: скрепка + поле + «Спросить»)
     и весь раздел уезжает за край экрана. */
  .chat-wrap { grid-template-columns: minmax(0, 1fr); }
  .chat-chans { flex-direction: column; }
}

/* Телефон: список каналов и «кто на сайте» ложатся лентами вдоль экрана.
   Вертикально они занимали 350 px над самим разговором — на 844 px экрана
   это значит, что чат начинался за его нижним краем. Правила скоупим по
   .view-chat: в ИИ-помощнике та же разметка, но там в боковой карточке
   шаблоны с описаниями, их в строку не уложить. */
@media (max-width: 720px) {
  .view-chat .chat-side { padding: 10px 12px; }
  .view-chat .chat-chans { flex-direction: row; overflow-x: auto; gap: 6px;
    scrollbar-width: none; }
  .view-chat .chat-chans::-webkit-scrollbar { display: none; }
  .view-chat .chat-chan { flex: none; padding: 6px 10px; }
  .view-chat .cc-desc { display: none; }
  .view-chat .chat-online { flex-direction: row; max-height: none; overflow-x: auto;
    gap: 8px; scrollbar-width: none; }
  .view-chat .chat-online::-webkit-scrollbar { display: none; }
  /* Имена рядом с аватарками в строку не помещаются — остаются в подсказке. */
  .view-chat .chat-online-u b { display: none; }
  .view-chat .chat-online-h { margin: 12px 0 8px; }
  .view-chat .chat-note { display: none; }
}

@media (max-width: 560px) {
  /* Плашки со сводкой: на 390 px их семь штук по три строки — ужимаем, чтобы
     список пар начинался выше. */
  .chipstat { font-size: 12px; padding: 7px 10px; }
  .chat-form { gap: 7px; }
  .chat-send { padding: 0 14px; }
  .ai-clip { width: 38px; height: 38px; }
  .chat-msgs { max-height: 60vh; }
  .chat-main { min-height: 56vh; }
}

/* ===== Точка «новые сообщения» в боковом меню ===== */
.nav-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); margin-left: 7px; vertical-align: middle; }
.nav-badge { display: inline-block; min-width: 17px; height: 17px; padding: 0 4px; margin-left: 7px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700;
  line-height: 17px; text-align: center; font-style: normal; vertical-align: middle; }

/* ===== МИНИ-ЧАТ ===== */
.mini-chat { position: fixed; right: 22px; bottom: 22px; z-index: 900;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.mini-fab { position: relative; width: 58px; height: 58px; border-radius: 50%; border: none;
  cursor: pointer; color: #fff; display: grid; place-items: center; flex: none;
  background: var(--violet);
  box-shadow: none; transition: transform .18s, box-shadow .18s; }
.mini-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: none; }
.mini-fab:active { transform: scale(0.97); }
.mini-fab.open .mini-fab-ic { transform: rotate(-8deg); }
.mini-badge { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg); }
.mini-panel { width: 376px; max-width: calc(100vw - 32px); height: 440px; max-height: calc(100vh - 130px);
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  background: var(--panel); border: 1px solid var(--stroke-2); box-shadow: var(--shadow); animation: miniIn .18s ease-out; }
@keyframes miniIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.mini-head { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--violet) 18%, var(--card-2)); }
.mini-title { font-weight: 700; font-size: 15px; }
.mini-sub { font-size: 11.5px; color: var(--muted); }
.mini-x { background: transparent; border: none; color: var(--muted); font-size: 15px; cursor: pointer;
  padding: 4px 6px; border-radius: 8px; }
.mini-x:hover { color: var(--txt); background: rgba(255,255,255,0.08); }
.mini-full { margin: 10px 12px 0; padding: 9px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--stroke-2); background: var(--card-2); color: var(--purple-light);
  font: inherit; font-size: 12.5px; font-weight: 600; transition: all .15s; }
.mini-full:hover { background: var(--card-hover); color: #fff; border-color: var(--violet-hi); }
.mini-msgs { flex: 1; overflow-y: auto; padding: 12px 14px 4px; }
.mini-msgs .msg { gap: 7px; }
.mini-msgs .msg-ava, .mini-msgs .msg-ava-sp { width: 32px; height: 32px; }
.mini-msgs .msg-ava { font-size: 12px; }
.mini-msgs .msg-ava.ava-sys { font-size: 14px; }
.mini-msgs .msg-body { max-width: calc(100% - 34px); }
.mini-msgs .msg-bubble { font-size: 12.5px; padding: 7px 10px 5px; }
.mini-msgs .msg-author { font-size: 10.5px; }
.mini-form { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--stroke); }
.mini-form input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--stroke-2); background: var(--card-2); color: var(--txt);
  font: inherit; font-size: 13px; }
.mini-form input:focus { outline: none; border-color: var(--violet-hi); }
.mini-send { flex: none; width: 40px; border: none; border-radius: 10px; cursor: pointer; color: #fff;
  background: var(--violet); font-size: 15px; }
@media (max-width: 720px) {
  .mini-chat { right: 14px; bottom: 14px; }
  .mini-panel { width: calc(100vw - 28px); height: 62vh; }
  .mini-fab { width: 52px; height: 52px; }
}

/* ===== ИИ-ПОМОЩНИК ===== */
.ai-msgs { max-height: 56vh; }
.ai-msg { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-start; }
.ai-msg.own { flex-direction: row-reverse; }
.ai-ava { width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid;
  place-items: center; font-size: 12px; font-weight: 700; color: #fff;
  background: var(--violet);
  border: 1px solid var(--stroke-2); }
.ai-msg.own .ai-ava { background: var(--card-2); color: var(--purple-light); }
.ai-body { min-width: 0; max-width: 84%; }
.ai-msg.own .ai-body { display: flex; flex-direction: column; align-items: flex-end; }
.ai-bubble { padding: 10px 14px; border-radius: 14px; background: var(--card-2);
  border: 1px solid var(--stroke); font-size: 13.5px; line-height: 1.55; word-break: break-word; }
.ai-msg.own .ai-bubble { background: color-mix(in srgb, var(--violet) 30%, var(--card-2));
  border-color: var(--stroke-2); white-space: pre-wrap; }
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble h4 { margin: 12px 0 6px; font-size: 13.5px; color: var(--purple-light); }
.ai-bubble ul { margin: 6px 0; padding-left: 20px; }
.ai-bubble li { margin: 3px 0; }
.ai-inline { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 5px;
  font-family: "JetBrains Mono", monospace; font-size: 12px; }
.ai-code { margin: 8px 0; padding: 11px 13px; border-radius: 10px; overflow-x: auto;
  background: rgba(0,0,0,0.38); border: 1px solid var(--stroke);
  font-family: "JetBrains Mono", monospace; font-size: 12px; line-height: 1.5; position: relative; }
.ai-code[data-lang]::before { content: attr(data-lang); position: absolute; top: 5px; right: 10px;
  font-size: 9.5px; color: var(--muted); }
.ai-hr { border: none; border-top: 1px solid var(--stroke); margin: 10px 0; }

/* Реплики Gemini в общем чате: отдельный цвет, чтобы не путать с людьми. */
.msg .msg-ava.ava-ai { background: var(--violet);
  color: #fff; font-size: 18px; }
.msg.ai-say .msg-author { color: var(--purple-light); }
.msg.ai-say .msg-bubble { background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.4); }

/* Ответ бота — markdown, а не строчка. Обычный пузырь это флекс-строка «текст
   рядом со временем», и списки с блоками кода в ней сплющивались; здесь
   раскладываем в столбик, а время уводим под текст. Классы .ai-code,
   .ai-inline, .ai-hr и формулы глобальные и работают сами — дублируем только
   то, что в разделе ИИ прибито к .ai-bubble. */
.msg.ai-say .msg-bubble { flex-direction: column; align-items: stretch; gap: 3px; }
.msg.ai-say .msg-time { align-self: flex-end; }
.msg.ai-say .msg-text p { margin: 0 0 8px; }
.msg.ai-say .msg-text p:last-child { margin-bottom: 0; }
.msg.ai-say .msg-text ul, .msg.ai-say .msg-text ol { margin: 6px 0; padding-left: 20px; }
.msg.ai-say .msg-text li { margin: 3px 0; }
.msg.ai-say .msg-text h4 { margin: 10px 0 5px; font-size: 13.5px; color: var(--purple-light); }

/* Формулы. KaTeX в проект не тянем — LaTeX от модели раскладывается в
   обычный HTML (sup/sub/flex), здесь только его типографика. */
.ai-math, .m-in { font-family: "Cambria Math", "Times New Roman", Georgia, serif;
  font-size: 1.05em; line-height: 1.35; }
/* Выносная формула не переносится, а едет горизонтально: разрыв посреди
   равенства читается хуже полосы прокрутки. Строчная переносится как текст,
   иначе на телефоне она растянет всё сообщение. */
.ai-math { display: block; margin: 12px 0; padding: 8px 10px; border-radius: 8px;
  text-align: center; background: rgba(0,0,0,0.22); border: 1px solid var(--stroke);
  overflow-x: auto; overflow-y: hidden; font-size: 1.15em; white-space: nowrap; }
.m-in { padding: 0 1px; }
.ai-math i, .m-in i { font-style: italic; }
.m-up { font-style: normal; padding: 0 1px; }
.ai-math sup, .m-in sup, .ai-math sub, .m-in sub { font-size: 0.72em; line-height: 0; }
.m-frac { display: inline-flex; flex-direction: column; vertical-align: -0.55em;
  text-align: center; margin: 0 0.18em; }
.m-num { padding: 0 0.3em 1px; border-bottom: 1px solid currentColor; }
.m-den { padding: 1px 0.3em 0; }
.m-root { white-space: nowrap; }
.m-root .m-deg { font-size: 0.62em; margin-right: -0.35em; vertical-align: 0.55em; }
.m-rad { border-top: 1px solid currentColor; padding: 0 0.15em; margin-left: 1px; }
.m-over { border-top: 1px solid currentColor; padding: 0 0.1em; }
.ai-meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
.ai-file { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }

/* Три точки, пока модель думает */
.ai-thinking { display: flex; gap: 5px; align-items: center; padding: 14px; }
.ai-thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--purple-light);
  animation: ai-blink 1.2s infinite ease-in-out; }
.ai-thinking i:nth-child(2) { animation-delay: .18s; }
.ai-thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }

/* Приветствие пустого диалога */
.ai-hello { text-align: center; padding: 42px 16px; color: var(--muted); }
.ai-hello-ic { font-size: 34px; color: var(--purple-light); margin-bottom: 10px; }
.ai-hello h3 { margin: 0 0 6px; color: var(--txt); }
.ai-hello p { margin: 0; font-size: 13px; }

.ai-form { align-items: center; }
/* Кнопка без своей высоты сжималась до строки текста — тянем её по полю */
.ai-form .chat-send { align-self: stretch; }
.ai-clip { flex: none; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--stroke-2); background: var(--card-2); font-size: 16px; }
.ai-clip:hover { background: var(--card-hover); }
.ai-attach { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 8px;
  padding: 7px 11px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--stroke); }
.ai-attach button { margin-left: auto; background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; }
.ai-attach button:hover { color: var(--brand); }
.ai-err { margin-bottom: 8px; padding: 9px 13px; border-radius: 10px; font-size: 12px;
  color: #fecaca; background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.3); }
/* «Раздел не настроен» — это не сбой запроса, а состояние: янтарный, не красный. */
.ai-err.ai-warn { color: #fde68a; background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.32); }
/* Отзыв сданной работы: действие редкое и слегка опасное — приглушённое,
   но с красным ховером, чтобы не нажать мимоходом. */
.btn-withdraw {
  padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: 12.5px; color: var(--muted);
  background: transparent; border: 1px solid var(--stroke);
  transition: all 0.15s;
}
.btn-withdraw:hover { color: #f87171; border-color: rgba(239, 68, 68, 0.4); }
.btn-withdraw:disabled { opacity: 0.55; cursor: progress; }

/* Индикатор «правлю готовую работу» над полем ввода: по смыслу это то же,
   что цитата в мессенджере — показывает, к чему относится следующий текст. */
.ai-revise {
  margin-bottom: 8px; padding: 8px 12px; border-radius: 10px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px;
  background: rgba(124, 58, 237, 0.14); border: 1px solid var(--stroke-2);
}
.ai-rev-ic { color: var(--purple-light); }
.ai-revise b { font-weight: 600; }
.ai-revise button {
  margin-left: auto; padding: 3px 9px; border-radius: 7px; cursor: pointer;
  font: inherit; font-size: 11px; color: var(--muted);
  background: transparent; border: 1px solid var(--stroke);
}
.ai-revise button:hover { color: var(--txt); border-color: var(--stroke-2); }

/* Номер версии на карточке — появляется только начиная со второй. */
.ag-ver {
  font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 100px;
  background: rgba(124, 58, 237, 0.2); color: var(--purple-light);
  border: 1px solid var(--stroke-2);
}

/* ===== Карточка агента «Сделать ДЗ» ===== */
/* Живёт внутри ленты диалога вместо обычного пузыря: лог шагов, найденное
   задание, готовый файл и кнопки сдачи. */
.ag-card {
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--card-2);
  padding: 13px 15px 14px;
  animation: pop 0.22s ease both;
}
.ag-card.done { border-color: rgba(16, 185, 129, 0.34); }
.ag-card.fail { border-color: rgba(239, 68, 68, 0.34); }

.ag-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ag-ic { font-size: 15px; display: inline-flex; }
.ag-name { font-size: 12.5px; font-weight: 600; }
.ag-badge {
  font-size: 10.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 100px;
  background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.32);
}
.ag-badge.done { background: rgba(16, 185, 129, 0.18); color: #34d399; border-color: rgba(16, 185, 129, 0.34); }
.ag-badge.fail { background: rgba(239, 68, 68, 0.18); color: #f87171; border-color: rgba(239, 68, 68, 0.34); }
.ag-cancel {
  margin-left: auto; padding: 4px 11px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 11.5px; color: var(--muted);
  background: transparent; border: 1px solid var(--stroke);
}
.ag-cancel:hover { color: #f87171; border-color: rgba(239, 68, 68, 0.4); }
.ag-cancel:disabled { opacity: 0.5; cursor: not-allowed; }

.ag-req { margin-top: 9px; font-size: 12px; color: var(--muted); font-style: italic; }

/* Найденное задание */
.ag-hw {
  margin-top: 11px; padding: 10px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--stroke);
}
.ag-hw-spec { font-size: 11px; color: var(--purple-light); font-weight: 600; }
.ag-hw-theme { font-size: 13.5px; font-weight: 600; margin: 3px 0 4px; line-height: 1.35; }
.ag-hw-meta { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

/* Лог шагов */
.ag-steps { list-style: none; margin: 12px 0 0; padding: 0; }
.ag-step { display: flex; gap: 10px; padding: 5px 0; align-items: flex-start; }
/* Вертикальная нить между шагами: без неё список выглядит просто строчками,
   а не последовательностью. */
.ag-step + .ag-step { border-top: 1px solid rgba(167, 139, 250, 0.08); }
.ag-dot {
  flex: none; width: 19px; height: 19px; margin-top: 1px;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 11px; font-weight: 600;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--stroke); color: var(--muted);
}
.ag-step.ok .ag-dot { background: rgba(16, 185, 129, 0.18); border-color: rgba(16, 185, 129, 0.38); color: #34d399; }
.ag-step.fail .ag-dot { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.38); color: #f87171; }
.ag-spin {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid rgba(167, 139, 250, 0.28); border-top-color: var(--purple-light);
  animation: spin 0.7s linear infinite;
}
.ag-step-body { min-width: 0; }
.ag-step-title { font-size: 12.5px; line-height: 1.4; }
.ag-step.run .ag-step-title { color: var(--purple-light); }
.ag-step.ok .ag-step-title { color: var(--txt); }
.ag-step-detail { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; word-break: break-word; }

.ag-fail {
  margin-top: 11px; padding: 9px 12px; border-radius: 10px; font-size: 12px;
  color: #fecaca; background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Результат */
.ag-summary {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.55;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--stroke);
}
.ag-file {
  margin-top: 11px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: 12px;
}
.ag-file-name { font-weight: 600; }
.ag-link {
  font: inherit; font-size: 11.5px; padding: 0; cursor: pointer;
  color: var(--purple-light); background: none; border: none; text-decoration: underline;
  text-underline-offset: 2px;
}
.ag-link:hover { color: var(--txt); }
.ag-preview {
  margin: 10px 0 0; padding: 11px 13px; border-radius: 10px; max-height: 340px; overflow: auto;
  background: rgba(0, 0, 0, 0.38); border: 1px solid var(--stroke);
  font-family: "JetBrains Mono", monospace; font-size: 11.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

.ag-actions { margin-top: 13px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ag-actions .btn-primary, .ag-actions .btn-sec { margin: 0; padding: 8px 15px; font-size: 12.5px; }
.ag-confirm-q { font-size: 12px; color: #fbbf24; flex-basis: 100%; }
.ag-submitted { font-size: 12.5px; font-weight: 600; color: #34d399; }
.ag-submitted.mine { color: var(--muted); font-weight: 400; }
.ag-note { margin-top: 9px; font-size: 11.5px; color: var(--muted); }
.ag-note.bad { color: #fecaca; }

@media (max-width: 560px) {
  .ag-actions .btn-primary, .ag-actions .btn-sec { flex: 1 1 auto; text-align: center; }
}

.ai-reset { width: 100%; margin-top: 12px; padding: 9px; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--muted); background: transparent;
  border: 1px solid var(--stroke); }
.ai-reset:hover { color: var(--txt); border-color: var(--stroke-2); }

/* значок формата документа: в карточке агента и в списке шаблонов */
.ag-kind {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px;
  border-radius: 5px; font-style: normal; font-size: 10px; font-weight: 700; color: #fff;
  vertical-align: -4px; letter-spacing: .02em; background: var(--muted);
}
.ag-kind.k-docx { background: var(--doc-docx); }
.ag-kind.k-pdf { background: var(--doc-pdf); }
.ag-kind.k-pptx { background: var(--doc-pptx); }
.ag-kind.k-xlsx { background: var(--doc-xlsx); }

/* ===== шаблоны документов (боковая панель ИИ) ===== */
.dt { margin-top: 14px; border: 1px solid var(--stroke); border-radius: 12px; background: rgba(0, 0, 0, 0.16); }
.dt > summary {
  list-style: none; cursor: pointer; padding: 10px 12px; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.dt > summary::-webkit-details-marker { display: none; }
.dt > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.dt[open] > summary::after { transform: rotate(180deg); }
.dt-count {
  font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--card-2); color: var(--purple-light);
}
.dt-body { padding: 0 12px 12px; display: grid; gap: 10px; }
.dt-subj { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.dt-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 7px;
  font-size: 12px; padding: 5px 0; border-top: 1px solid var(--stroke);
}
.dt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-item .muted { font-size: 11px; }
.dt-del {
  font: inherit; font-size: 11px; padding: 2px 6px; border-radius: 6px; cursor: pointer;
  color: var(--muted); background: none; border: 1px solid transparent;
}
.dt-del:hover { color: var(--bad); border-color: var(--stroke-2); }
.dt-empty { font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.dt-form { display: grid; gap: 7px; }
.dt-form select {
  width: 100%; min-width: 0; font: inherit; font-size: 12px; padding: 7px 9px; border-radius: 9px;
  color: var(--txt); background: var(--card); border: 1px solid var(--stroke);
}
.dt-pick { margin: 0; text-align: center; font-size: 12px; padding: 8px 10px; cursor: pointer; }
.dt-pick.is-busy { opacity: .6; cursor: progress; }
.dt-err { font-size: 11.5px; color: #fecaca; }
.dt-hint { font-size: 11px; line-height: 1.5; color: var(--muted); }

/* ===== АВТООЦЕНКА УРОКОВ (INFO_MODAL) ===== */
.fb-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  padding: 20px 22px; border-radius: var(--radius); margin-bottom: 20px; flex-wrap: wrap;
}
.fb-head-main h3 { margin: 0 0 6px; font-size: 18px; }
.fb-head-main p { margin: 0 0 12px; max-width: 640px; }
.fb-cfg { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--stroke); color: var(--txt);
}
.fb-chip.on { border-color: var(--good); color: var(--good); }
.fb-chip.off { color: var(--muted); }
.fb-actions { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
/* label по умолчанию — колонка (поле под подписью); у переключателя галочка
   должна стоять рядом с текстом. */
.fb-toggle { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.fb-toggle input { width: 16px; height: 16px; accent-color: var(--purple-brand); }
.fb-sec { margin: 22px 2px 12px; font-size: 15px; color: var(--muted); font-weight: 600; }
.fb-pending { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
/* Пустое состояние — на всю ширину, а не в первую ячейку сетки */
.fb-log > .empty { background: var(--card); border-radius: var(--radius); }
.fb-pending > .empty { grid-column: 1 / -1; background: var(--card); border-radius: var(--radius); }
.fb-pcard {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 14px;
}
.fb-pc-teach { font-weight: 600; margin-bottom: 3px; }
.fb-pc-spec { font-size: 12px; }
.fb-pc-date { font-size: 12px; margin-top: 3px; }
.fb-rate-one { white-space: nowrap; }
.fb-log { overflow-x: auto; border-radius: var(--radius); }
.fb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fb-table th {
  text-align: left; padding: 10px 12px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--stroke); white-space: nowrap;
}
.fb-table td { padding: 10px 12px; border-bottom: 1px solid var(--stroke-2); vertical-align: top; }
.fb-table tr.ok td:last-child { color: var(--good); }
.fb-table tr.err td:last-child { color: var(--brand); }
.fb-table .nowrap { white-space: nowrap; }
.fb-src { font-size: 11px; }
.fb-server-box {
  margin-top: 14px; padding: 14px 16px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--stroke);
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
}
.fb-server-info { flex: 1 1 280px; }
.fb-server-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.fb-server-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 500;
  border: 1px solid var(--stroke);
}
.fb-server-badge.active { background: rgba(34, 197, 94, 0.15); border-color: var(--good); color: var(--good); }
.fb-server-badge.off { background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.fb-server-badge.warn { background: rgba(239, 68, 68, 0.15); border-color: var(--brand); color: var(--brand); }
.fb-server-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.fb-server-err { margin-top: 4px; color: var(--brand); font-size: 12px; font-weight: 500; }
.fb-server-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fb-modal-notice {
  padding: 12px 14px; border-radius: 10px; background: var(--card-2);
  border: 1px solid var(--stroke); font-size: 13px; line-height: 1.45;
  margin-bottom: 12px;
}
.fb-modal-notice .fb-notice-sub { margin-top: 8px; font-size: 12px; line-height: 1.4; }
.fb-consent-label {
  display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px;
  color: var(--txt); cursor: pointer; line-height: 1.4; margin: 10px 0 6px;
}
.fb-consent-label input { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; accent-color: var(--purple-brand); }

@media (max-width: 720px) {
  .fb-head { flex-direction: column; }
  .fb-actions { align-items: flex-start; width: 100%; }
  .fb-server-box { flex-direction: column; align-items: flex-start; }
  .fb-server-actions { width: 100%; justify-content: flex-start; }
}

/* ===== ДРУЗЬЯ ===== */
.fr-wrap { display: flex; flex-direction: column; gap: 14px; }
.seg.sm button { padding: 5px 12px; font-size: 12px; }

.fr-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.fr-input { flex: 1 1 220px; padding: 9px 13px; border-radius: 10px; border: 1px solid var(--stroke);
  background: var(--card); color: var(--txt); font: inherit; }
.fr-input:focus { outline: none; border-color: var(--stroke-2); }

/* Колонка широкая намеренно: при 300px на широком экране вставало по пять
   карточек в ряд, «Фамилия Имя Отчество» не влезало и жалось к аватарке.
   min() в minmax — чтобы на узком экране трек не оказался шире контейнера
   и сетка не поехала горизонтальной прокруткой. */
.fr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr)); gap: 12px; }
.fr-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 15px;
  border: 1px solid var(--stroke); background: var(--card); transition: border-color .15s; }
.fr-card:hover { border-color: var(--stroke-2); }
.fr-card.busy { opacity: .55; pointer-events: none; }
/* Контур вокруг аватарки: фото из Omni приходят разной яркости, и тёмные
   сливались с карточкой, а светлые резали глаз. Кольцо уравнивает их между
   собой и с кружками-инициалами у тех, у кого фото нет. */
.fr-ava { width: 58px; height: 58px; border-radius: 50%; flex: none; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700;
  font-size: 19px; box-shadow: 0 0 0 1px var(--stroke-2); }
.fr-meta { flex: 1; min-width: 0; }
/* ФИО переносим, а не режем многоточием: фамилия с отчеством в одну строку
   не помещается почти никогда. Потолок в две строки — чтобы случайное
   длинное имя не растянуло карточку выше соседних по ряду. */
.fr-name { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.fr-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center;
  gap: 7px; flex-wrap: wrap; }
.fr-dir { font-weight: 700; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; }
.fr-dir.rpo { background: rgba(59,130,246,.18); color: #93c5fd; }
.fr-dir.gd { background: rgba(236,27,46,.16); color: #fca5a5; }
.fr-course { font-weight: 600; font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  background: var(--card-2); color: var(--muted); }
.fr-online { color: #22c55e; font-weight: 600; }
.fr-act { display: flex; flex-direction: column; gap: 6px; flex: none; }
.fr-btn { padding: 7px 12px; border-radius: 9px; border: 1px solid transparent; background: var(--violet);
  color: #fff; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: filter .15s; }
.fr-btn:hover { filter: brightness(1.08); }
.fr-btn.ghost { background: transparent; border-color: var(--stroke-2); color: var(--txt); font-weight: 600; }
.fr-btn.ghost:hover { background: var(--card-2); filter: none; }

.fr-reqs { border: 1px solid var(--stroke-2); border-radius: 14px; padding: 12px 13px;
  background: rgba(236,27,46,.05); display: flex; flex-direction: column; gap: 9px; }
.fr-reqs-h { font-weight: 700; font-size: 12.5px; color: var(--purple-light); }
.fr-reqs .fr-card { background: var(--card-2); }

.fr-empty { padding: 40px 20px; text-align: center; color: var(--muted); line-height: 1.6; }
.fr-empty code { background: var(--card-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.fr-count { text-align: center; color: var(--muted); font-size: 12px; padding: 12px; }
.fr-more-wrap { text-align: center; padding: 12px; }
.fr-more { padding: 9px 20px; border-radius: 10px; border: 1px solid var(--stroke-2);
  background: var(--card); color: var(--txt); font: inherit; font-weight: 600; cursor: pointer; }
.fr-more:hover:not(:disabled) { background: var(--card-2); }
.fr-more:disabled { opacity: .5; cursor: default; }

@media (max-width: 560px) {
  .fr-list { grid-template-columns: 1fr; }
  .fr-card { flex-wrap: wrap; }
  .fr-act { flex-direction: row; width: 100%; }
  .fr-btn { flex: 1; }
}

/* ===== АДМИН-ПАНЕЛЬ ===== */
/* Раздел виден только администраторам (ADMIN_IDS на сервере). Оформление
   намеренно скромное: это заготовка, содержимое будет меняться. */
.adm-wrap { display: flex; flex-direction: column; gap: 14px; }
.adm-note { padding: 11px 14px; border-radius: 12px; font-size: 12.5px; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--stroke); line-height: 1.6; }
.adm-note b { color: var(--txt); }
.adm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.adm-card h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.adm-card p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.adm-num { font-size: 30px; font-weight: 700; line-height: 1.1; }
.adm-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.9; }
.adm-flag { font-weight: 600; font-size: 11px; padding: 1px 8px; border-radius: 999px; }
.adm-flag.on { background: rgba(34,197,94,.16); color: #86efac; }
.adm-flag.off { background: var(--card-2); color: var(--muted); }
.adm-todo p { font-size: 12.5px; }
.adm-wrap code { background: var(--card-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* Модерация, объявления и журнал действий в админ-панели. */
.adm-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.adm-sel { flex: 0 0 220px; }
.adm-area { width: 100%; resize: vertical; font: inherit; line-height: 1.5; }
.adm-dim { color: var(--muted); font-size: 12px; }
.adm-pad { padding: 14px; }
.adm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.adm-chip { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: var(--card-2);
  border: 1px solid var(--stroke); display: inline-flex; gap: 6px; align-items: center; }
.adm-chip b { color: var(--purple-light); }
.adm-people { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.adm-feed { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto;
  border: 1px solid var(--stroke); border-radius: 12px; padding: 8px; background: var(--card); }
.adm-msg { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 8px 10px; border-radius: 10px; background: var(--card-2); }
.adm-msg-head { grid-column: 1; display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.adm-msg-text { grid-column: 1; font-size: 13px; line-height: 1.45; word-break: break-word; }
.adm-msg [data-hide] { grid-column: 2; grid-row: 1 / span 2; }
.adm-msg.gone .adm-msg-text { opacity: .5; text-decoration: line-through; }
/* Место скрытого сообщения в обычной ленте чата. */
.msg-gone { color: var(--muted); font-size: 12.5px; }
.adm-sub { margin: 14px 0 6px; font-size: 12px; color: var(--purple-light); font-weight: 600; }

/* «Печатает…» над полем ввода. Высоту держим постоянной и в пустом состоянии:
   иначе появление подсказки дёргает ленту вверх-вниз на каждое нажатие. */
.chat-typing { min-height: 18px; padding: 0 4px 2px; font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .15s; }
.chat-typing.on { opacity: 1; }
.ct-name { color: var(--purple-light); font-weight: 600; }
.ct-dots { display: inline-flex; font-style: normal; letter-spacing: 1px; }
/* Точки анимируем в CSS: перерисовка ленты сбрасывала бы фазу таймера. */
.ct-dots b { animation: ct-blink 1.2s infinite; opacity: .25; font-weight: 600; }
.ct-dots b:nth-child(2) { animation-delay: .2s; }
.ct-dots b:nth-child(3) { animation-delay: .4s; }
@keyframes ct-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.mini-typing { padding: 0 10px 2px; font-size: 11.5px; }

/* Шаблоны ответа для /ai в админ-панели. */
.adm-prompts { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.adm-prompt { border: 1px solid var(--stroke); border-radius: 12px; padding: 11px 13px;
  background: var(--card-2); }
.adm-prompt.active { border-color: var(--stroke-2); background: rgba(124, 58, 237, 0.1); }
.adm-prompt-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
/* Промпт длинный: показываем начало, полный текст открывается при правке. */
.adm-prompt-text { font-size: 12px; color: var(--muted); line-height: 1.5; max-height: 76px;
  overflow: hidden; white-space: pre-wrap; }
.adm-prompt-act { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.adm-prompt-form { display: flex; flex-direction: column; gap: 9px; margin-top: 12px;
  padding: 12px; border: 1px solid var(--stroke-2); border-radius: 12px; background: var(--card); }

/* ===== ВЛОЖЕНИЯ И ГИФКИ В ЧАТЕ ===== */
/* Скрепка и кнопка GIF в строке ввода. */
.chat-clip { flex: none; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--stroke-2); background: var(--card-2); font-size: 16px; }
.chat-clip:hover { background: var(--card-hover); }
.chat-gif-btn { flex: none; padding: 0 12px; border-radius: 12px; border: 1px solid var(--stroke-2);
  background: var(--card-2); color: var(--txt); font: inherit; font-weight: 700; font-size: 12px; cursor: pointer; }
.chat-gif-btn:hover { background: var(--card-hover); border-color: var(--violet-hi); color: var(--violet-hi); }
/* Чип выбранного файла над формой. */
.chat-attach { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; margin: 0 0 8px; }
.chat-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border-radius: 10px; background: var(--card-2); border: 1px solid var(--stroke); max-width: 260px; }
.chat-chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-chip .chat-attach-del { background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; flex: none; }
.chat-chip .chat-attach-del:hover { color: var(--brand); }

/* Мини-чат: кнопки компактнее. */
.mini-form .chat-clip { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
.mini-form .chat-gif-btn { padding: 0 9px; border-radius: 10px; font-size: 11px; }

/* Вложения в сообщении. */
.msg-img { display: inline-block; max-width: min(320px, 70%); border-radius: 12px; overflow: hidden; }
.msg-img img { display: block; width: 100%; height: auto; }
.msg-gif { position: relative; display: block; width: 340px; max-width: 100%;
  border-radius: 12px; overflow: hidden; }
/* В мини-чате колонка узкая — там гифку держим поменьше, чтобы не распирала панель. */
.mini-msgs .msg-gif { width: 240px; }
.msg-gif img { display: block; width: 100%; height: auto; background: var(--card-2); }
.msg-gif-tag { position: absolute; left: 6px; bottom: 6px; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff; }
.msg-doc { display: inline-flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  background: rgba(0,0,0,.22); border: 1px solid var(--stroke); text-decoration: none; color: var(--txt);
  max-width: 280px; }
.msg-doc:hover { border-color: var(--violet-hi); }
.msg-doc-ic { font-size: 20px; flex: none; color: var(--violet-hi); display: flex; }
.msg-doc-meta { display: flex; flex-direction: column; min-width: 0; }
.msg-doc-name { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-doc-size { font-size: 11px; color: var(--muted); }
/* Если у сообщения только вложение, пузырю ни к чему широкий текстовый паддинг. */
.msg-bubble .msg-img, .msg-bubble .msg-gif, .msg-bubble .msg-doc { margin: 2px 0; }

/* Пикер гифок Klipy. */
.gif-pop { position: fixed; z-index: 1000; display: flex; flex-direction: column;
  max-height: min(440px, 70vh); background: var(--card); border: 1px solid var(--stroke-2);
  border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.45); overflow: hidden; }
.gif-pop.hidden { display: none; }
.gif-head { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--stroke); }
.gif-search { flex: 1; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--stroke-2);
  background: var(--card-2); color: var(--txt); font: inherit; }
.gif-search:focus { outline: none; border-color: var(--violet-hi); }
.gif-close { flex: none; width: 34px; border: none; border-radius: 9px; background: var(--card-2);
  color: var(--muted); cursor: pointer; font-size: 14px; }
.gif-close:hover { color: var(--brand); }
/* Вкладки пикера: тренды/поиск и избранное. */
.gif-tabs { display: flex; gap: 6px; padding: 8px 10px 0; }
.gif-tab { flex: 1; padding: 7px 10px; border: 1px solid var(--stroke-2); border-radius: 9px;
  background: var(--card-2); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.gif-tab:hover { color: var(--txt); }
.gif-tab.on { color: #fff; background: var(--violet); border-color: var(--violet); }
/* Высоту ячеек задаём треком грида, а не aspect-ratio: у div-ячейки auto-трек
   подстраивался под строку текста (~17px) и ячейки налезали друг на друга.
   Фиксированный ряд убирает это. */
.gif-grid { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 110px;
  gap: 6px; padding: 10px; overflow-y: auto; }
.gif-cell { position: relative; padding: 0; border: none; border-radius: 9px; overflow: hidden;
  cursor: pointer; background: var(--card-2); height: 100%; }
.gif-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-cell:hover { outline: 2px solid var(--violet-hi); }
/* Звезда «в избранное»: контур при наведении, жёлтая — у сохранённых. */
.gif-star { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; padding: 0;
  border: none; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; cursor: pointer;
  font-size: 15px; line-height: 26px; text-align: center; opacity: 0; transition: opacity .12s;
  display: flex; align-items: center; justify-content: center; }
.gif-cell:hover .gif-star { opacity: 1; }
.gif-star:hover { background: rgba(0,0,0,.72); }
.gif-star.on { opacity: 1; color: #ffc933; }
.gif-more { grid-column: 1 / -1; padding: 9px; border-radius: 9px; border: 1px solid var(--stroke-2);
  background: var(--card-2); color: var(--txt); font: inherit; cursor: pointer; }
.gif-msg { grid-column: 1 / -1; padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.gif-foot { padding: 6px 10px; border-top: 1px solid var(--stroke); text-align: right; }
.gif-credit { font-size: 10px; color: var(--muted); }

/* ===== ПЕРЕТАСКИВАНИЕ ФАЙЛА В ЧАТ ===== */
/* Зоны, над которыми ловим drop, делаем контейнером для абсолютного оверлея. */
.chat-main, .mini-panel { position: relative; }
.chat-drop { position: absolute; inset: 8px; z-index: 20; display: flex;
  align-items: center; justify-content: center; border-radius: 14px;
  background: color-mix(in srgb, var(--card) 82%, transparent); pointer-events: none; }
.chat-drop.hidden { display: none; }
.chat-drop-in { display: flex; align-items: center; justify-content: center; text-align: center;
  width: calc(100% - 8px); height: calc(100% - 8px); border-radius: 12px;
  border: 2px dashed var(--violet-hi); color: var(--violet-hi); font-weight: 600; font-size: 15px; }
.chat-drop-in::before { content: "📎"; margin-right: 8px; font-size: 18px; }
/* --- админ: карточки студентов --- */
/* Список длинный (сотня человек), поэтому строка плоская и читается по
   вертикали: имя слева, три числа справа всегда на одном месте. */
.st-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px;
  max-height: 560px; overflow-y: auto; }
/* Подписи к числам: в самих строках места на них нет, а без них колонка
   «4.4 / 88% / 16.09» читается как ребус. */
.st-legend { display: grid; grid-template-columns: 34px 1fr auto; gap: 11px;
  padding: 8px 11px 0; }
.st-legend .st-nums i { font-size: 10px; font-weight: 600; color: var(--muted); }
.st-item { border: 1px solid var(--stroke); border-radius: 12px; background: var(--card-2); }
.st-head { display: grid; grid-template-columns: 34px 1fr auto; gap: 11px; align-items: center;
  width: 100%; padding: 8px 11px; }
.st-ava { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  font-weight: 700; font-size: 12px; box-shadow: 0 0 0 1px var(--stroke-2); }
.st-who { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.st-who b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-who i { font-style: normal; font-size: 11.5px; color: var(--muted); }
.st-nums { display: flex; gap: 14px; align-items: baseline; }
/* Ширина фиксирована: иначе колонки пляшут от строки к строке и глазом
   сравнить два числа в списке уже нельзя. */
.st-nums i { font-style: normal; font-size: 12.5px; font-weight: 600; text-align: right;
  min-width: 46px; }
.st-nums i.low { color: #fca5a5; }

/* --- пасхалка «список учеников»: зелёный терминал --- */
/* Кнопка намеренно тихая: это не функция раздела, а шутка для своих. */
.st-egg { margin-top: 10px; padding: 0; background: none; border: 0; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
  color: rgba(163, 155, 184, .45); }
.st-egg:hover { color: #35ff6d; text-shadow: 0 0 8px rgba(53, 255, 109, .55); }

.hack { position: fixed; inset: 0; z-index: 1200; background: #010a03; color: #35ff6d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px;
  display: flex; flex-direction: column; overflow: hidden; }
.hack-rain { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .22; }
/* Полосы развёртки поверх всего — то самое «как в кино». pointer-events: none,
   иначе слой съедал бы клики по таблице и полю ввода. */
.hack::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(rgba(0,0,0,0) 0 2px, rgba(0,0,0,.28) 2px 4px); }
.hack-crt { position: relative; z-index: 1; display: flex; flex-direction: column;
  flex: 1; min-height: 0; padding: 14px 16px; gap: 10px; text-shadow: 0 0 7px rgba(53,255,109,.45); }
.hack-head { display: flex; align-items: center; gap: 9px; font-size: 11.5px;
  letter-spacing: .12em; border-bottom: 1px solid rgba(53,255,109,.28); padding-bottom: 8px; }
.hack-dot { width: 8px; height: 8px; border-radius: 50%; background: #35ff6d;
  box-shadow: 0 0 9px #35ff6d; animation: hack-pulse 1.4s infinite; }
@keyframes hack-pulse { 50% { opacity: .25; } }
.hack-x { margin-left: auto; background: none; border: 0; cursor: pointer; font: inherit;
  color: #35ff6d; opacity: .75; }
.hack-x:hover { opacity: 1; }
.hack-boot { margin: 0; white-space: pre-wrap; line-height: 1.55; font-size: 12.5px; }
/* Курсор мигает у последней строки лога, пока таблица не появилась. */
.hack-boot::after { content: "▋"; animation: hack-blink 1s steps(1) infinite; }
@keyframes hack-blink { 50% { opacity: 0; } }
.hack-body { display: flex; flex-direction: column; gap: 9px; flex: 1; min-height: 0; }
/* Строка приглашения — это <label>, а у него в теме flex-direction: column;
   без явного row подпись уезжает над полем. */
.hack-prompt { display: flex; flex-direction: row; align-items: center; gap: 8px;
  color: inherit; font-size: inherit; }
/* Поле ввода перебиваем по весу селектора: общее правило для input — это
   input:not([type]), оно тяжелее одного класса. */
.hack .hack-q { flex: 1; min-width: 0; background: none; border: 0; outline: none;
  padding: 0; border-radius: 0; font: inherit; color: #eaffef; caret-color: #35ff6d; }
.hack .hack-q:focus { border: 0; box-shadow: none; }
.hack .hack-q::placeholder { color: rgba(53,255,109,.4); }
.hack-scroll { flex: 1; min-height: 0; overflow: auto; border: 1px solid rgba(53,255,109,.22); }
.hack-tab { width: 100%; border-collapse: collapse; }
/* z-index обязателен: без него прокрученный дамп рисуется поверх липкой
   шапки и текст наезжает на названия колонок. */
.hack-tab th { position: sticky; top: 0; z-index: 2; background: #041307; text-align: left;
  font-size: 10.5px; letter-spacing: .1em; padding: 7px 10px;
  border-bottom: 1px solid rgba(53,255,109,.3); }
.hack-tab td { padding: 5px 10px; border-bottom: 1px solid rgba(53,255,109,.08);
  white-space: nowrap; }
.hack-tab tbody tr:nth-child(even) { background: rgba(53,255,109,.035); }
.hack-row { cursor: pointer; }
.hack-row:hover { background: rgba(53,255,109,.13); color: #d6ffe2; }
/* Раскрытая строка: подсвечиваем её саму и дамп под ней как одно целое. */
.hack-row.on { background: rgba(53,255,109,.16); color: #eaffef; }
.hack-row.on td:first-child::before { content: ">"; margin-right: 4px; }
.hack-dump > td { padding: 8px 10px 12px 22px; background: rgba(53,255,109,.06);
  border-bottom: 1px solid rgba(53,255,109,.22); white-space: normal; }
.hack-dump-cmd { opacity: .65; margin-bottom: 6px; }
.hack-dump-body { display: flex; gap: 14px; align-items: flex-start; }
.hack-dump-body pre { flex: 1; min-width: 0; }

/* --- аватарка «с кассеты» --- */
/* Расслоение цвета делаем тремя копиями фото: центральная зелёная, красная и
   синяя сдвинуты на пиксель и наложены screen'ом. Так же это делали на
   настоящей плёнке — каналы уезжали друг от друга. */
.vhs { position: relative; flex: none; width: 104px; aspect-ratio: 3 / 4; overflow: hidden;
  border: 1px solid rgba(53,255,109,.35); background: #020d04;
  box-shadow: 0 0 14px rgba(53,255,109,.18) inset; }
.vhs-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(1) contrast(1.5) brightness(.66) sepia(.7) hue-rotate(62deg) saturate(2.6); }
/* Цветные копии держим тихими: на screen'е они высветляют кадр, и при .5
   лицо уходит в молоко. Расслоение должно читаться по краям, не по всему кадру. */
.vhs-r, .vhs-b { mix-blend-mode: screen; opacity: .34; }
.vhs-r { filter: grayscale(1) sepia(1) hue-rotate(-38deg) saturate(5) contrast(1.1);
  transform: translateX(2px); }
.vhs-b { filter: grayscale(1) sepia(1) hue-rotate(168deg) saturate(5) contrast(1.1);
  transform: translateX(-2px); }
/* Строки развёртки + бегущая вверх светлая полоса: она и делает картинку
   «живой кассетой», а не просто зелёным фото. */
.vhs-lines { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.1), rgba(255,255,255,0) 18%) 0 0 / 100% 46px no-repeat,
    radial-gradient(120% 90% at 50% 45%, rgba(0,0,0,0) 40%, rgba(0,0,0,.6)),
    repeating-linear-gradient(rgba(0,0,0,0) 0 2px, rgba(0,0,0,.38) 2px 3px);
  animation: vhs-roll 5.5s linear infinite; }
@keyframes vhs-roll { from { background-position: 0 110%, 0 0, 0 0; } to { background-position: 0 -20%, 0 0, 0 0; } }
.vhs-rec, .vhs-stamp { position: absolute; font-size: 8.5px; letter-spacing: .08em;
  color: #d9ffe6; text-shadow: 0 0 6px rgba(53,255,109,.8); }
.vhs-rec { top: 5px; right: 6px; color: #ff6b6b; animation: hack-blink 1.6s steps(1) infinite; }
.vhs-stamp { left: 5px; bottom: 5px; white-space: nowrap; }
.vhs-none { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 11px; letter-spacing: .12em; color: rgba(53,255,109,.5);
  background: repeating-linear-gradient(115deg, rgba(53,255,109,.07) 0 3px, rgba(0,0,0,0) 3px 7px); }

/* Подёргивание кадра — по вкусу видеомагнитофона, но не насильно:
   с «меньше движения» в системе картинка просто стоит. */
@media (prefers-reduced-motion: no-preference) {
  .vhs { animation: vhs-jitter 3.2s steps(2) infinite; }
  @keyframes vhs-jitter { 0%, 92% { transform: none; } 94% { transform: translateX(-1px); }
    96% { transform: translateX(1px) skewX(.4deg); } 98% { transform: translateX(-1px); } }
}
@media (prefers-reduced-motion: reduce) {
  .vhs-lines { animation: none; }
  .vhs-rec { animation: none; }
}

@media (max-width: 720px) {
  .hack-dump-body { flex-direction: column; }
}
.hack-dump pre { margin: 0; white-space: pre-wrap; line-height: 1.55; font-size: 12px;
  color: #b6ffcd; }
.hack-foot { font-size: 11px; opacity: .7; }

@media (max-width: 720px) {
  .hack-crt { padding: 10px; font-size: 12px; }
  /* Узкий экран: таблица уезжает вбок в своей прокрутке, а не ломает вёрстку. */
  .hack-tab { min-width: 620px; }
}

/* Узкий экран: числа уезжают под имя, иначе имя сжимается до трёх букв. */
@media (max-width: 720px) {
  .st-head { grid-template-columns: 34px 1fr; }
  .st-legend { display: none; }
  .st-nums { grid-column: 2; gap: 12px; }
  .st-nums i { min-width: 0; }
}

/* ===== Значки интерфейса (ico() в app.js) =====
   Линейные SVG вместо эмодзи: размер — от кегля, цвет — от текста. */
.ico { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hw-file .ico { width: 13px; height: 13px; }
.btn-del-hw .ico { width: 14px; height: 14px; }
.cc-icon .ico { width: 18px; height: 18px; color: var(--violet-hi); }
.chat-clip .ico { width: 19px; height: 19px; }
.row .lead .ico { width: 18px; height: 18px; }
.ai-ava-img { width: 18px; height: 18px; display: block; }
.ai-msg .ai-ava:has(.ai-ava-img) { background: var(--raised); }
.btn-submit-hw .ico, .btn-sec .ico { width: 13px; height: 13px; margin-right: 5px; }
.btn-sm { font-size: 12px; padding: 6px 10px; display: inline-flex; align-items: center; }
/* Тройка рейтинга: место цифрой на плашке «металла» вместо медалей-эмодзи */
.rk-1, .rk-2, .rk-3 { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #1a1424; }
.rk-1 { background: #f5c451; }
.rk-2 { background: #cfd4de; }
.rk-3 { background: #d99a62; }

/* Новости: непрочитанная — фиолетовая точка, прочитанная — значок письма-файла */
.news-row .lead.unread { display: grid; place-items: center; }
.news-row .lead.unread::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--violet-hi); }

/* Нативные выпадающие списки (админка, шаблоны документов): своя стрелка
   и фон панели вместо системного вида, который на тёмной теме белел. */
select, select.fr-input, .dt-form select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 32px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23a99bc0%27 stroke-width=%272.4%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M6 9l6 6 6-6%27/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
select:focus-visible { outline: 2px solid var(--violet-hi); outline-offset: 1px; }
select option { background: var(--panel); color: var(--txt); }
