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

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  color: var(--text-main);
  background: radial-gradient(circle at 15% 10%, #1b2334, #11131a 42%, #08090c 100%);
  font-family: "Noto Sans Hebrew", 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: center;
  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 {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 0;
}

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

.count-caption {
  margin: 0;
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 2px;
  direction: rtl;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

#source-link {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

#count-number {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  margin-inline-end: 5px;
}

#count-number,
.count-label,
.count-from {
  white-space: nowrap;
}

#source-link:hover {
  color: var(--text-main);
}

.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: 0;
  border-radius: 11px;
  overflow: hidden;
  background: #10131a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tile:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}

.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: 13px;
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
}

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

.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);
}

.control-btn:focus,
.control-btn:focus-visible {
  outline: none;
}

.control-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--line);
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  font-family: Arial, sans-serif;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.icon-btn svg {
  width: 14px;
  height: 14px;
  display: block;
  fill: currentColor;
}

.auto-pan-btn {
  font-size: 0;
}

.auto-pan-btn.is-paused {
  opacity: 0.86;
}

.auto-pan-btn.is-paused:hover {
  border-color: var(--line);
}

.zoom-control {
  position: fixed;
  left: 16px;
  bottom: 18px;
  transform: none;
  z-index: 31;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  backdrop-filter: blur(8px);
  background: rgba(16, 19, 25, 0.74);
}

.zoom-btn {
  appearance: none;
  display: inline-block;
  width: 52px;
  height: 46px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text-main);
  background: transparent;
  font-family: "Noto Sans Hebrew", sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

#zoom-in-button {
  order: 0;
}

#zoom-out-button {
  order: 1;
}

.zoom-btn:last-child {
  border-bottom: 0;
}

.zoom-btn:hover {
  box-shadow: inset 0 0 0 1px rgba(244, 205, 116, 0.9);
}

.zoom-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  background: rgba(2, 4, 8, 0.75);
  backdrop-filter: blur(5px);
}

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

.close-icon-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
}

.detail-shell {
  width: min(1180px, 100%);
  max-height: 100%;
  display: grid;
  grid-template-columns: minmax(290px, 1fr) minmax(230px, 300px);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 12, 18, 0.96);
  position: relative;
  align-items: stretch;
}

.detail-image-stage {
  width: 100%;
  height: min(66dvh, 680px);
  max-height: calc(100dvh - 120px);
  min-width: 0;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-image-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  border-radius: 10px;
  display: block;
  transition: opacity 0.22s ease;
}

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

.detail-image-stage img.is-fading-in {
  opacity: 0;
}

.detail-copy {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  overflow: auto;
  direction: rtl;
  text-align: right;
  padding-top: 32px;
  min-height: 0;
}

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

.detail-description {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-muted);
}

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

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

  .tile-overlay {
    display: none;
  }

  .topbar {
    inset: 10px 10px auto;
    padding: 12px;
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .meta-row {
    justify-content: flex-start;
  }

  .zoom-control {
    left: 10px;
    bottom: 10px;
    transform: none;
  }

  .detail-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    max-height: 100%;
    width: 100%;
    gap: 10px;
    padding: 8px;
  }

  .detail-image-stage {
    height: min(44dvh, 380px);
    max-height: 44dvh;
    min-height: 220px;
  }

  .detail-copy {
    gap: 8px;
    padding-top: 0;
    padding-bottom: 6px;
    max-height: min(34dvh, 260px);
  }
}
