:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #182033;
  --muted: #5a6480;
  --accent: #0c6cfd;
  --accent-soft: #dbe8ff;
  --danger: #c22f2f;
  --border: #d8dfee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, #e6efff, var(--bg) 40%);
}

.app {
  width: min(900px, 92vw);
  margin: 24px auto 40px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(20, 31, 58, 0.06);
}

.actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  min-height: 56px;
  padding: 14px 18px;
  font-size: 1.06rem;
  font-weight: 600;
  flex: 1 1 220px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button.secondary {
  background: var(--accent-soft);
  color: #1542a3;
}

button[disabled] {
  opacity: 0.6;
}

.preview {
  margin-top: 14px;
  position: relative;
}

.preview img {
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #eef2fb;
  position: relative;
  z-index: 1;
}

.celebration-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.celebration-piece {
  position: absolute;
  bottom: -24px;
  font-size: 1.35rem;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.2));
  animation: celebrate-burst var(--duration) ease-out forwards;
  opacity: 0;
}

@keyframes celebrate-burst {
  0% {
    transform: translate3d(0, 0, 0) scale(0.6);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift), -140px, 0) scale(1.15);
    opacity: 0;
  }
}

.hidden {
  display: none;
}

.status {
  min-height: 1.25rem;
  margin-top: 10px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.timeline {
  display: grid;
  gap: 12px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 14, 30, 0.84);
  overscroll-behavior: contain;
}

.lightbox.hidden {
  display: none;
}

.lightbox-card {
  position: relative;
  width: min(960px, 100%);
  max-height: 90vh;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.lightbox-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.lightbox-nav img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
  touch-action: manipulation;
}

.lightbox-btn,
.lightbox-close {
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  border-radius: 999px;
  min-height: 48px;
  min-width: 48px;
  padding: 10px 14px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 2;
}

.lightbox-meta {
  margin: 0;
  color: #f2f5ff;
  font-size: 0.95rem;
}

.hour-group h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.hour-group h3 span {
  color: var(--muted);
  font-weight: 500;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.photo {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.photo:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(20, 31, 58, 0.12);
}

.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.empty {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 520px) {
  .app {
    width: 94vw;
    margin-top: 14px;
  }

  .card {
    padding: 14px;
  }

  button {
    width: 100%;
    min-height: 60px;
    font-size: 1.1rem;
  }

  .lightbox {
    padding: 12px;
  }

  .lightbox-nav {
    gap: 8px;
  }

  .lightbox-close {
    top: 8px;
    right: 8px;
  }

  .photo {
    min-height: 128px;
  }
}