/* Базовые стили, layout и компоненты дизайн-системы.
   Все цвета/отступы — только через токены из tokens.css. Mobile-first. */

/* ---------- Сброс и база ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: var(--leading-tight); font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { color: var(--text-muted); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
::selection { background: var(--accent-soft); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: 100;
  background: var(--accent); color: var(--on-accent); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
}
.skip-link:focus { top: var(--space-4); }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: var(--text-sm); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-6); }
.stack-lg > .page-header { margin-bottom: 0; }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
.grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 479px) { .grid-stats .stat-value { font-size: var(--text-xl); } .grid-stats .card { padding: var(--space-4); } }

/* ---------- Layout приложения ---------- */
.app { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: min(var(--sidebar-w), 85vw);
  background: var(--surface-1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  transform: translateX(-100%); transition: transform var(--dur) var(--ease);
}
.sidebar[data-open="true"] { transform: none; box-shadow: var(--shadow-lg); }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 39; background: var(--overlay); }
.sidebar-backdrop[hidden] { display: none; }
.brand {
  display: flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg);
  color: var(--text); padding: var(--space-2) var(--space-3) var(--space-4);
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; flex: none; object-fit: cover; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { margin-top: var(--space-4); padding: 0 var(--space-3) var(--space-1); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); }
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-md);
  color: var(--text-muted); font-weight: 500; font-size: var(--text-sm);
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.nav a[aria-current="page"] .icon { color: var(--accent-text); }
.nav .badge { margin-left: auto; }
.nav a[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.sidebar-footer { margin-top: auto; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-4);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.content { padding: var(--space-5) var(--space-4) var(--space-12); max-width: 1200px; margin: 0 auto; }
.page-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-header p { margin-top: var(--space-1); }

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .sidebar-backdrop, .menu-toggle { display: none !important; }
  .main { margin-left: var(--sidebar-w); }
  .content { padding: var(--space-8) var(--space-8) var(--space-12); }
}

/* Центрированная страница (вход/регистрация) */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--space-6) var(--space-4);
  background: var(--bg);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; padding-bottom: var(--space-6); }

/* ---------- Иконки ---------- */
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-h); padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-weight: 600; font-size: var(--text-sm); line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn[aria-busy="true"] { position: relative; color: transparent; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--on-accent); border-right-color: transparent; animation: spin 0.7s linear infinite;
}

/* ---------- Формы ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.help { font-size: var(--text-xs); color: var(--text-subtle); }
.field-error { font-size: var(--text-xs); color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: 0 var(--space-3);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { padding: var(--space-3); min-height: 110px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: var(--space-3); font-size: var(--text-sm); color: var(--text-muted); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-errors { list-style: none; padding: 0; }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-title { font-family: var(--font-display); font-size: var(--text-base); font-weight: 700; }
.card-interactive { transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card-interactive:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.stat-value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; font-variant-numeric: lining-nums; color: var(--text); }
.stat-label { font-size: var(--text-sm); color: var(--text-muted); }
.stat-value.text-danger { color: var(--danger); }
.stat-value-sm { display: block; font-size: var(--text-lg); }
a.stat-value-sm:hover { text-decoration: none; color: var(--accent-text); }

/* ---------- Бейджи статусов ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-muted);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Алерты / баннеры ---------- */
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--surface-2); font-size: var(--text-sm);
}
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--text); }
.alert-success { background: var(--success-soft); border-color: transparent; color: var(--text); }
.alert-warning { background: var(--warning-soft); border-color: transparent; color: var(--text); }
.alert-danger { background: var(--danger-soft); border-color: transparent; color: var(--text); }
.banner { border-radius: 0; border-width: 0 0 1px; justify-content: center; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 600; color: var(--text-subtle); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Прогресс ---------- */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 300ms var(--ease); }
.progress[data-level="warning"] > span { background: var(--warning); }
.progress[data-level="danger"] > span { background: var(--danger); }
progress.progress { appearance: none; width: 100%; border: 0; }
progress.progress::-webkit-progress-bar { background: var(--surface-3); }
progress.progress::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-full); }
progress.progress::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-full); }

/* ---------- Аватар ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text);
  font-weight: 700; font-size: var(--text-xs);
}

/* ---------- Пустое состояние / ошибка ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3);
  padding: var(--space-8) var(--space-4); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.empty .icon { width: 36px; height: 36px; color: var(--text-subtle); }
.empty-title { font-weight: 700; color: var(--text); }
.empty p { max-width: 36ch; font-size: var(--text-sm); }

/* ---------- Skeleton ---------- */
.skeleton {
  display: block; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton-text { height: 0.9em; margin: 0.35em 0; }
.skeleton-title { height: 1.4em; width: 50%; }
.skeleton-block { height: 96px; }

/* ---------- Модалка (нативный <dialog>) ---------- */
.modal {
  width: min(560px, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100dvh - 2 * var(--space-6));
  margin: auto; padding: 0; color: var(--text);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.modal[open] { animation: pop var(--dur) var(--ease); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) 0; }
.modal-body { padding: var(--space-4) var(--space-5); overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: 0 var(--space-5) var(--space-5); flex-wrap: wrap; }

/* ---------- Тосты ---------- */
.toasts {
  position: fixed; z-index: 60; left: var(--space-4); right: var(--space-4); bottom: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none;
}
@media (min-width: 640px) { .toasts { left: auto; width: 380px; } }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow-md);
  font-size: var(--text-sm); animation: slide-up var(--dur) var(--ease);
}
.toast[data-level="success"] { border-left: 3px solid var(--success); }
.toast[data-level="error"] { border-left: 3px solid var(--danger); }
.toast[data-level="warning"] { border-left: 3px solid var(--warning); }
.toast[data-level="info"] { border-left: 3px solid var(--info); }
.toast-close { margin-left: auto; background: none; border: 0; color: var(--text-subtle); cursor: pointer; padding: 0; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: var(--space-3) var(--space-3); color: var(--text-muted); font-size: var(--text-sm); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Меню / выпадашки (<details>) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: 50; min-width: 220px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: var(--space-2);
}
.menu-panel a, .menu-panel button {
  display: flex; width: 100%; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: none; border: 0; color: var(--text); font-size: var(--text-sm); text-align: left; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-label { padding: 0 var(--space-3) var(--space-2); font-size: var(--text-sm); color: var(--text-subtle); }
.menu-sep { height: 1px; margin: var(--space-2) 0; background: var(--border); }

/* ---------- Чек-лист ---------- */
.checklist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.checklist li { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.checklist .tick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; display: grid; place-items: center; }
.checklist li[data-done="true"] .tick { background: var(--success); border-color: var(--success); }

/* ---------- HTMX-индикатор ---------- */
.htmx-indicator { opacity: 0; transition: opacity var(--dur) var(--ease); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- Анимации ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Списки, тулбары, детали ---------- */
.narrow { max-width: 720px; }
.prewrap { white-space: pre-wrap; color: var(--text); }
.plain { list-style: none; padding: 0; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; letter-spacing: 0.12em; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px var(--space-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.toolbar .select { width: auto; min-width: 150px; flex: 1 1 150px; }
.toolbar-search { flex: 3 1 240px; }
.list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.list-item {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.list-item:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.list-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.list-title { font-weight: 600; }
.mark-row {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  background: var(--surface-1); border: 1px solid var(--border);
}
.mark-row .list-main { color: var(--text); }
.mark-row .list-main:hover { text-decoration: none; }
.mark-actions { gap: var(--space-2); flex-wrap: wrap; }
.list-meta { margin-left: auto; gap: var(--space-2); }
.avatar-lg { width: 52px; height: 52px; font-size: var(--text-base); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.dl dt { color: var(--text-subtle); }
.dl dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.copy-box { display: flex; gap: var(--space-2); }
.copy-box .input { flex: 1; min-width: 0; font-size: var(--text-sm); }
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-top: var(--space-4); }

/* ---------- Группы чекбоксов / радио ---------- */
fieldset.field { border: 0; padding: 0; min-width: 0; }
.choices { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.choices-stack { flex-direction: column; }
.choice {
  display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer;
  min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border); font-size: var(--text-sm);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { accent-color: var(--accent); width: 16px; height: 16px; }
.input-sm { min-height: 32px; width: 110px; font-size: var(--text-sm); }
/* Поля повтора видны только когда выбран повтор (без JS) */
.lesson-form:has(select[name="repeat"] option[value="none"]:checked) .repeat-fields { display: none; }

/* ---------- Календарь: неделя ---------- */
.week { display: grid; gap: var(--space-2); grid-template-columns: 1fr; }
.week-day { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-3); min-width: 0; }
.week-day.is-today { border-color: var(--accent); box-shadow: var(--glow-accent); }
.week-day-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.week-day-name { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); }
.week-day-num { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); }
.is-today .week-day-num { color: var(--accent-text); }
.week-add { margin-left: auto; }
.week-day-body { display: flex; flex-direction: column; gap: var(--space-2); }
.week-empty { color: var(--text-subtle); font-size: var(--text-sm); }
@media (min-width: 1024px) {
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .week-day { min-height: 320px; }
  .week-day-head { flex-wrap: wrap; }
}

.lesson-chip {
  display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); background: var(--accent-soft); border-left: 3px solid var(--accent);
  color: var(--text); font-size: var(--text-sm); min-width: 0;
}
.lesson-chip:hover { text-decoration: none; background: var(--surface-3); }
.lesson-chip-wide { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.lesson-day { font-weight: 700; font-size: var(--text-xs); color: var(--text); min-width: 7.5em; }
.lesson-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--text-xs); color: var(--accent-text); }
.lesson-title { font-weight: 600; overflow-wrap: anywhere; }
.lesson-who { color: var(--text-muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
.lesson-chip.status-done { background: var(--success-soft); border-left-color: var(--success); }
.lesson-chip.status-done .lesson-time { color: var(--success); }
.lesson-chip.status-canceled { background: var(--surface-2); border-left-color: var(--border-strong); }
.lesson-chip.status-canceled .lesson-title { text-decoration: line-through; color: var(--text-subtle); }

/* ---------- Календарь: неделя сеткой по часам (перетаскивание — static/js/calendar.js) ---------- */
.tgrid { display: none; --hour-h: 52px; --hours-w: 52px; }
@media (min-width: 900px) {
  .tgrid { display: block; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
  .tgrid + .week { display: none; }
}
.tgrid-head, .tgrid-body { display: grid; grid-template-columns: var(--hours-w) repeat(7, minmax(0, 1fr)); }
.tgrid-head { border-bottom: 1px solid var(--border); }
.tgrid-hint { display: none; font-size: var(--text-sm); }
@media (min-width: 900px) { .tgrid-hint { display: block; } }
.tgrid-day { display: flex; align-items: baseline; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-left: 1px solid var(--border); }
.tgrid-day.is-today .week-day-num { color: var(--accent-text); }
.tgrid-scroll { max-height: 70vh; overflow-y: auto; }
.tgrid-body { position: relative; }
.tgrid-hours { position: relative; }
.tgrid-hour { display: block; height: var(--hour-h); font-size: 11px; color: var(--text-subtle); text-align: right; padding-right: var(--space-2); transform: translateY(-0.6em); font-variant-numeric: tabular-nums; }
.tgrid-hour:first-child { transform: none; }
.tgrid-col {
  position: relative; border-left: 1px solid var(--border);
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 100% var(--hour-h);
}
.tgrid-col.is-today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }
.tgrid[data-editable] .tgrid-col { cursor: cell; }
.tgrid-col.is-drop { background-color: color-mix(in srgb, var(--accent) 10%, transparent); }
.tgrid-event {
  position: absolute; left: 3px; right: 3px; display: flex; flex-direction: column; gap: 1px; overflow: hidden;
  padding: 3px 6px; border-radius: var(--radius-md); background: var(--accent-soft); border-left: 3px solid var(--accent);
  color: var(--text); font-size: var(--text-xs); line-height: 1.25; cursor: pointer; touch-action: none; user-select: none;
  transition: box-shadow var(--dur) var(--ease);
}
.tgrid-event:hover { text-decoration: none; background: var(--surface-3); }
.tgrid-event[data-move-url] { cursor: grab; }
.tgrid-event.is-dragging { cursor: grabbing; z-index: 5; box-shadow: var(--shadow-lg, 0 8px 24px rgb(0 0 0 / 0.4)); opacity: 0.95; transition: none; }
.tgrid-event.is-saving { opacity: 0.6; pointer-events: none; }
.tgrid-event.status-done { background: var(--success-soft); border-left-color: var(--success); }
.tgrid-event.status-canceled { background: var(--surface-2); border-left-color: var(--border-strong); color: var(--text-subtle); text-decoration: line-through; }
.tgrid-time { font-weight: 700; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.tgrid-event.status-done .tgrid-time { color: var(--success); }
.tgrid-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.tgrid-resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: var(--border-strong); opacity: 0; transition: opacity var(--dur) var(--ease); }
.tgrid-event:hover .tgrid-resize::after { opacity: 1; }
.tgrid-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.tgrid-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.move-bar {
  position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; max-width: calc(100vw - 32px);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); background: var(--surface-3);
  border: 1px solid var(--border-strong); box-shadow: 0 10px 30px rgb(0 0 0 / 0.45); font-size: var(--text-sm);
}
.month-chip[draggable="true"] { cursor: grab; }
.month-cell.is-drop { background: var(--accent-soft); }

/* ---------- Календарь: месяц ---------- */
.month { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-1); }
.month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-head div { padding: var(--space-2); font-size: var(--text-xs); color: var(--text-subtle); text-transform: uppercase; text-align: center; border-bottom: 1px solid var(--border); }
.month-cell { min-height: 64px; padding: var(--space-1); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.month-cell:nth-child(7n) { border-right: 0; }
.month-row:last-child .month-cell { border-bottom: 0; }
.month-cell.is-out { background: var(--bg); }
.month-cell.is-out .month-num { color: var(--text-subtle); }
.month-num { font-size: var(--text-xs); font-weight: 700; color: var(--text); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.month-cell.is-today .month-num { background: var(--accent); color: var(--on-accent); }
.month-chip { display: block; font-size: 11px; padding: 1px 4px; border-radius: 4px; background: var(--accent-soft); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-chip.status-done { background: var(--success-soft); }
.month-chip.status-canceled { background: var(--surface-2); text-decoration: line-through; color: var(--text-subtle); }
@media (min-width: 720px) { .month-cell { min-height: 110px; padding: var(--space-2); } .month-chip { font-size: var(--text-xs); } }

/* ---------- Участники занятия ---------- */
.participant { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.participant:last-child { border-bottom: 0; }
.participant-name { flex: 1 1 160px; color: var(--text); font-weight: 600; }
.participant-price { display: flex; align-items: center; gap: var(--space-1); }

/* ---------- Вложения ---------- */
.attachments { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.attachment {
  display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%;
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: var(--text-sm);
}
.attachment span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Чат ---------- */
.content:has(.chat) { padding-bottom: var(--space-4); }
.chat { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-h) - var(--space-10)); min-height: 420px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.chat-thread { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.chat-empty { margin: auto; border: 0; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: min(80%, 620px); }
.msg-mine { align-self: flex-end; align-items: flex-end; }
.msg-bubble { padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); background: var(--surface-3); border-bottom-left-radius: var(--radius-sm); }
.msg-mine .msg-bubble { background: var(--accent); color: var(--on-accent); border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-sm); }
.msg-mine .msg-bubble .prewrap { color: var(--on-accent); }
.msg-mine .attachment { background: rgb(255 255 255 / 0.15); border-color: transparent; color: var(--on-accent); }
.msg-mine .attachment .subtle { color: rgb(255 255 255 / 0.8); }
.msg-meta { font-size: var(--text-xs); color: var(--text-subtle); margin-top: 2px; }
.chat-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--border); }
.chat-input { flex: 1 1 200px; min-height: var(--control-h); max-height: 160px; padding: var(--space-2) var(--space-3); }
.chat-files { flex-basis: 100%; }
.chat-files:empty { display: none; }
.assign-form:has(input[name="assigned_to_all"]:checked) .assign-students { display: none; }
@media (max-width: 1023px) {
  /* Пустые дни недели на телефоне — одной строкой */
  .week-day:has(.week-empty) { display: flex; align-items: center; padding: var(--space-2) var(--space-3); }
  .week-day:has(.week-empty) .week-day-head { margin: 0; flex: 1; }
  .week-day:has(.week-empty) .week-day-body { display: none; }
}
.chat-input { resize: none; overflow-y: auto; }

/* ---------- Тарифы ---------- */
.plan-card { position: relative; }
.plan-card.is-featured { border: 2px solid var(--text); }
.plan-card.is-current { background: var(--surface-2); }
.plan-features { font-size: var(--text-sm); display: flex; flex-direction: column; gap: var(--space-1); flex: 1; }
.input-promo { min-height: 34px; font-size: var(--text-sm); }
.banner a { font-weight: 700; margin-left: var(--space-2); }
.limit-card h1 { font-size: var(--text-xl); }
@media print {
  .no-print, .sidebar, .topbar, .toasts, .skip-link { display: none !important; }
  body, .auth { background: #fff; color: #000; }
  .card { border: 0; box-shadow: none; }
}

/* ---------- Тесты ---------- */
/* Конструктор вопроса: показываем поля для выбранного типа */
.question-form .field-options, .question-form .field-answers, .question-form .field-pairs { display: none; }
.question-form:has(select[name="kind"] option[value="single"]:checked) .field-options,
.question-form:has(select[name="kind"] option[value="multiple"]:checked) .field-options,
.question-form:has(select[name="kind"] option[value="short"]:checked) .field-answers,
.question-form:has(select[name="kind"] option[value="matching"]:checked) .field-pairs { display: flex; }
.question-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); }
.question-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-weight: 700; font-size: var(--text-sm); flex: none; }
.question-text { font-size: var(--text-lg); color: var(--text); }
.question-image { max-height: 320px; width: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
.code-block { white-space: pre; overflow-x: auto; font-family: ui-monospace, Consolas, monospace; font-size: var(--text-sm); background: var(--surface-2); padding: var(--space-3); border-radius: var(--radius-md); }
details.card > summary { cursor: pointer; }

.quiz-head { position: sticky; top: var(--topbar-h); z-index: 5; background: var(--bg); padding: var(--space-3) 0; margin-bottom: 0; }
.timer { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; font-variant-numeric: tabular-nums; }
.timer[data-level="warning"] { border-color: var(--warning); color: var(--warning); }
.timer[data-level="danger"] { border-color: var(--danger); color: var(--danger); }
.matching { display: flex; flex-direction: column; gap: var(--space-2); }
.matching-row { display: grid; grid-template-columns: 1fr; gap: var(--space-2); align-items: center; }
@media (min-width: 640px) { .matching-row { grid-template-columns: 1fr 1fr; } }

.result-card .stat-value { font-size: var(--text-3xl); }
.question-review.is-correct { border-left: 3px solid var(--success); }
.question-review.is-wrong { border-left: 3px solid var(--danger); }
.review-option { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); }
.review-option.is-correct { background: var(--success-soft); }
.review-option.is-wrong { background: var(--danger-soft); }
.review-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.essay-answer { padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius-md); }
.review-grade { border-top: 1px solid var(--border); padding-top: var(--space-3); }
.history-item { padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: 0; }
/* Мини-график результатов тестов: высота столбика — класс dyn-N (десятки процентов), без inline-стилей (CSP) */
.dynamics { display: flex; align-items: flex-end; gap: var(--space-1); height: 120px; padding-top: var(--space-4); }
.dyn-bar { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: var(--radius-sm); }
.dyn-fill { display: block; width: 100%; border-radius: var(--radius-sm); background: var(--accent); min-height: 4px; }
.dyn-bar.is-fail .dyn-fill { background: var(--danger); }
.dyn-label { position: absolute; top: -18px; width: 100%; text-align: center; font-size: 11px; color: var(--text-subtle); }
.dyn-0 { height: 4%; } .dyn-1 { height: 10%; } .dyn-2 { height: 20%; } .dyn-3 { height: 30%; } .dyn-4 { height: 40%; }
.dyn-5 { height: 50%; } .dyn-6 { height: 60%; } .dyn-7 { height: 70%; } .dyn-8 { height: 80%; } .dyn-9 { height: 90%; } .dyn-10 { height: 100%; }

/* ---------- Публичный сайт ---------- */
.site-container { max-width: 1120px; margin: 0 auto; padding: 0 var(--space-5); }
.site-header { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.site-header .site-container { min-height: var(--topbar-h); }
.site-header .brand { padding: 0; }
.site-nav { gap: var(--space-2); }
@media (max-width: 719px) { .hide-mobile { display: none; } }
.site-section { padding: 5rem 0; }
.section-title { font-size: clamp(1.75rem, 3.4vw, 2.5rem); max-width: 22ch; }
.eyebrow { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); }
.site-footer { border-top: 1px solid var(--border); padding: var(--space-8) 0; font-size: var(--text-sm); }
.site-footer nav { gap: var(--space-4); }

.hero { padding: 4rem 0 5rem; border-bottom: 1px solid var(--border); }
.hero-grid { display: grid; gap: var(--space-10); align-items: center; }
@media (min-width: 960px) { .hero-grid { grid-template-columns: 1.15fr 0.85fr; gap: 4rem; } .hero { padding: 6rem 0 6.5rem; } }
.hero-title { font-size: clamp(2.25rem, 5.4vw, 4rem); line-height: 1.04; letter-spacing: -0.025em; font-weight: 600; max-width: 15ch; }
.hero-title em { font-style: italic; font-weight: 500; color: var(--accent-text); }
.hero .badge { align-self: flex-start; }
.hero-lead { font-size: var(--text-lg); color: var(--text-muted); max-width: 52ch; }

.preview { position: relative; display: flex; flex-direction: column; gap: var(--space-3); }
.preview .card { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.preview-card { display: flex; flex-direction: column; gap: var(--space-2); transform: rotate(-1.2deg); }
.preview-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); transform: rotate(0.8deg); }
.preview-chat { display: flex; flex-direction: column; gap: var(--space-2); margin-left: var(--space-6); transform: rotate(-0.5deg); }
.preview-chat .msg { max-width: 90%; }
.preview .stat-value { font-size: var(--text-3xl); }

.feature-list { list-style: none; padding: 0; display: grid; border-top: 1px solid var(--border-strong); margin-top: var(--space-4); }
.feature-row { display: grid; gap: var(--space-2) var(--space-8); padding: var(--space-6) 0; border-bottom: 1px solid var(--border); align-items: baseline; }
@media (min-width: 720px) { .feature-row { grid-template-columns: 3.5rem 15rem 1fr; } }
.feature-row .num { font-family: var(--font-display); font-size: var(--text-sm); color: var(--text-subtle); font-variant-numeric: lining-nums; }
.feature-row h3 { font-size: var(--text-xl); }
.feature-row p { max-width: 60ch; }

.steps { list-style: none; padding: 0; display: grid; gap: var(--space-8); margin-top: var(--space-4); }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); gap: var(--space-10); } }
.step { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-4); border-top: 2px solid var(--text); }
.step-num { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 500; line-height: 1; color: var(--accent-text); }
.step h3 { font-size: var(--text-lg); }

.faq { padding: var(--space-4) var(--space-5); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin-top: var(--space-3); }
.cta { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); padding: clamp(2rem, 6vw, 4rem); background: var(--text); border-color: var(--text); border-radius: var(--radius-xl); }
.cta .section-title { color: var(--bg); }
.cta p { color: color-mix(in srgb, var(--bg) 78%, transparent); max-width: 44ch; }
.legal h2 { font-size: var(--text-lg); margin-top: var(--space-4); }
.legal p, .legal li { color: var(--text); }
.legal ul { padding-left: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); }

.tutor-grid { display: grid; gap: var(--space-6); align-items: start; }
@media (min-width: 960px) { .tutor-grid { grid-template-columns: 1fr 380px; } .lead-card { position: sticky; top: calc(var(--topbar-h) + var(--space-4)); } }
.tutor-head { align-items: flex-start; gap: var(--space-5); }
.tutor-photo { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-strong); }
.avatar-xl { width: 112px; height: 112px; font-size: var(--text-2xl); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.check-help { padding-left: 30px; }

.wizard-steps { list-style: none; padding: 0; display: flex; gap: var(--space-2); }
.wizard-steps li { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: var(--text-sm); background: var(--surface-3); color: var(--text-muted); }
.wizard-steps li[aria-current="step"] { background: var(--accent); color: var(--on-accent); }
.wizard-steps li.is-done { background: var(--success-soft); color: var(--success); }

/* Аналитика платформы */
.chart { width: 100%; height: auto; max-height: 180px; }
.chart-bar { fill: var(--accent); }
.chart-bar-empty { fill: var(--border); }
.staff { max-width: 1200px; margin: 0 auto; }

/* Банк заданий */
.math-display { display: block; overflow-x: auto; overflow-y: hidden; padding: var(--space-2) 0; text-align: center; }
.prose p { margin: 0 0 var(--space-3); }
.prose p:last-child { margin-bottom: 0; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-md); }
.prose table { border-collapse: collapse; margin: var(--space-3) 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: var(--space-2) var(--space-3); }
.prose ul, .prose ol { margin: 0 0 var(--space-3); padding-left: var(--space-5); }
.bank-layout { display: grid; gap: var(--space-5); grid-template-columns: 1fr; align-items: start; }
@media (min-width: 960px) { .bank-layout { grid-template-columns: 280px minmax(0, 1fr); } }
.topic-tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.topic-tree ul { list-style: none; margin: 0 0 var(--space-2); padding-left: var(--space-4); }
.topic-tree a { display: flex; justify-content: space-between; gap: var(--space-2); padding: 6px 10px; border-radius: var(--radius-md); color: var(--text-muted); text-decoration: none; font-size: var(--text-sm); }
.topic-tree a:hover { background: var(--surface-2); color: var(--text); }
.topic-tree a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-text); }
.task-card { display: flex; flex-direction: column; gap: var(--space-3); }
.task-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.reveal > summary { cursor: pointer; list-style: none; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal[open] > summary { margin-bottom: var(--space-3); }
.katex svg { max-width: none; } /* глобальное svg { max-width: 100% } обнуляло стрелки векторов, корни, дроби */

/* Просмотр страниц сдачи */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.page-thumb { position: relative; display: block; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface-2); }
.page-thumb img { width: 100%; height: 180px; object-fit: cover; }
.page-num { position: absolute; top: 6px; left: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; border-radius: 999px; padding: 0 8px; font-size: var(--text-xs); }
body.viewer-open { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; background: rgba(5, 8, 18, 0.96); touch-action: none; }
.viewer[hidden] { display: none; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); color: #fff; }
.viewer-tools { display: flex; gap: var(--space-2); }
.viewer-tools button, .viewer-nav { min-width: 44px; min-height: 44px; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.08); color: #fff; font-size: 1.25rem; cursor: pointer; }
.viewer-tools button:focus-visible, .viewer-nav:focus-visible { outline: 2px solid var(--accent); }
.viewer-stage { flex: 1; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.viewer-img { max-width: 100%; max-height: 100%; user-select: none; transform-origin: center; transition: transform 0.08s ease-out; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.viewer-prev { left: var(--space-2); }
.viewer-next { right: var(--space-2); }

/* ---------- Лёгкая «живость» кабинета ----------
   Только короткие однократные анимации при загрузке и отклик на наведение; при «уменьшить движение» — выключено. */
@media (prefers-reduced-motion: no-preference) {
  /* Плавное появление содержимого страницы, блоки — с небольшой лесенкой */
  .content > * { animation: rise 420ms var(--ease) both; }
  .content > .stack-lg > *, .content > .stack > * { animation: rise 420ms var(--ease) both; }
  .content > .stack-lg > :nth-child(2), .content > .stack > :nth-child(2) { animation-delay: 50ms; }
  .content > .stack-lg > :nth-child(3), .content > .stack > :nth-child(3) { animation-delay: 100ms; }
  .content > .stack-lg > :nth-child(4), .content > .stack > :nth-child(4) { animation-delay: 150ms; }
  .content > .stack-lg > :nth-child(5), .content > .stack > :nth-child(5) { animation-delay: 200ms; }
  .content > .stack-lg > :nth-child(n+6), .content > .stack > :nth-child(n+6) { animation-delay: 240ms; }
  .grid > .card { animation: rise 420ms var(--ease) both; }
  .grid > .card:nth-child(2) { animation-delay: 60ms; }
  .grid > .card:nth-child(3) { animation-delay: 120ms; }
  .grid > .card:nth-child(4) { animation-delay: 180ms; }

  /* Карточки-ссылки и статистика слегка приподнимаются */
  .card-interactive:hover, a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md, 0 6px 18px rgb(0 0 0 / 0.08)); }
  a.card { transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }

  /* Меню: иконка чуть сдвигается, активный пункт — мягкая полоска */
  .nav a .icon { transition: transform var(--dur) var(--ease), color var(--dur) var(--ease); }
  .nav a:hover .icon { transform: translateX(2px); }
  .nav a[aria-current="page"] { animation: nav-in 320ms var(--ease) both; }

  /* Кнопки: блик по основной при наведении, нажатие — лёгкое «вдавливание» */
  .btn-primary { position: relative; overflow: hidden; isolation: isolate; }
  .btn-primary::after {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 0.22) 50%, transparent 70%);
    transform: translateX(-120%); transition: transform 600ms var(--ease);
  }
  .btn-primary:hover::after { transform: translateX(120%); }
  .btn:active { transform: translateY(1px) scale(0.98); }

  /* Выпадающее меню профиля и полоски прогресса */
  details.menu[open] > .menu-panel { animation: pop 160ms var(--ease) both; transform-origin: top right; }
  .progress > span { animation: grow 700ms var(--ease) both; transform-origin: left center; }
  .badge-accent { animation: badge-pop 420ms var(--ease) both 300ms; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes nav-in { from { box-shadow: inset 0 0 0 var(--accent); } to { box-shadow: inset 2px 0 0 var(--accent); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: none; } }
@keyframes badge-pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: none; } }

/* Котёнок в пустых состояниях «всё сделано» и на 404 — маленький, появляется только когда дел нет */
.kitten { display: block; width: 120px; height: auto; margin: 0 auto calc(-1 * var(--space-2)); user-select: none; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .kitten { display: none; } }
@media (prefers-reduced-motion: no-preference) { .kitten { animation: kitten-in 500ms var(--ease) both 150ms; } }
@keyframes kitten-in { from { opacity: 0; transform: translateY(10px) scale(0.92); } to { opacity: 1; transform: none; } }

/* Кнопки рядом с полем «Ссылка на онлайн-урок» */
.meeting-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: calc(-1 * var(--space-2)); }
.meeting-tools .help { flex-basis: 100%; margin: 0; }

/* Карточка «Пригласите ученика» вверху профиля нового ученика */
.access-card-new { border-color: var(--accent); background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface-1); }

/* ---------- Модалка «Приведите друга» ---------- */
.referral-modal { width: min(480px, calc(100vw - 2 * var(--space-4))); overflow: hidden; }
.referral-modal .modal-body { position: relative; padding-top: var(--space-5); text-align: left; }
.referral-modal h2 { font-family: var(--font-display); font-size: var(--text-xl); padding-right: var(--space-8); }
.referral-close { position: absolute; top: var(--space-3); right: var(--space-3); }
.referral-hero {
  position: relative; height: 120px; display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(135deg, #6a4ce6, #3b82f6 60%, #22c1a4);
}
.referral-gift {
  position: relative; z-index: 1; display: grid; place-items: center; width: 64px; height: 64px;
  border-radius: 20px; background: rgb(255 255 255 / 0.18); color: #fff;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.18); backdrop-filter: blur(4px);
}
.referral-gift .icon { width: 32px; height: 32px; }
.referral-orb { position: absolute; border-radius: 50%; filter: blur(18px); opacity: 0.7; }
.referral-orb-a { width: 140px; height: 140px; left: -30px; top: -40px; background: #a78bfa; }
.referral-orb-b { width: 160px; height: 160px; right: -40px; bottom: -70px; background: #5eead4; }
.referral-modal .row { flex-wrap: wrap; }
@media (prefers-reduced-motion: no-preference) {
  .referral-modal[open] { animation: pop 260ms var(--ease) both; }
  .referral-gift { animation: gift-bob 2.6s ease-in-out infinite; }
  .referral-orb-a { animation: orb-drift 7s ease-in-out infinite alternate; }
  .referral-orb-b { animation: orb-drift 9s ease-in-out infinite alternate-reverse; }
}
@keyframes gift-bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(4deg); } }
@keyframes orb-drift { from { transform: translate(0, 0); } to { transform: translate(30px, 16px); } }
@media (max-width: 480px) { .referral-modal .copy-box { flex-direction: column; } }
