.calendar {
  width: min(var(--calendar-max-width), 100%);
  margin: 0 auto;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.api-status {
  min-height: 44px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: var(--border-width) solid var(--line);
  background: #fff6dc;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.api-status[hidden] {
  display: none;
}

.api-status.error {
  background: #fff0ee;
}

.api-status-copy {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-status-retry {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 11px;
  border: var(--border-thin) solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.api-status-retry:hover {
  background: var(--hover-bar);
}

/* Header & Controls */
.month-header {
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: var(--border-width) solid var(--line);
}

.month-nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -1px;
  margin: 0;
  line-height: 1;
  white-space: nowrap;
}

.nav-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  border: var(--border-width) solid var(--line);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  border-radius: 6px;
  transition: background 0.1s ease, transform 0.1s ease;
}

.nav-btn:hover,
.today-btn:hover {
  background: var(--bar-bg);
}

.nav-btn:active,
.today-btn:active {
  transform: translateY(1px);
}

.today-btn {
  height: 28px;
  padding: 0 10px;
  background: var(--paper);
  border: var(--border-width) solid var(--line);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
  margin-left: 4px;
  transition: background 0.1s ease, transform 0.1s ease;
}

.month-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.events-view-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  border: var(--border-width) solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  box-shadow: none;
  transition: background 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.events-view-btn:hover {
  background: var(--hover-bar);
  transform: translateY(-1px);
  box-shadow: 2px 2px 0 var(--line);
}

.events-view-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Weekday Bar & Calendar Grid */
.weekday-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday {
  height: 28px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  border-right: var(--border-thin) solid var(--line);
  border-bottom: var(--border-width) solid var(--line);
  background: var(--bg-muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Option 1: Inverted Ink header for Bangladesh Weekend (Friday & Saturday) */
.weekday.weekend,
.weekday:nth-child(6),
.weekday:nth-child(7) {
  background: var(--weekday-weekend-bg);
  color: var(--weekday-weekend-color);
}

.weekday:last-child {
  border-right: 0;
}

/*
  Single Day Cells
  Flush event layout with no inner padding around event pills.
*/
.day {
  height: var(--day-cell-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: var(--border-thin) solid var(--line);
  border-bottom: var(--border-thin) solid var(--line);
  background: var(--paper);
}

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

.day:nth-last-child(-n + 7) {
  border-bottom: 0;
}

.day.muted {
  background: var(--bg-muted);
  color: var(--text-muted);
}

.day-header {
  height: var(--day-header-height);
  flex: 0 0 var(--day-header-height);
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: var(--border-thin) solid var(--line);
  background: var(--paper);
}

.day.muted .day-header {
  background: var(--bg-muted);
}

.day-number {
  font-size: 17px;
  line-height: 1;
  font-weight: 900;
}

.count {
  width: 20px;
  height: 20px;
  border: var(--border-thin) solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  color: var(--text-muted);
  background: var(--paper);
}

.day.is-today .day-number {
  background: var(--today-badge-bg);
  color: var(--today-badge-color);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 14px;
  margin-left: -3px;
}

.day.is-today .day-header {
  background: var(--today-header-bg);
}

/* Category Filter Dimming */
.event.dimmed {
  opacity: 0.15;
  filter: grayscale(0.85);
  pointer-events: none;
}

.empty-space {
  flex: 1;
  background: var(--paper);
}

.day.is-loading .empty-space {
  position: relative;
}

.day.is-loading .empty-space::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 26%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f1f1f1 25%, #e3e3e3 50%, #f1f1f1 75%);
  background-size: 200% 100%;
  animation: calendar-loading 1.2s ease-in-out infinite;
}

@keyframes calendar-loading {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.day.muted .empty-space {
  background: var(--bg-muted);
}

@media (max-width: 768px) {
  .calendar {
    width: 100%;
    min-width: 0;
    border-radius: 6px;
  }

  .month-header {
    height: 44px;
    min-height: 44px;
    padding: 0 10px;
  }

  .month-title {
    font-size: 19px;
    letter-spacing: -0.5px;
  }

  .nav-btn {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .today-btn {
    height: 24px;
    padding: 0 7px;
    font-size: 10px;
  }

  .events-view-btn {
    width: 24px;
    height: 24px;
  }

  .events-view-btn svg {
    width: 13px;
    height: 13px;
  }

  .weekday {
    height: 22px;
    padding: 0 1px;
    font-size: 8.5px;
    justify-content: center;
    letter-spacing: 0.02em;
  }

  .day {
    height: 100px;
  }

  .day-header {
    height: 22px;
    flex: 0 0 22px;
    padding: 0 3px;
  }

  .day-number {
    font-size: 12px;
    font-weight: 900;
  }

  .count {
    width: 15px;
    height: 15px;
    font-size: 7.5px;
  }

  .day.is-today .day-number {
    width: 18px;
    height: 18px;
    font-size: 10px;
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .day.is-loading .empty-space::after {
    animation: none;
  }
}
