:root {
  color-scheme: dark;
  --bg: #071016;
  --bg-soft: #0e1a22;
  --surface: rgba(12, 23, 31, .86);
  --surface-strong: #132532;
  --line: rgba(188, 232, 249, .18);
  --text: #f5fbff;
  --muted: #a9bfca;
  --cyan: #41C0F0;
  --cyan-soft: #dff6ff;
  --danger: #ff5c7a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 15% 0%, rgba(65, 189, 229, .18), transparent 34%),
    linear-gradient(180deg, #071016 0%, #0a141b 54%, #050a0e 100%);
  color: var(--text);
  font-family: "Bai Jamjuree", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--cyan);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  grid-template-columns: 22px minmax(0, 1fr) 22px;
  align-items: center;
  column-gap: 6px;
  text-align: center;
}

.icon-button::after {
  content: "";
  width: 22px;
}

.icon-button i {
  grid-column: 1;
  justify-self: start;
  font-size: 17px;
}

.icon-button span {
  grid-column: 2;
  justify-self: center;
  font-size: 13px;
  font-weight:bold;
}

button:hover,
a:hover {
  border-color: var(--cyan);
}

button:disabled {
  opacity: .3;
  cursor: not-allowed;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(190px, 300px) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 22, .88);
  backdrop-filter: blur(18px);
}

.brand {
  display: block;
  min-width: 0;
}

.brand img {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
}

.gallery-meta {
  min-width: 0;
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.15;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

main {
  width: min(1660px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.status {
  color: var(--muted);
  padding: 42px 0;
  text-align: center;
}

.masonry {
  column-count: 4;
  column-gap: 4px;
}

.photo-card {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0;
  break-inside: avoid;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.photo-card img,
.video-tile {
  width: 100%;
  display: block;
}

.photo-card img,
.video-thumb {
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
}

.video-tile {
  min-height: 210px;
  padding: 18px;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  color: var(--cyan-soft);
  background:
    linear-gradient(135deg, rgba(65, 189, 229, .22), transparent 48%),
    #0a151d;
}

.play-icon {
  width: 66px;
  height: 66px;
  display: inline-grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(3, 10, 14, .42);
  color: var(--cyan-soft);
  font-size: 36px;
  font-weight: 700;
}

.video-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: rgba(255, 255, 255, .9);
  font-size: 48px;
  text-shadow: 0 3px 18px rgba(0, 0, 0, .58);
}

.media-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(3, 10, 14, .78);
  color: var(--cyan-soft);
  font-size: 12px;
  font-weight: 700;
}

.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  position: relative;
}

.photo-open:hover img,
.photo-open:hover .video-tile {
  filter: brightness(1.08);
}

.photo-select {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-height: 0;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  backdrop-filter: none;
}

.photo-select i {
  color: rgba(255, 255, 255, .58);
  font-size: 24px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .55));
}

.photo-card.selected {
  border-color: transparent;
  box-shadow: none;
}

.photo-card.selected .photo-select {
  background: transparent;
  color: var(--cyan);
}

.photo-card.selected .photo-select i {
  color: var(--cyan);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  overflow: hidden;
  background: rgba(2, 6, 9, .96);
  touch-action: none;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img,
.lightbox video {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
  object-position: center center;
  margin: auto;
}

.lightbox img {
  display: block;
  pointer-events: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 48px;
  height: 48px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(3, 10, 14, .28);
  color: rgba(255, 255, 255, .88);
  font-size: 34px;
}

.lightbox-prev {
  left: max(8px, env(safe-area-inset-left));
}

.lightbox-next {
  right: max(8px, env(safe-area-inset-right));
}

.lightbox-toolbar {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.lightbox-close,
.lightbox-download {
  min-width: 0;
  pointer-events: auto;
}

.lightbox-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-height: 0;
  padding: 0;
  border-color: rgba(65, 192, 240, .42);
  border-radius: 999px;
  background: rgba(3, 10, 14, .5);
  color: var(--cyan);
  font-size: 28px;
}

.lightbox-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  text-decoration: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 28px));
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .masonry {
    column-count: 3;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(128px, 44%) minmax(0, 1fr);
    padding: 12px;
    gap: 10px;
  }

  .brand img {
    max-width: 190px;
  }

  .gallery-meta {
    text-align: right;
    align-self: center;
  }

  h1 {
    font-size: 16px;
  }

  p {
    font-size: 12px;
  }

  .actions {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .icon-button {
    min-height: 38px;
    padding: 0 10px;
    grid-template-columns: 20px minmax(0, 1fr) 20px;
    column-gap: 4px;
  }

  .icon-button::after {
    width: 20px;
  }

  .icon-button i {
    justify-self: start;
    font-size: 15px;
  }

  .icon-button span {
    font-size: 13px;
  }

  main {
    padding: 0;
  }

  .masonry {
    column-count: 2;
    column-gap: 3px;
  }

  .photo-card {
    margin: 0px;
  }

  .lightbox {
    padding: 0;
  }

  .lightbox img,
  .lightbox video {
    width: 100vw;
    height: 100dvh;
  }

  .lightbox-nav {
    width: 42px;
    height: 42px;
    font-size: 30px;
  }

  .lightbox-close,
  .lightbox-download {
    font-size: 14px;
  }

  .lightbox-close {
    width: 46px;
    height: 46px;
    font-size: 27px;
  }

  .lightbox-download {
    min-height: 36px;
    padding: 0 8px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .lightbox {
    padding: 0;
  }

  .lightbox img,
  .lightbox video {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    padding: 0;
  }

  .lightbox-nav {
    align-self: center;
  }

  .lightbox-prev {
    left: max(4px, env(safe-area-inset-left));
  }

  .lightbox-next {
    right: max(4px, env(safe-area-inset-right));
  }

  .lightbox-download {
    width: auto;
    min-width: 0;
    background: rgba(19, 37, 50, .82);
    font-size: 13px;
  }

  .lightbox-close {
    width: 42px;
    height: 42px;
    padding: 0;
    background: rgba(3, 10, 14, .5);
    font-size: 26px;
  }

  .lightbox-download {
    min-height: 32px;
    padding: 0 9px;
  }
}

@media (max-width: 430px) {
  .masonry {
    column-count: 1;
  }
}
