* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
}

:root {
  color-scheme: dark;
}

html {
  /* Prevent horizontal overscroll / bounce from triggering navigation */
  overscroll-behavior-x: none;
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  background: #111;
  color: #eaeaea;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: min(1200px, calc(100% - 24px));
  margin: 20px auto;
}

.toolbar {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.searchBox {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 6px;
}

#searchInput {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #eaeaea;
  font-size: 1rem;
  padding: 10px 12px;
}

#searchInput::placeholder {
  color: #777;
}

#searchInput:disabled {
  color: #666;
  cursor: not-allowed;
}

.searchButton {
  background: #2a2a2a;
  border: 1px solid #333;
  color: #ddd;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  /* Removes 300ms tap delay on mobile */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.searchButton:hover:not(:disabled) {
  background: #353535;
}

.searchButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.similarChip[hidden] {
  display: none;
}

.similarChip {
  position: relative;
  flex-shrink: 0;
  align-self: center;
  padding: 0;
  border: none;
  background: none;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  margin-left: 2px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.similarChipImg {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
}

.similarChip::after {
  content: "×";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.15s;
}

.similarChip:hover::after {
  opacity: 1;
}

.gallery {
}

.yearGroup {
  margin-bottom: 36px;
  /* Skip painting off-screen year groups — big perf win for large galleries.
     Falls back gracefully on browsers that don't support it. */
  content-visibility: auto;
  /* "auto N" = use N as estimate initially, remember actual size after first render */
  contain-intrinsic-block-size: auto 3000px;
}

.yearHeader {
  font-size: 1.6rem;
  font-weight: 600;
  color: #ccc;
  margin-bottom: 10px;
}

.monthHeader {
  font-size: 1rem;
  font-weight: 500;
  color: #666;
  margin: 16px 0 8px;
}

.monthHeader:first-of-type {
  margin-top: 0;
}

.galleryRow {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.galleryItem {
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: none;
  background: #1b1b1b;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  /* Removes 300ms tap delay and prevents text selection on long-press */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
}

.galleryItem img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  /* Prevent iOS long-press image save dialog from interfering with taps */
  pointer-events: none;
}

.similarBtn {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.galleryItem:hover .similarBtn {
  opacity: 1;
}

.similarBtn svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}

@media (pointer: coarse) {
  .similarBtn {
    display: none;
  }
}

/* ── PhotoSwipe overrides ──────────────────────────────────────────────────── */

:root {
  /* Dark placeholder instead of grey while image loads */
  --pswp-placeholder-color: #111;
}

.pswp__button--similar-button {
  display: none;
}

.pswp__button--download-button .pswp__icn,
.pswp__button--similar-button .pswp__icn {
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@media (pointer: coarse) {
  .pswp__button--similar-button {
    display: block;
  }

  /* Hide nav arrows on touch devices — swipe to navigate instead */
  .pswp__button--arrow {
    display: none !important;
  }
}

.pswp__button--arrow {
  opacity: 0 !important;
  transition: opacity 0.2s;
}

.pswp__button--arrow:hover {
  opacity: 1 !important;
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 16px, 1200px);
    margin: 12px auto;
  }

  .yearHeader {
    font-size: 1.3rem;
  }
}
