#gallery [hidden],
.media-dialog [hidden] {
  display: none;
}

.media-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 14px;
}

.media-toolbar label,
.media-notice,
.media-category,
.media-dialog-footer {
  color: #c4b99e;
  font: 11px/1.5 'DM Mono', monospace;
  letter-spacing: .08em;
}

.media-toolbar label,
.media-category {
  text-transform: uppercase;
}

.media-toolbar select,
.media-dialog button {
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #d4af3769;
  border-radius: 4px;
  background: #151319;
  color: #ffe29a;
  color-scheme: dark;
  font: inherit;
}

.media-toolbar select {
  max-width: min(100%, 26rem);
}

.media-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid #d4af373d;
  background: #d4af3708;
}

.media-notice p,
.media-dialog p {
  margin: 0;
}

.media-notice--error {
  border-color: #e68c5360;
}

.media-notice--populated {
  padding: 0;
  border: 0;
  background: transparent;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: clamp(12px, 2vw, 24px);
  padding: 0;
  margin: 0;
  list-style: none;
}

.media-item {
  min-width: 0;
}

.media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid #d4af3740;
  border-radius: 4px;
  background: #0a0a0c;
  color: #f8f4e8;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease;
}

.media-card:hover,
.media-dialog button:not(:disabled):hover {
  border-color: #d4af37;
}

@media (hover: hover) {
  .media-card:hover { transform: translateY(-2px); }
}

.media-card:focus-visible,
.media-toolbar select:focus-visible,
.media-dialog button:focus-visible {
  outline: 2px solid #ffe497;
  outline-offset: 3px;
}

.media-artwork {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 4 / 3;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid #d4af3738;
  background: radial-gradient(ellipse at 80% 15%, #24433162, transparent 66%), linear-gradient(135deg, #211a13, #101013);
}

.media-artwork .media-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.media-artwork--loaded .media-photo {
  opacity: 1;
}

.media-placeholder {
  color: #c6bca9;
  font: 11px/1.5 'DM Mono', monospace;
  letter-spacing: .08em;
}

.media-details {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 12px 44px 15px 13px;
  overflow-wrap: anywhere;
}

.media-category {
  color: #c8b172;
}

.media-title {
  font-size: clamp(15px, 2vw, 19px);
  font-weight: 750;
}

.media-expand {
  position: absolute;
  right: 14px;
  bottom: 14px;
  color: #edc662;
  font-size: 23px;
  line-height: 1;
}

.media-dialog {
  box-sizing: border-box;
  width: min(65rem, calc(100% - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 0;
  border: 1px solid #d4af3778;
  border-radius: 8px;
  background: #0a0a0c;
  color: #f8f4e8;
  box-shadow: 0 24px 74px #000a;
}

.media-dialog::backdrop {
  background: #030303e0;
}

.media-dialog-header,
.media-dialog-footer {
  display: grid;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
}

.media-dialog-header {
  grid-template-columns: minmax(0, 1fr) auto;
}

.media-dialog-header h2 {
  margin: 0;
  color: #ffe19b;
  font-size: clamp(16px, 2.8vw, 22px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#lightbox-close {
  min-width: 44px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.media-dialog-stage {
  position: relative;
  display: grid;
  width: 100%;
  height: min(67vh, 45rem);
  height: min(67dvh, 45rem);
  place-items: center;
  overflow: hidden;
  background: #050506;
  border-block: 1px solid #d4af3738;
}

.media-dialog-stage .media-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
}

.media-dialog-stage .media-photo--loaded {
  opacity: 1;
}

.media-dialog-status {
  color: #c4b99e;
}

.media-dialog-footer {
  grid-template-columns: 1fr auto 1fr;
  text-align: center;
}

#lightbox-prev { justify-self: start; }
#lightbox-next { justify-self: end; }
.media-dialog button { cursor: pointer; }
.media-dialog button:disabled { opacity: .48; cursor: default; }

@media (max-width: 360px) {
  .media-dialog-footer button { min-width: 44px; }
  .media-dialog-footer button span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .media-card { transition: none; }
  .media-card:hover { transform: none; }
}
