/* Шрифты лежат у нас, а не у Google: в Telegram внутри РФ так надёжнее и быстрее */
@font-face { font-family: Unbounded; src: url(fonts/unbounded-cyrillic.woff2) format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Unbounded; src: url(fonts/unbounded-latin.woff2) format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: Onest; src: url(fonts/onest-cyrillic.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; src: url(fonts/onest-latin.woff2) format('woff2'); font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2212; }

:root {
  --fog: #EEF1F7;        /* фон */
  --sheet: #FFFFFF;      /* поверхности */
  --ink: #161A33;        /* текст */
  --muted: #6B7191;
  --line: #D5DAE8;
  --ultra: #2F45FF;      /* всё, что нажимается */
  --amber: #FFAE1F;      /* «сейчас» — единственное тёплое пятно */
  --red: #D93A40;
  --teal: #0B8C7E;
  --on-ink: #FFFFFF;

  --display: Unbounded, 'Onest', system-ui, sans-serif;
  --text: Onest, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --spring: cubic-bezier(.2, .9, .25, 1.15);
  --ease: cubic-bezier(.3, .7, .2, 1);

  --safe-top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}
:root[data-theme="dark"] {
  --fog: #0F1226;
  --sheet: #1A1E3D;
  --ink: #EEF0FF;
  --muted: #8E94BA;
  --line: #2C3159;
  --ultra: #8290FF;
  --red: #FF6B70;
  --teal: #3FCDBB;
  --on-ink: #0F1226;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fog); color: var(--ink);
  font: 400 16px/1.4 var(--text);
  padding: var(--safe-top) 0 0;
  max-width: 520px; margin-inline: auto;   /* в Telegram на компьютере окно бывает широким */
  overscroll-behavior-y: none;
  transition: background-color .35s, color .35s;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--ultra); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
a { color: var(--ultra); text-decoration: none; }

/* ── шапка ─────────────────────────────────────────────────────────────── */
.top { display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 20px 6px; }
.group-btn { display: flex; align-items: baseline; gap: 8px; }
.group-num { font: 700 28px/1 var(--display); letter-spacing: -.02em; }
.group-cap { font-size: 13px; color: var(--muted); border-bottom: 1px dashed var(--muted); }
.top-faculty { font-size: 13px; color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 12px; }
/* переключатель темы: кружок, у которого «луна» наезжает на «солнце» */
.theme-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.theme-btn span { position: relative; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); overflow: hidden; transition: transform .5s var(--spring), background-color .35s; }
.theme-btn span::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: var(--fog); top: -5px; left: 18px; transition: left .5s var(--spring), background-color .35s; }
:root[data-theme="dark"] .theme-btn span { transform: rotate(-40deg); }
:root[data-theme="dark"] .theme-btn span::after { left: 7px; }
.theme-btn:active span { transform: scale(.85); }

#view { padding: 0 0 calc(84px + var(--safe-bottom)); min-height: 60vh; }
.pane { padding: 0 20px; }

/* ── полоса недели ─────────────────────────────────────────────────────── */
.strip-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px 2px; }
.strip-month { font-size: 14px; color: var(--muted); }
.strip-nav { display: flex; gap: 4px; }
.strip-nav button { width: 36px; height: 32px; border-radius: 10px; color: var(--ultra); font: 500 18px/1 var(--text); }
.strip-nav button:active { background: var(--line); }
.strip-nav .to-today { width: auto; padding: 0 10px; font-size: 13px; }

.strip { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); margin: 4px 14px 0; }
.strip-thumb {
  position: absolute; top: 0; left: 0; width: calc(100% / 7); height: 100%;
  border-radius: 16px; background: var(--ink);
  transform: translateX(calc(var(--at, 0) * 100%));
  transition: transform .42s var(--spring);
}
.strip button { position: relative; padding: 8px 0 9px; display: grid; justify-items: center; gap: 3px; transition: color .25s; }
.strip .wd { font-size: 12px; color: var(--muted); transition: color .25s; }
.strip .num { font: 600 17px/1.1 var(--display); }
.strip .load { display: flex; gap: 2px; height: 4px; }
.strip .load i { width: 4px; height: 4px; border-radius: 50%; background: var(--line); transition: background .25s; }
.strip button.off .num { color: var(--muted); font-weight: 400; }
.strip button.today .num::after { content: ''; position: absolute; top: 6px; right: calc(50% - 16px); width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.strip button[aria-pressed="true"] { color: var(--on-ink); }
.strip button[aria-pressed="true"] .wd, .strip button[aria-pressed="true"].off .num { color: var(--on-ink); opacity: .7; }
.strip button[aria-pressed="true"] .load i { background: var(--on-ink); opacity: .55; }

/* ── главное: что сейчас ───────────────────────────────────────────────── */
.now { padding: 22px 20px 6px; }
.now-line { font: 600 24px/1.18 var(--display); letter-spacing: -.025em; text-wrap: balance; }
.now-line b { font-weight: 800; font-variant-numeric: tabular-nums; }
.now-sub { margin-top: 8px; color: var(--muted); font-size: 15px; }

/* ── лента дня ─────────────────────────────────────────────────────────── */
.tape { padding: 14px 20px 0; touch-action: pan-y; }
.row { display: grid; grid-template-columns: 52px 18px 1fr; column-gap: 8px; }
.row-time { padding-top: 1px; text-align: right; font: 500 13px/1.35 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.row-time .end { display: block; color: var(--muted); font-weight: 400; }

.rail { position: relative; }
.rail::before {            /* сама линия: серая — прошло, цвет текста — впереди */
  content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; border-radius: 2px;
  background: linear-gradient(var(--amber) 0 0) top / 100% calc(var(--p, 0) * 100%) no-repeat, var(--ink);
  transform-origin: top;
}
.row.past .rail::before { background: var(--line); }
.row.gap .rail::before { background: repeating-linear-gradient(var(--line) 0 4px, transparent 4px 8px); }
.rail::after {             /* узелок в начале пары */
  content: ''; position: absolute; left: 4px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--fog); border: 2px solid var(--ink);
}
.row.past .rail::after { border-color: var(--line); }
.row.live .rail::after { border-color: var(--amber); background: var(--amber); }
.row.gap .rail::after { display: none; }

.now-dot {
  position: absolute; left: 1px; top: calc(var(--p, 0) * 100%); width: 16px; height: 16px; margin-top: -8px;
  border-radius: 50%; background: var(--amber); border: 3px solid var(--fog); z-index: 1;
  transition: top 1s linear;
}
.now-dot::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; background: var(--amber); opacity: .45; animation: ping 2.4s var(--ease) infinite; z-index: -1; }
@keyframes ping { 0% { transform: scale(1); opacity: .45; } 70%, 100% { transform: scale(2.4); opacity: 0; } }

.lesson { padding: 0 0 22px; min-width: 0; }
.lesson-head { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.lesson h3 { font: 600 17px/1.25 var(--text); overflow-wrap: anywhere; }
.lesson-meta { margin-top: 3px; font-size: 14px; color: var(--muted); }
.lesson-edit { margin-top: 5px; font-size: 13px; color: var(--ultra); }
.row.past .lesson { opacity: .5; }
.row.cancelled h3 { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--muted); }

/* табличка на двери аудитории */
.plate {
  flex: none; min-width: 44px; padding: 5px 8px 4px; text-align: center;
  font: 700 14px/1 var(--display); letter-spacing: -.01em;
  color: var(--ink); background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 7px;
}
.plate.teal { color: var(--teal); border-color: var(--teal); background: none; font: 600 12px/1.2 var(--text); padding: 5px 8px; }
.plate.red { color: var(--red); border-color: var(--red); background: none; font: 600 12px/1.2 var(--text); padding: 5px 8px; }

.row.gap .lesson { padding: 0 0 16px; font-size: 13px; color: var(--muted); }
.row.gap .row-time { visibility: hidden; }

/* подсказка про напоминания под лентой — показывается, пока не ответишь */
.nudge { margin: 8px 20px 0; padding: 16px; border: 1.5px solid var(--ink); border-radius: 18px; background: var(--sheet); }
.nudge p { font-weight: 600; text-wrap: balance; }
.nudge small { display: block; margin-top: 4px; font-size: 14px; color: var(--muted); }
.nudge div { display: flex; gap: 8px; margin-top: 14px; }
.nudge button { padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.nudge .yes { background: var(--ink); color: var(--on-ink); }
.nudge .no { color: var(--muted); }

.empty { padding: 36px 20px; }
.empty p { color: var(--muted); margin-top: 6px; }
.empty button { margin-top: 16px; color: var(--ultra); font-weight: 600; }

/* единственная постановочная анимация — первый показ ленты */
.tape.intro .row { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 55ms + 80ms); }
.tape.intro .rail::before { animation: draw .5s var(--ease) both; animation-delay: calc(var(--i) * 55ms + 120ms); }
.tape.intro .now-dot { animation: drop .6s var(--spring) both; animation-delay: .55s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes draw { from { transform: scaleY(0); } }
@keyframes drop { from { transform: scale(0); } }

/* ── неделя ────────────────────────────────────────────────────────────── */
.wk-day { display: block; width: 100%; text-align: left; padding: 16px 0; border-top: 1px solid var(--line); }
.wk-day:first-of-type { border-top: 0; }
.wk-head { display: flex; align-items: baseline; gap: 10px; }
.wk-head .num { font: 700 20px/1 var(--display); }
.wk-head .wd { font-size: 15px; font-weight: 600; }
.wk-head .mode { margin-left: auto; font-size: 13px; color: var(--muted); }
.wk-day.today .wk-head .num { color: var(--ultra); }
.wk-list { margin-top: 10px; display: grid; gap: 7px; }
.wk-item { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: baseline; font-size: 15px; }
.wk-item .t { font: 500 12px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--muted); }
.wk-item .r { font: 600 12px/1 var(--display); }
.wk-item.cancelled .s { text-decoration: line-through; color: var(--muted); }
.wk-none { margin-top: 6px; font-size: 14px; color: var(--muted); }

/* ── поиск ─────────────────────────────────────────────────────────────── */
.find-box { position: sticky; top: 0; z-index: 2; padding: 12px 20px 10px; background: var(--fog); }
.find-box input {
  width: 100%; padding: 13px 16px; font: 500 16px/1.2 var(--text); color: var(--ink);
  background: var(--sheet); border: 1.5px solid var(--line); border-radius: 14px; outline: 0;
  transition: border-color .2s;
}
.find-box input:focus { border-color: var(--ultra); }
.find-box input::placeholder { color: var(--muted); font-weight: 400; }

.h2 { font: 600 15px/1.2 var(--display); letter-spacing: -.01em; margin: 22px 0 10px; }
.h2 small { font: 400 13px/1 var(--text); color: var(--muted); margin-left: 6px; letter-spacing: 0; }

.room-row { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 8px 0; }
.room-row .state { font-size: 14px; color: var(--muted); }
.room-row .state b { color: var(--ink); font-weight: 600; }
.room-row.busy .plate { background: var(--ink); color: var(--on-ink); }

.person { display: block; width: 100%; text-align: left; padding: 11px 0; border-top: 1px solid var(--line); }
.person .name { font-weight: 600; }
.person .what { font-size: 14px; color: var(--muted); margin-top: 1px; }
.person .next { font-size: 13px; margin-top: 3px; color: var(--ultra); }

.hit-date { font: 600 13px/1 var(--display); margin: 20px 0 8px; color: var(--muted); }
.hit { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: start; }
.hit .t { font: 500 12px/1.5 var(--display); font-variant-numeric: tabular-nums; }
.hit .s { font-weight: 600; font-size: 15px; }
.hit .m { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── контакты ──────────────────────────────────────────────────────────── */
.place { padding: 20px 0 4px; }
.place h2 { font: 700 20px/1.2 var(--display); letter-spacing: -.02em; text-wrap: balance; }
.place p { margin-top: 8px; color: var(--muted); }
.place a { display: inline-block; margin-top: 8px; font-weight: 600; }
.contact { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--ink); }
.contact .v { font-weight: 600; overflow-wrap: anywhere; }
.contact .n { font-size: 13px; color: var(--muted); text-align: right; }
.contact .go { color: var(--ultra); font-size: 14px; font-weight: 600; flex: none; }
button.contact { width: 100%; text-align: left; }
.footnote { margin: 24px 0 0; font-size: 13px; color: var(--muted); }

/* ── нижние вкладки ────────────────────────────────────────────────────── */
.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-bottom)); z-index: 5;
  max-width: 496px; margin-inline: auto;
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px;
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 20px;
}
.tabs button { position: relative; z-index: 1; padding: 11px 0; font-size: 14px; font-weight: 600; border-radius: 15px; transition: color .25s; }
.tabs button[aria-current="page"] { color: var(--on-ink); }
.tabs-thumb {
  position: absolute; top: 5px; bottom: 5px; left: 5px; width: calc((100% - 10px) / 4);
  background: var(--ink); border-radius: 15px;
  transform: translateX(calc(var(--at, 0) * 100%)); transition: transform .42s var(--spring);
}

/* ── выбор группы ──────────────────────────────────────────────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 10; }
.sheet-shade { position: absolute; inset: 0; background: #0B0E22; opacity: .5; animation: fade .25s both; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow: auto;
  max-width: 520px; margin-inline: auto;
  padding: 24px 20px calc(24px + var(--safe-bottom)); background: var(--fog);
  border-radius: 26px 26px 0 0; animation: up .45s var(--spring) both;
}
.sheet h2 { font: 700 22px/1.1 var(--display); letter-spacing: -.02em; }
.sheet-wrap.closing .sheet { animation: down .22s var(--ease) both; }
.sheet-wrap.closing .sheet-shade { animation: fade .22s reverse both; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.course { margin-top: 20px; }
.course p { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.course div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.course button { padding: 14px 0 12px; border: 1.5px solid var(--ink); border-radius: 14px; background: var(--sheet); font: 700 18px/1 var(--display); transition: transform .15s; }
.course button:active { transform: scale(.95); }
.course button small { display: block; margin-top: 5px; font: 400 12px/1 var(--text); color: var(--muted); }
.course button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.course button[aria-pressed="true"] small { color: inherit; opacity: .7; }

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