:root {
  --bg-top: #090a0e;
  --bg-bottom: #16181f;
  --panel: rgba(16, 19, 25, 0.78);
  --line: rgba(232, 234, 244, 0.22);
  --text-main: #f2f3f8;
  --text-muted: #b9bed4;
  --accent: #f3cb70;
  --tile-size: 186px;
  --tile-gap: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--text-main);
  background: radial-gradient(circle at 15% 10%, #1b2334, #11131a 42%, #08090c 100%);
  font-family: "Space Grotesk", sans-serif;
}

.stage-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.17;
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
}

.topbar {
  position: fixed;
  inset: 14px 16px auto 16px;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  background: var(--panel);
}

.brand-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.brand h1 {
  margin: 2px 0 0;
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#count-pill {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: #12151f;
  background: var(--accent);
  border-radius: 999px;
  padding: 7px 11px;
}

#source-link {
  color: var(--text-main);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  text-decoration: none;
}

.viewport {
  position: fixed;
  inset: 0;
  cursor: grab;
  touch-action: none;
}

.viewport.dragging {
  cursor: grabbing;
}

.canvas-wrapper {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.gallery-grid {
  position: relative;
}

.tile {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: #10131a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.tile:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(244, 205, 116, 0.8);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.03) contrast(1.03);
  user-select: none;
  pointer-events: none;
}

.tile-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px;
  background: linear-gradient(to top, rgba(3, 4, 6, 0.82), transparent);
  color: var(--text-main);
}

.tile-title {
  display: block;
  font-size: 12px;
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
}

.controls {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 25;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--panel);
  backdrop-filter: blur(8px);
}

.control-group {
  display: flex;
  gap: 8px;
}

.control-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text-main);
  background: rgba(24, 28, 38, 0.85);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  cursor: pointer;
}

.control-btn:hover {
  border-color: rgba(244, 205, 116, 0.9);
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  background: rgba(2, 4, 8, 0.75);
  backdrop-filter: blur(5px);
}

.detail-overlay.is-hidden {
  display: none;
}

.close-detail {
  position: absolute;
  top: 16px;
  right: 16px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--text-main);
  background: rgba(13, 15, 20, 0.8);
  cursor: pointer;
}

.detail-shell {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-columns: minmax(290px, 1fr) minmax(230px, 300px);
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 12, 18, 0.96);
}

.detail-shell img {
  width: 100%;
  height: min(78vh, 760px);
  object-fit: contain;
  background: #0f1118;
  border-radius: 10px;
}

.detail-shell img.is-loading {
  opacity: 0.65;
}

.detail-copy {
  overflow: auto;
}

.detail-year {
  margin: 0 0 4px;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.detail-copy h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
}

.detail-location,
.detail-description,
.detail-tags {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-muted);
}

.detail-copy a {
  color: var(--text-main);
}

@media (max-width: 860px) {
  :root {
    --tile-size: 150px;
    --tile-gap: 12px;
  }

  .tile-overlay {
    display: none;
  }

  .topbar {
    inset: 10px 10px auto;
    padding: 12px;
  }

  .controls {
    left: 10px;
    right: 10px;
    bottom: 10px;
    flex-direction: column;
    align-items: stretch;
  }

  .detail-shell {
    grid-template-columns: 1fr;
    max-height: calc(100vh - 20px);
    width: calc(100vw - 20px);
  }

  .detail-shell img {
    height: 48vh;
  }
}
