/* ============================================================
   РсухСпейсЭп — стили. Токены, темы, базовый каркас.
   Компоненты экранов/sheet'ов дополняются в частях 2–3.
   ============================================================ */

/* --- Onest (локальные woff2) --- */
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('public/fonts/onest-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('public/fonts/onest-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Тёмная тема (основная). Финальная палитра из Hi-Fi эталона. --- */
:root,
[data-theme='dark'] {
  --bg: #0E0B18;            /* основной фон */
  --surface: #17132A;       /* карточки */
  --surface-2: #201A38;     /* приподнятые блоки / bottom sheet */
  --border: rgba(255, 255, 255, 0.07); /* разделители */

  --text: #F1EEFA;          /* основной текст */
  --text-muted: #9D98B5;    /* вторичный */
  --text-dim: #6A6582;      /* третичный (даты, подписи) */

  --primary: #7C6CF7;       /* акцент / основные CTA */
  --selected: rgba(124, 108, 247, 0.15); /* фон выбранного дня */
  --selected-text: var(--primary);        /* число выбранного дня */
  --amber: #F59E0B;         /* CTA-аксессор, бейдж лекции, тумблеры on */
  --seminar: #7C6CF7;       /* контур бейджа семинара */

  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.30);
  --shadow-mid: 0 12px 48px rgba(0, 0, 0, 0.5);
  --sheet-overlay: rgba(8, 6, 14, 0.7);

  /* Лёгкая полупрозрачная подложка карточек — «парит» над основным фоном. */
  --card-bg: rgba(255, 255, 255, 0.04);
}

/* --- Светлая тема. --- */
[data-theme='light'] {
  --bg: #F6F4FB;
  --surface: #FFFFFF;
  --surface-2: #FFFFFF;
  --border: #ECE8F5;

  --text: #1A1530;
  --text-muted: rgba(26, 21, 48, 0.55);
  --text-dim: rgba(26, 21, 48, 0.35);

  --primary: #5A43E0;
  --selected: #5A43E0;
  --selected-text: #FFFFFF;
  --amber: #F59E0B;
  --seminar: #5A43E0;

  --shadow-soft: 0 2px 8px rgba(26, 21, 48, 0.05);
  --shadow-mid: 0 12px 48px rgba(0, 0, 0, 0.12);
  --sheet-overlay: rgba(246, 244, 251, 0.5);

  --card-bg: rgba(0, 0, 0, 0.03);
}

/* --- Spacing / radius шкалы (для справки и утилит) --- */
:root {
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;

  --r-card: 8px;
  --r-btn: 12px;
  --r-sheet: 16px;

  --z-content: 0;
  --z-header: 10;
  --z-sheet: 100;
  --z-overlay: 200;
}

/* --- Reset / база --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Onest', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

/* Нативный скроллбар прячем — у нас свой scrubber в режиме «Лента». В Telegram
   webview нативный скроллбар уже накладывается на наш и получается двойной. */
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; width: 0; height: 0; }
body { scrollbar-width: none; }
body::-webkit-scrollbar { display: none; width: 0; height: 0; }

.app {
  position: relative;
  z-index: var(--z-content);
  min-height: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) var(--sp-4) env(safe-area-inset-bottom);
}

/* --- Типографика --- */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.25;
}
h1 { font-size: 24px; }
h2 { font-size: 20px; }
.caption { font-size: 12px; color: var(--text-muted); }
.muted { color: var(--text-muted); }

/* --- Кнопки (базовые) --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-5);
  border: none;
  border-radius: var(--r-btn);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); filter: brightness(0.92); }
.btn--amber { background: var(--amber); color: #1A1530; }
.btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
}
.btn--block { width: 100%; }

/* --- Иконочная кнопка (шапка) --- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* --- Маскот --- */
.mascot {
  width: 140px;
  height: 140px;
  object-fit: contain;
  image-rendering: auto;
}

/* --- Утилиты раскладки --- */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.center-screen {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--sp-4);
}

/* --- Спиннер (загрузка, рядом с маскотом «думает») --- */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Выбор группы (picker) --- */
.picker {
  padding-top: var(--sp-5);
  gap: var(--sp-5);
}
.picker-head h2 { margin-bottom: var(--sp-1); }
.picker-head__top {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.picker-head__top h2 { margin-bottom: 0; }
.picker-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: -6px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.picker-back:hover { background: var(--surface-2); }
.picker-back:active { background: var(--surface-2); filter: brightness(0.92); transform: scale(0.97); }

.picker-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: var(--sp-3) 0 calc(-1 * var(--sp-2));
}
.picker-group-title:first-of-type { margin-top: 0; }

.option-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.option-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.option-row:hover { background: var(--surface-2); }
.option-row:active { transform: scale(0.97); background: var(--surface-2); filter: brightness(0.95); }
.option-row__label { font-size: 16px; font-weight: 600; }
.option-row__sub { font-size: 12px; color: var(--text-muted); }

.course-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}
.course-chip {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.course-chip:active { transform: scale(0.97); background: var(--primary); }

.picker-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.search-input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* --- Сплэш (ожидание persistence на старте) --- */
.splash {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Расписание (3/3)
   ============================================================ */
.schedule {
  padding-top: var(--sp-2);
}

/* Верхняя строка: погода слева, шестерёнка справа */
.sched-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}
.icon-btn { color: var(--text-dim); }
.sched-top__right { display: flex; align-items: center; gap: var(--sp-2); }
.today-btn {
  min-height: 36px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--amber);
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--amber);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.today-btn:active { background: rgba(245, 158, 11, 0.12); }

.weather { display: flex; align-items: center; gap: 5px; }
.weather__icon { font-size: 16px; line-height: 1; }
.weather__temp { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* Полоска дней — горизонтальный скролл по всему загруженному диапазону
   (обычно весь семестр), выбранный день центрируется. */
.week-strip {
  display: flex;
  gap: 4px;
  margin-bottom: var(--sp-2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.week-strip::-webkit-scrollbar { display: none; }
.day-cell {
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  cursor: pointer;
  scroll-snap-align: center;
}
.day-cell__num {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 15px; font-weight: 600;
}
.day-cell__dow { font-size: 11px; font-weight: 500; }
.day-cell--sel .day-cell__num {
  background: var(--selected);
  color: var(--selected-text);
  font-weight: 700;
}
.day-cell--sel .day-cell__dow { color: var(--primary); font-weight: 600; }
/* Пустой день (в диапазоне, без пар) — приглушаем, но кликается */
.day-cell--empty { opacity: 0.4; }
/* Сегодня — акцентный жёлтый (приоритет над выбранным) */
.day-cell--today { opacity: 1; }
.day-cell--today .day-cell__num {
  background: var(--amber);
  color: #1A1530;
  font-weight: 700;
}
.day-cell--today .day-cell__dow { color: var(--amber); font-weight: 600; }
/* Недельный вид: подсветка всех 7 дней текущей недели в полоске
   (исключая сегодня — пусть остаётся акцентно-жёлтым). */
.day-cell--in-range:not(.day-cell--today):not(.day-cell--sel) .day-cell__num {
  background: var(--selected);
  color: var(--selected-text);
}
/* Недельный режим: одна общая pill-плашка за всеми 7 днями недели вместо
   отдельных подсвеченных кружков. Сегодняшний/выбранный кружки остаются
   поверх плашки (их собственные стили __num выигрывают по специфичности). */
/* Pill — это фон только за рядом чисел; ярлыки «Пн/Вт/…» остаются под плашкой.
   Реализовано через ::before, чтобы высота плашки не растягивалась на весь
   .day-cell (он содержит и __num, и __dow), а ограничивалась рядом чисел. */
.week-strip__pill {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  isolation: isolate;
  width: 100%;
}
.week-strip__pill::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 6px;
  height: 40px;
  background: var(--surface-2);
  border-radius: 999px;
  z-index: -1;
}
/* В недельном режиме сама полоска не скроллится — 7 ячеек распределяются
   равномерно по ширине, без обрезки последнего дня (Bug 1). */
.week-strip--weekly {
  overflow-x: hidden;
}
.week-strip--weekly .day-cell {
  flex: initial;
  min-width: 0;
  width: 100%;
}
.week-strip--weekly .day-cell--in-range:not(.day-cell--today):not(.day-cell--sel) .day-cell__num {
  background: transparent;
  color: var(--text);
}
/* В недельном виде выбранный день внутри pill не получает свой кружок —
   достаточно общей плашки (выделять «выбран» в режиме «по неделям» нечего:
   листание всё равно идёт неделями, акцент только на «сегодня»). */
.week-strip--weekly .day-cell--sel:not(.day-cell--today) .day-cell__num {
  background: transparent;
}
.week-strip--weekly .day-cell--sel:not(.day-cell--today) .day-cell__dow {
  color: var(--text-dim);
  font-weight: 500;
}

/* Навигация дня */
.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.day-nav__title { font-size: 15px; font-weight: 600; }
.day-nav__arrow {
  width: 52px; height: 52px;
  border: none; background: transparent;
  color: var(--text);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}
.counter {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 14px;
  min-height: 14px;
}

.sched-body { min-height: 300px; }
/* Мягкая анимация смены дня/недели — только тело, без шапки и полоски дней.
   forward → приехать справа; backward → слева; fade → быстрое появление. */
.sched-body--in-forward  { animation: sched-slide-in-right 220ms ease-out both; }
.sched-body--in-backward { animation: sched-slide-in-left 220ms ease-out both; }
.sched-body--in-fade     { animation: sched-fade-in 180ms ease-out both; }
@keyframes sched-slide-in-right {
  from { transform: translateX(28px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes sched-slide-in-left {
  from { transform: translateX(-28px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes sched-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sched-body--in-forward,
  .sched-body--in-backward,
  .sched-body--in-fade { animation: none; }
}
.mascot-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: 48px 0;
  text-align: center;
}
.mascot-block h1 { font-size: 15px; font-weight: 500; color: var(--text-muted); }

/* --- Пара: общий бейдж/точка --- */
.badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-radius: 4px;
  padding: 2px 7px;
}
.badge--lecture { color: var(--amber); border: 1px solid rgba(245,158,11,0.25); }
.badge--seminar { color: var(--seminar); border: 1px solid rgba(124,108,247,0.25); }
.badge--other   { color: var(--text-muted); border: 1px solid var(--border); }
.badge--lecture-seminar { color: var(--seminar); border: 1px solid rgba(124,108,247,0.25); background: linear-gradient(90deg, rgba(245,158,11,0.1), rgba(124,108,247,0.1)); }
.badge--solid.badge--lecture { background: rgba(245,158,11,0.1); }
.badge--solid.badge--seminar { background: rgba(124,108,247,0.1); }
.badge--solid.badge--lecture-seminar { background: linear-gradient(90deg, rgba(245,158,11,0.1), rgba(124,108,247,0.1)); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; box-sizing: border-box; }
.dot--lecture { background: var(--amber); }
.dot--seminar { border: 2px solid var(--seminar); }
.dot--lecture-seminar { background: linear-gradient(90deg, var(--amber) 50%, var(--seminar) 50%); }
.dot--other   { background: var(--text-dim); }

/* --- Блочный вид --- */
.lessons--block { display: flex; flex-direction: column; gap: 8px; }
.lesson--block {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: none;
  /* Акцентная линия с 2px отступом от левого края карточки — даём ей «дышать»,
     карточка кажется менее плоской. Реализовано через box-shadow inset, чтобы
     не двигать содержимое. */
  border-radius: 12px;
  padding: 14px 14px 14px 16px;
  box-shadow: inset 4px 0 0 var(--amber), var(--shadow-soft);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.lesson--block.kind-seminar { box-shadow: inset 4px 0 0 var(--seminar), var(--shadow-soft); }
.lesson--block.kind-other { box-shadow: inset 4px 0 0 var(--text-dim), var(--shadow-soft); }
.lesson--block.kind-lecture-seminar { box-shadow: inset 4px 0 0 var(--seminar), var(--shadow-soft); }
.lesson--block:active { transform: scale(0.99); }
.lesson__time { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.lesson__title { font-size: 16px; font-weight: 600; margin-top: 5px; }
.lesson__badge-row { margin-top: 7px; }
.lesson__meta { font-size: 12px; color: var(--text-dim); margin-top: 7px; }
/* Строка «аудитория — тип»: одной строкой, space-between. Без плашек/бейджей. */
.lesson__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  min-width: 0;
}
.lesson__room {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
  min-width: 0;
}
.lesson__room-placeholder { display: inline-block; }
.lesson__room-icon { font-size: 12px; line-height: 1; }
.lesson__room-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lesson__type {
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}
/* Экзамен подсвечиваем amber (отдельный класс, см. renderBlock), лекция/
   семинар/прочее по умолчанию приглушены — уже задано выше через .lesson__type. */
.lesson__type--exam { color: var(--amber); font-weight: 600; }

/* --- Компактный вид --- */
.lessons--compact { display: flex; flex-direction: column; }
.lesson--compact {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.lesson__c-time { width: 40px; font-size: 13px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.lesson__c-title { flex: 1; font-size: 14px; font-weight: 500; }
.lesson__c-room { font-size: 13px; font-weight: 600; color: var(--text); }

/* --- Ленточный вид --- */
.lessons--ribbon { display: flex; flex-direction: column; gap: 8px; }
.lesson--ribbon { display: flex; gap: 10px; }
.ribbon__axis { display: flex; flex-direction: column; align-items: center; width: 40px; flex-shrink: 0; }
.ribbon__time { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.ribbon__line { flex: 1; width: 2px; background: var(--border); margin-top: 4px; }
.lesson--ribbon:last-child .ribbon__line { display: none; }
.lesson--ribbon.kind-seminar .ribbon__line { background: repeating-linear-gradient(var(--border) 0 4px, transparent 4px 8px); }
.ribbon__card {
  flex: 1;
  text-align: left;
  background: var(--surface);
  border: none;
  border-left: 3px solid var(--amber);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.ribbon__card.kind-seminar { border-left-color: var(--seminar); }
.ribbon__card.kind-other { border-left-color: var(--text-dim); }
.ribbon__card.kind-lecture-seminar { border-left-color: var(--seminar); border-image: linear-gradient(var(--amber), var(--seminar)) 1; }
.ribbon__title { font-size: 14px; margin-top: 0; }

/* ============================================================
   Режим «Лента» — непрерывный скролл всего семестра, sticky-месяцы,
   вертикальный скруббер справа.
   ============================================================ */
.sched-body--feed { position: relative; }

/* В режиме «Лента» верхняя шапка с «Сегодня»/⚙️ становится sticky — иначе
   при скролле пропадает доступ к настройкам и быстрому возврату к сегодня. */
.schedule--feed .sched-top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  /* Полная ширина: подложка вылазит за горизонтальные padding'и .app, чтобы
     при скролле край контента не оставался видимым по бокам. */
  margin: 0 calc(-1 * var(--sp-4));
  padding: 0 var(--sp-4);
}

.feed {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding-bottom: 48px;
  /* справа — место под scrubber-track (ширина scrubber'а 28px + 6px от края),
     чтобы карточки не залезали под ползунок. */
  padding-right: 20px;
}

.feed-month { display: flex; flex-direction: column; gap: var(--sp-3); }
.feed-month__head {
  position: sticky;
  /* Высота sticky-sched-top = min-height 44px. Месяцы прилипают под ней. */
  top: 44px;
  z-index: 5;
  margin: 0 calc(-1 * var(--sp-4));
  padding: 10px var(--sp-4) 8px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-bottom: 1px solid var(--border);
}
.feed-month__days { display: flex; flex-direction: column; gap: var(--sp-5); }

/* scroll-margin = высота sticky-sched-top (44) + месяца (~36) + breathing room. */
.feed-day { display: flex; flex-direction: column; gap: var(--sp-2); scroll-margin-top: 96px; }
.feed-day__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 2px 0;
}
.feed-day__title { min-width: 0; }
.feed-day__head .weather__icon { font-size: 13px; }
.feed-day__head .weather__temp { font-size: 12px; }

.feed-day--today .feed-day__head {
  color: var(--amber);
}
.feed-day--today .feed-day__title::after {
  content: '· сегодня';
  margin-left: 6px;
  font-size: 11px;
  color: var(--amber);
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Пустые дни (без пар) — заголовок есть, но приглушённый, тело пустое. */
.feed-day--empty .feed-day__head { opacity: 0.45; }

/* Вертикальный ползунок-скруббер. Тонкий, полупрозрачный — не мешает. */
.feed-scrubber {
  position: fixed;
  top: 96px;
  right: 6px;
  /* выше FAB (поиск преподавателя) — 56px кнопка + 20px отступ + breathing room. */
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  width: 28px;
  z-index: 30;
  display: flex;
  justify-content: center;
  /* Контейнер не ловит тачи — иначе пользователь, скроллящий пальцем у правого
     края экрана, всё время триггерил бы drag. Интерактивен только сам ползунок. */
  pointer-events: none;
}
.feed-scrubber__track {
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  background: var(--border);
  border-radius: 999px;
  opacity: 0.6;
}
.feed-scrubber__thumb {
  position: absolute;
  top: 0;
  width: 16px;
  height: 32px;
  background: var(--amber);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transition: transform 60ms linear, width 120ms ease, height 120ms ease;
}
.feed-scrubber--drag .feed-scrubber__thumb {
  cursor: grabbing;
  width: 18px;
  height: 36px;
  transition: width 120ms ease, height 120ms ease;
}
.feed-scrubber__tip {
  position: absolute;
  right: 32px;
  transform: translateY(-50%);
  padding: 6px 10px;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-mid);
  transition: opacity 120ms ease;
}
.feed-scrubber__tip--on { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .feed-scrubber__thumb, .feed-scrubber--drag .feed-scrubber__thumb { transition: none; }
}

/* --- Недельный вид: 7 дней друг под другом, листание неделями --- */
.week-days { display: flex; flex-direction: column; gap: var(--sp-5); }
.week-day { display: flex; flex-direction: column; gap: var(--sp-2); }
.week-day__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--border);
}
.week-day__head--today { color: var(--amber); border-bottom-color: var(--amber); }
.week-day__title { min-width: 0; }
.week-day__head .weather__icon { font-size: 14px; }
.week-day__head .weather__temp { font-size: 12px; }
.week-day__empty {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  padding: var(--sp-2) 0 var(--sp-3);
}

/* ============================================================
   Bottom sheet (детали пары / настройки)
   ============================================================ */
.overlay {
  position: fixed; inset: 0;
  z-index: var(--z-overlay);
  background: var(--sheet-overlay);
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: flex-end;
}
.overlay--in { opacity: 1; }
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  margin: 0 auto;
  background: var(--surface-2);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-mid);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.overlay--in .sheet { transform: translateY(0); }
.sheet__handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 18px;
}
.sheet__title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }

/* Детали пары */
.detail__title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.detail__badge-row { margin-bottom: 16px; }
.detail__rows { display: flex; flex-direction: column; }
.detail__row {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.detail__row:last-child { border-bottom: none; }
.detail__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.detail__dot--amber { background: var(--amber); }
.detail__k { font-size: 11px; color: var(--text-dim); }
.detail__v { font-size: 14px; font-weight: 500; margin-top: 2px; }
.detail__breakdown { margin: 4px 0 0; padding-left: 18px; font-size: 13px; font-weight: 400; color: var(--text-muted); }
.detail__breakdown li { margin-top: 2px; }
.detail__section { margin-top: var(--sp-4); }
.detail__section-title {
  font-size: 10px; font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px; text-transform: uppercase;
  margin-bottom: var(--sp-1);
}

/* Заметки в деталях пары */
.detail__note-section { margin-top: var(--sp-4); }
.detail__note-label {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: var(--sp-1);
}
.detail__note-header {
  display: flex; align-items: center; justify-content: space-between;
}
.detail__note-text {
  font-size: 14px; color: var(--text); line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.detail__note-edit {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 4px; display: flex; align-items: center;
}
.detail__note-edit:active { color: var(--primary); }
.detail__note-add {
  background: none; border: 1px dashed var(--border); border-radius: 8px;
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  padding: var(--sp-2) var(--sp-3); width: 100%;
}
.detail__note-add:active { background: var(--selected); }
.detail__note-input {
  width: 100%; resize: none; min-height: 160px; max-height: 300px;
  overflow-y: auto;
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: var(--sp-2); outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}
.detail__note-input::-webkit-scrollbar { width: 4px; }
.detail__note-input::-webkit-scrollbar-track { background: transparent; }
.detail__note-input::-webkit-scrollbar-thumb {
  background: var(--text-dim); border-radius: 4px;
}
.detail__note-input:focus { border-color: var(--primary); }
.detail__note-actions { margin-top: var(--sp-2); }
.btn--small { padding: 8px 16px; font-size: 13px; }

/* Заметка в посещаемости */
.attend-item__name-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.attend-item__note-hint { font-size: 12px; flex-shrink: 0; }
.attend-item__note {
  font-size: 13px; color: var(--text-muted); line-height: 1.4;
  padding: 0 var(--sp-3) var(--sp-2); white-space: pre-wrap; word-break: break-word;
}

/* Настройки */
.settings__label {
  font-size: 10px; font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px; text-transform: uppercase;
  margin-bottom: 8px;
}
.settings__group {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.settings__group-name { font-size: 15px; font-weight: 600; }
.settings__group-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.link-amber { border: none; background: transparent; color: var(--amber); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }

.segmented { display: flex; gap: 6px; margin-bottom: 18px; }
.seg {
  flex: 1;
  border: none;
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 11px; font-weight: 500;
  cursor: pointer;
}
.seg--on { background: var(--amber); color: #1A1530; font-weight: 700; }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.toggle {
  width: 44px; height: 24px;
  border: none;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.toggle--on { background: var(--amber); }
.toggle__knob {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.15s ease;
}
.toggle--on .toggle__knob { left: 22px; }
.settings__version { padding: 14px 0; font-size: 12px; color: var(--text-dim); }

/* --- Доступность: скрытый, но читаемый скринридером --- */
.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;
}

/* ============== FAB поиска преподавателя ============== */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(20, 8, 63, .35);
  cursor: pointer;
  z-index: 50;
  transition: transform .25s cubic-bezier(.2,.7,.2,1), opacity .2s ease, filter .12s ease;
}
.fab:hover { filter: brightness(1.08); }
.fab:active { filter: brightness(.9); transform: scale(0.96); }
.fab--hidden { transform: translateY(110px); opacity: 0; pointer-events: none; }
/* Расписание ещё не нарисовано (загрузка / ошибка / иное состояние). */
.fab--gone { display: none; }

/* ============== Баннер режима преподавателя ============== */
.teacher-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  margin: 8px 0;
  background: rgba(124, 108, 247, .12);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.teacher-banner__text { flex: 1; min-width: 0; }
.teacher-banner__label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.teacher-banner__name { font-size: 15px; font-weight: 600; color: var(--text); margin-top: 2px; }
.teacher-banner__back { font-size: 13px; }

/* ============== Поиск преподавателя (sheet) ============== */
.teacher-search { display: flex; flex-direction: column; gap: 10px; }
.teacher-search__input input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  outline: none;
}
.teacher-search__input input:focus { border-color: var(--primary); }
.teacher-search__status { color: var(--text-muted); min-height: 18px; }
.teacher-search__list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }

/* Staggered появление строк поиска преподавателя. */
@keyframes teacher-row-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.teacher-row { animation: teacher-row-in 150ms ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .teacher-row { animation: none; }
}

/* ============== Настройки: блоки тумблеров, разделитель, ссылки ============== */
/* Группа тумблеров в едином карточном контейнере. */
.toggle-list {
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.toggle-list > .toggle-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.toggle-list > .toggle-row:last-child { border-bottom: none; }

/* Список ссылок (поддержать, о приложении). */
.settings__list {
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.settings__hint { font-size: 12px; color: var(--text-muted); padding: 4px 2px 8px; }
.settings__divider { height: 1px; background: var(--border); margin: 18px 0; }

.link-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease;
}
.settings__list > .link-row:last-child { border-bottom: none; }
.link-row:hover { filter: brightness(1.08); }
.link-row:active { filter: brightness(.9); transform: scale(0.99); }
.link-row__icon { font-size: 18px; line-height: 1; width: 22px; text-align: center; }
.link-row__text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.link-row__label { font-size: 14px; font-weight: 500; }
.link-row__sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.link-row__chev { color: var(--text-dim); font-size: 18px; line-height: 1; }

.error-report {
  text-align: center;
  margin-top: var(--sp-3);
}
.error-report__link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

/* ============================================================
   Экран «Профиль»: блоки «Студент / Экзамены / Статистика / Посещаемость»
   ============================================================ */
.profile {
  padding-top: 0;
  /* Внизу — большой отступ, чтобы последний предмет в посещаемости
     не упирался в край viewport (учитываем safe-area iOS). */
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  gap: var(--sp-6);
}
.profile-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: var(--sp-3) 0 var(--sp-2);
}
.profile-head h2 { margin: 0; }
.profile-loading {
  text-align: center;
  color: var(--text-muted);
  padding: var(--sp-6) 0;
}

.profile-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.profile-block__title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding-left: var(--sp-1);
}
.profile-block__card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.profile-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: var(--sp-2) 0;
}

/* — Блок «Студент» — */
.profile-student { display: flex; flex-direction: column; gap: 6px; }
.profile-student__direction { font-size: 18px; font-weight: 700; color: var(--text); }
.profile-student__details { font-size: 13px; color: var(--text-muted); }
.profile-student__institute { font-size: 14px; color: var(--text); margin-top: 4px; }
.profile-student__profile { font-size: 12px; }
.profile-student__group { font-size: 12px; margin-bottom: var(--sp-2); }
.profile-student__change { margin-top: var(--sp-2); }

/* — Блок «Экзамены» — */
.exams-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text);
}
.exams-counter strong { color: var(--amber); }
.info-tip {
  border: none;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  position: relative;
}
.info-tip:active { background: rgba(255,255,255,0.05); }
.info-tip-wrap { position: relative; }
.tip-bubble {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 12;
  width: 240px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  border-radius: 10px;
  box-shadow: var(--shadow-mid);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.tip-bubble--on { opacity: 1; transform: translateY(0); }

.exam-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.exam-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: var(--sp-3);
  border-left: 3px solid var(--amber);
}
.exam-row__date { font-size: 12px; font-weight: 600; color: var(--amber); }
.exam-row__subject { font-size: 14px; font-weight: 600; color: var(--text); }
.exam-row__meta { font-size: 12px; color: var(--text-muted); }
.exam-row--past { opacity: 0.45; border-left-color: var(--text-dim); }
.exam-row--past .exam-row__date {
  color: var(--text-dim);
  text-decoration: line-through;
}

/* — Блок «Статистика семестра» — */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: 14px;
  color: var(--text);
}
.stat-row strong { font-weight: 700; }
.stat-row--col { flex-direction: column; align-items: flex-start; gap: 2px; }
.progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: var(--sp-2);
}
.progress__bar {
  height: 100%;
  background: var(--amber);
  border-radius: 3px;
  transition: width 280ms ease-out;
}
.progress-label {
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
}
.progress-label strong { color: var(--amber); }

/* — Блок «Посещаемость» — */
.attend-list { display: flex; flex-direction: column; }
.attend-item {
  border-bottom: 1px solid var(--border);
}
.attend-item:last-child { border-bottom: none; }
.attend-item__head {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.attend-item__subject {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attend-item__counter {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.attend-item__chev {
  color: var(--text-dim);
  font-size: 18px;
  width: 14px;
  text-align: center;
  transition: transform 160ms ease;
}
.attend-item--open .attend-item__chev { transform: rotate(90deg); }
.attend-item__body {
  display: none;
  padding: 0 0 var(--sp-3);
  flex-direction: column;
}
.attend-item--open .attend-item__body { display: flex; }

.attend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-2) 0;
  border-top: 1px dashed var(--border);
  font-size: 13px;
}
.attend-row:first-child { border-top: none; }
.attend-row__date { color: var(--text); font-weight: 500; }
.attend-row__future-mark { font-size: 11px; }
.attend-row--future { opacity: 0.55; }
.attend-status {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, transform 80ms ease;
}
.attend-status:active { transform: scale(0.95); }
.attend-status--present { border-color: rgba(34,197,94,0.45); background: rgba(34,197,94,0.12); }
.attend-status--absent  { border-color: rgba(239,68,68,0.45); background: rgba(239,68,68,0.12); }
.attend-status--none    { color: var(--text-dim); }

/* Сводка посещаемости сверху раздела: текущий процент + прогресс-бар + ℹ️ */
.attend-summary {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.attend-summary__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.attend-summary__label { font-size: 14px; color: var(--text); }
.attend-summary__value-wrap { display: inline-flex; align-items: center; gap: 4px; }
.attend-summary__value { color: var(--amber); font-weight: 700; font-size: 15px; }
.attend-summary__hint { font-size: 12px; }
