*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #fff;
  --text: #111;
  --caption: #888;
  --col-width: 220px;
  --gap: 10px;
  --padding: 16px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 13px;
  line-height: 1.6;
}

/* grid */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--padding);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--col-width), 1fr));
  gap: var(--gap);
  align-items: start;
}

.work {
  cursor: pointer;
}

.work img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.2s;
}

.work:hover img {
  opacity: 0.85;
}

/* hide inline text — shown only in lightbox */
.work p {
  display: none;
}


/* ── lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}

.lightbox.open {
  opacity: 1;
  pointer-events: all;
}

.lb-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: #555;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  transition: color 0.15s;
}

.lb-close:hover { color: #fff; }

.lb-body {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 3.5rem 3rem 1rem;
  gap: 3rem;
  overflow: hidden;
  min-height: 0;
}

.lb-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.lb-img-wrap img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  display: block;
}

.lb-caption {
  width: 220px;
  flex-shrink: 0;
  color: var(--caption);
  font-size: 13px;
  line-height: 1.75;
  align-self: flex-start;
  padding-top: 0.25rem;
  overflow-y: auto;
}

.lb-filename {
  color: #555;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.lb-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 0.8rem;
}

.lb-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  transition: color 0.15s;
}

.lb-btn:hover { color: #fff; }

.lb-count {
  color: #444;
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* mobile */
@media (max-width: 600px) {
  :root {
    --col-width: 160px;
    --gap: 6px;
    --padding: 6px;
  }

  .lb-body {
    flex-direction: column;
    align-items: flex-start;
    padding: 3rem 1rem 0.5rem;
    gap: 1rem;
    overflow-y: auto;
  }

  .lb-caption {
    width: 100%;
    align-self: auto;
  }

  .lb-img-wrap img {
    max-height: 55vh;
  }
}
