:root {
  color-scheme: light;
  --navy-950: #11152f;
  --navy-900: #171b3b;
  --navy-700: #30365f;
  --violet-700: #6339cb;
  --violet-500: #8358e8;
  --violet-100: #eee8ff;
  --blue-700: #1b64c8;
  --blue-100: #e7f1ff;
  --orange-700: #b84d0f;
  --orange-100: #fff0df;
  --ink: #24273d;
  --muted: #676b80;
  --line: #e7e8ef;
  --canvas: #f4f5f9;
  --card: #ffffff;
  --focus: #ff9f43;
  --sticky-content-offset: 238px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: var(--sticky-content-offset);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #eceefa 0, var(--canvas) 320px);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

#schedule-app {
  width: min(1320px, calc(100% - 40px));
  margin-inline: auto;
  padding-block: 28px 64px;
}

.overview-header {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 40px;
  align-items: end;
  padding: 32px 36px;
  color: white;
  background: linear-gradient(125deg, var(--navy-950) 0%, var(--navy-900) 54%, #532b9e 100%);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 18px 45px rgb(23 27 59 / 18%);
}

.eyebrow, .overview-header h1, .station-summary, .visible-range { margin: 0; }
.eyebrow {
  margin-bottom: 6px;
  color: #c9bcff;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.overview-header h1 { font-size: clamp(1.8rem, 3vw, 2.75rem); line-height: 1.08; }
.station-summary { margin-top: 12px; color: #ddd8f3; font-size: .94rem; }

.schedule-toolbar {
  display: grid;
  grid-template-columns: auto minmax(180px, auto) auto;
  gap: 14px;
  align-items: center;
  justify-items: end;
}

.date-navigation, .segmented-control {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgb(255 255 255 / 12%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 12px;
}

.icon-button, .segmented-control button {
  min-height: 38px;
  color: white;
  background: transparent;
  border: 0;
  border-radius: 8px;
}
.icon-button { min-width: 40px; font-size: 1.2rem; }
.date-picker input {
  width: 132px;
  min-height: 38px;
  padding-inline: 8px;
  color: white;
  color-scheme: dark;
  background: transparent;
  border: 0;
}
.segmented-control button { padding-inline: 16px; }
.segmented-control button[aria-pressed="true"] {
  color: var(--navy-950);
  background: white;
  box-shadow: 0 3px 10px rgb(0 0 0 / 14%);
}
.visible-range { min-width: 170px; color: #f1eefb; font-weight: 700; text-align: center; }

.overview-filters {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: grid;
  gap: 18px;
  padding: 22px 28px;
  background: rgb(255 255 255 / 96%);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 12px 28px rgb(28 33 69 / 10%);
  backdrop-filter: blur(12px);
}

.filter-fields {
  display: grid;
  grid-template-columns: minmax(280px, 1.6fr) minmax(190px, 1fr) minmax(150px, .7fr);
  gap: 14px;
}
.filter-fields label { display: grid; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.filter-fields input, .filter-fields select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fbfbfd;
  border: 1px solid #d9dbe5;
  border-radius: 10px;
}

.filter-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-group-label { margin-right: 4px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.filter-group button, .text-button, .secondary-button, .primary-button, .status-action {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 9px;
}
.filter-group button { color: #505469; background: #f4f5f8; border: 1px solid transparent; }
.filter-group button[aria-pressed="true"] { color: #4c2da7; background: var(--violet-100); border-color: #c9b6fb; }
.filter-actions { display: flex; justify-content: flex-end; gap: 8px; }
.text-button, .secondary-button, .primary-button, .status-action { font-weight: 750; }
.text-button { color: var(--muted); background: transparent; border: 0; }
.secondary-button, .status-action { color: var(--violet-700); background: white; border: 1px solid #cfc4eb; }
.primary-button {
  color: white;
  background: var(--violet-700);
  border: 1px solid var(--violet-700);
  box-shadow: 0 6px 14px rgb(99 57 203 / 22%);
}
.nearest-button { white-space: nowrap; }

.overview-content { padding-top: 22px; }
#schedule-status, #schedule-grid { scroll-margin-top: var(--sticky-content-offset); }
#schedule-status:empty { display: none; }
#schedule-status { display: grid; gap: 8px; margin-bottom: 12px; }
.status-banner {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #dfe1eb;
  border-radius: 11px;
  background: white;
  box-shadow: 0 5px 14px rgb(28 33 69 / 6%);
}
.status-cached { color: #704012; background: #fff8ed; border-color: #f3d7ad; }
.status-error { color: #912b2b; background: #fff2f2; border-color: #efc4c4; }
.status-refreshing, .status-loading { color: #314c7d; background: #f1f6ff; border-color: #cbdcf8; }
.status-diagnostic { color: #64687a; background: #f7f7fa; }

#schedule-grid {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgb(28 33 69 / 8%);
}

.day-grid { overflow: hidden; border-radius: inherit; }
.day-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  min-height: 136px;
  border-bottom: 1px solid var(--line);
}
.day-row:last-child { border-bottom: 0; }
.time-cell {
  padding: 22px 14px;
  color: var(--navy-700);
  font-size: .86rem;
  font-weight: 800;
  text-align: left;
  background: #fafafd;
  border-right: 1px solid var(--line);
}
.day-events {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  padding: 14px;
  text-align: left;
}

.exercise-card {
  position: relative;
  display: grid;
  gap: 7px;
  width: 100%;
  min-width: 0;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: var(--card);
  border: 1px solid #dcdee8;
  border-radius: 12px;
  box-shadow: 0 5px 14px rgb(27 32 67 / 7%);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.exercise-card:hover { border-color: #b7a3ed; box-shadow: 0 9px 22px rgb(56 39 112 / 12%); transform: translateY(-1px); }
.exercise-card.is-nearest, .exercise-card[data-nearest="true"] {
  border-color: var(--orange-700);
  box-shadow: 0 0 0 3px rgb(255 159 67 / 22%), 0 9px 22px rgb(56 39 112 / 12%);
}
.exercise-time { color: var(--violet-700); font-size: .78rem; font-weight: 850; }
.exercise-title { overflow-wrap: anywhere; font-size: .94rem; line-height: 1.25; }
.exercise-trainer { overflow-wrap: anywhere; color: var(--muted); font-size: .78rem; }
.station-mark, .availability-badge {
  justify-self: start;
  padding: 4px 7px;
  font-size: .68rem;
  font-weight: 800;
  line-height: 1.2;
  border-radius: 999px;
}
.station-nagatinskaya { color: var(--blue-700); background: var(--blue-100); }
.station-premium { color: var(--violet-700); background: var(--violet-100); }
.station-other { color: var(--muted); background: #f0f1f4; }
.availability-badge.is-available { color: var(--orange-700); background: var(--orange-100); }
.availability-badge.is-full { color: #686b77; background: #eceef2; }

.week-grid { min-width: 0; border-radius: inherit; }
.week-headings, .week-row {
  display: grid;
  grid-template-columns: 68px repeat(7, minmax(0, 1fr));
}
.week-headings {
  position: sticky;
  top: var(--sticky-content-offset);
  z-index: 10;
  min-height: 58px;
  background: white;
  border-bottom: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 5px 12px rgb(28 33 69 / 6%);
}
.week-time-heading, .week-day-heading {
  display: flex;
  align-items: center;
  padding: 12px 10px;
  color: var(--navy-700);
  font-size: .76rem;
  font-weight: 850;
  text-align: left;
  border-right: 1px solid var(--line);
}
.week-row {
  min-height: 126px;
  border-bottom: 1px solid var(--line);
}
.week-row:last-child { border-bottom: 0; }
.week-cell {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding: 8px;
  text-align: left;
  border-right: 1px solid var(--line);
}
.week-cell:last-child, .week-day-heading:last-child { border-right: 0; }
.week-cell[data-today="true"], .week-day-heading[data-today="true"] { background: #f5f1ff; }
.week-cell .exercise-card { padding: 10px; }

.empty-state {
  display: grid;
  justify-items: start;
  gap: 14px;
  min-height: 240px;
  padding: 64px;
  text-align: left;
}
.empty-state-title { margin: 0; color: var(--navy-700); font-size: 1.1rem; font-weight: 800; }
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  min-height: 360px;
  padding: 28px;
}
.skeleton-card {
  min-height: 118px;
  border-radius: 12px;
  background: linear-gradient(100deg, #eff0f4 20%, #f8f8fa 38%, #eff0f4 56%);
  background-size: 300% 100%;
  animation: skeleton-wave 1.4s ease-in-out infinite;
}
@keyframes skeleton-wave { from { background-position: 100% 0; } to { background-position: 0 0; } }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1099px) {
  .schedule-toolbar { grid-template-columns: auto auto; }
  .visible-range { grid-column: 1 / -1; grid-row: 2; }
  #schedule-grid[data-mode="week"] {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }
  .week-grid { min-width: 1120px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

.multi-filter { margin: 0; padding: 0; border: 0; min-width: 0; }
.multi-filter legend { padding: 0; margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.checkbox-options { display: flex; flex-wrap: wrap; gap: 7px; }
.checkbox-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 10px; color: #505469; background: #f4f5f8; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-size: .84rem; }
.checkbox-chip:has(input:checked), .checkbox-chip:has(input:indeterminate) { color: #4c2da7; background: var(--violet-100); border-color: #c9b6fb; }
.checkbox-chip input { width: 15px; height: 15px; margin: 0; accent-color: var(--violet-700); }
.all-chip { font-weight: 750; }
.exercise-card { text-decoration: none; }
.event-kind { justify-self: start; color: #6a6282; font-size: .65rem; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.event-kind-game { color: #1b64c8; }
.event-kind-tournament { color: #b84d0f; }
.schedule-footer { width: min(1320px, calc(100% - 40px)); margin: 0 auto 28px; color: var(--muted); font-size: .8rem; text-align: center; }
.overview-filters { position: relative; top: auto; }
:root { --sticky-content-offset: 24px; }
.week-headings { top: 0; }
@media (max-width: 759px) {
  #schedule-app { width: calc(100% - 20px); padding-top: 10px; }
  .overview-header { grid-template-columns: 1fr; padding: 24px 20px; gap: 22px; }
  .schedule-toolbar { justify-items: start; grid-template-columns: auto auto; gap: 10px; }
  .visible-range { text-align: left; }
  .overview-filters { padding: 18px 14px; gap: 16px; }
  .filter-fields { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filter-actions { flex-wrap: wrap; justify-content: start; }
  .day-row { grid-template-columns: 54px minmax(0, 1fr); }
  .day-events { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; gap: 8px; }
  .exercise-card { padding: 10px; }
  .empty-state { padding: 32px 20px; }
  .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; }
}
@media (max-width: 430px) {
  .day-events { grid-template-columns: 1fr; }
  .schedule-toolbar { grid-template-columns: 1fr; }
  .visible-range { grid-row: auto; }
}
