.page-events-calendar {
  padding: 1rem 0 2rem;
}

.ev-cal-hero {
  margin-bottom: 1.25rem;
  padding: 1.2rem 1.35rem;
  border-radius: 18px;
  border: 1px solid var(--theme-border, #d4deef);
  background: linear-gradient(
    140deg,
    color-mix(in srgb, var(--theme-primary-soft, #e9f0ff) 60%, var(--theme-surface, #fff)),
    var(--theme-surface, #fff) 72%
  );
}

.ev-cal-hero h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  line-height: 1.15;
}

.ev-cal-hero p {
  margin: 0;
  color: var(--theme-muted, #5f6d8c);
  line-height: 1.55;
  max-width: 52rem;
}

.ev-cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
}

.ev-cal-month-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ev-cal-month-btn {
  border: 1px solid var(--theme-border, #d4deef);
  background: var(--theme-surface, #fff);
  color: var(--theme-text, #18243d);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.ev-cal-month-btn.is-active {
  background: var(--theme-primary, #243b84);
  border-color: var(--theme-primary, #243b84);
  color: #fff;
}

.ev-cal-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: start;
}

.ev-cal-grid-wrap,
.ev-cal-list-wrap,
.ev-cal-recurring {
  border: 1px solid var(--theme-border, #d4deef);
  border-radius: 18px;
  background: var(--theme-surface, #fff);
  padding: 0.85rem 0.95rem;
}

.ev-cal-grid-wrap h2,
.ev-cal-list-wrap h2,
.ev-cal-recurring h2 {
  margin: 0 0 0.55rem;
  font-size: 1.08rem;
  font-family: var(--theme-font-display, Georgia, serif);
  color: var(--theme-primary, #243b84);
}

.ev-cal-weekdays,
.ev-cal-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.22rem;
}

.ev-cal-weekday {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--theme-muted, #5f6d8c);
  padding: 0.2rem 0;
}

.ev-cal-day {
  min-height: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 0.82rem;
  color: var(--theme-text, #18243d);
  text-align: center;
  position: relative;
  cursor: default;
}

.ev-cal-day--empty {
  min-height: 0;
  height: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
}

.ev-cal-day--plain {
  aspect-ratio: 1;
  max-height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
}

.ev-cal-day--plain .ev-cal-day__num {
  font-size: 0.84rem;
  font-weight: 650;
}

.ev-cal-day--has {
  min-height: 3.6rem;
  padding: 0.28rem 0.22rem 0.32rem;
  text-align: left;
  border-color: color-mix(in srgb, var(--theme-primary, #243b84) 38%, var(--theme-border, #d4deef));
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--theme-primary-soft, #e9f0ff) 70%, #fff), var(--theme-surface, #fff) 75%);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.ev-cal-day--has:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(36, 59, 132, 0.12);
}

.ev-cal-day--has.is-selected {
  outline: 2px solid var(--theme-primary, #243b84);
  outline-offset: 1px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-primary, #243b84) 22%, transparent);
}

.ev-cal-day__num {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.1;
}

.ev-cal-day__titles {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.ev-cal-day__title {
  padding: 0.12rem 0.28rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--theme-primary, #243b84) 12%, transparent);
  color: var(--theme-primary, #243b84);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ev-cal-day__more {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--theme-muted, #5f6d8c);
  padding-left: 0.1rem;
}

.ev-cal-events {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.65rem;
}

.ev-cal-event {
  border: 1px solid var(--theme-border, #d4deef);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  background: var(--theme-surface, #fff);
}

.ev-cal-event__meta {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  color: var(--theme-muted, #5f6d8c);
}

.ev-cal-event h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  line-height: 1.3;
}

.ev-cal-event p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--theme-muted, #5f6d8c);
}

.ev-cal-event__actions {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ev-cal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--theme-border, #d4deef);
  background: var(--theme-surface, #fff);
  color: var(--theme-text, #18243d);
  cursor: pointer;
}

.ev-cal-btn--primary {
  background: var(--theme-primary, #243b84);
  border-color: var(--theme-primary, #243b84);
  color: #fff;
}

.ev-cal-recurring {
  margin-top: 1rem;
}

.ev-cal-recurring-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.ev-cal-rec-card {
  border: 1px solid var(--theme-border, #d4deef);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  background: color-mix(in srgb, var(--theme-surface-soft, #f7f9fc) 70%, var(--theme-surface, #fff));
}

.ev-cal-rec-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
}

.ev-cal-rec-card p {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--theme-muted, #5f6d8c);
}

.ev-cal-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 14, 26, 0.55);
}

.ev-cal-modal[hidden] {
  display: none !important;
}

body.ev-cal-modal-open {
  overflow: hidden;
}

.ev-cal-modal__dialog {
  width: min(640px, 100%);
  max-height: min(92vh, 880px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--theme-border, #d4deef) 70%, transparent);
  background: var(--theme-surface, #fff);
  padding: 0;
  box-shadow: 0 32px 80px rgba(8, 14, 26, 0.32);
  animation: evCalModalIn 0.28s ease;
  position: relative;
}

@keyframes evCalModalIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ev-cal-modal__head {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

.ev-cal-modal__head h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.ev-cal-modal__close {
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: rgba(12, 18, 32, 0.5);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.ev-cal-modal__cover {
  position: relative;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(145deg, #1e3270 0%, #314a8f 55%, #6b5a2e 100%);
  border-radius: 20px 20px 0 0;
  isolation: isolate;
  flex: 0 0 auto;
}

.ev-cal-modal__cover img {
  display: block;
  width: 100%;
  height: 132px;
  object-fit: cover;
  object-position: center 28%;
}

.ev-cal-modal__cover-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 14, 28, 0.05) 0%, rgba(8, 14, 28, 0.18) 40%, rgba(8, 14, 28, 0.72) 100%);
  pointer-events: none;
}

.ev-cal-modal__cover-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1rem 0.75rem;
  margin: 0;
}

.ev-cal-modal__cover .ev-cal-spots {
  justify-self: start;
  margin: 0;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 750;
}

.ev-cal-modal__cover-title {
  display: none;
}

#evCalModalBody {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.ev-cal-modal__content {
  padding: 1rem 1.15rem 1.25rem;
  display: grid;
  gap: 0.75rem;
}

.ev-cal-modal__heading {
  margin: 0;
  font-family: var(--theme-font-display, "Zodiak", Georgia, serif);
  font-size: clamp(1.2rem, 2.8vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--theme-text, #18243d);
}

.ev-cal-modal__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ev-cal-modal__pill {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.4rem;
  max-width: 100%;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--theme-border, #d4deef) 85%, transparent);
  background: color-mix(in srgb, var(--theme-surface-soft, #f5f7fb) 80%, #fff);
  font-size: 0.92rem;
  line-height: 1.35;
  font-weight: 650;
  color: var(--theme-text, #18243d);
}

.ev-cal-modal__pill-k {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--theme-muted, #5f6d8c);
}

.ev-cal-modal__desc {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--theme-muted, #5f6d8c);
}

.ev-cal-spots {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--theme-text, #18243d);
}

.ev-cal-approx {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--theme-muted, #5f6d8c);
}

.ev-cal-closed {
  margin: 0;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: #fff4f4;
  color: #8a2f2f;
  font-size: 0.94rem;
  line-height: 1.45;
}

.ev-cal-signup {
  display: grid;
  gap: 0.7rem;
  margin: 0.15rem 0 0;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid var(--theme-border, #d4deef);
  background: color-mix(in srgb, var(--theme-surface-soft, #f7f9fc) 75%, #fff);
}

.ev-cal-signup__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--theme-text, #18243d);
}

.ev-cal-signup__fio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.ev-cal-signup input[type="text"],
.ev-cal-signup input[type="tel"] {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.25rem;
  border: 1px solid var(--theme-border, #d4deef);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  background: var(--theme-surface, #fff);
}

.ev-cal-signup label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.88rem;
  line-height: 1.45;
  font-weight: 650;
  color: var(--theme-text, #18243d);
}

.ev-cal-signup__choice {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--theme-border, #d4deef);
  background: var(--theme-surface-soft, #f7f9fc);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
}

.ev-cal-signup__choice legend {
  padding: 0 0.15rem;
  font-size: 0.86rem;
  font-weight: 800;
}

.ev-cal-signup__chip {
  display: inline-flex !important;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--theme-border, #d4deef);
  background: var(--theme-surface, #fff);
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
}

.ev-cal-signup__chip:has(input:checked) {
  border-color: color-mix(in srgb, var(--theme-primary, #243b84) 45%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-primary-soft, #e9f0ff) 55%, #fff);
  color: var(--theme-primary, #243b84);
}

.ev-cal-signup__consent {
  display: flex !important;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--theme-muted, #5f6d8c);
}

.ev-cal-signup__consent input {
  margin-top: 0.2rem;
}

.ev-cal-signup-msg {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--theme-primary, #243b84);
}

.ev-cal-empty {
  margin: 0;
  color: var(--theme-muted, #5f6d8c);
}

@media (max-width: 700px) {
  .ev-cal-signup__fio {
    grid-template-columns: 1fr;
  }

  .ev-cal-modal {
    padding: 0;
    place-items: end center;
  }

  .ev-cal-modal__dialog {
    width: 100%;
    max-height: min(92vh, 100%);
    border-radius: 18px 18px 0 0;
  }

  .ev-cal-modal__cover {
    border-radius: 18px 18px 0 0;
  }

  .ev-cal-modal__cover img {
    height: 96px;
  }

  .ev-cal-modal__content {
    padding: 0.9rem 1rem 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ev-cal-modal__dialog,
  .ev-cal-modal__cover img {
    animation: none !important;
  }
}

@media (max-width: 900px) {
  .ev-cal-events {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .ev-cal-weekdays,
  .ev-cal-days {
    gap: 0.18rem;
  }

  .ev-cal-day--has {
    min-height: 3.1rem;
  }

  .ev-cal-day--plain {
    max-height: 2.1rem;
  }

  .ev-cal-day__title {
    font-size: 0.54rem;
    padding: 0.06rem 0.16rem;
    -webkit-line-clamp: 2;
  }
}

/* Кнопки: стабильный контраст */
.ev-cal-btn,
.ev-cal-month-btn {
  color: var(--theme-text, #18243d);
  background: var(--theme-surface, #fff);
  border: 1px solid var(--theme-border, #d4deef);
}

.ev-cal-btn--primary,
.ev-cal-month-btn.is-active {
  background: var(--theme-primary, #243b84) !important;
  border-color: var(--theme-primary, #243b84) !important;
  color: #fff !important;
}

.ev-cal-btn:focus-visible,
.ev-cal-month-btn:focus-visible {
  outline: 3px solid var(--theme-primary, #243b84);
  outline-offset: 2px;
}

/* Тёмная тема — страница календаря */
:root[data-theme="dark"] body.page-events-calendar,
:root[data-theme="dark"] .page-events-calendar {
  background: var(--theme-bg, #0f1729);
  color: var(--theme-text, #e8eefc);
}

:root[data-theme="dark"] .ev-cal-hero {
  background:
    linear-gradient(
      140deg,
      color-mix(in srgb, var(--theme-primary, #243b84) 28%, var(--theme-surface, #162038)),
      var(--theme-surface, #162038) 72%
    ) !important;
  border-color: var(--theme-border, #3a4a6a) !important;
  color: var(--theme-text, #e8eefc) !important;
}

:root[data-theme="dark"] .ev-cal-hero h1,
:root[data-theme="dark"] .ev-cal-grid-wrap h2,
:root[data-theme="dark"] .ev-cal-list-wrap h2,
:root[data-theme="dark"] .ev-cal-recurring h2,
:root[data-theme="dark"] .ev-cal-event h3,
:root[data-theme="dark"] .ev-cal-rec-card h3,
:root[data-theme="dark"] .about-breadcrumb a {
  color: var(--theme-text, #e8eefc) !important;
}

:root[data-theme="dark"] .ev-cal-hero p,
:root[data-theme="dark"] .ev-cal-event__meta,
:root[data-theme="dark"] .ev-cal-event p,
:root[data-theme="dark"] .ev-cal-approx,
:root[data-theme="dark"] .ev-cal-rec-card p,
:root[data-theme="dark"] .ev-cal-empty,
:root[data-theme="dark"] .ev-cal-weekday,
:root[data-theme="dark"] .about-breadcrumb {
  color: var(--theme-muted, #a9b6d4) !important;
}

:root[data-theme="dark"] .ev-cal-grid-wrap,
:root[data-theme="dark"] .ev-cal-list-wrap,
:root[data-theme="dark"] .ev-cal-recurring,
:root[data-theme="dark"] .ev-cal-event,
:root[data-theme="dark"] .ev-cal-rec-card,
:root[data-theme="dark"] .ev-cal-modal__dialog {
  background: var(--theme-surface, #162038) !important;
  border-color: var(--theme-border, #3a4a6a) !important;
  color: var(--theme-text, #e8eefc) !important;
}

:root[data-theme="dark"] .ev-cal-modal__pill,
:root[data-theme="dark"] .ev-cal-signup {
  background: color-mix(in srgb, var(--theme-bg, #0f1729) 55%, var(--theme-surface, #162038)) !important;
  border-color: var(--theme-border, #3a4a6a) !important;
}

:root[data-theme="dark"] .ev-cal-day {
  background: color-mix(in srgb, var(--theme-surface, #162038) 75%, #0f1729);
  border-color: var(--theme-border, #3a4a6a);
  color: var(--theme-text, #e8eefc);
}

:root[data-theme="dark"] .ev-cal-day--has {
  background: color-mix(in srgb, var(--theme-primary, #243b84) 28%, var(--theme-surface, #162038));
  border-color: color-mix(in srgb, var(--theme-primary, #9bb6ff) 40%, var(--theme-border, #3a4a6a));
}

:root[data-theme="dark"] .ev-cal-day__title {
  background: color-mix(in srgb, var(--theme-primary, #9bb6ff) 18%, transparent);
  color: color-mix(in srgb, var(--theme-primary, #9bb6ff) 85%, #fff);
}

:root[data-theme="dark"] .ev-cal-day__more {
  color: var(--theme-muted, #a9b6d4);
}

:root[data-theme="dark"] .ev-cal-day--empty {
  background: transparent;
  border-color: transparent;
}

:root[data-theme="dark"] .ev-cal-btn,
:root[data-theme="dark"] .ev-cal-month-btn {
  background: color-mix(in srgb, var(--theme-bg, #0f1729) 45%, var(--theme-surface, #162038)) !important;
  border-color: var(--theme-border, #3a4a6a) !important;
  color: var(--theme-text, #e8eefc) !important;
}

:root[data-theme="dark"] .ev-cal-btn--primary,
:root[data-theme="dark"] .ev-cal-month-btn.is-active {
  background: var(--theme-primary, #4d78d8) !important;
  border-color: var(--theme-primary, #4d78d8) !important;
  color: #fff !important;
}

:root[data-theme="dark"] .ev-cal-spots {
  color: var(--theme-text, #e8eefc) !important;
}

:root[data-theme="dark"] .ev-cal-signup input[type="text"],
:root[data-theme="dark"] .ev-cal-signup input[type="tel"],
:root[data-theme="dark"] .ev-cal-signup__choice,
:root[data-theme="dark"] .ev-cal-signup__chip {
  background: color-mix(in srgb, var(--theme-bg, #0f1729) 50%, var(--theme-surface, #162038)) !important;
  border-color: var(--theme-border, #3a4a6a) !important;
  color: var(--theme-text, #e8eefc) !important;
}

:root[data-theme="dark"] .ev-cal-signup label,
:root[data-theme="dark"] .ev-cal-signup__title,
:root[data-theme="dark"] .ev-cal-modal__desc,
:root[data-theme="dark"] #evCalModalBody {
  color: var(--theme-text, #e8eefc) !important;
}

:root[data-theme="dark"] .official-footer {
  background: var(--theme-bg, #0f1729);
}
