/* ------------------------------------------------------------------ токены */

:root {
  --bg: #f4f5fa;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #e6e7fb 0%, transparent 60%),
             radial-gradient(900px 500px at 95% 0%, #e4f1fb 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --text: #14151c;
  --muted: #6a6f83;
  --faint: #9aa0b4;
  --border: #e5e7f0;
  --border-strong: #d5d8e6;
  --accent: #5b5bd6;
  --accent-text: #ffffff;
  --accent-soft: #ecebfd;
  --danger: #d64545;
  --ok: #2e9e6b;
  --warn: #c98a17;
  --shadow: 0 1px 2px rgba(20, 21, 28, .04), 0 8px 24px rgba(20, 21, 28, .06);
  --shadow-lg: 0 12px 48px rgba(20, 21, 28, .18);
  --radius: 16px;
  --radius-sm: 10px;
  --tint-l: 96%;
  --tint-s: 70%;
  --chip-l: 92%;
  --stripe-l: 58%;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

html[data-theme="dark"] {
  --bg: #0c0d12;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #1b1c33 0%, transparent 60%),
             radial-gradient(900px 500px at 95% 0%, #12232f 0%, transparent 55%);
  --surface: #15171f;
  --surface-2: #1c1f29;
  --text: #e8eaf2;
  --muted: #949ab0;
  --faint: #6e748a;
  --border: #242833;
  --border-strong: #333846;
  --accent: #8b8bf5;
  --accent-text: #10111a;
  --accent-soft: #1e2038;
  --danger: #e56a6a;
  --ok: #4cc38a;
  --warn: #e0ac3c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
  --tint-l: 15%;
  --tint-s: 40%;
  --chip-l: 20%;
  --stripe-l: 62%;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #0c0d12;
    --bg-grad: radial-gradient(1200px 600px at 15% -10%, #1b1c33 0%, transparent 60%),
               radial-gradient(900px 500px at 95% 0%, #12232f 0%, transparent 55%);
    --surface: #15171f;
    --surface-2: #1c1f29;
    --text: #e8eaf2;
    --muted: #949ab0;
    --faint: #6e748a;
    --border: #242833;
    --border-strong: #333846;
    --accent: #8b8bf5;
    --accent-text: #10111a;
    --accent-soft: #1e2038;
    --danger: #e56a6a;
    --ok: #4cc38a;
    --warn: #e0ac3c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
    --tint-l: 15%;
    --tint-s: 40%;
    --chip-l: 20%;
    --stripe-l: 62%;
  }
}

* { box-sizing: border-box; }

/* Правила ниже задают display элементам, у которых он бывает выключен атрибутом. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ----------------------------------------------------------------- шапка */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 18px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.brand__badge {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--accent), #38a3d1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.brand__sub {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions { margin-left: auto; display: flex; gap: 6px; }

.ghost-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, transform .3s;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text); }
.ghost-btn:active { transform: scale(.94); }
.ghost-btn.is-spinning svg { animation: spin .9s linear infinite; }
/* Включённый фильтр подгруппы подсвечивает шестерёнку. */
.ghost-btn.is-on { color: var(--accent); background: var(--accent-soft); }

@keyframes spin { to { transform: rotate(360deg); } }

html[data-theme="dark"] .i-sun, html[data-theme="auto"] .i-sun { display: none; }
html[data-theme="dark"] .i-moon, html[data-theme="auto"] .i-moon { display: block; }
html[data-theme="light"] .i-moon { display: none; }
html[data-theme="light"] .i-sun { display: block; }
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] .i-sun { display: block; }
  html[data-theme="auto"] .i-moon { display: none; }
}

/* ------------------------------------------------------------------ табы */

.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 14px 10px;
  display: flex;
  gap: 4px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  font-size: 15px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { background: var(--accent); color: var(--accent-text); }

.tab__count {
  min-width: 18px;
  padding: 0 5px;
  height: 18px;
  border-radius: 9px;
  background: color-mix(in srgb, currentColor 18%, transparent);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ------------------------------------------------------------- контейнер */

.view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 18px 90px;
}

/* Сетка расписания шире остальных видов: семь колонок должны помещаться
   на десктопе целиком, без горизонтальной прокрутки. */
.view--wide { max-width: 1440px; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
}
.section-title h1 {
  font-size: 23px;
  letter-spacing: -.02em;
  margin: 0;
  font-weight: 680;
}
.section-title .sub { color: var(--muted); font-size: 15px; }

/* -------------------------------------------------------------- карточки */

.lessons { display: flex; flex-direction: column; gap: 10px; }

.lesson {
  --h: 250;
  position: relative;
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 14px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.lesson::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: hsl(var(--h) var(--tint-s) var(--stripe-l));
}
.lesson:hover { border-color: var(--border-strong); }

.lesson.is-past { opacity: .5; }
.lesson.is-now {
  border-color: hsl(var(--h) var(--tint-s) var(--stripe-l));
  box-shadow: 0 0 0 1px hsl(var(--h) var(--tint-s) var(--stripe-l) / .35), var(--shadow);
}

.lesson__time {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-left: 2px;
}
.lesson__start { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.lesson__end { font-variant-numeric: tabular-nums; color: var(--faint); font-size: 14px; }
.lesson__slot { margin-top: 4px; font-size: 12px; color: var(--faint); }

/* Начало и конец пары связаны вертикальной линией с точками на концах —
   так пара читается как промежуток, а не как два отдельных числа. */
.lesson__range {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 11px;
}
.lesson__range::before {
  content: "";
  position: absolute;
  left: 2.5px;
  top: 9px;
  bottom: 8px;
  width: 1.5px;
  border-radius: 1px;
  background: hsl(var(--h) var(--tint-s) var(--stripe-l));
  opacity: .45;
}
.lesson__range .lesson__start, .lesson__range .lesson__end { position: relative; }
.lesson__range .lesson__start::before, .lesson__range .lesson__end::before {
  content: "";
  position: absolute;
  left: -11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: hsl(var(--h) var(--tint-s) var(--stripe-l));
}
.lesson__range .lesson__start::before { top: 6px; }
.lesson__range .lesson__end::before { top: 5px; opacity: .5; }

/* ----------------------------------------------------------------- окно */

.gap {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 14px;
  align-items: center;
  margin: 8px 0;
  padding: 12px 16px 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.gap__span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 2px;
  font-variant-numeric: tabular-nums;
}
.gap__from { font-size: 14.5px; font-weight: 600; color: var(--muted); }
.gap__to { font-size: 13.5px; color: var(--faint); }
.gap__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gap__title { font-weight: 600; font-size: 15px; color: var(--text); }
.gap__sub { font-size: 13.5px; color: var(--muted); }

.lesson__body { min-width: 0; }

.lesson__subject {
  font-weight: 600;
  font-size: 16.5px;
  letter-spacing: -.01em;
  margin: 0 0 6px;
  line-height: 1.3;
}

.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; stroke-width: 2; }
.chip--room { background: hsl(var(--h) var(--tint-s) var(--chip-l)); color: hsl(var(--h) 45% var(--stripe-l)); }
html[data-theme="light"] .chip--room, :root .chip--room { color: hsl(var(--h) 60% 32%); }
html[data-theme="dark"] .chip--room { color: hsl(var(--h) 55% 80%); }
@media (prefers-color-scheme: dark) { html[data-theme="auto"] .chip--room { color: hsl(var(--h) 55% 80%); } }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 7px;
  letter-spacing: .01em;
}
.badge--time { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge--exam { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.badge--period { background: var(--surface-2); color: var(--muted); }
.badge--kind { background: var(--accent-soft); color: var(--accent); }
.badge--now { background: var(--ok); color: #fff; }

.variants { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.variant {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.variant__label {
  font-weight: 650;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}

.progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: color-mix(in srgb, var(--ok) 20%, transparent);
}
.progress__bar { height: 100%; background: var(--ok); transition: width 30s linear; }

/* ------------------------------------------------------------- домашка */

.hw {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 9px 11px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color .15s;
}
.hw:hover { border-color: var(--border-strong); }
.hw__icon { color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.hw__icon svg { width: 15px; height: 15px; }
.hw__body { min-width: 0; flex: 1; }
.hw__text { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.hw__meta { font-size: 12.5px; color: var(--faint); margin-top: 3px; }
.hw.is-done .hw__text { text-decoration: line-through; color: var(--faint); }

.hw-check {
  appearance: none;
  width: 17px; height: 17px;
  margin: 1px 0 0;
  border: 1.6px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background .15s, border-color .15s;
}
.hw-check:checked { background: var(--ok); border-color: var(--ok); }
.hw-check:checked::after {
  content: "";
  width: 9px; height: 5px;
  border: 2px solid #fff;
  border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* --------------------------------------------------------------- неделя */

.weeknav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.weeknav__title { font-weight: 640; font-size: 16px; letter-spacing: -.01em; }
.weeknav__range { color: var(--muted); font-size: 14.5px; }

.btn {
  appearance: none;
  font: inherit;
  font-size: 14.5px;
  font-weight: 550;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }
.btn--primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }
.btn--icon { padding: 7px 10px; display: grid; place-items: center; }
.btn--icon svg { width: 16px; height: 16px; }

.day { display: flex; flex-direction: column; gap: 9px; }
.day__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 2px;
}
.day__name { font-weight: 640; font-size: 15.5px; }
.day__date { color: var(--faint); font-size: 14px; }
.day.is-today .day__name { color: var(--accent); }
.day.is-today .day__name::after {
  content: "сегодня";
  margin-left: 7px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 5px;
  vertical-align: 1px;
}

/* Прошедший день в ленте домашки приглушён: он есть, но не спорит
   за внимание с ближайшим заданием. */
.day.is-past-day { opacity: .62; }
.day.is-past-day:hover { opacity: 1; }

/* Лента домашки: день — одно окошко, задания внутри идут строками по порядку
   пар и разделены волосяной линией. Отдельные карточки на каждое задание
   дробили день на куски, а спрашивают обычно «что задано на вторник», а не
   про конкретную пару. */
.day--box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px 6px;
  gap: 2px;
}
.day--box .day__head { padding: 0 0 2px; }
.day--box .lessons { gap: 0; }
.day--box .lesson {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 11px 0 11px 12px;
}
.day--box .lesson:hover { border-color: transparent; }
.day--box .lesson + .lesson { border-top: 1px solid var(--border); }
/* Цветная метка предмета не должна упираться в края строки. */
.day--box .lesson::before { top: 10px; bottom: 10px; border-radius: 2px; }

/* День без домашки: ответ «ничего не задано» нужен, но шуметь не должен. */
.day__nothing {
  color: var(--faint);
  font-size: 14px;
  padding: 2px 2px 2px;
}

/* ---------------------------------------------------------- лента дней */

.daybar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.daybar__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.daystrip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.daystrip::-webkit-scrollbar { display: none; }

.daystrip__day {
  appearance: none;
  font: inherit;
  flex: 1 0 auto;
  min-width: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 6px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.daystrip__day:hover { border-color: var(--border-strong); }
.daystrip__wd { font-size: 12px; color: var(--muted); }
.daystrip__num { font-size: 17px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
.daystrip__dots { display: flex; gap: 2px; height: 4px; margin-top: 3px; }
.daystrip__dot { width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }

/* Пустой день приглушён, но остаётся нажимаемым: «пар нет» — тоже ответ. */
.daystrip__day.is-empty { background: transparent; border-style: dashed; color: var(--faint); }
.daystrip__day.is-empty .daystrip__num { font-weight: 550; }

/* Сегодняшний день помечен даже когда открыт другой. */
.daystrip__day.is-today { border-color: var(--accent); border-style: solid; }
.daystrip__day.is-today .daystrip__wd { color: var(--accent); font-weight: 700; }

.daystrip__day.is-active { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.daystrip__day.is-active .daystrip__wd { color: inherit; opacity: .8; }
.daystrip__day.is-active .daystrip__dot { background: currentColor; opacity: .75; }

/* Стрелки недель — часть самой ленты: «назад» слева от понедельника,
   «вперёд» справа от воскресенья. Не растягиваются и не сжимаются,
   чтобы узкая лента прокручивалась, а не ломалась. */
.daystrip__nav {
  flex: 0 0 auto;
  align-self: stretch;
  min-width: 30px;
  padding: 0 6px;
}
.daystrip__nav svg { width: 15px; height: 15px; }

/* Кнопка выбора: день из календаря или неделя из списка. Внутри две строки —
   название и диапазон дат, как в прежней надписи над лентой. */
.pickbtn {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-align: left;
  min-width: 0;
}
.pickbtn svg { width: 16px; height: 16px; align-self: center; flex: 0 0 auto; }
.pickbtn__range { color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------- календарь */

.cal__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.cal__title { font-weight: 640; font-size: 16px; flex: 1; text-align: center; }

.cal__wd, .cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal__wd { margin-bottom: 4px; }
.cal__wd span { text-align: center; font-size: 12px; color: var(--faint); }

.cal__day {
  appearance: none;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 1 / 1;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 0;
}
.cal__day .cal__dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

/* День с парами — нажимаемый и на подложке. День без пар в расписании есть,
   но пуст: остаётся нажимаемым, только без точки. */
button.cal__day { cursor: pointer; background: var(--surface-2); border-color: var(--border); }
button.cal__day:hover { border-color: var(--border-strong); }

/* Дни вне опубликованного расписания выбрать нельзя — они приглушены и не кнопки. */
.cal__day.is-off { color: var(--faint); opacity: .45; }
.cal__day.is-blank { visibility: hidden; }

.cal__day.is-today { border-color: var(--accent); }
.cal__day.is-active { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.cal__day.is-active .cal__dot { background: currentColor; }

/* ------------------------------------------------------- лента домашки */

/* Переключатель прошедших заданий. Подпись и сам переключатель — одна кнопка,
   попасть по ней пальцем легко. */
.hwbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.switch {
  appearance: none;
  font: inherit;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.switch__track {
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  flex: 0 0 auto;
  transition: background .15s;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform .15s;
}
.switch.is-on { color: var(--accent); border-color: var(--accent); }
.switch.is-on .switch__track { background: var(--accent); }
.switch.is-on .switch__track::after { transform: translateX(12px); }

/* ------------------------------------------------------- сетка недели */

.grid-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.grid { border-collapse: separate; border-spacing: 0; width: 100%; }
.grid th, .grid td {
  padding: 0;
  margin: 0;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.grid tr:last-child th, .grid tr:last-child td { border-bottom: 0; }
.grid th:last-child, .grid td:last-child { border-right: 0; }

/* Колонка времени остаётся на месте, когда сетка прокручивается вбок.
   Содержимое по центру: узкая колонка из трёх коротких строк читается
   как столбик, а прижатая к левому краю — как обрывок соседней клетки. */
.grid__corner, .grid__time {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 92px;
  min-width: 92px;
  background: var(--surface);
  border-right: 1px solid var(--border-strong);
  text-align: center;
  font-weight: inherit;
  padding: 12px 10px 13px;
}
.grid__slotnum { display: block; font-size: 13px; color: var(--faint); margin-bottom: 3px; }
.grid__from { display: block; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.grid__to { display: block; font-size: 14px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* position: relative — опора для кнопки «+ДЗ», она лежит в клетке-ячейке
   рядом с кнопкой клетки, а не внутри неё.
   height: 1px — приём для таблиц: он не сжимает ячейку (строка всё равно
   растягивается по самой высокой), но даёт кнопке клетки опору для height: 100%.
   Без этого цветной фон занимал только высоту своего текста, и в высокой
   строке под ним оставалась бесцветная полоса — цвета в сетке выглядели
   съехавшими и не совпадали с карточкой того же предмета в дне. */
.grid__day { min-width: 168px; position: relative; height: 1px; }
.grid__day.is-today { background: var(--accent-soft); }

.dayhead {
  appearance: none;
  font: inherit;
  border: 0;
  background: transparent;
  color: inherit;
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px 12px;
  cursor: pointer;
}
.dayhead__wd { display: block; font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.dayhead__date { display: block; font-size: 13.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.grid__day.is-today .dayhead__wd { color: var(--accent); }

.cell {
  --h: 250;
  appearance: none;
  font: inherit;
  border: 0;
  background: transparent;
  color: inherit;
  position: relative;
  display: block;
  width: 100%;
  min-height: 86px;
  /* Заполняем ячейку целиком: фон предмета должен покрывать её всю. */
  height: 100%;
  text-align: left;
  padding: 12px 14px 13px 16px;
  cursor: pointer;
  transition: box-shadow .15s, background .15s;
}
.cell--empty:hover { background: var(--surface-2); }
/* Нижнее поле шире обычного: под ним стоит кнопка «+ДЗ», и текст клетки
   не должен под неё заезжать. */
.cell--filled { background: hsl(var(--h) var(--tint-s) var(--tint-l)); padding-bottom: 40px; }
.cell--filled::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: hsl(var(--h) var(--tint-s) var(--stripe-l));
}
.cell--filled:hover { box-shadow: inset 0 0 0 1px hsl(var(--h) var(--tint-s) var(--stripe-l)); }

.cell__subject {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.cell__meta { display: block; font-size: 13.5px; line-height: 1.35; color: var(--muted); margin-top: 5px; }
.cell.has-hw .cell__subject { padding-right: 22px; }

/* В сетке домашка только помечена — читать и править её нужно в дне. */
.cell__hw {
  position: absolute;
  top: 9px;
  right: 9px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Запись домашки прямо из сетки. Кнопка соседствует с кнопкой клетки,
   поэтому нажатие на неё не открывает заодно день. Размер — под палец. */
.cell__add {
  position: absolute;
  right: 9px;
  bottom: 9px;
  appearance: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.cell__add:hover { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.cell__add:active { transform: scale(.95); }

.grid__hint { margin: 10px 2px 0; font-size: 13.5px; color: var(--faint); }

/* ------------------------------------------------------------ состояния */

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty__emoji { font-size: 34px; display: block; margin-bottom: 10px; }
.empty__title { font-weight: 600; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14.5px;
  margin-bottom: 14px;
}

.skeleton-wrap { display: flex; flex-direction: column; gap: 10px; }
.skeleton {
  height: 84px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* --------------------------------------------------------- статус-строка */

.statusbar {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 28px);
  white-space: nowrap;
  overflow: hidden;
}
.statusbar a { color: var(--accent); text-decoration: none; white-space: nowrap; }
@media (max-width: 420px) { .statusbar a { display: none; } }
.statusbar a:hover { text-decoration: underline; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.dot.is-stale { background: var(--warn); }
.dot.is-error { background: var(--danger); }
.dot.is-loading { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------------------------------------------------------------- диалог */

.dialog {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  width: min(520px, calc(100vw - 32px));
  max-height: 90vh;
}
.dialog::backdrop { background: rgba(10, 11, 16, .45); backdrop-filter: blur(3px); }
.dialog__form { padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.dialog__head h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.dialog__sub { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.dialog__foot { display: flex; gap: 8px; align-items: center; }
.dialog__error { margin: 0; color: var(--danger); font-size: 14px; }
.spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.field__label { font-size: 13.5px; color: var(--muted); font-weight: 550; }
/* Пояснение под полем: например, что будущих пар по предмету не осталось. */
.field__note { font-size: 12.5px; color: var(--warn); }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }

textarea, select, input[type="text"], input[type="password"] {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  resize: vertical;
  width: 100%;
}

/* Список выбора: собственная стрелка, чтобы поле не выпадало из темы. */
select {
  appearance: none;
  resize: none;
  cursor: pointer;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
textarea:focus, input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; border-color: transparent; }

/* ----------------------------------------------------------------- тост */

.toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%) translateY(8px);
  z-index: 40;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14.5px;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- поиск */

.searchbar {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 14px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.searchbar__icon {
  position: absolute;
  left: 25px;
  top: calc(50% - 5px);
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--faint);
  pointer-events: none;
}
.searchbar input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px 7px 33px;
}
.searchbar input::placeholder { color: var(--faint); }

/* Результаты поиска — одной колонкой: порядок «ближайшие сверху» должен читаться
   сверху вниз, а не зигзагом по сетке. */
.results { display: flex; flex-direction: column; gap: 14px; }

.ghost-btn--sm { width: 30px; height: 30px; border-radius: 8px; }
.ghost-btn--sm svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------ подгруппы */

/* Признак того, что показана только выбранная подгруппа, и способ раскрыть обе. */
.variants__note {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--faint);
}

.linkish {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

.choices { display: flex; flex-direction: column; gap: 8px; }

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.choice:hover { border-color: var(--border-strong); }
.choice.is-active { border-color: var(--accent); background: var(--accent-soft); }
.choice > span:first-child { min-width: 0; }
.choice__title { display: block; font-weight: 600; font-size: 15px; }
.choice__sub { display: block; font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.choice__mark {
  margin-left: auto;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.6px solid var(--border-strong);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.choice.is-active .choice__mark { border-color: var(--accent); background: var(--accent); }
.choice.is-active .choice__mark::after {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-text);
}

/* -------------------------------------------------------- вид предмета */

.subject-link {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.subject-link:hover { color: var(--accent); text-decoration: underline; }

.btn--back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.btn--back svg { width: 15px; height: 15px; }

.subject-hero {
  --h: 250;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 14px 18px;
  margin-bottom: 16px;
}
.subject-hero::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: hsl(var(--h) var(--tint-s) var(--stripe-l));
}
.subject-hero h1 { margin: 0 0 8px; font-size: 21px; letter-spacing: -.02em; font-weight: 680; }

.lesson__date { font-size: 12.5px; color: var(--faint); margin-bottom: 2px; white-space: nowrap; }

/* Ближайшая пара по предмету — единственная выделенная в длинном списке. */
.lesson.is-next {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent), var(--shadow);
}

.hw-list { display: flex; flex-direction: column; }

/* --------------------------------------------------------------- мобилка */

@media (max-width: 560px) {
  .view { padding: 16px 12px 96px; }
  .lesson { grid-template-columns: 62px 1fr; gap: 10px; padding: 12px 13px 12px 12px; }
  .lesson__start { font-size: 16px; }
  .gap { grid-template-columns: 62px 1fr; gap: 10px; padding: 11px 13px 11px 12px; }
  .grid__corner, .grid__time { width: 80px; min-width: 80px; padding: 11px 6px 12px; }
  .grid__day { min-width: 158px; }
  .cell { padding: 11px 12px 12px 13px; }
  .cell--filled { padding-bottom: 40px; }
  .dayhead { padding: 10px 12px 11px; }
  .daystrip__day { min-width: 44px; }
  .section-title { flex-direction: column; gap: 2px; }
  .searchbar { padding: 0 12px 10px; }
  .searchbar__icon { left: 23px; }
  .subject-hero h1 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
