/* ============================================================
   Расписание МИЭТ — оформление
   ============================================================ */

:root {
  --bg:            #f4f6fb;
  --bg-grad:       radial-gradient(1200px 600px at 15% -10%, #dbe7ff 0%, transparent 60%),
                   radial-gradient(900px 500px at 95% 0%, #e6f7f4 0%, transparent 55%);
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #eef2f7;
  --text:          #101828;
  --text-soft:     #475467;
  --muted:         #7a869a;
  --border:        #e3e8ef;
  --border-strong: #cfd6e0;
  --accent:        #2563eb;
  --accent-ink:    #1d4ed8;
  --accent-soft:   #e8f0fe;
  --accent-contrast:#ffffff;
  --ok:            #0f9d58;
  --ok-soft:       #e6f6ee;
  --warn:          #b45309;
  --warn-soft:     #fdf1e0;
  --danger:        #c0392b;
  --danger-soft:   #fdecea;
  --shadow-sm:     0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-md:     0 4px 12px rgba(16,24,40,.07), 0 2px 4px rgba(16,24,40,.04);
  --shadow-lg:     0 24px 48px -12px rgba(16,24,40,.20);
  --radius:        14px;
  --radius-sm:     10px;
  --radius-lg:     20px;
  --topbar-h:      64px;

  --kind-lek:  #2563eb;  --kind-lek-bg:  #e8f0fe;
  --kind-pr:   #0f9d58;  --kind-pr-bg:   #e6f6ee;
  --kind-lab:  #b45309;  --kind-lab-bg:  #fdf1e0;
  --kind-other:#7c3aed;  --kind-other-bg:#f0eafe;
}

:root:not([data-theme="light"]) {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0a0d14;
    --bg-grad:       radial-gradient(1100px 560px at 12% -12%, #14213d 0%, transparent 62%),
                     radial-gradient(900px 480px at 96% -4%, #10262a 0%, transparent 58%);
    --surface:       #111623;
    --surface-2:     #161c2b;
    --surface-3:     #1c2435;
    --text:          #e7ebf3;
    --text-soft:     #b3bccd;
    --muted:         #8b96ab;
    --border:        #222b3d;
    --border-strong: #313c53;
    --accent:        #6ea8fe;
    --accent-ink:    #9cc4ff;
    --accent-soft:   #17253f;
    --accent-contrast:#0a0d14;
    --ok:            #4ade80;   --ok-soft:    #12291f;
    --warn:          #fbbf24;   --warn-soft:  #2c2110;
    --danger:        #fb7185;   --danger-soft:#2d1419;
    --shadow-sm:     0 1px 2px rgba(0,0,0,.5);
    --shadow-md:     0 6px 16px rgba(0,0,0,.45);
    --shadow-lg:     0 28px 56px -16px rgba(0,0,0,.7);

    --kind-lek:  #6ea8fe;  --kind-lek-bg:  #16243c;
    --kind-pr:   #4ade80;  --kind-pr-bg:   #10281d;
    --kind-lab:  #fbbf24;  --kind-lab-bg:  #2b2010;
    --kind-other:#c4b5fd;  --kind-other-bg:#221b3a;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #0a0d14;
  --bg-grad:       radial-gradient(1100px 560px at 12% -12%, #14213d 0%, transparent 62%),
                   radial-gradient(900px 480px at 96% -4%, #10262a 0%, transparent 58%);
  --surface:       #111623;
  --surface-2:     #161c2b;
  --surface-3:     #1c2435;
  --text:          #e7ebf3;
  --text-soft:     #b3bccd;
  --muted:         #8b96ab;
  --border:        #222b3d;
  --border-strong: #313c53;
  --accent:        #6ea8fe;
  --accent-ink:    #9cc4ff;
  --accent-soft:   #17253f;
  --accent-contrast:#0a0d14;
  --ok:            #4ade80;   --ok-soft:    #12291f;
  --warn:          #fbbf24;   --warn-soft:  #2c2110;
  --danger:        #fb7185;   --danger-soft:#2d1419;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.5);
  --shadow-md:     0 6px 16px rgba(0,0,0,.45);
  --shadow-lg:     0 28px 56px -16px rgba(0,0,0,.7);
  --kind-lek:  #6ea8fe;  --kind-lek-bg:  #16243c;
  --kind-pr:   #4ade80;  --kind-pr-bg:   #10281d;
  --kind-lab:  #fbbf24;  --kind-lab-bg:  #2b2010;
  --kind-other:#c4b5fd;  --kind-other-bg:#221b3a;
}

* { box-sizing: border-box; }

/* display у наших компонентов перебивает встроенный [hidden] — возвращаем ему силу */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "tnum" 0;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
button { font: inherit; color: inherit; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-contrast);
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Липкая шапка не должна накрывать якорь, к которому проматываем */
.section, .card, [id] { scroll-margin-top: calc(var(--topbar-h) + 16px); }

/* ---------- Шапка ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1360px; margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 10px max(20px, env(safe-area-inset-left)) 10px max(20px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 16px;
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #16a394));
  color: #fff; box-shadow: var(--shadow-sm);
}
.brand__mark svg { width: 21px; height: 21px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__text b { font-size: 15px; letter-spacing: -.01em; }
.brand__text small { color: var(--muted); font-size: 11.5px; }

.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }

.week-chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  white-space: nowrap;
}

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface); cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.95); }
.icon-btn.is-busy svg { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Поиск ---------- */

.search { position: relative; flex: 1 1 420px; max-width: 520px; }
.search__field {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 0 12px; height: 42px;
  transition: border-color .15s, box-shadow .15s;
}
.search__field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 16%, transparent);
}
.search__icon { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; color: var(--text);
  font: inherit; outline: none; height: 100%;
}
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search__hint {
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 4px 6px; flex: none;
}
.search__field:focus-within .search__hint { display: none; }

.search__results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: min(460px, 70vh); overflow-y: auto; padding: 6px;
}
.search__group {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 10px 12px 5px;
}
.result {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 11px; border-radius: var(--radius-sm);
  border: 0; background: none; cursor: pointer; text-align: left;
}
.result:hover, .result.is-active { background: var(--surface-3); text-decoration: none; }
.result__icon {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-ink);
}
.result__icon svg { width: 16px; height: 16px; }
.result__body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.result__name { font-weight: 600; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result__meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result__count { font-size: 12px; color: var(--muted); flex: none; }
.search__empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 14px; }


/* ---------- Чип «Сейчас» в шапке ---------- */

.now-chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 38px; padding: 0 13px; border-radius: 999px;
  font-size: 13px; font-weight: 650; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s, background .15s;
}
.now-chip:hover { text-decoration: none; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.now-chip__dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
  animation: beat 2.4s ease-in-out infinite;
}
@keyframes beat { 50% { opacity: .35; } }

/* ---------- Живой блок «сейчас» ---------- */

.live { margin: 26px 0 30px; }
.live__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px;
  padding: 18px 22px; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 0;
  border-left: 4px solid var(--muted);
}
.live__head--live { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 6%, var(--surface)); }
.live__head--soon { border-left-color: var(--accent); }
.live__head--idle { border-left-color: var(--border-strong); }
.live__clock { display: flex; flex-direction: column; flex: none; line-height: 1.2; }
.live__clock b { font-size: 30px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.live__clock span { font-size: 12.5px; color: var(--muted); }
.live__state { flex: 1 1 220px; min-width: 0; }
.live__title { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.live__note { font-size: 13.5px; color: var(--text-soft); margin-top: 2px; }
.live__slot {
  flex: none; font-size: 12px; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; background: var(--surface-3);
}

.live__tiles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
}
.live__tile {
  border: 0; background: var(--surface); padding: 14px 16px; cursor: pointer;
  text-align: left; display: flex; flex-direction: column; gap: 2px;
  transition: background .15s;
}
.live__tile:hover { background: var(--surface-3); }
.live__tile b { font-size: 23px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.live__tile span { font-size: 12px; color: var(--muted); line-height: 1.3; }
.live__tile--ok b { color: var(--ok); }

/* ---------- Панель «сейчас» ---------- */

.now-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.now-col { display: flex; flex-direction: column; min-width: 0; }
.now-col__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px;
}
.now-col__head h3 { font-size: 15px; }
.now-col__head .badge { margin-left: auto; }
.now-col__filter { padding: 0 18px 12px; }
.now-col__filter input {
  width: 100%; padding: 9px 12px; border-radius: 10px; font: inherit;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none;
}
.now-col__filter input:focus { border-color: var(--accent); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 16%, transparent); }
.now-col__body { padding: 0 12px 14px; overflow-y: auto; max-height: 560px; }

.where { padding: 9px 8px; border-radius: var(--radius-sm); }
.where:hover { background: var(--surface-2); }
.where + .where { border-top: 1px solid var(--border); }
.where__name { display: block; font-weight: 620; font-size: 14px; color: var(--text); }
.where__name:hover { color: var(--accent-ink); }
.where__places { display: grid; gap: 4px; margin-top: 5px; }
.where__place { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12.5px; }
.where__subject { color: var(--text-soft); }
.where__groups { color: var(--muted); }

.free-group + .free-group { margin-top: 12px; }
.free-group__head {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 0 0 7px 2px;
}
.free-group__head small { font-weight: 600; opacity: .8; }
.chip--sm { padding: 5px 10px; font-size: 12.5px; }

.hint {
  font-size: 13px; color: var(--text-soft); margin-bottom: 12px;
  padding: 9px 13px; border-radius: var(--radius-sm);
  background: var(--surface-3); border: 1px solid var(--border);
}
.empty-inline { padding: 18px 12px; color: var(--muted); font-size: 13.5px; text-align: center; }

.picker { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.other-time { margin-top: 16px; }
.other-time > summary { font-size: 13.5px; }

.next-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.next-row .next { margin-bottom: 0; }
.dot { color: var(--muted); margin: 0 6px; }

.tabs.tabs--scroll {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs.tabs--scroll::-webkit-scrollbar { display: none; }
.tabs.tabs--scroll .tab { flex: none; }

/* ---------- Каркас страницы ---------- */

.view { flex: 1; max-width: 1360px; width: 100%; margin: 0 auto; padding: 26px 20px 60px; }
.view:focus { outline: none; }

.footer { border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.footer__inner {
  max-width: 1360px; margin: 0 auto; padding: 16px 20px;
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: baseline;
  font-size: 12.5px; color: var(--muted);
}
.footer__support { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.footer__dot { opacity: .5; }
.footer__sync { margin-left: auto; }

@media (max-width: 560px) {
  .footer__inner { flex-direction: column; gap: 6px; }
  .footer__sync { margin-left: 0; }
}

/* ---------- Главная ---------- */

.hero { text-align: center; padding: 40px 0 30px; }
.hero h1 { font-size: clamp(28px, 5vw, 42px); letter-spacing: -.03em; }
.hero p { color: var(--text-soft); font-size: clamp(15px, 2vw, 17px); max-width: 620px; margin: 12px auto 0; }
.hero__semester {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}
.hero__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 30px 0 34px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }

.section { margin-top: 34px; }
.section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section__head h2 { font-size: 19px; }
.section__head p { margin: 0; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; flex-wrap: wrap; }
.tab {
  border: 0; background: none; padding: 8px 14px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--text-soft); white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.chip:active { transform: scale(.97); }
.chip small { color: var(--muted); font-weight: 500; }
.chip:hover small { color: inherit; opacity: .75; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card--pad { padding: 18px 20px; }

.browse { display: grid; gap: 10px; }
.browse__group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.browse__group > summary {
  padding: 13px 18px; cursor: pointer; font-weight: 650; font-size: 14.5px;
  display: flex; align-items: center; gap: 10px; list-style: none;
}
.browse__group > summary::-webkit-details-marker { display: none; }
.browse__group > summary::after {
  content: ""; width: 7px; height: 7px; margin-left: auto; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .18s;
}
.browse__group[open] > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.browse__group > summary:hover { background: var(--surface-2); }
.browse__body { padding: 4px 18px 18px; }
.browse__count { color: var(--muted); font-weight: 500; font-size: 12.5px; }

.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.list__item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}
.list__item:hover { background: var(--surface-3); text-decoration: none; }
.list__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__item small { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }

/* ---------- Страница расписания ---------- */

.page-head { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; margin-bottom: 20px; }
.page-head__main { flex: 1 1 320px; min-width: 0; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent-ink); }
.page-head h1 { font-size: clamp(23px, 3.6vw, 31px); letter-spacing: -.025em; overflow-wrap: anywhere; }
.page-head__meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-soft); border: 1px solid var(--border);
}
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.badge--ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 18px; position: sticky; top: calc(var(--topbar-h) + 6px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); padding: 8px 0;
}
.controls__spacer { flex: 1; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 20px; align-items: start; }
@media (max-width: 1080px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.next {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  padding: 14px 18px; margin-bottom: 16px;
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
}
.next--live { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.next__label {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-ink);
}
.next--live .next__label { color: var(--ok); }
.next__title { font-weight: 650; font-size: 15px; flex: 1 1 240px; min-width: 0; }
.next__meta { font-size: 13px; color: var(--text-soft); display: flex; flex-wrap: wrap; gap: 5px 12px; align-items: center; }

/* Сетка недели */

.grid-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.grid { display: grid; min-width: 760px; }
.grid__cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; min-height: 74px; }
.grid__cell:nth-child(7n) { border-right: 0; }
.grid__head {
  position: sticky; top: 0; z-index: 5; min-height: 0;
  background: var(--surface-2); padding: 11px 12px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--text-soft);
}
.grid__head--today { color: var(--accent-ink); background: var(--accent-soft); }
.grid__time {
  background: var(--surface-2); font-size: 12px; color: var(--text-soft);
  display: flex; flex-direction: column; gap: 2px; justify-content: center;
  padding: 10px; text-align: center; font-variant-numeric: tabular-nums;
}
.grid__time b { font-size: 13px; color: var(--text); }
.grid__time span { color: var(--muted); }
.grid__cell--today { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.grid__cell--empty { background: repeating-linear-gradient(45deg, transparent, transparent 9px, color-mix(in srgb, var(--border) 45%, transparent) 9px, color-mix(in srgb, var(--border) 45%, transparent) 10px); }

/* Карточка занятия */

.lesson {
  display: block; width: 100%; text-align: left;
  border-radius: var(--radius-sm); padding: 7px 9px; margin-bottom: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--kind-other);
  color: var(--text); font-size: 13px; transition: transform .1s, box-shadow .15s, border-color .15s;
}
.lesson:last-child { margin-bottom: 0; }
.lesson:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--border-strong); }
.lesson--lek { border-left-color: var(--kind-lek); }
.lesson--pr  { border-left-color: var(--kind-pr); }
.lesson--lab { border-left-color: var(--kind-lab); }
.lesson__title {
  font-weight: 620; line-height: 1.3; margin-bottom: 4px; font-size: 12.5px;
  overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto;
}
.lesson__row { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12px; color: var(--text-soft); }
.lesson__row a { color: var(--text-soft); }
.lesson__row a:hover { color: var(--accent-ink); }
.lesson__tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px; background: var(--kind-other-bg); color: var(--kind-other);
}
.lesson__tag--lek { background: var(--kind-lek-bg); color: var(--kind-lek); }
.lesson__tag--pr  { background: var(--kind-pr-bg);  color: var(--kind-pr); }
.lesson__tag--lab { background: var(--kind-lab-bg); color: var(--kind-lab); }
.lesson__week {
  font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  background: var(--surface-3); color: var(--muted); white-space: nowrap;
}
.lesson__room {
  font-weight: 650; color: var(--text); background: var(--surface-3);
  padding: 1px 7px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
a.lesson__room:hover { background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }

/* Список по дням (день / мобильная версия) */

.days { display: grid; gap: 16px; }
.day-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.day-card__head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-weight: 680; font-size: 14.5px;
}
.day-card__head small { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12.5px; }
.day-card--today .day-card__head { background: var(--accent-soft); color: var(--accent-ink); }
.slot { display: flex; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.slot:last-child { border-bottom: 0; }
.slot__time {
  flex: none; width: 62px; font-size: 12.5px; color: var(--text-soft);
  font-variant-numeric: tabular-nums; line-height: 1.4;
}
.slot__time b { display: block; color: var(--text); font-size: 13.5px; }
.slot__time span { color: var(--muted); }
.slot__body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.slot--now { background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* Окно между парами */
.gap { display: flex; align-items: center; gap: 10px; padding: 6px 16px; }
.gap__line { flex: 1; height: 1px; background: var(--border); }
.gap__text {
  flex: none; font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--muted); text-transform: lowercase;
}
.slot--now .slot__time b::after { content: " ●"; color: var(--accent); font-size: 10px; vertical-align: middle; }

/* Боковая колонка */

.side { display: grid; gap: 14px; position: sticky; top: calc(var(--topbar-h) + 60px); }
@media (max-width: 1080px) { .side { position: static; } }
.side__card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.side__head { padding: 13px 16px 9px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.side__body { padding: 0 10px 12px; display: grid; gap: 2px; max-height: 360px; overflow-y: auto; }
.side__row {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  border-radius: 9px; font-size: 13.5px; color: var(--text);
}
.side__row:hover { background: var(--surface-3); text-decoration: none; }
.side__row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__row small { margin-left: auto; flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.side__bar { height: 3px; border-radius: 2px; background: var(--accent); opacity: .35; }

.empty {
  text-align: center; padding: 56px 20px; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

/* ---------- Панель синхронизации ---------- */

.sheet { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(6,10,18,.45); backdrop-filter: blur(2px); animation: fade .2s ease; }
.sheet__panel {
  position: relative; width: min(460px, 100%); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide .22s cubic-bezier(.2,.7,.3,1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.sheet__head h2 { font-size: 17px; }
.sheet__body { padding: 18px; overflow-y: auto; display: grid; gap: 16px; align-content: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; }
.btn--block { width: 100%; }
.btn--ghost { background: none; border-style: dashed; color: var(--text-soft); margin-top: 8px; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.field input, .select {
  padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; outline: none;
}
.select { cursor: pointer; min-width: 150px; height: 42px; padding-right: 30px; }
.field input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 16%, transparent);
}
.field small { color: var(--muted); font-size: 12px; }

.kv { display: grid; gap: 8px; font-size: 13.5px; }
.kv__row { display: flex; gap: 12px; align-items: baseline; }
.kv__row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.kv__row span { color: var(--text-soft); }

.log {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-soft); max-height: 190px; overflow-y: auto; white-space: pre-wrap;
}

.runs { display: grid; gap: 6px; }
.run { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12.5px; }
.run__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.run__dot--ok { background: var(--ok); }
.run__dot--partial { background: var(--warn); }
.run__dot--failed { background: var(--danger); }
.run__dot--running { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.run__meta { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.diff { display: grid; gap: 5px; }
.diff__item { display: flex; gap: 9px; align-items: baseline; font-size: 12.5px; padding: 7px 9px; border-radius: 8px; background: var(--surface-2); }
.diff__sign { font-weight: 800; flex: none; width: 12px; }
.diff__sign--added { color: var(--ok); }
.diff__sign--removed { color: var(--danger); }
.diff__text { color: var(--text-soft); overflow-wrap: anywhere; }



/* ---------- Тепловая карта загруженности ---------- */

.heat {
  display: grid; gap: 3px;
  overflow-x: auto; padding-bottom: 2px;
}
.heat__corner { min-height: 22px; }
.heat__head {
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); text-align: center; padding-bottom: 2px;
}
.heat__time {
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 8px;
}
.heat__cell {
  min-height: 30px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  background:
    linear-gradient(color-mix(in srgb, var(--accent) var(--fill), transparent),
                    color-mix(in srgb, var(--accent) var(--fill), transparent)),
    var(--surface-2);
  border: 1px solid var(--border);
  cursor: default;
}
.heat__cell span { mix-blend-mode: normal; }

.heat__legend {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 11.5px; color: var(--muted);
}
.heat__scale {
  flex: 1; max-width: 180px; height: 8px; border-radius: 4px;
  border: 1px solid var(--border);
  background: linear-gradient(90deg,
    var(--surface-2),
    color-mix(in srgb, var(--accent) 100%, transparent));
}

.chip--on {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink);
}

@media (max-width: 560px) {
  .heat { min-width: 340px; }
  .heat__cell { min-height: 26px; font-size: 11px; }
}

/* ---------- Админка ---------- */

.view--admin { max-width: 1000px; }
.admin__title { font-size: 24px; margin-bottom: 16px; letter-spacing: -.02em; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.admin__run { margin-top: 14px; }
.run__trigger {
  font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--surface-3); color: var(--muted); flex: none;
}

.login { max-width: 380px; margin: 8vh auto 0; }
.login__title { font-size: 20px; margin-bottom: 6px; }
.login__note { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.login__warn { display: block; margin-bottom: 14px; line-height: 1.5; }
.login__warn code { font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.login form { display: grid; gap: 12px; }

@media (max-width: 820px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .login { margin-top: 4vh; }
}


/* ---------- Кнопки действий на странице ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .btn { padding: 8px 14px; font-size: 13.5px; }
.btn--pin.is-on {
  background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-ink);
}
.btn--pin.is-on svg { fill: currentColor; }

/* ---------- Закреплённая группа на главной ---------- */

.pinned {
  margin: 0 0 26px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.pinned__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 12px; }
.pinned__label {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.pinned__name { font-size: 17px; font-weight: 680; color: var(--text); letter-spacing: -.015em; }
.pinned__name:hover { color: var(--accent-ink); }
.pinned__off {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font-size: 12.5px; color: var(--muted); padding: 4px 6px; border-radius: 6px;
}
.pinned__off:hover { color: var(--danger); background: var(--surface-3); }
.pinned__foot { margin-top: 10px; font-size: 12.5px; color: var(--muted); }


/* ---------- Уведомления ---------- */

.pinned__bell {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--text-soft);
  padding: 5px 11px; border-radius: 999px;
  transition: border-color .15s, background .15s, color .15s;
}
.pinned__bell svg { width: 15px; height: 15px; }
.pinned__bell:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.pinned__bell.is-on { border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ok); }
.pinned__bell.is-on svg { fill: color-mix(in srgb, var(--ok) 18%, transparent); }
.pinned__head .pinned__off { margin-left: 0; }

.switch {
  display: flex; align-items: flex-start; gap: 11px; cursor: pointer;
  padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
}
.switch:hover { border-color: var(--border-strong); }
.switch input { margin: 2px 0 0; width: 17px; height: 17px; flex: none; accent-color: var(--accent); }
.switch span { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.switch small { color: var(--muted); font-size: 12px; }

.times { display: flex; flex-wrap: wrap; gap: 6px; }
.times--off { opacity: .4; pointer-events: none; }
.times .tab {
  border: 1px solid var(--border); background: var(--surface); border-radius: 9px;
  padding: 7px 11px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.times .tab--on {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink);
}

/* ---------- Модальное окно ---------- */

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(6,10,18,.5); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative; width: min(460px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.2,.7,.3,1);
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal__head h2 { font-size: 17px; }
.modal__body { padding: 18px; display: grid; gap: 14px; }
.modal__lead { margin: 0; font-size: 14px; color: var(--text-soft); line-height: 1.5; }
.modal__how { display: grid; gap: 8px; font-size: 12.5px; color: var(--text-soft); }
.modal__how p { margin: 0; }
.modal__note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.copy { display: flex; gap: 8px; }
.copy input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; outline: none;
}
.copy .btn { flex: none; }

@media (max-width: 560px) {
  .copy { flex-direction: column; }
  .copy .btn { justify-content: center; }
  .modal { padding: 0; align-items: end; }
  .modal__panel { width: 100%; max-height: 92vh; border-radius: var(--radius) var(--radius) 0 0; }
}

/* ---------- Загрузка ---------- */

.skeleton { display: grid; gap: 12px; }
.skeleton__bar {
  height: 16px; border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

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

/* ---------- Адаптив ---------- */

@media (max-width: 900px) {
  .now-grid { grid-template-columns: minmax(0, 1fr); }
  .now-col__body { max-height: none; }
  .live__tiles { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  :root { --topbar-h: 104px; }   /* на мобильном шапка в две строки */
  .topbar__inner { flex-wrap: wrap; padding: 8px 12px; row-gap: 8px; gap: 10px; min-height: 0; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .brand__text small { display: none; }
  .brand__mark { width: 34px; height: 34px; border-radius: 10px; }
  .week-chip { display: none; }
  .view { padding: 16px 14px 40px; }
  .controls { top: auto; position: static; backdrop-filter: none; padding: 0; }
  .footer__inner { padding: 14px; }

  .hero { padding: 22px 0 16px; }
  .hero p { font-size: 14.5px; }
  .live { margin: 18px 0 22px; }
  .live__head { padding: 14px 16px; gap: 8px 16px; }
  .live__clock { flex-direction: row; align-items: baseline; gap: 8px; }
  .live__clock b { font-size: 25px; }
  .live__slot { order: 4; width: 100%; text-align: center; }
  .live__tile { padding: 12px 14px; }
  .live__tile b { font-size: 20px; }

  .page-head { margin-bottom: 14px; }
  .controls { gap: 8px; }
  .controls .badge { display: none; }        /* выбранная неделя уже подсвечена в табах */
  .controls__spacer { display: none; }
  .page-head__meta { gap: 6px; }
  .next-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .next { padding: 12px 14px; }
  .side { gap: 10px; }
  .side__body { max-height: 300px; }
}

@media (max-width: 640px) {
  /* iOS зумит страницу, если шрифт в поле меньше 16px */
  .search input, .field input, .select, .now-col__filter input { font-size: 16px; }
  .search__field { height: 44px; }
  .icon-btn, .now-chip { height: 40px; }
  .icon-btn { width: 40px; }
  .tab { padding: 9px 13px; }
  .chip { padding: 8px 13px; }
  .list__item, .side__row, .result { min-height: 40px; }
  .picker { display: grid; grid-template-columns: 1fr 1fr; }
  .picker .field:nth-child(3) { grid-column: 1 / -1; }
  .picker .btn { grid-column: 1 / -1; justify-content: center; }
  .select { min-width: 0; width: 100%; }
  .search__results { max-height: min(60vh, 420px); }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 13px 14px; }
  .stat b { font-size: 22px; }
  .slot { gap: 10px; padding: 10px 12px; }
  .slot__time { width: 48px; }
  .day-card__head { padding: 11px 13px; }
  .browse__body { padding: 4px 13px 15px; }
  .browse__group > summary { padding: 12px 14px; }
  .now-col__head, .now-col__filter { padding-left: 14px; padding-right: 14px; }
  .now-col__body { padding: 0 8px 12px; }
  .card--pad { padding: 14px 15px; }
  .live__tiles { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 26px; }
  .view { padding: 14px 12px 36px; }
}

@media print {
  .topbar, .footer, .controls, .side, .sheet { display: none !important; }
  body { background: #fff; }
  .grid-wrap { border: 0; box-shadow: none; }
}
