/* ============================================================
   Расписание ОГУ — стили
   Мобильный первый экран, светлая/тёмная тема, системный шрифт.
   ============================================================ */

:root {
  --bg: #f5f6fa;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, #e8eaff 0%, transparent 60%),
             radial-gradient(900px 500px at 0% 0%, #eaf6ff 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f0f2f9;
  --text: #0f172a;
  --muted: #667085;
  --line: #e6e8f0;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #0f9d58;
  --warn: #b45309;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-md: 0 10px 30px -18px rgba(16, 24, 40, .35), 0 2px 6px rgba(16, 24, 40, .05);
  --radius: 18px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #080b14;
  --bg-grad: radial-gradient(1100px 560px at 90% -10%, #1b2350 0%, transparent 60%),
             radial-gradient(800px 500px at -10% 0%, #10243a 0%, transparent 55%);
  --surface: #121828;
  --surface-2: #1a2236;
  --text: #e9edf9;
  --muted: #98a2b8;
  --line: #222c44;
  --accent: #7c83ff;
  --accent-ink: #0b1020;
  --accent-soft: #1b2350;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 16px 40px -24px rgba(0, 0, 0, .9), 0 2px 8px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------------------------------------------------------- шапка */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand__mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.brand__mark svg { width: 20px; height: 20px; }
.brand__text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.01em;
  display: flex; gap: 6px; align-items: baseline;
  white-space: nowrap;
}
.brand__text small {
  font-weight: 600; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}

.topbar__actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------------------------------------------------------- каркас */
.view {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 16px 24px;
}
.view > * { animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.h1 { font-size: 26px; line-height: 1.2; font-weight: 750; }
.sub { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 6px 0 0; }

/* ---------------------------------------------------------- поиск */
.search {
  position: relative;
  margin: 6px 0 16px;
}
.search__field {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search__field:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow-md);
}
.search__field svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search__field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}
.search__field input::placeholder { color: var(--muted); }
.search__clear {
  border: 0; background: var(--surface-2); color: var(--muted);
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; font-size: 14px;
}

.suggest {
  position: absolute;
  inset: calc(100% + 8px) 0 auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 20;
  max-height: min(62vh, 520px);
  overflow-y: auto;
}
.suggest__group {
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.suggest__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-top: 1px solid transparent;
}
.suggest__item:hover, .suggest__item[aria-selected="true"] {
  background: var(--accent-soft);
}
.suggest__item b { font-weight: 650; }
.suggest__item small { color: var(--muted); margin-left: auto; font-size: 12px; white-space: nowrap; }
.suggest__empty { padding: 16px 14px; color: var(--muted); font-size: 14px; }

.type-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
}
.type-dot--group { background: #4f46e5; }
.type-dot--teacher { background: #0ea5e9; }
.type-dot--room { background: #f59e0b; }

/* ---------------------------------------------------------- чипы и кнопки */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, border-color .15s ease;
}
.chip:active { transform: scale(.96); }
.chip--accent {
  background: var(--accent); border-color: transparent; color: var(--accent-ink);
  font-weight: 600;
}
.chip--ghost { background: transparent; box-shadow: none; }
.chip svg { width: 14px; height: 14px; opacity: .8; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600; font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--wide { width: 100%; }

/* ---------------------------------------------------------- карточки */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin: 0 0 12px;
}
.card--pad0 { padding: 0; overflow: hidden; }

.entity-head {
  display: flex; align-items: flex-start; gap: 12px;
  margin: 4px 0 14px;
}
.entity-head__badge {
  width: 46px; height: 46px; flex: none;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.entity-head__badge svg { width: 22px; height: 22px; }
.entity-head h1 { font-size: 21px; line-height: 1.25; font-weight: 720; }
.entity-head .sub { margin-top: 3px; }

.meta-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 10px 0 0;
}

/* ---------------------------------------------------------- переключатель */
.segmented {
  position: sticky;
  top: 58px;
  z-index: 15;
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 14px;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 6px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------- день
   Таймлайн пар: слева время, справа карточка занятия. */
.day-label {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 2px 10px;
}
.day-label h2 { font-size: 15px; font-weight: 700; }
.day-label span { font-size: 13px; color: var(--muted); }

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

.pair {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 12px;
  align-items: stretch;
}
.pair__time {
  padding-top: 12px;
  text-align: right;
}
.pair__time b { display: block; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pair__time span { display: block; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pair__num {
  display: inline-block; margin-bottom: 3px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
}

.lesson {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.lesson::before {
  content: "";
  position: absolute; inset: 0 auto 0 0;
  width: 4px;
  background: var(--kind-color, var(--accent));
}
.lesson--l { --kind-color: #4f46e5; }
.lesson--pr { --kind-color: #0ea5e9; }
.lesson--lb { --kind-color: #10b981; }
.lesson--exam { --kind-color: #ef4444; }
.lesson--credit { --kind-color: #f59e0b; }
.lesson--other { --kind-color: #94a3b8; }

.lesson__title { font-weight: 650; font-size: 15px; line-height: 1.3; }
.lesson__kind {
  font-size: 12px; color: var(--muted); margin-top: 2px;
}
.lesson__links {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px;
}
.link-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  font-size: 12.5px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  border: 0;
  cursor: pointer;
  transition: background .14s ease;
}
.link-pill:hover { background: var(--accent-soft); }
.link-pill svg { width: 13px; height: 13px; opacity: .65; }
.link-pill--room { background: color-mix(in srgb, #f59e0b 14%, var(--surface)); }
.link-pill--teacher { background: color-mix(in srgb, #0ea5e9 14%, var(--surface)); }
.link-pill--group { background: color-mix(in srgb, #4f46e5 12%, var(--surface)); }
.lesson__sub {
  margin-top: 8px; font-size: 12px; color: var(--warn);
  display: flex; align-items: center; gap: 6px;
}

.lesson__note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* пустое состояние */
.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--muted);
}
.empty__icon {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 22px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--muted);
}
.empty__icon svg { width: 30px; height: 30px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------------------------------------------------------- неделя (сетка) */
.week-grid {
  display: grid;
  grid-template-columns: 60px repeat(6, minmax(0, 1fr));
  gap: 6px;
  font-size: 12px;
  grid-auto-rows: minmax(64px, auto);
}
.week-grid__head {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  text-align: center; padding: 4px 0;
}
.week-grid__head--today { color: var(--accent); }
.week-grid__time {
  font-size: 11px; color: var(--muted); text-align: right;
  font-variant-numeric: tabular-nums; padding-top: 6px; line-height: 1.35;
}
.week-grid__time b { display: block; color: var(--text); font-size: 12px; font-weight: 700; }
.week-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 7px;
  min-height: 54px;
  height: 100%;
  font-size: 11.5px;
  line-height: 1.3;
  overflow: hidden;
  cursor: pointer;
}
.week-cell--empty {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  border-color: color-mix(in srgb, var(--line) 55%, transparent);
  cursor: default;
}
.week-cell b { display: block; font-weight: 650; margin-bottom: 2px; }
.week-cell span { color: var(--muted); font-size: 11px; }
.week-cell--today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* ---------------------------------------------------------- инфо-строки */
.info-list { display: grid; gap: 2px; }
.info-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  align-items: start;
}
.info-row:last-child { border-bottom: 0; }
.info-row svg { width: 18px; height: 18px; color: var(--muted); margin-top: 1px; }
.info-row small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.info-row a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
  margin: 22px 2px 10px;
}

/* ---------------------------------------------------------- скелетон */
.skeleton { display: grid; gap: 10px; }
.sk {
  height: 74px;
  border-radius: 16px;
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.15s linear infinite;
}
.sk--sm { height: 48px; }
@keyframes shimmer { to { background-position: -120% 0; } }

/* ---------------------------------------------------------- таббар */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: grid; place-items: center; gap: 3px;
  padding: 6px 0;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 12px;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------- прочее */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  z-index: 60;
  box-shadow: var(--shadow-md);
  animation: rise .2s ease both;
}

.hint {
  display: flex; gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.hint svg { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: 1px; }

.offline-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 650;
  color: var(--warn);
  background: color-mix(in srgb, #f59e0b 16%, var(--surface));
  padding: 4px 9px; border-radius: 8px;
}

@media (min-width: 720px) {
  .view { padding: 14px 24px 40px; }
  .h1 { font-size: 30px; }
  .pair { grid-template-columns: 78px 1fr; }
  .tabbar { max-width: 560px; margin: 0 auto 12px; border-radius: 18px; border: 1px solid var(--line); bottom: 10px; }
  .week-grid { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------- избранное */
.fav-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 14px;
}
.fav-remove {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: grid; place-items: center;
}
.fav-remove:hover { color: #ef4444; border-color: color-mix(in srgb, #ef4444 40%, var(--line)); }
