* {
  box-sizing: border-box;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: #f7f7f7;
  color: #222;
}

body {
  margin: 0;
}

.site-header {
  padding: 2rem 1rem 1rem;
  text-align: center;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 700;
}

.subtitle {
  margin: 0.5rem 0 0;
  color: #666;
}

main {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto 3rem;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  margin: 1rem 0;
  background: rgba(247, 247, 247, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid #ddd;
  border-radius: 14px;
}

button {
  appearance: none;
  border: 1px solid #bbb;
  border-radius: 999px;
  background: white;
  color: #222;
  padding: 0.55rem 0.85rem;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: #eee;
}

button:active {
  transform: translateY(1px);
}

.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #444;
}

.speed-control input {
  width: 4.5rem;
  padding: 0.45rem;
  border: 1px solid #bbb;
  border-radius: 8px;
  font: inherit;
}

.status {
  min-height: 1.5rem;
  text-align: center;
  color: #555;
  margin-bottom: 1rem;
}

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

.photo-card {
  background: white;
  border: 1px solid #ddd;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

.photo-card label {
  display: block;
  cursor: pointer;
}

.photo-card input {
  position: absolute;
  margin: 0.65rem;
  transform: scale(1.25);
  accent-color: #222;
}

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

.photo-title {
  display: block;
  padding: 0.55rem 0.65rem;
  font-size: 0.92rem;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #050505;
  color: white;
}

.hidden {
  display: none;
}

.viewer-topbar {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.82);
}

.viewer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.viewer button {
  border-color: #555;
  background: #1f1f1f;
  color: white;
}

.viewer button:hover {
  background: #333;
}

.slide-counter {
  min-width: 7rem;
  color: #ddd;
}

.slide-frame {
  display: grid;
  grid-template-rows: 1fr auto;
  margin: 0;
  min-height: 0;
}

#slideImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  min-height: 0;
}

#slideTitle {
  padding: 0.75rem 1rem 1rem;
  text-align: center;
  color: #ddd;
  background: rgba(0, 0, 0, 0.65);
}

@media (max-width: 640px) {
  .viewer-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .viewer-buttons {
    justify-content: flex-start;
  }

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