:root {
  --paper: #070d18;
  --ink: #e8eef8;
  --card: #101a2c;
  --card-2: #152238;
  --muted: #9aa8bd;
  --line: #243552;
  --grid: #2a3d5c;
  --brand: #0c3060;
  --brand-bright: #1a4f96;
  --accent: #dd3333;
  --accent-soft: rgba(221, 51, 51, 0.18);
  --gold: #c9a45b;
  --change: #e67e22;
  --change-bg: rgba(230, 126, 34, 0.2);
  --ok: #3dba7a;
  --bad: #ef4d5a;
  --now: #dd3333;
  --now-bg: #3a1520;
  --next: #4d8fd9;
  --next-bg: #152a40;
  --stac: #7eb6ff;
  --stac-bg: #16355a;
  --online: #ddb76a;
  --online-bg: #2a2418;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(221, 51, 51, 0.12), transparent 28%),
    radial-gradient(circle at top left, rgba(12, 48, 96, 0.55), transparent 40%),
    linear-gradient(180deg, #0b1526 0%, var(--paper) 280px);
}

* { box-sizing: border-box; }
body {
  margin: 0 auto;
  max-width: 1240px;
  padding: 24px 18px 64px;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 560; }
h1 { font-size: clamp(40px, 6vw, 68px); line-height: 0.92; margin: 0; letter-spacing: -0.04em; }
h1 span {
  font-size: 0.42em;
  letter-spacing: 0;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  padding: 0.15em 0.35em 0.2em;
  vertical-align: 12px;
}
.eyebrow, .range, .status-line, footer, .meta, .now-label, .slot-time { color: var(--muted); }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--gold); }
.range { margin: 12px 0 0; font-size: 17px; }
.top { display: flex; justify-content: space-between; gap: 24px; align-items: end; }
.stamp {
  border: 2px solid currentColor;
  padding: 10px 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 13px;
  font-weight: 600;
  transform: rotate(-2deg);
  white-space: nowrap;
}
.stamp[data-state="current"] { color: var(--ok); }
.stamp[data-state="updated"] { color: var(--change); }
.stamp[data-state="error"] { color: var(--bad); }
.stamp[data-state="checking"] { color: var(--gold); }

.now-board {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.now-board.is-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.now-board.is-clickable:hover {
  border-color: var(--brand-bright);
  background: #121e32;
}
.now-board.is-clickable:focus-visible {
  outline: 2px solid var(--next);
  outline-offset: 2px;
}
.now-board[data-phase="live"] { border-color: var(--accent); }
.now-board[data-phase="next"] { border-color: var(--next); }
.now-clock {
  background: linear-gradient(180deg, #0c3060, #081428);
  color: #e8eef8;
  padding: 18px;
  display: grid;
  gap: 4px;
  align-content: center;
  border-right: 1px solid var(--line);
}
.now-clock strong {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: 0.02em;
}
.now-label { color: #8fa6c7; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; }
.now-body { padding: 18px 20px; display: grid; gap: 6px; align-content: center; }
.now-title { margin: 0; font-family: Fraunces, Georgia, serif; font-size: clamp(24px, 3vw, 34px); }
.now-meta { margin: 0; color: var(--muted); }
.now-progress {
  margin-top: 8px;
  height: 8px;
  background: #1a2740;
  overflow: hidden;
}
.now-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.6s linear;
}
.now-board[data-phase="next"] .now-progress > span { background: var(--next); }

body.account-locked .now-board,
body.account-locked #controls,
body.account-locked #main,
body.account-locked #banner,
body.account-locked #stamp {
  display: none !important;
}
body.account-locked .login {
  margin-top: 28px;
}
body:not(.account-locked) .login { display: none; }

.login {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
  max-width: 520px;
}
.login[hidden], .filters[hidden] { display: none; }
.login h2 { margin: 0 0 8px; font-size: 28px; }
.login p { margin: 0 0 14px; color: var(--muted); }
.login form { display: grid; gap: 12px; }
.login label { display: grid; gap: 6px; font-size: 14px; }
.login input {
  font: inherit;
  border: 1px solid var(--line);
  background: #0b1424;
  color: var(--ink);
  padding: 10px 12px;
}
.banner {
  margin-top: 22px;
  background: linear-gradient(135deg, #0c3060, #1a1830 55%, #4a1520);
  color: #eef3fb;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.banner h2 { margin: 0 0 8px; font-size: 28px; }
.banner ul { margin: 8px 0 0; padding-left: 18px; }
.banner button { margin-top: 12px; }
.status-line { min-height: 1.4em; }
.controls {
  margin: 18px 0 20px;
  border: 1px solid var(--line);
  background: rgba(16, 26, 44, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.sync-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(180deg, #152238, #101a2c);
  border-bottom: 1px solid var(--line);
}
.sync-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  max-width: 72ch;
}
.sync-copy strong { color: var(--ink); font-weight: 600; }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 16px 4px;
}
.cohort, .actions, .groups, .seg { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cohort {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
}
.filters {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 8px 16px 16px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.filter-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
}
.filter-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  line-height: 1.2;
}
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: #0b1424;
}
.seg .chip {
  border: 0;
  margin: 0;
  background: transparent;
  min-height: 34px;
  padding: 7px 12px;
  color: var(--muted);
  font-weight: 500;
}
.seg .chip:hover { color: var(--ink); background: rgba(255, 255, 255, 0.04); }
.seg .chip[aria-pressed="true"] {
  background: var(--brand-bright);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.groups { gap: 4px; padding: 4px; border: 1px solid var(--line); background: #0b1424; }
.groups .tab {
  border: 0;
  min-height: 34px;
  padding: 7px 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 500;
}
.groups .tab:hover { color: var(--ink); background: rgba(255, 255, 255, 0.04); }
.groups .tab[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
button, .tab, .chip {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}
button.ghost, a.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
button.ghost:hover, a.ghost:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  font-weight: 600;
}
button.primary:hover { background: #c42b2b; }
button:disabled { opacity: 0.55; cursor: progress; }
.source-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(16, 26, 44, 0.9);
  font-size: 13px;
  color: var(--muted);
}
.source-card strong { color: var(--ink); font-weight: 600; }
.source-card a {
  color: var(--stac);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}
@media (max-width: 720px) {
  .cohort, .filter-row { grid-template-columns: 1fr; gap: 6px; }
  .sync-bar { align-items: stretch; }
  .actions { width: 100%; justify-content: flex-start; }
}

.board {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: auto;
}
.board-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.board-head h2 { margin: 0; font-size: 28px; }
.board-head p { margin: 4px 0 0; color: var(--muted); }

.timetable {
  --hour-height: 68px;
  --label-width: 72px;
  --head-height: 56px;
  min-width: 720px;
  display: grid;
  grid-template-columns: var(--label-width) repeat(var(--days), minmax(160px, 1fr));
  align-items: start;
}
.timetable .time-rail,
.timetable .day-col {
  min-height: calc(var(--head-height) + var(--body-height));
}
.timetable .time-rail {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #0e1a2e;
  border-right: 1px solid var(--grid);
}
.timetable .rail-head {
  height: var(--head-height);
  border-bottom: 1px solid var(--grid);
  position: sticky;
  top: 0;
  background: #0e1a2e;
  z-index: 4;
}
.timetable .hour-label {
  height: var(--hour-height);
  border-bottom: 1px dashed var(--grid);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  padding: 6px 8px;
  color: var(--muted);
}
.timetable .day-col { border-right: 1px solid var(--grid); }
.timetable .day-head {
  height: var(--head-height);
  padding: 10px 12px;
  border-bottom: 1px solid var(--grid);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: #0e1a2e;
  z-index: 2;
}
.timetable .day-head small { display: block; color: var(--muted); font-weight: 400; }
.timetable .day-head.today { background: rgba(221, 51, 51, 0.16); }
.timetable .lane {
  position: relative;
  height: var(--body-height);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--hour-height) - 1px),
    var(--grid) calc(var(--hour-height) - 1px),
    var(--grid) var(--hour-height)
  );
}
.lesson-block {
  position: absolute;
  left: 6px;
  right: 6px;
  border: 1px solid transparent;
  padding: 7px 8px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.25;
  background: var(--card-2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  background-clip: padding-box;
}
.lesson-block.stacjonarne { background: var(--stac-bg); border-color: #3a6aa0; color: var(--stac); }
.lesson-block.on-line { background: var(--online-bg); border-color: #6a5a30; color: var(--online); }
.lesson-block strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.lesson-block .slot-time { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 11px; }
.lesson-block .meta { color: var(--muted); }
.lesson-block .lesson-zjazdy { color: #9ec0e8; }
.lesson-block .lesson-arrange { color: var(--gold); }
.agenda-row .lesson-zjazdy { color: #9ec0e8; }
.agenda-row .lesson-arrange { color: var(--gold); }
.lesson-block.past {
  background: #121820;
  border-color: #2a3548;
  color: #6f7d92;
  filter: grayscale(0.35);
}
.lesson-block.past strong { color: #9aa8bd; }
.lesson-block.next {
  outline: 2px solid var(--next);
  box-shadow: 0 0 0 4px rgba(77, 143, 217, 0.16);
  z-index: 1;
}
.lesson-block.live {
  background: var(--now-bg);
  border-color: var(--accent);
  color: #ffb4b4;
  outline: 2px solid var(--accent);
  box-shadow: 0 0 0 5px rgba(221, 51, 51, 0.18);
  z-index: 2;
  animation: pulse 1.8s ease-in-out infinite;
}
.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 5;
  pointer-events: none;
}
.now-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

@keyframes pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

.agenda { margin-top: 18px; display: grid; gap: 10px; }
.day-card {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.day-card.today { border-color: var(--accent); }
.day-card h3 { margin: 0 0 8px; font-size: 22px; }
.agenda-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.agenda-row.live { background: var(--now-bg); margin: 0 -8px; padding: 10px 8px; }
.agenda-row.next { background: var(--next-bg); margin: 0 -8px; padding: 10px 8px; }
.agenda-row.past { opacity: 0.55; }
.agenda-row .clock { font-family: "IBM Plex Mono", ui-monospace, monospace; }

.note-list {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(16, 26, 44, 0.9);
}
.note-list h3 {
  margin: 0 0 8px;
  font-size: 22px;
}
.note-list ul {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 4px;
}
.note-list li { line-height: 1.4; }
.sheet-fold {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: rgba(16, 26, 44, 0.9);
}
.sheet-fold > summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 560;
  user-select: none;
}
.sheet-fold > summary::-webkit-details-marker { display: none; }
.sheet-fold > summary::before {
  content: "▸";
  display: inline-block;
  width: 1.1em;
  color: var(--muted);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.7em;
  vertical-align: 0.15em;
}
.sheet-fold[open] > summary::before { content: "▾"; }
.sheet-fold-body { padding: 0 12px 12px; display: grid; gap: 8px; }
.sheet-fold-nested {
  margin-top: 0;
  background: #0b1424;
}
.sheet-fold-nested > summary {
  font-size: 17px;
  padding: 10px 12px;
}
.sheet-fold .table-wrap { margin-top: 0; padding: 0 12px 12px; }
.table-wrap { overflow-x: auto; margin-top: 18px; }
table { border-collapse: collapse; min-width: 100%; background: var(--card); box-shadow: var(--shadow); }
th, td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; white-space: pre-wrap; font-size: 14px; }
th { background: #152238; text-align: left; }
td.changed { background: var(--change-bg); box-shadow: inset 0 0 0 2px var(--change); }
.site-footer {
  margin-top: 28px;
  padding: 14px 0 6px;
  border-top: 1px solid var(--line);
}
.site-footer-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  text-align: center;
  display: grid;
  gap: 2px;
}
.site-footer p { margin: 0; }
.site-footer-brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 13px;
  color: #8b9bb0;
  letter-spacing: -0.02em;
}
.site-footer-author {
  font-size: 11px;
  color: #7a8a9e;
}
.site-footer-author strong { color: #9aa8bd; font-weight: 600; }
.site-footer-company {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 600;
  color: #8b9bb0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.site-footer-meta {
  font-size: 10px;
  line-height: 1.45;
  color: #6f7d92;
}
.empty { padding: 28px 8px 8px; font-size: 18px; }
a { color: inherit; }

@media (max-width: 820px) {
  .top, .now-board { display: block; }
  .stamp { display: inline-block; margin-top: 16px; }
  .now-clock { border-right: 0; border-bottom: 1px solid var(--line); }
  .agenda-row { grid-template-columns: 1fr; }
}
