.fexk-calendar {
  --fexk-border: #d5dde8;
  --fexk-accent: #0057a8;
  --fexk-accent-soft: #edf4fb;
  --fexk-text: #1f2937;
  --fexk-muted: #6b7280;
  --fexk-surface: #ffffff;
  --fexk-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  color: var(--fexk-text);
  font-family: inherit;
  position: relative;
}

.fexk-calendar__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.fexk-calendar__controls,
.fexk-calendar__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.fexk-calendar__title {
  margin: 0;
  font-size: 1.5rem;
  text-transform: capitalize;
}

.fexk-calendar__nav,
.fexk-calendar__today,
.fexk-calendar__subscribe,
.fexk-calendar-popover__button,
.fexk-calendar-popover__close {
  border: 1px solid var(--fexk-border);
  background: var(--fexk-surface);
  border-radius: 999px;
  color: var(--fexk-text);
  cursor: pointer;
  text-decoration: none;
  padding: 0.65rem 1rem;
  font: inherit;
  transition: all 0.2s ease;
}

.fexk-calendar__subscribe,
.fexk-calendar-popover__button {
  background: var(--fexk-accent);
  border-color: var(--fexk-accent);
  color: #fff;
}

.fexk-calendar__nav:hover,
.fexk-calendar__today:hover,
.fexk-calendar__subscribe:hover,
.fexk-calendar-popover__button:hover,
.fexk-calendar-popover__close:hover {
  transform: translateY(-1px);
  box-shadow: var(--fexk-shadow);
}

.fexk-calendar-popover__button--secondary {
  background: var(--fexk-accent-soft);
  border-color: transparent;
  color: var(--fexk-accent);
}

.fexk-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--fexk-border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--fexk-surface);
}

.fexk-calendar__weekday {
  padding: 0.85rem;
  text-align: center;
  font-weight: 700;
  background: var(--fexk-accent-soft);
  border-bottom: 1px solid var(--fexk-border);
}

.fexk-calendar__day {
  min-height: 140px;
  padding: 0.75rem;
  border-right: 1px solid var(--fexk-border);
  border-bottom: 1px solid var(--fexk-border);
  background: #fff;
}

.fexk-calendar__day:nth-child(7n) {
  border-right: 0;
}

.fexk-calendar__day--muted {
  background: #f8fafc;
  color: var(--fexk-muted);
}

.fexk-calendar__day--today {
  background: #fff9eb;
}

.fexk-calendar__day-number {
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.fexk-calendar__day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.fexk-calendar__day-weekday {
  display: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fexk-muted);
}

.fexk-calendar__events {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fexk-calendar__event {
  border: 0;
  background: var(--fexk-accent-soft);
  color: var(--fexk-accent);
  border-left: 4px solid var(--fexk-accent);
  border-radius: 10px;
  text-align: left;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  font: inherit;
}

.fexk-calendar__event-title {
  display: block;
  font-size: 0.875rem;
  line-height: 1.3;
}

.fexk-calendar__more,
.fexk-calendar__empty {
  color: var(--fexk-muted);
  font-size: 0.95rem;
}

.fexk-calendar__empty {
  margin-top: 1rem;
}

.fexk-calendar-popover[hidden] {
  display: none;
}

.fexk-calendar-popover {
  position: absolute;
  width: min(360px, calc(100% - 16px));
  max-height: min(420px, calc(100% - 16px));
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--fexk-border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--fexk-shadow);
  z-index: 30;
}

.fexk-calendar-popover__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  line-height: 1;
  padding: 0.5rem 0.8rem;
}

.fexk-calendar-popover__title {
  margin: 0 2.5rem 0.75rem 0;
  font-size: 1.1rem;
}

.fexk-calendar-popover__meta p,
.fexk-calendar-popover__description {
  margin: 0 0 0.75rem;
}

.fexk-calendar-popover__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .fexk-calendar__header {
    align-items: stretch;
  }

  .fexk-calendar__controls,
  .fexk-calendar__actions {
    width: 100%;
    justify-content: space-between;
  }

  .fexk-calendar__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    border: 0;
    background: transparent;
    border-radius: 16px;
    overflow: visible;
  }

  .fexk-calendar__weekday {
    display: none;
  }

  .fexk-calendar__day {
    min-height: 120px;
    border: 1px solid var(--fexk-border);
    border-radius: 16px;
  }

  .fexk-calendar__day-weekday {
    display: block;
  }
}

@media (max-width: 640px) {
  .fexk-calendar__controls,
  .fexk-calendar__actions {
    justify-content: flex-start;
  }

  .fexk-calendar__grid {
    grid-template-columns: 1fr;
  }

  .fexk-calendar__day {
    min-height: auto;
  }

  .fexk-calendar__nav,
  .fexk-calendar__today,
  .fexk-calendar__subscribe {
    width: 100%;
    text-align: center;
  }

  .fexk-calendar-popover {
    position: fixed;
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: 8px;
    width: auto;
    max-height: 70vh;
  }
}
