#main { width: min(1120px, calc(100% - 32px)); }
#main h1 { max-width: none; }
#gallery-admin, .gallery-album { padding: 24px; margin: 28px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
#gallery-create, .gallery-upload { display: grid; gap: 12px; margin-bottom: 20px; }
#gallery-create { max-width: 540px; }
#main input { padding: 12px; width: 100%; min-width: 0; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
#main label { font-weight: bold; }
#main .button { background: var(--blue); color: white; cursor: pointer; justify-self: start; transition: background-color 150ms; }
#main .button:hover { background: var(--blue-dark); }
#main .sign-out { background: var(--red); }
#main .sign-out:hover { background: #941f28; }
#main button:disabled { opacity: .6; cursor: wait; }
.gallery-album h2 { overflow-wrap: anywhere; }
.gallery-album time { display: block; margin: 10px 0 20px; color: var(--muted); }
.gallery-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 16px; margin-bottom: 20px; }
.gallery-photo { border: 0; padding: 0; background: transparent; cursor: zoom-in; border-radius: 10px; overflow: hidden; }
.gallery-photo img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
#photo-viewer { max-width: 94vw; max-height: 94vh; border: 0; border-radius: 12px; padding: 16px; }
#photo-viewer::backdrop { background: #000b; }
#full-photo { max-width: 85vw; max-height: 78vh; object-fit: contain; }
#close-photo { display: block; margin: 0 0 12px auto; padding: 8px 16px; cursor: pointer; }

/* Keep the admin session action beneath all gallery content. */
#main { display: flex; flex-direction: column; min-height: 70vh; }
#gallery-sign-out { margin-top: auto; padding-top: 32px; border-top: 1px solid var(--line); }
.gallery-photo { position: relative; }
.gallery-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .35); color: white; font-size: 2.5rem; font-weight: 700; cursor: pointer; transition: background-color 150ms; }
.gallery-photo:hover .gallery-more { background: rgba(0, 0, 0, .48); }
.gallery-upload { margin-top: 24px; }
.gallery-photo:focus-visible, #main .button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

#main .gallery-collapse { display: flex; margin-left: auto; background: #e7e9ec; color: var(--ink); }
#main .gallery-collapse:hover { background: #cdd2d8; }

.gallery-tile { min-width: 0; position: relative; }
.gallery-tile .gallery-photo { display: block; width: 100%; }
#main .gallery-remove { background: var(--red); color: white; margin-top: 10px; }
#main .gallery-remove:hover { background: #941f28; }
.gallery-remove-photo { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .65); color: white; font-size: 25px; line-height: 1; cursor: pointer; transition: background-color 150ms; }
.gallery-remove-photo:hover { background: var(--red); }
.gallery-remove-photo:focus-visible { outline: 3px solid white; outline-offset: 2px; }

@media (max-width: 720px) {
  #photo-viewer[open] { display: flex; flex-direction: column; }
  #full-photo { order: 0; min-height: 0; }
  #close-photo { order: 1; flex-shrink: 0; align-self: flex-end; margin: 12px 0 0; min-height: 44px; }
  .gallery-album { padding: 12px; }
  .gallery-photos { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .gallery-photo { border-radius: 6px; }
  .gallery-photo img { aspect-ratio: 1; }
  .gallery-more { font-size: 1.1rem; }
  .gallery-remove-photo { top: 2px; right: 2px; width: 24px; height: 24px; font-size: 20px; }
}
