.kal-msg {
  color: #888;
  font-size: 0.9rem;
  font-style: italic;
  padding: 0.5rem 0;
}

.kal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-family: sans-serif;
  font-size: 0.82rem;
}

.kal-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border-radius: 50%;
  vertical-align: middle;
}

.kal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.kal-nav button {
  padding: 0.25rem 0.65rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: none;
  color: #444;
  cursor: pointer;
  font-size: 1rem;
}

.kal-nav button:hover { background: #f5f5f5; }
.kal-nav button:disabled { cursor: wait; opacity: 0.55; }

.kal-nav h3 {
  color: #2c2c2c;
  font-family: sans-serif;
  font-size: 1rem;
}

.kal-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: sans-serif;
  font-size: 0.82rem;
}

.kal-grid th {
  padding: 0.3rem 0;
  border-bottom: 1px solid #eee;
  color: #888;
  font-weight: 600;
  text-align: center;
}

.kal-grid td {
  width: calc(100% / 7);
  height: calc(1.75rem + var(--kal-visible-events, 6) * 1.3rem);
  padding: 0.25rem;
  border: 1px solid #f0e8e8;
  cursor: default;
  vertical-align: top;
}

.kal-grid td.other-month { background: #fafaf8; }
.kal-grid td.today { background: #fff7f7; }

.kal-day-num {
  color: #aaa;
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: right;
}

.kal-day-header {
  display: flex;
  align-items: center;
  height: 1.4rem;
}

.kal-day-header .kal-day-num { margin-left: auto; }

.kal-event-list {
  height: calc(var(--kal-visible-events, 6) * 1.3rem);
  overflow: hidden;
}

.kal-more {
  padding: 0;
  border: 0;
  background: transparent;
  color: #666;
  cursor: pointer;
  font-size: 0.67rem;
  line-height: 1;
  text-decoration: underline;
}

.kal-more:hover { color: #222; }

.kal-grid td.today .kal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e30613;
  color: #fff;
}

.kal-chip {
  display: block;
  width: 100%;
  height: calc(1.3rem - 2px);
  margin-top: 2px;
  padding: 1px 4px;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kal-chip:hover { opacity: 0.85; }
.kal-grid-wrap { overflow-x: auto; }

.kal-popup {
  display: none;
  position: fixed;
  z-index: 100;
  width: 300px;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  font-family: sans-serif;
  font-size: 0.84rem;
}

.kal-popup.visible { display: block; }

.kal-popup-header {
  display: flex;
  position: sticky;
  z-index: 1;
  top: 0;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem 0.5rem;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
}

.kal-popup-title { color: #2c2c2c; font-size: 0.88rem; font-weight: 700; }

.kal-popup-close {
  flex-shrink: 0;
  margin-left: 0.5rem;
  padding: 0.15rem 0.3rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}

.kal-popup-close:hover { background: #f0f0f0; color: #555; }

.kal-popup-events {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem 0.7rem;
}

.kal-popup-event {
  padding: 0.38rem 0.6rem;
  border-left: 3px solid #ccc;
  border-radius: 0 5px 5px 0;
}

.kal-popup-event-title { color: #1a1a1a; font-size: 0.84rem; font-weight: 600; line-height: 1.35; }
.kal-popup-event-detail { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.2rem; color: #666; font-size: 0.75rem; }
.kal-popup-event-cal { display: inline-block; margin-top: 0.28rem; padding: 0.1rem 0.45rem; border-radius: 10px; color: #fff; font-size: 0.67rem; font-weight: 700; line-height: 1.6; }

.kal-year-grid {
  display: grid;
  grid-template-columns: repeat(var(--kal-cols, 3), 1fr);
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.kal-mini-month { min-width: 0; overflow-x: auto; }
.kal-mini-title { margin-bottom: 0.3rem; color: #2c2c2c; font-family: sans-serif; font-size: 0.8rem; font-weight: 600; text-align: center; }

.kal-mini-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: sans-serif;
  font-size: 0.72rem;
}

.kal-mini-grid th { padding: 0.1rem 0; overflow: hidden; color: #bbb; font-weight: 600; text-align: center; }
.kal-mini-grid td { padding: 1px 0; overflow: hidden; cursor: default; text-align: center; vertical-align: middle; }
.kal-mini-grid td.kal-mini-has-events { cursor: pointer; }
.kal-mini-grid td.kal-mini-has-events:hover { border-radius: 3px; background: #f0f0f0; }

.kal-mini-day { display: inline-flex; align-items: center; justify-content: center; width: 1.7em; height: 1.7em; color: #444; font-size: 0.72rem; line-height: 1; }
.kal-mini-day.kal-mini-today { border-radius: 50%; background: #e30613; color: #fff; }
.kal-dot-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; margin-top: 1px; overflow: hidden; }
.kal-dot { display: inline-block; flex-shrink: 0; width: 5px; height: 5px; border-radius: 50%; }
.kal-dot-more { align-self: center; color: #aaa; font-size: 0.55rem; line-height: 1; }

@media (max-width: 480px) {
  .kal-grid { min-width: calc(100% * 7 / 5); font-size: 0.72rem; }
  .kal-grid th { padding: 0.15rem 0; }
  .kal-grid td { padding: 0.1rem; }
  .kal-chip { padding: 1px 2px; font-size: 0.6rem; }
  .kal-day-num { font-size: 0.65rem; }
  .kal-grid td.today .kal-day-num { width: 17px; height: 17px; font-size: 0.65rem; }
  .kal-popup { width: min(300px, calc(100vw - 16px)); }
  .kal-year-grid { grid-template-columns: 1fr; }
  .kal-mini-grid { min-width: calc(100% * 7 / 5); }
}

@media (min-width: 481px) and (max-width: 720px) {
  .kal-year-grid { grid-template-columns: repeat(2, 1fr); }
}
