:root {
  --bg: #f2f2f7;
  --bar-bg: rgb(242 242 247 / 0.86);
  --card: #ffffff;
  --text: #000000;
  --muted: #5f5f66;
  --track: #e3e3e9;
  --thumb: #ffffff;
  --accent: #0062cc;
  --on-accent: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bar-bg: rgb(0 0 0 / 0.82);
    --card: #1c1c1e;
    --text: #ffffff;
    --muted: #a1a1a8;
    --track: #1c1c1e;
    --thumb: #48484a;
    --accent: #4da3ff;
    --on-accent: #00172e;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  color: var(--text);
  font: 17px/1.35 -apple-system, "SF Pro", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  touch-action: pan-y pinch-zoom;
}

button {
  min-height: 44px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, color 0.2s, opacity 0.1s;
}

button:active { opacity: 0.6; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }

/* Шапка: остаётся наверху при прокрутке. */
#bar {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 -16px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
}

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
#group, #date-line { color: var(--muted); font-size: 14px; }
/* На узких экранах шрифт чуть меньше, чтобы «30 сентября · нечётная неделя» оставалось в строку. */
#date-line { font-size: clamp(12px, 3.6vw, 14px); }
h1 { font-size: clamp(22px, 7.4vw, 28px); line-height: 1.15; letter-spacing: -0.02em; }
h1::first-letter { text-transform: uppercase; }

#weeks, #days { display: grid; gap: 2px; padding: 3px; border-radius: 12px; background: var(--track); }
#weeks { grid-template-columns: 1fr 1fr; flex: none; }
#days { grid-template-columns: repeat(6, 1fr); margin-top: 10px; }
#weeks button, #days button { position: relative; border-radius: 9px; font-size: 15px; font-weight: 600; }
#weeks button { min-width: 56px; padding: 0 6px; }
#weeks .today::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: calc(50% - 2px);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

#days .today { color: var(--accent); }
#weeks button[aria-pressed="true"], #days button[aria-current="true"] {
  background: var(--thumb);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.14);
}

/* Дни один под другим. */
main { overflow-x: clip; }
section { padding-top: 6px; scroll-margin-top: var(--bar, 130px); }
/* Чтобы и субботу можно было прокрутить наверх: 128px — это подвал и отступ под ним. */
section:last-child {
  min-height: calc(100vh - var(--bar, 130px) - 128px);
  min-height: calc(100dvh - var(--bar, 130px) - 128px);
}

h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 4px 10px; font-size: 20px; letter-spacing: -0.01em; }
.date { color: var(--muted); font-size: 15px; font-weight: 400; }
section.today h2, section.today h2 .date { color: var(--accent); }

.lesson {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  padding: 14px 14px 14px 12px;
  border-radius: 18px;
  background: var(--card);
}

.num { display: grid; flex: none; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--bg); font-size: 15px; font-weight: 600; }
.info { flex: 1; min-width: 0; padding-top: 3px; }
.status { margin-bottom: 4px; color: var(--accent); font-size: 14px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.teacher { margin-top: 3px; color: var(--muted); font-size: 15px; }
.row { display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 2px; margin-top: 10px; color: var(--muted); font-size: 14px; }
.hours { color: var(--text); font-weight: 600; }
.type { margin-left: auto; }
.remote { display: inline-block; margin-top: 8px; padding: 1px 8px; border: 1px solid currentColor; border-radius: 6px; color: var(--muted); font-size: 13px; }

.place { display: flex; align-items: center; min-height: 44px; color: var(--accent); font-size: 14px; text-decoration: none; }
.info .place { margin: 2px 0 -12px; }
.building { margin-top: 10px; font-size: 14px; font-weight: 600; }
.building + .place { margin-top: -8px; }

.progress { height: 4px; margin-top: 12px; overflow: hidden; border-radius: 2px; background: rgb(127 127 127 / 0.35); }
.progress i { display: block; height: 100%; background: currentColor; transition: width 0.6s; }

.lesson.now { background: var(--accent); color: var(--on-accent); }
.lesson.now :is(.status, .teacher, .row, .hours, .remote, .place) { color: inherit; }
.lesson.now .num { background: rgb(127 127 127 / 0.28); }
.lesson.now .place { text-decoration: underline; }

.gap { display: flex; align-items: center; gap: 12px; margin: 0 4px 8px; color: var(--muted); font-size: 13px; }
.gap::before, .gap::after { content: ""; flex: 1; border-top: 1px solid rgb(127 127 127 / 0.35); }

.empty { padding: 20px; border-radius: 18px; background: var(--card); color: var(--muted); text-align: center; }

footer { display: flex; flex-direction: column; align-items: center; margin-top: 16px; }

#to-today {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 2;
  padding: 0 24px;
  transform: translateX(-50%);
  border-radius: 22px;
  background: var(--thumb);
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.25);
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
}

.from-right { animation: from-right 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
.from-left { animation: from-left 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes from-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-28px); } }

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