* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.calendar-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.calendar-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, auto) auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 760;
}

.brand h1 a {
  color: inherit;
  text-decoration: none;
}

.brand h1 a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.brand .powered-by {
  margin-top: 3px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
}

.brand .range {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-links {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.viewer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.viewer-link {
  min-width: 76px;
  padding: 0 12px;
  font-weight: 650;
}

.viewer-link:hover {
  border-color: var(--accent);
}

.period-title {
  min-width: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 760;
  white-space: nowrap;
}

.summary {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.metric {
  min-width: 92px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric strong {
  display: block;
  font-size: 16px;
  line-height: 1.1;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

.calendar-content {
  min-width: 0;
  padding: 16px;
}

.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-deep);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.weekdays span {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  text-align: center;
}

.calendar-grid {
  background: var(--line);
  gap: 1px;
}

.calendar-day {
  position: relative;
  min-width: 0;
  min-height: 152px;
  padding: 10px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
}

.calendar-day.has-images {
  background: var(--bg);
  color: #fff;
}

.calendar-day.has-images::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(20, 0, 0, 0.3), rgba(10, 0, 0, 0.78)),
    linear-gradient(90deg, rgba(30, 0, 0, 0.45), rgba(0, 0, 0, 0.15));
  pointer-events: none;
}

.calendar-day.has-summary {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
}

.calendar-day.empty {
  background: var(--calendar-empty);
}

.calendar-day:hover {
  outline: 2px solid var(--accent-outline);
  outline-offset: -2px;
}

.day-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.day-number {
  font-size: 16px;
  font-weight: 760;
}

.message-count {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-text);
  font-size: 12px;
  white-space: nowrap;
}

.overview {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--text-2);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

.calendar-day.has-images .overview {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.team-count {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  align-self: end;
}

.calendar-day.has-images .team-count {
  color: rgba(255, 255, 255, 0.72);
}

.day-slideshow {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.day-slideshow img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.03);
  animation: day-image-dissolve calc(var(--slide-count) * 6s) infinite ease-in-out;
  animation-delay: calc(var(--slide-index) * 6s);
}

.day-slideshow img:first-child {
  opacity: 1;
}

.day-slideshow img:only-child {
  opacity: 1;
  animation: none;
}

@keyframes day-image-dissolve {
  0% {
    opacity: 1;
    transform: scale(1.03);
  }

  22% {
    opacity: 1;
    transform: scale(1.055);
  }

  36% {
    opacity: 0;
    transform: scale(1.075);
  }

  100% {
    opacity: 0;
    transform: scale(1.075);
  }
}

.empty-state {
  margin: 32px auto;
  max-width: 460px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .calendar-topbar {
    grid-template-columns: 1fr;
  }

  .summary {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .view-links {
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .calendar-topbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .calendar-content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .calendar-content {
    padding: 10px;
  }

  .weekdays span {
    padding: 8px 3px;
    font-size: 11px;
  }

  .calendar-day {
    min-height: 118px;
    padding: 7px;
  }

  .overview {
    -webkit-line-clamp: 4;
    font-size: 12px;
  }

  .message-count,
  .team-count {
    font-size: 11px;
  }
}

@media (max-width: 520px) {
  .summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .calendar-panel {
    overflow-x: auto;
  }

  .weekdays,
  .calendar-grid {
    min-width: 720px;
  }
}
