* { box-sizing: border-box; }
body { margin: 0; background: #f2f2f2; color: #222; font: 16px Arial, sans-serif; }
header { background: #24476f; color: white; padding: 24px 15px 14px; text-align: center; }
h1 { margin: 0 0 7px; font-size: 30px; }
header p { margin: 0 0 20px; }
nav { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
nav a { color: white; text-decoration: none; padding: 9px 13px; border-radius: 4px; }
nav a:hover, nav a.active { background: #fff; color: #24476f; }
main { max-width: 1000px; margin: 25px auto; padding: 0 16px; min-height: 65vh; }
h2 { margin-bottom: 8px; }
.page > p { color: #555; }
.random-wrap { display: flex; justify-content: center; align-items: center; margin: 25px 0 15px; min-height: 300px; }
.photo-click { border: 0; background: transparent; cursor: pointer; padding: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.photo-click img { max-width: 100%; max-height: 65vh; width: auto; height: auto; object-fit: contain; border-radius: 3px; box-shadow: 0 3px 12px #0002; }
#randomEmpty { padding: 55px 15px; border: 2px dashed #aaa; color: #666; }
.controls { text-align: center; }
button { font: inherit; }
.controls button, #closeDialog { background: #24476f; border: 0; color: white; border-radius: 4px; padding: 11px 16px; cursor: pointer; }
.controls button:hover { background: #183553; }
#randomCount { display: block; margin-top: 12px; color: #666; font-size: 14px; }
.gallery { columns: 3 220px; column-gap: 14px; margin-top: 22px; }
.gallery button { display: block; width: 100%; margin: 0 0 14px; padding: 0; background: none; border: 0; cursor: zoom-in; break-inside: avoid; }
.gallery img { width: 100%; height: auto; display: block; border-radius: 3px; }
.gallery img:hover { opacity: .85; }
#classList { line-height: 2.1; padding-left: 26px; }
footer { padding: 20px; text-align: center; color: #777; font-size: 13px; }
dialog { border: 0; border-radius: 5px; padding: 15px; max-width: 95vw; max-height: 95vh; background: #222; color: white; }
dialog::backdrop { background: #000b; }
#closeDialog { display: block; margin: 0 0 10px auto; }
#dialogImage { display: block; max-width: 88vw; max-height: 78vh; width: auto; height: auto; object-fit: contain; }
@media(max-width: 500px) { h1 { font-size: 25px; } .random-wrap { min-height: 180px; } }
