:root {
  --bg: #111315;
  --panel: #1a1d20;
  --panel-2: #22272b;
  --text: #f1f3f5;
  --muted: #a7b0b8;
  --accent: #c8a56a;
  --border: #30363d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.gallery-app {
  width: min(1200px, 100%);
}

.topbar {
  text-align: center;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.viewer-wrap {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  gap: 12px;
  align-items: stretch;
}

.viewer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  outline: none;
}

.viewer:focus-visible {
  box-shadow: 0 0 0 3px rgba(200, 165, 106, 0.35), var(--shadow);
}

.image-stage {
  height: min(72vh, 820px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0c0e10;
  position: relative;
  overflow: hidden;
}

.image-stage.grabbing,
.image-stage.grabbing img {
  cursor: grabbing;
}

.image-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  cursor: grab;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.image-stage.dragging img {
  transition: none;
}

.caption-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

.caption-left,
.caption-right {
  min-width: 0;
}

#imageTitle {
  display: block;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#imageCounter {
  color: var(--muted);
  font-weight: 700;
}

.nav-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 16px;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-btn:hover {
  transform: scale(1.02);
  background: #202428;
  border-color: #444c56;
}

.nav-btn:active {
  transform: scale(0.98);
}

.thumbs {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.thumb-btn {
  padding: 0;
  border: 2px solid transparent;
  background: var(--panel);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.thumb-btn.active {
  border-color: var(--accent);
}

.thumb-btn img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.thumb-label {
  display: block;
  padding: 10px;
  font-size: 0.92rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px;
  text-align: center;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.fullscreen-overlay.open {
  display: flex;
}

.fullscreen-stage {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.fullscreen-image {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.15s ease;
}

.fullscreen-caption {
  margin-top: 14px;
  color: #fff;
  font-size: 20px;
  text-align: center;
}

.fullscreen-counter {
  margin-top: 6px;
  color: #cfcfcf;
  font-size: 14px;
  text-align: center;
}

.fullscreen-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 46px;
  height: 46px;
  font-size: 30px;
  cursor: pointer;
}

.fullscreen-nav {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  font-size: 28px;
  cursor: pointer;
  margin: 0 18px;
}

.fullscreen-prev,
.fullscreen-next {
  flex: 0 0 auto;
}

@media (max-width: 700px) {
  body {
    padding: 12px;
  }

  .viewer-wrap {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 8px;
  }

  .nav-btn {
    font-size: 1.6rem;
    border-radius: 12px;
  }

  .image-stage {
    height: 58vh;
  }

  .caption-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .fullscreen-image {
    max-width: 96vw;
    max-height: 74vh;
  }

  .fullscreen-caption {
    font-size: 16px;
    padding: 0 14px;
  }

  .fullscreen-close {
    top: 10px;
    right: 12px;
    width: 42px;
    height: 42px;
    font-size: 26px;
  }

  .fullscreen-nav {
    width: 44px;
    height: 44px;
    font-size: 22px;
    margin: 0 8px;
  }
}