.ec-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,.45);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}
.ec-overlay.ec-open { display: flex; }

.ec-modal {
  background: #fff;
  border-radius: 8px;
  width: 700px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  position: relative;
}

.ec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.ec-header-title {
  font-size: 18px;
  font-weight: bold;
}
.ec-nav { display: flex; align-items: center; gap: 12px; }
.ec-nav button {
  background: none; border: 1px solid #ccc; border-radius: 4px;
  padding: 4px 10px; cursor: pointer; font-size: 16px;
}
.ec-nav button:hover { background: #f0f0f0; }
.ec-close {
  background: none; border: none; font-size: 24px;
  cursor: pointer; color: #666; line-height: 1;
}
.ec-close:hover { color: #333; }

.ec-grid-wrap {
  position: relative;
  overflow: hidden;
}
.ec-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid #e0e0e0;
  border-left: 1px solid #e0e0e0;
  table-layout: fixed;
}
.ec-dow {
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  padding: 6px 0;
  background: #f5f5f5;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}
.ec-dow:first-child { color: #e53935; }
.ec-dow:last-child { color: #1e88e5; }

.ec-cell {
  min-height: 80px;
  border-right: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  padding: 2px;
  vertical-align: top;
  overflow: hidden;
}
.ec-cell.ec-outside { background: #fafafa; }
.ec-cell.ec-today { background: #fff8e1; }
.ec-day-num {
  font-size: 12px;
  padding: 2px 4px;
  color: #333;
}
.ec-cell:nth-child(7n+1) .ec-day-num { color: #e53935; }
.ec-cell:nth-child(7n) .ec-day-num { color: #1e88e5; }

.ec-event {
  display: block;
  font-size: 11px;
  padding: 1px 3px;
  margin: 1px 0;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  color: #fff;
}
.ec-event.ec-cat-1 { background: #43a047; }
.ec-event.ec-cat-2 { background: #1e88e5; }
.ec-event.ec-cat-other { background: #fb8c00; }
.ec-event.ec-past { opacity: .45; }

.ec-popup {
  display: none;
  position: fixed;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  padding: 12px;
  z-index: 10001;
  max-width: 300px;
  font-size: 13px;
}
.ec-popup.ec-popup-open { display: block; }
.ec-popup-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 6px;
  color: #333;
}
.ec-popup-meta {
  color: #666;
  margin-bottom: 4px;
  line-height: 1.5;
}
.ec-popup-summary {
  color: #444;
  margin-bottom: 10px;
  line-height: 1.5;
}
.ec-popup-detail {
  display: inline-block;
  background: #1e88e5;
  color: #fff;
  text-decoration: none;
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 13px;
}
.ec-popup-detail:hover { background: #1565c0; }

.ec-cal-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2px solid #035193;
  border-top: 5px solid #035193;
  border-radius: 3px;
  vertical-align: middle;
  position: relative;
  cursor: pointer;
  margin-left: 6px;
  background:
    linear-gradient(#035193, #035193) 3px 4px / 4px 1px no-repeat,
    linear-gradient(#035193, #035193) 9px 4px / 4px 1px no-repeat,
    linear-gradient(#035193, #035193) 15px 4px / 4px 1px no-repeat,
    linear-gradient(#035193, #035193) 3px 9px / 4px 1px no-repeat,
    linear-gradient(#035193, #035193) 9px 9px / 4px 1px no-repeat,
    linear-gradient(#035193, #035193) 15px 9px / 4px 1px no-repeat,
    linear-gradient(#035193, #035193) 3px 14px / 4px 1px no-repeat,
    linear-gradient(#035193, #035193) 9px 14px / 4px 1px no-repeat;
}
.ec-cal-icon::before,
.ec-cal-icon::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 5px;
  background: #035193;
  top: -7px;
  border-radius: 1px;
}
.ec-cal-icon::before { left: 5px; }
.ec-cal-icon::after { right: 5px; }

@media screen and (max-width: 768px) {
  .ec-overlay { align-items: flex-start; padding-top: 3vh; }
  .ec-modal { max-height: 60vh; }
  .ec-cell { min-height: 50px; }
  .ec-event { font-size: 9px; }
  .ec-day-num { font-size: 10px; }
  .ec-header-title { font-size: 15px; }
  .ec-popup {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    width: 100%;
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    max-height: 40vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding-bottom: 20px;
  }
}
