* { box-sizing: border-box; }

:root {
  --bg: #111;
  --panel: #1b1b1b;
  --panel-2: #242424;
  --text: #eee;
  --muted: #aaa;
  --border: #333;
  --gap: 14px;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { padding-bottom: 40px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 22px;
  background: rgba(17,17,17,.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.site-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.search input {
  width: min(320px, 45vw);
  padding: 8px 11px;
  border: 1px solid #444;
  border-radius: 7px;
  background: #202020;
  color: var(--text);
  outline: none;
}

.search input:focus { border-color: #777; }

.slide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
  padding: 22px;
  max-width: 1800px;
  margin: auto;
}

.slide-card {
  min-width: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--panel);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform .12s ease, border-color .12s ease;
}

.slide-card:hover {
  transform: translateY(-2px);
  border-color: #777;
}

.slide-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
}

.slide-label {
  display: block;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--muted);
}

/* Full-screen viewer */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
  background: rgba(0,0,0,.96);
}

.viewer[hidden] { display: none; }

.viewer-content {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.slide-area {
  position: absolute;
  top: 10vh;
  left: 0;
  width: 100%;
  height: 60vh;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: visible;
}

.slide-frame {
  position: relative;
  flex: 0 0 auto;
  width: 1px;
  height: 1px;
}

.slide-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  box-shadow: 0 8px 35px rgba(0,0,0,.35);
}

.notes[hidden] {
  display: none !important;
}

.notes {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  min-width: 0;
  max-height: 26vh;
  display: flex;
  flex-direction: column;
  background: #181818;
  border: 1px solid #3d3d3d;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 5px 25px rgba(0,0,0,.25);
}

#notesText {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 22px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #e5e5e5;
}

/* Navigation is attached to the displayed image. */
.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 82px;
  border: 2px solid #aaa;
  border-radius: 8px;
  color: #fff;
  background: rgba(20,20,20,.92);
  cursor: pointer;
  box-shadow: 0 3px 15px rgba(0,0,0,.5);
  font-size: 58px;
  font-weight: 300;
  line-height: .8;
  padding: 0 0 7px 0;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.nav.prev { left: -72px; }
.nav.next { right: -72px; }

.nav:hover {
  background: #303030;
  border-color: #fff;
}

.nav:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.nav:active {
  transform: translateY(-50%) scale(.96);
}

.close {
  position: absolute;
  z-index: 10;
  top: 14px;
  left: -72px;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #aaa;
  border-radius: 8px;
  color: #fff;
  background: rgba(20,20,20,.94);
  cursor: pointer;
  box-shadow: 0 3px 15px rgba(0,0,0,.5);
  font-size: 42px;
  font-weight: 300;
  line-height: 1;
  padding: 0 0 4px 0;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.close:hover {
  background: #303030;
  border-color: #fff;
}

.close:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.close:active {
  transform: scale(.96);
}

@media (max-width: 900px) {
  .slide-area {
    top: 8vh;
    height: 60vh;
  }

  .nav {
    width: 48px;
    height: 68px;
    font-size: 48px;
  }

  .nav.prev { left: -58px; }
  .nav.next { right: -58px; }

  .close {
    top: 12px;
    left: -58px;
  }

  .notes {
    max-height: 25vh;
  }
}

@media (max-width: 600px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .search input { width: 100%; }

  .slide-grid {
    padding: 12px;
    gap: 8px;
  }

  .slide-area {
    top: 8vh;
    height: 58vh;
  }

  .close {
    width: 48px;
    height: 48px;
    font-size: 36px;
    top: 10px;
    left: -50px;
  }

  .nav {
    width: 44px;
    height: 58px;
    font-size: 44px;
  }

  .nav.prev { left: -50px; }
  .nav.next { right: -50px; }

  #notesText {
    padding: 14px 16px;
    font-size: 14px;
  }
}
