:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  --background: #151813;
  --surface: #1a1e17;
  --text: #f4f2e9;
  --muted: #bfc2b1;
  --accent: #e2bf86;
  --rule: #383c31;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--background);
}

button { font: inherit; }
[hidden] { display: none !important; }

.gallery {
  --edge: clamp(15px, 2.5vw, 34px);
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.brand {
  position: absolute;
  z-index: 1;
  top: var(--edge);
  left: var(--edge);
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 6px 15px 8px;
  border: 1px solid #eee6d15e;
  border-radius: 8px;
  background: #171b14e8;
  pointer-events: none;
}

.brand h1 {
  margin: 0;
  font: normal clamp(1.5rem, 2.45vw, 2.15rem)/1.04 var(--serif);
  letter-spacing: -.042em;
  white-space: nowrap;
}

.brand h1 span {
  color: var(--accent);
  font-style: italic;
}

.rail {
  position: absolute;
  z-index: 2;
  top: var(--edge);
  right: var(--edge);
  width: clamp(8rem, 13vw, 10.5rem);
}

.rail-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid #eee6d15e;
  border-radius: 8px;
  background: #171b14f5;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  transition: border-color .18s ease;
}

.rail-toggle::-webkit-details-marker { display: none; }
.rail-toggle:hover,
.rail[open] .rail-toggle { border-color: var(--accent); }

.rail-chevron {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border: solid var(--accent);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .18s ease;
}

.rail[open] .rail-chevron { transform: translateY(2px) rotate(225deg); }

@media (prefers-reduced-motion: no-preference) {
  .rail:not([open]) .rail-chevron {
    animation: hint-down 2.2s ease-in-out infinite;
  }
  @keyframes hint-down {
    0%, 65%, 100% { transform: translateY(-2px) rotate(45deg); opacity: 1; }
    32% { transform: translateY(1px) rotate(45deg); opacity: .65; }
  }
}

.scenes {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  width: min(18.5rem, calc(100vw - var(--edge) * 2));
  max-height: min(34rem, calc(100vh - var(--edge) * 2 - 64px));
  max-height: min(34rem, calc(100dvh - var(--edge) * 2 - 64px));
  margin: 0;
  padding: 11px;
  border: 1px solid #c6b79366;
  border-radius: 10px;
  background: #1a1e17fa;
  box-shadow: 0 12px 28px #090b0773;
  list-style: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #8b806a var(--surface);
  scrollbar-width: thin;
}

.rail:not([open]) .scenes { display: none; }
.rail[open] .scenes { animation: reveal-scenes .18s ease-out both; }

@keyframes reveal-scenes {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: end;
  width: 100%;
  aspect-ratio: 2.43;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid #6c7060;
  border-radius: 5px;
  background: #30352b;
  color: #fffdf6;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.scene::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(0deg, #080a07e8, #080a0729 69%, #080a0717);
  content: "";
}

.scene img {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity .18s ease, transform .24s ease;
}

.scene:hover { border-color: #f0dbb9; }
.scene:hover img { transform: scale(1.045); }

.scene[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.scene[aria-pressed="true"] .scene-label { color: #ffddb0; }

.scene-label {
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .01em;
}

.rail-toggle:focus-visible,
.scene:focus-visible,
.fullscreen:focus-visible {
  outline: 2px solid #fff8df;
  outline-offset: 2px;
}


.viewer {
  position: absolute;
  inset: 0;
  background: #20271d;
  overflow: hidden;
}

.poster,
.viewer iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.poster { object-fit: cover; }

.viewer iframe {
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease-in;
}

.viewer[data-loaded="true"] iframe {
  opacity: 1;
  pointer-events: auto;
}

.viewer-top,
.viewer-bottom {
  position: absolute;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.viewer-top {
  top: calc(var(--edge) + 59px);
  align-items: start;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 var(--edge);
}

.view-mode,
.loading {
  border: 1px solid #f1f1db55;
  border-radius: 999px;
  background: #171e16d9;
  color: #fffaf0;
}

.view-mode {
  padding: 7px 13px;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .06em;
}

.loading {
  max-width: 12rem;
  padding: 7px 12px;
  font-size: .875rem;
  line-height: 1.3;
  text-align: center;
}

.viewer-bottom {
  bottom: 0;
  align-items: end;
  gap: 10px;
  padding: clamp(22px, 3.2vw, 48px) clamp(15px, 2.5vw, 34px);
  padding-top: clamp(42px, 8vw, 115px);
  background: linear-gradient(0deg, #0b100ae6 0%, #0b100a73 48%, transparent 100%);
}

.view-info h2 {
  margin: 0 0 4px;
  font: normal clamp(1.5rem, 3.1vw, 3.25rem)/1.04 var(--serif);
  letter-spacing: -.025em;
}

.view-info p {
  margin: 8px 0 0;
  color: #f7f4e9;
  font-size: clamp(.875rem, 1.15vw, 1rem);
}

.fullscreen {
  flex: 0 0 auto;
  display: grid;
  width: 48px;
  height: 48px;
  justify-items: center;
  align-items: center;
  padding: 0;
  border: 1px solid #f1f1db82;
  border-radius: 50%;
  background: #171e16d9;
  color: #fffaf0;
  cursor: pointer;
  pointer-events: auto;
}

.fullscreen:hover,
.fullscreen[aria-pressed="true"] {
  border-color: var(--accent);
  background: #22281f;
  color: var(--accent);
}

.fullscreen-icon {
  width: 17px;
  height: 17px;
  background: linear-gradient(currentColor, currentColor) left top / 6px 1.5px,
    linear-gradient(currentColor, currentColor) right top / 6px 1.5px,
    linear-gradient(currentColor, currentColor) left bottom / 6px 1.5px,
    linear-gradient(currentColor, currentColor) right bottom / 6px 1.5px,
    linear-gradient(currentColor, currentColor) left top / 1.5px 6px,
    linear-gradient(currentColor, currentColor) right top / 1.5px 6px,
    linear-gradient(currentColor, currentColor) left bottom / 1.5px 6px,
    linear-gradient(currentColor, currentColor) right bottom / 1.5px 6px;
  background-repeat: no-repeat;
}

noscript {
  position: fixed;
  right: 16px;
  bottom: 120px;
  left: 16px;
  padding: 12px;
  border: 1px solid var(--rule);
  background: var(--background);
  text-align: center;
}

@media (max-width: 720px) {
  .gallery { --edge: 12px; }
  .brand { min-height: 44px; padding: 6px 10px 8px; }
  .brand h1 { font-size: clamp(1.2rem, 5vw, 1.6rem); }
  .rail { width: 7.5rem; }
  .rail-toggle { min-height: 44px; padding: 9px 11px; font-size: .875rem; }
  .viewer-top { top: calc(var(--edge) + 54px); }
  .scenes { width: min(15rem, calc(100vw - var(--edge) * 2)); padding: 9px; }
  .scene { padding: 7px 9px; }
  .scene-label { font-size: .875rem; }
  .view-info h2 { font-size: clamp(1.125rem, 5vw, 2rem); }
  .view-info p { margin-top: 4px; font-size: .875rem; }
  .viewer-bottom { padding-right: var(--edge); padding-left: var(--edge); }
  .fullscreen { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { animation: none !important; transition: none !important; }
}


.help-trigger, .navigation-help button {
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 9px 17px;
  color: var(--text);
  background: #1a1e17f5;
  font: 600 .92rem/1.2 "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}
.help-trigger {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  min-height: 44px;
  box-shadow: 0 3px 14px #0b100a55;
}
.help-trigger.in-corner {
  top: calc(var(--edge) + 59px);
  left: calc(var(--edge) + 68px);
  transform: none;
  min-height: 0;
  padding: 7px 13px;
  font-size: .875rem;
}
.viewer[data-loaded="false"] .help-trigger.in-corner { visibility: hidden; }
.navigation-help {
  box-sizing: border-box;
  width: min(24rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid #b6996c;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 65px #0007;
}
.navigation-help::backdrop { background: #0a100a82; }
.navigation-help h2 { margin: 0 0 1.1rem; font: normal 1.85rem/1.1 var(--serif); }
.navigation-help p { margin: .75rem 0; font-size: .96rem; line-height: 1.45; }
.navigation-help strong { color: #ebcea0; }
.navigation-help form { margin: 1.15rem 0 0; text-align: right; }
.navigation-help button { min-height: 44px; }
.help-trigger:focus-visible, .navigation-help button:focus-visible { outline: 2px solid #fff8df; outline-offset: 3px; }
@media (max-width: 720px) {
  .help-trigger.in-corner { top: calc(var(--edge) + 54px); }
}
