:root {
  --ink: #171717;
  --muted: #777;
  --line: #d8d8d8;
  --page-pad: clamp(12px, 2vw, 28px);
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
}

html {
  background: #fff;
  color: var(--ink);
  font-family: Arial, "Helvetica Neue", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  font-stretch: normal;
  font-weight: 400;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}

button {
  font: inherit;
  font-weight: 400;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 46px;
  padding: 8px var(--page-pad);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
}

.wordmark {
  width: max-content;
  font-size: 0.9rem;
}

.view-controls {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 10px;
}

.view-options {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
}

.view-button,
.filter-clear {
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
}

.view-button:hover,
.filter-clear:hover {
  color: var(--ink);
}

.view-button.is-active {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.view-button:focus-visible,
.filter-clear:focus-visible,
.size-range:focus-visible,
.date-filter input:focus-visible,
.image-button:focus-visible,
.lightbox-close:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.image-count {
  color: var(--muted);
  font-size: 0.72rem;
}

.size-control,
.date-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.65rem;
  white-space: nowrap;
}

.date-filter {
  position: relative;
}

.date-filter summary {
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.65rem;
  list-style: none;
}

.date-filter summary::-webkit-details-marker {
  display: none;
}

.date-filter[open] summary {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.date-filter-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 9px);
  right: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 7px 9px;
  min-width: 190px;
  padding: 9px;
  border: 1px solid var(--line);
  background: #fff;
}

.date-filter-panel label {
  display: contents;
}

.date-filter-panel span {
  align-self: center;
}

.size-range {
  width: 76px;
  height: 10px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.size-range::-webkit-slider-runnable-track {
  height: 1px;
  background: #888;
}

.size-range::-webkit-slider-thumb {
  width: 8px;
  height: 8px;
  margin-top: -3.5px;
  appearance: none;
  border: 0;
  border-radius: 0;
  background: var(--ink);
}

.size-range::-moz-range-track {
  height: 1px;
  background: #888;
}

.size-range::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
}

.date-filter input {
  width: 118px;
  padding: 1px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
}

.filter-clear {
  grid-column: 2;
  justify-self: start;
  color: var(--muted);
}

main {
  padding: 18px var(--page-pad) 60px;
}

.month-section {
  margin-bottom: 34px;
}

.month-heading {
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
}

.masonry {
  display: grid;
  grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
  gap: clamp(8px, 1vw, 14px);
  align-items: start;
}

.masonry-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: clamp(12px, 1.4vw, 20px);
}

.image-item {
  min-width: 0;
  margin: 0;
}

.image-button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #f2f2f2;
  cursor: pointer;
}

.image-button img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  object-fit: cover;
  transition: opacity 0.16s ease;
}

.image-button.is-loading {
  aspect-ratio: var(--ratio, 4/5);
}

.image-button.is-loading img {
  opacity: 0;
}

.image-item figcaption {
  overflow: hidden;
  margin-top: 5px;
  color: #555;
  font-size: 0.65rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  min-height: 50vh;
  margin: 0;
  padding-top: 30vh;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 0.7rem;
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
}

.lightbox::backdrop {
  background: #000;
}

.lightbox figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 24px;
}

.lightbox-viewer {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: default;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: inherit;
  object-fit: contain;
  transform-origin: center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

.lightbox-viewer.is-zoomed {
  cursor: grab;
}

.lightbox-viewer.is-zoomed:active {
  cursor: grabbing;
}

.lightbox-viewer.is-zoomed .lightbox-image {
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.zoom-level {
  position: fixed;
  z-index: 2;
  top: 11px;
  left: 12px;
  color: #aaa;
  font-size: 0.62rem;
  pointer-events: none;
}

.zoom-level:empty {
  display: none;
}

.lightbox figcaption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
  color: #aaa;
  font-size: 0.65rem;
}

.lightbox-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox time {
  white-space: nowrap;
}

.lightbox-close {
  position: fixed;
  z-index: 2;
  top: 8px;
  right: 10px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

@media (max-width: 559px) {
  .topbar {
    grid-template-columns: 1fr auto 1fr;
    min-height: 42px;
  }

  .view-controls {
    grid-column: 2;
    grid-row: 1;
  }

  .view-options {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    flex-wrap: wrap;
    margin-top: 6px;
  }

  .date-filter-panel {
    right: auto;
    left: 0;
  }

  .month-section {
    margin-bottom: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
