.media-gallery-page { margin: 0; }
.gallery-main {
 --gallery-rows: 3;
 display: flex;
 flex-direction: column;
 height: calc(100svh - var(--gallery-header-height, 80px));
 min-height: 360px;
 color: #f4f5f7;
 background: #080a0d;
}
.gallery-main button { font: inherit; cursor: pointer; }
.gallery-main button:focus-visible,
.gallery-viewport:focus-visible,
.media-tile:focus-visible { outline: 2px solid #c7ef9a; outline-offset: -3px; }
.gallery-intro { display: flex; align-items: center; gap: 20px; padding: 12px 20px; flex-shrink: 0; }
.gallery-intro h1 { margin: 0; font-size: 20px; font-weight: 700; }
.gallery-help { margin: 0; color: #a7afb9; font-size: 11px; }
#gallery-shuffle { margin-left: auto; padding: 8px 16px; border: 0; border-radius: 24px; background: #c7ef9a; color: #152209; font-size: 12px; font-weight: bold; }
#gallery-shuffle:disabled { opacity: .4; cursor: default; }
.gallery-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.gallery-stage::before,
.gallery-stage::after { content: ''; position: absolute; inset: 0 auto 14px 0; width: 5vw; z-index: 2; pointer-events: none; background: linear-gradient(90deg, #080a0d, transparent); }
.gallery-stage::after { left: auto; right: 0; transform: rotate(180deg); }
.gallery-viewport { height: 100%; overflow-x: scroll; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: auto; scrollbar-color: #737d89 #171d26; padding: 0; }
.gallery-viewport::-webkit-scrollbar { height: 14px; }
.gallery-viewport::-webkit-scrollbar-track { background: #171d26; }
.gallery-viewport::-webkit-scrollbar-thumb { background: #737d89; border: 3px solid #171d26; border-radius: 10px; }
.gallery-viewport::-webkit-scrollbar-thumb:hover { background: #a7afb9; }
.gallery-grid {
 display: grid;
 grid-auto-flow: column;
 grid-template-rows: repeat(var(--gallery-rows), minmax(0, 1fr));
 grid-auto-columns: var(--gallery-tile-width, 300px);
 gap: 0;
 width: max-content;
 height: 100%;
}
.media-tile { display: block; text-decoration: none; cursor: pointer; position: relative; overflow: hidden; min-width: 0; min-height: 0; border: 0; border-radius: 0; background: #12171f; padding: 0; isolation: isolate; color: white; }
.media-tile img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.media-tile:hover img,
.media-tile:focus-visible img { transform: scale(1.025); }
.gallery-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px; flex-shrink: 0; font-size: 10px; color: #a7afb9; }
.gallery-controls { display: flex; align-items: center; gap: 18px; }
.gallery-controls button { border: 1px solid #ffffff25; background: transparent; color: white; border-radius: 50%; width: 30px; height: 30px; }
.gallery-controls button:disabled { opacity: .3; cursor: default; }
.gallery-empty { width: min(90vw, 640px); padding: 48px 24px; color: #a7afb9; line-height: 1.8; }
@media (min-height: 1000px) { .gallery-main { --gallery-rows: 4; } }
@media (max-width: 640px) {
 .gallery-intro { padding: 10px 12px; gap: 12px; flex-wrap: wrap; }
 .gallery-intro h1 { font-size: 16px; }
 .gallery-help { font-size: 10px; order: 3; width: 100%; }
 #gallery-shuffle { padding: 7px 12px; }
 .gallery-bottom { padding: 8px 12px; }
 .gallery-controls { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { .media-tile img { transition: none; } }

.media-preview { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; opacity: 0; transition: opacity .15s ease-out; }
.media-tile.is-previewing .media-preview { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .media-preview { transition: none; } }

#gallery-detail { width: min(92vw, 960px); max-height: 90svh; padding: 16px; border: 1px solid #ffffff30; border-radius: 14px; background: #10141a; color: white; overflow: auto; }
#gallery-detail::backdrop { background: #000c; backdrop-filter: blur(8px); }
.gallery-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
#gallery-detail-title { font-size: 16px; font-weight: bold; }
#gallery-close { flex-shrink: 0; width: 36px; height: 36px; border: 1px solid #ffffff40; border-radius: 50%; background: #0009; color: white; cursor: pointer; }
#gallery-detail-video { display: block; width: 100%; max-height: 72svh; background: black; }
#gallery-video-status { margin-top: 8px; font-size: 13px; }
