:root {
  color-scheme: light;
  --bg: #f3f2ef;
  --surface: #fffefa;
  --surface-2: #f8f7f3;
  --text: #242522;
  --muted: #777970;
  --line: #e3e1da;
  --blue: #587fa0;
  --blue-hover: #edf2f7;
  --blue-soft: #f7eee8;
  --green: #39775c;
  --red: #b84d43;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

/* ===== Верхняя панель ===== */
.topbar {
  height: 62px;
  padding-inline: max(5vw, 22px);
  background: rgba(255, 254, 250, .96);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.25px;
}

.brand-mark {
  width: 29px;
  height: 29px;
  border-radius: 8px;
  border: 1px solid #dedbd2;
  background: #efede7;
  display: grid;
  place-items: center;
  font: 600 10px var(--mono);
  color: #383a34;
}

.brand-blue,
.blue-period {
  color: var(--blue);
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  font: 10px var(--mono);
  color: var(--muted);
  letter-spacing: .015em;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.top-date {
  margin-left: 12px;
  color: var(--muted);
}

/* ===== Меню группы ===== */
.group-menu-toggle {
  width: 38px;
  height: 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.group-menu-toggle span {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: #252a34;
}

.group-menu-toggle:hover {
  background: #f7f8fa;
}

.group-menu {
  position: absolute;
  z-index: 30;
  right: 24px;
  top: calc(100% + 8px);
  width: min(340px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(20, 25, 35, .12);
}

.group-menu[hidden] {
  display: none;
}

.group-menu-heading {
  color: #20242d;
  font-size: 16px;
  font-weight: 700;
}

.group-menu-current {
  margin: 5px 0 17px;
  color: #647084;
  font-size: 13px;
}

.group-menu label {
  display: block;
  margin-bottom: 7px;
  color: #7b8493;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}

.group-menu-search-line {
  width: 100%;
}

.group-menu-search-line input {
  width: 100%;
  min-width: 0;
}

.group-menu-hint {
  margin: 12px 0 0;
  color: #8992a0;
  font-size: 12px;
  line-height: 1.5;
}

.group-menu .suggestions:not(:empty) {
  margin-top: 5px;
}

/* ===== Основной контент ===== */
.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 38px 32px 28px;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 7px 0 28px;
}

.kicker,
.micro-label {
  margin: 0 0 8px;
  color: #89877e;
  font: 10px var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0;
  font-size: clamp(29px, 3.5vw, 38px);
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -1.45px;
}

.intro-sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.intro-note {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font: 10px var(--mono);
}

.mode-bar {
  height: 54px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 30px;
  overflow: hidden;
}

.mode-indicator {
  display: flex;
  gap: 22px;
  align-items: center;
}

.mode-pill {
  font: 550 12px var(--sans);
  color: #8b8b82;
  transition: color .2s;
  position: relative;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mode-pill:hover {
  color: #6f7784;
}

.mode-pill.active {
  color: var(--text);
}

.mode-pill.active:after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--blue);
}

.swipe-hint {
  color: #9aa1ac;
  font: 9px var(--mono);
  white-space: nowrap;
}

.swipe-hint span {
  color: var(--muted);
  font-size: 14px;
  margin-left: 5px;
}

/* ===== Анимации смены вкладок ===== */
.view-stack {
  position: relative;
  overflow: hidden;
  min-height: 60vh;
  touch-action: pan-y;
}

.view {
  animation: none;
  touch-action: pan-y;
}

.view[hidden] {
  display: none;
}

.view.slide-out-left { animation: slideOutLeft .28s ease forwards; }
.view.slide-in-right { animation: slideInRight .28s ease forwards; }
.view.slide-out-right { animation: slideOutRight .28s ease forwards; }
.view.slide-in-left { animation: slideInLeft .28s ease forwards; }

@keyframes slideOutLeft { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-30%); opacity: 0; } }
@keyframes slideInRight { from { transform: translateX(30%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(30%); opacity: 0; } }
@keyframes slideInLeft { from { transform: translateX(-30%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Поиск и заголовки ===== */
.view-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 22px;
}

.view-heading h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.7px;
}

.view-tag {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 8px;
  color: #777970;
  font: 9px var(--mono);
  white-space: nowrap;
  background: var(--surface);
}

.search-wrap {
  position: relative;
  margin: 0 0 25px;
}

.search-wrap > label,
.modal label {
  display: block;
  margin-bottom: 7px;
  color: #85847b;
  font: 9px var(--mono);
  letter-spacing: .075em;
  text-transform: uppercase;
}

.search-line {
  height: 47px;
  border: 1px solid #dedcd4;
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}

.search-line:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88, 127, 160, .15);
}

.search-icon {
  font-size: 19px;
  color: #8a897f;
}

.search-line input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 13px var(--sans);
}

.search-line input::placeholder {
  color: #aaa99f;
}

.search-clear {
  border: 0;
  background: transparent;
  color: #486086;
  font-size: 19px;
  cursor: pointer;
}

.current-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 23px 0 13px;
}

.current-line h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.45px;
}

.outline-button,
.back-link {
  border: 1px solid #dedcd4;
  border-radius: 10px;
  background: var(--surface);
  color: #4f514a;
  padding: 8px 12px;
  font: 11px var(--sans);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.outline-button:hover,
.back-link:hover {
  background: #f1efe9;
  border-color: #cbc7bc;
}

/* ===== Кнопки дней недели и фильтры ===== */
.schedule-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.schedule-toolbar h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.35px;
}

.schedule-toolbar .kicker {
  margin-bottom: 4px;
}

.schedule-toolbar-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.schedule-toolbar-title > h3 {
  flex: none;
}

.group-title-inline {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--blue);
  font-weight: 600;
}

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

.day-button {
  min-width: 42px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #efede7;
  color: #777970;
  font: 500 10px var(--sans);
  letter-spacing: .01em;
  cursor: pointer;
  position: relative;
  transition: background .16s, color .16s, border-color .16s, transform .16s;
}

.day-button:hover {
  border-color: #dbe4ec;
  background: var(--blue-hover);
  color: var(--blue);
}

.day-button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fffefa;
  box-shadow: 0 2px 5px rgba(88, 127, 160, .25);
}

.day-button:focus-visible,
.filter-row .filter:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.day-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 2px rgba(88, 127, 160, .15);
  pointer-events: none;
  transition: background .16s, box-shadow .16s;
}

.day-button.active .day-dot {
  background: #fffefa;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .3);
}

.day-caption {
  margin: 10px 0;
  color: #89877e;
  font: 9px var(--mono);
  letter-spacing: .04em;
}

/* Фильтры (ВСЕ, ИЗБРАННОЕ, НЕДАВНИЕ) */
.filter-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.filter-row .filter {
  min-width: 0;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #efede7;
  color: #777970;
  font: 500 10px var(--sans);
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s, transform .16s;
}

.filter-row .filter:hover {
  border-color: #dbe4ec;
  background: var(--blue-hover);
  color: var(--blue);
}

.filter-row .filter.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fffefa;
  box-shadow: 0 2px 5px rgba(88, 127, 160, .25);
}

.filter-row .filter:active {
  transform: translateY(1px);
}

.filter-row .result-count {
  margin-left: auto;
  color: #89877e;
  font: 9px var(--mono);
}

/* ===== Сетка карточек занятий ===== */
.lesson-grid {
  display: grid;
  gap: 0;
  border: 1px solid #dedbd5;
  border-radius: 18px;
  background: #fff;
  padding: 6px 16px; /* 👈 Вернул отступы сверху и снизу по 6px, по бокам 16px */
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(35, 32, 28, 0.035);
}

.lesson-card {
  position: relative;
  height: auto;
  min-height: 76px;
  border: 0;
  border-bottom: 1px solid #eeece7;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  transition: background .18s;
}

/* Первая карточка в списке (верхняя) */
.lesson-card:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

/* Последняя карточка в списке (нижняя) */
.lesson-card:last-child {
  border-bottom: 0;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.lesson-card:hover {
  background: #faf9f5;
}

.lesson-card-empty {
  background: #faf9f6;
}

.lesson-card.is-now {
  background: #e1ebf4;
  box-shadow: inset 3px 0 0 var(--blue);
}

.lesson-time {
  padding: 12px 16px;
  border-right: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 0;
}

.lesson-number {
  color: #55564f;
  font: 13px var(--mono);
}

.lesson-clock {
  color: #85847b;
  font: 10px var(--mono);
  white-space: nowrap;
}

.lesson-main {
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}

.lesson-subject {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-teacher {
  color: #686960;
  font: 11px var(--sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-detail {
  color: #929187;
  font: 9px var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-status {
  width: max-content;
  max-width: 100%;
  border: 0;
  border-radius: 3px;
  background: #edf3ed;
  color: #477254;
  padding: 1px 5px;
  font: 9px var(--mono);
}

.lesson-status.distance {
  background: #f5eee8;
  color: var(--blue);
}

.lesson-card-empty .lesson-number { color: #b4bac3; }
.lesson-card-empty .lesson-clock { color: #b4bac3; }
.lesson-card-empty .lesson-subject { color: #9aa1ac; font-weight: 500; }
.lesson-card-empty .lesson-detail { color: #b4bac3; }

/* "Выберите аудиторию" — теперь тоже с внутренними отступами как у сетки */
.lesson-empty, .loading, .empty-box {
  padding: 24px 20px;
  border: 1px solid #dedbd5;
  border-radius: 18px;
  background: var(--surface);
  color: #777970;
  font: 11px var(--mono);
  text-align: center;
  margin: 0; 
  box-shadow: 0 2px 8px rgba(35, 32, 28, 0.035);
}

/* ===== Список преподавателей ===== */
.teacher-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
}

.teacher-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 67px;
  padding: 12px 4px;
  border: 0;
  border-bottom: 1px solid #e7e5de;
  border-radius: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background .16s;
}

.teacher-card:hover {
  background: #f8f7f2;
}

.teacher-card:active {
  transform: translateY(1px);
}

.teacher-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.teacher-avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: #eae8e0;
  object-fit: cover;
  display: block;
}

.teacher-info {
  min-width: 0;
  flex: 1;
}

.teacher-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 650;
}

.teacher-subject {
  display: block;
  margin-top: 3px;
  color: #777970;
  font-size: 10px;
}

.teacher-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: #85847b;
  font: 9px var(--mono);
}

.teacher-status:before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4b8a69;
}

.teacher-status.busy:before {
  background: #bd6257;
}

/* ===== Окно преподавателя и модалки ===== */
.star-button {
  width: 31px;
  height: 31px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #85847b;
  font-size: 17px;
  cursor: pointer;
  flex: none;
  transition: background .15s;
}

.star-button:hover {
  background: #f0eee8;
}

.star-button.active {
  color: var(--blue);
}

.teacher-view {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  display: flex;
  justify-content: center;
  overflow: auto;
  animation: viewIn .18s ease;
}

.teacher-view[hidden] {
  display: none;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.teacher-view-inner {
  width: min(1120px, 100%);
  padding: 38px 32px 42px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.teacher-view-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 14px;
}

.teacher-view-title h2 {
  margin: 0;
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -.8px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.teacher-view-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px;
}

.teacher-view-title .kicker {
  margin-bottom: 6px;
}

.teacher-view-toolbar {
  margin-top: 16px;
  margin-bottom: 6px;
}

.teacher-view-lessons {
  margin-top: 4px;
}

footer {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
  padding: 17px 0;
  border-top: 1px solid var(--line);
  color: #89877e;
  font: 9px var(--mono);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 31, 27, .38);
  backdrop-filter: blur(2px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(420px, 100%);
  padding: 25px;
  border: 1px solid #e1dfd7;
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(30, 29, 24, .15);
}

.modal h2 {
  margin: 12px 0;
  font-size: 27px;
  line-height: 1.05;
  font-weight: 650;
  letter-spacing: -.8px;
}

.modal-input {
  width: 100%;
  height: 44px;
  padding: 0 11px;
  border: 1px solid #dedcd4;
  border-radius: 7px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font: 13px var(--sans);
}

.modal-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88, 127, 160, .15);
}

.primary-button {
  width: 100%;
  height: 43px;
  margin-top: 14px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font: 600 12px var(--sans);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.primary-button:hover {
  background: #4a6c89;
  border-color: #4a6c89;
}

.modal-suggestions {
  position: static;
  margin-top: 4px;
  border-radius: 7px;
}

.modal-error {
  color: var(--red);
  font: 10px var(--mono);
}

/* ===== Тосты и подсказки ===== */
.suggestions {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 230px;
  overflow: auto;
  border: 1px solid #dedcd4;
  border-radius: 0 0 7px 7px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(35, 34, 28, .08);
}

.suggestions:empty {
  display: none;
}

.suggestion {
  display: block;
  width: 100%;
  padding: 10px 13px;
  border: 0;
  border-bottom: 1px solid #efede7;
  background: transparent;
  color: #34362f;
  text-align: left;
  font: 12px var(--sans);
  cursor: pointer;
}

.suggestion:hover {
  background: #f7f5ef;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 50;
  transform: translate(-50%, 15px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border: 1px solid #dedcd4;
  border-radius: 6px;
  background: var(--surface);
  color: #34362f;
  font: 11px var(--mono);
  box-shadow: 0 8px 24px rgba(30, 29, 24, .10);
  transition: .18s;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ===== Адаптивность ===== */
@media (max-width: 680px) {
  .shell { padding: 24px 15px; }
  .topbar { padding-inline: 15px; }
  .top-meta { font-size: 8px; }
  .top-date { display: none; }
  .intro { align-items: flex-start; gap: 10px; padding-bottom: 23px; }
  .intro h1 { font-size: 29px; }
  .intro-note { font-size: 8px; }
  .mode-bar { gap: 10px; height: 54px; margin-bottom: 24px; }
  .mode-indicator { gap: 12px; }
  .mode-pill { font-size: 11px; }
  .swipe-hint { display: none; }
  .view-heading { align-items: center; }
  .view-heading h2 { font-size: 19px; }
  .teacher-grid { grid-template-columns: 1fr; gap: 0; }
  .schedule-toolbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .schedule-toolbar-title { flex-wrap: nowrap; gap: 6px; width: 100%; }
  .schedule-toolbar-title > h3 { font-size: 15px; }
  .group-title-inline { max-width: calc(100% - 130px); }
  .day-switch { width: 100%; }
  .day-button { flex: 1; padding: 7px 3px; }
  .lesson-card { grid-template-columns: 104px minmax(0, 1fr); }
  .lesson-time { padding: 10px 9px; }
  .lesson-main { padding: 9px 11px; }
  .current-line h3 { font-size: 16px; }
  footer { gap: 10px; font-size: 8px; margin-top: 34px; }
  .view { overscroll-behavior-x: contain; }
  .teacher-view-inner { padding: 20px 15px 28px; }
  .teacher-view-title h2 { font-size: 20px; }
  .teacher-view-header { margin-bottom: 8px; }
  .teacher-view-title-row { gap: 10px; }
  .group-menu { right: 12px; }
  .lesson-grid { padding: 6px 10px; border-radius: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}